I'm currently using bullet physics for my space game, using a very simple, single world created like so:
collisionConf = new btDefaultCollisionConfiguration;
sweep = new btAxisSweep3(btVector3(-4000, -4000, -4000), btVector3(4000, 4000, 4000));
dispatcher = new btCollisionDispatcher(collisionConf);
solver = new btSequentialImpulseConstraintSolver;
world = new btDiscreteDynamicsWorld(dispatcher, sweep, solver, collisionConf);
I now want to add teleporters which transport you to different worlds. I'm keeping it simple for now: objects in one world cannot travel to another world without being teleported (simply deleted in 1 world and added to another.)
Initially I plan to have lots of unconnected worlds, say a 10x10x10 grid of them, each with 200 or so objects (I'm already starting to realize I may not even have the processing power for this).
I saw in another forum post that multithreading leads to complications, so I'll just stick to a single thread. I also saw that it is best to sequentially call stepSimulation on each world each tick.
My main question is what is the best way to implement multiple unconnected worlds?
Specifically, is there anything that can be shared between worlds to save memory and cpu? I noticed that adding 1 entirely seperate and empty world added 10 MB of memory usage. If I shared the same btDefaultCollisionConfiguration, additional worlds only cost 1 MB. But I am not sure which of (dispatcher, sweep, solver, collisionConf, and misc collision shapes) can be safely shared and what has a specific world-dependant state.
Are there any other optimizations I should make? CPU/Ram is a huge concern, I'm really doubting whether this is even feasible. Will I save a ton of resources if I try and cram all the different sections into a single world?