Suphi Posted February 15, 2016 Share Posted February 15, 2016 Hi it's me again hope you guys don't mind me asking all these questions but i have a small problem. So i have a custom mesh and the mesh is dynamic and needs to get updated so this is how i do it: var positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);// edit positionsmesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions); Then when i moveWithCollisions the collisions are not updated. I have worked out a few ways to update the collisions but i'm not sure what is the correct/fastest method 1) mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions, false, true); 2) mesh.setIndices(mesh.getIndices()); 3) mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, positions); Whats the correct/fastest method? Quote Link to comment Share on other sites More sharing options...
Suphi Posted February 15, 2016 Author Share Posted February 15, 2016 i just ran some tests and this is what i got mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions, false, false);mesh.setIndices(mesh.getIndices()); around 0.13 milliseconds mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions, false, true); around 0.70 milliseconds mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, positions); around 0.20 milliseconds so from my tests looks like resetting the Indices is the fastest method is this the best way to do this it feels hacky Quote Link to comment Share on other sites More sharing options...
Suphi Posted February 15, 2016 Author Share Posted February 15, 2016 OK this is super strange updating indices does not update collisions correctly anymore but mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions, true); is now working when it was not before i have no idea what i changed i think this is the correct way to do this it takes about 0.30 milliseconds EDIT*mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions, true); is not working again i'm confused Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted February 15, 2016 Share Posted February 15, 2016 To trigger recompute of BoundingInfo, on which collisions are highly likely to be based, make sure the third parameter of updateVerticesData() is set to true. If you decide to also recompute normals, there is a method in mesh, updateMeshPositions(), which can do do it automatically. Unfortunately, it does not have a recompute BoundingInfo arg. Perhaps edit it & PR, if you like. Looks like there is also a bug in Geometry.updateVerticesData(). It probably should be ignoring updateExtends unless type is positions. Quote Link to comment Share on other sites More sharing options...
Suphi Posted February 15, 2016 Author Share Posted February 15, 2016 setting the 3rd parameter to true does not work for me i have to set it to true but at the same time i need to set the Indices again or collisions will not work Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 16, 2016 Share Posted February 16, 2016 Woot:) the best thing to do first is to provide a playground. Basically, calling mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, positions, true) should update the bounding info as you can see here: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.geometry.ts#L118 Quote Link to comment Share on other sites More sharing options...
Suphi Posted February 16, 2016 Author Share Posted February 16, 2016 OK i think i worked out why its doing it i'm making a playground demo showing the problem/maybe bug please wait loading... Quote Link to comment Share on other sites More sharing options...
Suphi Posted February 16, 2016 Author Share Posted February 16, 2016 OK this shows the problem: http://www.babylonjs-playground.com/#NTUKO#0 if we update the mesh inside registerBeforeRender collisions will not work correctly unless we setIndices again -------------------------------- Also if we set updateExtends to false and setIndices then the collisions does a strange bouncing thing but this is not really a problem just showing it to you http://www.babylonjs-playground.com/#NTUKO#1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 16, 2016 Share Posted February 16, 2016 It was a bug Now fixed: You can clear your cache and reload the PG Quote Link to comment Share on other sites More sharing options...
Suphi Posted February 16, 2016 Author Share Posted February 16, 2016 nice Quote Link to comment Share on other sites More sharing options...
jasonmcleod Posted September 21, 2016 Share Posted September 21, 2016 Are there additional steps to support physics after a mesh update? Using the same PG, I enabled physics but the ball still rolls over as if its flat.. thoughts? http://www.babylonjs-playground.com/#NTUKO#6 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 22, 2016 Share Posted September 22, 2016 Physic impostor are not updated when you change verticesData. In your case I recommend disabling/enabling physics to create an updated impostor Quote Link to comment Share on other sites More sharing options...
jasonmcleod Posted September 24, 2016 Share Posted September 24, 2016 Thanks deltakosh, first pass at that threw some errors. I'll continue to mess around and update this thread. Really appreciate the response GameMonetize 1 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.