diff options
author | Daniel Dunbar <daniel@zuster.org> | 2005-07-22 21:03:50 +0400 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2005-07-22 21:03:50 +0400 |
commit | cb3d0afd87b9276ef8b6937f664c3960c7bd6a23 (patch) | |
tree | 36dba0e5d8aa8e0cb9d3ddb24d57a1b7369b8ce3 | |
parent | f6024cfdac4aec15a2674ffbadc6928271f1b936 (diff) |
- moved mesh_getVertexCos to mesh.c and prototyped
- make mesh_modifier build vertex locations on demand
-rw-r--r-- | source/blender/blenkernel/BKE_mesh.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 43 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 13 |
4 files changed, 28 insertions, 44 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index addea547340..f92ad61191c 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -93,6 +93,10 @@ void mesh_calculate_vertex_normals (struct Mesh *me); */ void mesh_calc_normals(struct MVert *mverts, int numVerts, struct MFace *mfaces, int numFaces, float **faceNors_r); + /* Return a newly MEM_malloc'd array of all the mesh vertex locations + * (_numVerts_r_ may be NULL) */ +float (*mesh_getVertexCos(struct Mesh *me, int *numVerts_r))[3]; + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index f0807857248..e5305f3dff3 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1123,18 +1123,6 @@ DerivedMesh *derivedmesh_from_displistmesh(DispListMesh *dlm) typedef float vec3f[3]; -static vec3f *mesh_getVertexCos(Mesh *me, int *numVerts_r) -{ - int i, numVerts = *numVerts_r = me->totvert; - float (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "vertexcos1"); - - for (i=0; i<numVerts; i++) { - VECCOPY(cos[i], me->mvert[i].co); - } - - return cos; -} - static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3], DerivedMesh **deform_r, DerivedMesh **final_r, int useRenderParams, int useDeform) { Mesh *me = ob->data; diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 2b48e8bf101..dde9418fb6f 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -59,6 +59,7 @@ #include "BKE_object.h" #include "BKE_softbody.h" #include "BKE_utildefines.h" +#include "BKE_mesh.h" #include "BLI_blenlib.h" #include "BLI_arithb.h" @@ -231,31 +232,14 @@ void mesh_modifier(Object *ob, float (**vertexCos_r)[3]) { MVert *origMVert=NULL; Mesh *me= ob->data; - int a, done=0; - float (*vertexCos)[3]; + float (*vertexCos)[3] = NULL; + int a; - *vertexCos_r = NULL; - do_mesh_key(me); - - /* conditions if it's needed */ - if(ob->hooks.first); - else if(ob->effect.first); // weak... particles too - else if(ob->parent && ob->parent->type==OB_LATTICE); - else if(ob->parent && ob->partype==PARSKEL); - else if(ob->softflag & OB_SB_ENABLE); - else return; - - if(me->totvert==0) return; - - vertexCos = MEM_mallocN(sizeof(*vertexCos)*me->totvert, "mm_vertexcos"); - for (a=0; a<me->totvert; a++) { - VECCOPY(vertexCos[a], me->mvert[a].co); - } /* hooks */ if(ob->hooks.first) { - done= 1; + if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); /* NULL signals initialize */ hook_object_deform(ob, 0, NULL); @@ -272,50 +256,45 @@ void mesh_modifier(Object *ob, float (**vertexCos_r)[3]) for (wav= ob->effect.first; wav; wav= wav->next) { if(wav->type==EFF_WAVE) { + if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); init_wave_deform(wav); for(a=0; a<me->totvert; a++) { calc_wave_deform(wav, ctime, vertexCos[a]); } - - done = 1; } } } if((ob->softflag & OB_SB_ENABLE) && !(ob->softflag & OB_SB_POSTDEF)) { - done= 1; + if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); sbObjectStep(ob, (float)G.scene->r.cfra, vertexCos); } if (ob->parent && me->totvert) { if(ob->parent->type==OB_CURVE && ob->partype==PARSKEL) { + if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); curve_deform_verts(ob->parent, ob, vertexCos, me->totvert); - done= 1; } else if(ob->parent->type==OB_LATTICE) { + if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); lattice_deform_verts(ob->parent, ob, vertexCos, me->totvert); - done= 1; } else if(ob->parent->type==OB_ARMATURE && ob->partype==PARSKEL) { // misleading making displists... very bad if (ob->parent!=G.obedit) { + if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); armature_deform_verts(ob->parent, ob, vertexCos, me->totvert); } - done= 1; } } if((ob->softflag & OB_SB_ENABLE) && (ob->softflag & OB_SB_POSTDEF)) { - done= 1; + if (!vertexCos) vertexCos = mesh_getVertexCos(me, NULL); sbObjectStep(ob, (float)G.scene->r.cfra, vertexCos); } - if (done) { - *vertexCos_r = vertexCos; - } else { - MEM_freeN(vertexCos_r); - } + *vertexCos_r = vertexCos; } int curve_modifier(Object *ob, char mode) diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 8c2ee133487..09922413bfb 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1283,3 +1283,16 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, MEM_freeN(fnors); } } + +float (*mesh_getVertexCos(Mesh *me, int *numVerts_r))[3] +{ + int i, numVerts = me->totvert; + float (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "vertexcos1"); + + if (numVerts_r) *numVerts_r = numVerts; + for (i=0; i<numVerts; i++) { + VECCOPY(cos[i], me->mvert[i].co); + } + + return cos; +} |