I will try some of your suggestions, but let me first describe what I am actually doing:
Basically, I "misuse" PolyVox as a tool to create a mesh out of a 3D noise field. That's it. No paging, no LOD, nothing. Or rather, all of that we will be doing ourselves, as we just need the mesh and no voxel manipulation will happen at runtime (hence we need no voxel logic at runtime, a mesh is enough).
I also use only one a single volume.
Oh, and I indeed did not see the compiler warnings. I have many libraries that spawn warnings I can do nothing about, so I tend to ignore those if they do not come from my own files.
What I just tried is this:
Code:
//Extract and decode mesh
PolyVox::Region region = _voxelVolume->getEnclosingRegion();
region.shrink(30);
MeshType mesh = PolyVox::extractMarchingCubesMesh(_voxelVolume, region);
30 is 10% of the whole region. With that value, the error is gone.
So I tried with more values. From 15 on, things start to improve slightly, but all errors seem to be gone only from 25. So it is kind of a threshold.
Of course, we do not want to cut off almost 10% of our regions
I will now try another controller...
Edit: Okay, it seems the default controller already is the marching cubes one, so not sure what I should change there.
Edit 2:Okay, I replaced my SimpleVolume with a RawVolume. The result was a significant speedup, faster even than the old version using SimpleVolume. I also did the smoothing of the noise field directly on that field, not after I transferred it to the RawVolume. No idea why I did not do it like that to begin with.
So I think the performance problem is solved using RawVolume. If I understood everything, it should be better suited to our case anyway, right? We use the volume once to create a mesh, then delete it.
Edit 3:What I tried next is using different wrap modes. Border is the default and you know the result.
Clamp produces exactly the same erroneous faces as Border.
Both AssumeValid and Validate crash during the process, with Validate producing the following error:
Quote:
Position is outside valid region
Edit 4:I tried to get creative and thought "Well, if shrinking works, why not make the volume too big to begin with, then shrink the extracted region down to the correct size?!". So I created the RawVolume at 330x330x330, then shrunk the extracted region to be 300x300x300. Didn't work, same problem
It seems one really has to cut pieces of the actual region filled with noise values.
I am now officially out of ideas. My best bet now would be reverting to the old PolyVox and using RawVolume there for the speedup. But I would really love to test if the new extraction is faster in my case.