diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-12 01:01:38 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-12 01:07:44 +0300 |
commit | cfbd605567f48229a923df382baf6db98fbafc61 (patch) | |
tree | d4218c49672047d6c3b37517034660b3b5dcd966 /source/blender/blenlib/intern/math_interp.c | |
parent | 71a57a37b2eebbed53b5335019287b4df9c30519 (diff) | |
parent | 7212ebd09f9720883581221be923ae5e97ff5d76 (diff) |
Merge branch 'master' into blender2.8
Conflicts:
intern/cycles/blender/addon/ui.py
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_distribute.c
source/blender/blenkernel/intern/texture.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_relations.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/physics/particle_object.c
source/blender/editors/transform/transform_snap_object.c
Diffstat (limited to 'source/blender/blenlib/intern/math_interp.c')
-rw-r--r-- | source/blender/blenlib/intern/math_interp.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c index 069d23e7147..8c361673715 100644 --- a/source/blender/blenlib/intern/math_interp.c +++ b/source/blender/blenlib/intern/math_interp.c @@ -284,16 +284,19 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f if (x1 < 0) x1 = width - 1; if (x2 >= width) x2 = 0; } + else if (x2 < 0 || x1 >= width) { + copy_vn_fl(float_output, components, 0.0f); + return; + } + if (wrap_y) { if (y1 < 0) y1 = height - 1; if (y2 >= height) y2 = 0; } - - CLAMP(x1, 0, width - 1); - CLAMP(x2, 0, width - 1); - - CLAMP(y1, 0, height - 1); - CLAMP(y2, 0, height - 1); + else if (y2 < 0 || y1 >= height) { + copy_vn_fl(float_output, components, 0.0f); + return; + } /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) row1 = empty; @@ -331,8 +334,21 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, const f const unsigned char *row1, *row2, *row3, *row4; unsigned char empty[4] = {0, 0, 0, 0}; - /* sample area entirely outside image? */ - if (x2 < 0 || x1 > width - 1 || y2 < 0 || y1 > height - 1) { + /* pixel value must be already wrapped, however values at boundaries may flip */ + if (wrap_x) { + if (x1 < 0) x1 = width - 1; + if (x2 >= width) x2 = 0; + } + else if (x2 < 0 || x1 >= width) { + copy_vn_uchar(byte_output, components, 0); + return; + } + + if (wrap_y) { + if (y1 < 0) y1 = height - 1; + if (y2 >= height) y2 = 0; + } + else if (y2 < 0 || y1 >= height) { copy_vn_uchar(byte_output, components, 0); return; } |