Just a few questions about the world bounding box... first off, is there a way (which I am intended to use) that can return the demensions of the bounding box which I would have set on world delcaration? And secondly, what would be the best way to get my objects to just bounce off of the bounding box and back into the simulation? And furthermore on that second one, what would be the best way to just get my objects to loop around to the other side?
World bounding box (answered)
General Discussion1) Aside from the privateness of the variales, it would be world.m_broadPhase.m_worldAABB, but you could have written a global variable to store it in the time it took to ask the question!
2) Just put some walls with restitution 1 in your simulation, making a box slightly smaller than your AABB
3) Non-trivial, as you could conceivably have a box being interacted on from both sides simultaneously. I'd say the best bet is to create a copy of the body, and use joints to ensure they match each other, but translated.
2) Just put some walls with restitution 1 in your simulation, making a box slightly smaller than your AABB
3) Non-trivial, as you could conceivably have a box being interacted on from both sides simultaneously. I'd say the best bet is to create a copy of the body, and use joints to ensure they match each other, but translated.
Quote:
1) Aside from the privateness of the variales, it would be world.m_broadPhase.m_worldAABB, but you could have written a global variable to store it in the time it took to ask the question!
Well I wouldn't want to waste space...
As for 2 and 3... I was really hoping for better solutions.
2 is a pretty good solution, very simple to implement. For 2 and 3 you might try a BoundaryListener and when an object leaves you could re-create it, either bouncing it back or wrapping it around.
I think BorisTheBrave's response assumed you would see part of wrapped body on both sides for a brief moment. Given that assumption it is certainly harder to implement, requiring two bodies I think. Your question was not clear on this.
Bill
I think BorisTheBrave's response assumed you would see part of wrapped body on both sides for a brief moment. Given that assumption it is certainly harder to implement, requiring two bodies I think. Your question was not clear on this.
Bill
Original thread: https://box2d.org/forum/viewtopic.php?t=871