diff --git a/library/PolyVoxCore/include/PolyVoxCore/Density.h b/library/PolyVoxCore/include/PolyVoxCore/Density.h index ccc97eac..90b66905 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Density.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Density.h @@ -101,16 +101,6 @@ namespace PolyVox // These are the predefined density types. The 8-bit types are sufficient for many purposes (including // most games) but 16-bit and float types do have uses particularly in medical/scientific visualisation. typedef Density Density8; - - template<> - class VoxelTypeTraits< Density8 > - { - public: - typedef uint8_t DensityType; - typedef uint8_t MaterialType; - static Density8::DensityType minDensity() { return std::numeric_limits::min(); } - static Density8::DensityType maxDensity() { return std::numeric_limits::max(); } - }; template class SurfaceExtractionController< Density > diff --git a/library/PolyVoxCore/include/PolyVoxCore/Material.h b/library/PolyVoxCore/include/PolyVoxCore/Material.h index 10f8fe34..cd22abb7 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Material.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Material.h @@ -94,25 +94,6 @@ namespace PolyVox typedef Material Material8; typedef Material Material16; - - template<> - class VoxelTypeTraits< Material8 > - { - public: - typedef uint8_t DensityType; - typedef uint8_t MaterialType; - static int minDensity() { assert(false); return 0; } - static int maxDensity() { assert(false); return 0; } - }; - - template<> - class VoxelTypeTraits< Material16 > - { - public: - typedef uint8_t DensityType; - static int minDensity() { assert(false); return 0; } - static int maxDensity() { assert(false); return 0; } - }; } #endif //__PolyVox_Material_H__ diff --git a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h index aea988bd..2e8e892f 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h @@ -140,26 +140,6 @@ namespace PolyVox typedef MaterialDensityPair MaterialDensityPair44; typedef MaterialDensityPair MaterialDensityPair88; - - template<> - class VoxelTypeTraits< MaterialDensityPair44 > - { - public: - typedef uint8_t DensityType; - typedef uint8_t MaterialType; - static MaterialDensityPair44::DensityType minDensity() { return 0; } - static MaterialDensityPair44::DensityType maxDensity() { return 15; } - }; - - template<> - class VoxelTypeTraits< MaterialDensityPair88 > - { - public: - typedef uint8_t DensityType; - typedef uint8_t MaterialType; - static MaterialDensityPair88::DensityType minDensity() { return 0; } - static MaterialDensityPair88::DensityType maxDensity() { return 255; } - }; } #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/SurfaceExtractor.h b/library/PolyVoxCore/include/PolyVoxCore/SurfaceExtractor.h index 17055686..36bf8927 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SurfaceExtractor.h @@ -33,16 +33,6 @@ freely, subject to the following restrictions: namespace PolyVox { - template<> - class VoxelTypeTraits< uint8_t > - { - public: - typedef uint8_t DensityType; - typedef uint8_t MaterialType; - static uint8_t minDensity() { return 0; } - static uint8_t maxDensity() { return 255; } - }; - template< typename VolumeType> class SurfaceExtractor { @@ -218,7 +208,8 @@ namespace PolyVox Region m_regSliceCurrent; //Our threshold value - typename VoxelTypeTraits::DensityType m_tThreshold; + //typename VoxelTypeTraits::DensityType m_tThreshold; + typename SurfaceExtractionController::DensityType m_tThreshold; //Used to convert arbitrary voxel types in densities and materials. SurfaceExtractionController m_controller; diff --git a/library/PolyVoxCore/include/PolyVoxCore/Voxel.h b/library/PolyVoxCore/include/PolyVoxCore/Voxel.h index 1ed0a405..e69de29b 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Voxel.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Voxel.h @@ -1,61 +0,0 @@ -/******************************************************************************* -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_Voxel_H__ -#define __PolyVox_Voxel_H__ - -#include "PolyVoxImpl/TypeDef.h" - -#include -#include - -namespace PolyVox -{ - // Various properties of the voxel types can be expressed via types traits, similar to the way std::numeric_limits is implemented. - // This has some advantages compared to storing the properties directly in the voxel class. For example, by using traits it is possible - // to also apply these properties to primative types which might be desirable (the Volume classes do accept primative types as template - // parameters). Also, properties such as minDensity() and maxDensity() would be difficult to represent though class members because they - // depend ont the type (float has a very different range from int8_t for example). - // - // The properties are currently exposed as constants because we need access to them at compile time. Ideally we would like to make them - // functions flagged with 'constexpr' as we could then make use of the max() and min() functions in std::numeric_limits, but this is not - // widely supported by compilers yet. We may change this in the future. - // - // Syntax for templatised traits classes: http://stackoverflow.com/q/8606302/849083 - template - class VoxelTypeTraits - { - public: - typedef uint8_t DensityType; - typedef uint8_t MaterialType; - - // These default implementations return an int32_t rather than void so that the result can be - // assigned to a variable for all voxel types (even those without density components). Calls - // to these functions should be protected by calls to hasDensity(), but the compiler still - // needs to ensure the assignment is compilable even if hasDensity() returns false. - static int32_t minDensity() { assert(false); return 0; } - static int32_t maxDensity() { assert(false); return 0; } - }; -} - -#endif //__PolyVox_Voxel_H__ diff --git a/tests/TestVoxels.cpp b/tests/TestVoxels.cpp index 28d93a01..b20e421f 100644 --- a/tests/TestVoxels.cpp +++ b/tests/TestVoxels.cpp @@ -34,48 +34,7 @@ freely, subject to the following restrictions: using namespace PolyVox; void TestVoxels::testVoxelTypeLimits() -{ - // It's worth testing these as they are not all explictily defined (e.g. Density8 is just a - // typedef of DensityI8), and in the future we might define then with bitwise magic or something. - - /*QCOMPARE(VoxelTypeTraits::minDensity(), Density8::DensityType(0)); - QCOMPARE(VoxelTypeTraits::maxDensity(), Density8::DensityType(255)); - - QCOMPARE(VoxelTypeTraits::minDensity(), DensityI8::DensityType(-127)); - QCOMPARE(VoxelTypeTraits::maxDensity(), DensityI8::DensityType(127)); - - QCOMPARE(VoxelTypeTraits::minDensity(), DensityU8::DensityType(0)); - QCOMPARE(VoxelTypeTraits::maxDensity(), DensityU8::DensityType(255)); - - QCOMPARE(VoxelTypeTraits::minDensity(), Density16::DensityType(0)); - QCOMPARE(VoxelTypeTraits::maxDensity(), Density16::DensityType(65535)); - - QCOMPARE(VoxelTypeTraits::minDensity(), DensityI16::DensityType(-32767)); - QCOMPARE(VoxelTypeTraits::maxDensity(), DensityI16::DensityType(32767)); - - QCOMPARE(VoxelTypeTraits::minDensity(), DensityU16::DensityType(0)); - QCOMPARE(VoxelTypeTraits::maxDensity(), DensityU16::DensityType(65535)); - - QCOMPARE(VoxelTypeTraits::minDensity(), -FLT_MAX); - QCOMPARE(VoxelTypeTraits::maxDensity(), FLT_MAX); - - QCOMPARE(VoxelTypeTraits::minDensity(), -DBL_MAX); - QCOMPARE(VoxelTypeTraits::maxDensity(), DBL_MAX);*/ - - /*fValue = VoxelTypeTraits::minDensity(); - QCOMPARE(fValue, -FLT_MAX); - fValue = VoxelTypeTraits::maxDensity(); - QCOMPARE(fValue, FLT_MAX);*/ - - /*iValue = VoxelTypeTraits::minDensity(); - QCOMPARE(iValue, 0); - iValue = VoxelTypeTraits::maxDensity(); - QCOMPARE(iValue, 0);*/ - - /*iValue = VoxelTypeTraits::minDensity(); - QCOMPARE(iValue, 0); - iValue = VoxelTypeTraits::maxDensity(); - QCOMPARE(iValue, 15);*/ +{ } QTEST_MAIN(TestVoxels)