[Bf-blender-cvs] [8725bb5108c] blender-v3.3-release: Fix T101517: GPencil strokes snap to origin in a Scale value is on 0
Antonio Vazquez
noreply at git.blender.org
Mon Oct 17 16:31:17 CEST 2022
Commit: 8725bb5108ccab455c61a98f0da7d05dc0972660
Author: Antonio Vazquez
Date: Thu Oct 6 13:29:56 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB8725bb5108ccab455c61a98f0da7d05dc0972660
Fix T101517: GPencil strokes snap to origin in a Scale value is on 0
The problem was the conversion to object space converted the
points to zero.
Now, the new function `zero_axis_bias_m4` is used in order to add
a small bias in the inverse matrix and avoid the zero points.
A known math issue is the stroke can be offsetted if the scale is set to 1
again. In this case apply the scale to reset to 1.
Differential Revision: https://developer.blender.org/D16162
===================================================================
M source/blender/editors/gpencil/gpencil_sculpt_paint.c
M source/blender/editors/gpencil/gpencil_utils.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index e27cd255217..424544c8085 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -544,8 +544,10 @@ static void gpencil_brush_grab_apply_cached(tGP_BrushEditData *gso,
return;
}
- float inverse_diff_mat[4][4];
- invert_m4_m4(inverse_diff_mat, diff_mat);
+ float matrix[4][4], inverse_diff_mat[4][4];
+ copy_m4_m4(matrix, diff_mat);
+ zero_axis_bias_m4(matrix);
+ invert_m4_m4(inverse_diff_mat, matrix);
/* Apply dvec to all of the stored points */
for (int i = 0; i < data->size; i++) {
@@ -1169,7 +1171,10 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op)
gso->scene = scene;
gso->object = ob;
if (ob) {
- invert_m4_m4(gso->inv_mat, ob->obmat);
+ float matrix[4][4];
+ copy_m4_m4(matrix, ob->obmat);
+ zero_axis_bias_m4(matrix);
+ invert_m4_m4(gso->inv_mat, matrix);
gso->vrgroup = gso->gpd->vertex_group_active_index - 1;
if (!BLI_findlink(&gso->gpd->vertex_group_names, gso->vrgroup)) {
gso->vrgroup = -1;
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 7b659511aaa..b554c81ab00 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -633,6 +633,7 @@ void gpencil_apply_parent(Depsgraph *depsgraph, Object *obact, bGPDlayer *gpl, b
float fpt[3];
BKE_gpencil_layer_transform_matrix_get(depsgraph, obact, gpl, diff_mat);
+ zero_axis_bias_m4(diff_mat);
invert_m4_m4(inverse_diff_mat, diff_mat);
for (i = 0; i < gps->totpoints; i++) {
@@ -653,6 +654,7 @@ void gpencil_apply_parent_point(Depsgraph *depsgraph,
float fpt[3];
BKE_gpencil_layer_transform_matrix_get(depsgraph, obact, gpl, diff_mat);
+ zero_axis_bias_m4(diff_mat);
invert_m4_m4(inverse_diff_mat, diff_mat);
mul_v3_m4v3(fpt, inverse_diff_mat, &pt->x);
@@ -935,6 +937,7 @@ void ED_gpencil_project_stroke_to_view(bContext *C, bGPDlayer *gpl, bGPDstroke *
gpencil_point_conversion_init(C, &gsc);
BKE_gpencil_layer_transform_matrix_get(depsgraph, ob, gpl, diff_mat);
+ zero_axis_bias_m4(diff_mat);
invert_m4_m4(inverse_diff_mat, diff_mat);
/* Adjust each point */
@@ -1050,6 +1053,7 @@ void ED_gpencil_stroke_reproject(Depsgraph *depsgraph,
float diff_mat[4][4], inverse_diff_mat[4][4];
BKE_gpencil_layer_transform_matrix_get(depsgraph, gsc->ob, gpl, diff_mat);
+ zero_axis_bias_m4(diff_mat);
invert_m4_m4(inverse_diff_mat, diff_mat);
float origin[3];
More information about the Bf-blender-cvs
mailing list