PhysicsSpace instead of BulletAppState?

Hi guys.

I want to physics on a server and i don’t need to use Spatials.
Is it OK if i will just create a PhysicsSpace class and will add PhysicsRigidBody? Instead of using BulletAppState + RigidBodyControl.

If it’s ok, then i have a question: should i use any update loop for PhysicsSpace like in BulletAppState? Or i can just create PhysicsSpace object and everything will be ok for physics update?

Thanks!

No, obviously you will have to run the physics on some thread. It cannot magically make stuff happen.

@normen said: No, obviously you will have to run the physics on some thread. It cannot magically make stuff happen.

Ok, i understand.

BulletAppState class makes this:

  • update collisions in update() method (pSpace.distributeEvents())
  • update PhysicsSpace in render() method (pSpace.update(active ? tpf * speed : 0))

My server uses Headless mode. Is it ok if i will update PhysicsSpace in the render() method on my server then even if my server is in Headles mode?

Why use your own implementation when you use a normal Application in headless mode anyway? You’d have to care for parallel execution yourself then.

@normen said: Why use your own implementation when you use a normal Application in headless mode anyway? You'd have to care for parallel execution yourself then.

Hey, i have just tried render() method in Headless mode. And it works!
We need multiple physicsSpaces and we will use your implementation.:slight_smile: I think we just modify existing BulletAppState for our needs. Thank you.

Another 2 questions:

  1. Is it possible to use PhysicsRayTest only for a certain CollisionGroup? At present, my PhysicsRayTest creates results from all CollisionGroups.
  2. Should I use PhysicsRayTest only in physicsTick() method or i can use the PhysicsRayTest in any place of my code?

If you do this then all your physics spaces will be computed sequentially.

  1. Just check the collision group of the result then
  2. You should not run it in parallel to the physics update
1 Like
@normen said: 2) You should not run it in parallel to the physics update

Thanks. You helped a lot.
The last question: If i use PARALLEL Threading, then where i should use RayTest?

I should use RayTest in the same Thread of the physics update or i should use RayTest in PhysicsTickListener->physicsTick() ? Or i can use RayTest in Main Thread?

Thanks.

You can use it in update or in the physics tick, not in render.

1 Like