Just a moment with that, I have another weird problem.
In my editor I have this function:
Code:
void VoxelEntity::RebuildAllInBox(Vector3& min, Vector3 &max)
{
Vector3 meshMin, meshMax;
for (int x = 0; x < m_NumPatchesX; x++)
for (int y = 0; y < m_NumPatchesY; y++)
for (int z = 0; z < m_NumPatchesZ; z++)
{
GetMeshBoundingBox(PolyVox::Vector3DInt32(x,y,z), meshMin, meshMax);
if (IntersectBoxToBox(min, max, meshMin, meshMax))
m_Meshes[PolyVox::Vector3DInt32(x,y,z)]->Construct(*m_VolumeData.get(), PolyVox::Region(PolyVox::Vector3DInt32(x * m_PatchSizeX, y * m_PatchSizeY, z * m_PatchSizeZ), PolyVox::Vector3DInt32(m_PatchSizeX + x * m_PatchSizeX, m_PatchSizeY + y * m_PatchSizeY, m_PatchSizeZ + z * m_PatchSizeZ)));
}
}
Here is my Cosntruct function:
Code:
bool VoxelMesh::Construct(PolyVox::Volume<PolyVox::MaterialDensityPair44>& volume, PolyVox::Region region)
{
PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> mesh;
PolyVox::SurfaceExtractor<PolyVox::MaterialDensityPair44> surfaceExtractor(&volume, region, &mesh);
surfaceExtractor.execute();
//mesh.smoothPositions(1, true);
const vector<uint32_t>& vecIndices = mesh.getIndices();
const vector<PolyVox::PositionMaterialNormal>& vecVertices = mesh.getVertices();
m_VertexBuffer.Create(sizeof(PolyVox::PositionMaterialNormal) * mesh.getNoOfVertices());
m_IndexBuffer.Create(mesh.getNoOfIndices() * sizeof(DWORD), 8UL, D3DFMT_INDEX32);
if (vecIndices.empty())
return false;
void* pVoid;
m_IndexBuffer.Lock(&pVoid);
const void* pIndices = static_cast<const void*>(&(vecIndices[0]));
int count = 0;
memcpy((pVoid), pIndices, sizeof(uint32_t) * vecIndices.size());
m_IndexBuffer.Unlock();
const void* pVertices = static_cast<const void*>(&(vecVertices[0]));
m_VertexBuffer.Lock(&pVoid);
count = 0;
memcpy((pVoid), pVertices, sizeof(PolyVox::PositionMaterialNormal) * vecVertices.size());
m_VertexBuffer.Unlock();
m_NumVertices = vecVertices.size();
m_NumFaces = vecIndices.size() / 3;
m_Region = region;
m_WorldPosition.Move(region.getLowerCorner().getX(), region.getLowerCorner().getY(), region.getLowerCorner().getZ());
m_WorldPosition.Update();
return true;
}
Now here is the strange part:
First of all I am having this hole, only at the first patch it seems:

But here is another problem I have on every patch:

I click to create the "bulge" close to me and it also created one in the patch next to it. The problem is not with the editor because it edits the volume itself, not the patches, just updates the patches with the above function.
Now when I move to the next patch and tried to create one at the border it create again on the next, but also around the same positino in the previous patch!
Again, it does not create them on patches other than neighbouring ones.

This also happens when I edit the the edge at the very beginning (editing the next)