Browse Source

added Sphere.transform

Nicolas Cannasse 1 year ago
parent
commit
b00d8157c9
1 changed files with 11 additions and 0 deletions
  1. 11 0
      h3d/col/Sphere.hx

+ 11 - 0
h3d/col/Sphere.hx

@@ -78,6 +78,17 @@ class Sphere extends Collider {
 		return res;
 	}
 
+	public function transform( m : h3d.Matrix ) {
+		var s = m.getScale();
+		var smax = hxd.Math.max(hxd.Math.max(hxd.Math.abs(s.x), hxd.Math.abs(s.y)), hxd.Math.abs(s.z));
+		r *= smax;
+		var pt = new h3d.col.Point(x,y,z);
+		pt.transform(m);
+		x = pt.x;
+		y = pt.y;
+		z = pt.z;
+	}
+
 	public inline function inSphere( s : Sphere ) {
 		return new Point(x,y,z).distanceSq(new Point(s.x,s.y,s.z)) < (s.r + r)*(s.r + r);
 	}