diff --git a/examples/OpenGL/OpenGLImmediateModeSupport.cpp b/examples/OpenGL/OpenGLImmediateModeSupport.cpp index d4ee57c3..09990abf 100644 --- a/examples/OpenGL/OpenGLImmediateModeSupport.cpp +++ b/examples/OpenGL/OpenGLImmediateModeSupport.cpp @@ -26,8 +26,6 @@ freely, subject to the following restrictions: #include "SurfaceMesh.h" -#include - using namespace PolyVox; using namespace std; diff --git a/examples/OpenGL/OpenGLWidget.cpp b/examples/OpenGL/OpenGLWidget.cpp index 75b270b0..21da4d10 100644 --- a/examples/OpenGL/OpenGLWidget.cpp +++ b/examples/OpenGL/OpenGLWidget.cpp @@ -89,7 +89,7 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) //Extract the surface for this region //extractSurface(m_volData, 0, PolyVox::Region(regLowerCorner, regUpperCorner), meshCurrent); - shared_ptr mesh(new SurfaceMesh); + polyvox_shared_ptr mesh(new SurfaceMesh); SurfaceExtractor surfaceExtractor(volData, PolyVox::Region(regLowerCorner, regUpperCorner), mesh.get()); surfaceExtractor.execute(); @@ -229,7 +229,7 @@ void OpenGLWidget::paintGL() Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ); if(m_mapSurfaceMeshes.find(v3dRegPos) != m_mapSurfaceMeshes.end()) { - shared_ptr meshCurrent = m_mapSurfaceMeshes[v3dRegPos]; + polyvox_shared_ptr meshCurrent = m_mapSurfaceMeshes[v3dRegPos]; unsigned int uLodLevel = 0; //meshCurrent->m_vecLodRecords.size() - 1; if(m_bUseOpenGLVertexBufferObjects) { diff --git a/examples/OpenGL/OpenGLWidget.h b/examples/OpenGL/OpenGLWidget.h index 5c85898a..9d05a01f 100644 --- a/examples/OpenGL/OpenGLWidget.h +++ b/examples/OpenGL/OpenGLWidget.h @@ -73,7 +73,7 @@ class OpenGLWidget : public QGLWidget //Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region std::map m_mapOpenGLSurfaceMeshes; - std::map > m_mapSurfaceMeshes; + std::map > m_mapSurfaceMeshes; unsigned int m_uRegionSideLength; unsigned int m_uVolumeWidthInRegions; diff --git a/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h b/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h index 9ce83584..13fbfad0 100644 --- a/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h +++ b/library/PolyVoxCore/include/PolyVoxForwardDeclarations.h @@ -26,7 +26,7 @@ freely, subject to the following restrictions: #ifndef __PolyVox_ForwardDeclarations_H__ #define __PolyVox_ForwardDeclarations_H__ -#include +#include "PolyVoxImpl/TypeDef.h" namespace PolyVox { diff --git a/library/PolyVoxCore/include/PolyVoxImpl/ArraySizesImpl.h b/library/PolyVoxCore/include/PolyVoxImpl/ArraySizesImpl.h index 47a0f085..688d1840 100644 --- a/library/PolyVoxCore/include/PolyVoxImpl/ArraySizesImpl.h +++ b/library/PolyVoxCore/include/PolyVoxImpl/ArraySizesImpl.h @@ -27,7 +27,7 @@ distribution. #define __PolyVox_ArraySizesImpl_H__ #pragma region Headers -#include +#include "typedef.h" #pragma endregion namespace PolyVox diff --git a/library/PolyVoxCore/include/PolyVoxImpl/TypeDef.h b/library/PolyVoxCore/include/PolyVoxImpl/TypeDef.h index e1db9f5f..51b8e23c 100644 --- a/library/PolyVoxCore/include/PolyVoxImpl/TypeDef.h +++ b/library/PolyVoxCore/include/PolyVoxImpl/TypeDef.h @@ -26,6 +26,7 @@ freely, subject to the following restrictions: #ifndef __PolyVox_TypeDef_H__ #define __PolyVox_TypeDef_H__ +//Definitions needed to make library functions accessable #ifdef _MSC_VER //We are using a Microsoft compiler. #ifdef POLYVOXCORE_EXPORT @@ -38,14 +39,26 @@ freely, subject to the following restrictions: #define POLYVOXCORE_API __attribute__ ((visibility("default"))) #endif -// To support non-C++0x compilers we use boost to replace the std::shared_ptr -// and potentially other C++0x features. To use this capability you will need -// to make sure you have boost installed on your system. -#ifdef _MSC_VER - #if _MSC_VER < 1600 // Older than VS 2010 - #include - #define std::shared_ptr boost::shared_ptr - #endif +//Check which compiler we are using and work around unsupported features as necessary. +#if defined(_MSC_VER) && (_MSC_VER < 1600) + //To support old Microsoft compilers we use boost to replace the std::shared_ptr + //and potentially other C++0x features. To use this capability you will need to + //make sure you have boost installed on your system. + #include "boost/smart_ptr.hpp" + #define polyvox_shared_ptr boost::shared_ptr + + //We also need to define these types as cstdint isn't available + typedef char int8_t; + typedef short int16_t; + typedef long int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned long uint32_t; +#else + //We have a decent compiler - use real C++0x features + #include + #include + #define polyvox_shared_ptr std::shared_ptr #endif #endif diff --git a/library/PolyVoxCore/include/PolyVoxImpl/Utility.h b/library/PolyVoxCore/include/PolyVoxImpl/Utility.h index 988b1f50..023ac0fb 100644 --- a/library/PolyVoxCore/include/PolyVoxImpl/Utility.h +++ b/library/PolyVoxCore/include/PolyVoxImpl/Utility.h @@ -29,7 +29,6 @@ freely, subject to the following restrictions: #include "TypeDef.h" #include -#include namespace PolyVox { diff --git a/library/PolyVoxCore/include/SurfaceMesh.h b/library/PolyVoxCore/include/SurfaceMesh.h index 58f54887..fc716731 100644 --- a/library/PolyVoxCore/include/SurfaceMesh.h +++ b/library/PolyVoxCore/include/SurfaceMesh.h @@ -66,7 +66,7 @@ namespace PolyVox void smoothPositions(float fAmount, bool bIncludeGeometryEdgeVertices = false); void sumNearbyNormals(bool bNormaliseResult = true); - std::shared_ptr extractSubset(std::set setMaterials); + polyvox_shared_ptr extractSubset(std::set setMaterials); void generateAveragedFaceNormals(bool bNormalise, bool bIncludeEdgeVertices = false); diff --git a/library/PolyVoxCore/include/Volume.h b/library/PolyVoxCore/include/Volume.h index 498f5f53..dd6dd34a 100644 --- a/library/PolyVoxCore/include/Volume.h +++ b/library/PolyVoxCore/include/Volume.h @@ -159,10 +159,10 @@ namespace PolyVox void tidyUpMemory(uint32_t uNoOfBlocksToProcess = (std::numeric_limits::max)()); private: - std::shared_ptr< Block > getHomogenousBlock(VoxelType tHomogenousValue); + polyvox_shared_ptr< Block > getHomogenousBlock(VoxelType tHomogenousValue); - std::shared_ptr< Block > m_pBorderBlock; - std::vector< std::shared_ptr< Block > > m_pBlocks; + polyvox_shared_ptr< Block > m_pBorderBlock; + std::vector< polyvox_shared_ptr< Block > > m_pBlocks; std::vector m_vecBlockIsPotentiallyHomogenous; //Note: We were once storing weak_ptr's in this map, so that the blocks would be deleted once they @@ -170,7 +170,7 @@ namespace PolyVox //shared. A call to shared_ptr::unique() from within setVoxel was not sufficient as weak_ptr's did //not contribute to the reference count. Instead we store shared_ptr's here, and check if they //are used by anyone else (i.e are non-unique) when we tidy the volume. - std::map > > m_pHomogenousBlock; + std::map > > m_pHomogenousBlock; uint32_t m_uNoOfBlocksInVolume; diff --git a/library/PolyVoxCore/include/Volume.inl b/library/PolyVoxCore/include/Volume.inl index 8a1f37f5..10adefed 100644 --- a/library/PolyVoxCore/include/Volume.inl +++ b/library/PolyVoxCore/include/Volume.inl @@ -121,7 +121,7 @@ namespace PolyVox } //Create the border block - std::shared_ptr< Block > pTempBlock(new Block(m_uBlockSideLength)); + polyvox_shared_ptr< Block > pTempBlock(new Block(m_uBlockSideLength)); pTempBlock->fill(VoxelType()); m_pBorderBlock = pTempBlock; @@ -253,7 +253,7 @@ namespace PolyVox const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower); const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); - const std::shared_ptr< Block< VoxelType > >& block = m_pBlocks + const polyvox_shared_ptr< Block< VoxelType > >& block = m_pBlocks [ blockX + blockY * m_uWidthInBlocks + @@ -316,7 +316,7 @@ namespace PolyVox blockY * m_uWidthInBlocks + blockZ * m_uWidthInBlocks * m_uHeightInBlocks; - std::shared_ptr< Block >& block = m_pBlocks[uBlockIndex]; + polyvox_shared_ptr< Block >& block = m_pBlocks[uBlockIndex]; //It's quite possible that the user might attempt to set a voxel to it's current value. //We test for this case firstly because it could help performance, but more importantly @@ -332,7 +332,7 @@ namespace PolyVox } else { - std::shared_ptr< Block > pNewBlock(new Block(*(block))); + polyvox_shared_ptr< Block > pNewBlock(new Block(*(block))); block = pNewBlock; m_vecBlockIsPotentiallyHomogenous[uBlockIndex] = false; block->setVoxelAt(xOffset,yOffset,zOffset, tValue); @@ -407,7 +407,7 @@ namespace PolyVox } //Identify and remove any homogeneous blocks which are not actually in use. - typename std::map > >::iterator iter = m_pHomogenousBlock.begin(); + typename std::map > >::iterator iter = m_pHomogenousBlock.begin(); while(iter != m_pHomogenousBlock.end()) { if(iter->second.unique()) @@ -424,13 +424,13 @@ namespace PolyVox #pragma region Private Implementation template - std::shared_ptr< Block > Volume::getHomogenousBlock(VoxelType tHomogenousValue) + polyvox_shared_ptr< Block > Volume::getHomogenousBlock(VoxelType tHomogenousValue) { - typename std::map > >::iterator iterResult = m_pHomogenousBlock.find(tHomogenousValue); + typename std::map > >::iterator iterResult = m_pHomogenousBlock.find(tHomogenousValue); if(iterResult == m_pHomogenousBlock.end()) { //Block block; - std::shared_ptr< Block > pHomogeneousBlock(new Block(m_uBlockSideLength)); + polyvox_shared_ptr< Block > pHomogeneousBlock(new Block(m_uBlockSideLength)); //block.m_pBlock = temp; //block.m_uReferenceCount++; pHomogeneousBlock->fill(tHomogenousValue); @@ -440,7 +440,7 @@ namespace PolyVox else { //iterResult->second.m_uReferenceCount++; - //std::shared_ptr< Block > result(iterResult->second); + //polyvox_shared_ptr< Block > result(iterResult->second); return iterResult->second; } } diff --git a/library/PolyVoxCore/include/VolumeSampler.inl b/library/PolyVoxCore/include/VolumeSampler.inl index 8f03c466..dafe2a20 100644 --- a/library/PolyVoxCore/include/VolumeSampler.inl +++ b/library/PolyVoxCore/include/VolumeSampler.inl @@ -165,7 +165,7 @@ namespace PolyVox const uint32_t uBlockIndexInVolume = uXBlock + uYBlock * mVolume->m_uWidthInBlocks + uZBlock * mVolume->m_uWidthInBlocks * mVolume->m_uHeightInBlocks; - const std::shared_ptr< Block >& currentBlock = mVolume->m_pBlocks[uBlockIndexInVolume]; + const polyvox_shared_ptr< Block >& currentBlock = mVolume->m_pBlocks[uBlockIndexInVolume]; mCurrentVoxel = currentBlock->m_tData + uVoxelIndexInBlock; } diff --git a/library/PolyVoxCore/source/SurfaceMesh.cpp b/library/PolyVoxCore/source/SurfaceMesh.cpp index 9899846c..1876f283 100644 --- a/library/PolyVoxCore/source/SurfaceMesh.cpp +++ b/library/PolyVoxCore/source/SurfaceMesh.cpp @@ -349,9 +349,9 @@ namespace PolyVox } } - shared_ptr SurfaceMesh::extractSubset(std::set setMaterials) + polyvox_shared_ptr SurfaceMesh::extractSubset(std::set setMaterials) { - shared_ptr result(new SurfaceMesh); + 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... { diff --git a/library/PolyVoxUtil/include/Serialization.h b/library/PolyVoxUtil/include/Serialization.h index 02a4a84f..2e60aac6 100644 --- a/library/PolyVoxUtil/include/Serialization.h +++ b/library/PolyVoxUtil/include/Serialization.h @@ -42,12 +42,12 @@ namespace PolyVox }; template - std::shared_ptr< Volume > loadVolumeRaw(std::istream& stream, VolumeSerializationProgressListener* progressListener = 0); + polyvox_shared_ptr< Volume > loadVolumeRaw(std::istream& stream, VolumeSerializationProgressListener* progressListener = 0); template void saveVolumeRaw(std::ostream& stream, Volume& volume, VolumeSerializationProgressListener* progressListener = 0); template - std::shared_ptr< Volume > loadVolumeRle(std::istream& stream, VolumeSerializationProgressListener* progressListener = 0); + polyvox_shared_ptr< Volume > loadVolumeRle(std::istream& stream, VolumeSerializationProgressListener* progressListener = 0); template void saveVolumeRle(std::ostream& stream, Volume& volume, VolumeSerializationProgressListener* progressListener = 0); } diff --git a/library/PolyVoxUtil/include/Serialization.inl b/library/PolyVoxUtil/include/Serialization.inl index ef09bce6..03fdd497 100644 --- a/library/PolyVoxUtil/include/Serialization.inl +++ b/library/PolyVoxUtil/include/Serialization.inl @@ -30,7 +30,7 @@ namespace PolyVox //Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller. //FIXME - think about pointer ownership issues. Or could return volume by value if the copy constructor is shallow template - std::shared_ptr< Volume > loadVolumeRaw(std::istream& stream, VolumeSerializationProgressListener* progressListener) + polyvox_shared_ptr< Volume > loadVolumeRaw(std::istream& stream, VolumeSerializationProgressListener* progressListener) { //Read volume dimensions uint8_t volumeWidthPower = 0; @@ -45,7 +45,7 @@ namespace PolyVox uint16_t volumeDepth = 0x0001 << volumeDepthPower; //FIXME - need to support non cubic volumes - std::shared_ptr< Volume > volume(new Volume(volumeWidth, volumeHeight, volumeDepth)); + polyvox_shared_ptr< Volume > volume(new Volume(volumeWidth, volumeHeight, volumeDepth)); //Read data for(uint16_t z = 0; z < volumeDepth; ++z) @@ -126,7 +126,7 @@ namespace PolyVox //Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller. //FIXME - think about pointer ownership issues. Or could return volume by value if the copy constructor is shallow template - std::shared_ptr< Volume > loadVolumeRle(std::istream& stream, VolumeSerializationProgressListener* progressListener) + polyvox_shared_ptr< Volume > loadVolumeRle(std::istream& stream, VolumeSerializationProgressListener* progressListener) { //Read volume dimensions uint8_t volumeWidthPower = 0; @@ -141,7 +141,7 @@ namespace PolyVox uint16_t volumeDepth = 0x0001 << volumeDepthPower; //FIXME - need to support non cubic volumes - std::shared_ptr< Volume > volume(new Volume(volumeWidth, volumeHeight, volumeDepth)); + polyvox_shared_ptr< Volume > volume(new Volume(volumeWidth, volumeHeight, volumeDepth)); //Read data bool firstTime = true;