Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2022-10-06 14:29:56 +0300
committerAntonio Vazquez <blendergit@gmail.com>2022-10-06 14:30:09 +0300
commit25533ac22d73086fb8841a7fc96018338fff44c5 (patch)
treecf466b133b1034dee6fd16564f4766b0780e81e5 /source/blender/editors/gpencil/gpencil_sculpt_paint.c
parent7163a83450655316900a91c6a24c8abf155c3e71 (diff)
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
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_sculpt_paint.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_sculpt_paint.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index c2e548397e3..1df106d2754 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;