What is the best way to manipulate a mesh at runtime without significant lag? I want to be able to raise and lower a terrain's collider mesh. It is 256x256 faces big. Not sure I'm doing this right but this is the process. It seems overly complicated but don't know another way, please let me know if there is a more straightforward way of doing this.
- I have a mesh (collider mesh) in the scene
- To change a vertex I have to convert the mesh into an
ArrayMesh
using SurfaceTools
- Then create a
MeshDataTool
and assign the ArrayMesh
- Get the vertex and set the new value
- Then do all this to commit the new mesh shape:
array_mesh.surface_remove(0)
mesh_data.commit_to_surface(array_mesh)
surface_tool.create_from(array_ground, 0)
surface_tool.generate_normals() ## probably don't need this for a collider mesh
mesh = surface_tool.commit()
If I hard code this to find 1 specific vertex and change its Y-value this operation takes about 1 second to perform. Is there a way to manipulate a mesh at runtime that is way more performant than this. It can't be with a shader, since it is for a collider mesh.
Thanks!