Merge a cloned mesh leeds into out of memory

Hello again,
It took me a while to figure this and I had to switch to another problematic mesh to get this understanding. Finally, turned up with this, working the merge of my wheels.

Where the ‘wheel_back’ is a clone of parts of the front wheel, with the added merge of a rear wheel sprocket, already merged together with wheel sprocket bolts… not sure I make myself clear here… told ya this project was a lego game;) In short it’s a triple merge of meshes and clones and merged clones.

Realizing with my suspension debug that the bug was unlikely to be a result of parenting, I focused on the merge and here is my discovery, although I’m not sure how to interprete this:

It appears that if I end my array of merged items (already merged meshes/clones and separate meshes/clones), If I end my array with my already merged “tyre” (in other words with a multimat although I didn’t set it, it comes from the merge), then the result is ok:

Project Motorcycle Debug merges

However, if I end my array with a single mat (non-merged) mesh or clone, the result is this:

Project Motorcycle Debug merges 4

Focus on the tyre and see how the material is applied. Set an alpha of 0 on the tyresidemat and see the difference between the front tyre base (at zero origin) and the back wheel tyre (on top right).
Notice that the count of vertices is the same in both cases, however the bug version displays a ‘ghost’ of the tyre side using the first material of the other merged object in the array (the sprocket with material named ‘aluscratchrustmat03’.

In resume, where ‘wheelsprocket’ and ‘tyre_back’ are already a merge of meshes and clones:

If I pass on this, it shows fine:
const wheel_back = BABYLON.Mesh.MergeMeshes([wheelb, wheelprofileb, wheelraysb, wheelsprocket, (scene.getMeshByName(“cyl_screwclone0”)), (scene.getMeshByName(“bolt_basic_clone2”)), tyre_back], true, true, undefined, false, true);

As opposed to this that shows fine with cdn but wrong with preview:
const wheel_back = BABYLON.Mesh.MergeMeshes([wheelb, wheelprofileb, wheelraysb, tyre_back, wheelsprocket, (scene.getMeshByName(“cyl_screwclone0”)), (scene.getMeshByName(“bolt_basic_clone2”))], true, true, undefined, false, true);

Edited 4h later:( :
Following the above I tried to apply this to my suspension (first exemple of buggy meshes) but had no luck. I tried hard figuring what was going, since the ‘standalone’ debug version is working, unmerging everything, removing meshes/clones, changing the order in the array, changing the materials but nothing did it.
Only now do I realize I get this warning from loading in preview (not with cdn)
GL_INVALID_OPERATION: Vertex buffer is not big enough for the draw call

@RaananW Could this be part of an explanation? Thanks for your time…

ok! seems like we still have an issue with cloned meshes when they are merged together.

I’ll look into that during the week, we’ll find a solution.

1 Like

Am issue was resolved with the merged meshes function, but I’m not sure if it helps you. Could you give it a try and tell me if it’s still not working as expected?

Will do, will let you know. Thanks for the fix anyways.

Edit: Sadly No, it still shows the same as can be seen here:
https://media-geneva.ch/demos/bjs/motorcycle/motorcycle-5a-preview.html

Just following up on this one - this issue has been resolved, right?

Thanks, for the follow-up. Not really, not in my case as you can still see in the link above.
I still need to check back on it (I found this one case explained above where passing a single mat last in the merge meshes array creates the bug as opposed to passing a multimat last in the array).
But the trick didn’t seem to work for all. I still suspect the issue to come from material may be associated with inverted meshes/clones (-1 scale). I will have to find a go-around. It still feels a bit weird that:

  1. it was working perfectly with previous versions (until end of february)
  2. the meshes/clones used are also used (multiple times) elsewhere and work fine.

Will have to return on it but meanwhile was just working some other project… I’ll let you know my findings.

1 Like