[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31200] branches/soc-2010-nicolasbishop/ source/blender: == Ptex ==

Nicholas Bishop nicholasbishop at gmail.com
Mon Aug 9 23:48:14 CEST 2010


Revision: 31200
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31200
Author:   nicholasbishop
Date:     2010-08-09 23:48:13 +0200 (Mon, 09 Aug 2010)

Log Message:
-----------
== Ptex ==

* Enabled undo for multires
* Changed texture interpolation to linear

Modified Paths:
--------------
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_customdata.h
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_dmgrid.h
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_subsurf.h
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/CMakeLists.txt
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/SConscript
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/customdata.c
    branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h
    branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/pbvh_undo.c
    branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h	2010-08-09 20:14:33 UTC (rev 31199)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_DerivedMesh.h	2010-08-09 21:48:13 UTC (rev 31200)
@@ -156,6 +156,7 @@
 	DMGridAdjacency *(*getGridAdjacency)(DerivedMesh *dm);
 	int *(*getGridOffset)(DerivedMesh *dm);
 	struct GridKey *(*getGridKey)(DerivedMesh *dm);
+	struct GridToFace *(*getGridFaceMap)(DerivedMesh *dm, struct Object *ob);
 
 	/* Iterate over each mapped vertex in the derived mesh, calling the
 	 * given function with the original vert and the mapped vert's new

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_customdata.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_customdata.h	2010-08-09 20:14:33 UTC (rev 31199)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_customdata.h	2010-08-09 21:48:13 UTC (rev 31200)
@@ -368,3 +368,5 @@
 
 #endif
 
+struct MPtex;
+void *mptex_grid_offset(struct MPtex *pt, int offset, int *ures, int *vres, int *rowlen);

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_dmgrid.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_dmgrid.h	2010-08-09 20:14:33 UTC (rev 31199)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_dmgrid.h	2010-08-09 21:48:13 UTC (rev 31200)
@@ -51,4 +51,9 @@
    or masks, -1 if not found */
 int gridelem_active_offset(struct CustomData *data, GridKey *gridkey, int type);
 
+typedef struct GridToFace {
+	int face;
+	char offset;
+} GridToFace;
+
 #endif

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_subsurf.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_subsurf.h	2010-08-09 20:14:33 UTC (rev 31199)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_subsurf.h	2010-08-09 21:48:13 UTC (rev 31200)
@@ -82,6 +82,7 @@
 	struct DMGridAdjacency *gridAdjacency;
 	int *gridOffset;
 	struct _CCGFace **gridFaces;
+	struct GridToFace *gridFaceMap;
 
 	struct {
 		struct MultiresModifierData *mmd;

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/CMakeLists.txt
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/CMakeLists.txt	2010-08-09 20:14:33 UTC (rev 31199)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/CMakeLists.txt	2010-08-09 21:48:13 UTC (rev 31200)
@@ -31,7 +31,8 @@
 	../render/extern/include ../../../intern/decimation/extern
 	../imbuf ../avi ../../../intern/elbeem/extern ../../../intern/opennl/extern
 	../../../intern/iksolver/extern ../blenloader ../ikplugin
-	../nodes ../../../extern/glew/include ../gpu ../makesrna ../../../intern/smoke/extern
+	../nodes ../../../extern/glew/include  ../../../extern/ptex
+	../gpu ../makesrna ../../../intern/smoke/extern
 	../../../intern/bsp/extern ../blenfont
 	../../../intern/audaspace/intern
     ../../../source/blender/windowmanager # XXX - BAD LEVEL CALL WM_api.h

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/SConscript
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/SConscript	2010-08-09 20:14:33 UTC (rev 31199)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/SConscript	2010-08-09 21:48:13 UTC (rev 31200)
@@ -11,6 +11,7 @@
 incs += ' #/extern/bullet2/src'
 incs += ' #/intern/opennl/extern #/intern/bsp/extern'
 incs += ' ../gpu #/extern/glew/include'
+incs += ' #/extern/ptex'
 incs += ' #/intern/smoke/extern'
 incs += ' #/intern/audaspace/intern'
 

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/customdata.c	2010-08-09 20:14:33 UTC (rev 31199)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/customdata.c	2010-08-09 21:48:13 UTC (rev 31200)
@@ -49,6 +49,8 @@
 #include "BKE_global.h"
 #include "BKE_utildefines.h"
 
+#include "ptex.h"
+
 /* number of layers to add when growing a CustomData object */
 #define CUSTOMDATA_GROW 5
 
@@ -797,6 +799,35 @@
 	}
 }
 
+void *mptex_grid_offset(MPtex *pt, int offset, int *ures, int *vres, int *rowlen)
+{
+	char *data = pt->data;
+	int layersize = pt->channels * ptex_data_size(pt->type);
+
+	if(pt->subfaces == 1) {
+		*ures = pt->res[0][0] / 2;
+		*vres = pt->res[0][1] / 2;
+		*rowlen = pt->res[0][0];
+		if(offset == 1)
+			data += layersize * *ures;
+		else if(offset == 3)
+			data += layersize * *vres * *rowlen;
+		else if(offset == 2)
+			data += layersize * (*vres * *rowlen + *ures);
+	}
+	else {
+		int i;
+
+		*ures = pt->res[offset][0];
+		*vres = pt->res[offset][1];
+		*rowlen = pt->res[offset][0];
+		for(i = 0; i < offset; ++i)
+			data += layersize * pt->res[i][0] * pt->res[i][1];
+	}
+
+	return data;
+}
+
 static void layerCopy_mptex(const void *source_v, void *dest_v, int count)
 {
 	const MPtex *source = source_v;

Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c	2010-08-09 20:14:33 UTC (rev 31199)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/subsurf_ccg.c	2010-08-09 21:48:13 UTC (rev 31200)
@@ -2160,6 +2160,7 @@
 		if(ccgdm->gridData) MEM_freeN(ccgdm->gridData);
 		if(ccgdm->gridAdjacency) MEM_freeN(ccgdm->gridAdjacency);
 		if(ccgdm->gridOffset) MEM_freeN(ccgdm->gridOffset);
+		if(ccgdm->gridFaceMap) MEM_freeN(ccgdm->gridFaceMap);
 		if(ccgdm->freeSS) ccgSubSurf_free(ccgdm->ss);
 		if(ccgdm->fmap) MEM_freeN(ccgdm->fmap);
 		if(ccgdm->fmap_mem) MEM_freeN(ccgdm->fmap_mem);
@@ -2414,6 +2415,33 @@
 	return ccgSubSurf_getGridKey(ccgdm->ss);
 }
 
+static GridToFace *ccgDM_getGridFaceMap(DerivedMesh *dm, Object *ob)
+{
+	CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
+	Mesh *me = ob->data;
+	GridToFace *gtf;
+	int numGrids;
+	int i, j;
+
+	if(ccgdm->gridFaceMap)
+		return ccgdm->gridFaceMap;
+
+	numGrids = ccgDM_getNumGrids(dm);
+
+	ccgdm->gridFaceMap = MEM_callocN(sizeof(GridToFace) * numGrids, "ccgdm.grid_face_map");
+
+	for(i = 0, gtf = ccgdm->gridFaceMap; i < me->totface; ++i) {
+		int S = me->mface[i].v4 ? 4 : 3;
+
+		for(j = 0; j < S; ++j, ++gtf) {
+			gtf->face = i;
+			gtf->offset = j;
+		}
+	}
+
+	return ccgdm->gridFaceMap;
+}
+
 static ListBase *ccgDM_getFaceMap(Object *ob, DerivedMesh *dm)
 {
 	CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm;
@@ -2505,9 +2533,9 @@
 		ob->paint->pbvh= ccgdm->pbvh = BLI_pbvh_new(leaf_limit);
 		BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency,
 				     numGrids, gridSize, gridkey, (void**)ccgdm->gridFaces,
+				     ccgDM_getGridFaceMap(dm, ob),
 				     &me->vdata, &me->fdata,
-				     ss ? &ss->hidden_areas : NULL,
-				     me->mface, me->totface);
+				     ss ? &ss->hidden_areas : NULL);
 		ccgdm->pbvh_draw = 1;
 	}
 	else if(ob->type == OB_MESH) {
@@ -2576,6 +2604,7 @@
 	ccgdm->dm.getGridAdjacency = ccgDM_getGridAdjacency;
 	ccgdm->dm.getGridOffset = ccgDM_getGridOffset;
 	ccgdm->dm.getGridKey = ccgDM_getGridKey;
+	ccgdm->dm.getGridFaceMap = ccgDM_getGridFaceMap;
 	ccgdm->dm.getFaceMap = ccgDM_getFaceMap;
 	ccgdm->dm.getPBVH = ccgDM_getPBVH;
 

Modified: branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h	2010-08-09 20:14:33 UTC (rev 31199)
+++ branches/soc-2010-nicolasbishop/source/blender/blenlib/BLI_pbvh.h	2010-08-09 21:48:13 UTC (rev 31200)
@@ -32,6 +32,7 @@
 struct MFace;
 struct MVert;
 struct GridKey;
+struct GridToFace;
 struct DMGridAdjacency;
 struct DMGridData;
 struct PBVH;
@@ -51,11 +52,6 @@
 	float (*co)[3];
 } PBVHProxyNode;
 
-typedef struct {
-	int face;
-	char offset;
-} GridToFace;
-
 /* Callbacks */
 
 /* returns 1 if the search should continue from this node, 0 otherwise */
@@ -81,8 +77,9 @@
 void BLI_pbvh_build_grids(PBVH *bvh, struct DMGridData **grids,
 			  struct DMGridAdjacency *gridadj, int totgrid,
 			  int gridsize, struct GridKey *gridkey, void **gridfaces,
+			  struct GridToFace *grid_face_map,
 			  struct CustomData *vdata, struct CustomData *fdata,
-			  ListBase *hidden_areas, struct MFace *mface, int totface);
+			  ListBase *hidden_areas);
 void BLI_pbvh_free(PBVH *bvh);
 
 /* Hierarchical Search in the BVH, two methods:
@@ -148,7 +145,7 @@
 int BLI_pbvh_uses_grids(PBVH *bvh);
 
 void BLI_pbvh_get_customdata(PBVH *pbvh, struct CustomData **vdata, struct CustomData **fdata);
-GridToFace *BLI_pbvh_get_grid_face_map(PBVH *pbvh);
+struct GridToFace *BLI_pbvh_get_grid_face_map(PBVH *pbvh);
 
 void BLI_pbvh_node_get_faces(PBVH *bvh, PBVHNode *node,
 			     struct MFace **faces,

Modified: branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c	2010-08-09 20:14:33 UTC (rev 31199)
+++ branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c	2010-08-09 21:48:13 UTC (rev 31200)
@@ -674,32 +674,13 @@
 		pbvh_begin_build(bvh, totface, hidden_areas);
 }
 
-static GridToFace *pbvh_build_grid_face_map(MFace *mface, int totface, int totgrid)
-{
-	GridToFace *map, *gtf;
-	int i, j;
-
-	map = MEM_callocN(sizeof(GridToFace) * totgrid, "PBVH.grid_face_map");
-
-	for(i = 0, gtf = map; i < totface; ++i) {
-		int S = mface[i].v4 ? 4 : 3;
-
-		for(j = 0; j < S; ++j, ++gtf) {
-			gtf->face = i;
-			gtf->offset = j;
-		}
-	}
-
-	return map;
-}
-
 /* Do a full rebuild with on Grids data structure */
 void BLI_pbvh_build_grids(PBVH *bvh, DMGridData **grids,
 			  DMGridAdjacency *gridadj,
 			  int totgrid, int gridsize, GridKey *gridkey,
-			  void **gridfaces, CustomData *vdata,
-			  CustomData *fdata, ListBase *hidden_areas,
-			  MFace *mface, int totface)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list