Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_cloth.c
| Show First 20 Lines • Show All 633 Lines • ▼ Show 20 Lines | |||||
| void SCULPT_do_cloth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) | void SCULPT_do_cloth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) | ||||
| { | { | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| Brush *brush = BKE_paint_brush(&sd->paint); | Brush *brush = BKE_paint_brush(&sd->paint); | ||||
| const int totverts = SCULPT_vertex_count_get(ss); | const int totverts = SCULPT_vertex_count_get(ss); | ||||
| /* In the first brush step of each symmetry pass, build the constraints for the vertices in all | /* In the first brush step of each symmetry pass, build the constraints for the vertices in all | ||||
| * nodes inside the simulation's limits. */ | * nodes inside the simulation's limits. */ | ||||
| /* Brush stroke types that restore the mesh on each brush step also need the cloth sim data to be | /* Brushes that use anchored strokes and restore the mesh can't rely on symmetry passes and steps | ||||
| * created on each step. */ | * count as it is always the first step, so the simulation needs to be created when it does not | ||||
| * exist for this stroke. */ | |||||
| if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache) || !ss->cache->cloth_sim) { | if (SCULPT_stroke_is_first_brush_step_of_symmetry_pass(ss->cache) || !ss->cache->cloth_sim) { | ||||
| /* The simulation structure only needs to be created on the first symmetry pass. */ | /* The simulation structure only needs to be created on the first symmetry pass. */ | ||||
| if (SCULPT_stroke_is_first_brush_step(ss->cache)) { | if (SCULPT_stroke_is_first_brush_step(ss->cache) || !ss->cache->cloth_sim) { | ||||
| ss->cache->cloth_sim = cloth_brush_simulation_create( | ss->cache->cloth_sim = cloth_brush_simulation_create( | ||||
| ss, brush->cloth_mass, brush->cloth_damping); | ss, brush->cloth_mass, brush->cloth_damping); | ||||
| for (int i = 0; i < totverts; i++) { | for (int i = 0; i < totverts; i++) { | ||||
| copy_v3_v3(ss->cache->cloth_sim->prev_pos[i], SCULPT_vertex_co_get(ss, i)); | copy_v3_v3(ss->cache->cloth_sim->prev_pos[i], SCULPT_vertex_co_get(ss, i)); | ||||
| copy_v3_v3(ss->cache->cloth_sim->init_pos[i], SCULPT_vertex_co_get(ss, i)); | copy_v3_v3(ss->cache->cloth_sim->init_pos[i], SCULPT_vertex_co_get(ss, i)); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 334 Lines • Show Last 20 Lines | |||||