Work on refactoring voxel types.
This commit is contained in:
@ -9,10 +9,12 @@ SET(CORE_SRC_FILES
|
||||
source/Density.cpp
|
||||
source/GradientEstimators.cpp
|
||||
source/Log.cpp
|
||||
source/MaterialDensityPair.cpp
|
||||
source/MeshDecimator.cpp
|
||||
source/Region.cpp
|
||||
source/SimpleInterface.cpp
|
||||
source/VertexTypes.cpp
|
||||
source/Voxel.cpp
|
||||
source/VoxelFilters.cpp
|
||||
)
|
||||
|
||||
|
@ -99,36 +99,36 @@ namespace PolyVox
|
||||
|
||||
// We have to define all the min and max values explicitly here rather than using std::numeric_limits because we need
|
||||
// compile time constants. The new 'constexpr' would help here but it's not supported by all compilers at the moment.
|
||||
template<>
|
||||
/*template<>
|
||||
class VoxelTypeTraits< Density<int8_t> >
|
||||
{
|
||||
public:
|
||||
const static int8_t MinDensity = -127;
|
||||
const static int8_t MaxDensity = 127;
|
||||
};
|
||||
const static int8_t MinDensity;
|
||||
const static int8_t MaxDensity;
|
||||
};*/
|
||||
|
||||
template<>
|
||||
/*template<>
|
||||
class VoxelTypeTraits< Density<uint8_t> >
|
||||
{
|
||||
public:
|
||||
const static uint8_t MinDensity = 0;
|
||||
const static uint8_t MaxDensity = 255;
|
||||
};
|
||||
const static uint8_t MinDensity;
|
||||
const static uint8_t MaxDensity;
|
||||
};*/
|
||||
|
||||
template<>
|
||||
/*template<>
|
||||
class VoxelTypeTraits< Density<int16_t> >
|
||||
{
|
||||
public:
|
||||
const static int16_t MinDensity = -32767;
|
||||
const static int16_t MaxDensity = 32767;
|
||||
const static int16_t MinDensity;
|
||||
const static int16_t MaxDensity;
|
||||
};
|
||||
|
||||
template<>
|
||||
class VoxelTypeTraits< Density<uint16_t> >
|
||||
{
|
||||
public:
|
||||
const static uint16_t MinDensity = 0;
|
||||
const static uint16_t MaxDensity = 65535;
|
||||
const static uint16_t MinDensity;
|
||||
const static uint16_t MaxDensity;
|
||||
};
|
||||
|
||||
//Constants for float defined in .cpp file as they are not integers.
|
||||
@ -147,7 +147,7 @@ namespace PolyVox
|
||||
public:
|
||||
const static double MinDensity;
|
||||
const static double MaxDensity;
|
||||
};
|
||||
};*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -86,13 +86,13 @@ namespace PolyVox
|
||||
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;
|
||||
typedef MaterialDensityPair<uint16_t, 8, 8> MaterialDensityPair88;
|
||||
|
||||
template<typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits>
|
||||
/*template<typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits>
|
||||
class VoxelTypeTraits< MaterialDensityPair<Type, NoOfDensityBits, NoOfMaterialBits> >
|
||||
{
|
||||
public:
|
||||
const static Type MinDensity = 0;
|
||||
const static Type MaxDensity = (0x01 << NoOfDensityBits) - 1;
|
||||
};
|
||||
};*/
|
||||
}
|
||||
|
||||
#endif
|
@ -68,8 +68,8 @@ namespace PolyVox
|
||||
class VoxelTypeTraits
|
||||
{
|
||||
public:
|
||||
const static typename Type::DensityType MinDensity = 0;
|
||||
const static typename Type::DensityType MaxDensity = 0;
|
||||
const static typename Type::DensityType MinDensity;
|
||||
const static typename Type::DensityType MaxDensity;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -27,9 +27,33 @@ freely, subject to the following restrictions:
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template<>
|
||||
const int8_t VoxelTypeTraits< Density<int8_t> >::MinDensity = -127;
|
||||
template<>
|
||||
const int8_t VoxelTypeTraits< Density<int8_t> >::MaxDensity = 127;
|
||||
|
||||
template<>
|
||||
const uint8_t VoxelTypeTraits< Density<uint8_t> >::MinDensity = 0;
|
||||
template<>
|
||||
const uint8_t VoxelTypeTraits< Density<uint8_t> >::MaxDensity = 255;
|
||||
|
||||
template<>
|
||||
const int16_t VoxelTypeTraits< Density<int16_t> >::MinDensity = -32767;
|
||||
template<>
|
||||
const int16_t VoxelTypeTraits< Density<int16_t> >::MaxDensity = 32767;
|
||||
|
||||
template<>
|
||||
const uint16_t VoxelTypeTraits< Density<uint16_t> >::MinDensity = 0;
|
||||
template<>
|
||||
const uint16_t VoxelTypeTraits< Density<uint16_t> >::MaxDensity = 65535;
|
||||
|
||||
template<>
|
||||
const float VoxelTypeTraits< Density<float> >::MinDensity = FLT_MIN;
|
||||
template<>
|
||||
const float VoxelTypeTraits< Density<float> >::MaxDensity = FLT_MAX;
|
||||
|
||||
template<>
|
||||
const double VoxelTypeTraits< Density<double> >::MinDensity = DBL_MIN;
|
||||
template<>
|
||||
const double VoxelTypeTraits< Density<double> >::MaxDensity = DBL_MAX;
|
||||
}
|
37
library/PolyVoxCore/source/MaterialDensityPair.cpp
Normal file
37
library/PolyVoxCore/source/MaterialDensityPair.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
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/MaterialDensityPair.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
//template<typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits>
|
||||
//const Type VoxelTypeTraits< MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> >::MinDensity = 0;
|
||||
//template<typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits>
|
||||
//const Type VoxelTypeTraits< Type >::MaxDensity = (0x01 << NoOfDensityBits) - 1;
|
||||
|
||||
template<>
|
||||
const uint8_t VoxelTypeTraits< MaterialDensityPair44 >::MinDensity = 0;
|
||||
template<>
|
||||
const uint8_t VoxelTypeTraits< MaterialDensityPair44 >::MaxDensity = 15;
|
||||
}
|
32
library/PolyVoxCore/source/Voxel.cpp
Normal file
32
library/PolyVoxCore/source/Voxel.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*******************************************************************************
|
||||
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/Voxel.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template<typename Type>
|
||||
const typename Type::DensityType VoxelTypeTraits<Type>::MinDensity = 0;
|
||||
template<typename Type>
|
||||
const typename Type::DensityType VoxelTypeTraits<Type>::MaxDensity = 0;
|
||||
}
|
Reference in New Issue
Block a user