Browse Source

fix capsule when height is zero (#575)

Tom SPIRA 6 years ago
parent
commit
faca6425a7
1 changed files with 6 additions and 0 deletions
  1. 6 0
      h3d/col/Capsule.hx

+ 6 - 0
h3d/col/Capsule.hx

@@ -26,6 +26,12 @@ class Capsule implements Collider {
 		var RD = r.getDir();
 		var RD = r.getDir();
 
 
 		var ABdotAB = AB.dot(AB);
 		var ABdotAB = AB.dot(AB);
+
+		if (ABdotAB == 0) {
+			tmpSphere.load(this.a.x, this.a.y, this.a.z, this.r);
+			return tmpSphere.rayIntersection(r, bestMatch);
+		}
+
 		var m = AB.dot(RD) / ABdotAB;
 		var m = AB.dot(RD) / ABdotAB;
 		var n = AB.dot(AO) / ABdotAB;
 		var n = AB.dot(AO) / ABdotAB;