[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24323] branches/sculpt25/source/blender: Sculpt: derivedmesh no longer created CD_ORIGINDEX layer when there
Brecht Van Lommel
brecht at blender.org
Wed Nov 4 21:23:48 CET 2009
Revision: 24323
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24323
Author: blendix
Date: 2009-11-04 21:23:48 +0100 (Wed, 04 Nov 2009)
Log Message:
-----------
Sculpt: derivedmesh no longer created CD_ORIGINDEX layer when there
is no modifier, saving some memory.
Modified Paths:
--------------
branches/sculpt25/source/blender/blenkernel/intern/cdderivedmesh.c
branches/sculpt25/source/blender/blenkernel/intern/constraint.c
branches/sculpt25/source/blender/blenkernel/intern/modifier.c
branches/sculpt25/source/blender/blenkernel/intern/object.c
branches/sculpt25/source/blender/blenkernel/intern/particle.c
branches/sculpt25/source/blender/blenkernel/intern/subsurf_ccg.c
branches/sculpt25/source/blender/editors/sculpt_paint/paint_utils.c
branches/sculpt25/source/blender/editors/space_view3d/drawobject.c
branches/sculpt25/source/blender/render/intern/source/convertblender.c
Modified: branches/sculpt25/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/cdderivedmesh.c 2009-11-04 20:21:08 UTC (rev 24322)
+++ branches/sculpt25/source/blender/blenkernel/intern/cdderivedmesh.c 2009-11-04 20:23:48 UTC (rev 24323)
@@ -1017,7 +1017,7 @@
continue;
}
else if(setDrawOptions) {
- orig = index[a];
+ orig = (index)? index[a]: a;
if(orig == ORIGINDEX_NONE)
continue;
@@ -1514,17 +1514,12 @@
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 @@
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 @@
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 @@
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);
Modified: branches/sculpt25/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/constraint.c 2009-11-04 20:21:08 UTC (rev 24322)
+++ branches/sculpt25/source/blender/blenkernel/intern/constraint.c 2009-11-04 20:23:48 UTC (rev 24323)
@@ -440,15 +440,14 @@
/* 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) {
Modified: branches/sculpt25/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/modifier.c 2009-11-04 20:21:08 UTC (rev 24322)
+++ branches/sculpt25/source/blender/blenkernel/intern/modifier.c 2009-11-04 20:23:48 UTC (rev 24323)
@@ -5695,7 +5695,7 @@
/* 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) {
Modified: branches/sculpt25/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/object.c 2009-11-04 20:21:08 UTC (rev 24322)
+++ branches/sculpt25/source/blender/blenkernel/intern/object.c 2009-11-04 20:23:48 UTC (rev 24323)
@@ -1781,13 +1781,15 @@
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++;
Modified: branches/sculpt25/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/particle.c 2009-11-04 20:21:08 UTC (rev 24322)
+++ branches/sculpt25/source/blender/blenkernel/intern/particle.c 2009-11-04 20:23:48 UTC (rev 24323)
@@ -790,7 +790,7 @@
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 @@
/* 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 @@
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 @@
if(!data->dosimplify)
return 0;
- b= data->origindex[cpa->num];
+ b= (data->origindex)? data->origindex[cpa->num]: cpa->num;
if(b == -1)
return 0;
Modified: branches/sculpt25/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/subsurf_ccg.c 2009-11-04 20:21:08 UTC (rev 24322)
+++ branches/sculpt25/source/blender/blenkernel/intern/subsurf_ccg.c 2009-11-04 20:23:48 UTC (rev 24323)
@@ -546,7 +546,7 @@
// 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 @@
// 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 @@
// 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 @@
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 @@
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 @@
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 @@
return;
}
- ((int*)ccgSubSurf_getFaceUserData(ss, f))[1] = *index;
+ ((int*)ccgSubSurf_getFaceUserData(ss, f))[1] = (index)? *index++: i;
}
ccgSubSurf_processSync(ss);
Modified: branches/sculpt25/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- branches/sculpt25/source/blender/editors/sculpt_paint/paint_utils.c 2009-11-04 20:21:08 UTC (rev 24322)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list