[Bf-blender-cvs] [c2f2886] master: Fix T48169: 1 pixel offset painting 2D textures
Campbell Barton
noreply at git.blender.org
Tue May 3 09:47:57 CEST 2016
Commit: c2f28864d6f381f560f30bc8e7da56a2787881dd
Author: Campbell Barton
Date: Tue May 3 17:49:18 2016 +1000
Branches: master
https://developer.blender.org/rBc2f28864d6f381f560f30bc8e7da56a2787881dd
Fix T48169: 1 pixel offset painting 2D textures
Painting at negative locations was using int-rounding.
===================================================================
M source/blender/editors/sculpt_paint/paint_image_2d.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index c5a066e..59b50e2 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);
More information about the Bf-blender-cvs
mailing list