[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39929] branches/soc-2011-carrot: Dynamic Paint:

Miika Hamalainen miika.hamalainen at kolumbus.fi
Mon Sep 5 18:04:17 CEST 2011


Revision: 39929
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39929
Author:   miikah
Date:     2011-09-05 16:04:15 +0000 (Mon, 05 Sep 2011)
Log Message:
-----------
Dynamic Paint:
* Added "Initial Color" setting for surfaces. You can for example set color from UV mapped texture or from vertex colors.
* Added clamping option for "wave" brushes.
* Merged smudge and drip adjacency search code. This fixes some issues with drip effect and makes code easier to maintain.
* Some adjustments to the bounding box generation code.
* OpenMP is now completely disabled if no compile flag is set.
* Wetness values are now properly clamped on vertex surfaces. No more black dots on >1.0 wetness.
* Textured brushes now use same function calls as internal renderer, instead of modified duplicates.
* Moved operator code to editors/physics/.
* Re-enabled some particle brush optimizations.
* Fixed sometimes incorrect volume brush influence.
* Fixed possible crash when using a brush that uses "Voxel Data" texture simultaneously with material preview or render.
* Fixed texture mapping issues for "Object Center" brush.
* Fixed possible crash/corruption when duplicating brush object that uses color ramps.
* Other tweaking and code cleanup.

Modified Paths:
--------------
    branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
    branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h
    branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
    branches/soc-2011-carrot/source/blender/editors/physics/CMakeLists.txt
    branches/soc-2011-carrot/source/blender/makesdna/DNA_dynamicpaint_types.h
    branches/soc-2011-carrot/source/blender/makesrna/intern/rna_dynamicpaint.c
    branches/soc-2011-carrot/source/blender/modifiers/intern/MOD_dynamicpaint.c
    branches/soc-2011-carrot/source/blender/render/intern/include/texture.h
    branches/soc-2011-carrot/source/blender/render/intern/source/render_texture.c
    branches/soc-2011-carrot/source/blender/render/intern/source/volumetric.c
    branches/soc-2011-carrot/source/blenderplayer/bad_level_call_stubs/stubs.c

Added Paths:
-----------
    branches/soc-2011-carrot/source/blender/editors/physics/dynamicpaint_ops.c

Modified: branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
===================================================================
--- branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py	2011-09-05 15:55:53 UTC (rev 39928)
+++ branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py	2011-09-05 16:04:15 UTC (rev 39929)
@@ -117,8 +117,11 @@
                     elif (brush.brush_settings_context == "WAVE"):
                         layout.prop(brush, "wave_type")
                         if (brush.wave_type != "REFLECT"):
-                            split = layout.split(percentage=0.6)
-                            split.prop(brush, "wave_factor")
+                            split = layout.split(percentage=0.5)
+                            col = split.column()
+                            col.prop(brush, "wave_factor")
+                            col = split.column()
+                            col.prop(brush, "wave_clamp")
                     elif (brush.brush_settings_context == "VELOCITY"):
                         col = layout.row().column()
                         col.label(text="Velocity Settings:")
@@ -199,7 +202,40 @@
         layout.label(text="Brush Group:")
         layout.prop(surface, "brush_group", text="")
 
+class PHYSICS_PT_dp_canvas_initial_color(PhysicButtonsPanel, bpy.types.Panel):
+    bl_label = "Dynamic Paint: Initial Color"
+    bl_options = {'DEFAULT_CLOSED'}
 
+    @classmethod
+    def poll(cls, context):
+        md = context.dynamic_paint
+        if (not (md and (md.ui_type == "CANVAS") and (md.canvas_settings))):
+            return 0
+        surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
+        return (surface and surface.surface_type=="PAINT")
+
+    def draw(self, context):
+        layout = self.layout
+
+        canvas = context.dynamic_paint.canvas_settings
+        surface = canvas.canvas_surfaces.active
+        ob = context.object
+
+        layout.prop(surface, "init_color_type", expand=False)
+        layout.separator()
+
+        # dissolve
+        if (surface.init_color_type == "COLOR"):
+            layout.prop(surface, "init_color")
+            
+        if (surface.init_color_type == "TEXTURE"):
+            layout.prop(surface, "init_texture")
+            layout.prop_search(surface, "init_layername", ob.data, "uv_textures", text="UV Layer:")
+        
+        if (surface.init_color_type == "VERTEXCOLOR"):
+            layout.prop_search(surface, "init_layername", ob.data, "vertex_colors", text="Color Layer: ")
+
+
 class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, bpy.types.Panel):
     bl_label = "Dynamic Paint: Output"
     bl_options = {'DEFAULT_CLOSED'}

Modified: branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h	2011-09-05 15:55:53 UTC (rev 39928)
+++ branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h	2011-09-05 16:04:15 UTC (rev 39929)
@@ -18,6 +18,8 @@
 
 struct PaintEffectData;
 struct PaintBakeData;
+struct bContext;
+struct wmOperator;
 
 /* Actual surface point	*/
 typedef struct PaintSurfaceData {
@@ -61,12 +63,22 @@
 void dynamicPaint_Modifier_free (struct DynamicPaintModifierData *pmd);
 void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct DynamicPaintModifierData *tsmd);
 
+int dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, struct Scene *scene);
+struct DynamicPaintSurface *dynamicPaint_createNewSurface(struct DynamicPaintCanvasSettings *canvas, struct Scene *scene);
+void dynamicPaint_clearSurface(struct DynamicPaintSurface *surface);
+int  dynamicPaint_resetSurface(struct DynamicPaintSurface *surface);
+void dynamicPaint_freeSurface(struct DynamicPaintSurface *surface);
+void dynamicPaint_freeCanvas(struct DynamicPaintModifierData *pmd);
+void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd);
+
 void dynamicPaint_cacheUpdateFrames(struct DynamicPaintSurface *surface);
-void dynamicPaint_clearSurface(DynamicPaintSurface *surface);
-int  dynamicPaint_resetSurface(struct DynamicPaintSurface *surface);
-int  dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface);
+int  dynamicPaint_surfaceHasColorPreview(struct DynamicPaintSurface *surface);
 int dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, struct Object *ob, int index);
 void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface);
-void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, char *basename);
+void dynamicPaintSurface_setUniqueName(struct DynamicPaintSurface *surface, char *basename);
+void dynamicPaint_resetPreview(struct DynamicPaintCanvasSettings *canvas);
+struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings *canvas);
 
+int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op);
+
 #endif /* BKE_DYNAMIC_PAINT_H_ */

Modified: branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c	2011-09-05 15:55:53 UTC (rev 39928)
+++ branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c	2011-09-05 16:04:15 UTC (rev 39929)
@@ -58,15 +58,11 @@
 #include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"	/* to get temp file path	*/
 
-#include "ED_mesh.h"
-#include "ED_screen.h"
-
 #include "RNA_access.h"
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
-/* for bake operator	*/
-#include "WM_types.h"
+#include "ED_screen.h"
 #include "WM_api.h"
 
 /* for image output	*/
@@ -86,6 +82,7 @@
 #include "../render/intern/include/pointdensity.h"
 #include "../render/intern/include/render_types.h"
 #include "../render/intern/include/voxeldata.h"
+#include "../render/intern/include/texture.h"
 #include "DNA_material_types.h"
 #include "RE_render_ext.h"
 
@@ -125,6 +122,7 @@
 } Bounds2D;
 
 typedef struct Bounds3D {
+	int valid;
 	float min[3], max[3];
 } Bounds3D;
 
@@ -259,7 +257,7 @@
 }
 
 /* get currently active surface (in user interface) */
-static DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas)
+struct DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas)
 {
 	DynamicPaintSurface *surface = canvas->surfaces.first;
 	int i;
@@ -273,7 +271,7 @@
 }
 
 /* set preview to first previewable surface */
-static void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas)
+void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas)
 {
 	DynamicPaintSurface *surface = canvas->surfaces.first;
 	int done=0;
@@ -536,37 +534,51 @@
 	return flags;
 }
 
+/* check whether two bounds intersect */
 static int boundsIntersect(Bounds3D *b1, Bounds3D *b2)
 {
 	int i=2;
+	if (!b1->valid || !b2->valid) return 0;
 	for (; i>=0; i-=1)
 		if (!(b1->min[i] <= b2->max[i] && b1->max[i] >= b2->min[i])) return 0;
 	return 1;
 }
 
+/* check whether two bounds intersect inside defined proximity */
 static int boundsIntersectDist(Bounds3D *b1, Bounds3D *b2, float dist)
 {
 	int i=2;
+	if (!b1->valid || !b2->valid) return 0;
 	for (; i>=0; i-=1)
 		if (!(b1->min[i] <= (b2->max[i]+dist) && b1->max[i] >= (b2->min[i]-dist))) return 0;
 	return 1;
 }
 
+/* check whether bounds intersects a point with given radius */
 static int boundIntersectPoint(Bounds3D *b, float point[3], float radius)
 {
 	int i=2;
+	if (!b->valid) return 0;
 	for (; i>=0; i-=1)
 		if (!(b->min[i] <= (point[i]+radius) && b->max[i] >= (point[i]-radius))) return 0;
 	return 1;
 }
 
+/* expand bounds by a new point */
 static void boundInsert(Bounds3D *b, float point[3])
 {
 	int i=2;
-	for (; i>=0; i-=1) {
-		if (point[i] < b->min[i]) b->min[i]=point[i];
-		if (point[i] > b->max[i]) b->max[i]=point[i];
+	if (!b->valid) {
+		VECCOPY(b->min, point);
+		VECCOPY(b->max, point);
+		b->valid = 1;
 	}
+	else {
+		for (; i>=0; i-=1) {
+			if (point[i] < b->min[i]) b->min[i]=point[i];
+			if (point[i] > b->max[i]) b->max[i]=point[i];
+		}
+	}
 }
 
 static void freeGrid(PaintSurfaceData *data)
@@ -614,17 +626,11 @@
 		float tx,ty,tz;
 		float min_dim;
 
-		/* initial values for each thread */
-		for (index = 0; index<num_of_threads; index++) {
-			VECCOPY(grid_bounds[index].min, bData->realCoord[bData->s_pos[0]].v);
-			VECCOPY(grid_bounds[index].max, bData->realCoord[bData->s_pos[0]].v);
-		}
-		VECCOPY(grid->grid_bounds.min, bData->realCoord[bData->s_pos[0]].v);
-		VECCOPY(grid->grid_bounds.max, bData->realCoord[bData->s_pos[0]].v);
-
 		/* calculate canvas dimensions */
+		#ifdef _OPENMP
 		#pragma omp parallel for schedule(static)
-		for (index = 1; index < sData->total_points; index++) {
+		#endif
+		for (index = 0; index < sData->total_points; index++) {
 #ifdef _OPENMP
 			int id = omp_get_thread_num();
 			boundInsert(&grid_bounds[id], (bData->realCoord[bData->s_pos[index]].v));
@@ -688,7 +694,9 @@
 
 		if (!error) {
 			/* calculate number of points withing each cell */
+			#ifdef _OPENMP
 			#pragma omp parallel for schedule(static)
+			#endif
 			for (index = 0; index < sData->total_points; index++) {
 				int x,y,z;
 				x = floor((bData->realCoord[bData->s_pos[index]].v[0] - grid->grid_bounds.min[0])/dim[0]*grid->x);
@@ -731,7 +739,9 @@
 			/* calculate cell bounds */
 			{
 				int x;
+				#ifdef _OPENMP
 				#pragma omp parallel for schedule(static)
+				#endif
 				for (x=0; x<grid->x; x++) {
 					int y;
 					for (y=0; y<grid->y; y++) {
@@ -747,6 +757,8 @@
 							grid->bounds[b_index].max[0] = grid->grid_bounds.min[0] + dim[0]/grid->x*(x+1);
 							grid->bounds[b_index].max[1] = grid->grid_bounds.min[1] + dim[1]/grid->y*(y+1);
 							grid->bounds[b_index].max[2] = grid->grid_bounds.min[2] + dim[2]/grid->z*(z+1);
+
+							grid->bounds[b_index].valid = 1;
 						}
 					}
 				}
@@ -769,7 +781,7 @@
 /***************************** Freeing data ******************************/
 
 /* Free brush data */
-static void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd)
+void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd)
 {
 	if(pmd->brush) {
 		if(pmd->brush->dm)
@@ -855,7 +867,7 @@
 	surface->data = NULL;
 }
 
-static void dynamicPaint_freeSurface(DynamicPaintSurface *surface)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list