Ragdoll Physics on Left-Handed Scenes - Any Workarounds?

I know that ragdolls only work on right-handed scenes, not the default left-handed ones. Has anyone found a workaround or managed to get them working with left-handed scenes?

1 Like

@Cedric will love this one :slight_smile: cc @bghgary as well if he has an idea ?

I don’t know anything about ragdoll physics in Babylon.js so I’ll let @Cedric take it. Maybe @eoin knows also?

The problem I has is not with Physics engine but with the conversion from physics world orientation/position to Babylon skeleton hierarchy.
Intermediate transforms are inserted when loading a GLTF with left handedness and these transforms, coupled with bone local orientation plus TRS representation were an issue I could not solve.
I tried many things like using quaternion/position all along pipeline instead of matrix representation. I also tried to compute and verify results in various part of hierarchical transforms without success.
I’m pretty sure it’s possible to make it work with LH but I don’t know how to tackle it.

IIRC LH leads to non uniform scaling with negative values for some components. I don’t remember if I tried to pre transform vertices to put the mesh into a state I could control.
This was a nightmare but I’m sure it’s possible to make it work…not sure it’s possible without deep changes in Babylon bones hierarchy.

@Cedric I might have found a workaround. I uploaded the models that will use the ragdoll feature after the scene is created. Does it make sense? What could go wrong with this? https://playground.babylonjs.com/#DLPNQT#46

var scene = new BABYLON.Scene(engine);
scene.useRightHandedSystem = true;
const {meshes, particleSystems, skeletons} = await BABYLON.ImportMeshAsync("https://raw.githubusercontent.com/CedricGuillemet/dump/master/funnyGuy.glb", scene);
scene.useRightHandedSystem = false;
1 Like

With that (partial) flip, problem is the skeleton symetry: right is displayed on the left, basically:

Animations get that left/right symetry as well.

2 Likes

Thank you for the info!

OMG @ertugrulcetin you are the man :smiling_face_with_sunglasses:

Let me just double check: if we do the following with any glb mesh:

scene.useRightHandedSystem = true;
const {meshes, particleSystems, skeletons} = await BABYLON.ImportMeshAsync("https://raw.githubusercontent.com/CedricGuillemet/dump/master/funnyGuy.glb", scene);
scene.useRightHandedSystem = false;

we will convert the mesh/es to Babylon’s left-handed world. Everything will be taken care of for us by Babylon: animations will still work, attaching stuff to the skeleton will work, ragdolls will work.

The only catch is that the mesh will be flipped on the x-axis. But that is “only” a visual thing. Nothing will break or glitch. Shader will work, postprocesses, picking?

If all yes, then this seems to be a very good deal.


Nevermind :pleading_face:

In the playground it did look like it would work. But trying it in game, not a chance. Turning on ragdoll mode causes twisty bones and out-of-sync physics bodies. Bummer!

Not an expert on the glTF importer, but just going to add: the underlying vertex, skinning, and animation data is still “in” right-handed when imported into a scene, regardless of that scene’s useRightHandedSystem. I could see how something like that might mess up a physics engine?