Jump to content

is it possible to set the size of the bounding box ?


jerome
 Share

Recommended Posts

Do I need to repeat the title here ?  ;)

 

I have an updatable big mesh (updated each frame, so I wouldn't not refresh its bounding box computation : too many vertices to iterate) and I would like to manually set its bounding box dimensions.

Even if this set bounding box then doesn't really match the (varying) mesh size.

 

Is there a clean way to do this ?

Link to comment
Share on other sites

I don't know about a clean way, but a simple way would be:

 

mesh._boundingInfo = new BoundingInfo(min, max).

 

Does your position./rotation/scaling of your mesh is updated as well ? Otherwise you could use mesh.freezeWorldMatrix(). Does exactly what it says :) (Does not update the worldmatrix at all).

Link to comment
Share on other sites

mmh...

the new BoundInfo() has the disadvantage to create a new instance each frame, so to allocate memory... and the GC won't love this  :P

 

This problem is not related to world matrix (I don't know if the mesh will be translated or rotated, it just can be). It is related to culling.

 

As my updatable mesh changes its dimensions each frame (starting from a tiny space), I don't want the whole mesh to be culled if  this tiny original space (original bounding box) gets out of the screen when the cam rotates, as other parts of this mesh should stay visible.

And to refresh the bounding box each frame is expensive because the mesh has thousands vertices.

 

So I'm looking for a way either to set fake bounding box dimensions once to fool the culling process, either to set directly some fix culling directives.

Link to comment
Share on other sites

I just re-read the API and coudn't find any setter accessors or updater ones :-(

I'm even wondering if the bounding box object is updated or recreated each time ...

 

 

 

 

just couldn't code today ... : m'ont pété les rouleaux au taf

Link to comment
Share on other sites

this has absolutely no effect :(

  console.log(PS.mesh.getBoundingInfo());  PS.mesh.getBoundingInfo()._update(BABYLON.Matrix.Scaling(new BABYLON.Vector3(300, 300, 300)));  console.log(PS.mesh.getBoundingInfo());

exactly the same BoundingInfo result  before and after the _update call

 

Am I missing anything ?

Link to comment
Share on other sites

Ok

either I have a immobile mesh, then I can freeze the world matrix and set the bounding box values (need to test)

either the mesh moves/rotates and I don't care about the bounding box because it is recomputed each frame

 

so in this case (immobile mesh), the freezing will be a real optimization regarding the bounding box needs :)

Link to comment
Share on other sites

Cooln thank you 

I tested initially with FF.

 

So the Vector3 values passed to the _update function are the value to scale the current bounding box dimensions ?

I mean : if my BB is, say, between min vector and max vector, it will then become between min vector * scale and max vector * scale ?

Am i right ? 

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