Jump to content

Mesh.MergeMeshes behaviour


jahow
 Share

Recommended Posts

Hi,

 

I'm currently doing heavy optimization work, and having a great time (kidding). Bringing the draw call count down etc.

 

As such, merging meshes for static geometry is an absolute necessity. There is an 'old' tutorial about that here, but I figured I'd try the modern way which is using Mesh.MergeMeshes. It didn't give me immediately expected behaviour:

 

1/ I realized I was trying to merge cloned meshes, and BJS made the browser freeze since it basically tried to merge an array with itself. I fixed the problem by using makeGeometryUnique on the meshes before merging, but that is kind of counter-intuitive (also there's a small bug on Geometry.clone() so it won't work that way in the playground either, but I've fixed this one locally).

 

2/ I've also found I needed to force a new computation of the meshes' world matrices before doing the merging. Again, this is kind of counter-intuitive and may lead to a lot of head banging on wall (it did with me).

 

These issues are illustrated in this playground: http://www.babylonjs-playground.com/#2FQOTS

 

Is this behaviour intentional/acceptable? If the answer is no, I'll gladly work on a PR to fix it. Otherwise, I guess this could all be explained in the documentation (which needs updating anyway).

Link to comment
Share on other sites

Thanks, I had not looked into that but it's interesting. I also realized I needed to do a forced matrix computation because I was merging the meshes before any render happened.

 

Still, wouldn't that be easier to automatically recompute the meshes' world matrices before merging them?

 

Also, the MergeMeshOptimization still fails if we're using cloned meshes... :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...