From 7100e558f371b221d31e3d3a91af63fcf92e31ba Mon Sep 17 00:00:00 2001 From: David Williams Date: Tue, 10 Mar 2009 22:10:37 +0000 Subject: [PATCH] Removed LinearVolume class. --- library/CMakeLists.txt | 2 - library/include/PolyVoxCore/LinearVolume.h | 64 ----------- library/include/PolyVoxCore/LinearVolume.inl | 102 ------------------ .../PolyVoxCore/PolyVoxForwardDeclarations.h | 1 - .../include/PolyVoxUtil/VolumeChangeTracker.h | 5 +- .../PolyVoxUtil/VolumeChangeTracker.cpp | 3 +- 6 files changed, 5 insertions(+), 172 deletions(-) delete mode 100644 library/include/PolyVoxCore/LinearVolume.h delete mode 100644 library/include/PolyVoxCore/LinearVolume.inl diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 10b5e6bc..aea06539 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -32,8 +32,6 @@ SET(CORE_INC_FILES include/PolyVoxCore/Enums.h include/PolyVoxCore/GradientEstimators.h include/PolyVoxCore/GradientEstimators.inl - include/PolyVoxCore/LinearVolume.h - include/PolyVoxCore/LinearVolume.inl include/PolyVoxCore/IndexedSurfacePatch.h include/PolyVoxCore/MarchingCubesTables.h include/PolyVoxCore/PolyVoxForwardDeclarations.h diff --git a/library/include/PolyVoxCore/LinearVolume.h b/library/include/PolyVoxCore/LinearVolume.h deleted file mode 100644 index a4c9975b..00000000 --- a/library/include/PolyVoxCore/LinearVolume.h +++ /dev/null @@ -1,64 +0,0 @@ -#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_LinearVolume_H__ -#define __PolyVox_LinearVolume_H__ - -#pragma region Headers -#include "Constants.h" -#include "PolyVoxForwardDeclarations.h" -#include "TypeDef.h" - -#include "PolyVoxCStdInt.h" -#pragma endregion - -namespace PolyVox -{ - template - class LinearVolume - { - public: - LinearVolume(uint8 uSideLengthPower); - LinearVolume(const LinearVolume& rhs); - ~LinearVolume(); - - LinearVolume& operator=(const LinearVolume& rhs); - - //bool isHomogeneous(void); - - uint16 getSideLength(void); - - VoxelType getVoxelAt(const uint16 xPosition, const uint16 yPosition, const uint16 zPosition) const; - void setVoxelAt(const uint16 xPosition, const uint16 yPosition, const uint16 zPosition, const VoxelType value); - - //void fillWithValue(const VoxelType value); - - private: - uint32 getNoOfVoxels(void); - uint8 m_uSideLengthPower; - uint16 m_uSideLength; - VoxelType* m_tData; - }; -} - -#include "LinearVolume.inl" - -#endif diff --git a/library/include/PolyVoxCore/LinearVolume.inl b/library/include/PolyVoxCore/LinearVolume.inl deleted file mode 100644 index 3e3a9b54..00000000 --- a/library/include/PolyVoxCore/LinearVolume.inl +++ /dev/null @@ -1,102 +0,0 @@ -#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 - -#include - -namespace PolyVox -{ - - template - LinearVolume::LinearVolume(uint8 uSideLengthPower) - :m_tData(0) - { - //Check the block size is sensible. This corresponds to a side length of 256 voxels - assert(uSideLengthPower <= 8); - - //Compute the side length - m_uSideLengthPower = uSideLengthPower; - m_uSideLength = 0x01 << uSideLengthPower; - - //If this fails an exception will be thrown. Memory is not - //allocated and there is nothing else in this class to clean up - m_tData = new VoxelType[getNoOfVoxels()]; - } - - template - LinearVolume::LinearVolume(const LinearVolume& rhs) - { - *this = rhs; - } - - template - LinearVolume::~LinearVolume() - { - delete[] m_tData; - m_tData = 0; - } - - template - LinearVolume& LinearVolume::operator=(const LinearVolume& rhs) - { - if (this == &rhs) - { - return *this; - } - - memcpy(m_tData,rhs.m_tData,getNoOfVoxels()); - - return *this; - } - - template - VoxelType LinearVolume::getVoxelAt(const uint16 xPosition, const uint16 yPosition, const uint16 zPosition) const - { - return m_tData - [ - xPosition + - yPosition * m_uSideLength + - zPosition * m_uSideLength * m_uSideLength - ]; - } - - template - void LinearVolume::setVoxelAt(const uint16 xPosition, const uint16 yPosition, const uint16 zPosition, const VoxelType value) - { - m_tData - [ - xPosition + - yPosition * m_uSideLength + - zPosition * m_uSideLength * m_uSideLength - ] = value; - } - - template - uint16 LinearVolume::getSideLength(void) - { - return m_uSideLength; - } - - template - uint32 LinearVolume::getNoOfVoxels(void) - { - return m_uSideLength * m_uSideLength * m_uSideLength; - } -} diff --git a/library/include/PolyVoxCore/PolyVoxForwardDeclarations.h b/library/include/PolyVoxCore/PolyVoxForwardDeclarations.h index 575e90ad..9f1b61a7 100644 --- a/library/include/PolyVoxCore/PolyVoxForwardDeclarations.h +++ b/library/include/PolyVoxCore/PolyVoxForwardDeclarations.h @@ -38,7 +38,6 @@ namespace PolyVox class IndexedSurfacePatch; class IntegrealVector3; - template class LinearVolume; class Region; class SurfaceVertex; diff --git a/library/include/PolyVoxUtil/VolumeChangeTracker.h b/library/include/PolyVoxUtil/VolumeChangeTracker.h index 0a7afbc7..2a9f5c9f 100644 --- a/library/include/PolyVoxUtil/VolumeChangeTracker.h +++ b/library/include/PolyVoxUtil/VolumeChangeTracker.h @@ -63,7 +63,10 @@ namespace PolyVox bool m_bIsLocked; Region m_regLastLocked; BlockVolume* volumeData; - LinearVolume* volRegionLastModified; + + //It's not what the block class was designed for, but it + //provides a handy way of storing a 3D grid of values. + Block* volRegionLastModified; static int32 m_iCurrentTime; }; diff --git a/library/source/PolyVoxUtil/VolumeChangeTracker.cpp b/library/source/PolyVoxUtil/VolumeChangeTracker.cpp index 9b622773..6bb699d1 100644 --- a/library/source/PolyVoxUtil/VolumeChangeTracker.cpp +++ b/library/source/PolyVoxUtil/VolumeChangeTracker.cpp @@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "PolyVoxCore/GradientEstimators.h" #include "PolyVoxCore/IndexedSurfacePatch.h" -#include "PolyVoxCore/LinearVolume.h" #include "PolyVoxCore/MarchingCubesTables.h" #include "PolyVoxCore/SurfaceExtractors.h" #include "PolyVoxCore/SurfaceVertex.h" @@ -54,7 +53,7 @@ namespace PolyVox void VolumeChangeTracker::setVolumeData(BlockVolume* volumeDataToSet) { volumeData = volumeDataToSet; - volRegionLastModified = new LinearVolume(PolyVox::logBase2(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS)); + volRegionLastModified = new Block(PolyVox::logBase2(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS)); } void VolumeChangeTracker::setAllRegionsModified(void)