Changeset View
Changeset View
Standalone View
Standalone View
source/blender/physics/intern/BPH_mass_spring.cpp
| Context not available. | |||||
| bool do_extra_solve; | bool do_extra_solve; | ||||
| int i; | int i; | ||||
| if (!(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED)) | if (!(clmd->coll_parms->flags & (CLOTH_COLLSETTINGS_FLAG_ENABLED | CLOTH_COLLSETTINGS_FLAG_SELF))) | ||||
| return; | return; | ||||
| if (!clmd->clothObject->bvhtree) | if (!clmd->clothObject->bvhtree) | ||||
| return; | return; | ||||
| Context not available. | |||||
| float newv[3]; | float newv[3]; | ||||
| if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) | if ((clmd->sim_parms->vgroup_mass > 0) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) | ||||
| continue; | continue; | ||||
| BPH_mass_spring_set_new_position(id, i, verts[i].tx); | BPH_mass_spring_set_new_position(id, i, verts[i].tx); | ||||
| Context not available. | |||||
| clmd->solver_result = (ClothSolverResult *)MEM_callocN(sizeof(ClothSolverResult), "cloth solver result"); | clmd->solver_result = (ClothSolverResult *)MEM_callocN(sizeof(ClothSolverResult), "cloth solver result"); | ||||
| cloth_clear_result(clmd); | cloth_clear_result(clmd); | ||||
| if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { /* do goal stuff */ | if (clmd->sim_parms->vgroup_mass > 0) { /* Do goal stuff. */ | ||||
| for (i = 0; i < mvert_num; i++) { | for (i = 0; i < mvert_num; i++) { | ||||
| // update velocities with constrained velocities from pinned verts | // update velocities with constrained velocities from pinned verts | ||||
| if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) { | if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) { | ||||
| Context not available. | |||||
| /* initialize forces to zero */ | /* initialize forces to zero */ | ||||
| BPH_mass_spring_clear_forces(id); | BPH_mass_spring_clear_forces(id); | ||||
| // damping velocity for artistic reasons | |||||
| // this is a bad way to do it, should be removed imo - lukas_t | |||||
| if (clmd->sim_parms->vel_damping != 1.0f) { | |||||
| for (i = 0; i < mvert_num; i++) { | |||||
| float v[3]; | |||||
| BPH_mass_spring_get_motion_state(id, i, NULL, v); | |||||
| mul_v3_fl(v, clmd->sim_parms->vel_damping); | |||||
| BPH_mass_spring_set_velocity(id, i, v); | |||||
| } | |||||
| } | |||||
| // calculate forces | // calculate forces | ||||
| cloth_calc_force(scene, clmd, frame, effectors, step); | cloth_calc_force(scene, clmd, frame, effectors, step); | ||||
| Context not available. | |||||
| /* move pinned verts to correct position */ | /* move pinned verts to correct position */ | ||||
| for (i = 0; i < mvert_num; i++) { | for (i = 0; i < mvert_num; i++) { | ||||
| if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { | if (clmd->sim_parms->vgroup_mass > 0) { | ||||
| if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) { | if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) { | ||||
| float x[3]; | float x[3]; | ||||
| /* divide by time_scale to prevent pinned vertices' delta locations from being multiplied */ | /* divide by time_scale to prevent pinned vertices' delta locations from being multiplied */ | ||||
| Context not available. | |||||