Merge branch 'master' of git://gitorious.org/polyvox/polyvox
This commit is contained in:
commit
167822f1f0
@ -27,6 +27,7 @@ freely, subject to the following restrictions:
|
|||||||
#include "PolyVoxImpl/TypeDef.h"
|
#include "PolyVoxImpl/TypeDef.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
@ -42,12 +43,12 @@ namespace PolyVox
|
|||||||
///
|
///
|
||||||
/// \sa Material, MaterialDensityPair
|
/// \sa Material, MaterialDensityPair
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template <typename Type>
|
template <typename DensityType>
|
||||||
class Density
|
class Density
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Density() : m_uDensity(0) {}
|
Density() : m_uDensity(0) {}
|
||||||
Density(Type uDensity) : m_uDensity(uDensity) {}
|
Density(DensityType uDensity) : m_uDensity(uDensity) {}
|
||||||
|
|
||||||
bool operator==(const Density& rhs) const throw()
|
bool operator==(const Density& rhs) const throw()
|
||||||
{
|
{
|
||||||
@ -59,18 +60,18 @@ namespace PolyVox
|
|||||||
return !(*this == rhs);
|
return !(*this == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type getDensity() const throw() { return m_uDensity; }
|
DensityType getDensity() const throw() { return m_uDensity; }
|
||||||
Type getMaterial() const throw() { return 1; }
|
uint32_t getMaterial() const throw() { return 1; }
|
||||||
|
|
||||||
void setDensity(Type uDensity) { m_uDensity = uDensity; }
|
void setDensity(DensityType uDensity) { m_uDensity = uDensity; }
|
||||||
void setMaterial(Type uMaterial) { assert(false); } //Cannot set material on voxel of type Density
|
void setMaterial(uint32_t uMaterial) { assert(false); } //Cannot set material on voxel of type Density
|
||||||
|
|
||||||
static Type getMaxDensity() throw() { return (0x01 << (sizeof(Type) * 8)) - 1; }
|
static DensityType getMaxDensity() throw() { return (std::numeric_limits<DensityType>::max)(); }
|
||||||
static Type getMinDensity() throw() { return 0; }
|
static DensityType getMinDensity() throw() { return (std::numeric_limits<DensityType>::min)(); }
|
||||||
static Type getThreshold() throw() {return 0x01 << ((sizeof(Type) * 8) - 1);}
|
static DensityType getThreshold() throw() { return (std::numeric_limits<DensityType>::max)() / 2; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type m_uDensity;
|
DensityType m_uDensity;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Density<uint8_t> Density8;
|
typedef Density<uint8_t> Density8;
|
||||||
|
@ -43,12 +43,12 @@ namespace PolyVox
|
|||||||
///
|
///
|
||||||
/// \sa Density, MaterialDensityPair
|
/// \sa Density, MaterialDensityPair
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
template <typename Type>
|
template <typename MaterialType>
|
||||||
class Material
|
class Material
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Material() : m_uMaterial(0) {}
|
Material() : m_uMaterial(0) {}
|
||||||
Material(Type uMaterial) : m_uMaterial(uMaterial) {}
|
Material(MaterialType uMaterial) : m_uMaterial(uMaterial) {}
|
||||||
|
|
||||||
bool operator==(const Material& rhs) const throw()
|
bool operator==(const Material& rhs) const throw()
|
||||||
{
|
{
|
||||||
@ -60,7 +60,7 @@ namespace PolyVox
|
|||||||
return !(*this == rhs);
|
return !(*this == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
Type getDensity() const throw()
|
uint32_t getDensity() const throw()
|
||||||
{
|
{
|
||||||
//We don't actually have a density, so make one up based on the material.
|
//We don't actually have a density, so make one up based on the material.
|
||||||
if(m_uMaterial == 0)
|
if(m_uMaterial == 0)
|
||||||
@ -73,17 +73,17 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Type getMaterial() const throw() { return m_uMaterial; }
|
MaterialType getMaterial() const throw() { return m_uMaterial; }
|
||||||
|
|
||||||
void setDensity(Type /*uDensity*/) { assert(false); } //Cannot set density on voxel of type Material
|
void setDensity(uint32_t /*uDensity*/) { assert(false); } //Cannot set density on voxel of type Material
|
||||||
void setMaterial(Type uMaterial) { m_uMaterial = uMaterial; }
|
void setMaterial(MaterialType uMaterial) { m_uMaterial = uMaterial; }
|
||||||
|
|
||||||
static Type getMaxDensity() throw() { return 2; }
|
static uint32_t getMaxDensity() throw() { return 2; }
|
||||||
static Type getMinDensity() throw() { return 0; }
|
static uint32_t getMinDensity() throw() { return 0; }
|
||||||
static Type getThreshold() throw() { return 1; }
|
static uint32_t getThreshold() throw() { return 1; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type m_uMaterial;
|
MaterialType m_uMaterial;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Material<uint8_t> Material8;
|
typedef Material<uint8_t> Material8;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user