Commit: 2a86495125ad6188c18fccc2cff07db554f4a802
Author: Antonio Vazquez
Date:   Tue Nov 7 13:46:09 2017 +0100
Branches: greasepencil-object
https://developer.blender.org/rB2a86495125ad6188c18fccc2cff07db554f4a802

Improve thickness fix when no locked axis

There was some problems with the thickness when the axis was not locked that 
were not fixed in previous commit.

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

M       source/blender/editors/gpencil/gpencil_paint.c
M       source/blender/editors/gpencil/gpencil_utils.c

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

diff --git a/source/blender/editors/gpencil/gpencil_paint.c 
b/source/blender/editors/gpencil/gpencil_paint.c
index 238fcdff617..5294514d5fa 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -698,10 +698,8 @@ static short gp_stroke_addpoint(
                        
                        /* convert screen-coordinates to appropriate 
coordinates (and store them) */
                        gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL);
-                       /* if axis locked, reproject to plane locked (only in 
3d space) */
-                       if (p->lock_axis > GP_LOCKAXIS_NONE) {
-                               gp_reproject_toplane(p, gps);
-                       }
+                       /* reproject to plane (only in 3d space) */
+                       gp_reproject_toplane(p, gps);
                        /* if parented change position relative to parent 
object */
                        gp_apply_parent_point(obact, gpd, gpl, pts);
                        /* copy pressure and time */
@@ -884,10 +882,8 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
                        
                        /* convert screen-coordinates to appropriate 
coordinates (and store them) */
                        gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
-                       /* if axis locked, reproject to plane locked (only in 
3d space) */
-                       if (p->lock_axis > GP_LOCKAXIS_NONE) {
-                               gp_reproject_toplane(p, gps);
-                       }
+                       /* reproject to plane (only in 3d space) */
+                       gp_reproject_toplane(p, gps);
                        /* if parented change position relative to parent 
object */
                        gp_apply_parent_point(obact, gpd, gpl, pt);
                        /* copy pressure and time */
@@ -907,10 +903,8 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
                        
                        /* convert screen-coordinates to appropriate 
coordinates (and store them) */
                        gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
-                       /* if axis locked, reproject to plane locked (only in 
3d space) */
-                       if (p->lock_axis > GP_LOCKAXIS_NONE) {
-                               gp_reproject_toplane(p, gps);
-                       }
+                       /* reproject to plane (only in 3d space) */
+                       gp_reproject_toplane(p, gps);
                        /* if parented change position relative to parent 
object */
                        gp_apply_parent_point(obact, gpd, gpl, pt);
 
@@ -930,10 +924,8 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
                
                /* convert screen-coordinates to appropriate coordinates (and 
store them) */
                gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
-               /* if axis locked, reproject to plane locked (only in 3d space) 
*/
-               if (p->lock_axis > GP_LOCKAXIS_NONE) {
-                       gp_reproject_toplane(p, gps);
-               }
+               /* reproject to plane (only in 3d space) */
+               gp_reproject_toplane(p, gps);
                /* if parented change position relative to parent object */
                gp_apply_parent_point(obact, gpd, gpl, pt);
                /* copy pressure and time */
@@ -1054,10 +1046,8 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
                        }
                }
 
-               /* if axis locked, reproject to plane locked (only in 3d space) 
*/
-               if (p->lock_axis > GP_LOCKAXIS_NONE) {
-                       gp_reproject_toplane(p, gps);
-               }
+               /* reproject to plane (only in 3d space) */
+               gp_reproject_toplane(p, gps);
                /* change position relative to parent object */
                gp_apply_parent(obact, gpd, gpl, gps);
 
diff --git a/source/blender/editors/gpencil/gpencil_utils.c 
b/source/blender/editors/gpencil/gpencil_utils.c
index 92856346926..f94e8fe1d4d 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -1196,11 +1196,18 @@ void ED_gp_project_stroke_to_plane(Object *ob, 
RegionView3D *rv3d, bGPDstroke *g
 
        /* normal vector for a plane locked to axis */
        zero_v3(plane_normal);
-       plane_normal[axis] = 1.0f;
-       
-       /* if object, apply object rotation */
-       if (ob && (ob->type == OB_GPENCIL)) {
-               mul_mat3_m4_v3(ob->obmat, plane_normal);
+       if (axis < 0) {
+               /* if the axis is not locked, need a vector to the view 
direction
+               * in order to get the right size of the stroke.
+               */
+               ED_view3d_global_to_vector(rv3d, origin, plane_normal);
+       }
+       else {
+               plane_normal[axis] = 1.0f;
+               /* if object, apply object rotation */
+               if (ob && (ob->type == OB_GPENCIL)) {
+                       mul_mat3_m4_v3(ob->obmat, plane_normal);
+               }
        }
 
        /* Reproject the points in the plane */
@@ -1236,16 +1243,16 @@ void ED_gp_project_point_to_plane(Object *ob, 
RegionView3D *rv3d, const float or
                /* if the axis is not locked, need a vector to the view 
direction 
                 * in order to get the right size of the stroke.
                 */
-               ED_view3d_global_to_vector(rv3d, &pt->x, plane_normal);
+               ED_view3d_global_to_vector(rv3d, origin, plane_normal);
        }
        else {
                plane_normal[axis] = 1.0f;
+               /* if object, apply object rotation */
+               if (ob && (ob->type == OB_GPENCIL)) {
+                       mul_mat3_m4_v3(ob->obmat, plane_normal);
+               }
        }
 
-       /* if object, apply object rotation */
-       if (ob && (ob->type == OB_GPENCIL)) {
-               mul_mat3_m4_v3(ob->obmat, plane_normal);
-       }
 
        /* Reproject the points in the plane */
        /* get a vector from the point with the current view direction of the 
viewport */

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

Reply via email to