diff --git a/examples/OpenGL/OpenGLImmediateModeSupport.cpp b/examples/OpenGL/OpenGLImmediateModeSupport.cpp index f105065a..320a5050 100644 --- a/examples/OpenGL/OpenGLImmediateModeSupport.cpp +++ b/examples/OpenGL/OpenGLImmediateModeSupport.cpp @@ -24,18 +24,18 @@ freely, subject to the following restrictions: #include "OpenGLImmediateModeSupport.h" #include "OpenGLSupport.h" -#include "IndexedSurfacePatch.h" +#include "SurfaceMesh.h" using namespace PolyVox; using namespace std; -void renderRegionImmediateMode(PolyVox::IndexedSurfacePatch& isp, unsigned int uLodLevel) +void renderRegionImmediateMode(PolyVox::SurfaceMesh& mesh, unsigned int uLodLevel) { - const vector& vecVertices = isp.getVertices(); - const vector& vecIndices = isp.getIndices(); + const vector& vecVertices = mesh.getVertices(); + const vector& vecIndices = mesh.getIndices(); - int beginIndex = isp.m_vecLodRecords[uLodLevel].beginIndex; - int endIndex = isp.m_vecLodRecords[uLodLevel].endIndex; + int beginIndex = mesh.m_vecLodRecords[uLodLevel].beginIndex; + int endIndex = mesh.m_vecLodRecords[uLodLevel].endIndex; glBegin(GL_TRIANGLES); //for(vector::const_iterator iterIndex = vecIndices.begin(); iterIndex != vecIndices.end(); ++iterIndex) @@ -44,7 +44,7 @@ void renderRegionImmediateMode(PolyVox::IndexedSurfacePatch& isp, unsigned int u const SurfaceVertex& vertex = vecVertices[vecIndices[index]]; const Vector3DFloat& v3dVertexPos = vertex.getPosition(); //const Vector3DFloat v3dRegionOffset(uRegionX * g_uRegionSideLength, uRegionY * g_uRegionSideLength, uRegionZ * g_uRegionSideLength); - const Vector3DFloat v3dFinalVertexPos = v3dVertexPos + static_cast(isp.m_Region.getLowerCorner()); + const Vector3DFloat v3dFinalVertexPos = v3dVertexPos + static_cast(mesh.m_Region.getLowerCorner()); diff --git a/examples/OpenGL/OpenGLImmediateModeSupport.h b/examples/OpenGL/OpenGLImmediateModeSupport.h index c94873cf..509ef440 100644 --- a/examples/OpenGL/OpenGLImmediateModeSupport.h +++ b/examples/OpenGL/OpenGLImmediateModeSupport.h @@ -28,6 +28,6 @@ freely, subject to the following restrictions: #include "glew/glew.h" -void renderRegionImmediateMode(PolyVox::IndexedSurfacePatch& isp, unsigned int uLodLevel); +void renderRegionImmediateMode(PolyVox::SurfaceMesh& mesh, unsigned int uLodLevel); #endif //__OpenGLExample_OpenGLImmediateModeSupport_H__ diff --git a/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp b/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp index ecb3f620..f51c8045 100644 --- a/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp +++ b/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp @@ -24,22 +24,22 @@ freely, subject to the following restrictions: #include "OpenGLSupport.h" #include "OpenGLVertexBufferObjectSupport.h" -#include "IndexedSurfacePatch.h" +#include "SurfaceMesh.h" using namespace PolyVox; using namespace std; -OpenGLSurfacePatch BuildOpenGLSurfacePatch(const IndexedSurfacePatch& isp) +OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const SurfaceMesh& mesh) { //Represents our filled in OpenGL vertex and index buffer objects. - OpenGLSurfacePatch result; + OpenGLSurfaceMesh result; //The source - result.sourceISP = &isp; + result.sourceMesh = &mesh; //Convienient access to the vertices and indices - const vector& vecVertices = isp.getVertices(); - const vector& vecIndices = isp.getIndices(); + const vector& vecVertices = mesh.getVertices(); + const vector& vecIndices = mesh.getIndices(); //If we have any indices... if(!vecIndices.empty()) @@ -67,7 +67,7 @@ OpenGLSurfacePatch BuildOpenGLSurfacePatch(const IndexedSurfacePatch& isp) const SurfaceVertex& vertex = *iterVertex; const Vector3DFloat& v3dVertexPos = vertex.getPosition(); //const Vector3DFloat v3dRegionOffset(uRegionX * g_uRegionSideLength, uRegionY * g_uRegionSideLength, uRegionZ * g_uRegionSideLength); - const Vector3DFloat v3dFinalVertexPos = v3dVertexPos + static_cast(isp.m_Region.getLowerCorner()); + const Vector3DFloat v3dFinalVertexPos = v3dVertexPos + static_cast(mesh.m_Region.getLowerCorner()); *ptr = v3dFinalVertexPos.getX(); ptr++; @@ -100,23 +100,23 @@ OpenGLSurfacePatch BuildOpenGLSurfacePatch(const IndexedSurfacePatch& isp) return result; } -void renderRegionVertexBufferObject(const OpenGLSurfacePatch& openGLSurfacePatch, unsigned int uLodLevel) +void renderRegionVertexBufferObject(const OpenGLSurfaceMesh& openGLSurfaceMesh, unsigned int uLodLevel) { - int beginIndex = openGLSurfacePatch.sourceISP->m_vecLodRecords[uLodLevel].beginIndex; - int endIndex = openGLSurfacePatch.sourceISP->m_vecLodRecords[uLodLevel].endIndex; - glBindBuffer(GL_ARRAY_BUFFER, openGLSurfacePatch.vertexBuffer); + int beginIndex = openGLSurfaceMesh.sourceMesh->m_vecLodRecords[uLodLevel].beginIndex; + int endIndex = openGLSurfaceMesh.sourceMesh->m_vecLodRecords[uLodLevel].endIndex; + glBindBuffer(GL_ARRAY_BUFFER, openGLSurfaceMesh.vertexBuffer); glVertexPointer(3, GL_FLOAT, 36, 0); glNormalPointer(GL_FLOAT, 36, (GLvoid*)12); glColorPointer(3, GL_FLOAT, 36, (GLvoid*)24); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, openGLSurfacePatch.indexBuffer); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, openGLSurfaceMesh.indexBuffer); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_COLOR_ARRAY); - //glDrawElements(GL_TRIANGLES, openGLSurfacePatch.noOfIndices, GL_UNSIGNED_INT, 0); - glDrawRangeElements(GL_TRIANGLES, beginIndex, endIndex-1, endIndex - beginIndex,/* openGLSurfacePatch.noOfIndices,*/ GL_UNSIGNED_INT, 0); + //glDrawElements(GL_TRIANGLES, openGLSurfaceMesh.noOfIndices, GL_UNSIGNED_INT, 0); + glDrawRangeElements(GL_TRIANGLES, beginIndex, endIndex-1, endIndex - beginIndex,/* openGLSurfaceMesh.noOfIndices,*/ GL_UNSIGNED_INT, 0); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); diff --git a/examples/OpenGL/OpenGLVertexBufferObjectSupport.h b/examples/OpenGL/OpenGLVertexBufferObjectSupport.h index 39482e10..b73ef7af 100644 --- a/examples/OpenGL/OpenGLVertexBufferObjectSupport.h +++ b/examples/OpenGL/OpenGLVertexBufferObjectSupport.h @@ -28,15 +28,15 @@ freely, subject to the following restrictions: #include "glew/glew.h" -struct OpenGLSurfacePatch +struct OpenGLSurfaceMesh { GLulong noOfIndices; GLuint indexBuffer; GLuint vertexBuffer; - const PolyVox::IndexedSurfacePatch* sourceISP; + const PolyVox::SurfaceMesh* sourceMesh; }; -OpenGLSurfacePatch BuildOpenGLSurfacePatch(const PolyVox::IndexedSurfacePatch& isp); -void renderRegionVertexBufferObject(const OpenGLSurfacePatch& openGLSurfacePatch, unsigned int uLodLevel); +OpenGLSurfaceMesh BuildOpenGLSurfaceMesh(const PolyVox::SurfaceMesh& mesh); +void renderRegionVertexBufferObject(const OpenGLSurfaceMesh& openGLSurfaceMesh, unsigned int uLodLevel); #endif //__OpenGLExample_OpenGLVertexBufferObjectSupport_H__ diff --git a/examples/OpenGL/OpenGLWidget.cpp b/examples/OpenGL/OpenGLWidget.cpp index b173612d..9afbbac1 100644 --- a/examples/OpenGL/OpenGLWidget.cpp +++ b/examples/OpenGL/OpenGLWidget.cpp @@ -51,8 +51,8 @@ OpenGLWidget::OpenGLWidget(QWidget *parent) void OpenGLWidget::setVolume(PolyVox::Volume* volData) { //First we free anything from the previous volume (if there was one). - m_mapOpenGLSurfacePatches.clear(); - m_mapIndexedSurfacePatches.clear(); + m_mapOpenGLSurfaceMeshes.clear(); + m_mapSurfaceMeshes.clear(); m_volData = volData; //If we have any volume data then generate the new surface patches. @@ -89,63 +89,63 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) Vector3DInt16 regUpperCorner(regionEndX, regionEndY, regionEndZ); //Extract the surface for this region - //extractSurface(m_volData, 0, PolyVox::Region(regLowerCorner, regUpperCorner), ispCurrent); - POLYVOX_SHARED_PTR isp = surfaceExtractor.extractSurfaceForRegion(PolyVox::Region(regLowerCorner, regUpperCorner)); + //extractSurface(m_volData, 0, PolyVox::Region(regLowerCorner, regUpperCorner), meshCurrent); + POLYVOX_SHARED_PTR mesh = surfaceExtractor.extractSurfaceForRegion(PolyVox::Region(regLowerCorner, regUpperCorner)); - //computeNormalsForVertices(m_volData, *(isp.get()), SOBEL_SMOOTHED); - //*ispCurrent = getSmoothedSurface(*ispCurrent); - //isp->smooth(0.3f); - //ispCurrent->generateAveragedFaceNormals(true); + //computeNormalsForVertices(m_volData, *(mesh.get()), SOBEL_SMOOTHED); + //*meshCurrent = getSmoothedSurface(*meshCurrent); + //mesh->smooth(0.3f); + //meshCurrent->generateAveragedFaceNormals(true); - if(isp->m_vecTriangleIndices.size() > 0) + if(mesh->m_vecTriangleIndices.size() > 0) { - //isp->makeProgressiveMesh(); + //mesh->makeProgressiveMesh(); /*RenderDynamicMesh rdm; - rdm.buildFromIndexedSurfacePatch(*isp);*/ + rdm.buildFromSurfaceMesh(*mesh);*/ - //computeNormalsForVertices(m_volData, *(isp.get()), SOBEL_SMOOTHED); + //computeNormalsForVertices(m_volData, *(mesh.get()), SOBEL_SMOOTHED); - //isp->smoothPositions(0.3f); - //isp->generateAveragedFaceNormals(true); + //mesh->smoothPositions(0.3f); + //mesh->generateAveragedFaceNormals(true); /*for(int ct = 0; ct < 20; ct ++) { - //cout << "Before: " << isp->noOfDegenerateTris() << endl; - isp->decimate(); - //cout << "After: " << isp->noOfDegenerateTris() << endl; - isp->removeDegenerateTris(); - //cout << "After Remove: " << isp->noOfDegenerateTris() << endl << endl; + //cout << "Before: " << mesh->noOfDegenerateTris() << endl; + mesh->decimate(); + //cout << "After: " << mesh->noOfDegenerateTris() << endl; + mesh->removeDegenerateTris(); + //cout << "After Remove: " << mesh->noOfDegenerateTris() << endl << endl; }*/ //////////////////////////////////////////////////////////////////////////////// - //For decimation built into ISP - //isp->generateAveragedFaceNormals(true); + //For decimation built into Mesh + //mesh->generateAveragedFaceNormals(true); - isp->decimate(0.999f); + mesh->decimate(0.999f); - //isp->generateAveragedFaceNormals(true); + //mesh->generateAveragedFaceNormals(true); //////////////////////////////////////////////////////////////////////////////// - /*isp->generateAveragedFaceNormals(true); + /*mesh->generateAveragedFaceNormals(true); Mesh mesh; - mesh.buildFromISP(isp.get()); + mesh.buildFromMesh(mesh.get()); //mesh.removeEdge(*(mesh.m_edges.begin())); mesh.decimateAll(); - mesh.fillISP(isp.get());*/ + mesh.fillMesh(mesh.get());*/ Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ); if(m_bUseOpenGLVertexBufferObjects) { - OpenGLSurfacePatch openGLSurfacePatch = BuildOpenGLSurfacePatch(*(isp.get())); - m_mapOpenGLSurfacePatches.insert(make_pair(v3dRegPos, openGLSurfacePatch)); + OpenGLSurfaceMesh openGLSurfaceMesh = BuildOpenGLSurfaceMesh(*(mesh.get())); + m_mapOpenGLSurfaceMeshes.insert(make_pair(v3dRegPos, openGLSurfaceMesh)); } //else //{ - m_mapIndexedSurfacePatches.insert(make_pair(v3dRegPos, isp)); + m_mapSurfaceMeshes.insert(make_pair(v3dRegPos, mesh)); //} - //delete ispCurrent; + //delete meshCurrent; } } } @@ -226,17 +226,17 @@ void OpenGLWidget::paintGL() for(PolyVox::uint16_t uRegionX = 0; uRegionX < m_uVolumeWidthInRegions; ++uRegionX) { Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ); - if(m_mapIndexedSurfacePatches.find(v3dRegPos) != m_mapIndexedSurfacePatches.end()) + if(m_mapSurfaceMeshes.find(v3dRegPos) != m_mapSurfaceMeshes.end()) { - POLYVOX_SHARED_PTR ispCurrent = m_mapIndexedSurfacePatches[v3dRegPos]; - unsigned int uLodLevel = 0; //ispCurrent->m_vecLodRecords.size() - 1; + POLYVOX_SHARED_PTR meshCurrent = m_mapSurfaceMeshes[v3dRegPos]; + unsigned int uLodLevel = 0; //meshCurrent->m_vecLodRecords.size() - 1; if(m_bUseOpenGLVertexBufferObjects) { - renderRegionVertexBufferObject(m_mapOpenGLSurfacePatches[v3dRegPos], uLodLevel); + renderRegionVertexBufferObject(m_mapOpenGLSurfaceMeshes[v3dRegPos], uLodLevel); } else { - renderRegionImmediateMode(*ispCurrent, uLodLevel); + renderRegionImmediateMode(*meshCurrent, uLodLevel); } } } diff --git a/examples/OpenGL/OpenGLWidget.h b/examples/OpenGL/OpenGLWidget.h index cd365408..c6131b68 100644 --- a/examples/OpenGL/OpenGLWidget.h +++ b/examples/OpenGL/OpenGLWidget.h @@ -30,7 +30,7 @@ freely, subject to the following restrictions: #include #include "Volume.h" -#include "IndexedSurfacePatch.h" +#include "SurfaceMesh.h" #include "PolyVoxImpl/Utility.h" #include "OpenGLImmediateModeSupport.h" @@ -72,8 +72,8 @@ class OpenGLWidget : public QGLWidget PolyVox::Volume* m_volData; //Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region - std::map m_mapOpenGLSurfacePatches; - std::map > m_mapIndexedSurfacePatches; + std::map m_mapOpenGLSurfaceMeshes; + std::map > m_mapSurfaceMeshes; unsigned int m_uRegionSideLength; unsigned int m_uVolumeWidthInRegions; diff --git a/examples/OpenGL/main.cpp b/examples/OpenGL/main.cpp index 26de5bf0..8538a395 100644 --- a/examples/OpenGL/main.cpp +++ b/examples/OpenGL/main.cpp @@ -23,7 +23,7 @@ freely, subject to the following restrictions: #include "Log.h" #include "Volume.h" -#include "IndexedSurfacePatch.h" +#include "SurfaceMesh.h" #include "PolyVoxImpl/Utility.h" #include "OpenGLImmediateModeSupport.h" diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index e5689a94..9791e00a 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -5,7 +5,7 @@ PROJECT(PolyVoxCore) #Projects source files SET(CORE_SRC_FILES source/GradientEstimators.cpp - source/IndexedSurfacePatch.cpp + source/SurfaceMesh.cpp source/Log.cpp source/Mesh.cpp source/MeshEdge.cpp @@ -20,7 +20,7 @@ SET(CORE_SRC_FILES #Projects headers files SET(CORE_INC_FILES include/GradientEstimators.inl - include/IndexedSurfacePatch.h + include/SurfaceMesh.h include/Log.h include/Mesh.h include/MeshEdge.h diff --git a/library/PolyVoxCore/include/GradientEstimators.h b/library/PolyVoxCore/include/GradientEstimators.h index 975fb3bd..5df0de0e 100644 --- a/library/PolyVoxCore/include/GradientEstimators.h +++ b/library/PolyVoxCore/include/GradientEstimators.h @@ -55,7 +55,7 @@ namespace PolyVox template Vector3DFloat computeSmoothSobelGradient(VolumeSampler& volIter); - POLYVOXCORE_API void computeNormalsForVertices(Volume* volumeData, IndexedSurfacePatch& isp, NormalGenerationMethod normalGenerationMethod); + POLYVOXCORE_API void computeNormalsForVertices(Volume* volumeData, SurfaceMesh& mesh, NormalGenerationMethod normalGenerationMethod); POLYVOXCORE_API Vector3DFloat computeNormal(Volume* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod); } diff --git a/library/PolyVoxCore/include/Mesh.h b/library/PolyVoxCore/include/Mesh.h index 392fbce3..5e29fd6c 100644 --- a/library/PolyVoxCore/include/Mesh.h +++ b/library/PolyVoxCore/include/Mesh.h @@ -40,8 +40,8 @@ namespace PolyVox { public: - void buildFromISP(IndexedSurfacePatch* pIsp); - void fillISP(IndexedSurfacePatch* pIsp); + void buildFromMesh(SurfaceMesh* pMesh); + void fillMesh(SurfaceMesh* pMesh); void matchEdgePairs(void); void computeEdgeCosts(void); diff --git a/library/PolyVoxCore/include/MeshVertex.h b/library/PolyVoxCore/include/MeshVertex.h index 914751fe..9cbd26f1 100644 --- a/library/PolyVoxCore/include/MeshVertex.h +++ b/library/PolyVoxCore/include/MeshVertex.h @@ -43,7 +43,7 @@ namespace PolyVox //MeshEdge* m_pEdge; //std::set m_faces; //std::set m_edges; //Edges which have this vertex as the src - long int m_index; //Bit wasteful to store this the whle time, as it's only used when converting to ISPs? + long int m_index; //Bit wasteful to store this the whle time, as it's only used when converting to Meshs? bool isSane(void); }; diff --git a/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h b/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h index 2e450c6b..5d558b77 100644 --- a/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h +++ b/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h @@ -46,7 +46,7 @@ namespace PolyVox class MeshVertex; //--------------------------------- - class IndexedSurfacePatch; + class SurfaceMesh; class Region; class SurfaceVertex; class SurfaceExtractor; diff --git a/library/PolyVoxCore/include/SurfaceExtractor.h b/library/PolyVoxCore/include/SurfaceExtractor.h index 93fc4080..06d02641 100644 --- a/library/PolyVoxCore/include/SurfaceExtractor.h +++ b/library/PolyVoxCore/include/SurfaceExtractor.h @@ -45,7 +45,7 @@ namespace PolyVox void setLodLevel(uint8_t uLodLevel); - POLYVOX_SHARED_PTR extractSurfaceForRegion(Region region); + POLYVOX_SHARED_PTR extractSurfaceForRegion(Region region); private: //Extract the surface for a particular LOD level @@ -106,7 +106,7 @@ namespace PolyVox uint32_t m_uNoOfOccupiedCells; //The surface patch we are currently filling. - IndexedSurfacePatch* m_ispCurrent; + SurfaceMesh* m_meshCurrent; //Information about the region we are currently processing Region m_regInputCropped; diff --git a/library/PolyVoxCore/include/IndexedSurfacePatch.h b/library/PolyVoxCore/include/SurfaceMesh.h similarity index 88% rename from library/PolyVoxCore/include/IndexedSurfacePatch.h rename to library/PolyVoxCore/include/SurfaceMesh.h index 03b32673..9087e8ea 100644 --- a/library/PolyVoxCore/include/IndexedSurfacePatch.h +++ b/library/PolyVoxCore/include/SurfaceMesh.h @@ -23,8 +23,8 @@ freely, subject to the following restrictions: *******************************************************************************/ #pragma endregion -#ifndef __PolyVox_IndexedSurfacePatch_H__ -#define __PolyVox_IndexedSurfacePatch_H__ +#ifndef __PolyVox_SurfaceMesh_H__ +#define __PolyVox_SurfaceMesh_H__ #include #include @@ -45,11 +45,11 @@ namespace PolyVox int endIndex; //Let's put it just past the end STL style }; - class POLYVOXCORE_API IndexedSurfacePatch + class POLYVOXCORE_API SurfaceMesh { public: - IndexedSurfacePatch(); - ~IndexedSurfacePatch(); + SurfaceMesh(); + ~SurfaceMesh(); const std::vector& getIndices(void) const; uint32_t getNoOfIndices(void) const; @@ -67,7 +67,7 @@ namespace PolyVox void smoothPositions(float fAmount, bool bIncludeGeometryEdgeVertices = false); void sumNearbyNormals(bool bNormaliseResult = true); - POLYVOX_SHARED_PTR extractSubset(std::set setMaterials); + POLYVOX_SHARED_PTR extractSubset(std::set setMaterials); void generateAveragedFaceNormals(bool bNormalise, bool bIncludeEdgeVertices = false); @@ -110,4 +110,4 @@ namespace PolyVox }; } -#endif /* __IndexedSurfacePatch_H__ */ +#endif /* __SurfaceMesh_H__ */ diff --git a/library/PolyVoxCore/include/Volume.h b/library/PolyVoxCore/include/Volume.h index a57d64c7..70140f0f 100644 --- a/library/PolyVoxCore/include/Volume.h +++ b/library/PolyVoxCore/include/Volume.h @@ -46,7 +46,7 @@ namespace PolyVox /// by a three dimensional (x,y,z) coordinate, rather than the two dimensional (x,y) /// coordinate which is used to identify an element (pixel) in a normal image. Within /// PolyVox, the Volume class is used to store and manipulate our data before we extract - /// our SurfacePatch's from it. + /// our SurfaceMeshs from it. /// /// Data Representaion - feel free to skip /// If stored carelessly, volume data can take up a huge amount of memory. For example, a diff --git a/library/PolyVoxCore/source/GradientEstimators.cpp b/library/PolyVoxCore/source/GradientEstimators.cpp index d3e0fa0d..54eb19f3 100644 --- a/library/PolyVoxCore/source/GradientEstimators.cpp +++ b/library/PolyVoxCore/source/GradientEstimators.cpp @@ -22,7 +22,7 @@ freely, subject to the following restrictions: *******************************************************************************/ #include "GradientEstimators.h" -#include "IndexedSurfacePatch.h" +#include "SurfaceMesh.h" #include "SurfaceVertex.h" #include "PolyVoxImpl/TypeDef.h" @@ -30,13 +30,13 @@ using namespace std; namespace PolyVox { - void computeNormalsForVertices(Volume* volumeData, IndexedSurfacePatch& isp, NormalGenerationMethod normalGenerationMethod) + void computeNormalsForVertices(Volume* volumeData, SurfaceMesh& mesh, NormalGenerationMethod normalGenerationMethod) { - std::vector& vecVertices = isp.getRawVertexData(); + std::vector& vecVertices = mesh.getRawVertexData(); std::vector::iterator iterSurfaceVertex = vecVertices.begin(); while(iterSurfaceVertex != vecVertices.end()) { - const Vector3DFloat& v3dPos = iterSurfaceVertex->getPosition() + static_cast(isp.m_Region.getLowerCorner()); + const Vector3DFloat& v3dPos = iterSurfaceVertex->getPosition() + static_cast(mesh.m_Region.getLowerCorner()); const Vector3DInt16 v3dFloor = static_cast(v3dPos); VolumeSampler volIter(volumeData); diff --git a/library/PolyVoxCore/source/Mesh.cpp b/library/PolyVoxCore/source/Mesh.cpp index 49fccc63..6486f9a9 100644 --- a/library/PolyVoxCore/source/Mesh.cpp +++ b/library/PolyVoxCore/source/Mesh.cpp @@ -25,31 +25,31 @@ freely, subject to the following restrictions: #include "Mesh.h" -#include "IndexedSurfacePatch.h" +#include "SurfaceMesh.h" #include namespace PolyVox { - void Mesh::buildFromISP(IndexedSurfacePatch* pIsp) + void Mesh::buildFromMesh(SurfaceMesh* pMesh) { //First we copy the vertices across. //We also keep track of where each vertex went - std::vector< std::set::iterator > vertexMapper(pIsp->getNoOfVertices()); + std::vector< std::set::iterator > vertexMapper(pMesh->getNoOfVertices()); - for(int ct = 0; ct < pIsp->getNoOfVertices(); ct++) + for(int ct = 0; ct < pMesh->getNoOfVertices(); ct++) { MeshVertex* pMeshVertex = new MeshVertex; - pMeshVertex->m_vertexData = pIsp->m_vecVertices[ct]; + pMeshVertex->m_vertexData = pMesh->m_vecVertices[ct]; vertexMapper[ct] = m_vertices.insert(pMeshVertex).first; } //Next, we add each triangle to the mesh - for(int triCt = 0; triCt < pIsp->getNoOfIndices() / 3; triCt++) + for(int triCt = 0; triCt < pMesh->getNoOfIndices() / 3; triCt++) { - int index0 = pIsp->m_vecTriangleIndices[triCt * 3]; - int index1 = pIsp->m_vecTriangleIndices[triCt * 3 + 1]; - int index2 = pIsp->m_vecTriangleIndices[triCt * 3 + 2]; + int index0 = pMesh->m_vecTriangleIndices[triCt * 3]; + int index1 = pMesh->m_vecTriangleIndices[triCt * 3 + 1]; + int index2 = pMesh->m_vecTriangleIndices[triCt * 3 + 2]; MeshVertex* meshVertex0 = *(vertexMapper[index0]); MeshVertex* meshVertex1 = *(vertexMapper[index1]); @@ -188,14 +188,14 @@ namespace PolyVox } } - void Mesh::fillISP(IndexedSurfacePatch* pIsp) + void Mesh::fillMesh(SurfaceMesh* pMesh) { - pIsp->clear(); + pMesh->clear(); for(std::set::iterator vertItor = m_vertices.begin(); vertItor != m_vertices.end(); vertItor++) { MeshVertex* meshVertex = *vertItor; - meshVertex->m_index = pIsp->addVertex(meshVertex->m_vertexData); + meshVertex->m_index = pMesh->addVertex(meshVertex->m_vertexData); } for(std::set::iterator faceItor = m_faces.begin(); faceItor != m_faces.end(); faceItor++) @@ -205,14 +205,14 @@ namespace PolyVox MeshVertex* v1 = meshFace->m_pEdge->m_pNextEdge->m_pSrc; MeshVertex* v2 = meshFace->m_pEdge->m_pNextEdge->m_pNextEdge->m_pSrc; - pIsp->addTriangle(v0->m_index, v1->m_index, v2->m_index); + pMesh->addTriangle(v0->m_index, v1->m_index, v2->m_index); } - pIsp->m_vecLodRecords.clear(); + pMesh->m_vecLodRecords.clear(); LodRecord lodRecord; lodRecord.beginIndex = 0; - lodRecord.endIndex = pIsp->getNoOfIndices(); - pIsp->m_vecLodRecords.push_back(lodRecord); + lodRecord.endIndex = pMesh->getNoOfIndices(); + pMesh->m_vecLodRecords.push_back(lodRecord); } void Mesh::removeEdge(MeshEdge* pMeshEdge) diff --git a/library/PolyVoxCore/source/SurfaceExtractor.cpp b/library/PolyVoxCore/source/SurfaceExtractor.cpp index f20bbdc8..1c6b142d 100644 --- a/library/PolyVoxCore/source/SurfaceExtractor.cpp +++ b/library/PolyVoxCore/source/SurfaceExtractor.cpp @@ -23,7 +23,7 @@ freely, subject to the following restrictions: #include "SurfaceExtractor.h" -#include "IndexedSurfacePatch.h" +#include "SurfaceMesh.h" #include "PolyVoxImpl/MarchingCubesTables.h" #include "SurfaceVertex.h" @@ -49,7 +49,7 @@ namespace PolyVox m_uStepSize = 1 << uLodLevel; } - POLYVOX_SHARED_PTR SurfaceExtractor::extractSurfaceForRegion(Region region) + POLYVOX_SHARED_PTR SurfaceExtractor::extractSurfaceForRegion(Region region) { m_regInputUncropped = region; @@ -62,7 +62,7 @@ namespace PolyVox m_regInputCropped = region; m_regInputCropped.cropTo(m_regVolumeCropped); - m_ispCurrent = new IndexedSurfacePatch(); + m_meshCurrent = new SurfaceMesh(); m_uRegionWidth = m_regInputCropped.width(); m_uRegionHeight = m_regInputCropped.height(); @@ -111,15 +111,15 @@ namespace PolyVox delete[] m_pPreviousVertexIndicesZ; delete[] m_pCurrentVertexIndicesZ; - m_ispCurrent->m_Region = m_regInputUncropped; + m_meshCurrent->m_Region = m_regInputUncropped; - m_ispCurrent->m_vecLodRecords.clear(); + m_meshCurrent->m_vecLodRecords.clear(); LodRecord lodRecord; lodRecord.beginIndex = 0; - lodRecord.endIndex = m_ispCurrent->getNoOfIndices(); - m_ispCurrent->m_vecLodRecords.push_back(lodRecord); + lodRecord.endIndex = m_meshCurrent->getNoOfIndices(); + m_meshCurrent->m_vecLodRecords.push_back(lodRecord); - return POLYVOX_SHARED_PTR(m_ispCurrent); + return POLYVOX_SHARED_PTR(m_meshCurrent); } template @@ -636,7 +636,7 @@ namespace PolyVox surfaceVertex.setOnGeometryEdgePosY(isPosYEdge); surfaceVertex.setOnGeometryEdgeNegZ(isNegZEdge); surfaceVertex.setOnGeometryEdgePosZ(isPosZEdge); - uint32_t uLastVertexIndex = m_ispCurrent->addVertex(surfaceVertex); + uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); m_pCurrentVertexIndicesX[getIndex(uXVolSpace - m_regInputCropped.getLowerCorner().getX(),uYVolSpace - m_regInputCropped.getLowerCorner().getY())] = uLastVertexIndex; } if (edgeTable[iCubeIndex] & 8) @@ -654,7 +654,7 @@ namespace PolyVox surfaceVertex.setOnGeometryEdgePosY(isPosYEdge); surfaceVertex.setOnGeometryEdgeNegZ(isNegZEdge); surfaceVertex.setOnGeometryEdgePosZ(isPosZEdge); - uint32_t uLastVertexIndex = m_ispCurrent->addVertex(surfaceVertex); + uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); m_pCurrentVertexIndicesY[getIndex(uXVolSpace - m_regInputCropped.getLowerCorner().getX(),uYVolSpace - m_regInputCropped.getLowerCorner().getY())] = uLastVertexIndex; } if (edgeTable[iCubeIndex] & 256) @@ -672,7 +672,7 @@ namespace PolyVox surfaceVertex.setOnGeometryEdgePosY(isPosYEdge); surfaceVertex.setOnGeometryEdgeNegZ(isNegZEdge); surfaceVertex.setOnGeometryEdgePosZ(isPosZEdge); - uint32_t uLastVertexIndex = m_ispCurrent->addVertex(surfaceVertex); + uint32_t uLastVertexIndex = m_meshCurrent->addVertex(surfaceVertex); m_pCurrentVertexIndicesZ[getIndex(uXVolSpace - m_regInputCropped.getLowerCorner().getX(),uYVolSpace - m_regInputCropped.getLowerCorner().getY())] = uLastVertexIndex; } }//For each cell @@ -785,7 +785,7 @@ namespace PolyVox assert(ind0 < 1000000); assert(ind1 < 1000000); assert(ind2 < 1000000); - m_ispCurrent->addTriangle(ind0, ind1, ind2); + m_meshCurrent->addTriangle(ind0, ind1, ind2); } }//For each triangle }//For each cell diff --git a/library/PolyVoxCore/source/IndexedSurfacePatch.cpp b/library/PolyVoxCore/source/SurfaceMesh.cpp similarity index 89% rename from library/PolyVoxCore/source/IndexedSurfacePatch.cpp rename to library/PolyVoxCore/source/SurfaceMesh.cpp index e1caa13e..be5d1a8d 100644 --- a/library/PolyVoxCore/source/IndexedSurfacePatch.cpp +++ b/library/PolyVoxCore/source/SurfaceMesh.cpp @@ -23,7 +23,7 @@ freely, subject to the following restrictions: *******************************************************************************/ #pragma endregion -#include "IndexedSurfacePatch.h" +#include "SurfaceMesh.h" #include #include @@ -32,26 +32,26 @@ using namespace std; namespace PolyVox { - IndexedSurfacePatch::IndexedSurfacePatch() + SurfaceMesh::SurfaceMesh() { m_iTimeStamp = -1; } - IndexedSurfacePatch::~IndexedSurfacePatch() + SurfaceMesh::~SurfaceMesh() { } - const std::vector& IndexedSurfacePatch::getIndices(void) const + const std::vector& SurfaceMesh::getIndices(void) const { return m_vecTriangleIndices; } - uint32_t IndexedSurfacePatch::getNoOfIndices(void) const + uint32_t SurfaceMesh::getNoOfIndices(void) const { return m_vecTriangleIndices.size(); } - uint32_t IndexedSurfacePatch::getNoOfNonUniformTrianges(void) const + uint32_t SurfaceMesh::getNoOfNonUniformTrianges(void) const { uint32_t result = 0; for(uint32_t i = 0; i < m_vecTriangleIndices.size() - 2; i += 3) @@ -68,7 +68,7 @@ namespace PolyVox return result; } - uint32_t IndexedSurfacePatch::getNoOfUniformTrianges(void) const + uint32_t SurfaceMesh::getNoOfUniformTrianges(void) const { uint32_t result = 0; for(uint32_t i = 0; i < m_vecTriangleIndices.size() - 2; i += 3) @@ -82,22 +82,22 @@ namespace PolyVox return result; } - uint32_t IndexedSurfacePatch::getNoOfVertices(void) const + uint32_t SurfaceMesh::getNoOfVertices(void) const { return m_vecVertices.size(); } - std::vector& IndexedSurfacePatch::getRawVertexData(void) + std::vector& SurfaceMesh::getRawVertexData(void) { return m_vecVertices; } - const std::vector& IndexedSurfacePatch::getVertices(void) const + const std::vector& SurfaceMesh::getVertices(void) const { return m_vecVertices; } - void IndexedSurfacePatch::addTriangle(uint32_t index0, uint32_t index1, uint32_t index2) + void SurfaceMesh::addTriangle(uint32_t index0, uint32_t index1, uint32_t index2) { m_vecTriangleIndices.push_back(index0); m_vecTriangleIndices.push_back(index1); @@ -115,13 +115,13 @@ namespace PolyVox } } - uint32_t IndexedSurfacePatch::addVertex(const SurfaceVertex& vertex) + uint32_t SurfaceMesh::addVertex(const SurfaceVertex& vertex) { m_vecVertices.push_back(vertex); return m_vecVertices.size() - 1; } - void IndexedSurfacePatch::clear(void) + void SurfaceMesh::clear(void) { m_vecVertices.clear(); m_vecTriangleIndices.clear(); @@ -129,7 +129,7 @@ namespace PolyVox m_mapUsedMaterials.clear(); } - const bool IndexedSurfacePatch::isEmpty(void) const + const bool SurfaceMesh::isEmpty(void) const { return (getNoOfVertices() == 0) || (getNoOfIndices() == 0); } @@ -142,10 +142,10 @@ namespace PolyVox /// \param fAmount A factor controlling how much the vertices move by. Find a good /// value by experimentation, starting with something small such as 0.1f. /// \param bIncludeGeometryEdgeVertices Indicates whether vertices on the edge of an - /// IndexedSurfacePatch should be smoothed. This can cause dicontinuities between + /// SurfaceMesh should be smoothed. This can cause dicontinuities between /// neighbouring patches. //////////////////////////////////////////////////////////////////////////////// - void IndexedSurfacePatch::smoothPositions(float fAmount, bool bIncludeGeometryEdgeVertices) + void SurfaceMesh::smoothPositions(float fAmount, bool bIncludeGeometryEdgeVertices) { if(m_vecVertices.size() == 0) //FIXME - I don't think we should need this test, but I have seen crashes otherwise... { @@ -221,7 +221,7 @@ namespace PolyVox /// vertex. Usually, the resulting normals should be renormalised afterwards. /// Note: This function can cause lighting discontinuities accross region boundaries. //////////////////////////////////////////////////////////////////////////////// - void IndexedSurfacePatch::sumNearbyNormals(bool bNormaliseResult) + void SurfaceMesh::sumNearbyNormals(bool bNormaliseResult) { if(m_vecVertices.size() == 0) //FIXME - I don't think we should need this test, but I have seen crashes otherwise... { @@ -262,7 +262,7 @@ namespace PolyVox } } - void IndexedSurfacePatch::generateAveragedFaceNormals(bool bNormalise, bool bIncludeEdgeVertices) + void SurfaceMesh::generateAveragedFaceNormals(bool bNormalise, bool bIncludeEdgeVertices) { Vector3DFloat offset = static_cast(m_Region.getLowerCorner()); @@ -313,7 +313,7 @@ namespace PolyVox //This function looks at every vertex in the mesh and determines //how many of it's neighbours have the same material. - void IndexedSurfacePatch::countNoOfNeighboursUsingMaterial(void) + void SurfaceMesh::countNoOfNeighboursUsingMaterial(void) { //Find all the neighbouring vertices for each vertex std::vector< std::set > neighbouringVertices(m_vecVertices.size()); @@ -348,9 +348,9 @@ namespace PolyVox } } - POLYVOX_SHARED_PTR IndexedSurfacePatch::extractSubset(std::set setMaterials) + POLYVOX_SHARED_PTR SurfaceMesh::extractSubset(std::set setMaterials) { - POLYVOX_SHARED_PTR result(new IndexedSurfacePatch); + POLYVOX_SHARED_PTR result(new SurfaceMesh); if(m_vecVertices.size() == 0) //FIXME - I don't think we should need this test, but I have seen crashes otherwise... { @@ -413,7 +413,7 @@ namespace PolyVox return result; } - /*int IndexedSurfacePatch::countMaterialBoundary(void) + /*int SurfaceMesh::countMaterialBoundary(void) { int count = 0; for(int ct = 0; ct < m_vecVertices.size(); ct++) @@ -426,7 +426,7 @@ namespace PolyVox return count; } - void IndexedSurfacePatch::growMaterialBoundary(void) + void SurfaceMesh::growMaterialBoundary(void) { std::vector vecNewVertices = m_vecVertices; @@ -453,7 +453,7 @@ namespace PolyVox m_vecVertices = vecNewVertices; }*/ - void IndexedSurfacePatch::decimate(float fMinDotProductForCollapse) + void SurfaceMesh::decimate(float fMinDotProductForCollapse) { // We will need the information from this function to // determine when material boundary edges can collapse. @@ -475,7 +475,7 @@ namespace PolyVox } // Returns true if every bit which is set in 'a' is also set in 'b'. The reverse does not need to be true. - bool IndexedSurfacePatch::isSubset(std::bitset a, std::bitset b) + bool SurfaceMesh::isSubset(std::bitset a, std::bitset b) { bool result = true; @@ -494,7 +494,7 @@ namespace PolyVox return result; } - uint32_t IndexedSurfacePatch::performDecimationPass(float fMinDotProductForCollapse) + uint32_t SurfaceMesh::performDecimationPass(float fMinDotProductForCollapse) { // I'm using a vector of lists here, rather than a vector of sets, // because I don't believe that duplicaes should occur. But this @@ -783,7 +783,7 @@ namespace PolyVox return noOfEdgesCollapsed; } - int IndexedSurfacePatch::noOfDegenerateTris(void) + int SurfaceMesh::noOfDegenerateTris(void) { int count = 0; for(int triCt = 0; triCt < m_vecTriangleIndices.size();) @@ -803,7 +803,7 @@ namespace PolyVox return count; } - void IndexedSurfacePatch::removeDegenerateTris(void) + void SurfaceMesh::removeDegenerateTris(void) { int noOfNonDegenerate = 0; int targetCt = 0; diff --git a/library/PolyVoxUtil/source/VolumeChangeTracker.cpp b/library/PolyVoxUtil/source/VolumeChangeTracker.cpp index 2803122e..84e6ac97 100644 --- a/library/PolyVoxUtil/source/VolumeChangeTracker.cpp +++ b/library/PolyVoxUtil/source/VolumeChangeTracker.cpp @@ -26,7 +26,7 @@ freely, subject to the following restrictions: #include "VolumeChangeTracker.h" #include "GradientEstimators.h" -#include "IndexedSurfacePatch.h" +#include "SurfaceMesh.h" #include "PolyVoxImpl/MarchingCubesTables.h" #include "SurfaceVertex.h" #include "PolyVoxImpl/Utility.h"