b2_collsion.ts 里Contains函数写错了。
原来是:
public Contains(aabb: b2AABB): boolean {
if (this.lowerBound.x <= aabb.lowerBound.x) { return false; }
if (this.lowerBound.y <= aabb.lowerBound.y) { return false; }
if (aabb.upperBound.x <= this.upperBound.x) { return false; }
if (aabb.upperBound.y <= this.upperBound.y) { return false; }
return true;
}
应该改成:
public Contains(aabb: b2AABB): boolean {
if (this.lowerBound.x > aabb.lowerBound.x) { return false; }
if (this.lowerBound.y > aabb.lowerBound.y) { return false; }
if (aabb.upperBound.x > this.upperBound.x) { return false; }
if (aabb.upperBound.y > this.upperBound.y) { return false; }
return true;
}
否则 b2DynamicTree里MoveProxy函数 里的
if (node.aabb.Contains(aabb)) {
return false;
} 这个判断完全没用