Replaced 'm_region' with 'm_offset' and demonstrated its use.

This commit is contained in:
David Williams 2014-06-02 17:30:41 +02:00
parent 9fd52e3494
commit 31e5a6e346
5 changed files with 23 additions and 7 deletions

View File

@ -130,8 +130,9 @@ int main(int argc, char *argv[])
// The returned mesh needs to be decoded to be appropriate for GPU rendering.
auto decodedMesh = decode(mesh);
//Pass the surface to the OpenGL window
openGLWidget.addMesh(decodedMesh, Vector3DInt32(x, y, z));
// Pass the surface to the OpenGL window. Note that we are also passing an offset in this multi-mesh example. This is because
// the surface extractors return a mesh with 'local space' positions to reduce storage requirements and precision problems.
openGLWidget.addMesh(decodedMesh, decodedMesh.getOffset());
meshCounter++;
}

View File

@ -196,7 +196,7 @@ namespace PolyVox
}
}
m_meshCurrent->m_Region = m_regSizeInVoxels;
m_meshCurrent->setOffset(m_regSizeInVoxels.getLowerCorner());
m_meshCurrent->removeUnusedVertices();
m_meshCurrent->m_vecLodRecords.clear();

View File

@ -122,7 +122,7 @@ namespace PolyVox
m_regSliceCurrent.shift(Vector3DInt32(0,0,1));
}
m_meshCurrent->m_Region = m_regSizeInVoxels;
m_meshCurrent->setOffset(m_regSizeInVoxels.getLowerCorner());
m_meshCurrent->m_vecLodRecords.clear();
LodRecord lodRecord;

View File

@ -59,6 +59,9 @@ namespace PolyVox
uint32_t getNoOfIndices(void) const;
uint32_t getNoOfVertices(void) const;
const std::vector<VertexType>& getVertices(void) const;
const Vector3DInt32& getOffset(void) const;
void setOffset(const Vector3DInt32& offset);
void addTriangle(uint32_t index0, uint32_t index1, uint32_t index2);
uint32_t addVertex(const VertexType& vertex);
@ -66,7 +69,7 @@ namespace PolyVox
bool isEmpty(void) const;
void removeUnusedVertices(void);
Region m_Region;
Vector3DInt32 m_offset;
public:
std::vector<uint32_t> m_vecTriangleIndices;
@ -88,7 +91,7 @@ namespace PolyVox
result.m_vecTriangleIndices = mesh.m_vecTriangleIndices;
result.m_Region = mesh.m_Region;
result.m_offset = mesh.m_offset;
return result;
}

View File

@ -55,7 +55,19 @@ namespace PolyVox
const std::vector<VertexType>& Mesh<VertexType>::getVertices(void) const
{
return m_vecVertices;
}
}
template <typename VertexType>
const Vector3DInt32& Mesh<VertexType>::getOffset(void) const
{
return m_offset;
}
template <typename VertexType>
void Mesh<VertexType>::setOffset(const Vector3DInt32& offset)
{
m_offset = offset;
}
template <typename VertexType>
void Mesh<VertexType>::addTriangle(uint32_t index0, uint32_t index1, uint32_t index2)