[Bf-blender-cvs] [8a7dedc9d29] master: Fix T66011: Transformed objects break sculpt tools

Antonioya noreply at git.blender.org
Tue Jul 16 17:57:36 CEST 2019


Commit: 8a7dedc9d2951943f5826d8172280785739db6b4
Author: Antonioya
Date:   Tue Jul 16 17:55:42 2019 +0200
Branches: master
https://developer.blender.org/rB8a7dedc9d2951943f5826d8172280785739db6b4

Fix T66011: Transformed objects break sculpt tools

The Pinch, Push, Twist and Clone were not using the object transformation to compute point changes, so the point was way off of the right place.

===================================================================

M	source/blender/editors/gpencil/gpencil_brush.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index f5b27d8268d..7d866aedd87 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -579,6 +579,7 @@ static bool gp_brush_push_apply(
   mul_v3_v3fl(delta, gso->dvec, inf);
 
   /* apply */
+  mul_mat3_m4_v3(gso->object->obmat, delta); /* only rotation component */
   add_v3_v3(&pt->x, delta);
 
   /* compute lock axis */
@@ -646,7 +647,9 @@ static bool gp_brush_pinch_apply(
   inf = gp_brush_influence_calc(gso, radius, co) / 5.0f;
 
   /* 1) Make this point relative to the cursor/midpoint (dvec) */
-  sub_v3_v3v3(vec, &pt->x, gso->dvec);
+  float fpt[3];
+  mul_v3_m4v3(fpt, gso->object->obmat, &pt->x);
+  sub_v3_v3v3(vec, fpt, gso->dvec);
 
   /* 2) Shrink the distance by pulling the point towards the midpoint
    *    (0.0 = at midpoint, 1 = at edge of brush region)
@@ -664,7 +667,8 @@ static bool gp_brush_pinch_apply(
   mul_v3_fl(vec, fac);
 
   /* 3) Translate back to original space, with the shrinkage applied */
-  add_v3_v3v3(&pt->x, gso->dvec, vec);
+  add_v3_v3v3(fpt, gso->dvec, vec);
+  mul_v3_m4v3(&pt->x, gso->object->imat, fpt);
 
   /* compute lock axis */
   gpsculpt_compute_lock_axis(gso, pt, save_pt);
@@ -713,11 +717,14 @@ static bool gp_brush_twist_apply(
 
     axis_angle_normalized_to_mat3(rmat, axis, angle);
 
-    /* Rotate point (no matrix-space transforms needed, as GP points are in world space) */
-    sub_v3_v3v3(vec, &pt->x, gso->dvec); /* make relative to center
-                                          * (center is stored in dvec) */
+    /* Rotate point */
+    float fpt[3];
+    mul_v3_m4v3(fpt, gso->object->obmat, &pt->x);
+    sub_v3_v3v3(vec, fpt, gso->dvec); /* make relative to center
+                                       * (center is stored in dvec) */
     mul_m3_v3(rmat, vec);
-    add_v3_v3v3(&pt->x, vec, gso->dvec); /* restore */
+    add_v3_v3v3(fpt, vec, gso->dvec); /* restore */
+    mul_v3_m4v3(&pt->x, gso->object->imat, fpt);
 
     /* compute lock axis */
     gpsculpt_compute_lock_axis(gso, pt, save_pt);
@@ -1090,8 +1097,12 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
        * get pasted relative to where the cursor is now
        */
       for (i = 0, pt = new_stroke->points; i < new_stroke->totpoints; i++, pt++) {
+        /* Rotate around center new position */
+        mul_mat3_m4_v3(gso->object->obmat, &pt->x); /* only rotation component */
+
         /* assume that the delta can just be applied, and then everything works */
         add_v3_v3(&pt->x, delta);
+        mul_m4_v3(gso->object->imat, &pt->x);
       }
 
       /* Store ref for later */



More information about the Bf-blender-cvs mailing list