Refactoring of basic voxel types.
This commit is contained in:
parent
b3b22036c1
commit
396e1fea30
@ -70,6 +70,7 @@ SET(CORE_INC_FILES
|
||||
include/PolyVoxCore/VertexTypes.h
|
||||
include/PolyVoxCore/VolumeResampler.h
|
||||
include/PolyVoxCore/VolumeResampler.inl
|
||||
include/PolyVoxCore/Voxel.h
|
||||
include/PolyVoxCore/VoxelFilters.h
|
||||
)
|
||||
|
||||
|
@ -24,6 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_Density_H__
|
||||
#define __PolyVox_Density_H__
|
||||
|
||||
#include "PolyVoxCore/Voxel.h"
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include <cassert>
|
||||
@ -44,7 +46,7 @@ namespace PolyVox
|
||||
/// \sa Material, MaterialDensityPair
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename Type>
|
||||
class Density
|
||||
class Density : public Voxel<Type, uint8_t>
|
||||
{
|
||||
public:
|
||||
//We expose DensityType and MaterialType in this way so that, when code is
|
||||
@ -52,7 +54,7 @@ namespace PolyVox
|
||||
//using code such as 'VoxelType::DensityType value = voxel.getDensity()'
|
||||
//or 'VoxelType::MaterialType value = voxel.getMaterial()'.
|
||||
typedef Type DensityType;
|
||||
typedef uint8_t MaterialType;
|
||||
typedef uint8_t MaterialType; //Shouldn't define this one...
|
||||
|
||||
Density() : m_uDensity(0) {}
|
||||
Density(DensityType uDensity) : m_uDensity(uDensity) {}
|
||||
|
@ -24,6 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_Material_H__
|
||||
#define __PolyVox_Material_H__
|
||||
|
||||
#include "PolyVoxCore/Voxel.h"
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include <cassert>
|
||||
@ -44,14 +46,14 @@ namespace PolyVox
|
||||
/// \sa Density, MaterialDensityPair
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename Type>
|
||||
class Material
|
||||
class Material : public Voxel<uint8_t, Type>
|
||||
{
|
||||
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 uint8_t DensityType;
|
||||
typedef uint8_t DensityType; //Shouldn't define this one...
|
||||
typedef Type MaterialType;
|
||||
|
||||
Material() : m_uMaterial(0) {}
|
||||
|
@ -24,6 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_MaterialDensityPair_H__
|
||||
#define __PolyVox_MaterialDensityPair_H__
|
||||
|
||||
#include "PolyVoxCore/Voxel.h"
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
namespace PolyVox
|
||||
@ -43,7 +45,7 @@ namespace PolyVox
|
||||
/// \sa Density, Material
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename Type, uint8_t NoOfMaterialBits, uint8_t NoOfDensityBits>
|
||||
class MaterialDensityPair
|
||||
class MaterialDensityPair : public Voxel<Type, Type>
|
||||
{
|
||||
public:
|
||||
//We expose DensityType and MaterialType in this way so that, when code is
|
||||
|
57
library/PolyVoxCore/include/PolyVoxCore/Voxel.h
Normal file
57
library/PolyVoxCore/include/PolyVoxCore/Voxel.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*******************************************************************************
|
||||
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 <cassert>
|
||||
#include <limits>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
/// This class represents a voxel
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Detailed description...
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename DenType, typename MatType>
|
||||
class Voxel
|
||||
{
|
||||
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 DenType DensityType;
|
||||
typedef MatType MaterialType;
|
||||
|
||||
DensityType getDensity() const throw() { assert(false); return 0; }
|
||||
MaterialType getMaterial() const throw() { assert(false); return 0; }
|
||||
|
||||
void setDensity(DensityType uDensity) { assert(false); }
|
||||
void setMaterial(MaterialType /*uMaterial*/) { assert(false); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif //__PolyVox_Voxel_H__
|
Loading…
x
Reference in New Issue
Block a user