Revision: 41753
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41753
Author:   miikah
Date:     2011-11-11 10:46:26 +0000 (Fri, 11 Nov 2011)
Log Message:
-----------
Dynamic Paint:
* Renamed "Sharp" proximity falloff to "Constant".
* Added a new "Negate Volume" option for "Volume + Proximity" brush.
* Possible fix for random particle clipping errors.

Modified Paths:
--------------
    
trunk/blender/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
    trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c
    trunk/blender/source/blender/makesdna/DNA_dynamicpaint_types.h
    trunk/blender/source/blender/makesrna/intern/rna_dynamicpaint.c

Modified: 
trunk/blender/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
===================================================================
--- 
trunk/blender/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py  
    2011-11-11 06:37:29 UTC (rev 41752)
+++ 
trunk/blender/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py  
    2011-11-11 10:46:26 UTC (rev 41753)
@@ -414,6 +414,7 @@
                 sub.prop(brush, "proximity_project")
             elif brush.paint_source == 'VOLUME_DISTANCE':
                 sub.prop(brush, "proximity_inverse")
+                sub.prop(brush, "negate_volume")
 
             sub = split.column()
             if brush.paint_source == 'DISTANCE':

Modified: trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c       
2011-11-11 06:37:29 UTC (rev 41752)
+++ trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c       
2011-11-11 10:46:26 UTC (rev 41753)
@@ -3175,13 +3175,20 @@
                                        {
 
                                                float ray_start[3], ray_dir[3];
-                                               float colorband[4] = {0.0f};
-                                               float sample_factor;
+                                               float sample_factor = 0.0f;
                                                float sampleStrength = 0.0f;
                                                BVHTreeRayHit hit;
                                                BVHTreeNearest nearest;
                                                short hit_found = 0;
 
+                                               /* volume sample */
+                                               float volume_factor = 0.0f;
+                                               /* proximity sample */
+                                               float proximity_factor = 0.0f;
+                                               float prox_colorband[4] = 
{0.0f};
+                                               int inner_proximity = 
(brush->flags & MOD_DPAINT_INVERSE_PROX && 
+                                                                               
                   brush->collision == MOD_DPAINT_COL_VOLDIST);
+
                                                /* hit data     */
                                                float hitCoord[3];
                                                int hitFace = -1;
@@ -3236,7 +3243,7 @@
 
                                                                if(hit.index != 
-1) {
                                                                        /* Add 
factor on supersample filter     */
-                                                                       
sampleStrength += sample_factor;
+                                                                       
volume_factor = 1.0f;
                                                                        
hit_found = HIT_VOLUME;
 
                                                                        /* Mark 
hit info */
@@ -3256,8 +3263,6 @@
                                                        float hitCo[3];
                                                        short hQuad;
                                                        int face;
-                                                       int inner_proximity = 
(brush->flags & MOD_DPAINT_INVERSE_PROX && 
-                                                                               
                   brush->collision == MOD_DPAINT_COL_VOLDIST);
 
                                                        /* if inverse prox and 
no hit found, skip this sample */
                                                        if (inner_proximity && 
!hit_found) continue;
@@ -3299,25 +3304,12 @@
 
                                                        /* If a hit was found, 
calculate required values        */
                                                        if (proxDist >= 0.0f && 
proxDist <= brush->paint_distance) {
-                                                               float dist_rate 
= proxDist / brush->paint_distance;
-                                                               float 
prox_influence = 0.0f;
+                                                               
proximity_factor = proxDist / brush->paint_distance;
+                                                               
CLAMP(proximity_factor, 0.0f, 1.0f);
+                                                               if 
(!inner_proximity)
+                                                                       
proximity_factor = 1.0f - proximity_factor;
 
-                                                               /* in case of 
inverse prox also undo volume effect */
-                                                               if 
(inner_proximity) {
-                                                                       
sampleStrength -= sample_factor;
-                                                                       
dist_rate = 1.0f - dist_rate;
-                                                               }
-
-                                                               /* if using 
proximity color ramp use it's alpha */
-                                                               if 
(brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP && 
do_colorband(brush->paint_ramp, dist_rate, colorband))
-                                                                       
prox_influence = colorband[3];
-                                                               else if 
(brush->proximity_falloff == MOD_DPAINT_PRFALL_SMOOTH) {
-                                                                       
prox_influence = (1.0f - dist_rate) * sample_factor;
-                                                               }
-                                                               else 
prox_influence = inner_proximity ? 0.0f : 1.0f;
-
                                                                hit_found = 
HIT_PROXIMITY;
-                                                               sampleStrength 
+= prox_influence*sample_factor;
 
                                                                /* if no volume 
hit, use prox point face info */
                                                                if (hitFace == 
-1) {
@@ -3328,8 +3320,33 @@
                                                        }
                                                }
 
-                                               if (!hit_found) continue;
+                                               /* mix final sample strength 
depending on brush settings */
+                                               if (hit_found) {
+                                                       /* if "negate volume" 
enabled, negate all factors within volume*/
+                                                       if (brush->collision == 
MOD_DPAINT_COL_VOLDIST && brush->flags & MOD_DPAINT_NEGATE_VOLUME) {
+                                                               volume_factor = 
1.0f - volume_factor;
+                                                               if 
(inner_proximity)
+                                                                       
proximity_factor = 1.0f - proximity_factor;
+                                                       }
 
+                                                       /* apply final sample 
depending on final hit type */
+                                                       if (hit_found == 
HIT_VOLUME) {
+                                                               sampleStrength 
= volume_factor;
+                                                       }
+                                                       else if (hit_found == 
HIT_PROXIMITY) {
+                                                               /* apply 
falloff curve to the proximity_factor */
+                                                               if 
(brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP && 
do_colorband(brush->paint_ramp, (1.0f-proximity_factor), prox_colorband))
+                                                                       
proximity_factor = prox_colorband[3];
+                                                               else if 
(brush->proximity_falloff == MOD_DPAINT_PRFALL_CONSTANT)
+                                                                       
proximity_factor = (!inner_proximity || brush->flags & 
MOD_DPAINT_NEGATE_VOLUME) ? 1.0f : 0.0f;
+                                                               /* apply sample 
*/
+                                                               sampleStrength 
= proximity_factor;
+                                                       }
+
+                                                       sampleStrength *= 
sample_factor;
+                                               }
+                                               else continue;
+
                                                /* velocity brush, only do on 
main sample */
                                                if (brush->flags & 
MOD_DPAINT_USES_VELOCITY && ss==0 && brushVelocity) {
                                                        int v1,v2,v3;
@@ -3395,9 +3412,9 @@
                                                        /* Sample proximity 
colorband if required       */
                                                        if ((hit_found == 
HIT_PROXIMITY) && (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP)) {
                                                                if 
(!(brush->flags & MOD_DPAINT_RAMP_ALPHA)) {
-                                                                       
sampleColor[0] = colorband[0];
-                                                                       
sampleColor[1] = colorband[1];
-                                                                       
sampleColor[2] = colorband[2];
+                                                                       
sampleColor[0] = prox_colorband[0];
+                                                                       
sampleColor[1] = prox_colorband[1];
+                                                                       
sampleColor[2] = prox_colorband[2];
                                                                }
                                                        }
 
@@ -3478,7 +3495,7 @@
        float range = solidradius + smooth;
        float particle_timestep = 0.04f * part->timetweak;
 
-       Bounds3D part_bb;
+       Bounds3D part_bb = {0};
 
        if (psys->totpart < 1) return 1;
 
@@ -4482,7 +4499,7 @@
        return ret;
 }
 
-static int surface_needsVelocityData(DynamicPaintSurface *surface, Scene 
*scene, Object *UNUSED(ob))
+static int surface_needsVelocityData(DynamicPaintSurface *surface, Scene 
*scene)
 {
        if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP)
                return 1;
@@ -4509,7 +4526,7 @@
        PaintBakeData *bData = sData->bData;
        DerivedMesh *dm = surface->canvas->dm;
        int index, new_bdata = 0;
-       int do_velocity_data = surface_needsVelocityData(surface, scene, ob);
+       int do_velocity_data = surface_needsVelocityData(surface, scene);
        int do_accel_data = surface_needsAccelerationData(surface);
 
        int canvasNumOfVerts = dm->getNumVerts(dm);

Modified: trunk/blender/source/blender/makesdna/DNA_dynamicpaint_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_dynamicpaint_types.h      
2011-11-11 06:37:29 UTC (rev 41752)
+++ trunk/blender/source/blender/makesdna/DNA_dynamicpaint_types.h      
2011-11-11 10:46:26 UTC (rev 41753)
@@ -144,6 +144,7 @@
 #define MOD_DPAINT_RAMP_ALPHA (1<<4) /* only read falloff ramp alpha */
 #define MOD_DPAINT_PROX_PROJECT (1<<5) /* do proximity check only in defined 
dir */
 #define MOD_DPAINT_INVERSE_PROX (1<<6) /* inverse proximity painting */
+#define MOD_DPAINT_NEGATE_VOLUME (1<<7) /* negates volume influence on "volume 
+ prox" mode */
 
 #define MOD_DPAINT_DO_SMUDGE (1<<8) /* brush smudges existing paint */
 #define MOD_DPAINT_VELOCITY_ALPHA (1<<9) /* multiply brush influence by 
velocity */
@@ -160,7 +161,7 @@
 #define MOD_DPAINT_COL_POINT 4 /* use distance to object center point */
 
 /* proximity_falloff */
-#define MOD_DPAINT_PRFALL_SHARP 0 /* no-falloff */
+#define MOD_DPAINT_PRFALL_CONSTANT 0 /* no-falloff */
 #define MOD_DPAINT_PRFALL_SMOOTH 1 /* smooth, linear falloff */
 #define MOD_DPAINT_PRFALL_RAMP 2 /* use color ramp */
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_dynamicpaint.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_dynamicpaint.c     
2011-11-11 06:37:29 UTC (rev 41752)
+++ trunk/blender/source/blender/makesrna/intern/rna_dynamicpaint.c     
2011-11-11 10:46:26 UTC (rev 41753)
@@ -695,7 +695,7 @@
 
        static EnumPropertyItem prop_dynamicpaint_prox_falloff[] = {
                        {MOD_DPAINT_PRFALL_SMOOTH, "SMOOTH", ICON_SPHERECURVE, 
"Smooth", ""},
-                       {MOD_DPAINT_PRFALL_SHARP, "SHARP", ICON_SHARPCURVE, 
"Sharp", ""},
+                       {MOD_DPAINT_PRFALL_CONSTANT, "CONSTANT", ICON_NOCURVE, 
"Constant", ""},
                        {MOD_DPAINT_PRFALL_RAMP, "RAMP", ICON_COLOR, "Color 
Ramp", ""},
                        {0, NULL, 0, NULL, NULL}};
 
@@ -847,6 +847,11 @@
        RNA_def_property_boolean_sdna(prop, NULL, "flags", 
MOD_DPAINT_INVERSE_PROX);
        RNA_def_property_ui_text(prop, "Inner Proximity", "Proximity falloff is 
applied inside the volume");
        RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, 
"rna_DynamicPaint_redoModifier");
+
+       prop= RNA_def_property(srna, "negate_volume", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flags", 
MOD_DPAINT_NEGATE_VOLUME);
+       RNA_def_property_ui_text(prop, "Negate Volume", "Negate influence 
inside the volume");
+       RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, 
"rna_DynamicPaint_redoModifier");
        
 
        /*

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to