Efficieny of simulating 2 worlds at the same time?

Post Reply
TonyS
Posts: 10
Joined: Sat May 27, 2017 8:16 am

Efficieny of simulating 2 worlds at the same time?

Post by TonyS »

I need to know and manipulate the world before a collision happens. This means changing the world while it is stepping. The only possible solution to this is running simulation steps in a replica of the original world too and if anything collides, I will know those things and before running steps in the original world I will manipulate the original world, then, I will delete the replica world and create another one to keep both worlds in sync.

Is this an acceptable solution for an average game with around 120 rigid bodies?
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Efficieny of simulating 2 worlds at the same time?

Post by drleviathan »

In theory your vision would work. Assuming you're using decent hardware and are not terribly short of CPU cycles Bullet should be fast enough to handle distinct simulations each with 120 bodies.

That said there is probably other ways to achieve what you want: (A) It is possible to catch collision events and modify them before they are applied. (B) You can write "actions" which apply custom logic at the end of every substep. (C) You can put sweep tests in your action's updateAction() method (much like the btKinematicCharacterController) to "test" the next substep's collisions before they happen.
Post Reply