Index: trunk/src/core/random.cc
===================================================================
--- trunk/src/core/random.cc	(revision 453)
+++ trunk/src/core/random.cc	(revision 454)
@@ -231,5 +231,5 @@
 	vec2 opoint     = ellipse_edge( oradii );
 	vec2 opoint2    = opoint * opoint;
-	vec2 odir       = glm::normalize( opoint );
+	vec2 odir       = math::normalize( opoint );
 	f32 odist2    = opoint2.x + opoint2.y;
 
@@ -251,5 +251,5 @@
 	vec3 opoint     = ellipsoid_edge( oradii );
 	vec3 opoint2    = opoint * opoint;
-	vec3 odir       = glm::normalize( opoint );
+	vec3 odir       = math::normalize( opoint );
 	f32 odist2    = opoint2.x + opoint2.y + opoint2.z;
 
Index: trunk/src/engine/particle_engine.cc
===================================================================
--- trunk/src/engine/particle_engine.cc	(revision 453)
+++ trunk/src/engine/particle_engine.cc	(revision 454)
@@ -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 ) / math::sqrt(glm::dot( datap->plane_normal, datap->plane_normal ) );
+	datap->distance     = -math::dot( datap->plane_normal, datap->plane_point ) / math::sqrt( math::dot( datap->plane_normal, datap->plane_normal ) );
 	return true;
 }
@@ -242,12 +242,12 @@
 		particle& pt = p[i];
 		vec3 direction  = pt.velocity * factor;
-		if ( glm::dot( datap->plane_normal, pt.position + direction ) + datap->distance <= 0.0f )
+		if ( math::dot( datap->plane_normal, pt.position + direction ) + datap->distance <= 0.0f )
 		{
-			float val = glm::dot( datap->plane_normal, pt.position ) + datap->distance;
+			float val = math::dot( datap->plane_normal, pt.position ) + datap->distance;
 			if ( val > 0.0f )
 			{
-				vec3 part_dir = direction * ( -val / glm::dot( datap->plane_normal, direction ) );
+				vec3 part_dir = direction * ( -val / math::dot( datap->plane_normal, direction ) );
 				pt.position = pt.position + part_dir + ( part_dir - direction ) * datap->bounce;
-				pt.velocity = glm::reflect( pt.velocity, datap->plane_normal ) * datap->bounce;
+				pt.velocity = math::reflect( pt.velocity, datap->plane_normal ) * datap->bounce;
 			}
 		}
@@ -273,5 +273,5 @@
 	for ( uint32 i = 0; i < count; ++i )
 	{
-		p[i].color = glm::clamp( p[i].color + adjustment, 0.0f, 1.0f );
+		p[i].color = math::clamp( p[i].color + adjustment, 0.0f, 1.0f );
 	}
 }
@@ -296,5 +296,5 @@
 	for ( uint32 i = 0; i < count; ++i )
 	{
-		p[i].size = glm::max( p[i].size + adjustment, vec2() );
+		p[i].size = math::max( p[i].size + adjustment, vec2() );
 	}
 }
@@ -347,6 +347,6 @@
 	}
 
-	data.common_up  = glm::normalize( table.get<vec3>("common_up",  vec3(1,0,0) ) );
-	data.common_dir = glm::normalize( table.get<vec3>("common_dir", vec3(0,1,0) ) );
+	data.common_up  = math::normalize( table.get<vec3>("common_up",  vec3(1,0,0) ) );
+	data.common_dir = math::normalize( table.get<vec3>("common_dir", vec3(0,1,0) ) );
 
 	vec2 def_size        = table.get<vec2>("size", vec2(0.1,0.1) );
@@ -409,9 +409,10 @@
 
 				edata.rate         = element.get<float>("rate", 1.0f );
-				edata.dir          = glm::normalize( element.get<vec3>("direction", vec3(0,1,0) ) );
+				edata.dir          = math::normalize( element.get<vec3>("direction", vec3(0,1,0) ) );
 				
 				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 );
+					edata.odir = math::normalize( math::cross( edata.dir, vec3( 0, 1, 0 ) ) );
+				edata.cdir = math::cross( edata.dir, edata.odir );
 
 				data.emmiter_count++;
@@ -563,5 +564,5 @@
 		m_model_matrix = s.get_model();
 		m_camera_pos   = s.get_camera().get_position();
-		m_inv_view_dir = glm::normalize(-s.get_camera().get_direction());
+		m_inv_view_dir = math::normalize(-s.get_camera().get_direction());
 
 		update_emmiters( info, m_last_update );
@@ -636,29 +637,29 @@
 
 		vec3 view_dir( m_inv_view_dir );
-		if ( accurate_facing ) view_dir = glm::normalize( m_camera_pos - pdata.position );
+		if ( accurate_facing ) view_dir = math::normalize( m_camera_pos - pdata.position );
 
 		switch ( orientation )
 		{
 		case particle_orientation::POINT :
-			right   = glm::normalize( glm::cross( view_dir, vec3( 0, 1, 0 ) ) );
-			rot_mat = mat3( right, glm::cross( right, -view_dir ), -view_dir );
+			right   = math::normalize( math::cross( view_dir, vec3( 0, 1, 0 ) ) );
+			rot_mat = mat3( right, math::cross( right, -view_dir ), -view_dir );
 			break;
 		case particle_orientation::ORIENTED :
 			pdir    = normalize_safe( pdata.velocity, pdir );
-			right   = glm::normalize( glm::cross( pdir, view_dir ) );
-			rot_mat = mat3( right, pdir, glm::cross( pdir, right ) );
+			right   = math::normalize( math::cross( pdir, view_dir ) );
+			rot_mat = mat3( right, pdir, math::cross( pdir, right ) );
 			break;
 		case particle_orientation::ORIENTED_COMMON :
-			right   = glm::normalize( glm::cross( common_dir, view_dir ) );
-			rot_mat = mat3( right, common_dir, glm::cross( common_dir, right ) );
+			right   = math::normalize( math::cross( common_dir, view_dir ) );
+			rot_mat = mat3( right, common_dir, math::cross( common_dir, right ) );
 			break;
 		case particle_orientation::PERPENDICULAR :
 			pdir    = normalize_safe( pdata.velocity, pdir );
-			right   = glm::normalize( glm::cross( common_up, pdir ) );
-			rot_mat = mat3( right, common_up, glm::cross( common_up, right ) );
+			right   = math::normalize( math::cross( common_up, pdir ) );
+			rot_mat = mat3( right, common_up, math::cross( common_up, right ) );
 			break;
 		case particle_orientation::PERPENDICULAR_COMMON :
-			right   = glm::normalize( glm::cross( common_up, common_dir ) );
-			rot_mat = mat3( right, common_up, glm::cross( common_up, right ) );
+			right   = math::normalize( math::cross( common_up, common_dir ) );
+			rot_mat = mat3( right, common_up, math::cross( common_up, right ) );
 			break;
 		}
Index: trunk/src/formats/assimp_loader.cc
===================================================================
--- trunk/src/formats/assimp_loader.cc	(revision 453)
+++ trunk/src/formats/assimp_loader.cc	(revision 454)
@@ -134,11 +134,11 @@
 		{
 			vec3 v = assimp_vec3_cast( mesh->mVertices[i] );
-			vec3 n = glm::normalize( assimp_vec3_cast( mesh->mNormals[i] ) );
-			vec3 t = glm::normalize( assimp_vec3_cast( mesh->mTangents[i] ) );
-			vec3 b = glm::normalize( assimp_vec3_cast( mesh->mBitangents[i] ) );
+			vec3 n = math::normalize( assimp_vec3_cast( mesh->mNormals[i] ) );
+			vec3 t = math::normalize( assimp_vec3_cast( mesh->mTangents[i] ) );
+			vec3 b = math::normalize( assimp_vec3_cast( mesh->mBitangents[i] ) );
 			vec2 s = assimp_st_cast( mesh->mTextureCoords[0][i] );
 
-			vec3 t_i = glm::normalize( t - n * glm::dot( n, t ) );
-			float det = ( glm::dot( glm::cross( n, t ), b ) );
+			vec3 t_i = math::normalize( t - n * math::dot( n, t ) );
+			float det = ( math::dot( math::cross( n, t ), b ) );
 			det = ( det < 0.0f ? -1.0f : 1.0f );
 			nv::vec4 vt( t_i[0], t_i[1], t_i[2], det );
@@ -441,5 +441,5 @@
 // 	{
 // 		vec3 scale_vec0 = assimp_vec3_cast( node->mScalingKeys[0].mValue );
-// 		float scale_value   = glm::length( math::abs( scale_vec0 - vec3(1,1,1) ) );
+// 		float scale_value   = math::length( math::abs( scale_vec0 - vec3(1,1,1) ) );
 // 		if ( node->mNumScalingKeys > 1 || scale_value > 0.001 ) 
 // 		{
Index: trunk/src/formats/obj_loader.cc
===================================================================
--- trunk/src/formats/obj_loader.cc	(revision 453)
+++ trunk/src/formats/obj_loader.cc	(revision 454)
@@ -283,6 +283,6 @@
 			if ( ! (tv.x == 0.0f && tv.y == 0.0f && tv.z == 0.0f) )
 			{
-				m_data[a].tangent    = vec4( glm::normalize(tv - nv * glm::dot( nv, tv )), 0.0f ); 
-				m_data[a].tangent[3] = (glm::dot(glm::cross(nv, tv), tan2[a]) < 0.0f) ? -1.0f : 1.0f;
+				m_data[a].tangent    = vec4( math::normalize(tv - nv * math::dot( nv, tv )), 0.0f );
+				m_data[a].tangent[3] = ( math::dot( math::cross(nv, tv), tan2[a]) < 0.0f) ? -1.0f : 1.0f;
 			}
 		}
Index: trunk/src/gfx/keyframed_mesh.cc
===================================================================
--- trunk/src/gfx/keyframed_mesh.cc	(revision 453)
+++ trunk/src/gfx/keyframed_mesh.cc	(revision 454)
@@ -217,7 +217,7 @@
 		for ( size_t i = 0; i < m_vertex_count; ++i )
 		{
-			vtx[i].position = glm::mix( prev[i].position, next[i].position, m_interpolation );
-			vtx[i].normal   = glm::mix( prev[i].normal,   next[i].normal,   m_interpolation );
-			vtx[i].tangent  = glm::mix( prev[i].tangent,  next[i].tangent,   m_interpolation );
+			vtx[i].position = math::mix( prev[i].position, next[i].position, m_interpolation );
+			vtx[i].normal   = math::mix( prev[i].normal,   next[i].normal,   m_interpolation );
+			vtx[i].tangent  = math::mix( prev[i].tangent,  next[i].tangent,   m_interpolation );
 		}
 	}
@@ -231,6 +231,6 @@
 		for ( size_t i = 0; i < m_vertex_count; ++i )
 		{
-			vtx[i].position = glm::mix( prev[i].position, next[i].position, m_interpolation );
-			vtx[i].normal   = glm::mix( prev[i].normal,   next[i].normal,   m_interpolation );
+			vtx[i].position = math::mix( prev[i].position, next[i].position, m_interpolation );
+			vtx[i].normal   = math::mix( prev[i].normal,   next[i].normal,   m_interpolation );
 		}
 	}
Index: trunk/src/gfx/mesh_creator.cc
===================================================================
--- trunk/src/gfx/mesh_creator.cc	(revision 453)
+++ trunk/src/gfx/mesh_creator.cc	(revision 454)
@@ -95,5 +95,5 @@
 void nv::mesh_nodes_creator::transform( float scale, const mat3& r33 )
 {
-	mat3 ri33 = glm::inverse( r33 );
+	mat3 ri33 = math::inverse( r33 );
 	mat4 pre_transform ( scale * r33 );
 	mat4 post_transform( 1.f/scale * ri33 ); 
@@ -150,5 +150,5 @@
 			{
 				vec3& n = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + n_offset );
-				n = glm::normalize( normal_transform * n );
+				n = math::normalize( normal_transform * n );
 			}
 		if ( t_offset != -1 )
@@ -156,5 +156,5 @@
 			{
 				vec4& t = *reinterpret_cast<vec4*>(raw_data + vtx_size*i + t_offset );
-				t = vec4( glm::normalize( normal_transform * vec3(t) ), t[3] );
+				t = vec4( math::normalize( normal_transform * vec3(t) ), t[3] );
 			}
 	}
@@ -299,5 +299,5 @@
 			vec3 xyz2 = v2 - v1;
 
-			//vec3 normal = glm::cross( xyz1, xyz2 );
+			//vec3 normal = math::cross( xyz1, xyz2 );
 			//
 			//vtcs[ ti0 ].normal += normal;
@@ -323,6 +323,6 @@
 		if ( ! ( t.x == 0.0f && t.y == 0.0f && t.z == 0.0f ) )
 		{
-			tangents[i]    = vec4( glm::normalize(t - n * glm::dot( n, t )), 0.0f ); 
-			tangents[i][3] = (glm::dot(glm::cross(n, t), tangents2[i]) < 0.0f) ? -1.0f : 1.0f;
+			tangents[i]    = vec4( math::normalize(t - n * math::dot( n, t )), 0.0f );
+			tangents[i][3] = ( math::dot( math::cross(n, t), tangents2[i]) < 0.0f) ? -1.0f : 1.0f;
 		}
 	}
Index: trunk/src/lua/lua_area.cc
===================================================================
--- trunk/src/lua/lua_area.cc	(revision 453)
+++ trunk/src/lua/lua_area.cc	(revision 454)
@@ -255,5 +255,5 @@
 	nv::rectangle* a = to_parea( L, 1 );
 	nv::ivec2*     c = to_pcoord( L, 2 );
-	*c = glm::clamp( *c, a->ul, a->lr );
+	*c = nv::math::clamp( *c, a->ul, a->lr );
 	return 0;
 }
@@ -263,5 +263,5 @@
 	nv::rectangle* a = to_parea( L, 1 );
 	nv::ivec2*     c = to_pcoord( L, 2 );
-	push_coord( L, glm::clamp( *c, a->ul, a->lr ) );
+	push_coord( L, nv::math::clamp( *c, a->ul, a->lr ) );
 	return 0;
 }
Index: trunk/src/lua/lua_values.cc
===================================================================
--- trunk/src/lua/lua_values.cc	(revision 453)
+++ trunk/src/lua/lua_values.cc	(revision 454)
@@ -25,5 +25,5 @@
 void* nv::lua::detail::raw_check_userdata( lua_State *L, int index, const char* metatable )
 {
-	return luaL_checkudata( L, index, metatable );
+	return luaL_testudata( L, index, metatable );
 }
 
Index: trunk/src/rogue/fov_recursive_shadowcasting.cc
===================================================================
--- trunk/src/rogue/fov_recursive_shadowcasting.cc	(revision 453)
+++ trunk/src/rogue/fov_recursive_shadowcasting.cc	(revision 454)
@@ -24,6 +24,6 @@
 	{
 		position max_radius = m_size-m_position;
-		max_radius = glm::max(max_radius,m_position);
-		m_radius = static_cast<int>( glm::length( vec2( max_radius ) ) )+1;
+		max_radius = math::max(max_radius,m_position);
+		m_radius = static_cast<int>( math::length( vec2( max_radius ) ) )+1;
 	}
 	m_radius2 = m_radius * m_radius;
Index: trunk/src/sdl/sdl_audio.cc
===================================================================
--- trunk/src/sdl/sdl_audio.cc	(revision 453)
+++ trunk/src/sdl/sdl_audio.cc	(revision 454)
@@ -75,6 +75,6 @@
 			if ( relative != vec3() )
 			{
-				angle = math::degrees( -glm::orientedAngle( m_forward, glm::normalize( relative ), m_up ) );
-				distance = glm::clamp( 20.0f * glm::length( relative ), 0.0f, 255.0f );
+				angle = math::degrees( -math::oriented_angle( m_forward, math::normalize( relative ), m_up ) );
+				distance = math::clamp( 20.0f * math::length( relative ), 0.0f, 255.0f );
 			}
 			if ( angle < 0.0f ) angle += 360.0f;
