From 2fbe4182591e21cbd3fb338c05eccc9e972b634a Mon Sep 17 00:00:00 2001 From: David Williams Date: Fri, 28 Sep 2012 18:38:44 +0200 Subject: [PATCH] Material/Density types are no longer exposed on voxels. This is because primitive types don't have them anyway. --- .../PolyVoxCore/include/PolyVoxCore/Density.h | 20 ++++------- .../include/PolyVoxCore/Material.h | 24 +++----------- .../include/PolyVoxCore/MaterialDensityPair.h | 33 +++++-------------- 3 files changed, 21 insertions(+), 56 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/Density.h b/library/PolyVoxCore/include/PolyVoxCore/Density.h index 1f9e2598..0ae3d82a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Density.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Density.h @@ -47,19 +47,13 @@ namespace PolyVox class Density { public: - //We expose DensityType and MaterialType in this way so that, when code is - //templatised on voxel type, it can determine the underlying storage type - //using code such as 'VoxelType::DensityType value = voxel.getDensity()' - //or 'VoxelType::MaterialType value = voxel.getMaterial()'. - typedef Type DensityType; - typedef int32_t MaterialType; //Shouldn't define this one... - /// Constructor Density() : m_uDensity(0) {} /// Copy constructor - Density(DensityType uDensity) : m_uDensity(uDensity) {} + Density(Type uDensity) : m_uDensity(uDensity) {} + // The LowPassFilter uses this to convert between normal and accumulated types. /// Copy constructor with cast template explicit Density(const Density& density) throw() { @@ -98,14 +92,14 @@ namespace PolyVox return *this; } - DensityType getDensity() const throw() { return m_uDensity; } - void setDensity(DensityType uDensity) { m_uDensity = uDensity; } + Type getDensity() const throw() { return m_uDensity; } + void setDensity(Type uDensity) { m_uDensity = uDensity; } - static DensityType getMaxDensity() throw() { return (std::numeric_limits::max)(); } - static DensityType getMinDensity() throw() { return (std::numeric_limits::min)(); } + static Type getMaxDensity() throw() { return (std::numeric_limits::max)(); } + static Type getMinDensity() throw() { return (std::numeric_limits::min)(); } private: - DensityType m_uDensity; + Type m_uDensity; }; template diff --git a/library/PolyVoxCore/include/PolyVoxCore/Material.h b/library/PolyVoxCore/include/PolyVoxCore/Material.h index 9bbb3bc8..5cc074cb 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Material.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Material.h @@ -34,14 +34,7 @@ namespace PolyVox { ///This class represents a voxel storing only a material. //////////////////////////////////////////////////////////////////////////////// - /// In order to perform a surface extraction on a LargeVolume, PolyVox needs the underlying - /// voxel type to provide both getDensity() and getMaterial() functions. The getDensity() - /// function is used to determine if a voxel is 'solid', and if it is then the getMaterial() - /// funtion is used to determine what material should be assigned to the resulting mesh. - /// - /// This class meets these requirements, although it only actually stores a material value. - /// For the getDensity() function it simply returns the smallest possible density if the - /// material is zero and the largest possible density if the material is not zero. + /// Detailed description... /// /// \sa Density, MaterialDensityPair //////////////////////////////////////////////////////////////////////////////// @@ -52,15 +45,8 @@ namespace PolyVox class Material { public: - //We expose DensityType and MaterialType in this way so that, when code is - //templatised on voxel type, it can determine the underlying storage type - //using code such as 'VoxelType::DensityType value = voxel.getDensity()' - //or 'VoxelType::MaterialType value = voxel.getMaterial()'. - typedef int32_t DensityType; - typedef Type MaterialType; - Material() : m_uMaterial(0) {} - Material(MaterialType uMaterial) : m_uMaterial(uMaterial) {} + Material(Type uMaterial) : m_uMaterial(uMaterial) {} bool operator==(const Material& rhs) const throw() { @@ -72,11 +58,11 @@ namespace PolyVox return !(*this == rhs); } - MaterialType getMaterial() const throw() { return m_uMaterial; } - void setMaterial(MaterialType uMaterial) { m_uMaterial = uMaterial; } + Type getMaterial() const throw() { return m_uMaterial; } + void setMaterial(Type uMaterial) { m_uMaterial = uMaterial; } private: - MaterialType m_uMaterial; + Type m_uMaterial; }; typedef Material Material8; diff --git a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h index 6ab9a563..8da28bfd 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h @@ -33,15 +33,7 @@ namespace PolyVox { /// This class represents a voxel storing only a density. //////////////////////////////////////////////////////////////////////////////// - /// In order to perform a surface extraction on a LargeVolume, PolyVox needs the underlying - /// voxel type to provide both getDensity() and getMaterial() functions. The getDensity() - /// function is used to determine if a voxel is 'solid', and if it is then the getMaterial() - /// funtion is used to determine what material should be assigned to the resulting mesh. - /// - /// This class meets these requirements, and does so by storing and returning both a material - /// and a density value. Via the template parameters it is possible to control how much - /// precision is given to each. For example, if you create a class with 8 bits of storage, - /// you might choose to allocate 6 bits for the density and 2 bits for the material. + /// Detailed description... /// /// \sa Density, Material //////////////////////////////////////////////////////////////////////////////// @@ -49,13 +41,6 @@ namespace PolyVox class MaterialDensityPair { public: - //We expose DensityType and MaterialType in this way so that, when code is - //templatised on voxel type, it can determine the underlying storage type - //using code such as 'VoxelType::DensityType value = voxel.getDensity()' - //or 'VoxelType::MaterialType value = voxel.getMaterial()'. - typedef Type DensityType; - typedef Type MaterialType; - MaterialDensityPair() : m_uMaterial(0), m_uDensity(0) {} MaterialDensityPair(Type uMaterial, Type uDensity) : m_uMaterial(uMaterial), m_uDensity(uDensity) {} @@ -87,18 +72,18 @@ namespace PolyVox return *this; } - DensityType getDensity() const throw() { return m_uDensity; } - MaterialType getMaterial() const throw() { return m_uMaterial; } + Type getDensity() const throw() { return m_uDensity; } + Type getMaterial() const throw() { return m_uMaterial; } - void setDensity(DensityType uDensity) { m_uDensity = uDensity; } - void setMaterial(MaterialType uMaterial) { m_uMaterial = uMaterial; } + void setDensity(Type uDensity) { m_uDensity = uDensity; } + void setMaterial(Type uMaterial) { m_uMaterial = uMaterial; } - static DensityType getMaxDensity() throw() { return (0x01 << NoOfDensityBits) - 1; } - static DensityType getMinDensity() throw() { return 0; } + static Type getMaxDensity() throw() { return (0x01 << NoOfDensityBits) - 1; } + static Type getMinDensity() throw() { return 0; } private: - MaterialType m_uMaterial : NoOfMaterialBits; - DensityType m_uDensity : NoOfDensityBits; + Type m_uMaterial : NoOfMaterialBits; + Type m_uDensity : NoOfDensityBits; }; template