Jump to content

Set Bounding Box fixed values


jerome
 Share

Recommended Posts

I retrieve this old post because I wasn't satisfied by my result :

Actually, I'm trying to set some fixed values to a mesh bounding box, different from the computed ones. I would like these fixed values to keep stored then forever, so not recomputed.

http://www.babylonjs-playground.com/#1OOAYL

what I did ? I created a mesh, then scaled its BB, then froze its World Matrix so it isn't computed any longer.
I expected to keep and display the BB scaled values... this is not what I get.

Where's my error ? and is this possible to set forever a fixed BB for a given (frozen) mesh ?
 

Link to comment
Share on other sites

but... is there a way to set BB fixed values (at least scaling ones) whatever the mesh world matrix would be recomputed or not ?

 

[EDIT] I'm reading the BBox code and I understand that its 8 vertices are recomputed on the call to _update(matrix)https://github.com/BabylonJS/Babylon.js/blob/master/src/Culling/babylon.boundingBox.ts#L56

AFAIUndersand, these 8 vertices are compared in turn with the transformed (by the passed matrix) 8 world vertices. Ok, this means we apply the same transformation to the BBox than the one applied to its embedded mesh.

What I don't find in the code is where the BBox is recomputed if the mesh has its World matric frozen and don't even move, rotate or scale, but is updated, so when the mesh vertices change their positions.

http://www.babylonjs-playground.com/#1JFDFW#2

Link to comment
Share on other sites

There is still something I don't get about the BBox and Pickability (or visibility).

Please have a look at this : http://www.babylonjs-playground.com/#1JFDFW#6

Everything is done from the line 216 :

sps.setParticles();                   // set them
s.freezeWorldMatrix();                // freeze the mesh world matrix
sps.refreshVisibleSize();	      // force BB recomputation once
s.getBoundingInfo().update(BABYLON.Matrix.Scaling(5, 5, 100)); // set BB fixed values
s.showBoundingBox = true;	// show the BB

As you can see, the mesh World Matrix is frozen, the BBox is computed once from the current vertex positions and then scaled once.

If you try the PG, you can blow the wall particle mesh. Then once the particles are on the ground AND still within the BBox they aren't pickable any longer.

Now, if I uncomment the line 210 what forces the BBox recomputation each frame, I get this : http://www.babylonjs-playground.com/#1JFDFW#7

If you try to pick the particles on the ground they are still pickable.

I thought that the pickability was related to the current BBox size. Did I miss something anywhere ?

 

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