Physics Bounding Box Rotation

Hi there,

I’m having an issue with the scene I exported from Blender. The physics bounding box rotation is not the same as the mesh. Please see the image below.

I’m currently using OimoJS, I have tried applying rotation in Blender and still no luck.

@VoxelCubes could you create a repro in the playground ?

also it might be totally expected as physix for perf is probably relying on Axes Aligned Bounding Box ? @RaananW might confirm ?

It seems like the initial rotation of the meshes is not being taken into account when building their bounding boxes. It might be an issue with the physics engine, but might be an issue with the export itself. What happens if you disable the physics impostors? are the bounding boxes the same? Have you tried using a different physics engine?

And as @sebavan said, reproduction on the playground would be helpful for us to understand the issue.

Hi guys,

Thanks for looking into this for me, please find the link to the playground as requested below.

All looks well in the playground except for the collider for the small mesh(railings3). Now I’m thinking it might be the version of Babylon I’m currently running or perhaps something else.

My package includes

"babylonjs": "^4.2.0",
"babylonjs-loaders": "^4.2.0",
"babylonjs-materials": "^4.2.0",
"oimo": "^1.0.9",

https://www.babylonjs-playground.com/#W8HMBC#5

Many thanks.

Yes please, can you try using the preview version ?

Got few errors with the preview version. Should I paste the errors here?

Yes please, it sounds scary to have errors in latest. I d really appreciate if you let us know @VoxelCubes

Running Babylon in [ “@angular/core”: “~9.1.11” ]

Updated BabylonJS To

"babylonjs": "^5.0.0-alpha.45",
"babylonjs-loaders": "^5.0.0-alpha.45",
"babylonjs-materials": "^5.0.0-alpha.45",
"oimo": "^1.0.9",

Error Log

ERROR in node_modules/babylonjs/babylon.module.d.ts:569:32 - error TS2304: Cannot find name 'XMLHttpRequestBodyInit'.
    
    569         send(body?: Document | XMLHttpRequestBodyInit | null): void;
                                       ~~~~~~~~~~~~~~~~~~~~~~
    node_modules/babylonjs/babylon.module.d.ts:65095:71 - error TS2304: Cannot find name 'BigUint64Array'.
    
    65095         readValues(firstQuery?: number, queryCount?: number): Promise<BigUint64Array | null>;
                                                                                ~~~~~~~~~~~~~~
    node_modules/babylonjs/babylon.module.d.ts:92918:32 - error TS2304: Cannot find name 'XMLHttpRequestBodyInit'.
    
    92918         send(body?: Document | XMLHttpRequestBodyInit | null): void;
                                         ~~~~~~~~~~~~~~~~~~~~~~
    node_modules/babylonjs/babylon.module.d.ts:154813:71 - error TS2304: Cannot find name 'BigUint64Array'.
    
    154813         readValues(firstQuery?: number, queryCount?: number): Promise<BigUint64Array | null>;
                                                                                 ~~~~~~~~~~~~~~
    node_modules/babylonjs/babylon.module.d.ts:181353:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'VRFrameData' must be of type '{ new (): VRFrameData; prototype: VRFrameData; }', but here has type 'any'.
    
    181353 declare var VRFrameData: any;
                       ~~~~~~~~~~~
    
      node_modules/typescript/lib/lib.dom.d.ts:16252:13
        16252 declare var VRFrameData: {
                          ~~~~~~~~~~~
        'VRFrameData' was also declared here.
1 Like

You might need to upgrade you Typescript version :frowning: or you could put skipLibCheck to true in your ts config ?

1 Like

skipLibCheck fixed the errors and the rotations issues are now resolved but the position is off for the colliders. The playground code already shows the position issue. see code below.

https://www.babylonjs-playground.com/#W8HMBC#5

Seems to be an issue with the oimo impostor initialization. Oimo has not updated in a while, and while we do support it, it tends to be the lease used engine in the last few years. Have you considered using a different engine? Cannon seems to calculate it correctly, and so does ammo:

Physics Box Bounding Box | Babylon.js Playground (babylonjs-playground.com)

Physics Box Bounding Box | Babylon.js Playground (babylonjs-playground.com)

I will anyhow look into the oimo issue, but i have to admit it might take a little while before I can invest the time to fix it.

Thank you for the assistance guys, I will move to ammojs for now and hopefully all works :slight_smile: and if something unusual pops up, I will let you know. Also, CannonJS example doesn’t look right, is that the expected result @RaananW

1 Like

which part doesn’t look right using cannon?

Hmm, strange, the model position was a bit off the first time I loaded the page. see the image below. But it looks good now after I refreshed.

1 Like

I finally found a solution to the collider positioning without switching physics engine.

In order to resolve the issue, I had to use the [ Set Origin ] option on each collider. See images.

And now :slight_smile:

image

Here are my specs just in case anyone wants to know.

Package

"@angular/core": "~9.1.11",
"babylonjs": "^5.0.0-alpha.45",
"babylonjs-loaders": "^5.0.0-alpha.45",
"babylonjs-materials": "^5.0.0-alpha.45",
"oimo": "^1.0.9",

Exporter

Babylonjs ver 2.93.3

Blender

Version 2.93.1

Thank you guys for all your help, really appreciate it. :slight_smile:

5 Likes