-
Hi, I'm working on a game with a special setting, its world is intended to be very large (too large for floats and I'm not keen to use doubles) and "sparse", it's a space game where people can pilot their spaceships to go to very far from each other, using some kind of faster than light device. The idea to handle this technically is to have multiple physics worlds, for example the interior of a spaceship would be a physics world of its own (with the interior being pretty much static) and the exterior being sparse "cells" depending on where you are in the universe. Those cells all have their scene origin (0,0,0) at their center and are created/destroyed at will. My question is, how should I handle this with Jolt? At first I was thinking of give each cell their own broadphase (so bodies in multiple cells won't collide despite being at the same location), but Jolt has to know how many broadphase layer exists and it's a dynamic count in my case. Or maybe I should handle this with multiple I know it's a complex subject but maybe you have a tip about this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
X4 is a space game using Jolt, and it has a similar problem of theoretically infinite travel in each direction. We've solved this by setting the coordinate center of the physics system to be near the player / camera. If the player moves more than 50km away from it, the system is relocated and all bodies inside it are moved to match. Objects beyond ~100km don't have physics bodies and are generally simulated in a state we call "low attention". Very early on we tried to have a grid of physics systems, but that completely broke down at the boundary between two of them. It was not possible to have an object at the edge of one collide with another at the edge of the other, unless you add duplicate bodies that are close to the edge to both of them, which is just inviting lots of unnecessary trouble. |
Beta Was this translation helpful? Give feedback.
-
DocAce has a lot more experience than I have in making space games, but I just want to comment on this:
There is only 1 broadphase per PhysicsSystem so you can't do this, I'm assuming you meant 1 broadphase layer per cell. I guess this could work, but the number of layers is fixed at initialization time and that is not easily changed. I think the better solution is to use 1 PhysicsSystem per cell. Note that this would involve destroying and recreating the body when it crosses the cell boundary (bodies are tied to their PhysicsSystem), but besides that the amount of work is comparable to moving a body from one layer to the next. |
Beta Was this translation helpful? Give feedback.
DocAce has a lot more experience than I have in making space games, but I just want to comment on this:
There is only 1 broadphase per PhysicsSystem so you can't do this, I'm assuming you meant 1 broadphase layer per cell. I guess this could work, but the number of layers is fixed at initialization time and that is not easily changed. I think the better solution is to use 1 PhysicsSystem per cell. Note that this would involve destroying and recreating the b…