Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/cloth.c
| Show First 20 Lines • Show All 256 Lines • ▼ Show 20 Lines | static bool do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int framenr) | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| static int do_step_cloth( | static int do_step_cloth( | ||||
| Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, Mesh *result, int framenr) | Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, Mesh *result, int framenr) | ||||
| { | { | ||||
| /* simulate 1 frame forward */ | |||||
| ClothVertex *verts = NULL; | ClothVertex *verts = NULL; | ||||
| Cloth *cloth; | Cloth *cloth; | ||||
| ListBase *effectors = NULL; | ListBase *effectors = NULL; | ||||
| MVert *mvert; | MVert *mvert; | ||||
| unsigned int i = 0; | unsigned int i = 0; | ||||
| int ret = 0; | int ret = 0; | ||||
| bool vert_mass_changed = false; | |||||
| /* simulate 1 frame forward */ | |||||
| cloth = clmd->clothObject; | cloth = clmd->clothObject; | ||||
| verts = cloth->verts; | verts = cloth->verts; | ||||
| mvert = result->mvert; | mvert = result->mvert; | ||||
| vert_mass_changed = verts->mass != clmd->sim_parms->mass; | |||||
| /* force any pinned verts to their constrained location. */ | /* force any pinned verts to their constrained location. */ | ||||
| for (i = 0; i < clmd->clothObject->mvert_num; i++, verts++) { | for (i = 0; i < clmd->clothObject->mvert_num; i++, verts++) { | ||||
| /* save the previous position. */ | /* save the previous position. */ | ||||
| copy_v3_v3(verts->xold, verts->xconst); | copy_v3_v3(verts->xold, verts->xconst); | ||||
| copy_v3_v3(verts->txold, verts->x); | copy_v3_v3(verts->txold, verts->x); | ||||
| /* Get the current position. */ | /* Get the current position. */ | ||||
| copy_v3_v3(verts->xconst, mvert[i].co); | copy_v3_v3(verts->xconst, mvert[i].co); | ||||
| mul_m4_v3(ob->obmat, verts->xconst); | mul_m4_v3(ob->obmat, verts->xconst); | ||||
| if (vert_mass_changed) { | |||||
| verts->mass = clmd->sim_parms->mass; | |||||
| SIM_mass_spring_set_implicit_vertex_mass(cloth->implicit, i, verts->mass); | |||||
| } | |||||
| } | } | ||||
| effectors = BKE_effectors_create(depsgraph, ob, NULL, clmd->sim_parms->effector_weights, false); | effectors = BKE_effectors_create(depsgraph, ob, NULL, clmd->sim_parms->effector_weights, false); | ||||
| if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH) { | if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH) { | ||||
| cloth_update_verts(ob, clmd, result); | cloth_update_verts(ob, clmd, result); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,622 Lines • Show Last 20 Lines | |||||