ArrayMesh
and trimesh collision is pretty much what I'm doing too. Collision can get a speed up if you generate it before producing an ArrayMesh
: https://github.com/Zylann/godot_voxel/issues/54
In C# you'd probably need to pool your data structures to avoid garbage collection. Basically, during the game, new
should never happen more than once (even implicit new
called from inside C# libs).
Also, you don't need to "delete" the mesh at the end of the game. Meshes inherit Resource
, and Resource
inherit Reference
, so it will be automatically freed as soon as no other objects use it.
OpenSimplexNoise is relatively slow, especially in 3D with multiple octaves. You can speed it up depending on what you use it for. If it's voxels, you can look at the first octave and check if it's too high or too low so you can skip all other octaves since they won't have a high enough effect to affect the result. Another way is verify if a box is empty by looking at the corner values and check if the value can possibly ramp fast enough to become visible within that box (using derivatives).
If it's a heightmap, you can switch to shaders (and use a GLSL implementation of noise) to generate your terrain and grab the data from GPU using a Viewport
. You can probably do that too for voxels but in Godot 3 it's tricky due to the absence of a 3D image data type, it would be better with compute in Godot 4.
I've created a simple test script but nothing is showing up in the editor
Maybe you don't see the triange because of backface culling? Turn it around, maybe you'll see it