Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/softbody.c')
-rw-r--r--source/blender/blenkernel/intern/softbody.c156
1 files changed, 78 insertions, 78 deletions
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index efe423ccfc5..70ed7a6b14c 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -255,8 +255,8 @@ typedef struct ccdf_minmax {
typedef struct ccd_Mesh {
int mvert_num, tri_num;
- const MVert *mvert;
- const MVert *mprevvert;
+ const float (*positions)[3];
+ const float (*positions_prev)[3];
const MVertTri *tri;
int safety;
ccdf_minmax *mima;
@@ -290,20 +290,20 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
pccd_M->safety = CCD_SAFETY;
pccd_M->bbmin[0] = pccd_M->bbmin[1] = pccd_M->bbmin[2] = 1e30f;
pccd_M->bbmax[0] = pccd_M->bbmax[1] = pccd_M->bbmax[2] = -1e30f;
- pccd_M->mprevvert = NULL;
+ pccd_M->positions_prev = NULL;
/* Blow it up with force-field ranges. */
hull = max_ff(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
/* Allocate and copy verts. */
- pccd_M->mvert = MEM_dupallocN(cmd->xnew);
+ pccd_M->positions = MEM_dupallocN(cmd->xnew);
/* note that xnew coords are already in global space, */
/* determine the ortho BB */
for (i = 0; i < pccd_M->mvert_num; i++) {
const float *v;
/* evaluate limits */
- v = pccd_M->mvert[i].co;
+ v = pccd_M->positions[i];
pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
@@ -325,7 +325,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
mima->minx = mima->miny = mima->minz = 1e30f;
mima->maxx = mima->maxy = mima->maxz = -1e30f;
- v = pccd_M->mvert[vt->tri[0]].co;
+ v = pccd_M->positions[vt->tri[0]];
mima->minx = min_ff(mima->minx, v[0] - hull);
mima->miny = min_ff(mima->miny, v[1] - hull);
mima->minz = min_ff(mima->minz, v[2] - hull);
@@ -333,7 +333,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
mima->maxy = max_ff(mima->maxy, v[1] + hull);
mima->maxz = max_ff(mima->maxz, v[2] + hull);
- v = pccd_M->mvert[vt->tri[1]].co;
+ v = pccd_M->positions[vt->tri[1]];
mima->minx = min_ff(mima->minx, v[0] - hull);
mima->miny = min_ff(mima->miny, v[1] - hull);
mima->minz = min_ff(mima->minz, v[2] - hull);
@@ -341,7 +341,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
mima->maxy = max_ff(mima->maxy, v[1] + hull);
mima->maxz = max_ff(mima->maxz, v[2] + hull);
- v = pccd_M->mvert[vt->tri[2]].co;
+ v = pccd_M->positions[vt->tri[2]];
mima->minx = min_ff(mima->minx, v[0] - hull);
mima->miny = min_ff(mima->miny, v[1] - hull);
mima->minz = min_ff(mima->minz, v[2] - hull);
@@ -381,19 +381,19 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
hull = max_ff(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
/* rotate current to previous */
- if (pccd_M->mprevvert) {
- MEM_freeN((void *)pccd_M->mprevvert);
+ if (pccd_M->positions_prev) {
+ MEM_freeN((void *)pccd_M->positions_prev);
}
- pccd_M->mprevvert = pccd_M->mvert;
+ pccd_M->positions_prev = pccd_M->positions;
/* Allocate and copy verts. */
- pccd_M->mvert = MEM_dupallocN(cmd->xnew);
+ pccd_M->positions = MEM_dupallocN(cmd->xnew);
/* note that xnew coords are already in global space, */
/* determine the ortho BB */
for (i = 0; i < pccd_M->mvert_num; i++) {
const float *v;
/* evaluate limits */
- v = pccd_M->mvert[i].co;
+ v = pccd_M->positions[i];
pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
@@ -403,7 +403,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
pccd_M->bbmax[2] = max_ff(pccd_M->bbmax[2], v[2] + hull);
/* evaluate limits */
- v = pccd_M->mprevvert[i].co;
+ v = pccd_M->positions_prev[i];
pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
@@ -420,8 +420,8 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
mima->minx = mima->miny = mima->minz = 1e30f;
mima->maxx = mima->maxy = mima->maxz = -1e30f;
- /* mvert */
- v = pccd_M->mvert[vt->tri[0]].co;
+ /* positions */
+ v = pccd_M->positions[vt->tri[0]];
mima->minx = min_ff(mima->minx, v[0] - hull);
mima->miny = min_ff(mima->miny, v[1] - hull);
mima->minz = min_ff(mima->minz, v[2] - hull);
@@ -429,7 +429,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
mima->maxy = max_ff(mima->maxy, v[1] + hull);
mima->maxz = max_ff(mima->maxz, v[2] + hull);
- v = pccd_M->mvert[vt->tri[1]].co;
+ v = pccd_M->positions[vt->tri[1]];
mima->minx = min_ff(mima->minx, v[0] - hull);
mima->miny = min_ff(mima->miny, v[1] - hull);
mima->minz = min_ff(mima->minz, v[2] - hull);
@@ -437,7 +437,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
mima->maxy = max_ff(mima->maxy, v[1] + hull);
mima->maxz = max_ff(mima->maxz, v[2] + hull);
- v = pccd_M->mvert[vt->tri[2]].co;
+ v = pccd_M->positions[vt->tri[2]];
mima->minx = min_ff(mima->minx, v[0] - hull);
mima->miny = min_ff(mima->miny, v[1] - hull);
mima->minz = min_ff(mima->minz, v[2] - hull);
@@ -445,8 +445,8 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
mima->maxy = max_ff(mima->maxy, v[1] + hull);
mima->maxz = max_ff(mima->maxz, v[2] + hull);
- /* mprevvert */
- v = pccd_M->mprevvert[vt->tri[0]].co;
+ /* positions_prev */
+ v = pccd_M->positions_prev[vt->tri[0]];
mima->minx = min_ff(mima->minx, v[0] - hull);
mima->miny = min_ff(mima->miny, v[1] - hull);
mima->minz = min_ff(mima->minz, v[2] - hull);
@@ -454,7 +454,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
mima->maxy = max_ff(mima->maxy, v[1] + hull);
mima->maxz = max_ff(mima->maxz, v[2] + hull);
- v = pccd_M->mprevvert[vt->tri[1]].co;
+ v = pccd_M->positions_prev[vt->tri[1]];
mima->minx = min_ff(mima->minx, v[0] - hull);
mima->miny = min_ff(mima->miny, v[1] - hull);
mima->minz = min_ff(mima->minz, v[2] - hull);
@@ -462,7 +462,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
mima->maxy = max_ff(mima->maxy, v[1] + hull);
mima->maxz = max_ff(mima->maxz, v[2] + hull);
- v = pccd_M->mprevvert[vt->tri[2]].co;
+ v = pccd_M->positions_prev[vt->tri[2]];
mima->minx = min_ff(mima->minx, v[0] - hull);
mima->miny = min_ff(mima->miny, v[1] - hull);
mima->minz = min_ff(mima->minz, v[2] - hull);
@@ -476,10 +476,10 @@ static void ccd_mesh_free(ccd_Mesh *ccdm)
{
/* Make sure we're not nuking objects we don't know. */
if (ccdm && (ccdm->safety == CCD_SAFETY)) {
- MEM_freeN((void *)ccdm->mvert);
+ MEM_freeN((void *)ccdm->positions);
MEM_freeN((void *)ccdm->tri);
- if (ccdm->mprevvert) {
- MEM_freeN((void *)ccdm->mprevvert);
+ if (ccdm->positions_prev) {
+ MEM_freeN((void *)ccdm->positions_prev);
}
MEM_freeN(ccdm->mima);
MEM_freeN(ccdm);
@@ -1068,12 +1068,12 @@ static int sb_detect_face_pointCached(const float face_v1[3],
{
/* only with deflecting set */
if (ob->pd && ob->pd->deflect) {
- const MVert *mvert = NULL;
- const MVert *mprevvert = NULL;
+ const float(*positions)[3] = NULL;
+ const float(*positions_prev)[3] = NULL;
if (ccdm) {
- mvert = ccdm->mvert;
+ positions = ccdm->positions;
a = ccdm->mvert_num;
- mprevvert = ccdm->mprevvert;
+ positions_prev = ccdm->positions_prev;
outerfacethickness = ob->pd->pdef_sboft;
if ((aabbmax[0] < ccdm->bbmin[0]) || (aabbmax[1] < ccdm->bbmin[1]) ||
(aabbmax[2] < ccdm->bbmin[2]) || (aabbmin[0] > ccdm->bbmax[0]) ||
@@ -1091,12 +1091,12 @@ static int sb_detect_face_pointCached(const float face_v1[3],
}
/* Use mesh. */
- if (mvert) {
+ if (positions) {
while (a) {
- copy_v3_v3(nv1, mvert[a - 1].co);
- if (mprevvert) {
+ copy_v3_v3(nv1, positions[a - 1]);
+ if (positions_prev) {
mul_v3_fl(nv1, time);
- madd_v3_v3fl(nv1, mprevvert[a - 1].co, 1.0f - time);
+ madd_v3_v3fl(nv1, positions_prev[a - 1], 1.0f - time);
}
/* Origin to face_v2. */
sub_v3_v3(nv1, face_v2);
@@ -1120,7 +1120,7 @@ static int sb_detect_face_pointCached(const float face_v1[3],
}
a--;
} /* while (a) */
- } /* if (mvert) */
+ } /* if (positions) */
} /* if (ob->pd && ob->pd->deflect) */
BLI_ghashIterator_step(ihash);
}
@@ -1160,15 +1160,15 @@ static int sb_detect_face_collisionCached(const float face_v1[3],
{
/* only with deflecting set */
if (ob->pd && ob->pd->deflect) {
- const MVert *mvert = NULL;
- const MVert *mprevvert = NULL;
+ const float(*positions)[3] = NULL;
+ const float(*positions_prev)[3] = NULL;
const MVertTri *vt = NULL;
const ccdf_minmax *mima = NULL;
if (ccdm) {
- mvert = ccdm->mvert;
+ positions = ccdm->positions;
vt = ccdm->tri;
- mprevvert = ccdm->mprevvert;
+ positions_prev = ccdm->positions_prev;
mima = ccdm->mima;
a = ccdm->tri_num;
@@ -1197,21 +1197,21 @@ static int sb_detect_face_collisionCached(const float face_v1[3],
continue;
}
- if (mvert) {
+ if (positions) {
- copy_v3_v3(nv1, mvert[vt->tri[0]].co);
- copy_v3_v3(nv2, mvert[vt->tri[1]].co);
- copy_v3_v3(nv3, mvert[vt->tri[2]].co);
+ copy_v3_v3(nv1, positions[vt->tri[0]]);
+ copy_v3_v3(nv2, positions[vt->tri[1]]);
+ copy_v3_v3(nv3, positions[vt->tri[2]]);
- if (mprevvert) {
+ if (positions_prev) {
mul_v3_fl(nv1, time);
- madd_v3_v3fl(nv1, mprevvert[vt->tri[0]].co, 1.0f - time);
+ madd_v3_v3fl(nv1, positions_prev[vt->tri[0]], 1.0f - time);
mul_v3_fl(nv2, time);
- madd_v3_v3fl(nv2, mprevvert[vt->tri[1]].co, 1.0f - time);
+ madd_v3_v3fl(nv2, positions_prev[vt->tri[1]], 1.0f - time);
mul_v3_fl(nv3, time);
- madd_v3_v3fl(nv3, mprevvert[vt->tri[2]].co, 1.0f - time);
+ madd_v3_v3fl(nv3, positions_prev[vt->tri[2]], 1.0f - time);
}
}
@@ -1336,14 +1336,14 @@ static int sb_detect_edge_collisionCached(const float edge_v1[3],
{
/* only with deflecting set */
if (ob->pd && ob->pd->deflect) {
- const MVert *mvert = NULL;
- const MVert *mprevvert = NULL;
+ const float(*positions)[3] = NULL;
+ const float(*positions_prev)[3] = NULL;
const MVertTri *vt = NULL;
const ccdf_minmax *mima = NULL;
if (ccdm) {
- mvert = ccdm->mvert;
- mprevvert = ccdm->mprevvert;
+ positions = ccdm->positions;
+ positions_prev = ccdm->positions_prev;
vt = ccdm->tri;
mima = ccdm->mima;
a = ccdm->tri_num;
@@ -1373,21 +1373,21 @@ static int sb_detect_edge_collisionCached(const float edge_v1[3],
continue;
}
- if (mvert) {
+ if (positions) {
- copy_v3_v3(nv1, mvert[vt->tri[0]].co);
- copy_v3_v3(nv2, mvert[vt->tri[1]].co);
- copy_v3_v3(nv3, mvert[vt->tri[2]].co);
+ copy_v3_v3(nv1, positions[vt->tri[0]]);
+ copy_v3_v3(nv2, positions[vt->tri[1]]);
+ copy_v3_v3(nv3, positions[vt->tri[2]]);
- if (mprevvert) {
+ if (positions_prev) {
mul_v3_fl(nv1, time);
- madd_v3_v3fl(nv1, mprevvert[vt->tri[0]].co, 1.0f - time);
+ madd_v3_v3fl(nv1, positions_prev[vt->tri[0]], 1.0f - time);
mul_v3_fl(nv2, time);
- madd_v3_v3fl(nv2, mprevvert[vt->tri[1]].co, 1.0f - time);
+ madd_v3_v3fl(nv2, positions_prev[vt->tri[1]], 1.0f - time);
mul_v3_fl(nv3, time);
- madd_v3_v3fl(nv3, mprevvert[vt->tri[2]].co, 1.0f - time);
+ madd_v3_v3fl(nv3, positions_prev[vt->tri[2]], 1.0f - time);
}
}
@@ -1635,14 +1635,14 @@ static int sb_detect_vertex_collisionCached(float opco[3],
{
/* only with deflecting set */
if (ob->pd && ob->pd->deflect) {
- const MVert *mvert = NULL;
- const MVert *mprevvert = NULL;
+ const float(*positions)[3] = NULL;
+ const float(*positions_prev)[3] = NULL;
const MVertTri *vt = NULL;
const ccdf_minmax *mima = NULL;
if (ccdm) {
- mvert = ccdm->mvert;
- mprevvert = ccdm->mprevvert;
+ positions = ccdm->positions;
+ positions_prev = ccdm->positions_prev;
vt = ccdm->tri;
mima = ccdm->mima;
a = ccdm->tri_num;
@@ -1686,30 +1686,30 @@ static int sb_detect_vertex_collisionCached(float opco[3],
continue;
}
- if (mvert) {
+ if (positions) {
- copy_v3_v3(nv1, mvert[vt->tri[0]].co);
- copy_v3_v3(nv2, mvert[vt->tri[1]].co);
- copy_v3_v3(nv3, mvert[vt->tri[2]].co);
+ copy_v3_v3(nv1, positions[vt->tri[0]]);
+ copy_v3_v3(nv2, positions[vt->tri[1]]);
+ copy_v3_v3(nv3, positions[vt->tri[2]]);
- if (mprevvert) {
+ if (positions_prev) {
/* Grab the average speed of the collider vertices before we spoil nvX
* humm could be done once a SB steps but then we' need to store that too
* since the AABB reduced probability to get here drastically
* it might be a nice tradeoff CPU <--> memory.
*/
- sub_v3_v3v3(vv1, nv1, mprevvert[vt->tri[0]].co);
- sub_v3_v3v3(vv2, nv2, mprevvert[vt->tri[1]].co);
- sub_v3_v3v3(vv3, nv3, mprevvert[vt->tri[2]].co);
+ sub_v3_v3v3(vv1, nv1, positions_prev[vt->tri[0]]);
+ sub_v3_v3v3(vv2, nv2, positions_prev[vt->tri[1]]);
+ sub_v3_v3v3(vv3, nv3, positions_prev[vt->tri[2]]);
mul_v3_fl(nv1, time);
- madd_v3_v3fl(nv1, mprevvert[vt->tri[0]].co, 1.0f - time);
+ madd_v3_v3fl(nv1, positions_prev[vt->tri[0]], 1.0f - time);
mul_v3_fl(nv2, time);
- madd_v3_v3fl(nv2, mprevvert[vt->tri[1]].co, 1.0f - time);
+ madd_v3_v3fl(nv2, positions_prev[vt->tri[1]], 1.0f - time);
mul_v3_fl(nv3, time);
- madd_v3_v3fl(nv3, mprevvert[vt->tri[2]].co, 1.0f - time);
+ madd_v3_v3fl(nv3, positions_prev[vt->tri[2]], 1.0f - time);
}
}
@@ -1743,7 +1743,7 @@ static int sb_detect_vertex_collisionCached(float opco[3],
deflected = 2;
}
}
- if ((mprevvert) && (*damp > 0.0f)) {
+ if ((positions_prev) && (*damp > 0.0f)) {
choose_winner(ve, opco, nv1, nv2, nv3, vv1, vv2, vv3);
add_v3_v3(avel, ve);
cavel++;
@@ -2632,7 +2632,7 @@ static void springs_from_mesh(Object *ob)
BodyPoint *bp;
int a;
float scale = 1.0f;
- const MVert *verts = BKE_mesh_verts(me);
+ const float(*positions)[3] = BKE_mesh_positions(me);
sb = ob->soft;
if (me && sb) {
@@ -2643,7 +2643,7 @@ static void springs_from_mesh(Object *ob)
if (me->totvert) {
bp = ob->soft->bpoint;
for (a = 0; a < me->totvert; a++, bp++) {
- copy_v3_v3(bp->origS, verts[a].co);
+ copy_v3_v3(bp->origS, positions[a]);
mul_m4_v3(ob->object_to_world, bp->origS);
}
}
@@ -2755,7 +2755,7 @@ static void mesh_faces_to_scratch(Object *ob)
MLoopTri *looptri, *lt;
BodyFace *bodyface;
int a;
- const MVert *verts = BKE_mesh_verts(me);
+ const float(*positions)[3] = BKE_mesh_positions(me);
const MPoly *polys = BKE_mesh_polys(me);
const MLoop *loops = BKE_mesh_loops(me);
@@ -2763,7 +2763,7 @@ static void mesh_faces_to_scratch(Object *ob)
sb->scratch->totface = poly_to_tri_count(me->totpoly, me->totloop);
looptri = lt = MEM_mallocN(sizeof(*looptri) * sb->scratch->totface, __func__);
- BKE_mesh_recalc_looptri(loops, polys, verts, me->totloop, me->totpoly, looptri);
+ BKE_mesh_recalc_looptri(loops, polys, positions, me->totloop, me->totpoly, looptri);
bodyface = sb->scratch->bodyface = MEM_mallocN(sizeof(BodyFace) * sb->scratch->totface,
"SB_body_Faces");