Work on mimicing C++0x support using boost.

This commit is contained in:
David Williams 2009-03-30 19:32:34 +00:00
parent a4a8362dba
commit 329093abcf
5 changed files with 33 additions and 15 deletions

View File

@ -49,6 +49,7 @@ SET(IMPL_SRC_FILES
)
SET(IMPL_INC_FILES
include/PolyVoxCore/PolyVoxImpl/CPlusPlusZeroXSupport.h
include/PolyVoxCore/PolyVoxImpl/DecimatedSurfaceExtractor.h
include/PolyVoxCore/PolyVoxImpl/FastSurfaceExtractor.h
include/PolyVoxCore/PolyVoxImpl/ReferenceSurfaceExtractor.h
@ -101,7 +102,8 @@ INSTALL(TARGETS PolyVoxCore
COMPONENT library
)
INSTALL(FILES ${CORE_INC_FILES} DESTINATION include/PolyVoxCore COMPONENT development)
#Install the core header files, including the ones in the PolyVoxImpl subfolder.
INSTALL(DIRECTORY include/PolyVoxCore DESTINATION include COMPONENT development PATTERN "*.svn*" EXCLUDE)
#Util
#Build
@ -120,10 +122,11 @@ INSTALL(TARGETS PolyVoxUtil
COMPONENT library
)
INSTALL(FILES ${UTIL_INC_FILES} DESTINATION include/PolyVoxUtil COMPONENT development)
#Install the util header files.
INSTALL(DIRECTORY include/PolyVoxUtil DESTINATION include COMPONENT development PATTERN "*.svn*" EXCLUDE)
#Copy the boost files which we a re using to mimic C++0x
INSTALL(DIRECTORY include/boost DESTINATION include COMPONENT development)
INSTALL(DIRECTORY include/boost DESTINATION include COMPONENT development PATTERN "*.svn*" EXCLUDE)
#Set up PolyVoxConfig.cmake
if(WIN32)

View File

@ -0,0 +1,16 @@
#ifndef __PolyVox_CPlusPlusZeroXSupport_H__
#define __PolyVox_CPlusPlusZeroXSupport_H__
#ifdef C_PLUS_PLUS_ZERO_X_SUPPORTED
#include <shared_ptr> //Just a guess at what the standard name will be.
#include <weak_ptr> //These includes may need changing
#define POLYVOX_SHARED_PTR std::shared_ptr
#define POLYVOX_WEAK_PTR std::weak_ptr
#else
#include "boost/shared_ptr.hpp"
#include "boost/weak_ptr.hpp"
#define POLYVOX_SHARED_PTR boost::shared_ptr
#define POLYVOX_WEAK_PTR boost::weak_ptr
#endif
#endif

View File

@ -169,7 +169,7 @@ namespace PolyVox
bool equal = true;
for(uint32 ct = 0; ct < Size; ++ct)
{
if(m_tElements[ct] != rhs.getElement(ct))
if(m_tElements[ct] != rhs.m_tElements[ct])
{
equal = false;
break;

View File

@ -27,8 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "PolyVoxCStdInt.h"
#include "boost/shared_ptr.hpp"
#include "boost/weak_ptr.hpp"
#include "PolyVoxImpl/CPlusPlusZeroXSupport.h"
#include <map>
#pragma endregion
@ -39,7 +38,7 @@ namespace PolyVox
class Block
{
public:
boost::shared_ptr< BlockData<VoxelType> > m_pBlockData;
POLYVOX_SHARED_PTR< BlockData<VoxelType> > m_pBlockData;
VoxelType m_pHomogenousValue;
bool m_bIsShared;
bool m_bIsPotentiallySharable;
@ -72,10 +71,10 @@ namespace PolyVox
VolumeIterator<VoxelType> lastVoxel(void);
private:
boost::shared_ptr< BlockData<VoxelType> > getHomogenousBlockData(VoxelType tHomogenousValue) const;
POLYVOX_SHARED_PTR< BlockData<VoxelType> > getHomogenousBlockData(VoxelType tHomogenousValue) const;
Block<VoxelType>* m_pBlocks;
mutable std::map<VoxelType, boost::weak_ptr< BlockData<VoxelType> > > m_pHomogenousBlockData;
mutable std::map<VoxelType, POLYVOX_WEAK_PTR< BlockData<VoxelType> > > m_pHomogenousBlockData;
uint32 m_uNoOfBlocksInVolume;
uint16 m_uSideLengthInBlocks;

View File

@ -153,7 +153,7 @@ namespace PolyVox
const uint16 yOffset = uYPos - (blockY << m_uBlockSideLengthPower);
const uint16 zOffset = uZPos - (blockZ << m_uBlockSideLengthPower);
const boost::shared_ptr< BlockData<VoxelType> > block = m_pBlocks
const POLYVOX_SHARED_PTR< BlockData<VoxelType> > block = m_pBlocks
[
blockX +
blockY * m_uSideLengthInBlocks +
@ -197,7 +197,7 @@ namespace PolyVox
const VoxelType tHomogenousValue = m_pBlocks[uBlockIndex].m_pHomogenousValue;
if(tHomogenousValue != tValue)
{
boost::shared_ptr< BlockData<VoxelType> > temp(new BlockData<VoxelType>(m_uBlockSideLength));
POLYVOX_SHARED_PTR< BlockData<VoxelType> > temp(new BlockData<VoxelType>(m_uBlockSideLength));
m_pBlocks[uBlockIndex].m_pBlockData = temp;
m_pBlocks[uBlockIndex].m_bIsShared = false;
m_pBlocks[uBlockIndex].m_pBlockData->fill(tHomogenousValue);
@ -295,13 +295,13 @@ namespace PolyVox
#pragma region Private Implementation
template <typename VoxelType>
boost::shared_ptr< BlockData<VoxelType> > Volume<VoxelType>::getHomogenousBlockData(VoxelType tHomogenousValue) const
POLYVOX_SHARED_PTR< BlockData<VoxelType> > Volume<VoxelType>::getHomogenousBlockData(VoxelType tHomogenousValue) const
{
typename std::map<VoxelType, boost::weak_ptr< BlockData<VoxelType> > >::iterator iterResult = m_pHomogenousBlockData.find(tHomogenousValue);
typename std::map<VoxelType, POLYVOX_WEAK_PTR< BlockData<VoxelType> > >::iterator iterResult = m_pHomogenousBlockData.find(tHomogenousValue);
if(iterResult == m_pHomogenousBlockData.end())
{
Block<VoxelType> block;
boost::shared_ptr< BlockData<VoxelType> > temp(new BlockData<VoxelType>(m_uBlockSideLength));
POLYVOX_SHARED_PTR< BlockData<VoxelType> > temp(new BlockData<VoxelType>(m_uBlockSideLength));
block.m_pBlockData = temp;
//block.m_uReferenceCount++;
block.m_pBlockData->fill(tHomogenousValue);
@ -311,7 +311,7 @@ namespace PolyVox
else
{
//iterResult->second.m_uReferenceCount++;
boost::shared_ptr< BlockData<VoxelType> > result(iterResult->second);
POLYVOX_SHARED_PTR< BlockData<VoxelType> > result(iterResult->second);
return result;
}
}