JohnK Posted July 21, 2017 Share Posted July 21, 2017 After I first pushed the CreatePolygon function and it went live the following this PG http://playground.babylonjs.com/#4G18GY#2 was giving doublesided polygons, now it is only showing one side. Have had a look at my original code in javascript in a preview version of 3.0 and the current version of 3.0 in Javascript. Other than the additions Jerome did for frontUVs etc I cannot see where any changes would affect the doublesidedness. What is worse is that running the current version of 3.0 with a local example and now on a PG https://www.babylonjs-playground.com/#12X68C I get no mesh at all, but running against the preview version of 3.0 it still works OK. The preview version I changed to add the polygon code was downloaded on 27 June 2017. Probably a lot changed since then but hopefully what it was that did it could be found. Quote Link to comment Share on other sites More sharing options...
jerome Posted July 21, 2017 Share Posted July 21, 2017 I need to check this... JohnK 1 Quote Link to comment Share on other sites More sharing options...
JohnK Posted July 21, 2017 Author Share Posted July 21, 2017 @jerome just to be clear when it worked it used your frontUVs and backUVs correctly. Quote Link to comment Share on other sites More sharing options...
jerome Posted July 22, 2017 Share Posted July 22, 2017 mmhh... very weird, because I didn't touch anything since the frontUVs and backUVs addition, so since a big while here : https://github.com/BabylonJS/Babylon.js/pull/2212/files on 1st june Weirder : I can't see anything in the code of VertexData._ComputeSides() that would be different for the the Polygon mesh than for the others ... since it's the same called by any double sided mesh. Quote Link to comment Share on other sites More sharing options...
jerome Posted July 22, 2017 Share Posted July 22, 2017 Still investigating, now here : https://github.com/BabylonJS/Babylon.js/pull/2232/files btw, like we can't be sure the normalization computation approximation will give integer numbers, I would rather have written ">0" or "<0" instead of "==1" and "==-1" here : https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.vertexData.ts#L1653 and here : https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.vertexData.ts#L1657 or used something like EqualsWithEpsilon() Quote Link to comment Share on other sites More sharing options...
JohnK Posted July 22, 2017 Author Share Posted July 22, 2017 10 hours ago, jerome said: we can't be sure the normalization computation approximation will give integer numbers Not too worried about this as the PolygonMeshBuilder Build process set integer values for the normals. Though if you tell me it is still better to make the changes to <0 and >0 then I will do so. Back to original problem The problem seems to have arisen due to some changes in vertexData. After some time I tracked the discrepancy to the line vertexData.appyToMesh(polygon, options.updatable) up to this point everything is exactly the same, all positions, normals, indices and uvs. It seems that there is a problem using applyToMesh if the mesh already exists. If I add these lines polygon.dispose(); polygon = new BABYLON.Mesh(name, scene); before vertexData.applyToMesh(polygon, options.updatable); then everything works as before. Checking out what's new I found New BABYLON.VertexData.ExtractFromMesh function New BABYLON.VertexData object to easily manipulates vertex attributes Added mesh.markVerticesDataAsUpdatable() to allow a specific vertexbuffer to become updatable So the question now is do I simply add the two lines above or should I be doing something with the new vetexData object. I will wait for an answer to this before marking the topic as solved. jerome 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted July 22, 2017 Share Posted July 22, 2017 No idea what is the best ... the best is always the one what works JohnK 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted July 23, 2017 Share Posted July 23, 2017 and BTW, I would probably compare your floats like this because of the precision : Math.abs(y - 1.0) < 0.001 Quote Link to comment Share on other sites More sharing options...
JohnK Posted July 23, 2017 Author Share Posted July 23, 2017 About to do the changes and submit a PR so will do this as well. PR submitted Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 24, 2017 Share Posted July 24, 2017 It was a bug on my side thanks for having found it JohnK 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.