I am removing triangles from a mesh by updating the buffers. I remove the indexes/positions/normals and texture mapping of the selected triangle, set the buffers and the triangle disappears. All good except trying to remove a second triangle doesn’t work or causes one that I did not select to disappear.
I soon realized that if I click on the blank area where the triangle used to be I can still get the triangle Index?? How is that area even responding to my actionlistener?
When I call this I can see that the triangle count is decreasing:
int triCount = resultsGame.getClosestCollision().getGeometry().getTriangleCount();
When I call this after clicking on a blank area where the triangle used to be it returns the index of that dead and gone triangle:
int triIDX = resultsGame.getClosestCollision().getTriangleIndex() ;
It seems as if there is a discrepancy in the indexes where there is a ghost copy that refuses to update. I looked up the ‘getTriangle’ function in Mesh.java and can see that it is using the index buffer to find the Triangle vertices. Is the index that gets passed into that function in any way related to the Index returned by getIndex on the Triangle object?
I’m updating the buffers as follows - nothing earth shattering. I added the clear buffer and .updateCounts to see if I could somehow get the deleted triangle to go away.
m.clearBuffer(VertexBuffer.Type.Index); m.clearBuffer(VertexBuffer.Type.Position); m.clearBuffer(VertexBuffer.Type.Normal); m.setBuffer(VertexBuffer.Type.Index, 1, BufferUtils.createShortBuffer(ibNewarray)); m.setBuffer(VertexBuffer.Type.Position, 3, BufferUtils.createFloatBuffer(vbNewarray)); m.setBuffer(VertexBuffer.Type.Normal, 3, BufferUtils.createFloatBuffer(normNewarray)); m.updateCounts();