Index: /trunk/nv/engine/animation.hh
===================================================================
--- /trunk/nv/engine/animation.hh	(revision 528)
+++ /trunk/nv/engine/animation.hh	(revision 529)
@@ -126,8 +126,6 @@
 				else
 				{
-// 					duration -= last.time;
-// 					last.time = 0.0f;
-					int hack;
-					m_time = 0.0f;
+ 					duration -= last.time;
+					last.time = 0.0f;
 				}
 			}
Index: /trunk/nv/engine/light.hh
===================================================================
--- /trunk/nv/engine/light.hh	(revision 528)
+++ /trunk/nv/engine/light.hh	(revision 529)
@@ -132,6 +132,6 @@
 	{
 	public:
-		static const unsigned lgeo_vertices = 4;
-		static const unsigned lgeo_indices = 6;
+		static const unsigned lgeo_vertices = 8;
+		static const unsigned lgeo_indices = 6 * 6;
 
 		void initialize( uint32 max_size )
@@ -146,5 +146,5 @@
 		uint32 index_stride() const { return lgeo_indices; }
 
-		void update( array_view< light_data* > lights )
+		void update( array_view< light_data* > lights, float min_height )
 		{
 			uint32 count = nv::min< uint32 >( lights.size(), m_max_size );
@@ -152,8 +152,11 @@
 			{
 				vec3 nlp = lights[i]->position;
+
 				float radius = lights[i]->range;
-				nlp.y = 0.1f;
+				nlp.y = 0.001f;
 				vec3 r1( radius, 0.0f, radius );
 				vec3 r2( radius, 0.0f, -radius );
+				vec3 hlp = lights[i]->position;
+				hlp.y = nv::max( hlp.y, min_height );
 
 				m_light_data[i * lgeo_vertices + 0] = light_vertex{ vec4( nlp - r1, float( i ) ) };
@@ -161,6 +164,20 @@
 				m_light_data[i * lgeo_vertices + 2] = light_vertex{ vec4( nlp + r1, float( i ) ) };
 				m_light_data[i * lgeo_vertices + 3] = light_vertex{ vec4( nlp + r2, float( i ) ) };
-
-				uint16 indices[lgeo_indices] = { 0, 1, 2, 2, 3, 0 };
+				m_light_data[i * lgeo_vertices + 4] = light_vertex{ vec4( hlp - r1, float( i ) ) };
+				m_light_data[i * lgeo_vertices + 5] = light_vertex{ vec4( hlp - r2, float( i ) ) };
+				m_light_data[i * lgeo_vertices + 6] = light_vertex{ vec4( hlp + r1, float( i ) ) };
+				m_light_data[i * lgeo_vertices + 7] = light_vertex{ vec4( hlp + r2, float( i ) ) };
+
+
+				uint16 indices[lgeo_indices] =
+				{
+					2, 1, 0, 0, 3, 2,
+					4, 5, 6, 6, 7, 4,
+
+					0, 1, 5, 5, 4, 0,
+					1, 2, 6, 6, 5, 1,
+					2, 3, 7, 7, 6, 2,
+					3, 0, 4, 4, 7, 3,
+				};
 				for ( uint16 j = 0; j < lgeo_indices; ++j )
 				{
@@ -218,10 +235,10 @@
 		}
 
-		void update( context* ctx, array_view< light_data* > lights )
+		void update( context* ctx, array_view< light_data* > lights, float min_height )
 		{
 			m_active = nv::min<uint32>( m_geometry.max_size(), lights.size() );
 			if ( m_active == 0 ) return;
 			m_block.update( lights );
-			m_geometry.update( lights );
+			m_geometry.update( lights, min_height );
 
 			m_block.update( ctx );
@@ -229,5 +246,5 @@
 		}
 
-		void filter_update( context* ctx, array_view< light_data* > lights, shadow_type type )
+		void filter_update( context* ctx, array_view< light_data* > lights, shadow_type type, float min_height )
 		{
 			uint32 count = 0;
@@ -241,5 +258,5 @@
 				if ( count >= size ) break;
 			}
-			update( ctx, array_view< light_data* >( filtered_lights.data(), count ) );
+			update( ctx, array_view< light_data* >( filtered_lights.data(), count ), min_height );
 		}
 
Index: /trunk/src/engine/default_resource_manager.cc
===================================================================
--- /trunk/src/engine/default_resource_manager.cc	(revision 528)
+++ /trunk/src/engine/default_resource_manager.cc	(revision 529)
@@ -37,5 +37,5 @@
 	m_lua->register_enum( "RND_STEP_3",     static_cast<int>( random_dist::STEP_3 ) );
 	m_lua->register_enum( "RND_STEP_4",     static_cast<int>( random_dist::STEP_4 ) );
-	m_lua->register_enum( "RND_LINEAR",     static_cast<int>( random_dist::LINEAR ) );
+	m_lua->register_enum( "RND_MLINEAR",    static_cast<int>( random_dist::MLINEAR ) );
 	m_lua->register_enum( "RND_MGAUSSIAN",  static_cast<int>( random_dist::MGAUSSIAN ) );
 	m_lua->register_enum( "RND_MRGAUSSIAN", static_cast<int>( random_dist::MRGAUSSIAN ) );
Index: /trunk/src/engine/model_manager.cc
===================================================================
--- /trunk/src/engine/model_manager.cc	(revision 528)
+++ /trunk/src/engine/model_manager.cc	(revision 529)
@@ -135,5 +135,5 @@
 	node->choice    = model_node_choice( table.get_unsigned( "choice", false ) );
 	node->chance    = table.get_float( "chance", 1.0f );
-	node->weight    = table.get_unsigned( "weight", 1 );
+	node->weight    = static_cast< uint16 >( table.get_unsigned( "weight", 1 ) );
 	node->mesh      = cmesh;
 	node->attach_id = attach_id;
Index: /trunk/src/engine/particle_engine.cc
===================================================================
--- /trunk/src/engine/particle_engine.cc	(revision 528)
+++ /trunk/src/engine/particle_engine.cc	(revision 529)
@@ -454,11 +454,4 @@
 	uint32 ecount = info->data->emitter_count;
 	if ( ecount == 0 ) return;
-
-	bool local = model.is_identity();
-// 	if ( !local ) 
-// 	{
-// 		source = vec3( m_model_matrix[3] );
-// 		orient = mat3( m_model_matrix );
-// 	}
 
 	for ( uint32 i = 0; i < ecount; ++i )
Index: /trunk/src/engine/resource_system.cc
===================================================================
--- /trunk/src/engine/resource_system.cc	(revision 528)
+++ /trunk/src/engine/resource_system.cc	(revision 529)
@@ -44,5 +44,5 @@
 		lua::table_guard sub_table( table, i + 1 );
 		string64 id = sub_table.get_string64( "id" );
-		NV_ASSERT( m_id_hash.find( id ) == m_id_hash.end(), "HASH COLLISION - ", id, " - ", m_id_hash[id] );
+		NV_ASSERT( m_id_hash.find( id ) == m_id_hash.end(), "HASH COLLISION" );
 		m_id_hash[id] = id;
 	}
Index: /trunk/src/gfx/gfx_terminal.cc
===================================================================
--- /trunk/src/gfx/gfx_terminal.cc	(revision 528)
+++ /trunk/src/gfx/gfx_terminal.cc	(revision 529)
@@ -112,5 +112,5 @@
 };
 
-gfx_terminal::gfx_terminal( context* ctx, texture t, dimension tsize, dimension psize )
+gfx_terminal::gfx_terminal( context* ctx, texture t, dimension tsize, dimension /*psize*/ )
 	: terminal( tsize ), m_context( ctx )
 {
@@ -178,10 +178,10 @@
 }
 
-bool gfx_terminal::poll( io_event & kevent )
+bool gfx_terminal::poll( io_event & /*kevent*/ )
 {
 	return false;
 }
 
-void gfx_terminal::set_cursor( position p )
+void gfx_terminal::set_cursor( position /*p*/ )
 {
 }
Index: /trunk/src/image/png_writer.cc
===================================================================
--- /trunk/src/image/png_writer.cc	(revision 528)
+++ /trunk/src/image/png_writer.cc	(revision 529)
@@ -47,9 +47,9 @@
 
 // initialize a callback-based context
-static void stbi__start_write_callbacks( stbi__write_context *s, stbi_write_func *c, void *context )
-{
-	s->func = c;
-	s->context = context;
-}
+// static void stbi__start_write_callbacks( stbi__write_context *s, stbi_write_func *c, void *context )
+// {
+// 	s->func = c;
+// 	s->context = context;
+// }
 
 typedef unsigned int stbiw_uint32;
@@ -65,4 +65,5 @@
 #define stbi__errpuc(x,y)  ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL))
 
+/*
 static void stbiw__writefv( stbi__write_context *s, const char *fmt, va_list v )
 {
@@ -139,5 +140,5 @@
 			break;
 		}
-		/* FALLTHROUGH */
+		// FALLTHROUGH 
 	case 3:
 		stbiw__write3( s, d[1 - rgb_dir], d[1], d[1 + rgb_dir] );
@@ -188,5 +189,5 @@
 	}
 }
-
+*/
 
 static unsigned int stbiw__crc32( unsigned char *buffer, int len )
@@ -253,5 +254,5 @@
 }
 
-unsigned char * stbi_zlib_compress( unsigned char *data, int data_len, int *out_len, int quality )
+unsigned char * stbi_zlib_compress( unsigned char *data, int data_len, int *out_len, int /*quality*/ )
 {
 	unsigned long expected = nv::miniz_bound( data_len );
Index: /trunk/src/lua/lua_area.cc
===================================================================
--- /trunk/src/lua/lua_area.cc	(revision 528)
+++ /trunk/src/lua/lua_area.cc	(revision 529)
@@ -285,5 +285,5 @@
 {
 	nv::rectangle* a = to_parea( L, 1 );
-	push_coord( L, a->ul - a->lr + nv::ivec2(1,1) );
+	push_coord( L, a->lr - a->ul + nv::ivec2(1,1) );
 	return 1;
 }
Index: /trunk/src/lua/lua_math.cc
===================================================================
--- /trunk/src/lua/lua_math.cc	(revision 528)
+++ /trunk/src/lua/lua_math.cc	(revision 529)
@@ -138,4 +138,11 @@
 
 template< typename T >
+int nlua_vec_sign( lua_State* L )
+{
+	push_vec<T>( L, nv::math::sign( to_vec<T>( L, 1 ) ) );
+	return 1;
+}
+
+template< typename T >
 int nlua_vec_call( lua_State* L )
 {
@@ -324,4 +331,5 @@
 	static const struct luaL_Reg nlua_vec_f [] = {
 		{ "clone",          nlua_vec_clone<T> },
+		{ "sign",           nlua_vec_sign<T> },
 		{ "get",            nlua_vec_get<T> },
 		{ "tostring",       nlua_vec_tostring<T> },
Index: /trunk/src/sdl/sdl_window_manager.cc
===================================================================
--- /trunk/src/sdl/sdl_window_manager.cc	(revision 528)
+++ /trunk/src/sdl/sdl_window_manager.cc	(revision 529)
@@ -42,5 +42,7 @@
 		char buffer[128];
 		sprintf( buffer, "%p", primal_window );
-		NV_ASSERT( SDL_SetHint( "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT", buffer ) == SDL_TRUE );
+		SDL_bool result = SDL_SetHint( "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT", buffer );
+		NV_UNUSED( result );
+		NV_ASSERT( result == SDL_TRUE, "SetHint failed!" );
 	}
 	primal_window = SDL_CreateWindowFrom( sys_w_handle );
