More work refactoring basic voxel types.
This commit is contained in:
parent
21ce252e1e
commit
b4f7ac4f46
@ -94,18 +94,59 @@ namespace PolyVox
|
|||||||
|
|
||||||
// These types are here for backwards compatibility but they are a little ambiguous as the name doesn't indicate
|
// These types are here for backwards compatibility but they are a little ambiguous as the name doesn't indicate
|
||||||
// whether the values are signed. We would recommend using one of the 8 or 16 bit predefined types above instead.
|
// whether the values are signed. We would recommend using one of the 8 or 16 bit predefined types above instead.
|
||||||
typedef Density<uint8_t> Density8;
|
typedef DensityU8 Density8;
|
||||||
typedef Density<uint16_t> Density16;
|
typedef DensityU16 Density16;
|
||||||
|
|
||||||
// We have to define all the min and max values explicitly here rather than using std::numeric_limits because we need
|
// 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.
|
// compile time constants. The new 'constexpr' would help here but it's not supported by all compilers at the moment.
|
||||||
/*template<>
|
|
||||||
class VoxelTypeTraits< Density<int8_t> >
|
template<>
|
||||||
|
class VoxelTypeTraits< DensityI8 >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const static int8_t MinDensity;
|
const static typename DensityI8::DensityType MinDensity;
|
||||||
const static int8_t MaxDensity;
|
const static typename DensityI8::DensityType MaxDensity;
|
||||||
};*/
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class VoxelTypeTraits< DensityU8 >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const static typename DensityU8::DensityType MinDensity;
|
||||||
|
const static typename DensityU8::DensityType MaxDensity;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class VoxelTypeTraits< DensityI16 >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const static typename DensityI16::DensityType MinDensity;
|
||||||
|
const static typename DensityI16::DensityType MaxDensity;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class VoxelTypeTraits< DensityU16 >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const static typename DensityU16::DensityType MinDensity;
|
||||||
|
const static typename DensityU16::DensityType MaxDensity;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class VoxelTypeTraits< DensityFloat >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const static typename DensityFloat::DensityType MinDensity;
|
||||||
|
const static typename DensityFloat::DensityType MaxDensity;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class VoxelTypeTraits< DensityDouble >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const static typename DensityDouble::DensityType MinDensity;
|
||||||
|
const static typename DensityDouble::DensityType MaxDensity;
|
||||||
|
};
|
||||||
|
|
||||||
/*template<>
|
/*template<>
|
||||||
class VoxelTypeTraits< Density<uint8_t> >
|
class VoxelTypeTraits< Density<uint8_t> >
|
||||||
@ -113,9 +154,9 @@ namespace PolyVox
|
|||||||
public:
|
public:
|
||||||
const static uint8_t MinDensity;
|
const static uint8_t MinDensity;
|
||||||
const static uint8_t MaxDensity;
|
const static uint8_t MaxDensity;
|
||||||
};*/
|
};
|
||||||
|
|
||||||
/*template<>
|
template<>
|
||||||
class VoxelTypeTraits< Density<int16_t> >
|
class VoxelTypeTraits< Density<int16_t> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -86,13 +86,21 @@ namespace PolyVox
|
|||||||
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;
|
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;
|
||||||
typedef MaterialDensityPair<uint16_t, 8, 8> MaterialDensityPair88;
|
typedef MaterialDensityPair<uint16_t, 8, 8> MaterialDensityPair88;
|
||||||
|
|
||||||
/*template<typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits>
|
template<>
|
||||||
class VoxelTypeTraits< MaterialDensityPair<Type, NoOfDensityBits, NoOfMaterialBits> >
|
class VoxelTypeTraits< MaterialDensityPair44 >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const static Type MinDensity = 0;
|
const static typename MaterialDensityPair44::DensityType MinDensity;
|
||||||
const static Type MaxDensity = (0x01 << NoOfDensityBits) - 1;
|
const static typename MaterialDensityPair44::DensityType MaxDensity;
|
||||||
};*/
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class VoxelTypeTraits< MaterialDensityPair88 >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const static typename MaterialDensityPair88::DensityType MinDensity;
|
||||||
|
const static typename MaterialDensityPair88::DensityType MaxDensity;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -68,8 +68,8 @@ namespace PolyVox
|
|||||||
class VoxelTypeTraits
|
class VoxelTypeTraits
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const static typename Type::DensityType MinDensity;
|
const static Type MinDensity;
|
||||||
const static typename Type::DensityType MaxDensity;
|
const static Type MaxDensity;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,33 +27,62 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
|
//const typename Density8::DensityType VoxelTypeTraits< Density8 >::MinDensity = 0;
|
||||||
|
//const typename Density8::DensityType VoxelTypeTraits< Density8 >::MaxDensity = 255;
|
||||||
|
|
||||||
|
const typename DensityI8::DensityType VoxelTypeTraits< DensityI8 >::MinDensity = -127;
|
||||||
|
const typename DensityI8::DensityType VoxelTypeTraits< DensityI8 >::MaxDensity = 127;
|
||||||
|
|
||||||
|
const typename DensityU8::DensityType VoxelTypeTraits< DensityU8 >::MinDensity = 0;
|
||||||
|
const typename DensityU8::DensityType VoxelTypeTraits< DensityU8 >::MaxDensity = 255;
|
||||||
|
|
||||||
|
//const typename Density16::DensityType VoxelTypeTraits< Density16 >::MinDensity = 0;
|
||||||
|
//const typename Density16::DensityType VoxelTypeTraits< Density16 >::MaxDensity = 65535;
|
||||||
|
|
||||||
|
const typename DensityI16::DensityType VoxelTypeTraits< DensityI16 >::MinDensity = -32767;
|
||||||
|
const typename DensityI16::DensityType VoxelTypeTraits< DensityI16 >::MaxDensity = 32767;
|
||||||
|
|
||||||
|
const typename DensityU16::DensityType VoxelTypeTraits< DensityU16 >::MinDensity = 0;
|
||||||
|
const typename DensityU16::DensityType VoxelTypeTraits< DensityU16 >::MaxDensity = 65535;
|
||||||
|
|
||||||
|
const typename DensityFloat::DensityType VoxelTypeTraits< DensityFloat >::MinDensity = FLT_MIN;
|
||||||
|
const typename DensityFloat::DensityType VoxelTypeTraits< DensityFloat >::MaxDensity = FLT_MAX;
|
||||||
|
|
||||||
|
const typename DensityDouble::DensityType VoxelTypeTraits< DensityDouble >::MinDensity = DBL_MIN;
|
||||||
|
const typename DensityDouble::DensityType VoxelTypeTraits< DensityDouble >::MaxDensity = DBL_MAX;
|
||||||
|
|
||||||
|
//template<>
|
||||||
|
//const typename DensityI8::DensityType VoxelTypeTraits< DensityI8 >::MinDensity = -127;
|
||||||
|
//template<>
|
||||||
|
//const typename DensityI8::DensityType VoxelTypeTraits< DensityI8 >::MaxDensity = 127;
|
||||||
|
|
||||||
|
//template<>
|
||||||
|
//const typename DensityU8::DensityType VoxelTypeTraits< DensityU8 >::MinDensity = 0;
|
||||||
|
//template<>
|
||||||
|
//const typename DensityU8::DensityType VoxelTypeTraits< DensityU8 >::MaxDensity = 255;
|
||||||
|
|
||||||
|
/*template<>
|
||||||
|
const uint8_t VoxelTypeTraits< Density8 >::MinDensity = 0;
|
||||||
template<>
|
template<>
|
||||||
const int8_t VoxelTypeTraits< Density<int8_t> >::MinDensity = -127;
|
const uint8_t VoxelTypeTraits< Density8 >::MaxDensity = 255;
|
||||||
template<>
|
|
||||||
const int8_t VoxelTypeTraits< Density<int8_t> >::MaxDensity = 127;
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const uint8_t VoxelTypeTraits< Density<uint8_t> >::MinDensity = 0;
|
const int16_t VoxelTypeTraits< DensityI16 >::MinDensity = -32767;
|
||||||
template<>
|
template<>
|
||||||
const uint8_t VoxelTypeTraits< Density<uint8_t> >::MaxDensity = 255;
|
const int16_t VoxelTypeTraits< DensityI16 >::MaxDensity = 32767;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const int16_t VoxelTypeTraits< Density<int16_t> >::MinDensity = -32767;
|
const uint16_t VoxelTypeTraits< Density16 >::MinDensity = 0;
|
||||||
template<>
|
template<>
|
||||||
const int16_t VoxelTypeTraits< Density<int16_t> >::MaxDensity = 32767;
|
const uint16_t VoxelTypeTraits< Density16 >::MaxDensity = 65535;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const uint16_t VoxelTypeTraits< Density<uint16_t> >::MinDensity = 0;
|
const float VoxelTypeTraits< DensityFloat >::MinDensity = FLT_MIN;
|
||||||
template<>
|
template<>
|
||||||
const uint16_t VoxelTypeTraits< Density<uint16_t> >::MaxDensity = 65535;
|
const float VoxelTypeTraits< DensityFloat >::MaxDensity = FLT_MAX;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const float VoxelTypeTraits< Density<float> >::MinDensity = FLT_MIN;
|
const double VoxelTypeTraits< DensityDouble >::MinDensity = DBL_MIN;
|
||||||
template<>
|
template<>
|
||||||
const float VoxelTypeTraits< Density<float> >::MaxDensity = FLT_MAX;
|
const double VoxelTypeTraits< DensityDouble >::MaxDensity = DBL_MAX;*/
|
||||||
|
|
||||||
template<>
|
|
||||||
const double VoxelTypeTraits< Density<double> >::MinDensity = DBL_MIN;
|
|
||||||
template<>
|
|
||||||
const double VoxelTypeTraits< Density<double> >::MaxDensity = DBL_MAX;
|
|
||||||
}
|
}
|
@ -25,13 +25,9 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
//template<typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits>
|
const typename MaterialDensityPair44::DensityType VoxelTypeTraits< MaterialDensityPair44 >::MinDensity = 0;
|
||||||
//const Type VoxelTypeTraits< MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> >::MinDensity = 0;
|
const typename MaterialDensityPair44::DensityType VoxelTypeTraits< MaterialDensityPair44 >::MaxDensity = 15;
|
||||||
//template<typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits>
|
|
||||||
//const Type VoxelTypeTraits< Type >::MaxDensity = (0x01 << NoOfDensityBits) - 1;
|
|
||||||
|
|
||||||
template<>
|
const typename MaterialDensityPair88::DensityType VoxelTypeTraits< MaterialDensityPair88 >::MinDensity = 0;
|
||||||
const uint8_t VoxelTypeTraits< MaterialDensityPair44 >::MinDensity = 0;
|
const typename MaterialDensityPair88::DensityType VoxelTypeTraits< MaterialDensityPair88 >::MaxDensity = 255;
|
||||||
template<>
|
|
||||||
const uint8_t VoxelTypeTraits< MaterialDensityPair44 >::MaxDensity = 15;
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ freely, subject to the following restrictions:
|
|||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
const typename Type::DensityType VoxelTypeTraits<Type>::MinDensity = 0;
|
const Type VoxelTypeTraits<Type>::MinDensity = 0;
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
const typename Type::DensityType VoxelTypeTraits<Type>::MaxDensity = 0;
|
const Type VoxelTypeTraits<Type>::MaxDensity = 0;
|
||||||
}
|
}
|
@ -35,26 +35,44 @@ using namespace PolyVox;
|
|||||||
|
|
||||||
void TestVoxels::testTraits()
|
void TestVoxels::testTraits()
|
||||||
{
|
{
|
||||||
int iValue; float fValue; //Used for temporary storage as the QCOMPARE maro struggles with the complex types.
|
QCOMPARE(VoxelTypeTraits<Density8>::MinDensity, Density8::DensityType(0));
|
||||||
|
QCOMPARE(VoxelTypeTraits<Density8>::MaxDensity, Density8::DensityType(255));
|
||||||
|
|
||||||
|
QCOMPARE(VoxelTypeTraits<DensityI8>::MinDensity, DensityI8::DensityType(-127));
|
||||||
|
QCOMPARE(VoxelTypeTraits<DensityI8>::MaxDensity, DensityI8::DensityType(127));
|
||||||
|
|
||||||
QCOMPARE(VoxelTypeTraits<Density8>::MaxDensity, static_cast<uint8_t>(0));
|
QCOMPARE(VoxelTypeTraits<DensityU8>::MinDensity, DensityU8::DensityType(0));
|
||||||
QCOMPARE(VoxelTypeTraits<Density8>::MaxDensity, static_cast<uint8_t>(255));
|
QCOMPARE(VoxelTypeTraits<DensityU8>::MaxDensity, DensityU8::DensityType(255));
|
||||||
|
|
||||||
fValue = VoxelTypeTraits<DensityFloat>::MinDensity;
|
QCOMPARE(VoxelTypeTraits<Density16>::MinDensity, Density16::DensityType(0));
|
||||||
|
QCOMPARE(VoxelTypeTraits<Density16>::MaxDensity, Density16::DensityType(65535));
|
||||||
|
|
||||||
|
QCOMPARE(VoxelTypeTraits<DensityI16>::MinDensity, DensityI16::DensityType(-32767));
|
||||||
|
QCOMPARE(VoxelTypeTraits<DensityI16>::MaxDensity, DensityI16::DensityType(32767));
|
||||||
|
|
||||||
|
QCOMPARE(VoxelTypeTraits<DensityU16>::MinDensity, DensityU16::DensityType(0));
|
||||||
|
QCOMPARE(VoxelTypeTraits<DensityU16>::MaxDensity, DensityU16::DensityType(65535));
|
||||||
|
|
||||||
|
QCOMPARE(VoxelTypeTraits<DensityFloat>::MinDensity, FLT_MIN);
|
||||||
|
QCOMPARE(VoxelTypeTraits<DensityFloat>::MaxDensity, FLT_MAX);
|
||||||
|
|
||||||
|
QCOMPARE(VoxelTypeTraits<DensityDouble>::MinDensity, DBL_MIN);
|
||||||
|
QCOMPARE(VoxelTypeTraits<DensityDouble>::MaxDensity, DBL_MAX);
|
||||||
|
|
||||||
|
/*fValue = VoxelTypeTraits<DensityFloat>::MinDensity;
|
||||||
QCOMPARE(fValue, FLT_MIN);
|
QCOMPARE(fValue, FLT_MIN);
|
||||||
fValue = VoxelTypeTraits<DensityFloat>::MaxDensity;
|
fValue = VoxelTypeTraits<DensityFloat>::MaxDensity;
|
||||||
QCOMPARE(fValue, FLT_MAX);
|
QCOMPARE(fValue, FLT_MAX);*/
|
||||||
|
|
||||||
/*iValue = VoxelTypeTraits<Material8>::MinDensity;
|
/*iValue = VoxelTypeTraits<Material8>::MinDensity;
|
||||||
QCOMPARE(iValue, 0);
|
QCOMPARE(iValue, 0);
|
||||||
iValue = VoxelTypeTraits<Material8>::MaxDensity;
|
iValue = VoxelTypeTraits<Material8>::MaxDensity;
|
||||||
QCOMPARE(iValue, 0);*/
|
QCOMPARE(iValue, 0);*/
|
||||||
|
|
||||||
iValue = VoxelTypeTraits<MaterialDensityPair44>::MinDensity;
|
/*iValue = VoxelTypeTraits<MaterialDensityPair44>::MinDensity;
|
||||||
QCOMPARE(iValue, 0);
|
QCOMPARE(iValue, 0);
|
||||||
iValue = VoxelTypeTraits<MaterialDensityPair44>::MaxDensity;
|
iValue = VoxelTypeTraits<MaterialDensityPair44>::MaxDensity;
|
||||||
QCOMPARE(iValue, 15);
|
QCOMPARE(iValue, 15);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(TestVoxels)
|
QTEST_MAIN(TestVoxels)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user