Fix: Wrong border nearest interpolation around negative edges

The BLI wrapmode variant of nearest interpolation for border boundary is
wrong for coordinates between [-1, 0]. That's because the negative
comparison in wrap_coord is done on the integer rounded coordinates,
which will be zero in this case, so the condition will not fail. To fix
this, do the comparison on the original coordinates instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/131306
This commit is contained in:
Omar Emara
2024-12-03 15:04:50 +01:00
committed by Omar Emara
parent 60d918c297
commit be22fcf425

View File

@@ -32,7 +32,7 @@ BLI_INLINE int wrap_coord(float u, int size, InterpWrapMode wrap)
break;
case InterpWrapMode::Border:
x = int(u);
if (x < 0 || x >= size) {
if (u < 0.0f || x >= size) {
x = -1;
}
break;