cables-gl / cables_docs

cables documentation docs.cables.gl
https://cables.gl/docs/docs
44 stars 15 forks source link

Ammobody GLTF Mesh Initialisation Inconsistent #437

Open sebastianpetrovski opened 1 year ago

sebastianpetrovski commented 1 year ago

Describe the bug AmmoBodies from GLTF mesh set to Convex Hull with Mass = NonZero are not initialising consistently.

To Reproduce Please open in editor: a simplified and commented Patch based on the AmmoRaycast example here: https://cables.gl/p/SYrXFk

Expected behavior Initialisation and simulation of all Ammobodies

Desktop:

Smartphone:

Additional context In my original patch I thought maybe loading 5 lowpoly meshes at once was tripping it up somehow. So I tried using a TriggerDelay to initialise multiple objects 0.1 seconds after one another.

After further testing I found that when just 1 Ammobody from GLTF mesh with Geom Convex Hull is present it does not initialise consistently.

My solution while building has been to assign Right Click to reset Ammoworld and Repeatedly resetting Ammoworld until it results in successfully initialising Ammobodies.

After resetting Ammoworld a bunch and once all AmmoBodies initialise together: any simulation I've tried works really well, on desktop and mobile. Like, impressively well and it seems performant without any effort. I went ahead and made custom physics geometry for each rendered object and got even better simulation results. It seems like AmmoPhysics is super robust so I can't figure why the initialisation is bombing for me. Keen to see what you guys make of the debug patch.

pandrr commented 1 year ago

ok the behavious is really strange.

first: remove inactive objects should be activated, so you only see the current objects.

needs more investigation.

the origin position and rotation from ammo are somehow invalid numbers. if you add a coordinate op at the end of the branch you see they are all "NaN" will investigate further.

sebastianpetrovski commented 1 year ago

Hi,

Thanks for checking it out. Please let me know if I can help troubleshoot further.

Thanks also for letting me know re. Remove inactive objects and using a coordinate op to troubleshoot.

sebastianpetrovski commented 1 year ago

Hey,

Happy New Year 😀

Is there anyway I can help to troubleshoot this issue?

sebastianpetrovski commented 1 year ago

Hey there,

Is there anything I can do to help troubleshoot this?

sebastianpetrovski commented 1 year ago

Hey,

I just did a screen recording for my own reference and thought to share it here in case its helpful in some way. Its so strange how the AmmoWorld reset seems to inconsistently affect the AmmoBodies. Sometimes 2 bodies pop, sometimes 1. But always the simulation itself is fine.

https://user-images.githubusercontent.com/74696962/222156930-d91d6aa9-ba8f-4698-a27b-32995daa2e2f.mp4

Please let me know if there's anything I can do to help troubleshoot this.

pandrr commented 1 year ago

try to disable auto remove bodies in ammoworld op

sebastianpetrovski commented 1 year ago

Hello pandrr, thanks for your reply.

In that patch it is disabled already.

On the AmmoBody op I also tried the flag "never deactivate".

pandrr commented 1 year ago

can you try on a faster machine ? or optimize the patch ? the fps numbers in the video are quite low maybe it this idk

sebastianpetrovski commented 1 year ago

normally it is 60fps - recording was just slow with OBS this time.

Is the patch working normally on your machine?

pandrr commented 1 year ago

https://user-images.githubusercontent.com/98792/222179022-68b4a761-244d-4ba3-89ee-47d28d9bd3d9.mov

sebastianpetrovski commented 1 year ago

I think maybe my first patch was not clear. The issue is with multiple ammobodies not loading.

Maybe this patch makes the bug more clear: https://cables.gl/p/63ff6c2fa20b87e9f95741c5?s=hMVdEHh13NdTMYCP

There are 2 ammobodies - so we should see 2 ammobodies. But only 1 shows.

if you reset ammoworld with right click sometimes both ammobodies show, sometimes just one or the other.

sebastianpetrovski commented 1 year ago

Hey @pandrr I'm so sorry to be a pest. I keep following up because I've got this large patch I've been working on since last year and its part of a larger portfolio project I've been working on. I'm stoked with how its looking, but can't actually use it unless the ammobodies are all loading consistently.

The simulation works very well, but its rare that all ammobodies are visible. I have to reset the ammobodiesWorld 50-100 times to get them to all appear.

I've noticed after looking at the other ammobodies example patches it seems like there's only ever one GLTF Op present. Could that be the bug? Only one GLTF op is compatible with ammobides? Can this be fixed?

I've tried many different configurations and I'm certain as I can be that its a bug in how ammobodies is implemented in cables.

Here is the patch I've been working on since last year: https://cables.gl/p/639242a028fcb83dd0938687?s=mSQxdyGPLnGRo0TO

The patch is set-up to restart AmmoBodies world with right click.

It might take a few seconds to load as there's a lot of textures. And I haven't implemented a loading screen yet so it might look like its broken while the textures are downloaded/loaded into memory.

Thanks so much for getting through my message.