Merge branch 'develop' into feature/cubiquity-version

Conflicts:
	library/PolyVoxCore/include/PolyVoxCore/Impl/CompilerCapabilities.h
	library/PolyVoxCore/include/PolyVoxCore/Interpolation.h
This commit is contained in:
David Williams 2012-12-29 23:34:32 +01:00
commit 195a7a17a8
11 changed files with 156 additions and 113 deletions

View File

@ -107,6 +107,8 @@ SET(IMPL_INC_FILES
include/PolyVoxCore/Impl/AStarPathfinderImpl.h include/PolyVoxCore/Impl/AStarPathfinderImpl.h
include/PolyVoxCore/Impl/Block.h include/PolyVoxCore/Impl/Block.h
include/PolyVoxCore/Impl/Block.inl include/PolyVoxCore/Impl/Block.inl
include/PolyVoxCore/Impl/CompilerCapabilities.h
include/PolyVoxCore/Impl/Config.h
include/PolyVoxCore/Impl/ErrorHandling.h include/PolyVoxCore/Impl/ErrorHandling.h
include/PolyVoxCore/Impl/MarchingCubesTables.h include/PolyVoxCore/Impl/MarchingCubesTables.h
include/PolyVoxCore/Impl/RandomUnitVectors.h include/PolyVoxCore/Impl/RandomUnitVectors.h

View File

@ -21,6 +21,8 @@ freely, subject to the following restrictions:
distribution. distribution.
*******************************************************************************/ *******************************************************************************/
#include "PolyVoxCore/Impl/ErrorHandling.h"
namespace PolyVox namespace PolyVox
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -159,7 +161,7 @@ namespace PolyVox
if((openNodes.empty()) || (openNodes.getFirst() != endNode)) if((openNodes.empty()) || (openNodes.getFirst() != endNode))
{ {
//In this case we failed to find a valid path. //In this case we failed to find a valid path.
throw std::runtime_error("No path found"); POLYVOX_THROW(std::runtime_error, "No path found");
} }
else else
{ {

View File

@ -21,7 +21,9 @@ freely, subject to the following restrictions:
distribution. distribution.
*******************************************************************************/ *******************************************************************************/
#include "PolyVoxCore/Impl/ErrorHandling.h"
#include "PolyVoxCore/Impl/Utility.h" #include "PolyVoxCore/Impl/Utility.h"
#include "PolyVoxCore/Vector.h" #include "PolyVoxCore/Vector.h"
#include <cassert> #include <cassert>
@ -130,7 +132,7 @@ namespace PolyVox
//Release mode validation //Release mode validation
if(!isPowerOf2(uSideLength)) if(!isPowerOf2(uSideLength))
{ {
throw std::invalid_argument("Block side length must be a power of two."); POLYVOX_THROW(std::invalid_argument, "Block side length must be a power of two.");
} }
//Compute the side length //Compute the side length

View File

@ -1,20 +1,23 @@
/* /*
* This file provides the default compiler capabilities for for Visual Studio. * This file describes the capabilities of the C++ compiler and is used to determine which features to enable in PolyVox.
* On other compilers CMake will detect which features are available and create * It assumes that if the compiler is from VS2008 or earlier then no C++11 is present, otherwise it assumes full support
* a file like this. * is present.
* *
* To Enable these features in Visual Studio, define the variables in this file. * Not that this file is usually overwritten by CMake which does careful tests of the true compiler capabilities. However,
*/ * we provide this default file so that CMake is not actually required for users of PolyVox and they can instead just drop
* PolyVox code into their project/makefile if they prefer.
*/
#ifndef __PolyVox_CompilerCapabilities_H__ #ifndef __PolyVox_CompilerCapabilities_H__
#define __PolyVox_CompilerCapabilities_H__ #define __PolyVox_CompilerCapabilities_H__
//#undef HAS_CXX11_CONSTEXPR // If we are not using Visual Studio (or we are but it
// is a recent version) then assume support for these.
//#define HAS_CXX11_STATIC_ASSERT #if !defined(_MSC_VER) || (_MSC_VER >= 1600)
#define HAS_CXX11_CONSTEXPR
#define HAS_CXX11_CSTDINT_H #define HAS_CXX11_STATIC_ASSERT
#define HAS_CXX11_CSTDINT_H
#define HAS_CXX11_SHARED_PTR #define HAS_CXX11_SHARED_PTR
#endif
#endif #endif

View File

@ -0,0 +1,30 @@
/*******************************************************************************
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_Config_H__
#define __PolyVox_Config_H__
#define POLYVOX_ASSERTS_ENABLED
#define POLYVOX_THROW_ENABLED
#endif

View File

@ -24,13 +24,12 @@ freely, subject to the following restrictions:
#ifndef __PolyVox_ErrorHandling_H__ #ifndef __PolyVox_ErrorHandling_H__
#define __PolyVox_ErrorHandling_H__ #define __PolyVox_ErrorHandling_H__
#include "PolyVoxCore/Impl/Config.h"
#include <cstdlib> //For std::exit #include <cstdlib> //For std::exit
#include <iostream> //For std::cerr #include <iostream> //For std::cerr
#include <stdexcept> #include <stdexcept>
#define POLYVOX_ASSERTS_ENABLED
//#define POLYVOX_THROW_ENABLED
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define POLYVOX_HALT() __debugbreak() #define POLYVOX_HALT() __debugbreak()
#else #else

View File

@ -101,13 +101,12 @@ freely, subject to the following restrictions:
#if defined(HAS_CXX11_CSTDINT_H) #if defined(HAS_CXX11_CSTDINT_H)
#include <cstdint> #include <cstdint>
#else #else
#include <boost/cstdint.hpp> typedef signed char int8_t;
using boost::int8_t; typedef unsigned char uint8_t;
using boost::int16_t; typedef short int16_t;
using boost::int32_t; typedef unsigned short uint16_t;
using boost::uint8_t; typedef long int32_t;
using boost::uint16_t; typedef unsigned long uint32_t;
using boost::uint32_t;
#endif #endif
#if defined(HAS_CXX11_SHARED_PTR) #if defined(HAS_CXX11_SHARED_PTR)

View File

@ -1,82 +1,82 @@
/******************************************************************************* /*******************************************************************************
Copyright (c) 2005-2009 David Williams Copyright (c) 2005-2009 David Williams
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
arising from the use of this software. arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions: freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not 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 claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be in a product, an acknowledgment in the product documentation would be
appreciated but is not required. appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source 3. This notice may not be removed or altered from any source
distribution. distribution.
*******************************************************************************/ *******************************************************************************/
#ifndef __PolyVox_Interpolation_H__ #ifndef __PolyVox_Interpolation_H__
#define __PolyVox_Interpolation_H__ #define __PolyVox_Interpolation_H__
#include <cassert> #include <cassert>
namespace PolyVox namespace PolyVox
{ {
template <typename Type> template <typename Type>
Type lerp( Type lerp(
const Type& v0,const Type& v1, const Type& v0,const Type& v1,
const float x) const float x)
{ {
assert((x >= 0.0f) && (x <= 1.0f)); assert((x >= 0.0f) && (x <= 1.0f));
//Interpolate along X //Interpolate along X
Type v0_1 = (v1 - v0) * x + v0; Type v0_1 = (v1 - v0) * x + v0;
return v0_1; return v0_1;
} }
template <typename Type> template <typename Type>
Type bilerp( Type bilerp(
const Type& v00,const Type& v10,const Type& v01,const Type& v11, const Type& v00,const Type& v10,const Type& v01,const Type& v11,
const float x, const float y) const float x, const float y)
{ {
assert((x >= 0.0f) && (y >= 0.0f) && assert((x >= 0.0f) && (y >= 0.0f) &&
(x <= 1.0f) && (y <= 1.0f)); (x <= 1.0f) && (y <= 1.0f));
// Linearly interpolate along x // Linearly interpolate along x
Type v00_10 = lerp(v00, v10, x); Type v00_10 = lerp(v00, v10, x);
Type v01_11 = lerp(v01, v11, x); Type v01_11 = lerp(v01, v11, x);
// And linearly interpolate the results along y // And linearly interpolate the results along y
Type v00_10__v01_11 = lerp(v00_10, v01_11, y); Type v00_10__v01_11 = lerp(v00_10, v01_11, y);
return v00_10__v01_11; return v00_10__v01_11;
} }
template <typename Type> template <typename Type>
Type trilerp( Type trilerp(
const Type& v000,const Type& v100,const Type& v010,const Type& v110, const Type& v000,const Type& v100,const Type& v010,const Type& v110,
const Type& v001,const Type& v101,const Type& v011,const Type& v111, const Type& v001,const Type& v101,const Type& v011,const Type& v111,
const float x, const float y, const float z) const float x, const float y, const float z)
{ {
assert((x >= 0.0f) && (y >= 0.0f) && (z >= 0.0f) && assert((x >= 0.0f) && (y >= 0.0f) && (z >= 0.0f) &&
(x <= 1.0f) && (y <= 1.0f) && (z <= 1.0f)); (x <= 1.0f) && (y <= 1.0f) && (z <= 1.0f));
// Bilinearly interpolate along Y // Bilinearly interpolate along Y
Type v000_v100__v010_v110 = bilerp(v000, v100, v010, v110, x, y); Type v000_v100__v010_v110 = bilerp(v000, v100, v010, v110, x, y);
Type v001_v101__v011_v111 = bilerp(v001, v101, v011, v111, x, y); Type v001_v101__v011_v111 = bilerp(v001, v101, v011, v111, x, y);
// And linearly interpolate the results along z // And linearly interpolate the results along z
Type v000_v100__v010_v110____v001_v101__v011_v111 = lerp(v000_v100__v010_v110, v001_v101__v011_v111, z); Type v000_v100__v010_v110____v001_v101__v011_v111 = lerp(v000_v100__v010_v110, v001_v101__v011_v111, z);
return v000_v100__v010_v110____v001_v101__v011_v111; return v000_v100__v010_v110____v001_v101__v011_v111;
} }
} }
#endif //__PolyVox_Interpolation_H__ #endif //__PolyVox_Interpolation_H__

View File

@ -21,6 +21,8 @@ freely, subject to the following restrictions:
distribution. distribution.
*******************************************************************************/ *******************************************************************************/
#include "PolyVoxCore/Impl/ErrorHandling.h"
//Included here rather than in the .h because it refers to LargeVolume (avoids forward declaration) //Included here rather than in the .h because it refers to LargeVolume (avoids forward declaration)
#include "PolyVoxCore/ConstVolumeProxy.h" #include "PolyVoxCore/ConstVolumeProxy.h"
@ -471,11 +473,11 @@ namespace PolyVox
//Release mode validation //Release mode validation
if(uBlockSideLength == 0) if(uBlockSideLength == 0)
{ {
throw std::invalid_argument("Block side length cannot be zero."); POLYVOX_THROW(std::invalid_argument, "Block side length cannot be zero.");
} }
if(!isPowerOf2(uBlockSideLength)) if(!isPowerOf2(uBlockSideLength))
{ {
throw std::invalid_argument("Block side length must be a power of two."); POLYVOX_THROW(std::invalid_argument, "Block side length must be a power of two.");
} }
m_uTimestamper = 0; m_uTimestamper = 0;

View File

@ -21,6 +21,8 @@ freely, subject to the following restrictions:
distribution. distribution.
*******************************************************************************/ *******************************************************************************/
#include "PolyVoxCore/Impl/ErrorHandling.h"
namespace PolyVox namespace PolyVox
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -253,15 +255,15 @@ namespace PolyVox
//Release mode validation //Release mode validation
if(uBlockSideLength < 8) if(uBlockSideLength < 8)
{ {
throw std::invalid_argument("Block side length should be at least 8"); POLYVOX_THROW(std::invalid_argument, "Block side length should be at least 8");
} }
if(uBlockSideLength > 256) if(uBlockSideLength > 256)
{ {
throw std::invalid_argument("Block side length should not be more than 256"); POLYVOX_THROW(std::invalid_argument, "Block side length should not be more than 256");
} }
if(!isPowerOf2(uBlockSideLength)) if(!isPowerOf2(uBlockSideLength))
{ {
throw std::invalid_argument("Block side length must be a power of two."); POLYVOX_THROW(std::invalid_argument, "Block side length must be a power of two.");
} }
this->m_regValidRegion = regValidRegion; this->m_regValidRegion = regValidRegion;

View File

@ -21,6 +21,8 @@ freely, subject to the following restrictions:
distribution. distribution.
*******************************************************************************/ *******************************************************************************/
#include "PolyVoxCore/Impl/ErrorHandling.h"
namespace PolyVox namespace PolyVox
{ {
template <typename VoxelType> template <typename VoxelType>
@ -109,7 +111,7 @@ namespace PolyVox
//Release mode validation //Release mode validation
if(!isPowerOf2(uSideLength)) if(!isPowerOf2(uSideLength))
{ {
throw std::invalid_argument("Block side length must be a power of two."); POLYVOX_THROW(std::invalid_argument, "Block side length must be a power of two.");
} }
//Compute the side length //Compute the side length