[Bf-blender-cvs] [17253be] master: Fix T42892: UV pixel snap with negative values

Campbell Barton noreply at git.blender.org
Sun Dec 14 12:36:43 CET 2014


Commit: 17253bec0639a910b3f8e5875d1b5b5605123757
Author: Campbell Barton
Date:   Sun Dec 14 12:31:19 2014 +0100
Branches: master
https://developer.blender.org/rB17253bec0639a910b3f8e5875d1b5b5605123757

Fix T42892: UV pixel snap with negative values

===================================================================

M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/uvedit/uvedit_ops.c

===================================================================

diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index f571d36..6e06f2e 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -2817,8 +2817,8 @@ void flushTransUVs(TransInfo *t)
 		td->loc2d[1] = td->loc[1] * invy;
 
 		if ((sima->flag & SI_PIXELSNAP) && (t->state != TRANS_CANCEL)) {
-			td->loc2d[0] = floorf(width * td->loc2d[0] + 0.5f) / width;
-			td->loc2d[1] = floorf(height * td->loc2d[1] + 0.5f) / height;
+			td->loc2d[0] = roundf(width * td->loc2d[0]) / width;
+			td->loc2d[1] = roundf(height * td->loc2d[1]) / height;
 		}
 	}
 }
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 23a5ac8..c70fcdb 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -3189,8 +3189,8 @@ static void UV_OT_select_lasso(wmOperatorType *ot)
 
 static void uv_snap_to_pixel(float uvco[2], float w, float h)
 {
-	uvco[0] = ((float)((int)((uvco[0] * w) + 0.5f))) / w;
-	uvco[1] = ((float)((int)((uvco[1] * h) + 0.5f))) / h;
+	uvco[0] = roundf(uvco[0] * w) / w;
+	uvco[1] = roundf(uvco[1] * h) / h;
 }
 
 static void uv_snap_cursor_to_pixels(SpaceImage *sima)




More information about the Bf-blender-cvs mailing list