I'm creating a voxel-based game with procedurally generates rooms. I've created a 'voxel-no-collision' scene which just contains a single MeshInstance node, and elsewhere a 'room generator' script instances this scene and then uses a SurfaceTool to build the appropriate cube faces. Without any collision involved everything runs at a reasonable speed. However, when I have the room generator instance a different 'voxel' scene which is identical except it also contains a StaticBody and CollisionShape (which has a default BoxShape and a scale of 0.5, 0.5, 0.5) the level generation becomes very very slow.
As a point of reference, I instantiated a 20x20x20 grid of cubes without collision and it takes on average about 125ms to complete, but with collision it takes on average 5 seconds (i.e. with collision it is 4,000% slower!)
For comparison, I set up the same process in Unity (spawning a 20x20x20 grid of Cube Prefabs - both with and without a BoxCollider). Without collision involved the instancing speed was very similar to Godot (around 125ms), however the addition of a BoxCollider to the prefab had a far smaller impact. The total time to instance all 8,000 'cubes with collision' increased to just 200ms - so only 60% slower which is a lot better that the 4,000% slow-down that I'm seeing in Godot.
Could anyone please explain the cause of the delay that I'm seeing, and let me know if there is a different approach that I could take in Godot to achieve similar speeds?
Thanks in advance.