Revision: 39034
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39034
Author:   jwilkins
Date:     2011-08-04 20:01:07 +0000 (Thu, 04 Aug 2011)
Log Message:
-----------
all paint_stroke callbacks are now checked for being null.  paint_stroke will 
just ignore any actions that require a call back that has been set to null

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c

Modified: 
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c  
2011-08-04 18:28:51 UTC (rev 39033)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c  
2011-08-04 20:01:07 UTC (rev 39034)
@@ -289,7 +289,7 @@
        }
 }
 
-void paint_stroke_apply(
+static void apply_symmetric(
        const struct bContext *C,
        struct PaintStroke *stroke)
 {
@@ -302,13 +302,13 @@
           always do first pass (usually the only pass), or
           do passes that have bits in common with mirror_symm, and
           some combinations may be redundant, so
-            if mirror_symm is XZ skip pass XY, and
-            if mirror_symm is YZ skip passes XY and XZ */
+                if mirror_symm is XZ skip pass XY, and
+                if mirror_symm is YZ skip passes XY and XZ */
        for (pass= 0; pass <= mirror_symm; pass++) {
                if ((pass == 0) ||
-                   ((mirror_symm & pass) &&
-                    (mirror_symm != 5 || pass != 3) &&
-                    (mirror_symm != 6 || (pass != 3 && pass != 5))))
+                       ((mirror_symm & pass) &&
+                        (mirror_symm != 5 || pass != 3) &&
+                        (mirror_symm != 6 || (pass != 3 && pass != 5))))
                {
                        stroke->update_symmetry(C, stroke, pass, 0, 0);
 
@@ -321,8 +321,20 @@
        }
 }
 
+void paint_stroke_apply(
+       const struct bContext *C,
+       struct PaintStroke *stroke)
+{
+       if (stroke->apply) {
+               if (stroke->update_symmetry)
+                       apply_symmetric(C, stroke);
+               else
+                       stroke->apply(C, stroke);
+       }
+}
 
 
+
 /* Stroke Predicates
  *****************************************************************************/
 
@@ -401,9 +413,11 @@
        /* parameters should be read-only from within paint-stroke module,
           but mutable by the init_params callback */
 
-       stroke->init_params(
-               C,
-               (struct PaintStrokeParams *)&(stroke->params)); /* cast away 
const */
+       if (stroke->init_params) {
+               stroke->init_params(
+                       C,
+                       (struct PaintStrokeParams *)&(stroke->params)); /* cast 
away const */
+       }
 }
 
 void paint_stroke_update_params(
@@ -413,10 +427,12 @@
        /* parameters should be read-only from within paint-stroke module,
           but mutable by the update_params callback */
 
-       stroke->update_params(
-               C,
-               (struct PaintStrokeParams *)&(stroke->params), /* cast away 
const */
-               stroke);
+       if (stroke->update_params) {
+               stroke->update_params(
+                       C,
+                       (struct PaintStrokeParams *)&(stroke->params), /* cast 
away const */
+                       stroke);
+       }
 }
 
 void paint_stroke_new(
@@ -496,11 +512,13 @@
                }
 
                /* Temporary Setting Switch */
-               if (RNA_property_is_set(ptr, "switch")) {
+               if (stroke->alt &&
+                       stroke->temp_switch &&
+                       stroke->temp_unswitch &&
+                       RNA_property_is_set(ptr, "switch"))
+               {
                        RNA_string_get(ptr, "switch", temp_switch_name);
-
-                       if (stroke->alt && stroke->temp_switch && 
stroke->temp_unswitch)
-                               stroke->temp_switch(C, stroke, 
temp_switch_name);
+                       stroke->temp_switch(C, stroke, temp_switch_name);
                }
 
                init_params(C, stroke);
@@ -541,7 +559,8 @@
 
        stroke->start_time= PIL_check_seconds_timer();
 
-       stroke->start(C, stroke);
+       if (stroke->start)
+               stroke->start(C, stroke);
 
        paint_stroke_update_params(C, stroke);
 }
@@ -550,7 +569,9 @@
        const struct bContext *C,
        struct PaintStroke *stroke)
 {
-       return !(stroke->started) && stroke->test_start(C, stroke);
+       return
+               !(stroke->started) &&
+               ((!stroke->test_start) || stroke->test_start(C, stroke));
 }
 
 static void stroke_done(
@@ -583,8 +604,9 @@
        struct PaintStroke *stroke,
        struct PointerRNA *itemptr)
 {
-       if (!(stroke->params.flag & STROKE_LINE) &&
-               (stroke->params.flag & STROKE_RESTORE))
+       if (stroke->restore &&
+           !(stroke->params.flag & STROKE_LINE) &&
+           (stroke->params.flag & STROKE_RESTORE))
        {
                stroke->restore(C);
        }
@@ -613,7 +635,8 @@
                        dtime);
        }
        else {
-               stroke->update_step(C, stroke);
+               if (stroke->update_step)
+                       stroke->update_step(C, stroke);
        }
 
        stroke->path= stroke->current;
@@ -1548,8 +1571,11 @@
        float delta[2];
        float distance;
 
-       if (stroke->params.flag & STROKE_RESTORE)
+       if (stroke->restore &&
+           stroke->params.flag & STROKE_RESTORE)
+       {
                stroke->restore(C);
+       }
 
        sub_v2_v2v2(delta, stroke->current.mouse, stroke->start_mouse);
 

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

Reply via email to