wise9/enchant.js

feature/boundingRect

Closed this issue · 2 comments

現在、オブジェクト同士の当たり判定を計算するメソッドはEntity#intersectとEntity#withinがあります。
どちらも回転、拡大を考慮しないものなので、回転、拡大を行ったEntityについて正しい結果を得ることができません。
feature/boundingRectではEntityのバウンディングを取得するEntity#getBoundingRectとEntity#getOrientedBoundingRectを追加し、回転、拡大を考慮したサイズの矩形を取得することができます。
また、これらのメソッドで取得した値を基に厳密な当たり判定を計算するEntity#intersectStrictも追加しています。
intersectStrictはintersectに比べ1.8-2.0倍ほど計算時間がかかります。
getBoundingRect、intersectStrictの値はgetOrientedBoundingRectの結果を基に求められるので、getOrientedBoundingRectの結果をキャッシュする実装についても検討しています。

developにマージしました

v0.7でmasterにマージされました