erincatto / box2d

Box2D is a 2D physics engine for games
https://box2d.org
MIT License
7.44k stars 1.47k forks source link

Question about islands #720

Open chanscredi opened 2 years ago

chanscredi commented 2 years ago

When building islands, a graph is created where the vertices are bodies. There is an edge between the bodies if there is a contact or a joint between them. As a result, we get several graphs that are added to the island one by one and island.Solve() is executed for them.

Question: Can I add graphs not one by one, but all at once for the islands that are used in b2World::Solve? Will the behavior of the bodies change after that?

Why I think so: As I understand it, only contacts and joints with this body can change the position and speed for it. This can be done only by those bodies that are with him in the same graph. This means that bodies from another graph do not affect it. So nothing should change if I add all the graph at once. I don't worry about additional memoty allocation when expanding the islands.

Thank you.