Demindiro / godot_rapier3d

Godot bindings for the Rapier3D physics engine
MIT License
42 stars 2 forks source link

Performance? Errors #15

Open geekrelief opened 3 years ago

geekrelief commented 3 years ago

First off, thanks for making this available. I'm looking forward to playing with this more to see if it's a good replacement for Bullet.

I was wondering what kind of performance numbers you're getting on the benchmark? I'm running a Ryzen 5 3600 and I get quite a bit of stuttering and the framerate quickly drops. I added the time patch, looks like there's typo in the return type of get_physics_step_time_usec in engine.h. It's returning float when it should be uint64_t.

Anyway, the dense test is giving me about 15fps. The initial framerate of sparse is >100 but quickly drops to the 40s when things start to collapse.

I notice I'm getting a bunch of errors too:

ERROR: <native>: TODO 0
   At: rapier3d\src\server\mod.rs:290
ERROR: <native>: TODO 1
   At: rapier3d\src\server\mod.rs:290
ERROR: <native>: TODO 2
   At: rapier3d\src\server\mod.rs:290
ERROR: <native>: TODO free shape
   At: rapier3d\src\server\shape.rs:235
ERROR: <native>: TODO free shape
   At: rapier3d\src\server\shape.rs:235
ERROR: Not implemented
   At: modules\pluggable_physics\server.gen.cpp:1251
WARNING: ObjectDB::cleanup: ObjectDB instances leaked at exit (run with --verbose for details).
     At: core\object.cpp:2069

The TODOs are being spammed. Could that affect performance?

Also, can you point me to where I can modify the velocity and position iterations? Thanks!

geekrelief commented 3 years ago

I dropped the number of boxes to 1000. I guess 4000 is expecting too much. I noticed running with the editor there's a stutter even though the frame rate is high. Looks like the stutter disappears when running in release.

Demindiro commented 3 years ago

It is expected that the performance drops quite a bit with the tests. I've intentionally added many boxes so most of the time is spent inside the physics engine (this was from before I patched Godot to only measure the time spent during the physics step, so I suppose it could be changed).

The "TODO free shape" shouldn't affect performance except when the boxes are being removed. The other errors shouldn't be frequent enough to influence performance.

Also, can you point me to where I can modify the velocity and position iterations? Thanks!

The iterations can be changed by adjusting the IntegrationParameters in space.rs.

The full list of fields can be found here: https://docs.rs/rapier3d/0.7.2/rapier3d/dynamics/struct.IntegrationParameters.html

geekrelief commented 3 years ago

Thanks for the pointer to the docs. The other TODO errors definitely cause a stutter for me when running in the editor. Then again, it might be due to changes from 3.2 to 3.3. as you mentioned in #16.

I guess my first assumption of the benchmark was to expect super smooth performance in rapier vs bullet. But now I'd assume bullet would probably run in single digit fps. Still having a 1000 objects is great!

geekrelief commented 3 years ago

You're right the TODO errors aren't causing a stutter, since I tried commenting them out. But they seem to coincide with them. https://drive.google.com/file/d/1LWjj881oopIlRR0q01OisHVkfDXr2p5J/view?usp=sharing I modified the benchmark to run 1000 boxes with the first run in editor. The stutter only appears with the editor. Any clue what's causing that? It's very distracting when testing.