Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Mon, 2 Jul 2018 16:18:16 +0000 (18:18 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 2 Jul 2018 16:18:16 +0000 (18:18 +0200)
intern/cycles/util/util_ssef.h
source/blender/editors/sculpt_paint/paint_stroke.c

index bb007ff84a92cbf580a3b837e8d5e8bb1c1451e5..e9a617bb2cc38db779649ee53926f96858f49dbd 100644 (file)
@@ -606,7 +606,7 @@ ccl_device_inline const ssef uint32_to_float(const ssei &in)
 template<size_t S1, size_t S2, size_t S3, size_t S4>
 ccl_device_inline const ssef set_sign_bit(const ssef &a)
 {
-       return a ^ cast(ssei(S1 << 31, S2 << 31, S3 << 31, S4 << 31));
+       return cast(cast(a) ^ ssei(S1 << 31, S2 << 31, S3 << 31, S4 << 31));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
index 80211c4673315a97b5fdf29cbe66519854ea8a84..21afb9493305f53d2d8057316ffdccf09a21fbcb 100644 (file)
@@ -242,13 +242,14 @@ static bool paint_tool_require_location(Brush *brush, ePaintMode mode)
 }
 
 /* Initialize the stroke cache variants from operator properties */
-static bool paint_brush_update(bContext *C,
-                               Brush *brush,
-                               ePaintMode mode,
-                               struct PaintStroke *stroke,
-                               const float mouse_init[2],
-                               float mouse[2], float pressure,
-                               float location[3])
+static bool paint_brush_update(
+        bContext *C,
+        Brush *brush,
+        ePaintMode mode,
+        struct PaintStroke *stroke,
+        const float mouse_init[2],
+        float mouse[2], float pressure,
+        float r_location[3], bool *r_location_is_set)
 {
        Scene *scene = CTX_data_scene(C);
        UnifiedPaintSettings *ups = stroke->ups;
@@ -259,6 +260,7 @@ static bool paint_brush_update(bContext *C,
        bool is_dry_run = false;
        bool do_random = false;
        bool do_random_mask = false;
+       *r_location_is_set = false;
        /* XXX: Use pressure value from first brush step for brushes which don't
         *      support strokes (grab, thumb). They depends on initial state and
         *      brush coord/pressure/etc.
@@ -357,10 +359,11 @@ static bool paint_brush_update(bContext *C,
                        halfway[1] = dy * 0.5f + stroke->initial_mouse[1];
 
                        if (stroke->get_location) {
-                               if (stroke->get_location(C, location, halfway)) {
+                               if (stroke->get_location(C, r_location, halfway)) {
                                        hit = true;
                                        location_sampled = true;
                                        location_success = true;
+                                       *r_location_is_set = true;
                                }
                                else if (!paint_tool_require_location(brush, mode)) {
                                        hit = true;
@@ -430,14 +433,17 @@ static bool paint_brush_update(bContext *C,
 
        if (!location_sampled) {
                if (stroke->get_location) {
-                       if (stroke->get_location(C, location, mouse))
+                       if (stroke->get_location(C, r_location, mouse)) {
                                location_success = true;
+                               *r_location_is_set = true;
+                       }
                        else if (!paint_tool_require_location(brush, mode))
                                location_success = true;
                }
                else {
-                       zero_v3(location);
+                       zero_v3(r_location);
                        location_success = true;
+                       /* don't set 'r_location_is_set', since we don't want to use the value. */
                }
        }
 
@@ -516,8 +522,13 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const float
        }
 
 
-       ups->last_hit = paint_brush_update(C, brush, mode, stroke, mouse_in, mouse_out, pressure, location);
-       copy_v3_v3(ups->last_location, location);
+       bool is_location_is_set;
+       ups->last_hit = paint_brush_update(
+               C, brush, mode, stroke, mouse_in, mouse_out, pressure,
+               location, &is_location_is_set);
+       if (is_location_is_set) {
+               copy_v3_v3(ups->last_location, location);
+       }
        if (!ups->last_hit) {
                return;
        }