threaded physics

Problems building or running the engine, queries about how to use features etc.
slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

threaded physics

Post by slapin »

Hi, all!
Have anybody managed to run Bullet in separate thread? Any code I might look at?

rpgplayerrobin
Orc Shaman
Posts: 788
Joined: Wed Mar 18, 2009 3:03 am
x 447

Re: threaded physics

Post by rpgplayerrobin »

I have not tried it, but I have not seen it as a bottleneck in my game when activating analytics (which basically measures the time of all my code and the Ogre render step) it shows for me that it takes basically no time at all to update it.

So before you start with it, I would suggest you to first see if it actually takes a lot of performance in your application, because otherwise there is no point in doing this.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5534
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1394

Re: threaded physics

Post by dark_sylinc »

Yes, see Multithreaded Samples from OgreNext and the last part of the manual.

The concepts behind it aren't unique to OgreNext and work on Ogre 1.x as well.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: threaded physics

Post by slapin »

dark_sylinc wrote: Thu Sep 18, 2025 3:33 pm

Yes, see Multithreaded Samples from OgreNext and the last part of the manual.

The concepts behind it aren't unique to OgreNext and work on Ogre 1.x as well.

Thanks a lot!

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: threaded physics

Post by slapin »

rpgplayerrobin wrote: Thu Sep 18, 2025 3:11 pm

I have not tried it, but I have not seen it as a bottleneck in my game when activating analytics (which basically measures the time of all my code and the Ogre render step) it shows for me that it takes basically no time at all to update it.

So before you start with it, I would suggest you to first see if it actually takes a lot of performance in your application, because otherwise there is no point in doing this.

Well, it is not exactly a bottleneck in my case but perf shows 38% inside stepSimulation. And I have 7 other cores almost sleeping on my ARM CPU. And they could participate more in performance...

rpgplayerrobin
Orc Shaman
Posts: 788
Joined: Wed Mar 18, 2009 3:03 am
x 447

Re: threaded physics

Post by rpgplayerrobin »

What is your test scene doing when you get 38%?
My game when playing gets at most 3% or much less, even with some soft bodies in the scene.

It could be a setting or something that you might also use that decreases the performance.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: threaded physics

Post by slapin »

rpgplayerrobin wrote: Sat Sep 20, 2025 8:46 pm

What is your test scene doing when you get 38%?
My game when playing gets at most 3% or much less, even with some soft bodies in the scene.

It could be a setting or something that you might also use that decreases the performance.

3 ghost shapes (water and 2 characters), a heightmap collider for terrain, and a few boxes, not much, 60FPS on Rockchip rk3588 based board, same on PC. No dynamic RigidBodies (yet).

ghost shapes do their own narrow phase like they should.

It is not became a problem yet (I had some terrain size issues though - had to reduce worldSize for a chunk).

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5534
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1394

Re: threaded physics

Post by dark_sylinc »

Regarding Bullet's heightmap, beware of the following:

  • If an object is very big or your terrain density is high (i.e. one object sits at top many many triangles/pixels, instead of being inside just one pixel of the heightmap) it's going to be expensive.
  • If you perform a large raycast and it goes in 45° (diagonal), across the terrain, it's going to evalute width x height ray vs tri tests; where width and height depend on the surface area given by [ray_origin; ray_end]. Basically Bullet's algorithm to detect which candidates the ray goes through is very dumb and works best for short raycasts or for long rays that are axis aligned.

3 ghost shapes (water and 2 characters), a heightmap collider for terrain

Make sure to filter the water from the heightmap so they don't see each other. I suspect your water ghost is huge, which could trigger a massive test internally with the heightmap.

slapin
Bronze Sponsor
Bronze Sponsor
Posts: 250
Joined: Fri May 23, 2025 5:04 pm
x 16

Re: threaded physics

Post by slapin »

Yes, water is filtered-out or else it goes down do 30 FPS.