Conversation
|
To me it looks like there is a mismatch between the visual box size and the physics box size (although I don't spot the code bug), a simple shape like this should not penetrate. |
|
Hmm... I'm going to have to investigate this further... |
|
What kind of FPS were you getting? |
|
I've compared the demos
So it seems rapier is the fastest.
We can only make a comparison if the example uses the exact same setup like the three examples mentioned above. Otherwise a performance comparison isn't valid. If you can share a live example with for testing, we might have a chance to find out why you see a performance difference between |
box collision shape's convex radius (0.05) is too large for the visual cubes(side=0.075) 🤔 fyi, its less pronounced with smaller convex radius, e.g. 5% of min halfextent: |
|
@ycw I've added your approach to the branch. It looks indeed much better! |
|
nice |
| const sz = parameters.depth !== undefined ? parameters.depth / 2 : 0.5; | ||
|
|
||
| return new Jolt.BoxShape( new Jolt.Vec3( sx, sy, sz ), 0.05, null ); | ||
| return new Jolt.BoxShape( new Jolt.Vec3( sx, sy, sz ), 0.05 * Math.min( sx, sy, sz ), null ); |
There was a problem hiding this comment.
@jrouwe What do you think about this solution?
There was a problem hiding this comment.
Given that the example uses boxes of 0.075, a convex radius of 0.05 is indeed too big (the debug version of Jolt will assert because it is bigger than half the size of the box). So this solution is better as it reduces the convex radius to 0.00375.
The default allowed penetration in Jolt is 0.02 (PhysicsSettings.mPenetrationSlop) which means the boxes can still sink into each other by this amount. Also, this will not help performance as the allowed penetration is bigger than the convex radius which causes a more expensive code path to trigger more often. You can update the physics settings through PhysicsSystem.SetPhysicsSettings.
There's at least one big difference between the Rapier and Jolt tests. Rapier is configured to use the delta time from the browser as timestep: three.js/examples/jsm/physics/RapierPhysics.js Lines 166 to 167 in 360c0e9 while Jolt is configured to try to not make steps bigger than 1/60th of a second: three.js/examples/jsm/physics/JoltPhysics.js Lines 213 to 222 in 360c0e9 So when the frame rate is below 55 fps (as is the case in your test), Jolt is configured to do 2 simulation steps while Rapier is configured to do 1 (if I understand the Rapier code correctly). |
|
We should probably change it so both of them use the same approach. @jrouwe What approach would you think would be better for someone starting? (better = causes less headaches) |
|
For more basic/straightforward approach I'd just use the deltaTime. Drop the |
|
The danger of using |

Description
Just found out about Jolt which seems to be faster and more reliable than Rapier.
Made a
JoltPhysics.jswrapper for it:https://raw.githack.com/mrdoob/three.js/physics/examples/physics_jolt_instancing.html
Looks pretty good! Although the boxes seem to be overlapping 🤔
/fyi @jrouwe