I was wondering if a new shape type (called b2AABBShape or whatever), a box perfectly aligned on the x and y axis (zero rotation) would allow for an optimized collision response algorithm. For most sidescrollers the majority of the terrain fits this description (think Mario - all boxes). I've built engines that use this style of "physics" in the past and they are dead simple. Is there overhead to treating zero rotation boxes as polygons that could potentially rotate?
Potential AABB Shape Type Optimization?
Bugs, Requests, and FeedbackI think this would be significantly faster ... if the engine was built without using rotation at all. For Box2D it is too late.
Right, but couldn't Box2D optimize non rotated boxes that are always aligned to their AABB, even when mixed with the existing shape types? The broad-phase and narrow-phase checks would be equivalent. I'm tempted to try this, just testing the waters to see if it's worthwhile.
Did you profile Box2D? Did you find the narrow-phase to be the bottleneck? In my profiles, cache misses are usually the bottleneck.
Also, the narrow-phase can be made much faster by caching the minimum separating axis, which is not done yet. This would speed up all shape types.
Also, the narrow-phase can be made much faster by caching the minimum separating axis, which is not done yet. This would speed up all shape types.
Original thread: https://box2d.org/forum/viewtopic.php?t=5136