[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37184] branches/soc-2011-onion: Revision: 29832
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sat Jun 4 18:32:05 CEST 2011
Revision: 37184
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37184
Author: jwilkins
Date: 2011-06-04 16:32:04 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Revision: 29832
Author: nicholasbishop
Date: 1:16:52 PM, Wednesday, June 30, 2010
Message:
* Moved subsurf grid stuff into it's own header file
* Changed gridkey in CCGSubsurf to not be dynamically allocated
* Fixes at least one small memory leak
**jwilkins:
** still getting memory leaks that have existed for a long time, noted here in case it doesn't get fixed in upcoming patches:
SculptUndoNode.pmask len: 27744 06810020
PBVHNodeSearch len: 3072 0278BBE0
SculptUndoNode.pmask len: 27744 06A70020
PBVHNodeSearch len: 3072 0278C838
SculptUndoNode.pmask len: 27744 06AC0020
PBVHNodeSearch len: 3072 02E49160
SculptUndoNode.pmask len: 27744 06B10020
PBVHNodeSearch len: 3072 02F27090
SculptUndoNode.pmask len: 27744 07770020
PBVHNodeSearch len: 3072 02E32150
SculptUndoNode.pmask len: 27744 077C0020
PBVHNodeSearch len: 3072 02E713D0
SculptUndoNode.pmask len: 27744 07810020
PBVHNodeSearch len: 3072 02E334A8
SculptUndoNode.pmask len: 27744 07860020
SculptUndoNode.pmask len: 27744 078B0020
PBVHNodeSearch len: 3072 02EDE618
SculptUndoNode.pmask len: 27744 07900020
Modified Paths:
--------------
branches/soc-2011-onion/source/blender/blenkernel/BKE_DerivedMesh.h
branches/soc-2011-onion/source/blender/blenkernel/BKE_subsurf.h
branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.c
branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.h
branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c
branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
branches/soc-2011-onion/source/blender/blenlib/BLI_pbvh.h
branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
branches/soc-2011-onion/source/blender/gpu/GPU_buffers.h
branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c
Added Paths:
-----------
branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h
Property Changed:
----------------
branches/soc-2011-onion/
Property changes on: branches/soc-2011-onion
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29796
/trunk/blender:36833-37054
+ /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-29796,29832
/trunk/blender:36833-37054
Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_DerivedMesh.h 2011-06-04 16:16:25 UTC (rev 37183)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_DerivedMesh.h 2011-06-04 16:32:04 UTC (rev 37184)
@@ -71,7 +71,6 @@
#define SUB_ELEMS_FACE 4
typedef struct DMGridData DMGridData;
-typedef struct GridKey GridKey;
typedef struct DMGridAdjacency {
int index[4];
Copied: branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h (from rev 29832, branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_dmgrid.h)
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h (rev 0)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_dmgrid.h 2011-06-04 16:32:04 UTC (rev 37184)
@@ -0,0 +1,35 @@
+#ifndef BKE_DMGRID_H
+#define BKE_DMGRID_H
+
+/* Each grid element can contain zero or more layers of coordinates,
+ paint masks, and normals; these numbers are stored in the GridKey
+
+ For now, co and no can have only zero or one layers, only mask is
+ really variable.
+*/
+typedef struct GridKey {
+ int co;
+ int mask;
+ int no;
+} GridKey;
+
+#define GRIDELEM_KEY_INIT(_gridkey, _totco, _totmask, _totno) \
+ ((_gridkey)->co = _totco, (_gridkey)->mask = _totmask, (_gridkey)->no = _totno)
+
+#define GRIDELEM_SIZE(_key) ((3*(_key)->co + (_key)->mask + 3*(_key)->no) * sizeof(float))
+#define GRIDELEM_MASK_OFFSET(_key) ((_key)->mask ? 3*(_key)->co*sizeof(float) : -1)
+#define GRIDELEM_NO_OFFSET(_key) ((_key)->no ? (3*(_key)->co + (_key)->mask) * sizeof(float) : -1)
+#define GRIDELEM_INTERP_COUNT(_key) (3*(_key)->co + (_key)->mask)
+
+#define GRIDELEM_AT(_grid, _elem, _key) ((struct DMGridData*)(((char*)(_grid)) + (_elem) * GRIDELEM_SIZE(_key)))
+#define GRIDELEM_INC(_grid, _inc, _key) ((_grid) = GRIDELEM_AT(_grid, _inc, _key))
+
+#define GRIDELEM_CO(_grid, _key) ((float*)(_grid))
+#define GRIDELEM_NO(_grid, _key) ((float*)((char*)(_grid) + GRIDELEM_NO_OFFSET(_key)))
+#define GRIDELEM_MASK(_grid, _key) ((float*)((char*)(_grid) + GRIDELEM_MASK_OFFSET(_key)))
+
+#define GRIDELEM_CO_AT(_grid, _elem, _key) GRIDELEM_CO(GRIDELEM_AT(_grid, _elem, _key), _key)
+#define GRIDELEM_NO_AT(_grid, _elem, _key) GRIDELEM_NO(GRIDELEM_AT(_grid, _elem, _key), _key)
+#define GRIDELEM_MASK_AT(_grid, _elem, _key) GRIDELEM_MASK(GRIDELEM_AT(_grid, _elem, _key), _key)
+
+#endif
Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_subsurf.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_subsurf.h 2011-06-04 16:16:25 UTC (rev 37183)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_subsurf.h 2011-06-04 16:32:04 UTC (rev 37184)
@@ -36,6 +36,7 @@
struct DMGridData;
struct DerivedMesh;
struct EditMesh;
+struct GridKey;
struct IndexNode;
struct ListBase;
struct Mesh;
@@ -50,39 +51,6 @@
/**************************** External *****************************/
-/* Grids */
-
-/* Each grid element can contain zero or more layers of coordinates,
- paint masks, and normals; these numbers are stored in the GridKey
-
- For now, co and no can have only zero or one layers, only mask is
- really variable.
-*/
-struct GridKey {
- int co;
- int mask;
- int no;
-};
-
-#define GRIDELEM_KEY_INIT(_gridkey, _totco, _totmask, _totno) \
- (_gridkey->co = _totco, _gridkey->mask = _totmask, _gridkey->no = _totno)
-
-#define GRIDELEM_SIZE(_key) ((3*_key->co + _key->mask + 3*_key->no) * sizeof(float))
-#define GRIDELEM_MASK_OFFSET(_key) (_key->mask ? 3*_key->co*sizeof(float) : -1)
-#define GRIDELEM_NO_OFFSET(_key) (_key->no ? (3*_key->co + _key->mask) * sizeof(float) : -1)
-#define GRIDELEM_INTERP_COUNT(_key) (3*_key->co + _key->mask)
-
-#define GRIDELEM_AT(_grid, _elem, _key) ((struct DMGridData*)(((char*)(_grid)) + (_elem) * GRIDELEM_SIZE(_key)))
-#define GRIDELEM_INC(_grid, _inc, _key) ((_grid) = GRIDELEM_AT(_grid, _inc, _key))
-
-#define GRIDELEM_CO(_grid, _key) ((float*)(_grid))
-#define GRIDELEM_NO(_grid, _key) ((float*)((char*)(_grid) + GRIDELEM_NO_OFFSET(_key)))
-#define GRIDELEM_MASK(_grid, _key) ((float*)((char*)(_grid) + GRIDELEM_MASK_OFFSET(_key)))
-
-#define GRIDELEM_CO_AT(_grid, _elem, _key) GRIDELEM_CO(GRIDELEM_AT(_grid, _elem, _key), _key)
-#define GRIDELEM_NO_AT(_grid, _elem, _key) GRIDELEM_NO(GRIDELEM_AT(_grid, _elem, _key), _key)
-#define GRIDELEM_MASK_AT(_grid, _elem, _key) GRIDELEM_MASK(GRIDELEM_AT(_grid, _elem, _key), _key)
-
struct DerivedMesh *subsurf_make_derived_from_derived(
struct DerivedMesh *dm,
struct SubsurfModifierData *smd,
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.c 2011-06-04 16:16:25 UTC (rev 37183)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.c 2011-06-04 16:32:04 UTC (rev 37184)
@@ -759,8 +759,6 @@
_ehash_free(ss->eMap, (EHEntryFreeFP) _edge_free, ss);
_ehash_free(ss->vMap, (EHEntryFreeFP) _vert_free, ss);
- MEM_freeN(ss->meshIFC.gridkey);
-
CCGSUBSURF_free(ss, ss);
if (allocatorIFC.release) {
@@ -2579,7 +2577,7 @@
}
struct GridKey *ccgSubSurf_getGridKey(CCGSubSurf *ss) {
- return ss->meshIFC.gridkey;
+ return &ss->meshIFC.gridkey;
}
/* Vert accessors */
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.h 2011-06-04 16:16:25 UTC (rev 37183)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/CCGSubSurf.h 2011-06-04 16:32:04 UTC (rev 37184)
@@ -3,6 +3,8 @@
*/
/* $Id$ */
+#include "BKE_dmgrid.h"
+
typedef void* CCGMeshHDL;
typedef void* CCGVertHDL;
typedef void* CCGEdgeHDL;
@@ -22,7 +24,7 @@
that would be (3+1) floats, so finterpCount would be 4. */
int finterpCount;
- struct GridKey* gridkey;
+ struct GridKey gridkey;
};
/***/
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c 2011-06-04 16:16:25 UTC (rev 37183)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c 2011-06-04 16:32:04 UTC (rev 37184)
@@ -504,18 +504,11 @@
return multires_dm_create_from_derived(&mmd, 1, dm, ob, 0, 0);
}
-static GridKey *create_gridkey(CustomData *cd)
-{
- GridKey *gridkey = MEM_callocN(sizeof(GridKey), "create_gridkey");
-
- GRIDELEM_KEY_INIT(gridkey, 1, CustomData_number_of_layers(cd, CD_PAINTMASK), 1);
-
- return gridkey;
-}
-
static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal)
{
SubsurfModifierData smd= {{NULL}};
+ GridKey gridkey;
+ int pmask_totlayer;
smd.levels = smd.renderLevels = lvl;
smd.flags |= eSubsurfModifierFlag_SubsurfUv;
@@ -524,7 +517,11 @@
if(optimal)
smd.flags |= eSubsurfModifierFlag_ControlEdges;
- return subsurf_make_derived_from_derived(dm, &smd, create_gridkey(&get_mesh(ob)->vdata), 0, NULL, 0, 0, (ob->mode & OB_MODE_EDIT));
+ pmask_totlayer = CustomData_number_of_layers(&get_mesh(ob)->vdata,
+ CD_PAINTMASK);
+ GRIDELEM_KEY_INIT(&gridkey, 1, pmask_totlayer, 1);
+
+ return subsurf_make_derived_from_derived(dm, &smd, &gridkey, 0, NULL, 0, 0, (ob->mode & OB_MODE_EDIT));
}
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c 2011-06-04 16:16:25 UTC (rev 37183)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/subsurf_ccg.c 2011-06-04 16:32:04 UTC (rev 37184)
@@ -124,7 +124,7 @@
}
ifc.vertDataSize = GRIDELEM_SIZE(gridkey);
ifc.finterpCount = GRIDELEM_INTERP_COUNT(gridkey);
- ifc.gridkey = gridkey;
+ ifc.gridkey = *gridkey;
if (useArena) {
CCGAllocatorIFC allocatorIFC;
@@ -324,16 +324,15 @@
int index, gridSize, gridFaces, /*edgeSize,*/ totface, x, y, S;
MTFace *dmtface = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, n);
MTFace *tface = CustomData_get_layer_n(&result->faceData, CD_MTFACE, n);
- GridKey *gridkey;
+ GridKey gridkey;
if(!dmtface || !tface)
return;
- gridkey = MEM_callocN(sizeof(GridKey), "Subsurf UV GridKey");
- GRIDELEM_KEY_INIT(gridkey, 1, 0, 0); /* TODO */
+ GRIDELEM_KEY_INIT(&gridkey, 1, 0, 0); /* TODO */
/* create a CCGSubSurf from uv's */
- uvss = _getSubSurf(NULL, gridkey, ccgSubSurf_getSubdivisionLevels(ss), 0, 1, 0);
+ uvss = _getSubSurf(NULL, &gridkey, ccgSubSurf_getSubdivisionLevels(ss), 0, 1, 0);
if(!ss_sync_from_uv(uvss, ss, dm, dmtface)) {
ccgSubSurf_free(uvss);
@@ -368,10 +367,10 @@
for(y = 0; y < gridFaces; y++) {
for(x = 0; x < gridFaces; x++) {
- float *a = GRIDELEM_CO_AT(faceGridData, (y + 0)*gridSize + x + 0, gridkey);
- float *b = GRIDELEM_CO_AT(faceGridData, (y + 0)*gridSize + x + 1, gridkey);
- float *c = GRIDELEM_CO_AT(faceGridData, (y + 1)*gridSize + x + 1, gridkey);
- float *d = GRIDELEM_CO_AT(faceGridData, (y + 1)*gridSize + x + 0, gridkey);
+ float *a = GRIDELEM_CO_AT(faceGridData, (y + 0)*gridSize + x + 0, &gridkey);
+ float *b = GRIDELEM_CO_AT(faceGridData, (y + 0)*gridSize + x + 1, &gridkey);
+ float *c = GRIDELEM_CO_AT(faceGridData, (y + 1)*gridSize + x + 1, &gridkey);
+ float *d = GRIDELEM_CO_AT(faceGridData, (y + 1)*gridSize + x + 0, &gridkey);
tf->uv[0][0] = a[0]; tf->uv[0][1] = a[1];
tf->uv[1][0] = d[0]; tf->uv[1][1] = d[1];
@@ -2675,11 +2674,11 @@
int useSubsurfUv = smd->flags & eSubsurfModifierFlag_SubsurfUv;
int drawInteriorEdges = !(smd->flags & eSubsurfModifierFlag_ControlEdges);
CCGDerivedMesh *result;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list