Revision: 39590
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39590
Author:   miikah
Date:     2011-08-21 19:03:47 +0000 (Sun, 21 Aug 2011)
Log Message:
-----------
Dynamic Paint:
* Bake calculation memory is now freed if surface is deactivated or baked.
* Fixed possibly incorrect brush influence when using "Non-Closed" brush 
setting.
* Added new rna property descriptions.
* Added some comments and general 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/makesdna/DNA_dynamicpaint_types.h
    branches/soc-2011-carrot/source/blender/makesrna/intern/rna_dynamicpaint.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-08-21 18:57:33 UTC (rev 39589)
+++ 
branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
   2011-08-21 19:03:47 UTC (rev 39590)
@@ -400,7 +400,7 @@
             if (brush.paint_source != 'POINT'):
                 sub.prop(brush, "prox_facealigned")
             sub = split.column()
-            sub.prop(brush, "prox_falloff", text="Falloff")
+            sub.prop(brush, "prox_falloff")
             if brush.paint_source == "VOLDIST":
                 col = layout.row().column()
                 col.prop(brush, "prox_inverse")

Modified: branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h       
2011-08-21 18:57:33 UTC (rev 39589)
+++ branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h       
2011-08-21 19:03:47 UTC (rev 39590)
@@ -21,14 +21,11 @@
 
 /* Actual surface point        */
 typedef struct PaintSurfaceData {
-       /* surface format data */
-       void *format_data;
-       /* surface type data */
-       void *type_data;
-       /* point neighbor data */
-       struct PaintAdjData *adj_data;
+       void *format_data; /* special data for each surface "format" */
+       void *type_data; /* data used by specific surface type */
+       struct PaintAdjData *adj_data; /* adjacency data for current surface */
 
-       struct PaintBakeData *bData;
+       struct PaintBakeData *bData; /* temporary per step data used for frame 
calculation */
        unsigned int total_points;
 
 } PaintSurfaceData;

Modified: 
branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c    
2011-08-21 18:57:33 UTC (rev 39589)
+++ branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c    
2011-08-21 19:03:47 UTC (rev 39590)
@@ -130,12 +130,12 @@
 
 typedef struct VolumeGrid {
        int x,y,z;
-       Bounds3D grid_bounds;
+       Bounds3D grid_bounds; /* whole grid bounds */
 
        Bounds3D *bounds;       /* (x*y*z) precalculated grid cell bounds */
-       unsigned int *s_pos; /* (x*y*z) search indexses */
-       unsigned int *s_num; /* (x*y*z) number of points */
-       unsigned int *t_index; /* actual point index,
+       unsigned int *s_pos; /* (x*y*z) t_index begin id */
+       unsigned int *s_num; /* (x*y*z) number of t_index points */
+       unsigned int *t_index; /* actual surface point index,
                                                   access: (s_pos+s_num) */
 } VolumeGrid;
 
@@ -158,42 +158,42 @@
 typedef struct PaintBakeData {
        /* point space data */
        PaintBakeNormal *bNormal;
-       unsigned int *s_pos;            /* index to start reading point sample 
realCoord */
-       unsigned int *s_num;    /* num of samples for each point */
-       Vec3f *realCoord;  /* current pixel center world-space coordinates * 
numOfSamples
-                                          *  ordered as (s_pos+sample_num)*/
+       unsigned int *s_pos;    /* index to start reading point sample 
realCoord */
+       unsigned int *s_num;    /* num of realCoord samples */
+       Vec3f *realCoord;  /* current pixel center world-space coordinates for 
each sample
+                                          *  ordered as (s_pos+s_num)*/
 
-       /* adjacency */
-       BakeNeighPoint *bNeighs; /* current frame neighbour distances, if 
required */
+       /* adjacency info */
+       BakeNeighPoint *bNeighs; /* current global neighbour distances and 
directions, if required */
        double average_dist;
        /* space partitioning */
-       VolumeGrid *grid;       /* space partitioning grid to optimize brush 
checks */
+       VolumeGrid *grid;               /* space partitioning grid to optimize 
brush checks */
 
        /* velocity and movement */
-       Vec3f *velocity;  /* speed vector in global space movement per frame, 
if required */
+       Vec3f *velocity;                /* speed vector in global space 
movement per frame, if required */
        Vec3f *prev_velocity;
-       float *brush_velocity; /* special temp data for post-p velocity based 
brushes like smudge
-                                                  *  3 float dir vec + 1 float 
str */
-       MVert *prev_verts;      /* copy of previous frame vertices. used to 
observe surface movement */
+       float *brush_velocity;  /* special temp data for post-p velocity based 
brushes like smudge
+                                                       *  3 float dir vec + 1 
float str */
+       MVert *prev_verts;              /* copy of previous frame vertices. 
used to observe surface movement */
        float prev_obmat[4][4]; /* previous frame object matrix */
-       int clear;
+       int clear;                              /* flag to check if surface was 
cleared/reset -> have to redo velocity etc. */
 
 } PaintBakeData;
 
 /* UV Image sequence format point      */
 typedef struct PaintUVPoint {
        /* Pixel / mesh data */
-       unsigned int face_index, pixel_index;           /* face index on domain 
derived mesh */
-       unsigned 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 */
 
        unsigned int neighbour_pixel;   /* If this pixel isn't uv mapped to any 
face,
-                                                       but it's neighbouring 
pixel is */
+                                                                          but 
it's neighbouring pixel is */
        short quad;
 } PaintUVPoint;
 
 typedef struct ImgSeqFormatData {
        PaintUVPoint *uv_p;
-       Vec3f *barycentricWeights;      /* b-weights for all pixel samples */
+       Vec3f *barycentricWeights;              /* b-weights for all pixel 
samples */
 } ImgSeqFormatData;
 
 typedef struct EffVelPoint {
@@ -207,7 +207,7 @@
 
 typedef struct PaintAdjData {
        unsigned int *n_target;         /* array of neighbouring point indexes,
-                                                          for single sample 
use (n_index+neigh_num) */
+                                                              for single 
sample use (n_index+neigh_num) */
        unsigned int *n_index;          /* index to start reading n_target for 
each point */
        unsigned int *n_num;            /* num of neighs for each point */
        unsigned int *flags;            /* vertex adjacency flags */
@@ -247,7 +247,8 @@
 }
 
 /* checks whether surface's format/type has realtime preview */
-int dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface) {
+int dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface)
+{
        if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return 0;
        else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
                if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE ||
@@ -300,7 +301,8 @@
 }
 
 /* change surface data to defaults on new type */
-void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface) {
+void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface)
+{
        if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
                surface->output_name[0]='\0';
                surface->output_name2[0]='\0';
@@ -370,7 +372,8 @@
        return 0;
 }
 
-void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, char 
*basename) {
+void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, char 
*basename)
+{
        char name[64];
        strncpy(name, basename, 62); /* in case basename is surface->name use a 
copy */
        BLI_uniquename_cb(surfaceDublicateNameExists, surface, name, '.', 
surface->name, sizeof(surface->name));
@@ -792,6 +795,17 @@
        }
 }
 
+/* free surface data if it's not used anymore */
+void surface_freeUnusedData(DynamicPaintSurface *surface)
+{
+       if (!surface->data) return;
+
+       /* free bakedata if not active or surface is baked */
+       if (!(surface->flags & MOD_DPAINT_ACTIVE) ||
+               (surface->pointcache && surface->pointcache->flag & 
PTCACHE_BAKED))
+               free_bakeData(surface->data);
+}
+
 static void dynamicPaint_freeSurfaceData(DynamicPaintSurface *surface)
 {
        PaintSurfaceData *data = surface->data;
@@ -983,9 +997,6 @@
                        pmd->brush->paint_distance = 0.1f;
                        pmd->brush->proximity_falloff = 
MOD_DPAINT_PRFALL_SMOOTH;
 
-                       pmd->brush->displace_distance = 0.5f;
-                       pmd->brush->prox_displace_strength = 0.5f;
-
                        pmd->brush->particle_radius = 0.2f;
                        pmd->brush->particle_smooth = 0.05f;
 
@@ -1062,8 +1073,6 @@
                tpmd->brush->particle_smooth = pmd->brush->particle_smooth;
                tpmd->brush->paint_distance = pmd->brush->paint_distance;
                tpmd->brush->psys = pmd->brush->psys;
-               tpmd->brush->displace_distance = pmd->brush->displace_distance;
-               tpmd->brush->prox_displace_strength = 
pmd->brush->prox_displace_strength;
 
                tpmd->brush->paint_ramp = pmd->brush->paint_ramp;
 
@@ -1093,13 +1102,15 @@
        if (sData->type_data == NULL) printError(surface->canvas, "Not enough 
free memory!");
 }
 
-static int surface_usesAdjDistance(DynamicPaintSurface *surface) {
+static int surface_usesAdjDistance(DynamicPaintSurface *surface)
+{
        if (surface->type == MOD_DPAINT_SURFACE_T_PAINT && surface->effect) 
return 1;
        if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) return 1;
        return 0;
 }
 
-static int surface_usesAdjData(DynamicPaintSurface *surface) {
+static int surface_usesAdjData(DynamicPaintSurface *surface)
+{
        if (surface_usesAdjDistance(surface)) return 1;
        if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX &&
                surface->flags & MOD_DPAINT_ANTIALIAS) return 1;
@@ -1108,7 +1119,8 @@
 }
 
 /* initialize surface adjacency data */
-static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int 
force_init) {
+static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int 
force_init)
+{
        PaintSurfaceData *sData = surface->data;
        PaintAdjData *ed;
        int *temp_data;
@@ -1213,7 +1225,8 @@
 }
 
 /* clears surface data back to zero */
-void dynamicPaint_clearSurface(DynamicPaintSurface *surface) {
+void dynamicPaint_clearSurface(DynamicPaintSurface *surface)
+{
        PaintSurfaceData *sData = surface->data;
        if (sData && sData->type_data) {
                unsigned int data_size;
@@ -1572,6 +1585,9 @@
                for (; surface; surface=surface->next) {
                        int current_frame = (int)scene->r.cfra;
 
+                       /* free bake data if not required anymore */
+                       surface_freeUnusedData(surface);
+
                        /* image sequences are handled by bake operator */
                        if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) 
continue;
                        if (!(surface->flags & MOD_DPAINT_ACTIVE)) continue;
@@ -3183,6 +3199,8 @@
 
 static int meshBrush_boundsIntersect(Bounds3D *b1, Bounds3D *b2, 
DynamicPaintBrushSettings *brush)
 {
+       if (brush->flags & MOD_DPAINT_ACCEPT_NONCLOSED)
+               return 1;
        if (brush->collision == MOD_DPAINT_COL_VOLUME)
                return boundsIntersect(b1, b2);
        else if (brush->collision == MOD_DPAINT_COL_DIST || brush->collision == 
MOD_DPAINT_COL_VOLDIST)
@@ -4636,7 +4654,8 @@

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to