[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39331] branches/soc-2011-onion: Revision: 31092

Jason Wilkins Jason.A.Wilkins at gmail.com
Fri Aug 12 15:41:10 CEST 2011


Revision: 39331
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39331
Author:   jwilkins
Date:     2011-08-12 13:41:10 +0000 (Fri, 12 Aug 2011)
Log Message:
-----------
Revision: 31092
Author: nicholasbishop
Date: 11:16:13 PM, Thursday, August 05, 2010
Message:
== Ptex ==

Fixes for triangles

* the quad-mesh-with-triangles example file from ptex contains subfaces with
  non-matching resolutions; changed the internal MPtex format to store
  separate resolutions for each subface

* changed ptex drawing to give each subface its own texture

* various fixes to the loading and painting code to support triangles

* small change to the ptex build files, hopefully fixes and MSVC issue
----
Modified : /branches/soc-2010-nicolasbishop/extern/ptex/CMakeLists.txt
Modified : /branches/soc-2010-nicolasbishop/extern/ptex/SConscript
Modified : /branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/writefile.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_meshdata_types.h

Revision: 31097
Author: nicholasbishop
Date: 12:57:23 AM, Friday, August 06, 2010
Message:
== Ptex ==

* Small bugfix for my previous commit, broke ptex generation

----
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c

jwilkins:
Added a temporary pre-processor definition ENABLE_PTEX so I can separate out changes to vertex paint involving ptex from the old vertex paint system.  Although Ptex could be seen as obsoleting vertex paint, I'd like to preserve the old functionality for now.  Later I can refactor so that both systems exist side by side.

Modified Paths:
--------------
    branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_data_mesh.py
    branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
    branches/soc-2011-onion/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-onion/source/blender/blenloader/intern/writefile.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/ptex.c
    branches/soc-2011-onion/source/blender/gpu/intern/gpu_buffers.c
    branches/soc-2011-onion/source/blender/makesdna/DNA_meshdata_types.h

Modified: branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_data_mesh.py
===================================================================
--- branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_data_mesh.py	2011-08-12 13:40:18 UTC (rev 39330)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/properties_data_mesh.py	2011-08-12 13:41:10 UTC (rev 39331)
@@ -358,7 +358,7 @@
             else:
                 layout.operator("mesh.vertex_color_multiresolution_toggle", text="Add Multires")
 
-class DATA_PT_ptex(DataButtonsPanel):
+class DATA_PT_ptex(MeshButtonsPanel, bpy.types.Panel):
     bl_label = "PTex"
     COMPAT_ENGINES = {'BLENDER_RENDER'}
 

Modified: branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c	2011-08-12 13:40:18 UTC (rev 39330)
+++ branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c	2011-08-12 13:41:10 UTC (rev 39331)
@@ -24,8 +24,8 @@
  *  \ingroup bli
  */
 
+#define ENABLE_PTEX 1
 
-
 #include "DNA_meshdata_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_object_types.h"
@@ -1196,9 +1196,11 @@
 							      flags);
 			}
 			else {
+#if ENABLE_PTEX
 				if(flags & GPU_DRAW_ACTIVE_MCOL)
 					GPU_update_mesh_ptex(node->draw_buffers, bvh, node);
 				else
+#endif
 					GPU_update_mesh_color_buffers(node->draw_buffers,
 							      bvh, node, flags);
 			}

Modified: branches/soc-2011-onion/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenloader/intern/readfile.c	2011-08-12 13:40:18 UTC (rev 39330)
+++ branches/soc-2011-onion/source/blender/blenloader/intern/readfile.c	2011-08-12 13:41:10 UTC (rev 39331)
@@ -31,6 +31,7 @@
  *  \ingroup blenloader
  */
 
+#define ENABLE_TEX 1
 
 #include "zlib.h"
 
@@ -3506,6 +3507,7 @@
 	}
 }
 
+#if ENABLE_PTEX
 static void direct_link_customdata_mptex(FileData *fd, int count, MPtex *mptex)
 {
 	if(mptex) {
@@ -3516,6 +3518,7 @@
 		}
 	}
 }
+#endif
 
 static void direct_link_customdata(FileData *fd, CustomData *data, int count)
 {
@@ -3536,8 +3539,10 @@
 				direct_link_mdisps(fd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
 			if(layer->type == CD_GRIDS)
 				direct_link_customdata_multires(fd, count, layer->data);
+#if ENABLE_PTEX
 			if(layer->type == CD_MPTEX)
 				direct_link_customdata_mptex(fd, count, layer->data);
+#endif
 			i++;
 		}
 	}

Modified: branches/soc-2011-onion/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenloader/intern/writefile.c	2011-08-12 13:40:18 UTC (rev 39330)
+++ branches/soc-2011-onion/source/blender/blenloader/intern/writefile.c	2011-08-12 13:41:10 UTC (rev 39331)
@@ -73,6 +73,7 @@
 - write USER if filename is ~/X.XX/config/startup.blend
 */
 
+#define ENABLE_TEX 1
 
 #include <math.h>
 #include <fcntl.h>
@@ -1561,24 +1562,25 @@
 	}
 }
 
+#if ENABLE_PTEX
 static void write_customdata_mptex(WriteData *wd, int count,
 				  MPtex *mptex)
 {
-	int i;
+	int i, j;
 
 	writestruct(wd, DATA, "MPtex", count, mptex);
 
 	for(i = 0; i < count; ++i, ++mptex) {
 		int layersize = mptex->channels * ptex_data_size(mptex->type);
-		float texels = mptex->ures*mptex->vres;
+		int texels;
 
-		if(mptex->subfaces)
-			texels *= mptex->subfaces;
+		for(j = 0, texels = 0; j < mptex->subfaces; ++j)
+			texels += mptex->res[j][0] * mptex->res[j][1];
 
-		writedata(wd, DATA, layersize * texels,
-			  mptex->data);
+		writedata(wd, DATA, layersize * texels, mptex->data);
 	}
 }
+#endif
 
 static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, int partial_type, int partial_count)
 {
@@ -1608,9 +1610,11 @@
 		else if (layer->type == CD_GRIDS) {
 			write_customdata_multires(wd, count, layer->data);
 		}
+#if ENABLE_PTEX
 		else if (layer->type == CD_MPTEX) {
 			write_customdata_mptex(wd, count, layer->data);
 		}
+#endif
 		else {
 			CustomData_file_write_info(layer->type, &structname, &structnum);
 			if (structnum) {

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c	2011-08-12 13:40:18 UTC (rev 39330)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_ops.c	2011-08-12 13:41:10 UTC (rev 39331)
@@ -23,6 +23,8 @@
  *  \ingroup edsculpt
  */
 
+#define ENABLE_PTEX 1
+
 #include "paint_stroke.h"
 
 #include "MEM_guardedalloc.h"
@@ -402,11 +404,11 @@
 	WM_operatortype_append(PAINT_OT_vpaint_stroke);
 	WM_operatortype_append(PAINT_OT_vertex_color_set);
 	WM_operatortype_append(PAINT_OT_vertex_colors_to_texture);
-
+#if ENABLE_PTEX
 	/* ptex */
 	WM_operatortype_append(PTEX_OT_layer_add);
 	WM_operatortype_append(PTEX_OT_open);
-
+#endif
 	/* face-select */
 	WM_operatortype_append(PAINT_OT_face_select_linked);
 	WM_operatortype_append(PAINT_OT_face_select_linked_pick);

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c	2011-08-12 13:40:18 UTC (rev 39330)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c	2011-08-12 13:41:10 UTC (rev 39331)
@@ -31,6 +31,7 @@
  *  \ingroup edsculpt
  */
 
+#define ENABLE_PTEX 1
 
 #include "paint_stroke.h"
 #include "paint_brushlib.h"
@@ -1739,6 +1740,7 @@
 }
 #endif
 
+#if PTEX_TEST
 static void ptex_elem_to_float4(PtexDataType type, int channels, void *data, float fcol[4])
 {
 	int i;
@@ -1815,6 +1817,7 @@
 	struct PaintStroke *stroke,
 	struct PaintStrokeTest *test,
 	struct MPtex *pt,
+	int res[2],
 	char *data,
 	float v1[3],
 	float v2[3],
@@ -1830,20 +1833,20 @@
 	sub_v3_v3v3(dtop, v1, v2);
 	sub_v3_v3v3(dbot, v4, v3);;
 	ustep = 1;
-	if(pt->ures != 1)
-		ustep /= (pt->ures - 1);
+	if(res[0] != 1)
+		ustep /= (res[0] - 1);
 	mul_v3_fl(dtop, ustep);
 	mul_v3_fl(dbot, ustep);
 
 	vstep = 1;
-	if(pt->vres != 1)
-		vstep /= (pt->vres - 1);
+	if(res[1] != 1)
+		vstep /= (res[1] - 1);
 
-	for(v = 0, yinterp = 0; v < pt->vres; ++v) {
+	for(v = 0, yinterp = 0; v < res[1]; ++v) {
 		copy_v3_v3(co_top, v2);
 		copy_v3_v3(co_bot, v3);
 
-		for(u = 0; u < pt->ures; ++u, data += layersize) {
+		for(u = 0; u < res[0]; ++u, data += layersize) {
 			float co[3];
 
 			interp_v3_v3v3(co, co_bot, co_top, yinterp);
@@ -1862,10 +1865,6 @@
 				ptex_elem_from_float4(pt->type, pt->channels, data, fcol);
 			}
 
-			/*(*color)[0] = u / (pt->ures-1.0f);
-			  (*color)[1] = v / (pt->vres-1.0f);
-			  (*color)[2] = 1;*/
-
 			add_v3_v3(co_bot, dbot);
 			add_v3_v3(co_top, dtop);
 		}
@@ -1873,8 +1872,9 @@
 		yinterp += vstep;
 	}
 }
+#endif
 
-#if 0
+#if !PTEX_TEST
 static void vpaint_nodes_faces(
 	struct Brush *brush,
 	struct BrushSpace *bspace,
@@ -1949,8 +1949,11 @@
 	struct CustomData *vdata,
 	struct CustomData *fdata,
 	int *face_indices,
-	int totface)
+	int totface,
+	float location[3],
+	float radius3d)
 {
+	float radius3d_sq= radius3d*radius3d;
 	PaintStrokeTest test;
 	MPtex *mptex;
 	MCol *mcol;
@@ -1961,9 +1964,9 @@
 	pmask_totlayer = CustomData_number_of_layers(vdata, CD_PAINTMASK);
 	pmask_first_layer = CustomData_get_layer_index(vdata, CD_PAINTMASK);
 
-	paint_stroke_test_init(&test, bspace->location, bspace->radius3d_sq);
+	paint_stroke_test_init(&test, location, radius3d);
 
-	mptex = CustomData_get_layer(fdata, CD_MPTEX);
+	mptex= CustomData_get_layer(fdata, CD_MPTEX);
 	
 	for(i = 0; i < totface; ++i) {
 		int face_index = face_indices[i];
@@ -1973,9 +1976,18 @@
 
 		if(S == 4) {
 			/* fast case */
-			vpaint_ptex_from_quad(brush, bspace, stroke, &test, pt, pt->data,
-					      mvert[f->v3].co, mvert[f->v4].co,
-					      mvert[f->v1].co, mvert[f->v2].co);
+			vpaint_ptex_from_quad(
+				brush,
+				bspace,
+				stroke,
+				&test,
+				pt,
+				pt->res[0],
+				pt->data,
+				mvert[f->v3].co,
+				mvert[f->v4].co,
+				mvert[f->v1].co,
+				mvert[f->v2].co);
 		}
 		else {
 			/* subfaces */
@@ -1984,6 +1996,7 @@
 
 			float half[4][3], center[3];
 			int layersize = pt->channels * ptex_data_size(pt->type);
+			char *data= pt->data;
 
 			for(j = 0; j < 3; ++j) {
 				int next = (j == S-1) ? 0 : j+1;
@@ -1995,13 +2008,21 @@
 			for(j = 0; j < 3; ++j) {
 				int vndx = (&f->v1)[j];
 				int prev = j==0 ? S-1 : j-1;
-				char *data = pt->data;
-				data += layersize*pt->ures*pt->vres * j;
 				
-				vpaint_ptex_from_quad(brush, bspace, stroke, &test, pt,
-						      data,
-						      mvert[vndx].co, half[j],
-						      center, half[prev]);
+				vpaint_ptex_from_quad(
+					brush,
+					bspace,
+					stroke,
+					&test,
+					pt,
+					pt->res[j],
+					data,
+					center,
+					half[prev],
+					mvert[vndx].co,
+					half[j]);
+
+				data += layersize * pt->res[j][0]*pt->res[j][1];
 			}
 		}
 	}
@@ -2180,7 +2201,7 @@
 	BLI_pbvh_vertex_iter_end;
 }
 
-#if 0
+#if !PTEX_TEST
 static void vpaint_nodes(
 	struct VPaint *vp,
 	struct BrushSpace *bspace,
@@ -2189,8 +2210,8 @@
 	struct Object *ob,
 	struct PBVHNode **nodes,
 	int totnode,
-	float center[3],
-	float radius)
+	float location[3],
+	float radius3d)
 {
 	PBVH *pbvh = ob->paint->pbvh;
 	Brush *brush = paint_brush(&vp->paint);
@@ -2237,9 +2258,9 @@
 						totgrid,
 						gridsize,
 						active,
-						center,
-						radius,
-						radius*radius);
+						location,
+						radius3d,
+						radius3d*radius3d);
 
 					BLI_pbvh_node_set_flags(nodes[n],
 								SET_INT_IN_POINTER(PBVH_NeedsColorStitch));
@@ -2256,8 +2277,8 @@
 						totgrid,
 						gridsize,
 						active,
-						center,
-						radius);
+						location,
+						radius3d);
 				}
 			}
 		}
@@ -2283,9 +2304,9 @@
 					mface,
 					fdata,
 					fmap,
-					center,
-					radius,
-					radius*radius);
+					location,
+					radius3d,
+					radius3d*radius3d);
 			}
 			else {
 				vpaint_nodes_faces(
@@ -2298,8 +2319,8 @@
 					fdata,
 					face_indices,
 					totface,
-					center,
-					radius);
+					location,
+					radius3d);
 			}
 		}
 
@@ -2317,8 +2338,8 @@
 	struct Object *ob,
 	struct PBVHNode **nodes,
 	int totnode,
-	float center[3],
-	float radius)
+	float location[3],
+	float radius3d)
 {
 	PBVH *pbvh = ob->paint->pbvh;
 	Brush *brush = paint_brush(&vp->paint);
@@ -2368,17 +2389,32 @@
 				dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list