diff options
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 37 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 18 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 6 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 6 |
9 files changed, 51 insertions, 49 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index b7234a86af9..c9c035ba6d1 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1017,7 +1017,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo continue; } else if(setDrawOptions) { - orig = index[a]; + orig = (index)? index[a]: a; if(orig == ORIGINDEX_NONE) continue; @@ -1514,17 +1514,12 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *ob) CDDerivedMesh *cddm = cdDM_create("CDDM_from_mesh dm"); DerivedMesh *dm = &cddm->dm; CustomDataMask mask = CD_MASK_MESH & (~CD_MASK_MDISPS); - int i, *index, alloctype; + int alloctype; - /* this does a referenced copy, the only new layers being ORIGINDEX, - * with an exception for fluidsim */ + /* this does a referenced copy, with an exception for fluidsim */ DM_init(dm, mesh->totvert, mesh->totedge, mesh->totface); - CustomData_add_layer(&dm->vertData, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totvert); - CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totedge); - CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totface); - dm->deformedOnly = 1; alloctype= CD_REFERENCE; @@ -1540,18 +1535,6 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *ob) cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE); cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE); - index = CustomData_get_layer(&dm->vertData, CD_ORIGINDEX); - for(i = 0; i < mesh->totvert; ++i, ++index) - *index = i; - - index = CustomData_get_layer(&dm->edgeData, CD_ORIGINDEX); - for(i = 0; i < mesh->totedge; ++i, ++index) - *index = i; - - index = CustomData_get_layer(&dm->faceData, CD_ORIGINDEX); - for(i = 0; i < mesh->totface; ++i, ++index) - *index = i; - return dm; } @@ -1696,6 +1679,13 @@ DerivedMesh *CDDM_from_template(DerivedMesh *source, CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges); CustomData_add_layer(&dm->faceData, CD_MFACE, CD_CALLOC, NULL, numFaces); + if(!CustomData_get_layer(&dm->vertData, CD_ORIGINDEX)) + CustomData_add_layer(&dm->vertData, CD_ORIGINDEX, CD_CALLOC, NULL, numVerts); + if(!CustomData_get_layer(&dm->edgeData, CD_ORIGINDEX)) + CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges); + if(!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX)) + CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numFaces); + cddm->mvert = CustomData_get_layer(&dm->vertData, CD_MVERT); cddm->medge = CustomData_get_layer(&dm->edgeData, CD_MEDGE); cddm->mface = CustomData_get_layer(&dm->faceData, CD_MFACE); @@ -2000,6 +1990,13 @@ DerivedMesh *MultiresDM_new(MultiresSubsurf *ms, DerivedMesh *orig, int numVerts else DM_init(dm, numVerts, numEdges, numFaces); + if(!CustomData_get_layer(&dm->vertData, CD_ORIGINDEX)) + CustomData_add_layer(&dm->vertData, CD_ORIGINDEX, CD_CALLOC, NULL, numVerts); + if(!CustomData_get_layer(&dm->edgeData, CD_ORIGINDEX)) + CustomData_add_layer(&dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, numEdges); + if(!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX)) + CustomData_add_layer(&dm->faceData, CD_ORIGINDEX, CD_CALLOC, NULL, numFaces); + CustomData_add_layer(&dm->vertData, CD_MVERT, CD_CALLOC, NULL, numVerts); CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_CALLOC, NULL, numEdges); CustomData_add_layer(&dm->faceData, CD_MFACE, CD_CALLOC, NULL, numFaces); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index a319838a56f..a94fd8f6bd2 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -440,15 +440,14 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f /* only continue if there's a valid DerivedMesh */ if (dm) { MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); - int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX); int numVerts = dm->getNumVerts(dm); int i, j, count = 0; float co[3], nor[3]; - /* check that dvert and index are valid pointers (just in case) */ - if (dvert && index) { + /* check that dvert is a valid pointers (just in case) */ + if (dvert) { /* get the average of all verts with that are in the vertex-group */ - for (i = 0; i < numVerts; i++, index++) { + for (i = 0; i < numVerts; i++) { for (j = 0; j < dvert[i].totweight; j++) { /* does this vertex belong to nominated vertex group? */ if (dvert[i].dw[j].def_nr == dgroup) { diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index a445b6986f6..639797564cc 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5695,7 +5695,7 @@ static void hookModifier_deformVerts( /* if DerivedMesh is present and has original index data, * use it */ - if(dm && dm->getVertData(dm, 0, CD_ORIGINDEX)) { + if(dm && dm->getVertDataArray(dm, CD_ORIGINDEX)) { int j; int orig_index; for(j = 0; j < numVerts; ++j) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index c1b9634e5ec..7ed120c3cfb 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1781,13 +1781,15 @@ static void give_parvert(Object *par, int nr, float *vec) DerivedMesh *dm = par->derivedFinal; if(dm) { - int i, count = 0, numVerts = dm->getNumVerts(dm); + int i, count = 0, vindex, numVerts = dm->getNumVerts(dm); int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX); float co[3]; /* get the average of all verts with (original index == nr) */ - for(i = 0; i < numVerts; ++i, ++index) { - if(*index == nr) { + for(i = 0; i < numVerts; ++i) { + vindex= (index)? *index: i; + + if(vindex == nr) { dm->getVertCo(dm, i, co); VecAddf(vec, vec, co); count++; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 43a624b3013..6bd2a03a628 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -790,7 +790,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) totface= dm->getNumFaces(dm); totorigface= me->totface; - if(totface == 0 || totorigface == 0 || origindex == NULL) + if(totface == 0 || totorigface == 0) return tot; facearea= MEM_callocN(sizeof(float)*totorigface, "SimplifyFaceArea"); @@ -807,14 +807,14 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) /* compute number of children per original face */ for(a=0; a<tot; a++) { - b= origindex[ctx->index[a]]; + b= (origindex)? origindex[ctx->index[a]]: ctx->index[a]; if(b != -1) elems[b].totchild++; } /* compute areas and centers of original faces */ for(mf=mface, a=0; a<totface; a++, mf++) { - b= origindex[a]; + b= (origindex)? origindex[a]: a; if(b != -1) { VECCOPY(co1, mvert[mf->v1].co); @@ -910,7 +910,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) skipped= 0; for(a=0, newtot=0; a<tot; a++) { - b= origindex[ctx->index[a]]; + b= (origindex)? origindex[ctx->index[a]]: ctx->index[a]; if(b != -1) { if(elems[b].curchild++ < ceil(elems[b].lambda*elems[b].totchild)) { ctx->index[newtot]= ctx->index[a]; @@ -943,7 +943,7 @@ int psys_render_simplify_params(ParticleSystem *psys, ChildParticle *cpa, float if(!data->dosimplify) return 0; - b= data->origindex[cpa->num]; + b= (data->origindex)? data->origindex[cpa->num]: cpa->num; if(b == -1) return 0; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 1482bd75ff2..125c8a0c464 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -546,7 +546,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, // load verts faceBase = i = 0; mvert = CDDM_get_verts(result); - origIndex = result->getVertData(result, 0, CD_ORIGINDEX); + origIndex = result->getVertDataArray(result, CD_ORIGINDEX); for(index = 0; index < totface; index++) { CCGFace *f = faceMap2[index]; @@ -663,7 +663,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, // load edges i = 0; med = CDDM_get_edges(result); - origIndex = result->getEdgeData(result, 0, CD_ORIGINDEX); + origIndex = result->getEdgeDataArray(result, CD_ORIGINDEX); for(index = 0; index < totface; index++) { CCGFace *f = faceMap2[index]; @@ -738,7 +738,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh, // load faces i = 0; mf = CDDM_get_faces(result); - origIndex = result->getFaceData(result, 0, CD_ORIGINDEX); + origIndex = result->getFaceDataArray(result, CD_ORIGINDEX); for(index = 0; index < totface; index++) { CCGFace *f = faceMap2[index]; @@ -846,7 +846,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, mv = mvert; index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX); - for(i = 0; i < totvert; i++, mv++, index++) { + for(i = 0; i < totvert; i++, mv++) { CCGVert *v; if(vertexCos) { @@ -855,12 +855,12 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, ccgSubSurf_syncVert(ss, SET_INT_IN_POINTER(i), mv->co, 0, &v); } - ((int*)ccgSubSurf_getVertUserData(ss, v))[1] = *index; + ((int*)ccgSubSurf_getVertUserData(ss, v))[1] = (index)? *index++: i; } me = medge; index = (int *)dm->getEdgeDataArray(dm, CD_ORIGINDEX); - for(i = 0; i < totedge; i++, me++, index++) { + for(i = 0; i < totedge; i++, me++) { CCGEdge *e; float crease; @@ -870,12 +870,12 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, ccgSubSurf_syncEdge(ss, SET_INT_IN_POINTER(i), SET_INT_IN_POINTER(me->v1), SET_INT_IN_POINTER(me->v2), crease, &e); - ((int*)ccgSubSurf_getEdgeUserData(ss, e))[1] = *index; + ((int*)ccgSubSurf_getEdgeUserData(ss, e))[1] = (index)? *index++: i; } mf = mface; index = (int *)dm->getFaceDataArray(dm, CD_ORIGINDEX); - for (i = 0; i < totface; i++, mf++, index++) { + for (i = 0; i < totface; i++, mf++) { CCGFace *f; fVerts[0] = SET_INT_IN_POINTER(mf->v1); @@ -901,7 +901,7 @@ static void ss_sync_from_derivedmesh(CCGSubSurf *ss, DerivedMesh *dm, return; } - ((int*)ccgSubSurf_getFaceUserData(ss, f))[1] = *index; + ((int*)ccgSubSurf_getFaceUserData(ss, f))[1] = (index)? *index++: i; } ccgSubSurf_processSync(ss); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 15104068350..210d6e0ff95 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -96,7 +96,7 @@ void imapaint_pick_uv(Scene *scene, Object *ob, Mesh *mesh, unsigned int faceind DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); int *index = dm->getFaceDataArray(dm, CD_ORIGINDEX); MTFace *tface = dm->getFaceDataArray(dm, CD_MTFACE), *tf; - int numfaces = dm->getNumFaces(dm), a; + int numfaces = dm->getNumFaces(dm), a, findex; float p[2], w[3], absw, minabsw; MFace mf; MVert mv[4]; @@ -106,7 +106,9 @@ void imapaint_pick_uv(Scene *scene, Object *ob, Mesh *mesh, unsigned int faceind /* test all faces in the derivedmesh with the original index of the picked face */ for(a = 0; a < numfaces; a++) { - if(index[a] == faceindex) { + findex= (index)? index[a]: a; + + if(findex == faceindex) { dm->getFace(dm, a, &mf); dm->getVert(dm, mf.v1, &mv[0]); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 4f41b6e5045..1eecefdcf0f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -6142,10 +6142,8 @@ static void bbs_mesh_solid(Scene *scene, View3D *v3d, Object *ob) int ind; colors = MEM_mallocN(dm->getNumFaces(dm)*sizeof(MCol)*4,"bbs_mesh_solid"); for(i=0;i<dm->getNumFaces(dm);i++) { - if( index != 0 ) - ind = index[i]; - else - ind = i; + ind= ( index )? index[i]: i; + if (face_sel_mode==0 || !(me->mface[ind].flag&ME_HIDE)) { unsigned int fbindex = index_to_framebuffer(ind+1); for(j=0;j<4;j++) { diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 072083e58a7..cb8970a356f 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1710,8 +1710,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if(origindex) { for(a=0; a<totface; a++) strandbuf->totbound= MAX2(strandbuf->totbound, origindex[a]); - strandbuf->totbound++; } + else { + for(a=0; a<totface; a++) + strandbuf->totbound= MAX2(strandbuf->totbound, a); + } + strandbuf->totbound++; strandbuf->bound= MEM_callocN(sizeof(StrandBound)*strandbuf->totbound, "StrandBound"); sbound= strandbuf->bound; |