From 1d3c60f34107a8786445f1bcb8f07ca727b8997d Mon Sep 17 00:00:00 2001 From: David Williams Date: Thu, 24 Apr 2008 19:06:41 +0000 Subject: [PATCH] Tidying code and removing warnings. --- CMakeLists.txt | 11 ++++++++--- include/IndexedSurfacePatch.h | 21 ++++++++++++--------- include/RegionGeometry.h | 3 --- include/SurfaceVertex.h | 1 - include/Vector.h | 3 +++ include/Vector.inl | 2 +- source/IndexedSurfacePatch.cpp | 33 ++++++++++++++++++++------------- source/PolyVoxSceneManager.cpp | 14 +++++++------- source/RegionGeometry.cpp | 15 --------------- 9 files changed, 51 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab514441..52bb107d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ SET(SRC_FILES source/IndexedSurfacePatch.cpp source/MarchingCubesTables.cpp source/PolyVoxSceneManager.cpp - source/RegionGeometry.cpp + source/RegionGeometry.cpp source/SurfaceVertex.cpp ) @@ -19,9 +19,9 @@ SET(INC_FILES include/IndexedSurfacePatch.h include/MarchingCubesTables.h include/PolyVoxForwardDeclarations.h - include/PolyVoxSceneManager.h + include/PolyVoxSceneManager.h include/RegionGeometry.h - include/SurfaceVertex.h + include/SurfaceVertex.h include/TypeDef.h include/Vector.h include/Vector.inl @@ -38,6 +38,8 @@ FIND_PACKAGE(Boost REQUIRED) # SET(BOOST_LIBRARIES boost_program_options boost_filesystem) #ENDIF(NOT WIN32) + + ADD_DEFINITIONS(-DPOLYVOX_EXPORT) #Export symbols in the .dll #Appends "_d" to the generated library when in debug mode @@ -55,6 +57,9 @@ INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include) ADD_LIBRARY(PolyVoxSceneManager SHARED ${SRC_FILES} ${INC_FILES}) TARGET_LINK_LIBRARIES(PolyVoxSceneManager) SET_TARGET_PROPERTIES(PolyVoxSceneManager PROPERTIES VERSION ${THERMITE_VERSION} SOVERSION ${THERMITE_VERSION_MAJOR}) +IF(WIN32) + SET_TARGET_PROPERTIES(PolyVoxSceneManager PROPERTIES COMPILE_FLAGS "/wd4251") #Disable warning on STL exports +ENDIF(WIN32) #Install INSTALL(TARGETS PolyVoxSceneManager diff --git a/include/IndexedSurfacePatch.h b/include/IndexedSurfacePatch.h index 3bc147ff..405f73ae 100644 --- a/include/IndexedSurfacePatch.h +++ b/include/IndexedSurfacePatch.h @@ -19,22 +19,24 @@ namespace PolyVox ~IndexedSurfacePatch(); void addTriangle(const SurfaceVertex& v0,const SurfaceVertex& v1,const SurfaceVertex& v2); - void fillVertexAndIndexData(std::vector& vecVertices, std::vector& vecIndices); + void fillVertexAndIndexData(std::vector& vecVertices, std::vector& vecIndices); + + const std::vector& getVertices(void) const; + std::vector& getVertices(void); //FIXME - non const version should be removed. + const std::vector& getIndices(void) const; - //private: - std::vector m_vecTriangleIndices; + private: + std::vector m_vecTriangleIndices; std::vector m_vecVertices; - static long int vertexIndices[POLYVOX_REGION_SIDE_LENGTH*2+1][POLYVOX_REGION_SIDE_LENGTH*2+1][POLYVOX_REGION_SIDE_LENGTH*2+1]; + static boost::int32_t vertexIndices[POLYVOX_REGION_SIDE_LENGTH*2+1][POLYVOX_REGION_SIDE_LENGTH*2+1][POLYVOX_REGION_SIDE_LENGTH*2+1]; static boost::int32_t vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH]; static boost::int32_t vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH]; static boost::int32_t vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH]; - static long int noOfVerticesSubmitted; - static long int noOfVerticesAccepted; - static long int noOfTrianglesSubmitted; - - long int getSizeInBytes(void); + static boost::int32_t noOfVerticesSubmitted; + static boost::int32_t noOfVerticesAccepted; + static boost::int32_t noOfTrianglesSubmitted; boost::int32_t getIndexFor(const Vector3DFloat& pos); void setIndexFor(const Vector3DFloat& pos, boost::int32_t newIndex); @@ -42,6 +44,7 @@ namespace PolyVox private: bool m_AllowDuplicateVertices; }; + } #endif /* __IndexedSurfacePatch_H__ */ diff --git a/include/RegionGeometry.h b/include/RegionGeometry.h index 073c3968..87f61e35 100644 --- a/include/RegionGeometry.h +++ b/include/RegionGeometry.h @@ -38,9 +38,6 @@ namespace PolyVox Vector3DInt32 m_v3dRegionPosition; IndexedSurfacePatch* m_patchSingleMaterial; IndexedSurfacePatch* m_patchMultiMaterial; - - long int getSizeInBytes(void); - }; } diff --git a/include/SurfaceVertex.h b/include/SurfaceVertex.h index 9b6bd21d..955d8702 100644 --- a/include/SurfaceVertex.h +++ b/include/SurfaceVertex.h @@ -56,7 +56,6 @@ namespace PolyVox - //bool operator < (const SurfaceVertexIterator& lhs, const SurfaceVertexIterator& rhs); } diff --git a/include/Vector.h b/include/Vector.h index 109c3251..2cef95a5 100644 --- a/include/Vector.h +++ b/include/Vector.h @@ -111,6 +111,9 @@ namespace PolyVox typedef Vector<3,double> Vector3DDouble; typedef Vector<3,boost::int32_t> Vector3DInt32; typedef Vector<3,boost::uint32_t> Vector3DUint32; + + + }//namespace Thermite #include "Vector.inl" diff --git a/include/Vector.inl b/include/Vector.inl index 3677b681..91d6605e 100644 --- a/include/Vector.inl +++ b/include/Vector.inl @@ -501,7 +501,7 @@ namespace PolyVox } for(boost::uint32_t ct = 0; ct < Size; ++ct) { - m_tElements[ct] /= length; + m_tElements[ct] /= static_cast(length); } } }//namespace Thermite diff --git a/source/IndexedSurfacePatch.cpp b/source/IndexedSurfacePatch.cpp index 534595ee..c2e07c93 100644 --- a/source/IndexedSurfacePatch.cpp +++ b/source/IndexedSurfacePatch.cpp @@ -4,10 +4,10 @@ using namespace boost; namespace PolyVox { - long int IndexedSurfacePatch::noOfVerticesSubmitted = 0; - long int IndexedSurfacePatch::noOfVerticesAccepted = 0; - long int IndexedSurfacePatch::noOfTrianglesSubmitted = 0; - long int IndexedSurfacePatch::vertexIndices[POLYVOX_REGION_SIDE_LENGTH*2+1][POLYVOX_REGION_SIDE_LENGTH*2+1][POLYVOX_REGION_SIDE_LENGTH*2+1]; + int32_t IndexedSurfacePatch::noOfVerticesSubmitted = 0; + int32_t IndexedSurfacePatch::noOfVerticesAccepted = 0; + int32_t IndexedSurfacePatch::noOfTrianglesSubmitted = 0; + int32_t IndexedSurfacePatch::vertexIndices[POLYVOX_REGION_SIDE_LENGTH*2+1][POLYVOX_REGION_SIDE_LENGTH*2+1][POLYVOX_REGION_SIDE_LENGTH*2+1]; int32_t IndexedSurfacePatch::vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH]; int32_t IndexedSurfacePatch::vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH]; int32_t IndexedSurfacePatch::vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH]; @@ -92,7 +92,7 @@ namespace PolyVox } } - void IndexedSurfacePatch::fillVertexAndIndexData(std::vector& vecVertices, std::vector& vecIndices) + void IndexedSurfacePatch::fillVertexAndIndexData(std::vector& vecVertices, std::vector& vecIndices) { vecVertices.resize(m_vecVertices.size()); std::copy(m_vecVertices.begin(), m_vecVertices.end(), vecVertices.begin()); @@ -107,14 +107,6 @@ namespace PolyVox }*/ } - long int IndexedSurfacePatch::getSizeInBytes(void) - { - long int size = sizeof(IndexedSurfacePatch); - size += m_vecVertices.capacity() * sizeof(m_vecVertices[0]); - size += m_vecTriangleIndices.capacity() * sizeof(m_vecTriangleIndices[0]); - return size; - } - boost::int32_t IndexedSurfacePatch::getIndexFor(const Vector3DFloat& pos) { float xIntPart; @@ -163,4 +155,19 @@ namespace PolyVox vertexIndicesZ[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)] = newIndex; } } + + const std::vector& IndexedSurfacePatch::getVertices(void) const + { + return m_vecVertices; + } + + std::vector& IndexedSurfacePatch::getVertices(void) + { + return m_vecVertices; + } + + const std::vector& IndexedSurfacePatch::getIndices(void) const + { + return m_vecTriangleIndices; + } } diff --git a/source/PolyVoxSceneManager.cpp b/source/PolyVoxSceneManager.cpp index 57524fed..2765b8ce 100644 --- a/source/PolyVoxSceneManager.cpp +++ b/source/PolyVoxSceneManager.cpp @@ -73,9 +73,9 @@ namespace PolyVox generateMeshDataForRegion(regionX,regionY,regionZ, regionGeometry.m_patchSingleMaterial, regionGeometry.m_patchMultiMaterial); - regionGeometry.m_bContainsSingleMaterialPatch = regionGeometry.m_patchSingleMaterial->m_vecVertices.size() > 0; - regionGeometry.m_bContainsMultiMaterialPatch = regionGeometry.m_patchMultiMaterial->m_vecVertices.size() > 0; - regionGeometry.m_bIsEmpty = ((regionGeometry.m_patchSingleMaterial->m_vecVertices.size() == 0) && (regionGeometry.m_patchMultiMaterial->m_vecTriangleIndices.size() == 0)); + regionGeometry.m_bContainsSingleMaterialPatch = regionGeometry.m_patchSingleMaterial->getVertices().size() > 0; + regionGeometry.m_bContainsMultiMaterialPatch = regionGeometry.m_patchMultiMaterial->getVertices().size() > 0; + regionGeometry.m_bIsEmpty = ((regionGeometry.m_patchSingleMaterial->getVertices().size() == 0) && (regionGeometry.m_patchMultiMaterial->getIndices().size() == 0)); listChangedRegionGeometry.push_back(regionGeometry); } @@ -515,16 +515,16 @@ namespace PolyVox //for(std::map::iterator iterPatch = surfacePatchMapResult.begin(); iterPatch != surfacePatchMapResult.end(); ++iterPatch) { - std::vector::iterator iterSurfaceVertex = singleMaterialPatch->m_vecVertices.begin(); - while(iterSurfaceVertex != singleMaterialPatch->m_vecVertices.end()) + std::vector::iterator iterSurfaceVertex = singleMaterialPatch->getVertices().begin(); + while(iterSurfaceVertex != singleMaterialPatch->getVertices().end()) { Vector3DFloat tempNormal = computeNormal(static_cast(iterSurfaceVertex->getPosition() + offset), CENTRAL_DIFFERENCE); const_cast(*iterSurfaceVertex).setNormal(tempNormal); ++iterSurfaceVertex; } - iterSurfaceVertex = multiMaterialPatch->m_vecVertices.begin(); - while(iterSurfaceVertex != multiMaterialPatch->m_vecVertices.end()) + iterSurfaceVertex = multiMaterialPatch->getVertices().begin(); + while(iterSurfaceVertex != multiMaterialPatch->getVertices().end()) { Vector3DFloat tempNormal = computeNormal(static_cast(iterSurfaceVertex->getPosition() + offset), CENTRAL_DIFFERENCE); const_cast(*iterSurfaceVertex).setNormal(tempNormal); diff --git a/source/RegionGeometry.cpp b/source/RegionGeometry.cpp index a7e507cc..b4659027 100644 --- a/source/RegionGeometry.cpp +++ b/source/RegionGeometry.cpp @@ -3,22 +3,7 @@ namespace PolyVox { - RegionGeometry::RegionGeometry() { } - - long int RegionGeometry::getSizeInBytes(void) - { - long int size = sizeof(RegionGeometry); - if(m_patchSingleMaterial) - { - size += m_patchSingleMaterial->getSizeInBytes(); - } - if(m_patchMultiMaterial) - { - size += m_patchMultiMaterial->getSizeInBytes(); - } - return size; - } } \ No newline at end of file