Index: /trunk/nv/base/cmath.hh
===================================================================
--- /trunk/nv/base/cmath.hh	(revision 451)
+++ /trunk/nv/base/cmath.hh	(revision 451)
@@ -0,0 +1,25 @@
+// Copyright (C) 2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of Nova libraries. 
+// For conditions of distribution and use, see copying.txt file in root folder.
+
+/**
+* @file capi.hh
+* @author Kornel Kisielewicz
+* @brief C math API functions
+*
+* This header might be temporary
+*/
+
+// TODO: sanity checking with NV_DEBUG_ASSERT
+
+#ifndef NV_BASE_CMATH_HH
+#define NV_BASE_CMATH_HH
+
+#include <nv/base/common.hh>
+
+#include <math.h>
+
+
+#endif // NV_BASE_CMATH_HH
Index: /trunk/nv/core/arcball.hh
===================================================================
--- /trunk/nv/core/arcball.hh	(revision 450)
+++ /trunk/nv/core/arcball.hh	(revision 451)
@@ -50,5 +50,5 @@
 			vec3 vb = get_arcball_vector( nposition );
 
-			m_angle = glm::acos( glm::min( 1.0f, glm::dot( va, vb ) ) );
+			m_angle = math::acos( glm::min( 1.0f, glm::dot( va, vb ) ) );
 			m_axis  = glm::cross( va, vb );
 			m_last  = nposition;
Index: /trunk/nv/core/random.hh
===================================================================
--- /trunk/nv/core/random.hh	(revision 450)
+++ /trunk/nv/core/random.hh	(revision 451)
@@ -78,7 +78,7 @@
 
 		template < typename T >
-		tvec2<T> range( tvec2<T> min, tvec2<T> max )
-		{
-			return tvec2<T>( 
+		math::tvec2<T> range( math::tvec2<T> min, math::tvec2<T> max )
+		{
+			return math::tvec2<T>(
 				range_impl( min.x, max.x, is_floating_point<T>() ), 
 				range_impl( min.y, max.y, is_floating_point<T>() )
@@ -87,7 +87,7 @@
 
 		template < typename T >
-		tvec3<T> range( tvec3<T> min, tvec3<T> max )
-		{
-			return tvec3<T>( 
+		math::tvec3<T> range( math::tvec3<T> min, math::tvec3<T> max )
+		{
+			return math::tvec3<T>(
 				range_impl( min.x, max.x, is_floating_point<T>() ), 
 				range_impl( min.y, max.y, is_floating_point<T>() ),
@@ -97,7 +97,7 @@
 
 		template < typename T >
-		tvec4<T> range( tvec4<T> min, tvec4<T> max )
-		{
-			return tvec4<T>( 
+		math::tvec4<T> range( math::tvec4<T> min, math::tvec4<T> max )
+		{
+			return math::tvec4<T>(
 				range_impl( min.x, max.x, is_floating_point<T>() ), 
 				range_impl( min.y, max.y, is_floating_point<T>() ),
Index: /trunk/nv/interface/camera.hh
===================================================================
--- /trunk/nv/interface/camera.hh	(revision 450)
+++ /trunk/nv/interface/camera.hh	(revision 451)
@@ -26,5 +26,5 @@
 		void set_lookat( const vec3& eye, const vec3& focus, const vec3& up )
 		{
-			m_view      = glm::lookAt( eye, focus, up );
+			m_view      = math::look_at( eye, focus, up );
 			m_position  = eye;
 			m_direction = glm::normalize( focus - eye );
@@ -33,9 +33,9 @@
 		void set_perspective( f32 fov, f32 aspect, f32 near, f32 far )
 		{
-			m_projection = glm::perspective( glm::radians( fov ), aspect, near, far );
+			m_projection = math::perspective( glm::radians( fov ), aspect, near, far );
 		}
 		void set_ortho( f32 left, f32 right, f32 bottom, f32 top, f32 near = -1.0f, f32 far = 1.0f )
 		{
-			m_projection = glm::ortho( left, right, bottom, top, near, far );
+			m_projection = math::ortho( left, right, bottom, top, near, far );
 		}
 		const mat4& get_projection() const 
@@ -81,5 +81,5 @@
 		mat4 get_view_inv()   const { return glm::inverse( get_view() ); }
 		mat4 get_model_inv()  const { return glm::inverse( get_model() ); }
-		mat3 get_normal()     const { return glm::transpose(glm::inverse(glm::mat3( get_modelview() ) ) ); }
+		mat3 get_normal()     const { return glm::transpose(glm::inverse( mat3( get_modelview() ) ) ); }
 	protected:
 		mat4   m_model;
Index: /trunk/nv/interface/interpolation_raw.hh
===================================================================
--- /trunk/nv/interface/interpolation_raw.hh	(revision 450)
+++ /trunk/nv/interface/interpolation_raw.hh	(revision 451)
@@ -68,7 +68,7 @@
 			{
 			case slot::TIME:        return mat4();
-			case slot::TRANSLATION: return glm::translate( mat4(), make_vec3( data ) );
+			case slot::TRANSLATION: return math::translate( mat4(), make_vec3( data ) );
 			case slot::ROTATION:    return mat4_cast( make_quat_fixed( data ) );
-			case slot::SCALE:       return glm::scale( mat4(),make_vec3( data ) );
+			case slot::SCALE:       return math::scale( mat4(),make_vec3( data ) );
 			case slot::TFORM:       return transform( make_vec3( data ), make_quat_fixed( data + 3 ) ).extract();
 			default:
@@ -88,9 +88,9 @@
 				case slot::TIME:     break;
 				case slot::TRANSLATION:
-					translation = glm::translate( translation,make_vec3( data + offset ) ); break;
+					translation = math::translate( translation,make_vec3( data + offset ) ); break;
 				case slot::ROTATION: 
 					rotation = mat4_cast( make_quat_fixed( data + offset ) ); break;
 				case slot::SCALE:    
-					scale    = glm::scale( mat4(),make_vec3( data + offset ) ); break;
+					scale    = math::scale( mat4(),make_vec3( data + offset ) ); break;
 				case slot::TFORM:    return transform( make_vec3( data + offset ), make_quat_fixed( data + offset + 3 ) ).extract();
 				default:
Index: /trunk/nv/stl/handle.hh
===================================================================
--- /trunk/nv/stl/handle.hh	(revision 450)
+++ /trunk/nv/stl/handle.hh	(revision 451)
@@ -165,4 +165,5 @@
 		T* insert( handle h )
 		{
+			NV_ASSERT( !exists( h ), "Reinserting handle!" );
 			resize_indexes_to( index_type( h.index() ) );
 			m_indexes[ h.index() ] = index_type( m_data.size() );
Index: /trunk/nv/stl/math.hh
===================================================================
--- /trunk/nv/stl/math.hh	(revision 450)
+++ /trunk/nv/stl/math.hh	(revision 451)
@@ -11,72 +11,10 @@
 
 #include <nv/common.hh>
-
-#if NV_COMPILER == NV_GNUC
-#pragma GCC system_header
-#elif NV_COMPILER == NV_CLANG
-#pragma clang system_header
-#endif
-
-#include <glm/glm.hpp>
-#include <glm/gtc/matrix_transform.hpp>
-#include <glm/gtc/type_ptr.hpp>
-#include <glm/gtc/quaternion.hpp>
-#include <glm/gtx/vector_angle.hpp>
-
-namespace nv
-{
-#if 0
-	template < typename T > using tvec2 = ::glm::detail::tvec2<T, glm::precision::highp>;
-	template < typename T > using tvec3 = ::glm::detail::tvec3<T, glm::precision::highp>;
-	template < typename T > using tvec4 = ::glm::detail::tvec4<T, glm::precision::highp>;
-	template < typename T > using tmat2 = ::glm::detail::tmat2x2<T, glm::precision::highp>;
-	template < typename T > using tmat3 = ::glm::detail::tmat3x3<T, glm::precision::highp>;
-	template < typename T > using tmat4 = ::glm::detail::tmat4x4<T, glm::precision::highp>;
-	template < typename T > using tquat = ::glm::detail::tmat4x4<T, glm::precision::highp>;
-#else
-	template < typename T > using tvec2 = ::glm::tvec2<T>;
-	template < typename T > using tvec3 = ::glm::tvec3<T>;
-	template < typename T > using tvec4 = ::glm::tvec4<T>;
-	template < typename T > using tmat2 = ::glm::tmat2x2<T>;
-	template < typename T > using tmat3 = ::glm::tmat3x3<T>;
-	template < typename T > using tmat4 = ::glm::tmat4x4<T>;
-	template < typename T > using tquat = ::glm::tmat4x4<T>;
-#endif
-
-	using ::glm::mat3_cast;
-	using ::glm::mat4_cast;
-	using ::glm::quat_cast;
-	using ::glm::make_vec2;
-	using ::glm::make_vec3;
-	using ::glm::make_vec4;
-	using ::glm::make_mat2;
-	using ::glm::make_mat3;
-	using ::glm::make_mat4;
-
-	typedef tvec2<sint8> i8vec2;
-	typedef tvec3<sint8> i8vec3;
-	typedef tvec4<sint8> i8vec4;
-
-	typedef tvec2<sint16> i16vec2;
-	typedef tvec3<sint16> i16vec3;
-	typedef tvec4<sint16> i16vec4;
-
-	typedef tvec2<uint8> u8vec2;
-	typedef tvec3<uint8> u8vec3;
-	typedef tvec4<uint8> u8vec4;
-
-	typedef tvec2< float > vec2;
-	typedef tvec3< float > vec3;
-	typedef tvec4< float > vec4;
-
-	typedef tvec2< int > ivec2;
-	typedef tvec3< int > ivec3;
-	typedef tvec4< int > ivec4;
-
-	typedef tmat2< float > mat2;
-	typedef tmat3< float > mat3;
-	typedef tmat4< float > mat4;
-
-	typedef glm::quat quat;
+#include <nv/stl/math/common.hh>
+#include <nv/stl/math/constants.hh>
+#include <nv/stl/math/matrix_transform.hh>
+#include <nv/stl/math/cast.hh>
+
+namespace nv {
 
 	template <typename T> 
@@ -89,7 +27,7 @@
 
 	template <typename T> 
-	struct datatype_traits< tvec2<T> > 
-	{
-		typedef tvec2<T> type;
+	struct datatype_traits< math::tvec2<T> > 
+	{
+		typedef math::tvec2<T> type;
 		typedef typename type::value_type base_type;
 		static const size_t size = 2;
@@ -97,7 +35,7 @@
 
 	template <typename T> 
-	struct datatype_traits< tvec3<T> > 
-	{
-		typedef tvec3<T> type;
+	struct datatype_traits< math::tvec3<T> >
+	{
+		typedef math::tvec3<T> type;
 		typedef typename type::value_type base_type;
 		static const size_t size = 3;
@@ -105,7 +43,7 @@
 
 	template <typename T> 
-	struct datatype_traits< tvec4<T> > 
-	{
-		typedef tvec4<T> type;
+	struct datatype_traits< math::tvec4<T> >
+	{
+		typedef math::tvec4<T> type;
 		typedef typename type::value_type base_type;
 		static const size_t size = 4;
@@ -282,10 +220,10 @@
 
 	template <typename T>
-	tvec3<T> normalize_safe( 
-		const tvec3<T>& x, 
-		const tvec3<T>& def = vec3()
+	math::tvec3<T> normalize_safe(
+		const math::tvec3<T>& x,
+		const math::tvec3<T>& def = vec3()
 	)
 	{
-		typename tvec3<T>::value_type sqr = x.x * x.x + x.y * x.y + x.z * x.z;
+		typename math::tvec3<T>::value_type sqr = x.x * x.x + x.y * x.y + x.z * x.z;
 		return ( sqr > 0 ? x * glm::inversesqrt(sqr) : def );
 	}
Index: /trunk/nv/stl/math/cast.hh
===================================================================
--- /trunk/nv/stl/math/cast.hh	(revision 451)
+++ /trunk/nv/stl/math/cast.hh	(revision 451)
@@ -0,0 +1,164 @@
+// Copyright (C) 2015-2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of Nova libraries. 
+// For conditions of distribution and use, see copying.txt file in root folder.
+
+/**
+ * @file common.hh
+ * @author Kornel Kisielewicz epyon@chaosforge.org
+ * @brief math casts
+ */
+
+#ifndef NV_STL_MATH_CAST_HH
+#define NV_STL_MATH_CAST_HH
+
+#include <nv/stl/math/common.hh>
+#include <nv/base/capi.hh>
+
+namespace nv
+{
+
+	template < typename T >
+	inline const T* data_cast( const math::tvec2< T >& v )
+	{
+		return &( v.x );
+	}
+
+	template < typename T >
+	inline T* data_cast( math::tvec2< T >& v )
+	{
+		return &( v.x );
+	}
+
+	template < typename T >
+	inline const T* data_cast( const math::tvec3< T >& v )
+	{
+		return &( v.x );
+	}
+
+	template < typename T >
+	inline T* data_cast( math::tvec3< T >& v )
+	{
+		return &( v.x );
+	}
+
+	template < typename T >
+	inline const T* data_cast( const math::tvec4< T >& v )
+	{
+		return &( v.x );
+	}
+
+	template < typename T >
+	inline T* data_cast( math::tvec4< T >& v )
+	{
+		return &( v.x );
+	}
+
+	template < typename T >
+	inline const T* data_cast( const math::tmat2< T >& m )
+	{
+		return &( m[0].x );
+	}
+
+	template < typename T >
+	inline T* data_cast( math::tmat2< T >& m )
+	{
+		return &( m[0].x );
+	}
+
+	template < typename T >
+	inline const T* data_cast( const math::tmat3< T >& m )
+	{
+		return &( m[0].x );
+	}
+
+	template < typename T >
+	inline T* data_cast( math::tmat3< T >& m )
+	{
+		return &( m[0].x );
+	}
+
+	template < typename T >
+	inline const T* data_cast( const math::tmat4< T >& m )
+	{
+		return &( m[0].x );
+	}
+
+	template < typename T >
+	inline T* data_cast( math::tmat4< T >& m )
+	{
+		return &( m[0].x );
+	}
+
+	template < typename T >
+	inline const T* data_cast( const math::tquat< T >& q )
+	{
+		return &( q[0] );
+	}
+
+	template < typename T >
+	inline T* data_cast( math::tquat< T >& q )
+	{
+		return &( q[0] );
+	}
+
+	template < typename T >
+	inline math::tvec2<T> make_vec2( const T * const ptr )
+	{
+		math::tvec2<T> result( math::ctor::uninitialize );
+		nvmemcpy( data_cast( result ), ptr, sizeof( math::tvec2<T> ) );
+		return result;
+	}
+
+	template < typename T >
+	inline math::tvec3<T> make_vec3( const T * const ptr )
+	{
+		math::tvec3<T> result( math::ctor::uninitialize );
+		nvmemcpy( data_cast( result ), ptr, sizeof( math::tvec3<T> ) );
+		return result;
+	}
+
+	template < typename T >
+	inline math::tvec4<T> make_vec4( const T * const ptr )
+	{
+		math::tvec4<T> result( math::ctor::uninitialize );
+		nvmemcpy( data_cast( result ), ptr, sizeof( math::tvec4<T> ) );
+		return result;
+	}
+
+	template < typename T >
+	inline math::tmat2<T> make_mat2( const T * const ptr )
+	{
+		math::tmat2<T> result( math::ctor::uninitialize );
+		nvmemcpy( data_cast( result ), ptr, sizeof( math::tmat2<T> ) );
+		return result;
+	}
+
+	template < typename T >
+	inline math::tmat3<T> make_mat3( const T * const ptr )
+	{
+		math::tmat3<T> result( math::ctor::uninitialize );
+		nvmemcpy( data_cast( result ), ptr, sizeof( math::tmat3<T> ) );
+		return result;
+	}
+
+	template < typename T >
+	inline math::tmat4<T> make_mat4( const T * const ptr )
+	{
+		math::tmat4<T> result( math::ctor::uninitialize );
+		nvmemcpy( data_cast( result ), ptr, sizeof( math::tmat4<T> ) );
+		return result;
+	}
+
+	template < typename T >
+	inline math::tquat<T> make_quat( const T * const ptr )
+	{
+		math::tquat<T> result( math::ctor::uninitialize );
+		nvmemcpy( data_cast( result ), ptr, sizeof( math::tquat<T> ) );
+		return result;
+	}
+
+}
+
+#endif // NV_STL_MATH_COMMON_HH
Index: /trunk/nv/stl/math/common.hh
===================================================================
--- /trunk/nv/stl/math/common.hh	(revision 451)
+++ /trunk/nv/stl/math/common.hh	(revision 451)
@@ -0,0 +1,96 @@
+// Copyright (C) 2015-2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of Nova libraries. 
+// For conditions of distribution and use, see copying.txt file in root folder.
+
+/**
+* @file common.hh
+* @author Kornel Kisielewicz epyon@chaosforge.org
+* @brief math common
+*/
+
+#ifndef NV_STL_MATH_COMMON_HH
+#define NV_STL_MATH_COMMON_HH
+
+#include <nv/common.hh>
+
+#if NV_COMPILER == NV_GNUC
+#pragma GCC system_header
+#elif NV_COMPILER == NV_CLANG
+#pragma clang system_header
+#endif
+
+#include <nv/base/cmath.hh>
+#include <glm/glm.hpp>
+#include <glm/gtc/quaternion.hpp>
+#include <glm/gtx/vector_angle.hpp>
+
+namespace nv
+{
+
+	namespace math
+	{
+		using ::cos;
+		using ::sin;
+		using ::acos;
+		using ::asin;
+		using ::cosh;
+		using ::sinh;
+		using ::abs;
+		using ::tan;
+		using ::sqrt;
+		using ::pow;
+		using ::floor;
+		using ::ceil;
+#if 0
+		template < typename T > using tvec2 = ::glm::detail::tvec2<T, glm::precision::highp>;
+		template < typename T > using tvec3 = ::glm::detail::tvec3<T, glm::precision::highp>;
+		template < typename T > using tvec4 = ::glm::detail::tvec4<T, glm::precision::highp>;
+		template < typename T > using tmat2 = ::glm::detail::tmat2x2<T, glm::precision::highp>;
+		template < typename T > using tmat3 = ::glm::detail::tmat3x3<T, glm::precision::highp>;
+		template < typename T > using tmat4 = ::glm::detail::tmat4x4<T, glm::precision::highp>;
+		template < typename T > using tquat = ::glm::detail::tmat4x4<T, glm::precision::highp>;
+#else
+		template < typename T > using tvec2 = ::glm::tvec2<T>;
+		template < typename T > using tvec3 = ::glm::tvec3<T>;
+		template < typename T > using tvec4 = ::glm::tvec4<T>;
+		template < typename T > using tmat2 = ::glm::tmat2x2<T>;
+		template < typename T > using tmat3 = ::glm::tmat3x3<T>;
+		template < typename T > using tmat4 = ::glm::tmat4x4<T>;
+		template < typename T > using tquat = ::glm::tquat<T,glm::highp>;
+#endif
+
+		typedef glm::quat quat;
+		using glm::ctor;
+	}
+
+	typedef math::tvec2<sint8> i8vec2;
+	typedef math::tvec3<sint8> i8vec3;
+	typedef math::tvec4<sint8> i8vec4;
+
+	typedef math::tvec2<sint16> i16vec2;
+	typedef math::tvec3<sint16> i16vec3;
+	typedef math::tvec4<sint16> i16vec4;
+
+	typedef math::tvec2<uint8> u8vec2;
+	typedef math::tvec3<uint8> u8vec3;
+	typedef math::tvec4<uint8> u8vec4;
+
+	typedef math::tvec2< float > vec2;
+	typedef math::tvec3< float > vec3;
+	typedef math::tvec4< float > vec4;
+
+	typedef math::tvec2< int > ivec2;
+	typedef math::tvec3< int > ivec3;
+	typedef math::tvec4< int > ivec4;
+
+	typedef math::tmat2< float > mat2;
+	typedef math::tmat3< float > mat3;
+	typedef math::tmat4< float > mat4;
+
+	typedef math::quat quat;
+
+}
+
+#endif // NV_STL_MATH_COMMON_HH
Index: /trunk/nv/stl/math/constants.hh
===================================================================
--- /trunk/nv/stl/math/constants.hh	(revision 451)
+++ /trunk/nv/stl/math/constants.hh	(revision 451)
@@ -0,0 +1,202 @@
+// Copyright (C) 2015-2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of Nova libraries. 
+// For conditions of distribution and use, see copying.txt file in root folder.
+
+/**
+* @file common.hh
+* @author Kornel Kisielewicz epyon@chaosforge.org
+* @brief math constants
+*/
+
+#ifndef NV_STL_MATH_CONSTANTS_HH
+#define NV_STL_MATH_CONSTANTS_HH
+
+#include <nv/stl/math/common.hh>
+#include <nv/stl/limits.hh>
+
+namespace nv
+{
+	
+	namespace math
+	{
+		// TODO: change to variable templates when C++14 is out
+		template < typename T >
+		constexpr T epsilon()
+		{
+			return nv::numeric_limits<T>::epsilon();
+		}
+
+		template < typename T >
+		constexpr T zero()
+		{
+			return T( 0 );
+		}
+
+		template < typename T >
+		constexpr T one()
+		{
+			return T( 1 );
+		}
+
+		template < typename T >
+		constexpr T pi()
+		{
+			return T( 3.14159265358979323846264338327950288 );
+		}
+
+		template < typename T >
+		constexpr T two_pi()
+		{
+			return T( 6.28318530717958647692528676655900576 );
+		}
+
+		template < typename T >
+		constexpr T root_pi()
+		{
+			return T( 1.772453850905516027 );
+		}
+
+		template < typename T >
+		constexpr T half_pi()
+		{
+			return T( 1.57079632679489661923132169163975144 );
+		}
+
+		template < typename T >
+		constexpr T three_over_two_pi()
+		{
+			return T( 4.71238898038468985769396507491925432 );
+		}
+
+		template < typename T >
+		constexpr T quarter_pi()
+		{
+			return T( 0.785398163397448309615660845819875721 );
+		}
+
+		template < typename T >
+		constexpr T one_over_pi()
+		{
+			return T( 0.318309886183790671537767526745028724 );
+		}
+
+		template < typename T >
+		constexpr T one_over_two_pi()
+		{
+			return T( 0.159154943091895335768883763372514362 );
+		}
+
+		template < typename T >
+		constexpr T two_over_pi()
+		{
+			return T( 0.636619772367581343075535053490057448 );
+		}
+
+		template < typename T >
+		constexpr T four_over_pi()
+		{
+			return T( 1.273239544735162686151070106980114898 );
+		}
+
+		template < typename T >
+		constexpr T two_over_root_pi()
+		{
+			return T( 1.12837916709551257389615890312154517 );
+		}
+
+		template < typename T >
+		constexpr T one_over_root_two()
+		{
+			return T( 0.707106781186547524400844362104849039 );
+		}
+
+		template < typename T >
+		constexpr T root_half_pi()
+		{
+			return T( 1.253314137315500251 );
+		}
+
+		template < typename T >
+		constexpr T root_two_pi()
+		{
+			return T( 2.506628274631000502 );
+		}
+
+		template < typename T >
+		constexpr T root_ln_four()
+		{
+			return T( 1.17741002251547469 );
+		}
+
+		template < typename T >
+		constexpr T e()
+		{
+			return T( 2.71828182845904523536 );
+		}
+
+		template < typename T >
+		constexpr T euler()
+		{
+			return T( 0.577215664901532860606 );
+		}
+
+		template < typename T >
+		constexpr T root_two()
+		{
+			return T( 1.41421356237309504880168872420969808 );
+		}
+
+		template < typename T >
+		constexpr T root_three()
+		{
+			return T( 1.73205080756887729352744634150587236 );
+		}
+
+		template < typename T >
+		constexpr T root_five()
+		{
+			return T( 2.23606797749978969640917366873127623 );
+		}
+
+		template < typename T >
+		constexpr T ln_two()
+		{
+			return T( 0.693147180559945309417232121458176568 );
+		}
+
+		template < typename T >
+		constexpr T ln_ten()
+		{
+			return T( 2.30258509299404568401799145468436421 );
+		}
+
+		template < typename T >
+		constexpr T ln_ln_two()
+		{
+			return T( -0.3665129205816643 );
+		}
+
+		template < typename T >
+		constexpr T third()
+		{
+			return T( 0.3333333333333333333333333333333333333333 );
+		}
+
+		template < typename T >
+		constexpr T two_thirds()
+		{
+			return T( 0.666666666666666666666666666666666666667 );
+		}
+
+		template < typename T >
+		constexpr T golden_ratio()
+		{
+			return T( 1.61803398874989484820458683436563811 );
+		}
+
+	}
+}
+
+#endif // NV_STL_MATH_CONSTANTS_HH
Index: /trunk/nv/stl/math/matrix_transform.hh
===================================================================
--- /trunk/nv/stl/math/matrix_transform.hh	(revision 451)
+++ /trunk/nv/stl/math/matrix_transform.hh	(revision 451)
@@ -0,0 +1,240 @@
+// Copyright (C) 2015-2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of Nova libraries. 
+// For conditions of distribution and use, see copying.txt file in root folder.
+
+/**
+* @file common.hh
+* @author Kornel Kisielewicz epyon@chaosforge.org
+* @brief transform matrices
+*/
+
+#ifndef NV_STL_MATH_MATRIX_TRANSFORM_HH
+#define NV_STL_MATH_MATRIX_TRANSFORM_HH
+
+#include <nv/stl/math/common.hh>
+#include <nv/stl/math/constants.hh>
+
+namespace nv
+{
+	namespace math
+	{
+
+		template < typename T >
+		inline tmat4<T> translate( const tmat4<T>& m, const tvec3<T>& v )
+		{
+			tmat4<T> result( m );
+			result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3];
+			return result;
+		}
+
+		template < typename T >
+		inline tmat4<T> rotate( const tmat4<T>& m, T angle, const tvec3<T>& v )
+		{
+			T const a = angle;
+			T const c = math::cos( a );
+			T const s = math::sin( a );
+
+			tvec3<T> axis( glm::normalize( v ) );
+			tvec3<T> temp( ( T( 1 ) - c ) * axis );
+
+			tmat4<T> Rotate( ctor::uninitialize );
+			Rotate[0][0] = c + temp[0] * axis[0];
+			Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2];
+			Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1];
+
+			Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2];
+			Rotate[1][1] = c + temp[1] * axis[1];
+			Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0];
+
+			Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1];
+			Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0];
+			Rotate[2][2] = c + temp[2] * axis[2];
+
+			tmat4<T> result( ctor::uninitialize );
+			result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2];
+			result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2];
+			result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2];
+			result[3] = m[3];
+			return result;
+		}
+
+		template < typename T >
+		inline tmat4<T> scale( const tmat4<T>& m, const tvec3<T>& v )
+		{
+			tmat4<T> result( ctor::uninitialize );
+			result[0] = m[0] * v[0];
+			result[1] = m[1] * v[1];
+			result[2] = m[2] * v[2];
+			result[3] = m[3];
+			return result;
+		}
+
+		template < typename T>
+		inline tmat4<T> ortho( T left, T right, T bottom, T top, T z_near, T z_far )
+		{
+			tmat4<T> result( 1 );
+			result[0][0] =  static_cast<T>( 2 ) / ( right - left );
+			result[1][1] =  static_cast<T>( 2 ) / ( top - bottom );
+			result[2][2] = -static_cast<T>( 2 ) / ( z_far - z_near );
+			result[3][0] = -( right + left ) / ( right - left );
+			result[3][1] = -( top + bottom ) / ( top - bottom );
+			result[3][2] = -( z_far + z_near ) / ( z_far - z_near );
+			return result;
+		}
+
+		template < typename T >
+		inline tmat4<T> ortho( T left, T right, T bottom, T top )
+		{
+			tmat4<T> result( 1 );
+			result[0][0] =  static_cast<T>( 2 ) / ( right - left );
+			result[1][1] =  static_cast<T>( 2 ) / ( top - bottom );
+			result[2][2] = -static_cast<T>( 1 );
+			result[3][0] = -( right + left ) / ( right - left );
+			result[3][1] = -( top + bottom ) / ( top - bottom );
+			return result;
+		}
+
+		template < typename T >
+		inline tmat4<T> frustum( T left, T right, T bottom, T top, T near_val, T far_val )
+		{
+			tmat4<T> result( 0 );
+			result[0][0] = ( static_cast<T>( 2 ) * near_val ) / ( right - left );
+			result[1][1] = ( static_cast<T>( 2 ) * near_val ) / ( top - bottom );
+			result[2][0] = ( right + left ) / ( right - left );
+			result[2][1] = ( top + bottom ) / ( top - bottom );
+			result[2][2] = -( far_val + near_val ) / ( far_val - near_val );
+			result[2][3] = static_cast<T>( -1 );
+			result[3][2] = -( static_cast<T>( 2 ) * far_val * near_val ) / ( far_val - near_val );
+			return result;
+		}
+
+		template < typename T >
+		inline tmat4<T> perspective( T fovy, T aspect, T z_near, T z_far )
+		{
+			NV_ASSERT( abs( aspect - epsilon<T>() ) > static_cast<T>( 0 ), "bad parameters to math::perspective!" );
+
+			const T tan_half_fovy = math::tan( fovy / static_cast<T>( 2 ) );
+
+			tmat4<T> result( static_cast<T>( 0 ) );
+			result[0][0] = static_cast<T>( 1 ) / ( aspect * tan_half_fovy );
+			result[1][1] = static_cast<T>( 1 ) / ( tan_half_fovy );
+			result[2][2] = -( z_far + z_near ) / ( z_far - z_near );
+			result[2][3] = -static_cast<T>( 1 );
+			result[3][2] = -( static_cast<T>( 2 ) * z_far * z_near ) / ( z_far - z_near );
+			return result;
+		}
+
+		template < typename T >
+		inline tmat4<T> perspective_fov( T fov, T width, T height, T z_near, T z_far )
+		{
+			NV_ASSERT( width > static_cast<T>( 0 ), "bad parameters to math::perspective_fov!" );
+			NV_ASSERT( height > static_cast<T>( 0 ), "bad parameters to math::perspective_fov!" );
+			NV_ASSERT( fov > static_cast<T>( 0 ), "bad parameters to math::perspective_fov!" );
+
+			const T rad = fov;
+			const T h = math::cos( static_cast<T>( 0.5 ) * rad ) / math::sin( static_cast<T>( 0.5 ) * rad );
+			const T w = h * height / width; 
+
+			tmat4<T> result( static_cast<T>( 0 ) );
+			result[0][0] = w;
+			result[1][1] = h;
+			result[2][2] = -( z_far + z_near ) / ( z_far - z_near );
+			result[2][3] = -static_cast<T>( 1 );
+			result[3][2] = -( static_cast<T>( 2 ) * z_far * z_near ) / ( z_far - z_near );
+			return result;
+		}
+
+		template < typename T >
+		inline tmat4<T> infinite_perspective( T fovy, T aspect, T z_near, T ep = epsilon<T>() )
+		{
+			const T range  = math::tan( fovy / T( 2 ) ) * z_near;
+			const T left   = -range * aspect;
+			const T right  = range * aspect;
+			const T bottom = -range;
+			const T top    = range;
+
+			tmat4<T> result( T( 0 ) );
+			result[0][0] = ( static_cast<T>( 2 ) * zNear ) / ( right - left );
+			result[1][1] = ( static_cast<T>( 2 ) * zNear ) / ( top - bottom );
+			result[2][2] = ep - static_cast<T>( 1 );
+			result[2][3] = static_cast<T>( -1 );
+			result[3][2] = ( ep - static_cast<T>( 2 ) ) * z_near;
+			return result;
+		}
+
+		template <typename T, typename U >
+		inline tvec3<T> project( const tvec3<T>& obj, const tmat4<T>& model, const tmat4<T>& proj, const tvec4<U>& viewport )
+		{
+			tvec4<T> result = tvec4<T>( obj, T( 1 ) );
+			result = model * result;
+			result = proj * result;
+
+			result /= result.w;
+			result = result * T( 0.5 ) + T( 0.5 );
+			result[0] = result[0] * T( viewport[2] ) + T( viewport[0] );
+			result[1] = result[1] * T( viewport[3] ) + T( viewport[1] );
+
+			return tvec3<T>( result );
+		}
+
+		template <typename T, typename U >
+		inline tvec3<T> unproject( const tvec3<T>& win, const tmat4<T>& model, const tmat4<T>& proj, const tvec4<U>& viewport )
+		{
+			tmat4<T> invp = glm::inverse( proj * model );
+
+			tvec4<T> temp = tvec4<T>( win, T( 1 ) );
+			temp.x = ( temp.x - T( viewport[0] ) ) / T( viewport[2] );
+			temp.y = ( temp.y - T( viewport[1] ) ) / T( viewport[3] );
+			temp = temp * T( 2 ) - T( 1 );
+
+			tvec4<T> result = invp * temp;
+			result /= result.w;
+			return tvec3<T>( result );
+		}
+
+		template <typename T , typename U>
+		inline tmat4<T> pick_matrix( const tvec2<T>& center, const tvec2<T>& delta, const tvec4<U>& viewport )
+		{
+			NV_ASSERT( delta.x > T( 0 ) && delta.y > T( 0 ), "bad delta passed to pick_matrix!" );
+			if ( !( delta.x > T( 0 ) && delta.y > T( 0 ) ) ) return result;
+
+			tmat4<T> result( 1 );
+			tvec3<T> temp(
+				( T( viewport[2] ) - T( 2 ) * ( center.x - T( viewport[0] ) ) ) / delta.x,
+				( T( viewport[3] ) - T( 2 ) * ( center.y - T( viewport[1] ) ) ) / delta.y,
+				T( 0 )
+			);
+
+			result = translate( result, temp );
+			return scale( result, tvec3<T>( T( viewport[2] ) / delta.x, T( viewport[3] ) / delta.y, T( 1 ) ) );
+		}
+
+		template <typename T >
+		inline tmat4<T> look_at( const tvec3<T>& eye, const tvec3<T>& center, const tvec3<T>& up )
+		{
+			const tvec3<T> f( glm::normalize( center - eye ) );
+			const tvec3<T> s( glm::normalize( glm::cross( f, up ) ) );
+			const tvec3<T> u( glm::cross( s, f ) );
+
+			tmat4<T> result( 1 );
+			result[0][0] = s.x;
+			result[1][0] = s.y;
+			result[2][0] = s.z;
+			result[0][1] = u.x;
+			result[1][1] = u.y;
+			result[2][1] = u.z;
+			result[0][2] = -f.x;
+			result[1][2] = -f.y;
+			result[2][2] = -f.z;
+			result[3][0] = -glm::dot( s, eye );
+			result[3][1] = -glm::dot( u, eye );
+			result[3][2] = glm::dot( f, eye );
+			return result;
+		}
+
+	}
+}
+
+#endif // NV_STL_MATH_MATRIX_TRANSFORM_HH
Index: /trunk/nv/stl/range.hh
===================================================================
--- /trunk/nv/stl/range.hh	(revision 450)
+++ /trunk/nv/stl/range.hh	(revision 451)
@@ -66,11 +66,11 @@
 		template < typename T >
 		class range2d_iterator_base 
-			: public forward_iterator_base< tvec2<T> >
-		{
-		public:
-			typedef forward_iterator_base< tvec2<T> > base_class;
-
-			range2d_iterator_base( tvec2<T> value, T min, T max ) 
-				: forward_iterator_base< tvec2<T> >( value ), m_min(min), m_max(max) {}
+			: public forward_iterator_base< math::tvec2<T> >
+		{
+		public:
+			typedef forward_iterator_base< math::tvec2<T> > base_class;
+
+			range2d_iterator_base( math::tvec2<T> value, T min, T max )
+				: forward_iterator_base< math::tvec2<T> >( value ), m_min(min), m_max(max) {}
 			range2d_iterator_base& operator++ () 
 			{
Index: /trunk/src/core/random.cc
===================================================================
--- /trunk/src/core/random.cc	(revision 450)
+++ /trunk/src/core/random.cc	(revision 451)
@@ -110,16 +110,16 @@
 nv::vec2 nv::random::precise_unit_vec2()
 {
-	float angle = frand( glm::pi<float>() * 2.f );
-	return vec2( glm::cos( angle ), glm::sin( angle ) );
+	f32 angle = frand( math::pi<f32>() * 2.f );
+	return vec2( math::cos( angle ), math::sin( angle ) );
 }
 
 nv::vec3 nv::random::precise_unit_vec3()
 {
-	float cos_theta = frange( -1.0f, 1.0f );
-	float sin_theta = glm::sqrt( 1.0f - cos_theta * cos_theta );
-	float phi       = frand( 2 * glm::pi<float>() );
+	f32 cos_theta = frange( -1.0f, 1.0f );
+	f32 sin_theta = math::sqrt( 1.0f - cos_theta * cos_theta );
+	f32 phi       = frand( 2 * math::pi<f32>() );
 	return vec3( 
-		sin_theta * glm::sin(phi),
-		sin_theta * glm::cos(phi),
+		sin_theta * math::sin(phi),
+		sin_theta * math::cos(phi),
 		cos_theta
 		);
@@ -128,29 +128,29 @@
 nv::vec2 nv::random::fast_disk_point()
 {
-	float r1 = frand();
-	float r2 = frand();
+	f32 r1 = frand();
+	f32 r2 = frand();
 	if ( r1 > r2 ) swap( r1, r2 );
-	float rf = 2*glm::pi<float>()*(r1/r2);
-	return vec2( r2*glm::cos( rf ), r2*glm::sin( rf ) );
+	f32 rf = 2* math::pi<f32>()*(r1/r2);
+	return vec2( r2*math::cos( rf ), r2*math::sin( rf ) );
 }
 
 nv::vec2 nv::random::precise_disk_point()
 {
-	float r = glm::sqrt( frand() );
-	float rangle = frand( glm::pi<float>() );
-	return vec2( r*glm::cos( rangle ), r*glm::sin( rangle ) );
+	f32 r = math::sqrt( frand() );
+	f32 rangle = frand( math::pi<f32>() );
+	return vec2( r*math::cos( rangle ), r*math::sin( rangle ) );
 }
 
 nv::vec3 nv::random::fast_sphere_point()
 {
-	float rad     = frand();
-	float pi      = glm::pi<float>();
-	float phi     = glm::asin( frange( -1.0f, 1.0f ) ) + pi*.5f;
-	float theta   = frange( 0.0f, 2 * glm::pi<float>() );
-	float sin_phi = glm::sin( phi );
+	f32 rad     = frand();
+	f32 pi      = math::pi<f32>();
+	f32 phi     = math::asin( frange( -1.0f, 1.0f ) ) + pi*.5f;
+	f32 theta   = frange( 0.0f, 2 * math::pi<f32>() );
+	f32 sin_phi = math::sin( phi );
 	return vec3( 
-		rad * glm::cos(theta) * sin_phi,
-		rad * glm::sin(theta) * sin_phi,
-		rad * glm::cos(phi)
+		rad * math::cos(theta) * sin_phi,
+		rad * math::sin(theta) * sin_phi,
+		rad * math::cos(phi)
 	);
 }
@@ -158,11 +158,11 @@
 nv::vec3 nv::random::precise_sphere_point()
 {
-	float radius = glm::pow( frand(), 1.f/3.f );
-	float cos_theta = frange( -1.0f, 1.0f );
-	float sin_theta = glm::sqrt( 1.0f - cos_theta * cos_theta );
-	float phi       = frange( 0.0f, 2 * glm::pi<float>() );
+	f32 radius = math::pow( frand(), 1.f/3.f );
+	f32 cos_theta = frange( -1.0f, 1.0f );
+	f32 sin_theta = math::sqrt( 1.0f - cos_theta * cos_theta );
+	f32 phi       = frange( 0.0f, 2 * math::pi<f32>() );
 	return vec3( 
-		radius * sin_theta * glm::sin(phi),
-		radius * sin_theta * glm::cos(phi),
+		radius * sin_theta * math::sin(phi),
+		radius * sin_theta * math::cos(phi),
 		radius * cos_theta
 		);
@@ -199,26 +199,26 @@
 }
 
-nv::vec2 nv::random::fast_hollow_disk_point( float iradius, float oradius )
-{
-	float idist2 = iradius * iradius;
-	float odist2 = oradius * oradius;
-	float rdist  = glm::sqrt( frange( idist2, odist2 ) );
+nv::vec2 nv::random::fast_hollow_disk_point( f32 iradius, f32 oradius )
+{
+	f32 idist2 = iradius * iradius;
+	f32 odist2 = oradius * oradius;
+	f32 rdist  = math::sqrt( frange( idist2, odist2 ) );
 	return rdist * precise_unit_vec2();
 }
 
-nv::vec2 nv::random::precise_hollow_disk_point( float iradius, float oradius )
+nv::vec2 nv::random::precise_hollow_disk_point( f32 iradius, f32 oradius )
 {
 	return fast_hollow_disk_point( iradius, oradius );
 }
 
-nv::vec3 nv::random::fast_hollow_sphere_point( float iradius, float oradius )
-{
-	float idist3 = iradius * iradius * iradius;
-	float odist3 = oradius * oradius * oradius;
-	float rdist  = glm::pow( frange( idist3, odist3 ), 1.f/3.f );
+nv::vec3 nv::random::fast_hollow_sphere_point( f32 iradius, f32 oradius )
+{
+	f32 idist3 = iradius * iradius * iradius;
+	f32 odist3 = oradius * oradius * oradius;
+	f32 rdist  = math::pow( frange( idist3, odist3 ), 1.f/3.f );
 	return rdist * precise_unit_vec3();
 }
 
-nv::vec3 nv::random::precise_hollow_sphere_point( float iradius, float oradius )
+nv::vec3 nv::random::precise_hollow_sphere_point( f32 iradius, f32 oradius )
 {
 	return fast_hollow_sphere_point( iradius, oradius );
@@ -232,10 +232,10 @@
 	vec2 opoint2    = opoint * opoint;
 	vec2 odir       = glm::normalize( opoint );
-	float odist2    = opoint2.x + opoint2.y;
-
-	float low    = iradii2.y * opoint2.x + iradii2.x * opoint2.y;
-	float idist2 = ((iradii2.x * iradii2.y) / low ) * odist2;
-
-	float rdist     = glm::sqrt( frange( idist2, odist2 ) );
+	f32 odist2    = opoint2.x + opoint2.y;
+
+	f32 low    = iradii2.y * opoint2.x + iradii2.x * opoint2.y;
+	f32 idist2 = ((iradii2.x * iradii2.y) / low ) * odist2;
+
+	f32 rdist     = math::sqrt( frange( idist2, odist2 ) );
 	return odir * rdist;	
 }
@@ -252,16 +252,16 @@
 	vec3 opoint2    = opoint * opoint;
 	vec3 odir       = glm::normalize( opoint );
-	float odist2    = opoint2.x + opoint2.y + opoint2.z;
-
-	float low    = 
+	f32 odist2    = opoint2.x + opoint2.y + opoint2.z;
+
+	f32 low    = 
 		iradii2.y * iradii2.z * opoint2.x + 
 		iradii2.x * iradii2.z * opoint2.y +
 		iradii2.x * iradii2.y * opoint2.z;
-	float idist2 = ((iradii2.x * iradii2.y * iradii2.z) / low ) * odist2;
-
-	float odist3 = odist2 * glm::sqrt( odist2 );
-	float idist3 = idist2 * glm::sqrt( idist2 );
-
-	float rdist     = glm::pow( frange( idist3, odist3 ), 1.f/3.f );
+	f32 idist2 = ((iradii2.x * iradii2.y * iradii2.z) / low ) * odist2;
+
+	f32 odist3 = odist2 * math::sqrt( odist2 );
+	f32 idist3 = idist2 * math::sqrt( idist2 );
+
+	f32 rdist     = math::pow( frange( idist3, odist3 ), 1.f/3.f );
 	return odir * rdist;	
 }
Index: /trunk/src/engine/particle_engine.cc
===================================================================
--- /trunk/src/engine/particle_engine.cc	(revision 450)
+++ /trunk/src/engine/particle_engine.cc	(revision 451)
@@ -231,5 +231,5 @@
 	datap->plane_normal = normalize_safe( datap->plane_normal, vec3(0.0f,1.0f,0.0f) );
 	datap->bounce       = table->get<float>("bounce", 0.0f );
-	datap->distance     = -glm::dot( datap->plane_normal, datap->plane_point ) / glm::sqrt(glm::dot( datap->plane_normal, datap->plane_normal ) );
+	datap->distance     = -glm::dot( datap->plane_normal, datap->plane_point ) / math::sqrt(glm::dot( datap->plane_normal, datap->plane_normal ) );
 	return true;
 }
@@ -411,5 +411,5 @@
 				edata.dir          = glm::normalize( element.get<vec3>("direction", vec3(0,1,0) ) );
 				
-				edata.odir = glm::vec3( 0, 0, 1 );
+				edata.odir = vec3( 0, 0, 1 );
 				if ( edata.dir != vec3( 0, 1, 0 ) && edata.dir != vec3( 0, -1, 0 ) )
 					edata.odir = glm::normalize( glm::cross( edata.dir, vec3( 0, 1, 0 ) ) );		edata.cdir = glm::cross( edata.dir, edata.odir );
@@ -750,10 +750,10 @@
 					{
 						float emission_angle = glm::radians( edata.angle );
-						float cos_theta = r.frange( glm::cos( emission_angle ), 1.0f );
-						float sin_theta = glm::sqrt(1.0f - cos_theta * cos_theta );
-						float phi       = r.frange( 0.0f, 2*glm::pi<float>() );
+						float cos_theta = r.frange( math::cos( emission_angle ), 1.0f );
+						float sin_theta = math::sqrt(1.0f - cos_theta * cos_theta );
+						float phi       = r.frange( 0.0f, 2* math::pi<float>() );
 						pinfo.velocity  = orient * 
-							( edata.odir * ( glm::cos(phi) * sin_theta ) +
-							edata.cdir * ( glm::sin(phi)*sin_theta ) + 
+							( edata.odir * ( math::cos(phi) * sin_theta ) +
+							edata.cdir * ( math::sin(phi)*sin_theta ) +
 							edata.dir  * cos_theta );
 					}
Index: /trunk/src/formats/assimp_loader.cc
===================================================================
--- /trunk/src/formats/assimp_loader.cc	(revision 450)
+++ /trunk/src/formats/assimp_loader.cc	(revision 451)
@@ -139,5 +139,5 @@
 			vec2 s = assimp_st_cast( mesh->mTextureCoords[0][i] );
 
-			glm::vec3 t_i = glm::normalize( t - n * glm::dot( n, t ) );
+			vec3 t_i = glm::normalize( t - n * glm::dot( n, t ) );
 			float det = ( glm::dot( glm::cross( n, t ), b ) );
 			det = ( det < 0.0f ? -1.0f : 1.0f );
@@ -440,6 +440,6 @@
 // 	if ( node->mNumScalingKeys > 0 )
 // 	{
-// 		nv::vec3 scale_vec0 = assimp_vec3_cast( node->mScalingKeys[0].mValue );
-// 		float scale_value   = glm::length( glm::abs( scale_vec0 - nv::vec3(1,1,1) ) );
+// 		vec3 scale_vec0 = assimp_vec3_cast( node->mScalingKeys[0].mValue );
+// 		float scale_value   = glm::length( math::abs( scale_vec0 - vec3(1,1,1) ) );
 // 		if ( node->mNumScalingKeys > 1 || scale_value > 0.001 ) 
 // 		{
Index: /trunk/src/formats/md3_loader.cc
===================================================================
--- /trunk/src/formats/md3_loader.cc	(revision 450)
+++ /trunk/src/formats/md3_loader.cc	(revision 451)
@@ -240,5 +240,5 @@
 	if ( !s_normal_ready )
 	{
-		float pi      = glm::pi<float>();
+		float pi      = math::pi<float>();
 		float convert = (2 * pi) / 255.0f;
 		int n = 0;
@@ -246,11 +246,11 @@
 		{
 			float flat    = lat * convert;
-			float sin_lat = glm::sin( flat );
-			float cos_lat = glm::cos( flat );
+			float sin_lat = math::sin( flat );
+			float cos_lat = math::cos( flat );
 			for ( int lng = 0; lng < 256; ++lng, ++n )
 			{
 				float flng    = lng * convert;
-				float sin_lng = glm::sin( flng );
-				float cos_lng = glm::cos( flng );
+				float sin_lng = math::sin( flng );
+				float cos_lng = math::cos( flng );
 				s_normal_cache[n].x = cos_lat * sin_lng;
 //				s_normal_cache[n].y = sin_lat * sin_lng;
Index: /trunk/src/gfx/keyframed_mesh.cc
===================================================================
--- /trunk/src/gfx/keyframed_mesh.cc	(revision 450)
+++ /trunk/src/gfx/keyframed_mesh.cc	(revision 451)
@@ -93,8 +93,8 @@
 			}
 		}
-		m_last_frame    = static_cast<uint32>( glm::floor( tick_time ) + anim->get_start() );
+		m_last_frame    = static_cast<uint32>( math::floor( tick_time ) + anim->get_start() );
 		m_next_frame    = m_last_frame + 1;
 		if ( m_next_frame > static_cast<uint32>( anim->get_end() ) ) m_next_frame = static_cast<uint32>( anim->get_start() );
-		m_interpolation = tick_time - glm::floor( tick_time );
+		m_interpolation = tick_time - math::floor( tick_time );
 	}
 }
Index: /trunk/src/lua/lua_glm.cc
===================================================================
--- /trunk/src/lua/lua_glm.cc	(revision 450)
+++ /trunk/src/lua/lua_glm.cc	(revision 451)
@@ -56,5 +56,5 @@
 	static inline T unit() { return T( 1, 1, 1 ); }
 	static inline T construct( lua_State* L, int index ) {
-		typedef nv::tvec2<typename T::value_type> vec2;
+		typedef nv::math::tvec2<typename T::value_type> vec2;
 		if ( lua_type( L, index ) == LUA_TUSERDATA )
 		{
@@ -77,6 +77,6 @@
 	static inline T unit() { return T( 1, 1, 1, 1 ); }
 	static inline T construct( lua_State* L, int index ) {
-		typedef nv::tvec2<typename T::value_type> vec2;
-		typedef nv::tvec3<typename T::value_type> vec3;
+		typedef nv::math::tvec2<typename T::value_type> vec2;
+		typedef nv::math::tvec3<typename T::value_type> vec3;
 		if ( lua_type( L, index ) == LUA_TUSERDATA )
 		{
@@ -242,7 +242,7 @@
 	{
 		switch (len) {
-		case 2 : push_vec( L, nv::tvec2<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]] ) ); return 1;
-		case 3 : push_vec( L, nv::tvec3<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]], (*v)[nlua_swizzel_lookup[key[2]]] ) ); return 1;
-		case 4 : push_vec( L, nv::tvec4<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]], (*v)[nlua_swizzel_lookup[key[2]]], (*v)[nlua_swizzel_lookup[key[3]]] ) ); return 1;
+		case 2 : push_vec( L, nv::math::tvec2<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]] ) ); return 1;
+		case 3 : push_vec( L, nv::math::tvec3<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]], (*v)[nlua_swizzel_lookup[key[2]]] ) ); return 1;
+		case 4 : push_vec( L, nv::math::tvec4<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]], (*v)[nlua_swizzel_lookup[key[2]]], (*v)[nlua_swizzel_lookup[key[3]]] ) ); return 1;
 		default: break;
 		}
@@ -258,7 +258,7 @@
 int nlua_vec_newindex( lua_State* L )
 {
-	typedef nv::tvec2<typename T::value_type> vec2;
-	typedef nv::tvec3<typename T::value_type> vec3;
-	typedef nv::tvec4<typename T::value_type> vec4;
+	typedef nv::math::tvec2<typename T::value_type> vec2;
+	typedef nv::math::tvec3<typename T::value_type> vec3;
+	typedef nv::math::tvec4<typename T::value_type> vec4;
 
 	T* v = to_pvec<T>( L, 1 );
