Fix wrong unified weight paint value version patch, was doing incorrect version check.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 2 May 2012 16:05:25 +0000 (16:05 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 2 May 2012 16:05:25 +0000 (16:05 +0000)
Fix #31209: weight paint sample & fill not using correct brush/unified value.

source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/BKE_brush.h
source/blender/blenkernel/intern/brush.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/sculpt_paint/paint_vertex.c

index 19ca0f8cc61e78c0f4a332d7bbe26a457c7b14d4..4ea38628001abb3212f2bceaf441c9d5e4748dd4 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION                        263
-#define BLENDER_SUBVERSION             2
+#define BLENDER_SUBVERSION             3
 
 #define BLENDER_MINVERSION             250
 #define BLENDER_MINSUBVERSION  0
index 2a62d204e783b701668ae2f8de021ebf8f883733..52666ca1538d08d6e93c8430d48481be00d6e58a 100644 (file)
@@ -100,6 +100,7 @@ void  brush_set_unprojected_radius(struct Scene *scene, struct Brush *brush, flo
 
 float brush_alpha(const struct Scene *scene, struct Brush *brush);
 float brush_weight(const Scene *scene, struct Brush *brush);
+void brush_set_weight(const Scene *scene, struct Brush *brush, float value);
 
 int  brush_use_locked_size(const struct Scene *scene, struct Brush *brush);
 int  brush_use_alpha_pressure(const struct Scene *scene, struct Brush *brush);
index 917c59b35a1fd039cad22c985bf9bf822695be3c..b3d128bf2b47f51a6eed09ee5ef83012a69ea76a 100644 (file)
@@ -718,6 +718,16 @@ float brush_weight(const Scene *scene, Brush *brush)
        return (ups->flag & UNIFIED_PAINT_WEIGHT) ? ups->weight : brush->weight;
 }
 
+void brush_set_weight(const Scene *scene, Brush *brush, float value)
+{
+       UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
+
+       if(ups->flag & UNIFIED_PAINT_WEIGHT)
+               ups->weight = value;
+       else
+               brush->weight = value;
+}
+
 /* scale unprojected radius to reflect a change in the brush's 2D size */
 void brush_scale_unprojected_radius(float *unprojected_radius,
                                                                        int new_brush_size,
index 1813bd499360e6ed22d527b431241c2048d334e9..6c0ac651f13ece26672b2fcd0c184b1af40e0d7e 100644 (file)
@@ -13318,7 +13318,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
-       if (main->versionfile <= 263 && main->subversionfile == 0) {
+       if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 3)) {
                Scene *scene;
                Brush *brush;
 
index 2d984adf5cb8795d38a149f0f82a1c9ea3a3188b..18ddc9659767d5fe038d142bbf0a81943fd833a1 100644 (file)
@@ -1025,7 +1025,9 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        else {
                                MPoly *mp = ((MPoly *)me->mpoly) + (index - 1);
                                const int vgroup_active = vc.obact->actdef - 1;
+                               Scene *scene = vc.scene;
                                ToolSettings *ts = vc.scene->toolsettings;
+                               Brush *brush = paint_brush(&ts->wpaint->paint);
                                float mval_f[2];
                                int v_idx_best = -1;
                                int fidx;
@@ -1048,7 +1050,8 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
                                } while (fidx--);
 
                                if (v_idx_best != -1) { /* should always be valid */
-                                       ts->vgroup_weight = defvert_find_weight(&me->dvert[v_idx_best], vgroup_active);
+                                       float vgroup_weight = defvert_find_weight(&me->dvert[v_idx_best], vgroup_active);
+                                       brush_set_weight(scene, brush, vgroup_weight);
                                        change = TRUE;
                                }
                        }
@@ -2505,8 +2508,11 @@ static int weight_paint_set_exec(bContext *C, wmOperator *UNUSED(op))
 {
        struct Scene *scene = CTX_data_scene(C);
        Object *obact = CTX_data_active_object(C);
+       ToolSettings *ts = CTX_data_tool_settings(C);
+       Brush *brush = paint_brush(&ts->wpaint->paint);
+       float vgroup_weight = brush_weight(scene, brush);
 
-       wpaint_fill(scene->toolsettings->wpaint, obact, scene->toolsettings->vgroup_weight);
+       wpaint_fill(scene->toolsettings->wpaint, obact, vgroup_weight);
        ED_region_tag_redraw(CTX_wm_region(C)); /* XXX - should redraw all 3D views */
        return OPERATOR_FINISHED;
 }