Revision: 38043
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38043
Author:   miikah
Date:     2011-07-02 18:06:39 +0000 (Sat, 02 Jul 2011)
Log Message:
-----------
* Added a new surface type "Waves" that simulates simple 2D wave motion.
* Optimized adjacency point searching for vertex surfaces.
* Separated adjacency code from effect system.
* Overall code cleaning and tweaking.

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/blenkernel/intern/pointcache.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-07-02 16:41:01 UTC (rev 38042)
+++ 
branches/soc-2011-carrot/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
   2011-07-02 18:06:39 UTC (rev 38043)
@@ -104,7 +104,12 @@
                         col.prop(brush, "paint_color", text="")
                         col.prop(brush, "paint_alpha", text="Alpha")
                 
-                if (brush.brush_settings_context != "GENERAL"):
+                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")
+                else:
                     layout.label(text="-WIP-")
 
 
@@ -131,7 +136,7 @@
             split.prop(surface, "dry_speed", text="Dry Time")
             split.prop(surface, "use_dry_log", text="Slow")
             
-        if (surface.surface_type != "IWAVE"):
+        if (surface.surface_type != "WAVE"):
             if (surface.surface_type == "DISPLACE"):
                 layout.prop(surface, "use_dissolve", text="Dissolve:")
             elif (surface.surface_type == "WEIGHT"):
@@ -144,6 +149,19 @@
             split.prop(surface, "dissolve_speed", text="Time")
             split.prop(surface, "use_dissolve_log", text="Slow")
             
+        if (surface.surface_type == "WAVE"):
+            layout.prop(surface, "wave_open_borders")
+            
+            split = layout.split()
+            
+            col = split.column(align=True)
+            col.prop(surface, "wave_timescale")
+            col.prop(surface, "wave_speed")
+            
+            col = split.column(align=True)
+            col.prop(surface, "wave_damping")
+            col.prop(surface, "wave_spring")
+            
         layout.label(text="Brush Group:")
         layout.prop(surface, "brush_group", text="")
 
@@ -158,7 +176,7 @@
         if ((not md) or (md.dynamicpaint_type != 'CANVAS')):
             return 0
         surface = context.dynamic_paint.canvas_settings.canvas_surfaces.active
-        return (surface and (not (surface.surface_format=="VERTEX" and 
surface.surface_type=="DISPLACE") ))
+        return (surface and not (surface.surface_format=="VERTEX" and 
(surface.surface_type=="DISPLACE" or surface.surface_type=="WAVE")))
 
     def draw(self, context):
         layout = self.layout
@@ -202,9 +220,10 @@
                 sub = col.column()
                 sub.active = surface.do_output2
                 sub.prop(surface, "output_name2", text="Filename: ")
-            if (surface.surface_type == "DISPLACE"):
+            else:
                 col.prop(surface, "output_name", text="Filename: ")
-                col.prop(surface, "disp_type", text="Displace Type")
+                if (surface.surface_type == "DISPLACE"):
+                    col.prop(surface, "disp_type", text="Displace Type")
             
             layout.separator()
             layout.operator("dpaint.bake", text="Bake Image Sequence", 
icon='MOD_DYNAMICPAINT')

Modified: branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h
===================================================================
--- branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h       
2011-07-02 16:41:01 UTC (rev 38042)
+++ branches/soc-2011-carrot/source/blender/blenkernel/BKE_dynamicpaint.h       
2011-07-02 18:06:39 UTC (rev 38043)
@@ -24,8 +24,8 @@
        void *format_data;
        /* surface type data */
        void *type_data;
-       /* paint effects data */
-       struct PaintEffectData *eff_data;
+       /* point neighbor data */
+       struct PaintAdjData *adj_data;
 
        unsigned int total_points;
        short samples;
@@ -49,27 +49,28 @@
        float alpha;
 } PaintPoint;
 
-/* iWave type surface point    */
-typedef struct PaintIWavePoint {               
+/* heigh field waves   */
+typedef struct PaintWavePoint {                
 
-       float source;
-       float obstruction;
-       float height, previousHeight;
-
+       float height;
+       float velocity;
+       short state; /* 0 = neutral
+                                *  1 = obstacle
+                                *  2 = reflect only */
        float foam;
 
-       float verticalDerivative;
+} PaintWavePoint;
 
-} PaintIWavePoint;
-
 struct DerivedMesh *dynamicPaint_Modifier_do(struct DynamicPaintModifierData 
*pmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm);
-void dynamicPaint_cacheUpdateFrames(struct DynamicPaintSurface *surface);
-int dynamicPaint_resetSurface(struct DynamicPaintSurface *surface);
-int dynamicPaint_surfaceHasPreview(DynamicPaintSurface *surface);
-void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface);
-void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, char 
*basename);
 void dynamicPaint_Modifier_free (struct DynamicPaintModifierData *pmd);
 void dynamicPaint_Modifier_createType(struct DynamicPaintModifierData *pmd);
 void dynamicPaint_Modifier_copy(struct DynamicPaintModifierData *pmd, struct 
DynamicPaintModifierData *tsmd);
 
+void dynamicPaint_cacheUpdateFrames(struct DynamicPaintSurface *surface);
+void dynamicPaint_clearSurface(DynamicPaintSurface *surface);
+int  dynamicPaint_resetSurface(struct DynamicPaintSurface *surface);
+int  dynamicPaint_surfaceHasPreview(DynamicPaintSurface *surface);
+void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface);
+void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, char 
*basename);
+
 #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-07-02 16:41:01 UTC (rev 38042)
+++ branches/soc-2011-carrot/source/blender/blenkernel/intern/dynamicpaint.c    
2011-07-02 18:06:39 UTC (rev 38043)
@@ -166,20 +166,23 @@
        float previous_vel[3];
 } EffVelPoint;
 
-typedef struct EffBakeNPoint {
+typedef struct BakeNeighPoint {
        float dir[3];   /* vector pointing towards this neighbour */
        float dist;             /* distance to */
-} EffBakeNPoint;
+} BakeNeighPoint;
 
-typedef struct PaintEffectData {
+
+/* adjacency data flags */
+#define ADJ_ON_MESH_EDGE (1<<0)
+
+typedef struct PaintAdjData {
        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 *flags;            /* for each point */
        unsigned int total_targets; /* size of n_target */
-       unsigned int most_neighs;
-       //EffVelPoint *v_point;
-} PaintEffectData;
+} PaintAdjData;
 
 /***************************** General Utils ******************************/
 
@@ -286,8 +289,8 @@
        else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
                strcat(surface->output_name,"weight");
        }
-       else if (surface->type == MOD_DPAINT_SURFACE_T_IWAVE) {
-               strcat(surface->output_name,"iwave");
+       else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
+               strcat(surface->output_name,"wave");
                strcat(surface->output_name2,"foam");
        }
 
@@ -354,11 +357,12 @@
 
 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);
+       if (data->adj_data) {
+               if (data->adj_data->n_index) MEM_freeN(data->adj_data->n_index);
+               if (data->adj_data->numOf_n) MEM_freeN(data->adj_data->numOf_n);
+               if (data->adj_data->n_target) 
MEM_freeN(data->adj_data->n_target);
+               if (data->adj_data->flags) MEM_freeN(data->adj_data->flags);
+               MEM_freeN(data->adj_data);
        }
 }
 
@@ -474,6 +478,11 @@
        surface->spread_speed = 1.0f;
        surface->shrink_speed = 1.0f;
 
+       surface->wave_damping = 0.05f;
+       surface->wave_speed = 0.8f;
+       surface->wave_timescale = 1.0f;
+       surface->wave_spring = 0.20;
+
        sprintf(surface->image_output_path, "%sdynamicpaint/", "/tmp/");
        dynamicPaintSurface_setUniqueName(surface, "Surface");
 
@@ -534,9 +543,11 @@
                        pmd->brush->displace_distance = 0.5f;
                        pmd->brush->prox_displace_strength = 0.5f;
 
-                       pmd->brush->particle_radius = 0.2;
-                       pmd->brush->particle_smooth = 0.05;
+                       pmd->brush->particle_radius = 0.2f;
+                       pmd->brush->particle_smooth = 0.05f;
 
+                       pmd->brush->wave_factor = 1.0f;
+
                        pmd->brush->dm = NULL;
 
                        /*
@@ -636,22 +647,27 @@
        else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
                sData->type_data = 
MEM_callocN(sizeof(float)*sData->total_points, "DynamicPaintSurface 
WeightData");
        }
-       else if (surface->type == MOD_DPAINT_SURFACE_T_IWAVE) {
-               sData->type_data = 
MEM_callocN(sizeof(PaintIWavePoint)*sData->total_points, "DynamicPaintSurface 
iWaveData");
+       else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
+               sData->type_data = 
MEM_callocN(sizeof(PaintWavePoint)*sData->total_points, "DynamicPaintSurface 
WaveData");
        }
        else return;
 
        if (sData->type_data == NULL) printError(surface->canvas, "Not enough 
free memory!");
 }
 
+static int surface_usesNeighData(DynamicPaintSurface *surface) {
+       return (surface->type == MOD_DPAINT_SURFACE_T_PAINT ||
+                   surface->type == MOD_DPAINT_SURFACE_T_WAVE);
+}
 
-/* initialize "paint effect" data */
-static void dynamicPaint_initEffectData(DynamicPaintSurface *surface) {
+/* initialize surface adjacency data */
+static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface) {
        PaintSurfaceData *sData = surface->data;
-       PaintEffectData *ed;
+       PaintAdjData *ed;
+       int *temp_data;
        int neigh_points = 0;
 
-       if (!surface->effect) return;
+       if (!surface->effect && !surface_usesNeighData(surface)) return;
 
        if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
                /* For vertex format, neighbours are connected by edges */
@@ -663,58 +679,110 @@
        if (!neigh_points) return;
 
        /* allocate memory */
-       ed = sData->eff_data = MEM_callocN(sizeof(PaintEffectData), "Surface 
Effect Data");
+       ed = sData->adj_data = MEM_callocN(sizeof(PaintAdjData), "Surface Adj 
Data");
        if (!ed) return;
-       ed->n_index = MEM_callocN(sizeof(int)*sData->total_points, "Surface 
Effect Index");

@@ 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