浏览代码

fix capsule when height is zero (#575)

Tom SPIRA 6 年之前
父节点
当前提交
faca6425a7
共有 1 个文件被更改,包括 6 次插入0 次删除
  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 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 n = AB.dot(AO) / ABdotAB;