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>2014-04-16 17:25:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-04-16 17:25:10 +0400
commitd1b1d194dc9cc741d87dc63e701402de0776c694 (patch)
tree344bde4783c61c65412fa1fd2435e705ead26965 /source/blender/blenkernel
parentb3972aeea05bc6c60d7b7da4e6b59a64b822448a (diff)
Fix for half pixel offset rasterizing masks
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 92628387dc6..ea039dabce4 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -1434,6 +1434,10 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle,
const unsigned int width, const unsigned int height,
float *buffer)
{
+ const float x_inv = 1.0f / (float)width;
+ const float y_inv = 1.0f / (float)height;
+ const float x_px_ofs = x_inv * 0.5f;
+ const float y_px_ofs = y_inv * 0.5f;
#ifdef _MSC_VER
int y; /* msvc requires signed for some reason */
@@ -1449,9 +1453,9 @@ void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle,
unsigned int i = y * width;
unsigned int x;
float xy[2];
- xy[1] = (float)y / (float)height;
+ xy[1] = ((float)y * y_inv) + y_px_ofs;
for (x = 0; x < width; x++, i++) {
- xy[0] = (float)x / (float)width;
+ xy[0] = ((float)x * x_inv) + x_px_ofs;
buffer[i] = BKE_maskrasterize_handle_sample(mr_handle, xy);
}