新增raycast射线

This commit is contained in:
yhh
2020-07-31 17:17:44 +08:00
parent 514572f291
commit 40fe7a57db
13 changed files with 1182 additions and 813 deletions

View File

@@ -56,7 +56,7 @@ module es {
public overlaps(other: Shape) {
// 特殊情况这一个高性能方式实现其他情况则使用polygon方法检测
if (this.isUnrotated) {
if (other instanceof Box)
if (other instanceof Box && other.isUnrotated)
return this.bounds.intersects(other.bounds);
if (other instanceof Circle)
@@ -83,5 +83,12 @@ module es {
return super.containsPoint(point);
}
public pointCollidesWithShape(point: es.Vector2, result: es.CollisionResult): boolean {
if (this.isUnrotated)
return ShapeCollisions.pointToBox(point, this, result);
return super.pointCollidesWithShape(point, result);
}
}
}