Replaced constants with functions for type traits.

This commit is contained in:
unknown
2012-02-06 17:51:37 +01:00
parent 1ab1d9bed3
commit c483b44a41
18 changed files with 125 additions and 292 deletions

View File

@ -1,59 +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.
*******************************************************************************/
#include "PolyVoxCore/Density.h"
#include <cfloat> //Can't use <limits> as we need compile time constants.
namespace PolyVox
{
const bool VoxelTypeTraits< DensityI8 >::HasDensity = true;
const bool VoxelTypeTraits< DensityI8 >::HasMaterial = false;
const DensityI8::DensityType VoxelTypeTraits< DensityI8 >::MinDensity = -127;
const DensityI8::DensityType VoxelTypeTraits< DensityI8 >::MaxDensity = 127;
const bool VoxelTypeTraits< DensityU8 >::HasDensity = true;
const bool VoxelTypeTraits< DensityU8 >::HasMaterial = false;
const DensityU8::DensityType VoxelTypeTraits< DensityU8 >::MinDensity = 0;
const DensityU8::DensityType VoxelTypeTraits< DensityU8 >::MaxDensity = 255;
const bool VoxelTypeTraits< DensityI16 >::HasDensity = true;
const bool VoxelTypeTraits< DensityI16 >::HasMaterial = false;
const DensityI16::DensityType VoxelTypeTraits< DensityI16 >::MinDensity = -32767;
const DensityI16::DensityType VoxelTypeTraits< DensityI16 >::MaxDensity = 32767;
const bool VoxelTypeTraits< DensityU16 >::HasDensity = true;
const bool VoxelTypeTraits< DensityU16 >::HasMaterial = false;
const DensityU16::DensityType VoxelTypeTraits< DensityU16 >::MinDensity = 0;
const DensityU16::DensityType VoxelTypeTraits< DensityU16 >::MaxDensity = 65535;
const bool VoxelTypeTraits< DensityFloat >::HasDensity = true;
const bool VoxelTypeTraits< DensityFloat >::HasMaterial = false;
const DensityFloat::DensityType VoxelTypeTraits< DensityFloat >::MinDensity = -FLT_MAX;
const DensityFloat::DensityType VoxelTypeTraits< DensityFloat >::MaxDensity = FLT_MAX;
const bool VoxelTypeTraits< DensityDouble >::HasDensity = true;
const bool VoxelTypeTraits< DensityDouble >::HasMaterial = false;
const DensityDouble::DensityType VoxelTypeTraits< DensityDouble >::MinDensity = -DBL_MAX;
const DensityDouble::DensityType VoxelTypeTraits< DensityDouble >::MaxDensity = DBL_MAX;
}

View File

@ -1,44 +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.
*******************************************************************************/
#include "PolyVoxCore/Material.h"
#include <cfloat> //Can't use <limits> as we need compile time constants.
namespace PolyVox
{
const bool VoxelTypeTraits< MaterialU8 >::HasDensity = false;
const bool VoxelTypeTraits< MaterialU8 >::HasMaterial = true;
const MaterialU8::DensityType VoxelTypeTraits< MaterialU8 >::MinDensity = 0;
const MaterialU8::DensityType VoxelTypeTraits< MaterialU8 >::MaxDensity = 0;
const bool VoxelTypeTraits< MaterialU16 >::HasDensity = false;
const bool VoxelTypeTraits< MaterialU16 >::HasMaterial = true;
const MaterialU16::DensityType VoxelTypeTraits< MaterialU16 >::MinDensity = 0;
const MaterialU16::DensityType VoxelTypeTraits< MaterialU16 >::MaxDensity = 0;
const bool VoxelTypeTraits< MaterialU32 >::HasDensity = false;
const bool VoxelTypeTraits< MaterialU32 >::HasMaterial = true;
const MaterialU32::DensityType VoxelTypeTraits< MaterialU32 >::MinDensity = 0;
const MaterialU32::DensityType VoxelTypeTraits< MaterialU32 >::MaxDensity = 0;
}

View File

@ -1,37 +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.
*******************************************************************************/
#include "PolyVoxCore/MaterialDensityPair.h"
namespace PolyVox
{
const bool VoxelTypeTraits< MaterialDensityPair44 >::HasDensity = true;
const bool VoxelTypeTraits< MaterialDensityPair44 >::HasMaterial = true;
const MaterialDensityPair44::DensityType VoxelTypeTraits< MaterialDensityPair44 >::MinDensity = 0;
const MaterialDensityPair44::DensityType VoxelTypeTraits< MaterialDensityPair44 >::MaxDensity = 15;
const bool VoxelTypeTraits< MaterialDensityPair88 >::HasDensity = true;
const bool VoxelTypeTraits< MaterialDensityPair88 >::HasMaterial = true;
const MaterialDensityPair88::DensityType VoxelTypeTraits< MaterialDensityPair88 >::MinDensity = 0;
const MaterialDensityPair88::DensityType VoxelTypeTraits< MaterialDensityPair88 >::MaxDensity = 255;
}

View File

@ -1,37 +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.
*******************************************************************************/
#include "PolyVoxCore/Voxel.h"
namespace PolyVox
{
template<typename Type>
const bool VoxelTypeTraits<Type>::HasDensity = false;
template<typename Type>
const bool VoxelTypeTraits<Type>::HasMaterial = false;
template<typename Type>
const typename Type::DensityType VoxelTypeTraits< Type >::MinDensity = 0;
template<typename Type>
const typename Type::DensityType VoxelTypeTraits< Type >::MaxDensity = 0;
}