فهرست منبع

IPoint: Use round() instead of floor(). IBounds: make sure rounded bounds include original bounds

trethaller 7 سال پیش
والد
کامیت
51072f1d6e
2فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  1. 3 1
      h2d/col/Bounds.hx
  2. 1 1
      h2d/col/Point.hx

+ 3 - 1
h2d/col/Bounds.hx

@@ -20,7 +20,9 @@ class Bounds {
 	}
 
 	public inline function toIBounds( scale = 1. ) {
-		return IBounds.fromValues(Math.floor(x * scale), Math.floor(y * scale), Math.floor(width * scale), Math.floor(height * scale));
+		var ix = Math.floor(x * scale);
+		var iy = Math.floor(y * scale);
+		return IBounds.fromValues(ix, iy, Math.ceil(xMax * scale) - ix, Math.ceil(yMax * scale) - iy);
 	}
 
 	public inline function intersects( b : Bounds ) {

+ 1 - 1
h2d/col/Point.hx

@@ -12,7 +12,7 @@ class Point {
 	}
 
 	public inline function toIPoint( scale = 1. ) {
-		return new IPoint(Math.floor(x * scale), Math.floor(y * scale));
+		return new IPoint(Math.round(x * scale), Math.round(y * scale));
 	}
 
 	public inline function distanceSq( p : Point ) {