Jump to content

How to dispose ellipsoid in moveWithCollisions


brucewong21
 Share

Recommended Posts

So a gotcha of the moveWithCollisions method is that it uses an ellipsoid mesh to calculate collisions of your mesh instead of the original mesh dimensions. I see a clear way to remove your original mesh but how do we remove the ellipsoid mesh from the scene? I'm worried that keeping these ellipsoids even when my original mesh has been disposed of will hurt performance. Thank you so much.

Link to comment
Share on other sites

Hi BW.  Somemesh.ellipsoid is not a mesh, it is an "area". It will be gone with somemesh.dispose(), of course.

BUT, are you using a Wingnut function called BABYLON.Mesh.prototype.showEllipsoid()?  Are these "ellipsoid mesh"... wireframed spheres?

If so... do this...    somemesh.ellipsoidMesh.dispose();   ... after that.. somemesh.dispose();  Should work to kill those add-on sphere shapes.

Of course, you might wish to console.log(somemesh.ellipsoidMesh) to see if a mesh is there.  It might be so.

https://www.babylonjs-playground.com/#WWCK0#36

(lines 2-33)  Wingnut written "utility function" to show collision ellipsoids.  If you are using that, then yes... first somemesh.ellipsoidMesh.dispose(), and then somemesh.dispose().  Good idea.

I hope this helps.  Report back, please.  (thx)

Link to comment
Share on other sites

7 hours ago, Wingnut said:

Hi BW.  Somemesh.ellipsoid is not a mesh, it is an "area". It will be gone with somemesh.dispose(), of course.

BUT, are you using a Wingnut function called BABYLON.Mesh.prototype.showEllipsoid()?  Are these "ellipsoid mesh"... wireframed spheres?

If so... do this...    somemesh.ellipsoidMesh.dispose();   ... after that.. somemesh.dispose();  Should work to kill those add-on sphere shapes.

Of course, you might wish to console.log(somemesh.ellipsoidMesh) to see if a mesh is there.  It might be so.

https://www.babylonjs-playground.com/#WWCK0#36

(lines 2-33)  Wingnut written "utility function" to show collision ellipsoids.  If you are using that, then yes... first somemesh.ellipsoidMesh.dispose(), and then somemesh.dispose().  Good idea.

I hope this helps.  Report back, please.  (thx)

Sorry for the long delay in my response, I was trying to make a PG (no pain no gain :) ) but couldn't recreate the same situation. I was not using the Wingnut utility function btw so it's all good there!

As usual, my own stupidity overcomes me again! If you don't want to waste time don't read below. It seems that what was left behind after my mesh.dispose was not an "ellipsoid mesh" but rather an InstancedMesh object. I originally created my mesh like so

monsterInstance.hitbox = monsterType.hitbox.createInstance();

I tried to dispose of the mesh as so...

monsterInstance.hitbox.dispose();

 

It was leaving behind a InstanceMesh object which was still being affected by my other meshes colliding with it. After trying to recreate the error in PG, I eventually found out I was attaching the onCollide handler twice. I was calling the dispose method on my second onCollide handler. 

I never knew about these Wingnut functions and the utility one to see the ellipsoid will definitely help me! 
Thanks for your answer :)

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...