Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_collision.c
| Show First 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | if (mesh_src) { | ||||
| } | } | ||||
| if (collmd->time_xnew == -1000) { /* first time */ | if (collmd->time_xnew == -1000) { /* first time */ | ||||
| collmd->x = MEM_dupallocN(BKE_mesh_verts(mesh_src)); /* frame start position */ | collmd->x = MEM_dupallocN(BKE_mesh_verts(mesh_src)); /* frame start position */ | ||||
| for (uint i = 0; i < mvert_num; i++) { | for (uint i = 0; i < mvert_num; i++) { | ||||
| /* we save global positions */ | /* we save global positions */ | ||||
| mul_m4_v3(ob->obmat, collmd->x[i].co); | mul_m4_v3(ob->object_to_world, collmd->x[i].co); | ||||
| } | } | ||||
| collmd->xnew = MEM_dupallocN(collmd->x); /* Frame end position. */ | collmd->xnew = MEM_dupallocN(collmd->x); /* Frame end position. */ | ||||
| collmd->current_x = MEM_dupallocN(collmd->x); /* Inter-frame. */ | collmd->current_x = MEM_dupallocN(collmd->x); /* Inter-frame. */ | ||||
| collmd->current_xnew = MEM_dupallocN(collmd->x); /* Inter-frame. */ | collmd->current_xnew = MEM_dupallocN(collmd->x); /* Inter-frame. */ | ||||
| collmd->current_v = MEM_dupallocN(collmd->x); /* Inter-frame. */ | collmd->current_v = MEM_dupallocN(collmd->x); /* Inter-frame. */ | ||||
| collmd->mvert_num = mvert_num; | collmd->mvert_num = mvert_num; | ||||
| Show All 22 Lines | else if (mvert_num == collmd->mvert_num) { | ||||
| collmd->time_x = collmd->time_xnew; | collmd->time_x = collmd->time_xnew; | ||||
| memcpy(collmd->xnew, BKE_mesh_verts(mesh_src), mvert_num * sizeof(MVert)); | memcpy(collmd->xnew, BKE_mesh_verts(mesh_src), mvert_num * sizeof(MVert)); | ||||
| bool is_static = true; | bool is_static = true; | ||||
| for (uint i = 0; i < mvert_num; i++) { | for (uint i = 0; i < mvert_num; i++) { | ||||
| /* we save global positions */ | /* we save global positions */ | ||||
| mul_m4_v3(ob->obmat, collmd->xnew[i].co); | mul_m4_v3(ob->object_to_world, collmd->xnew[i].co); | ||||
| /* detect motion */ | /* detect motion */ | ||||
| is_static = is_static && equals_v3v3(collmd->x[i].co, collmd->xnew[i].co); | is_static = is_static && equals_v3v3(collmd->x[i].co, collmd->xnew[i].co); | ||||
| } | } | ||||
| memcpy(collmd->current_xnew, collmd->x, mvert_num * sizeof(MVert)); | memcpy(collmd->current_xnew, collmd->x, mvert_num * sizeof(MVert)); | ||||
| memcpy(collmd->current_x, collmd->x, mvert_num * sizeof(MVert)); | memcpy(collmd->current_x, collmd->x, mvert_num * sizeof(MVert)); | ||||
| ▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines | |||||