diff --git a/examples/Basic/main.cpp b/examples/Basic/main.cpp index 5674948c..04f9c3b6 100644 --- a/examples/Basic/main.cpp +++ b/examples/Basic/main.cpp @@ -23,17 +23,14 @@ freely, subject to the following restrictions: #include "OpenGLWidget.h" -#include "PolyVoxCore/MaterialDensityPair.h" -#include "PolyVoxCore/CubicSurfaceExtractorWithNormals.h" -#include "PolyVoxCore/SurfaceMesh.h" -#include "PolyVoxCore/SimpleVolume.h" +#include "PolyVoxCore/SimpleInterface.h" #include //Use the PolyVox namespace using namespace PolyVox; -void createSphereInVolume(SimpleVolume& volData, float fRadius) +void createSphereInVolume(BasicVolume& volData, float fRadius) { //This vector hold the position of the center of the volume Vector3DFloat v3dVolCenter(volData.getWidth() / 2, volData.getHeight() / 2, volData.getDepth() / 2); @@ -54,10 +51,10 @@ void createSphereInVolume(SimpleVolume& volData, float fR if(fDistToCenter <= fRadius) { //Our new density value - uint8_t uDensity = MaterialDensityPair44::getMaxDensity(); + uint8_t uDensity = MaterialDensityPair88::getMaxDensity(); //Get the old voxel - MaterialDensityPair44 voxel = volData.getVoxelAt(x,y,z); + MaterialDensityPair88 voxel = volData.getVoxelAt(x,y,z); //Modify the density voxel.setDensity(uDensity); @@ -78,13 +75,14 @@ int main(int argc, char *argv[]) openGLWidget.show(); //Create an empty volume and then place a sphere in it - SimpleVolume volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63))); + BasicVolume volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63))); createSphereInVolume(volData, 30); //Extract the surface - SurfaceMesh mesh; - CubicSurfaceExtractorWithNormals surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); - surfaceExtractor.execute(); + BasicMesh mesh; + //CubicSurfaceExtractorWithNormals surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh); + //surfaceExtractor.execute(); + extractCubicMesh(volData, volData.getEnclosingRegion(), mesh); //Pass the surface to the OpenGL window openGLWidget.setSurfaceMeshToRender(mesh); diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index b5d63110..8a4574f8 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -10,6 +10,7 @@ SET(CORE_SRC_FILES source/Log.cpp source/MeshDecimator.cpp source/Region.cpp + source/SimpleInterface.cpp source/VertexTypes.cpp source/VoxelFilters.cpp ) @@ -23,6 +24,9 @@ SET(CORE_INC_FILES include/PolyVoxCore/ArraySizes.h include/PolyVoxCore/AStarPathfinder.h include/PolyVoxCore/AStarPathfinder.inl + include/PolyVoxCore/BaseVolume.h + include/PolyVoxCore/BaseVolume.inl + include/PolyVoxCore/BaseVolumeSampler.inl include/PolyVoxCore/ConstVolumeProxy.h include/PolyVoxCore/CubicSurfaceExtractor.h include/PolyVoxCore/CubicSurfaceExtractor.inl @@ -52,6 +56,7 @@ SET(CORE_INC_FILES include/PolyVoxCore/RaycastWithCallback.h include/PolyVoxCore/RaycastWithCallback.inl include/PolyVoxCore/Region.h + include/PolyVoxCore/SimpleInterface.h include/PolyVoxCore/SimpleVolume.h include/PolyVoxCore/SimpleVolume.inl include/PolyVoxCore/SimpleVolumeBlock.inl @@ -63,9 +68,6 @@ SET(CORE_INC_FILES include/PolyVoxCore/Vector.h include/PolyVoxCore/Vector.inl include/PolyVoxCore/VertexTypes.h - include/PolyVoxCore/Volume.h - include/PolyVoxCore/Volume.inl - include/PolyVoxCore/VolumeSampler.inl include/PolyVoxCore/VolumeResampler.h include/PolyVoxCore/VolumeResampler.inl include/PolyVoxCore/VoxelFilters.h diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.h b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h similarity index 93% rename from library/PolyVoxCore/include/PolyVoxCore/Volume.h rename to library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h index 3a3368b5..ad606409 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h @@ -21,8 +21,8 @@ freely, subject to the following restrictions: distribution. *******************************************************************************/ -#ifndef __PolyVox_Volume_H__ -#define __PolyVox_Volume_H__ +#ifndef __PolyVox_BaseVolume_H__ +#define __PolyVox_BaseVolume_H__ #include "PolyVoxCore/Log.h" #include "PolyVoxCore/Region.h" @@ -34,7 +34,7 @@ freely, subject to the following restrictions: namespace PolyVox { template - class Volume + class BaseVolume { public: #ifndef SWIG @@ -104,12 +104,12 @@ namespace PolyVox public: /// Constructor for creating a fixed size volume. - Volume + BaseVolume ( const Region& regValid ); /// Destructor - ~Volume(); + ~BaseVolume(); /// Gets the value used for voxels which are outside the volume VoxelType getBorderValue(void) const; @@ -153,7 +153,7 @@ namespace PolyVox }; } -#include "PolyVoxCore/Volume.inl" -#include "PolyVoxCore/VolumeSampler.inl" +#include "PolyVoxCore/BaseVolume.inl" +#include "PolyVoxCore/BaseVolumeSampler.inl" -#endif //__PolyVox_Volume_H__ +#endif //__PolyVox_BaseVolume_H__ diff --git a/library/PolyVoxCore/include/PolyVoxCore/Volume.inl b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl similarity index 85% rename from library/PolyVoxCore/include/PolyVoxCore/Volume.inl rename to library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl index 0db51e3a..c211edb9 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Volume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl @@ -24,7 +24,7 @@ freely, subject to the following restrictions: namespace PolyVox { template - Volume::Volume + BaseVolume::BaseVolume ( const Region& regValid ) @@ -36,7 +36,7 @@ namespace PolyVox /// Destroys the volume //////////////////////////////////////////////////////////////////////////////// template - Volume::~Volume() + BaseVolume::~BaseVolume() { } @@ -46,7 +46,7 @@ namespace PolyVox /// \return The value used for voxels outside of the volume //////////////////////////////////////////////////////////////////////////////// template - VoxelType Volume::getBorderValue(void) const + VoxelType BaseVolume::getBorderValue(void) const { assert(false); return VoxelType(); @@ -56,7 +56,7 @@ namespace PolyVox /// \return A Region representing the extent of the volume. //////////////////////////////////////////////////////////////////////////////// template - Region Volume::getEnclosingRegion(void) const + Region BaseVolume::getEnclosingRegion(void) const { return m_regValidRegion; } @@ -66,7 +66,7 @@ namespace PolyVox /// \sa getHeight(), getDepth() //////////////////////////////////////////////////////////////////////////////// template - int32_t Volume::getWidth(void) const + int32_t BaseVolume::getWidth(void) const { return m_regValidRegion.getUpperCorner().getX() - m_regValidRegion.getLowerCorner().getX() + 1; } @@ -76,7 +76,7 @@ namespace PolyVox /// \sa getWidth(), getDepth() //////////////////////////////////////////////////////////////////////////////// template - int32_t Volume::getHeight(void) const + int32_t BaseVolume::getHeight(void) const { return m_regValidRegion.getUpperCorner().getY() - m_regValidRegion.getLowerCorner().getY() + 1; } @@ -86,7 +86,7 @@ namespace PolyVox /// \sa getWidth(), getHeight() //////////////////////////////////////////////////////////////////////////////// template - int32_t Volume::getDepth(void) const + int32_t BaseVolume::getDepth(void) const { return m_regValidRegion.getUpperCorner().getZ() - m_regValidRegion.getLowerCorner().getZ() + 1; } @@ -97,7 +97,7 @@ namespace PolyVox /// \sa getLongestSideLength(), getDiagonalLength() //////////////////////////////////////////////////////////////////////////////// template - int32_t Volume::getShortestSideLength(void) const + int32_t BaseVolume::getShortestSideLength(void) const { return m_uShortestSideLength; } @@ -108,7 +108,7 @@ namespace PolyVox /// \sa getShortestSideLength(), getDiagonalLength() //////////////////////////////////////////////////////////////////////////////// template - int32_t Volume::getLongestSideLength(void) const + int32_t BaseVolume::getLongestSideLength(void) const { return m_uLongestSideLength; } @@ -120,7 +120,7 @@ namespace PolyVox /// \sa getShortestSideLength(), getLongestSideLength() //////////////////////////////////////////////////////////////////////////////// template - float Volume::getDiagonalLength(void) const + float BaseVolume::getDiagonalLength(void) const { return m_fDiagonalLength; } @@ -132,7 +132,7 @@ namespace PolyVox /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType Volume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const + VoxelType BaseVolume::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { assert(false); return VoxelType(); @@ -143,7 +143,7 @@ namespace PolyVox /// \return The voxel value //////////////////////////////////////////////////////////////////////////////// template - VoxelType Volume::getVoxelAt(const Vector3DInt32& v3dPos) const + VoxelType BaseVolume::getVoxelAt(const Vector3DInt32& v3dPos) const { assert(false); return VoxelType(); @@ -153,7 +153,7 @@ namespace PolyVox /// \param tBorder The value to use for voxels outside the volume. //////////////////////////////////////////////////////////////////////////////// template - void Volume::setBorderValue(const VoxelType& tBorder) + void BaseVolume::setBorderValue(const VoxelType& tBorder) { assert(false); } @@ -166,7 +166,7 @@ namespace PolyVox /// \return whether the requested position is inside the volume //////////////////////////////////////////////////////////////////////////////// template - bool Volume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) + bool BaseVolume::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) { assert(false); return false; @@ -178,7 +178,7 @@ namespace PolyVox /// \return whether the requested position is inside the volume //////////////////////////////////////////////////////////////////////////////// template - bool Volume::setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue) + bool BaseVolume::setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue) { assert(false); return false; @@ -188,7 +188,7 @@ namespace PolyVox /// Note: This function needs reviewing for accuracy... //////////////////////////////////////////////////////////////////////////////// template - uint32_t Volume::calculateSizeInBytes(void) + uint32_t BaseVolume::calculateSizeInBytes(void) { return getWidth() * getHeight() * getDepth() * sizeof(VoxelType); } diff --git a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl similarity index 64% rename from library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl rename to library/PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl index 57fdeb09..01fcca4a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/VolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl @@ -25,7 +25,7 @@ namespace PolyVox { template template - Volume::Sampler::Sampler(DerivedVolumeType* volume) + BaseVolume::Sampler::Sampler(DerivedVolumeType* volume) :mVolume(volume) ,mXPosInVolume(0) ,mYPosInVolume(0) @@ -35,41 +35,41 @@ namespace PolyVox template template - Volume::Sampler::~Sampler() + BaseVolume::Sampler::~Sampler() { } template template - int32_t Volume::Sampler::getPosX(void) const + int32_t BaseVolume::Sampler::getPosX(void) const { return mXPosInVolume; } template template - int32_t Volume::Sampler::getPosY(void) const + int32_t BaseVolume::Sampler::getPosY(void) const { return mYPosInVolume; } template template - int32_t Volume::Sampler::getPosZ(void) const + int32_t BaseVolume::Sampler::getPosZ(void) const { return mZPosInVolume; } template template - VoxelType Volume::Sampler::getVoxel(void) const + VoxelType BaseVolume::Sampler::getVoxel(void) const { return mVolume->getVoxelAt(mXPosInVolume, mYPosInVolume, mZPosInVolume); } template template - void Volume::Sampler::setPosition(const Vector3DInt32& v3dNewPos) + void BaseVolume::Sampler::setPosition(const Vector3DInt32& v3dNewPos) { mXPosInVolume = v3dNewPos.getX(); mYPosInVolume = v3dNewPos.getY(); @@ -78,7 +78,7 @@ namespace PolyVox template template - void Volume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) + void BaseVolume::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos) { mXPosInVolume = xPos; mYPosInVolume = yPos; @@ -87,112 +87,112 @@ namespace PolyVox template template - bool Volume::Sampler::setVoxel(VoxelType tValue) + bool BaseVolume::Sampler::setVoxel(VoxelType tValue) { return mVolume->setVoxelAt(mXPosInVolume, mYPosInVolume, mZPosInVolume, tValue); } template template - void Volume::Sampler::movePositiveX(void) + void BaseVolume::Sampler::movePositiveX(void) { mXPosInVolume++; } template template - void Volume::Sampler::movePositiveY(void) + void BaseVolume::Sampler::movePositiveY(void) { mYPosInVolume++; } template template - void Volume::Sampler::movePositiveZ(void) + void BaseVolume::Sampler::movePositiveZ(void) { mZPosInVolume++; } template template - void Volume::Sampler::moveNegativeX(void) + void BaseVolume::Sampler::moveNegativeX(void) { mXPosInVolume--; } template template - void Volume::Sampler::moveNegativeY(void) + void BaseVolume::Sampler::moveNegativeY(void) { mYPosInVolume--; } template template - void Volume::Sampler::moveNegativeZ(void) + void BaseVolume::Sampler::moveNegativeZ(void) { mZPosInVolume--; } template template - VoxelType Volume::Sampler::peekVoxel1nx1ny1nz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1nx1ny1nz(void) const { return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume - 1); } template template - VoxelType Volume::Sampler::peekVoxel1nx1ny0pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1nx1ny0pz(void) const { return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume ); } template template - VoxelType Volume::Sampler::peekVoxel1nx1ny1pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1nx1ny1pz(void) const { return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume - 1, mZPosInVolume + 1); } template template - VoxelType Volume::Sampler::peekVoxel1nx0py1nz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1nx0py1nz(void) const { return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume , mZPosInVolume - 1); } template template - VoxelType Volume::Sampler::peekVoxel1nx0py0pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1nx0py0pz(void) const { return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume , mZPosInVolume ); } template template - VoxelType Volume::Sampler::peekVoxel1nx0py1pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1nx0py1pz(void) const { return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume , mZPosInVolume + 1); } template template - VoxelType Volume::Sampler::peekVoxel1nx1py1nz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1nx1py1nz(void) const { return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume - 1); } template template - VoxelType Volume::Sampler::peekVoxel1nx1py0pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1nx1py0pz(void) const { return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume ); } template template - VoxelType Volume::Sampler::peekVoxel1nx1py1pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1nx1py1pz(void) const { return mVolume->getVoxelAt(mXPosInVolume - 1, mYPosInVolume + 1, mZPosInVolume + 1); } @@ -201,63 +201,63 @@ namespace PolyVox template template - VoxelType Volume::Sampler::peekVoxel0px1ny1nz(void) const + VoxelType BaseVolume::Sampler::peekVoxel0px1ny1nz(void) const { return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume - 1, mZPosInVolume - 1); } template template - VoxelType Volume::Sampler::peekVoxel0px1ny0pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel0px1ny0pz(void) const { return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume - 1, mZPosInVolume ); } template template - VoxelType Volume::Sampler::peekVoxel0px1ny1pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel0px1ny1pz(void) const { return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume - 1, mZPosInVolume + 1); } template template - VoxelType Volume::Sampler::peekVoxel0px0py1nz(void) const + VoxelType BaseVolume::Sampler::peekVoxel0px0py1nz(void) const { return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume , mZPosInVolume - 1); } template template - VoxelType Volume::Sampler::peekVoxel0px0py0pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel0px0py0pz(void) const { return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume , mZPosInVolume ); } template template - VoxelType Volume::Sampler::peekVoxel0px0py1pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel0px0py1pz(void) const { return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume , mZPosInVolume + 1); } template template - VoxelType Volume::Sampler::peekVoxel0px1py1nz(void) const + VoxelType BaseVolume::Sampler::peekVoxel0px1py1nz(void) const { return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume + 1, mZPosInVolume - 1); } template template - VoxelType Volume::Sampler::peekVoxel0px1py0pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel0px1py0pz(void) const { return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume + 1, mZPosInVolume ); } template template - VoxelType Volume::Sampler::peekVoxel0px1py1pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel0px1py1pz(void) const { return mVolume->getVoxelAt(mXPosInVolume , mYPosInVolume + 1, mZPosInVolume + 1); } @@ -266,63 +266,63 @@ namespace PolyVox template template - VoxelType Volume::Sampler::peekVoxel1px1ny1nz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1px1ny1nz(void) const { return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume - 1); } template template - VoxelType Volume::Sampler::peekVoxel1px1ny0pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1px1ny0pz(void) const { return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume ); } template template - VoxelType Volume::Sampler::peekVoxel1px1ny1pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1px1ny1pz(void) const { return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume - 1, mZPosInVolume + 1); } template template - VoxelType Volume::Sampler::peekVoxel1px0py1nz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1px0py1nz(void) const { return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume , mZPosInVolume - 1); } template template - VoxelType Volume::Sampler::peekVoxel1px0py0pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1px0py0pz(void) const { return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume , mZPosInVolume ); } template template - VoxelType Volume::Sampler::peekVoxel1px0py1pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1px0py1pz(void) const { return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume , mZPosInVolume + 1); } template template - VoxelType Volume::Sampler::peekVoxel1px1py1nz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1px1py1nz(void) const { return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume - 1); } template template - VoxelType Volume::Sampler::peekVoxel1px1py0pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1px1py0pz(void) const { return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume ); } template template - VoxelType Volume::Sampler::peekVoxel1px1py1pz(void) const + VoxelType BaseVolume::Sampler::peekVoxel1px1py1pz(void) const { return mVolume->getVoxelAt(mXPosInVolume + 1, mYPosInVolume + 1, mZPosInVolume + 1); } diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index ba6e5523..9399f669 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -24,11 +24,11 @@ freely, subject to the following restrictions: #ifndef __PolyVox_LargeVolume_H__ #define __PolyVox_LargeVolume_H__ +#include "PolyVoxCore/BaseVolume.h" #include "PolyVoxImpl/Block.h" #include "PolyVoxCore/Log.h" #include "PolyVoxCore/Region.h" #include "PolyVoxCore/Vector.h" -#include "PolyVoxCore/Volume.h" #include #include @@ -150,7 +150,7 @@ namespace PolyVox template class ConstVolumeProxy; template - class LargeVolume : public Volume + class LargeVolume : public BaseVolume { public: //There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared. @@ -161,9 +161,9 @@ namespace PolyVox //typedef Volume VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. //class Sampler : public VolumeOfVoxelType::template Sampler< LargeVolume > #if defined(_MSC_VER) - class Sampler : public Volume::Sampler< LargeVolume > //This line works on VS2010 + class Sampler : public BaseVolume::Sampler< LargeVolume > //This line works on VS2010 #else - class Sampler : public Volume::template Sampler< LargeVolume > //This line works on GCC + class Sampler : public BaseVolume::template Sampler< LargeVolume > //This line works on GCC #endif { public: diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index 721488e0..d5ae0004 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -39,7 +39,7 @@ namespace PolyVox polyvox_function&, const Region&)> dataOverflowHandler, uint16_t uBlockSideLength ) - :Volume(Region::MaxRegion) + :BaseVolume(Region::MaxRegion) { m_funcDataRequiredHandler = dataRequiredHandler; m_funcDataOverflowHandler = dataOverflowHandler; @@ -86,7 +86,7 @@ namespace PolyVox bool bPagingEnabled, uint16_t uBlockSideLength ) - :Volume(regValid) + :BaseVolume(regValid) { m_funcDataRequiredHandler = dataRequiredHandler; m_funcDataOverflowHandler = dataOverflowHandler; diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl index 86f9dcac..be063dc7 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolumeSampler.inl @@ -30,7 +30,7 @@ namespace PolyVox { template LargeVolume::Sampler::Sampler(LargeVolume* volume) - :Volume::template Sampler< LargeVolume >(volume) + :BaseVolume::template Sampler< LargeVolume >(volume) { } diff --git a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h index 03bff183..1bb3a31f 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h @@ -75,6 +75,7 @@ namespace PolyVox }; typedef MaterialDensityPair MaterialDensityPair44; + typedef MaterialDensityPair MaterialDensityPair88; } #endif \ No newline at end of file diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index f5106e7d..3bef1a8a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -24,10 +24,10 @@ freely, subject to the following restrictions: #ifndef __PolyVox_RawVolume_H__ #define __PolyVox_RawVolume_H__ +#include "PolyVoxCore/BaseVolume.h" #include "PolyVoxCore/Log.h" #include "PolyVoxCore/Region.h" #include "PolyVoxCore/Vector.h" -#include "PolyVoxCore/Volume.h" #include #include //For abort() @@ -38,7 +38,7 @@ freely, subject to the following restrictions: namespace PolyVox { template - class RawVolume : public Volume + class RawVolume : public BaseVolume { public: #ifndef SWIG @@ -50,9 +50,9 @@ namespace PolyVox //typedef Volume VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. //class Sampler : public VolumeOfVoxelType::template Sampler< RawVolume > #if defined(_MSC_VER) - class Sampler : public Volume::Sampler< RawVolume > //This line works on VS2010 + class Sampler : public BaseVolume::Sampler< RawVolume > //This line works on VS2010 #else - class Sampler : public Volume::template Sampler< RawVolume > //This line works on GCC + class Sampler : public BaseVolume::template Sampler< RawVolume > //This line works on GCC #endif { public: diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl index 93e41ca1..25265eff 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl @@ -36,7 +36,7 @@ namespace PolyVox ( const Region& regValid ) - :Volume(regValid) + :BaseVolume(regValid) { setBorderValue(VoxelType()); diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl index 6bc9891f..aede84fc 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl @@ -32,7 +32,7 @@ namespace PolyVox { template RawVolume::Sampler::Sampler(RawVolume* volume) - :Volume::template Sampler< RawVolume >(volume) + :BaseVolume::template Sampler< RawVolume >(volume) ,mCurrentVoxel(0) ,m_bIsCurrentPositionValidInX(false) ,m_bIsCurrentPositionValidInY(false) diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleInterface.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleInterface.h new file mode 100644 index 00000000..eb8123b2 --- /dev/null +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleInterface.h @@ -0,0 +1,52 @@ +/******************************************************************************* +Copyright (c) 2005-2009 David Williams + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*******************************************************************************/ + +#ifndef __PolyVox_SimpleInterface_H__ +#define __PolyVox_SimpleInterface_H__ + +//Available voxel types +#include "PolyVoxCore\Density.h" +#include "PolyVoxCore\Material.h" +#include "PolyVoxCore\MaterialDensityPair.h" + +//Available volumes +#include "PolyVoxCore\LargeVolume.h" +#include "PolyVoxCore\RawVolume.h" +#include "PolyVoxCore\SimpleVolume.h" + +//Available extractors +#include "PolyVoxCore\CubicSurfaceExtractorWithNormals.h" +#include "PolyVoxCore\SurfaceExtractor.h" + +namespace PolyVox +{ + //The PolyVox simple interface only exposes one voxel type and one volume type. But if you like you can + //adjust these typedefs and rebuild the library in order to modify which one volume and voxel is exposed. + typedef SimpleVolume BasicVolume; + typedef SurfaceMesh BasicMesh; + + void extractCubicMesh(BasicVolume& volume, const Region& region, BasicMesh& resultMesh); + +} + +#endif //__PolyVox_SimpleInterface_H__ diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h index 0a45eb0b..447f0f18 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h @@ -26,10 +26,10 @@ freely, subject to the following restrictions: #include "PolyVoxImpl/Utility.h" +#include "PolyVoxCore/BaseVolume.h" #include "PolyVoxCore/Log.h" #include "PolyVoxCore/Region.h" #include "PolyVoxCore/Vector.h" -#include "PolyVoxCore/Volume.h" #include #include //For abort() @@ -41,7 +41,7 @@ freely, subject to the following restrictions: namespace PolyVox { template - class SimpleVolume : public Volume + class SimpleVolume : public BaseVolume { public: #ifndef SWIG @@ -76,9 +76,9 @@ namespace PolyVox //typedef Volume VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. //class Sampler : public VolumeOfVoxelType::template Sampler< SimpleVolume > #if defined(_MSC_VER) - class Sampler : public Volume::Sampler< SimpleVolume > //This line works on VS2010 + class Sampler : public BaseVolume::Sampler< SimpleVolume > //This line works on VS2010 #else - class Sampler : public Volume::template Sampler< SimpleVolume > //This line works on GCC + class Sampler : public BaseVolume::template Sampler< SimpleVolume > //This line works on GCC #endif { public: diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl index 21f960a9..f91a17ab 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl @@ -58,7 +58,7 @@ namespace PolyVox const Region& regValid, uint16_t uBlockSideLength ) - :Volume(regValid) + :BaseVolume(regValid) { //Create a volume of the right size. resize(regValid,uBlockSideLength); diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl index 6b1bf725..091a18a8 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolumeSampler.inl @@ -30,7 +30,7 @@ namespace PolyVox { template SimpleVolume::Sampler::Sampler(SimpleVolume* volume) - :Volume::template Sampler< SimpleVolume >(volume) + :BaseVolume::template Sampler< SimpleVolume >(volume) { } diff --git a/library/PolyVoxCore/source/SimpleInterface.cpp b/library/PolyVoxCore/source/SimpleInterface.cpp new file mode 100644 index 00000000..2a863928 --- /dev/null +++ b/library/PolyVoxCore/source/SimpleInterface.cpp @@ -0,0 +1,33 @@ +/******************************************************************************* +Copyright (c) 2005-2009 David Williams + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +*******************************************************************************/ + +#include "PolyVoxCore\SimpleInterface.h" + +namespace PolyVox +{ + void extractCubicMesh(BasicVolume& volume, const Region& region, BasicMesh& resultMesh) + { + CubicSurfaceExtractorWithNormals surfaceExtractor(&volume, region, &resultMesh); + surfaceExtractor.execute(); + } +} diff --git a/tests/TestVolumeSubclass.cpp b/tests/TestVolumeSubclass.cpp index 4ed1e4aa..ef61cbf4 100644 --- a/tests/TestVolumeSubclass.cpp +++ b/tests/TestVolumeSubclass.cpp @@ -24,25 +24,35 @@ freely, subject to the following restrictions: #include "TestVolumeSubclass.h" #include "PolyVoxCore/Array.h" +#include "PolyVoxCore/BaseVolume.h" #include "PolyVoxCore/CubicSurfaceExtractor.h" #include "PolyVoxCore/Material.h" #include "PolyVoxCore/Vector.h" -#include "PolyVoxCore/Volume.h" #include using namespace PolyVox; template -class VolumeSubclass : public Volume +class VolumeSubclass : public BaseVolume { public: - typedef Volume VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn - class Sampler : public VolumeOfVoxelType::template Sampler< VolumeSubclass > + //There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared. + //There is a work around (see also See http://goo.gl/qu1wn) given below which appears to work on VS2010 and GCC, but + //which seems to cause internal compiler errors on VS2008 when building with the /Gm 'Enable Minimal Rebuild' compiler + //option. For now it seems best to 'fix' it with the preprocessor insstead, but maybe the workaround can be reinstated + //in the future + //typedef BaseVolume VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn + //class Sampler : public VolumeOfVoxelType::template Sampler< VolumeSubclass > + #if defined(_MSC_VER) + class Sampler : public BaseVolume::Sampler< VolumeSubclass > //This line works on VS2010 + #else + class Sampler : public BaseVolume::template Sampler< VolumeSubclass > //This line works on GCC + #endif { public: Sampler(VolumeSubclass* volume) - :Volume::template Sampler< VolumeSubclass >(volume) + :BaseVolume::template Sampler< VolumeSubclass >(volume) { this->mVolume = volume; } @@ -51,7 +61,7 @@ public: /// Constructor for creating a fixed size volume. VolumeSubclass(const Region& regValid) - :Volume(regValid) + :BaseVolume(regValid) { mVolumeData.resize(ArraySizes(this->getWidth())(this->getHeight())(this->getDepth())); }