From a10fcf8eccd15bb4695aa557fd27ee40ed48b980 Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 27 Jul 2013 15:02:16 +0200 Subject: [PATCH] Small changes for debugging Cubiquity. --- library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h | 7 +++++++ library/PolyVoxCore/include/PolyVoxCore/Vector.inl | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h index 4500207e..191e34f4 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/TypeDef.h @@ -117,4 +117,11 @@ freely, subject to the following restrictions: #define polyvox_shared_ptr boost::shared_ptr #endif +//#define USE_LARGE_VOLUME +#ifdef USE_LARGE_VOLUME + #define POLYVOX_VOLUME LargeVolume +#else + #define POLYVOX_VOLUME SimpleVolume +#endif + #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/Vector.inl b/library/PolyVoxCore/include/PolyVoxCore/Vector.inl index a877fea0..7d7cd207 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Vector.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Vector.inl @@ -653,7 +653,10 @@ namespace PolyVox inline void Vector::normalise(void) { float fLength = this->length(); - if(fLength <= 0.0) + + // We could wait until the NAN occurs before throwing, but then we'd have to add some roll-back code. + // This seems like a lot of overhead for a common operation which should rarely go wrong. + if(fLength <= 0.0001) { POLYVOX_THROW(invalid_operation, "Cannot normalise a vector with a length of zero"); }