jerome Posted June 17, 2015 Share Posted June 17, 2015 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 ? Quote Link to comment Share on other sites More sharing options...
Temechon Posted June 17, 2015 Share Posted June 17, 2015 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). Quote Link to comment Share on other sites More sharing options...
jerome Posted June 17, 2015 Author Share Posted June 17, 2015 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 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. Quote Link to comment Share on other sites More sharing options...
jerome Posted June 18, 2015 Author Share Posted June 18, 2015 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 18, 2015 Share Posted June 18, 2015 Hey guys! every time the worldmatrix of a mesh is updated, the mesh calls boundingInfo._update() to keep the bbox in sync In your case, you can also call this function like:mesh.getBoundingInfo()._update(BABYLON.Matrix.Scaling(new BABYLON.Vector3(10, 1, 2)) Quote Link to comment Share on other sites More sharing options...
jerome Posted June 18, 2015 Author Share Posted June 18, 2015 Will this set the size as wanted ?cool Quote Link to comment Share on other sites More sharing options...
jerome Posted June 19, 2015 Author Share Posted June 19, 2015 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 ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 19, 2015 Share Posted June 19, 2015 The object is the same but inner bounding sphere and bounding box are updated (precisely the world members of these structures) Quote Link to comment Share on other sites More sharing options...
jerome Posted June 19, 2015 Author Share Posted June 19, 2015 mmh... I checked the world members. They had the same values before and after, although I expected a change by 300 times somewhere. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 19, 2015 Share Posted June 19, 2015 Warning: if your obejct is displayed, the computeWorldMatrix will be call and will overwrite your change Quote Link to comment Share on other sites More sharing options...
jerome Posted June 19, 2015 Author Share Posted June 19, 2015 Okeither 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 Quote Link to comment Share on other sites More sharing options...
jerome Posted June 19, 2015 Author Share Posted June 19, 2015 I just froze the world matrix before... this didn't change anything Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 19, 2015 Share Posted June 19, 2015 Yes sir! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 19, 2015 Share Posted June 19, 2015 Then you have another issue a little playground? Quote Link to comment Share on other sites More sharing options...
jerome Posted June 19, 2015 Author Share Posted June 19, 2015 heu, it's a big PG but anywayhttp://www.babylonjs-playground.com/#2JMK7G#3 look please at line 205the mesh world matrix is frozenthen I display in the console the bounding box infothen I update itthen display again same values in both objects Wingnut 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 19, 2015 Share Posted June 19, 2015 Actually it works http://www.babylonjs-playground.com/#2JMK7G#4 Beware when dumping objects, chrome is saving a reference in this case Wingnut 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted June 19, 2015 Author Share Posted June 19, 2015 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 ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 20, 2015 Share Posted June 20, 2015 Correct if the matrix used is a scaling matrix. The _update function applies the matrix to min and max vectors Quote Link to comment Share on other sites More sharing options...
jerome Posted June 20, 2015 Author Share Posted June 20, 2015 pigé Quote Link to comment Share on other sites More sharing options...
dbawel Posted June 20, 2015 Share Posted June 20, 2015 Forget dumping objects, let's simply dump Chrome. When will Google get it right? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 22, 2015 Share Posted June 22, 2015 Just use Edge Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.