Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / sculpt_paint / sculpt.c
index c067428..5dd7f23 100644 (file)
@@ -631,7 +631,7 @@ bool sculpt_brush_test_cube(SculptBrushTest *test, const float co[3], float loca
 
        if (local_co[0] <= side && local_co[1] <= side && local_co[2] <= side) {
                float p = 4.0f;
-               
+
                test->dist = ((powf(local_co[0], p) +
                               powf(local_co[1], p) +
                               powf(local_co[2], p)) / powf(side, p));
@@ -730,7 +730,7 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis,
 {
        float mirror[3];
        float distsq;
-       
+
        /* flip_v3_v3(mirror, cache->traced_location, symm); */
        flip_v3_v3(mirror, cache->true_location, symm);
 
@@ -1119,7 +1119,7 @@ static float brush_strength(
                case SCULPT_TOOL_DRAW:
                case SCULPT_TOOL_LAYER:
                        return alpha * flip * pressure * overlap * feather;
-                       
+
                case SCULPT_TOOL_MASK:
                        overlap = (1 + overlap) / 2;
                        switch ((BrushMaskTool)brush->mask_tool) {
@@ -1152,7 +1152,7 @@ static float brush_strength(
                        }
                        else {
                                /* reduce strength for DEEPEN, PEAKS, and CONTRAST */
-                               return 0.5f * alpha * flip * pressure * overlap * feather; 
+                               return 0.5f * alpha * flip * pressure * overlap * feather;
                        }
 
                case SCULPT_TOOL_SMOOTH:
@@ -1209,7 +1209,7 @@ float tex_strength(SculptSession *ss, const Brush *br,
                avg = 1;
        }
        else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) {
-               /* Get strength by feeding the vertex 
+               /* Get strength by feeding the vertex
                 * location directly into a texture */
                avg = BKE_brush_sample_tex_3D(scene, br, point, rgba, 0, ss->tex_pool);
        }
@@ -1219,7 +1219,7 @@ float tex_strength(SculptSession *ss, const Brush *br,
 
                /* if the active area is being applied for symmetry, flip it
                 * across the symmetry axis and rotate it back to the original
-                * position in order to project it. This insures that the 
+                * position in order to project it. This insures that the
                 * brush texture will be oriented correctly. */
 
                flip_v3_v3(symm_point, point, cache->mirror_symmetry_pass);
@@ -1279,16 +1279,16 @@ bool sculpt_search_sphere_cb(PBVHNode *node, void *data_v)
                BKE_pbvh_node_get_original_BB(node, bb_min, bb_max);
        else
                BKE_pbvh_node_get_BB(node, bb_min, bb_max);
-       
+
        for (i = 0; i < 3; ++i) {
                if (bb_min[i] > center[i])
                        nearest[i] = bb_min[i];
                else if (bb_max[i] < center[i])
                        nearest[i] = bb_max[i];
                else
-                       nearest[i] = center[i]; 
+                       nearest[i] = center[i];
        }
-       
+
        sub_v3_v3v3(t, center, nearest);
 
        return len_squared_v3(t) < data->radius_squared;
@@ -1399,7 +1399,7 @@ static void update_sculpt_normal(Sculpt *sd, Object *ob,
 {
        const Brush *brush = BKE_paint_brush(&sd->paint);
        StrokeCache *cache = ob->sculpt->cache;
-       
+
        if (cache->mirror_symmetry_pass == 0 &&
            cache->radial_symmetry_pass == 0 &&
            (cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
@@ -2041,7 +2041,7 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
 {
        SculptSession *ss = ob->sculpt;
        Brush *brush = BKE_paint_brush(&sd->paint);
-       
+
        switch ((BrushMaskTool)brush->mask_tool) {
                case BRUSH_MASK_DRAW:
                        do_mask_brush_draw(sd, ob, nodes, totnode);
@@ -2192,7 +2192,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
        mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius);
        mul_v3_v3(offset, ss->cache->scale);
        mul_v3_fl(offset, bstrength);
-       
+
        /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */
        crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor;
        brush_alpha = BKE_brush_alpha_get(scene, brush);
@@ -4040,7 +4040,7 @@ static void do_symmetrical_brush_actions(
        cache->bstrength = brush_strength(sd, cache, feather, ups);
        cache->symmetry = symm;
 
-       /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ 
+       /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
        for (i = 0; i <= symm; ++i) {
                if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) {
                        cache->mirror_symmetry_pass = i;
@@ -4175,14 +4175,14 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
                    (md->mode & eModifierMode_Realtime))
                {
                        MirrorModifierData *mmd = (MirrorModifierData *)md;
-                       
+
                        if (mmd->flag & MOD_MIR_CLIPPING) {
                                /* check each axis for mirroring */
                                for (i = 0; i < 3; ++i) {
                                        if (mmd->flag & (MOD_MIR_AXIS_X << i)) {
                                                /* enable sculpt clipping */
                                                ss->cache->flag |= CLIP_X << i;
-                                               
+
                                                /* update the clip tolerance */
                                                if (mmd->tolerance >
                                                    ss->cache->clip_tolerance[i])
@@ -4271,7 +4271,7 @@ static void sculpt_update_cache_invariants(
                        Paint *p = &sd->paint;
                        Brush *br;
                        int size = BKE_brush_size_get(scene, brush);
-               
+
                        BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2,
                                    sizeof(cache->saved_active_brush_name));
 
@@ -4367,7 +4367,7 @@ static void sculpt_update_cache_invariants(
 #define PIXEL_INPUT_THRESHHOLD 5
        if (brush->sculpt_tool == SCULPT_TOOL_ROTATE)
                cache->dial = BLI_dial_initialize(cache->initial_mouse, PIXEL_INPUT_THRESHHOLD);
-               
+
 #undef PIXEL_INPUT_THRESHHOLD
 }
 
@@ -4949,7 +4949,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st
        Object *ob = CTX_data_active_object(C);
        SculptSession *ss = ob->sculpt;
        const Brush *brush = BKE_paint_brush(&sd->paint);
-       
+
        sculpt_stroke_modifiers_check(C, ob, brush);
        sculpt_update_cache_variants(C, sd, ob, itemptr);
        sculpt_restore_mesh(sd, ob);
@@ -5048,7 +5048,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
                sculpt_undo_push_end();
 
                BKE_pbvh_update(ss->pbvh, PBVH_UpdateOriginalBB, NULL);
-               
+
                if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH)
                        BKE_pbvh_bmesh_after_stroke(ss->pbvh);
 
@@ -5092,7 +5092,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent
                paint_stroke_data_free(op);
                return OPERATOR_PASS_THROUGH;
        }
-       
+
        if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) {
                paint_stroke_data_free(op);
                return OPERATOR_FINISHED;
@@ -5102,7 +5102,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent
 
        OPERATOR_RETVAL_CHECK(retval);
        BLI_assert(retval == OPERATOR_RUNNING_MODAL);
-       
+
        return OPERATOR_RUNNING_MODAL;
 }
 
@@ -5149,7 +5149,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
        ot->name = "Sculpt";
        ot->idname = "SCULPT_OT_brush_stroke";
        ot->description = "Sculpt a stroke into the geometry";
-       
+
        /* api callbacks */
        ot->invoke = sculpt_brush_stroke_invoke;
        ot->modal = paint_stroke_modal;
@@ -5166,7 +5166,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot)
 
        RNA_def_boolean(ot->srna, "ignore_background_click", 0,
                        "Ignore Background Click",
-                       "Clicks on the background do not start the stroke");    
+                       "Clicks on the background do not start the stroke");
 }
 
 /**** Reset the copy of the mesh that is being sculpted on (currently just for the layer brush) ****/
@@ -5190,11 +5190,11 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot)
        ot->name = "Set Persistent Base";
        ot->idname = "SCULPT_OT_set_persistent_base";
        ot->description = "Reset the copy of the mesh that is being sculpted on";
-       
+
        /* api callbacks */
        ot->exec = sculpt_set_persistent_base_exec;
        ot->poll = sculpt_mode_poll;
-       
+
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
@@ -5298,7 +5298,7 @@ void sculpt_dynamic_topology_enable_ex(
 
        /* Enable dynamic topology */
        me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY;
-       
+
        /* Enable logging for undo/redo */
        ss->bm_log = BM_log_create(ss->bm);
 
@@ -5522,12 +5522,12 @@ static void SCULPT_OT_dynamic_topology_toggle(wmOperatorType *ot)
        ot->name = "Dynamic Topology Toggle";
        ot->idname = "SCULPT_OT_dynamic_topology_toggle";
        ot->description = "Dynamic topology alters the mesh topology while sculpting";
-       
+
        /* api callbacks */
        ot->invoke = sculpt_dynamic_topology_toggle_invoke;
        ot->exec = sculpt_dynamic_topology_toggle_exec;
        ot->poll = sculpt_mode_poll;
-       
+
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
@@ -5560,11 +5560,11 @@ static void SCULPT_OT_optimize(wmOperatorType *ot)
        ot->name = "Optimize";
        ot->idname = "SCULPT_OT_optimize";
        ot->description = "Recalculate the sculpt BVH to improve performance";
-       
+
        /* api callbacks */
        ot->exec = sculpt_optimize_exec;
        ot->poll = sculpt_and_dynamic_topology_poll;
-       
+
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
@@ -5614,7 +5614,7 @@ static void SCULPT_OT_symmetrize(wmOperatorType *ot)
        ot->name = "Symmetrize";
        ot->idname = "SCULPT_OT_symmetrize";
        ot->description = "Symmetrize the topology modifications";
-       
+
        /* api callbacks */
        ot->exec = sculpt_symmetrize_exec;
        ot->poll = sculpt_and_dynamic_topology_poll;
@@ -5836,11 +5836,11 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot)
        ot->name = "Sculpt Mode";
        ot->idname = "SCULPT_OT_sculptmode_toggle";
        ot->description = "Toggle sculpt mode in 3D view";
-       
+
        /* api callbacks */
        ot->exec = sculpt_mode_toggle_exec;
        ot->poll = ED_operator_object_active_editable_mesh;
-       
+
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }