[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37848] branches/soc-2011-carrot: Dynamic Paint:
Miika Hamalainen
miika.hamalainen at kolumbus.fi
Mon Jun 27 09:30:59 CEST 2011
Revision: 37848
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37848
Author: miikah
Date: 2011-06-27 07:30:58 +0000 (Mon, 27 Jun 2011)
Log Message:
-----------
Dynamic Paint:
* Fixed memory leak when baking image sequences.
* Fixed sub-steps when brush was controlled by a parent object.
* Added option to select active outputs for paint surfaces.
* Improved color mixing algorithm.
* Improved memory allocation behavior.
* Memory is now freed even in case of errors.
* Removed "initial color" setting, as it's better to adjust color from material.
* "Paint effects" system:
** Converted to use new data structures.
** Works now with any number of surrounding points.
** Re-implemented support for UV-image surfaces.
** Added support for vertex surfaces too.
** Improved color handling.
** Improved movement stability.
** "Drip" effect uses now Blender's force fields instead of just z-directional gravity like before. Now each surface point can have different force influence.
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/blenloader/intern/readfile.c
branches/soc-2011-carrot/source/blender/blenloader/intern/writefile.c
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/makesrna/intern/rna_object_force.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-06-27 06:07:29 UTC (rev 37847)
+++ branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py 2011-06-27 07:30:58 UTC (rev 37848)
@@ -21,6 +21,7 @@
from bl_ui.properties_physics_common import (
point_cache_ui,
+ effector_weights_ui,
)
class PhysicButtonsPanel():
@@ -123,9 +124,9 @@
ob = context.object
layout.prop(surface, "surface_type", expand=False)
+ layout.separator()
if (surface.surface_type == "PAINT"):
- layout.prop(surface, "initial_color", expand=False)
split = layout.split(percentage=0.8)
split.prop(surface, "dry_speed", text="Dry Time")
split.prop(surface, "use_dry_log", text="Slow")
@@ -189,15 +190,21 @@
col = layout.column()
col.prop(surface, "image_output_path", text="Output directory")
+ col.prop(surface, "image_fileformat", text="Image Format:")
if (surface.surface_type == "PAINT"):
- col.prop(surface, "output_name", text="Paintmap: ")
- col.prop(surface, "premultiply", text="Premultiply alpha")
- col.prop(surface, "output_name2", text="Wetmap: ")
+ col.prop(surface, "do_output1", text="Output Paintmaps:")
+ sub = col.column()
+ sub.active = surface.do_output1
+ sub.prop(surface, "output_name", text="Filename: ")
+ sub.prop(surface, "premultiply", text="Premultiply alpha")
+
+ col.prop(surface, "do_output2", text="Output Wetmaps:")
+ sub = col.column()
+ sub.active = surface.do_output2
+ sub.prop(surface, "output_name2", text="Filename: ")
if (surface.surface_type == "DISPLACE"):
col.prop(surface, "output_name", text="Filename: ")
col.prop(surface, "disp_type", text="Displace Type")
-
- col.prop(surface, "image_fileformat", text="Image Format:")
layout.separator()
layout.operator("dpaint.bake", text="Bake Image Sequence", icon='MOD_DYNAMICPAINT')
@@ -215,7 +222,7 @@
if ((not md) or (md.dynamicpaint_type != 'CANVAS')):
return False;
surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
- return surface and (surface.surface_format != "VERTEX")
+ return surface and (surface.surface_format != "PTEX")
def draw(self, context):
layout = self.layout
@@ -235,7 +242,7 @@
layout.prop(surface, "use_drip")
col = layout.column()
col.active = surface.use_drip
- col.prop(surface, "drip_speed")
+ effector_weights_ui(self, context, surface.effector_weights)
elif surface.effect_ui == "SHRINK":
layout.prop(surface, "use_shrink")
Modified: branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h 2011-06-27 06:07:29 UTC (rev 37847)
+++ branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h 2011-06-27 07:30:58 UTC (rev 37848)
@@ -16,12 +16,16 @@
#include "DNA_dynamicpaint_types.h"
+struct PaintEffectData;
+
/* Actual surface point */
typedef struct PaintSurfaceData {
/* surface format data */
void *format_data;
/* surface type data */
void *type_data;
+ /* paint effects data */
+ struct PaintEffectData *eff_data;
unsigned int total_points;
short samples;
Modified: branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c 2011-06-27 06:07:29 UTC (rev 37847)
+++ branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c 2011-06-27 07:30:58 UTC (rev 37848)
@@ -36,6 +36,7 @@
#include "BKE_depsgraph.h"
#include "BKE_DerivedMesh.h"
#include "BKE_dynamicpaint.h"
+#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_material.h"
@@ -136,37 +137,50 @@
typedef struct PaintBakePoint {
float invNorm[3]; /* current pixel world-space inverted normal. depends on face shading mode */
float normal_scale; /* normal directional scale for displace mapping */
-
- /*
- * Effect / moving layer data
- * ! Only generated if effects enabled ! */
- float gravity_dir; /* UV space direction of gravity */
- float gravity_rate; /* Gravity strength. (Depends on surface angle.) */
} PaintBakePoint;
typedef struct PaintBakeData {
PaintBakePoint *bPoint;
- float *realCoord; /* current pixel center world-space coordinates * numOfSamples */
+ float *realCoord; /* current pixel center world-space coordinates * numOfSamples
+ * ordered as (total_points*sample+index)*3*/
} PaintBakeData;
/* UV Image sequence format point */
-typedef struct PaintTexturePoint {
-
- int neighbour[8]; /* Indexes of 8 neighbouring pixels if exist */
- float neighbour_dist[8]; /* Distances to all 8 neighbouring pixels */
-
-
+typedef struct PaintUVPoint {
/* Pixel / mesh data */
- int face_index, pixel_index; /* face index on domain derived mesh */
- int v1, v2, v3; /* vertex indexes */
+ unsigned int face_index, pixel_index; /* face index on domain derived mesh */
+ unsigned int v1, v2, v3; /* vertex indexes */
- int neighbour_pixel; /* If this pixel isn't uv mapped to any face,
+ unsigned int neighbour_pixel; /* If this pixel isn't uv mapped to any face,
but it's neighbouring pixel is */
short quad;
- struct Vec3f *barycentricWeights; /* b-weights for all pixel samples */
+} PaintUVPoint;
-} PaintTexturePoint;
+typedef struct ImgSeqFormatData {
+ PaintUVPoint *uv_p;
+ Vec3f *barycentricWeights; /* b-weights for all pixel samples */
+} ImgSeqFormatData;
+typedef struct EffVelPoint {
+ float previous_pos[3];
+ float previous_vel[3];
+} EffVelPoint;
+
+typedef struct EffBakeNPoint {
+ float dir[3]; /* vector pointing towards this neighbour */
+ float dist; /* distance to */
+} EffBakeNPoint;
+
+typedef struct PaintEffectData {
+ unsigned int *n_index; /* total_points sized index array */
+ unsigned int *numOf_n; /* num of neighs for each point */
+ unsigned int *n_target; /* array of neighbouring point indexes
+ for single sample use n_index+neigh_num */
+ unsigned int total_targets; /* size of n_target */
+ unsigned int most_neighs;
+ //EffVelPoint *v_point;
+} PaintEffectData;
+
/***************************** General Utils ******************************/
/*
@@ -301,6 +315,24 @@
BLI_uniquename_cb(surfaceDublicateNameExists, surface, name, '.', surface->name, sizeof(surface->name));
}
+/* assumes source alpha > 0.0f */
+static void mixColors(float *t_color, float t_alpha, float *s_color, float s_alpha)
+{
+ float invFact = (s_alpha<t_alpha) ? 1.0f : t_alpha/s_alpha;
+ float factor = 1.0f - invFact;
+ /* set initial color depending on existing alpha */
+ t_color[0] = t_color[0]*invFact + s_color[0]*factor;
+ t_color[1] = t_color[1]*invFact + s_color[1]*factor;
+ t_color[2] = t_color[2]*invFact + s_color[2]*factor;
+
+ /* mix final color */
+ factor = s_alpha;
+ invFact = 1.0f - factor;
+ t_color[0] = t_color[0]*invFact + s_color[0]*factor;
+ t_color[1] = t_color[1]*invFact + s_color[1]*factor;
+ t_color[2] = t_color[2]*invFact + s_color[2]*factor;
+}
+
/***************************** Freeing data ******************************/
/* Free brush data */
@@ -320,14 +352,33 @@
}
}
+static void dynamicPaint_freeEffectData(PaintSurfaceData *data)
+{
+ if (data->eff_data) {
+ if (data->eff_data->n_index) MEM_freeN(data->eff_data->n_index);
+ if (data->eff_data->numOf_n) MEM_freeN(data->eff_data->numOf_n);
+ if (data->eff_data->n_target) MEM_freeN(data->eff_data->n_target);
+ MEM_freeN(data->eff_data);
+ }
+}
+
static void dynamicPaint_freeSurfaceData(DynamicPaintSurface *surface)
{
PaintSurfaceData *data = surface->data;
if (!data) return;
-
- if (data->format_data) MEM_freeN(data->format_data);
+ if (data->format_data) {
+ /* format specific free */
+ if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
+ ImgSeqFormatData *format_data = (ImgSeqFormatData*)data->format_data;
+ if (format_data->uv_p)
+ MEM_freeN(format_data->uv_p);
+ if (format_data->barycentricWeights)
+ MEM_freeN(format_data->barycentricWeights);
+ }
+ MEM_freeN(data->format_data);
+ }
if (data->type_data) MEM_freeN(data->type_data);
-
+ dynamicPaint_freeEffectData(data);
MEM_freeN(surface->data);
surface->data = NULL;
}
@@ -340,6 +391,10 @@
BKE_ptcache_free_list(&(surface->ptcaches));
surface->pointcache = NULL;
+ if(surface->effector_weights)
+ MEM_freeN(surface->effector_weights);
+ surface->effector_weights = NULL;
+
BLI_remlink(&(surface->canvas->surfaces), surface);
dynamicPaint_freeSurfaceData(surface);
MEM_freeN(surface);
@@ -400,7 +455,8 @@
surface->pointcache->step = 1;
/* Set initial values */
- surface->flags = MOD_DPAINT_ANTIALIAS | MOD_DPAINT_MULALPHA | MOD_DPAINT_DRY_LOG | MOD_DPAINT_DISSOLVE_LOG | MOD_DPAINT_ACTIVE | MOD_DPAINT_PREVIEW;
+ surface->flags = MOD_DPAINT_ANTIALIAS | MOD_DPAINT_MULALPHA | MOD_DPAINT_DRY_LOG | MOD_DPAINT_DISSOLVE_LOG |
+ MOD_DPAINT_ACTIVE | MOD_DPAINT_PREVIEW | MOD_DPAINT_OUT1;
surface->effect = 0;
surface->effect_ui = 1;
@@ -416,12 +472,13 @@
surface->substeps = 0;
surface->spread_speed = 1.0f;
- surface->drip_speed = 1.0f;
surface->shrink_speed = 1.0f;
sprintf(surface->image_output_path, "%sdynamicpaint/", "/tmp/");
dynamicPaintSurface_setUniqueName(surface, "Surface");
+ surface->effector_weights = BKE_add_effector_weights(NULL);
+
dynamicPaintSurface_updateType(surface);
BLI_addtail(&canvas->surfaces, surface);
@@ -461,7 +518,7 @@
pmd->brush->psys = NULL;
- pmd->brush->flags = 0;
+ pmd->brush->flags = MOD_DPAINT_ABS_ALPHA;
pmd->brush->collision = MOD_DPAINT_COL_VOLUME;
pmd->brush->mat = NULL;
@@ -584,17 +641,77 @@
}
else return;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list