Changeset View
Changeset View
Standalone View
Standalone View
source/blender/simulation/intern/SIM_mass_spring.cpp
| Show First 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | int SIM_cloth_solver_init(Object *UNUSED(ob), ClothModifierData *clmd) | ||||
| const float ZERO[3] = {0.0f, 0.0f, 0.0f}; | const float ZERO[3] = {0.0f, 0.0f, 0.0f}; | ||||
| Implicit_Data *id; | Implicit_Data *id; | ||||
| unsigned int i, nondiag; | unsigned int i, nondiag; | ||||
| nondiag = cloth_count_nondiag_blocks(cloth); | nondiag = cloth_count_nondiag_blocks(cloth); | ||||
| cloth->implicit = id = SIM_mass_spring_solver_create(cloth->mvert_num, nondiag); | cloth->implicit = id = SIM_mass_spring_solver_create(cloth->mvert_num, nondiag); | ||||
| for (i = 0; i < cloth->mvert_num; i++) { | for (i = 0; i < cloth->mvert_num; i++) { | ||||
| SIM_mass_spring_set_vertex_mass(id, i, verts[i].mass); | SIM_mass_spring_set_implicit_vertex_mass(id, i, verts[i].mass); | ||||
| } | } | ||||
| for (i = 0; i < cloth->mvert_num; i++) { | for (i = 0; i < cloth->mvert_num; i++) { | ||||
| SIM_mass_spring_set_motion_state(id, i, verts[i].x, ZERO); | SIM_mass_spring_set_motion_state(id, i, verts[i].x, ZERO); | ||||
| } | } | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| void SIM_mass_spring_set_implicit_vertex_mass(Implicit_Data *data, int index, float mass){ | |||||
| SIM_mass_spring_set_vertex_mass(data, index, mass); | |||||
| } | |||||
| void SIM_cloth_solver_free(ClothModifierData *clmd) | void SIM_cloth_solver_free(ClothModifierData *clmd) | ||||
| { | { | ||||
| Cloth *cloth = clmd->clothObject; | Cloth *cloth = clmd->clothObject; | ||||
| if (cloth->implicit) { | if (cloth->implicit) { | ||||
| SIM_mass_spring_solver_free(cloth->implicit); | SIM_mass_spring_solver_free(cloth->implicit); | ||||
| cloth->implicit = nullptr; | cloth->implicit = nullptr; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,143 Lines • Show Last 20 Lines | |||||