[java]public void getCell(Vector3f point, BulletAppState bulletAppState, boolean lookDown) {
int x, y, z;
//calculates the coordinates of the points that are within the mesh
x = (int) FastMath.floor(Math.abs(point.getX() / 2));
if (lookDown) {
y = (int) FastMath.ceil(Math.abs(point.getY() / 2));
} else {
y = (int) FastMath.floor(Math.abs(point.getY() / 2));
}
z = (int) FastMath.floor(Math.abs(point.getZ() / 2));
//Stored in mapCells 0 and 1, if 1 means there is a cube
mapCells[x][y][z] = 0;
//this.levelGeom.updateModelBound();
mapmesh.clearBuffer(Type.Position);
mapmesh.clearBuffer(Type.Normal);
mapmesh.clearBuffer(Type.TexCoord);
mapmesh.clearBuffer(Type.Index);
mapmesh.clearBuffer(Type.Color);
mapmesh.updateBound();
Ok. So is it a good idea to reuse already created (and root node attached) meshes/geomtries?
In our game bloxel I create each “update time” (after chunk changed etc.) a brand new mesh + a geometry. Should I recycle these objects too? What do you think?
My understanding is that if you change the mesh data then it will still need to be resent to the card. What you save is the direct memory churn which affects RAM usage. Direct memory buffers do not influence the garbage collector like regular heap memory does but they still only get garbage collected when the heap is GC’ed.
Therefore, it can be beneficial to reuse them… but I don’t think it affects rendering performance greatly.
ahoehma said:
Ok. So is it a good idea to reuse already created (and root node attached) meshes/geomtries?
In our game bloxel I create each "update time" (after chunk changed etc.) a brand new mesh + a geometry. Should I recycle these objects too? What do you think?
I trying to create a new mesh every update time, but the old mesh is not removed.. I don't understand how to remove the old mesh... detachAllChildren from box node don't remove mesh.. :(
Ok! your post give me an idea i know that, but now i could do it
but this is a new problem: mesh re-created pretty slow. May be this is because i have mesh 32x32 cubes, but i don’t think so… 16x16 chunk rebuild is noticeably too.