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:
authorCampbell Barton <ideasman42@gmail.com>2016-05-03 10:49:18 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-05-03 10:49:18 +0300
commitc2f28864d6f381f560f30bc8e7da56a2787881dd (patch)
tree98d30e6176a8a62c4ec0f95dc9573e2787abc9cc /source/blender/editors/sculpt_paint/paint_image_2d.c
parentead2496e6716dc15b0327ba69ebf16303ebc3877 (diff)
Fix T48169: 1 pixel offset painting 2D textures
Painting at negative locations was using int-rounding.
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image_2d.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index c5a066e9b14..59b50e28ce7 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -302,8 +302,8 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter, const
srcx = srcy = 0;
w = cache->tex_mask_old_w;
h = cache->tex_mask_old_h;
- destx = (int)painter->lastpaintpos[0] - (int)pos[0] + (diameter / 2 - w / 2);
- desty = (int)painter->lastpaintpos[1] - (int)pos[1] + (diameter / 2 - h / 2);
+ destx = (int)floorf(painter->lastpaintpos[0]) - (int)floorf(pos[0]) + (diameter / 2 - w / 2);
+ desty = (int)floorf(painter->lastpaintpos[1]) - (int)floorf(pos[1]) + (diameter / 2 - h / 2);
/* hack, use temporary rects so that clipping works */
IMB_rectclip(&maskibuf, &maskibuf_old, &destx, &desty, &srcx, &srcy, &w, &h);
@@ -570,8 +570,8 @@ static void brush_painter_imbuf_partial_update(BrushPainter *painter, const floa
srcx = srcy = 0;
w = oldtexibuf->x;
h = oldtexibuf->y;
- destx = (int)painter->lastpaintpos[0] - (int)pos[0] + (diameter / 2 - w / 2);
- desty = (int)painter->lastpaintpos[1] - (int)pos[1] + (diameter / 2 - h / 2);
+ destx = (int)floorf(painter->lastpaintpos[0]) - (int)floorf(pos[0]) + (diameter / 2 - w / 2);
+ desty = (int)floorf(painter->lastpaintpos[1]) - (int)floorf(pos[1]) + (diameter / 2 - h / 2);
IMB_rectclip(cache->texibuf, oldtexibuf, &destx, &desty, &srcx, &srcy, &w, &h);
}
@@ -641,8 +641,8 @@ static void brush_painter_2d_tex_mapping(ImagePaintState *s, int diameter, const
mapping->ymax = 1.0f;
}
else /* if (mapmode == MTEX_MAP_MODE_TILED) */ {
- mapping->xmin = (int)(-diameter * 0.5) + (int)pos[0] - (int)startpos[0];
- mapping->ymin = (int)(-diameter * 0.5) + (int)pos[1] - (int)startpos[1];
+ mapping->xmin = (int)(-diameter * 0.5) + (int)floorf(pos[0]) - (int)floorf(startpos[0]);
+ mapping->ymin = (int)(-diameter * 0.5) + (int)floorf(pos[1]) - (int)floorf(startpos[1]);
mapping->xmax = 1.0f;
mapping->ymax = 1.0f;
}
@@ -758,8 +758,8 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai
}
else if (do_partial_update) {
/* do only partial update of texture */
- int dx = (int)painter->lastpaintpos[0] - (int)pos[0];
- int dy = (int)painter->lastpaintpos[1] - (int)pos[1];
+ int dx = (int)floorf(painter->lastpaintpos[0]) - (int)floorf(pos[0]);
+ int dy = (int)floorf(painter->lastpaintpos[1]) - (int)floorf(pos[1]);
if ((dx != 0) || (dy != 0)) {
brush_painter_imbuf_partial_update(painter, pos, diameter);