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:
authorPhilipp Oeser <info@graphics-engineer.com>2022-11-08 14:27:17 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2022-11-08 15:40:14 +0300
commit09faf8a449e36ce044141e67e792f3d02dd1602d (patch)
tree64f4a5825defa0c1a15b899031a73199c2d93a3f
parent82ba2056462310b103ad16fba726340886e5b0b7 (diff)
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
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c29
1 files changed, 17 insertions, 12 deletions
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) {