diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-14 22:57:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-14 22:57:16 +0400 |
commit | 52c0f44659719b63fb618794e80f0aedf4129335 (patch) | |
tree | dcb70754b04e7af10f1953aeb2d3cb1c710c7da5 /source/blender/blenkernel | |
parent | a52153a618688bcabb9812959e7b1de7c4b92f71 (diff) |
zealous bounds checking broke the invert option.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/mask_rasterize.c | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index 9041e304444..d2b6a189aba 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -239,8 +239,8 @@ static int layer_bucket_isect_test(MaskRasterLayer *layer, unsigned int face_ind const float xmax = xmin + bucket_size_x; const float ymax = ymin + bucket_size_y; - float cent[2] = {(xmin + xmax) * 0.5f, - (ymin + ymax) * 0.5f}; + const float cent[2] = {(xmin + xmax) * 0.5f, + (ymin + ymax) * 0.5f}; if (face[3] == TRI_VERT) { const float *v1 = cos[face[0]]; @@ -809,53 +809,54 @@ static float layer_bucket_depth_from_xy(MaskRasterLayer *layer, const float xy[2 float BLI_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float xy[2]) { - if (BLI_in_rctf_v(&mr_handle->bounds, xy)) { - const unsigned int layers_tot = mr_handle->layers_tot; - unsigned int i; - MaskRasterLayer *layer = mr_handle->layers; + /* can't do this because some layers may invert */ + /* if (BLI_in_rctf_v(&mr_handle->bounds, xy)) */ - /* raycast vars*/ + const unsigned int layers_tot = mr_handle->layers_tot; + unsigned int i; + MaskRasterLayer *layer = mr_handle->layers; - /* return */ - float value = 0.0f; + /* raycast vars*/ - for (i = 0; i < layers_tot; i++, layer++) { - if (BLI_in_rctf_v(&layer->bounds, xy)) { - /* --- hit (start) --- */ - const float dist = 1.0f - layer_bucket_depth_from_xy(layer, xy); - const float dist_ease = (3.0f * dist * dist - 2.0f * dist * dist * dist); + /* return */ + float value = 0.0f; - float v; - /* apply alpha */ - v = dist_ease * layer->alpha; + for (i = 0; i < layers_tot; i++, layer++) { + float dist_ease; + float v; - if (layer->blend_flag & MASK_BLENDFLAG_INVERT) { - v = 1.0f - v; - } + if (BLI_in_rctf_v(&layer->bounds, xy)) { + /* --- hit (start) --- */ + const float dist = 1.0f - layer_bucket_depth_from_xy(layer, xy); + dist_ease = (3.0f * dist * dist - 2.0f * dist * dist * dist); + } + else { + dist_ease = 0.0f; + } - switch (layer->blend) { - case MASK_BLEND_SUBTRACT: - { - value -= v; - break; - } - case MASK_BLEND_ADD: - default: - { - value += v; - break; - } - } - /* --- hit (end) --- */ + /* apply alpha */ + v = dist_ease * layer->alpha; - } + if (layer->blend_flag & MASK_BLENDFLAG_INVERT) { + v = 1.0f - v; } - return CLAMPIS(value, 0.0f, 1.0f); - } - else { - return 0.0f; + switch (layer->blend) { + case MASK_BLEND_SUBTRACT: + { + value -= v; + break; + } + case MASK_BLEND_ADD: + default: + { + value += v; + break; + } + } } + + return CLAMPIS(value, 0.0f, 1.0f); } #endif /* USE_RASKTER */ |