diff --git a/CMakeLists.txt b/CMakeLists.txt index c5933caa..22c3fb3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ PROJECT(PolyVox) SET(SRC_FILES source/IndexedSurfacePatch.cpp source/MarchingCubesTables.cpp + source/Region.cpp source/RegionGeometry.cpp source/SurfaceExtractors.cpp source/SurfaceVertex.cpp @@ -26,6 +27,7 @@ SET(INC_FILES include/IndexedSurfacePatch.h include/MarchingCubesTables.h include/PolyVoxForwardDeclarations.h + include/Region.h include/RegionGeometry.h include/SurfaceExtractors.h include/SurfaceVertex.h diff --git a/include/BlockVolume.h b/include/BlockVolume.h index b964ca3b..27033530 100644 --- a/include/BlockVolume.h +++ b/include/BlockVolume.h @@ -49,8 +49,8 @@ namespace PolyVox VoxelType getVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos) const; VoxelType getVoxelAt(const Vector3DUint16& v3dPos) const; - bool containsPoint(Vector3DFloat pos, float boundary) const; - bool containsPoint(Vector3DInt32 pos, boost::uint16_t boundary) const; + bool containsPoint(const Vector3DFloat& pos, float boundary) const; + bool containsPoint(const Vector3DInt32& pos, boost::uint16_t boundary) const; VolumeIterator firstVoxel(void); void idle(boost::uint32_t uAmount); VolumeIterator lastVoxel(void); diff --git a/include/BlockVolume.inl b/include/BlockVolume.inl index 912b6a59..28226b8d 100644 --- a/include/BlockVolume.inl +++ b/include/BlockVolume.inl @@ -163,7 +163,7 @@ namespace PolyVox #pragma region Other template - bool BlockVolume::containsPoint(Vector3DFloat pos, float boundary) const + bool BlockVolume::containsPoint(const Vector3DFloat& pos, float boundary) const { return (pos.x() <= m_uSideLength - 1 - boundary) && (pos.y() <= m_uSideLength - 1 - boundary) @@ -174,7 +174,7 @@ namespace PolyVox } template - bool BlockVolume::containsPoint(Vector3DInt32 pos, boost::uint16_t boundary) const + bool BlockVolume::containsPoint(const Vector3DInt32& pos, boost::uint16_t boundary) const { return (pos.x() <= m_uSideLength - 1 - boundary) && (pos.y() <= m_uSideLength - 1 - boundary) diff --git a/include/PolyVoxForwardDeclarations.h b/include/PolyVoxForwardDeclarations.h index 427a2492..4a36b2cf 100644 --- a/include/PolyVoxForwardDeclarations.h +++ b/include/PolyVoxForwardDeclarations.h @@ -29,17 +29,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { template class Block; + + //---------- BlockVolume ---------- template class BlockVolume; - //Some handy typedefs typedef BlockVolume FloatBlockVolume; typedef BlockVolume UInt8BlockVolume; typedef BlockVolume UInt16BlockVolume; + //--------------------------------- + class IndexedSurfacePatch; class IntegrealVector3; template class LinearVolume; - class VolumeChangeTracker; + class Region; class RegionGeometry; class SurfaceVertex; + + //---------- Vector ---------- template class Vector; typedef Vector<3,float> Vector3DFloat; typedef Vector<3,double> Vector3DDouble; @@ -48,7 +53,10 @@ namespace PolyVox typedef Vector<3,boost::int16_t> Vector3DInt16; typedef Vector<3,boost::uint16_t> Vector3DUint16; typedef Vector<3,boost::int32_t> Vector3DInt32; - typedef Vector<3,boost::uint32_t> Vector3DUint32; + typedef Vector<3,boost::uint32_t> Vector3DUint32; + //---------------------------- + + class VolumeChangeTracker; template class VolumeIterator; } diff --git a/include/Region.h b/include/Region.h new file mode 100644 index 00000000..6f391172 --- /dev/null +++ b/include/Region.h @@ -0,0 +1,52 @@ +#pragma region License +/****************************************************************************** +This file is part of the PolyVox library +Copyright (C) 2006 David Williams + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +******************************************************************************/ +#pragma endregion + +#ifndef __PolyVox_Region_H__ +#define __PolyVox_Region_H__ + +#pragma region Headers +#include "Vector.h" +#pragma endregion + +namespace PolyVox +{ + class Region + { + public: + Region(); + Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner); + + const Vector3DInt32& getLowerCorner(void) const; + const Vector3DInt32& getUpperCorner(void) const; + + void setLowerCorner(const Vector3DInt32& v3dLowerCorner); + void setUpperCorner(const Vector3DInt32& v3dUpperCorner); + + bool containsPoint(const Vector3DFloat& pos, float boundary) const; + bool containsPoint(const Vector3DInt32& pos, boost::uint8_t boundary) const; + + private: + Vector3DInt32 m_v3dLowerCorner; + Vector3DInt32 m_v3dUpperCorner; + }; +} + +#endif diff --git a/source/Region.cpp b/source/Region.cpp new file mode 100644 index 00000000..a44f6762 --- /dev/null +++ b/source/Region.cpp @@ -0,0 +1,56 @@ +#include "Region.h" + +namespace PolyVox +{ + Region::Region() + :m_v3dLowerCorner(0,0,0) + ,m_v3dUpperCorner(0,0,0) + { + } + + Region::Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner) + :m_v3dLowerCorner(v3dLowerCorner) + ,m_v3dUpperCorner(v3dUpperCorner) + { + } + + const Vector3DInt32& Region::getLowerCorner(void) const + { + return m_v3dLowerCorner; + } + + const Vector3DInt32& Region::getUpperCorner(void) const + { + return m_v3dUpperCorner; + } + + void Region::setLowerCorner(const Vector3DInt32& v3dLowerCorner) + { + m_v3dLowerCorner = v3dLowerCorner; + } + + void Region::setUpperCorner(const Vector3DInt32& v3dUpperCorner) + { + m_v3dUpperCorner = v3dUpperCorner; + } + + bool Region::containsPoint(const Vector3DFloat& pos, float boundary) const + { + return (pos.x() <= m_v3dUpperCorner.x() - boundary) + && (pos.y() <= m_v3dUpperCorner.y() - boundary) + && (pos.z() <= m_v3dUpperCorner.z() - boundary) + && (pos.x() >= m_v3dLowerCorner.x() + boundary) + && (pos.y() >= m_v3dLowerCorner.y() + boundary) + && (pos.z() >= m_v3dLowerCorner.z() + boundary); + } + + bool Region::containsPoint(const Vector3DInt32& pos, boost::uint8_t boundary) const + { + return (pos.x() <= m_v3dUpperCorner.x() - boundary) + && (pos.y() <= m_v3dUpperCorner.y() - boundary) + && (pos.z() <= m_v3dUpperCorner.z() - boundary) + && (pos.x() >= m_v3dLowerCorner.x() + boundary) + && (pos.y() >= m_v3dLowerCorner.y() + boundary) + && (pos.z() >= m_v3dLowerCorner.z() + boundary); + } +} \ No newline at end of file diff --git a/source/VolumeChangeTracker.cpp b/source/VolumeChangeTracker.cpp index be529203..849163bd 100644 --- a/source/VolumeChangeTracker.cpp +++ b/source/VolumeChangeTracker.cpp @@ -250,24 +250,6 @@ namespace PolyVox m_normalGenerationMethod = method; } - /*bool VolumeChangeTracker::containsPoint(Vector3DFloat pos, float boundary) - { - return volumeData->containsPoint(pos, boundary); - } - - bool VolumeChangeTracker::containsPoint(Vector3DInt32 pos, uint16_t boundary) - { - return volumeData->containsPoint(pos, boundary); - }*/ - - /* - - void VolumeChangeTracker::setAxisVisible(bool visible) - { - if(m_axisNode) - m_axisNode->setVisible(visible); - }*/ - const BlockVolume* VolumeChangeTracker::getVolumeData(void) const { return volumeData;