From 09faf8a449e36ce044141e67e792f3d02dd1602d Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 8 Nov 2022 12:27:17 +0100 Subject: Fix T102312: anchored brush texture overlay draws in wrong place Rotation and scale was done around the wrong center (always around mouse position) in paint_draw_tex_overlay [on the other hand, paint_draw_cursor_overlay already got the center right]. Now make the center dependent on UnifiedPaintSettings "draw_anchored". Maniphest Tasks: T102312 Differential Revision: https://developer.blender.org/D16418 --- source/blender/editors/sculpt_paint/paint_cursor.c | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index b85b878af7d..b6e83187c86 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -562,31 +562,36 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups, if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) { GPU_matrix_push(); + float center[2] = { + ups->draw_anchored ? ups->anchored_initial_mouse[0] : x, + ups->draw_anchored ? ups->anchored_initial_mouse[1] : y, + }; + /* Brush rotation. */ - GPU_matrix_translate_2f(x, y); + GPU_matrix_translate_2fv(center); GPU_matrix_rotate_2d(-RAD2DEGF(primary ? ups->brush_rotation : ups->brush_rotation_sec)); - GPU_matrix_translate_2f(-x, -y); + GPU_matrix_translate_2f(-center[0], -center[1]); /* Scale based on tablet pressure. */ if (primary && ups->stroke_active && BKE_brush_use_size_pressure(brush)) { const float scale = ups->size_pressure_value; - GPU_matrix_translate_2f(x, y); + GPU_matrix_translate_2fv(center); GPU_matrix_scale_2f(scale, scale); - GPU_matrix_translate_2f(-x, -y); + GPU_matrix_translate_2f(-center[0], -center[1]); } if (ups->draw_anchored) { - quad.xmin = ups->anchored_initial_mouse[0] - ups->anchored_size; - quad.ymin = ups->anchored_initial_mouse[1] - ups->anchored_size; - quad.xmax = ups->anchored_initial_mouse[0] + ups->anchored_size; - quad.ymax = ups->anchored_initial_mouse[1] + ups->anchored_size; + quad.xmin = center[0] - ups->anchored_size; + quad.ymin = center[1] - ups->anchored_size; + quad.xmax = center[0] + ups->anchored_size; + quad.ymax = center[1] + ups->anchored_size; } else { const int radius = BKE_brush_size_get(vc->scene, brush) * zoom; - quad.xmin = x - radius; - quad.ymin = y - radius; - quad.xmax = x + radius; - quad.ymax = y + radius; + quad.xmin = center[0] - radius; + quad.ymin = center[1] - radius; + quad.xmax = center[0] + radius; + quad.ymax = center[1] + radius; } } else if (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) { -- cgit v1.2.3