Tidying code and removing warnings.

This commit is contained in:
David Williams 2008-04-24 19:06:41 +00:00
parent 545aa92d14
commit 1d3c60f341
9 changed files with 51 additions and 52 deletions

View File

@ -5,7 +5,7 @@ SET(SRC_FILES
source/IndexedSurfacePatch.cpp source/IndexedSurfacePatch.cpp
source/MarchingCubesTables.cpp source/MarchingCubesTables.cpp
source/PolyVoxSceneManager.cpp source/PolyVoxSceneManager.cpp
source/RegionGeometry.cpp source/RegionGeometry.cpp
source/SurfaceVertex.cpp source/SurfaceVertex.cpp
) )
@ -19,9 +19,9 @@ SET(INC_FILES
include/IndexedSurfacePatch.h include/IndexedSurfacePatch.h
include/MarchingCubesTables.h include/MarchingCubesTables.h
include/PolyVoxForwardDeclarations.h include/PolyVoxForwardDeclarations.h
include/PolyVoxSceneManager.h include/PolyVoxSceneManager.h
include/RegionGeometry.h include/RegionGeometry.h
include/SurfaceVertex.h include/SurfaceVertex.h
include/TypeDef.h include/TypeDef.h
include/Vector.h include/Vector.h
include/Vector.inl include/Vector.inl
@ -38,6 +38,8 @@ FIND_PACKAGE(Boost REQUIRED)
# SET(BOOST_LIBRARIES boost_program_options boost_filesystem) # SET(BOOST_LIBRARIES boost_program_options boost_filesystem)
#ENDIF(NOT WIN32) #ENDIF(NOT WIN32)
ADD_DEFINITIONS(-DPOLYVOX_EXPORT) #Export symbols in the .dll ADD_DEFINITIONS(-DPOLYVOX_EXPORT) #Export symbols in the .dll
#Appends "_d" to the generated library when in debug mode #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}) ADD_LIBRARY(PolyVoxSceneManager SHARED ${SRC_FILES} ${INC_FILES})
TARGET_LINK_LIBRARIES(PolyVoxSceneManager) TARGET_LINK_LIBRARIES(PolyVoxSceneManager)
SET_TARGET_PROPERTIES(PolyVoxSceneManager PROPERTIES VERSION ${THERMITE_VERSION} SOVERSION ${THERMITE_VERSION_MAJOR}) 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
INSTALL(TARGETS PolyVoxSceneManager INSTALL(TARGETS PolyVoxSceneManager

View File

@ -19,22 +19,24 @@ namespace PolyVox
~IndexedSurfacePatch(); ~IndexedSurfacePatch();
void addTriangle(const SurfaceVertex& v0,const SurfaceVertex& v1,const SurfaceVertex& v2); void addTriangle(const SurfaceVertex& v0,const SurfaceVertex& v1,const SurfaceVertex& v2);
void fillVertexAndIndexData(std::vector<SurfaceVertex>& vecVertices, std::vector<boost::uint16_t>& vecIndices); void fillVertexAndIndexData(std::vector<SurfaceVertex>& vecVertices, std::vector<boost::uint32_t>& vecIndices);
//private: const std::vector<SurfaceVertex>& getVertices(void) const;
std::vector<boost::uint16_t> m_vecTriangleIndices; std::vector<SurfaceVertex>& getVertices(void); //FIXME - non const version should be removed.
const std::vector<boost::uint32_t>& getIndices(void) const;
private:
std::vector<boost::uint32_t> m_vecTriangleIndices;
std::vector<SurfaceVertex> m_vecVertices; std::vector<SurfaceVertex> 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 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 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 boost::int32_t vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH][POLYVOX_REGION_SIDE_LENGTH];
static long int noOfVerticesSubmitted; static boost::int32_t noOfVerticesSubmitted;
static long int noOfVerticesAccepted; static boost::int32_t noOfVerticesAccepted;
static long int noOfTrianglesSubmitted; static boost::int32_t noOfTrianglesSubmitted;
long int getSizeInBytes(void);
boost::int32_t getIndexFor(const Vector3DFloat& pos); boost::int32_t getIndexFor(const Vector3DFloat& pos);
void setIndexFor(const Vector3DFloat& pos, boost::int32_t newIndex); void setIndexFor(const Vector3DFloat& pos, boost::int32_t newIndex);
@ -42,6 +44,7 @@ namespace PolyVox
private: private:
bool m_AllowDuplicateVertices; bool m_AllowDuplicateVertices;
}; };
} }
#endif /* __IndexedSurfacePatch_H__ */ #endif /* __IndexedSurfacePatch_H__ */

View File

@ -38,9 +38,6 @@ namespace PolyVox
Vector3DInt32 m_v3dRegionPosition; Vector3DInt32 m_v3dRegionPosition;
IndexedSurfacePatch* m_patchSingleMaterial; IndexedSurfacePatch* m_patchSingleMaterial;
IndexedSurfacePatch* m_patchMultiMaterial; IndexedSurfacePatch* m_patchMultiMaterial;
long int getSizeInBytes(void);
}; };
} }

View File

@ -57,7 +57,6 @@ namespace PolyVox
//bool operator < (const SurfaceVertexIterator& lhs, const SurfaceVertexIterator& rhs); //bool operator < (const SurfaceVertexIterator& lhs, const SurfaceVertexIterator& rhs);
} }

View File

@ -111,6 +111,9 @@ namespace PolyVox
typedef Vector<3,double> Vector3DDouble; typedef Vector<3,double> Vector3DDouble;
typedef Vector<3,boost::int32_t> Vector3DInt32; typedef Vector<3,boost::int32_t> Vector3DInt32;
typedef Vector<3,boost::uint32_t> Vector3DUint32; typedef Vector<3,boost::uint32_t> Vector3DUint32;
}//namespace Thermite }//namespace Thermite
#include "Vector.inl" #include "Vector.inl"

View File

@ -501,7 +501,7 @@ namespace PolyVox
} }
for(boost::uint32_t ct = 0; ct < Size; ++ct) for(boost::uint32_t ct = 0; ct < Size; ++ct)
{ {
m_tElements[ct] /= length; m_tElements[ct] /= static_cast<Type>(length);
} }
} }
}//namespace Thermite }//namespace Thermite

View File

@ -4,10 +4,10 @@ using namespace boost;
namespace PolyVox namespace PolyVox
{ {
long int IndexedSurfacePatch::noOfVerticesSubmitted = 0; int32_t IndexedSurfacePatch::noOfVerticesSubmitted = 0;
long int IndexedSurfacePatch::noOfVerticesAccepted = 0; int32_t IndexedSurfacePatch::noOfVerticesAccepted = 0;
long int IndexedSurfacePatch::noOfTrianglesSubmitted = 0; int32_t 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::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::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::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]; 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<SurfaceVertex>& vecVertices, std::vector<uint16_t>& vecIndices) void IndexedSurfacePatch::fillVertexAndIndexData(std::vector<SurfaceVertex>& vecVertices, std::vector<uint32_t>& vecIndices)
{ {
vecVertices.resize(m_vecVertices.size()); vecVertices.resize(m_vecVertices.size());
std::copy(m_vecVertices.begin(), m_vecVertices.end(), vecVertices.begin()); 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) boost::int32_t IndexedSurfacePatch::getIndexFor(const Vector3DFloat& pos)
{ {
float xIntPart; float xIntPart;
@ -163,4 +155,19 @@ namespace PolyVox
vertexIndicesZ[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)] = newIndex; vertexIndicesZ[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)] = newIndex;
} }
} }
const std::vector<SurfaceVertex>& IndexedSurfacePatch::getVertices(void) const
{
return m_vecVertices;
}
std::vector<SurfaceVertex>& IndexedSurfacePatch::getVertices(void)
{
return m_vecVertices;
}
const std::vector<boost::uint32_t>& IndexedSurfacePatch::getIndices(void) const
{
return m_vecTriangleIndices;
}
} }

View File

@ -73,9 +73,9 @@ namespace PolyVox
generateMeshDataForRegion(regionX,regionY,regionZ, regionGeometry.m_patchSingleMaterial, regionGeometry.m_patchMultiMaterial); generateMeshDataForRegion(regionX,regionY,regionZ, regionGeometry.m_patchSingleMaterial, regionGeometry.m_patchMultiMaterial);
regionGeometry.m_bContainsSingleMaterialPatch = regionGeometry.m_patchSingleMaterial->m_vecVertices.size() > 0; regionGeometry.m_bContainsSingleMaterialPatch = regionGeometry.m_patchSingleMaterial->getVertices().size() > 0;
regionGeometry.m_bContainsMultiMaterialPatch = regionGeometry.m_patchMultiMaterial->m_vecVertices.size() > 0; regionGeometry.m_bContainsMultiMaterialPatch = regionGeometry.m_patchMultiMaterial->getVertices().size() > 0;
regionGeometry.m_bIsEmpty = ((regionGeometry.m_patchSingleMaterial->m_vecVertices.size() == 0) && (regionGeometry.m_patchMultiMaterial->m_vecTriangleIndices.size() == 0)); regionGeometry.m_bIsEmpty = ((regionGeometry.m_patchSingleMaterial->getVertices().size() == 0) && (regionGeometry.m_patchMultiMaterial->getIndices().size() == 0));
listChangedRegionGeometry.push_back(regionGeometry); listChangedRegionGeometry.push_back(regionGeometry);
} }
@ -515,16 +515,16 @@ namespace PolyVox
//for(std::map<uint8_t, IndexedSurfacePatch*>::iterator iterPatch = surfacePatchMapResult.begin(); iterPatch != surfacePatchMapResult.end(); ++iterPatch) //for(std::map<uint8_t, IndexedSurfacePatch*>::iterator iterPatch = surfacePatchMapResult.begin(); iterPatch != surfacePatchMapResult.end(); ++iterPatch)
{ {
std::vector<SurfaceVertex>::iterator iterSurfaceVertex = singleMaterialPatch->m_vecVertices.begin(); std::vector<SurfaceVertex>::iterator iterSurfaceVertex = singleMaterialPatch->getVertices().begin();
while(iterSurfaceVertex != singleMaterialPatch->m_vecVertices.end()) while(iterSurfaceVertex != singleMaterialPatch->getVertices().end())
{ {
Vector3DFloat tempNormal = computeNormal(static_cast<Vector3DFloat>(iterSurfaceVertex->getPosition() + offset), CENTRAL_DIFFERENCE); Vector3DFloat tempNormal = computeNormal(static_cast<Vector3DFloat>(iterSurfaceVertex->getPosition() + offset), CENTRAL_DIFFERENCE);
const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal); const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal);
++iterSurfaceVertex; ++iterSurfaceVertex;
} }
iterSurfaceVertex = multiMaterialPatch->m_vecVertices.begin(); iterSurfaceVertex = multiMaterialPatch->getVertices().begin();
while(iterSurfaceVertex != multiMaterialPatch->m_vecVertices.end()) while(iterSurfaceVertex != multiMaterialPatch->getVertices().end())
{ {
Vector3DFloat tempNormal = computeNormal(static_cast<Vector3DFloat>(iterSurfaceVertex->getPosition() + offset), CENTRAL_DIFFERENCE); Vector3DFloat tempNormal = computeNormal(static_cast<Vector3DFloat>(iterSurfaceVertex->getPosition() + offset), CENTRAL_DIFFERENCE);
const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal); const_cast<SurfaceVertex&>(*iterSurfaceVertex).setNormal(tempNormal);

View File

@ -3,22 +3,7 @@
namespace PolyVox namespace PolyVox
{ {
RegionGeometry::RegionGeometry() 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;
}
} }