Index: trunk/nv/gfx/texture_atlas.hh
===================================================================
--- trunk/nv/gfx/texture_atlas.hh	(revision 141)
+++ trunk/nv/gfx/texture_atlas.hh	(revision 142)
@@ -4,4 +4,6 @@
 // This file is part of NV Libraries.
 // For conditions of distribution and use, see copyright notice in nv.hh
+//
+// TODO: fix behavior for exact fits (1024^2 atlas with border 0 only holds 9 256^2 images...)
 
 #ifndef NV_TEXTURE_ATLAS_HH
@@ -19,5 +21,5 @@
 	{
 	public:
-		texture_atlas( ivec2 size, size_t depth );
+		texture_atlas( ivec2 size, size_t depth, size_t border = 1 );
 		region get_region( ivec2 size );
 		void clear();
Index: trunk/nv/interface/mesh.hh
===================================================================
--- trunk/nv/interface/mesh.hh	(revision 141)
+++ trunk/nv/interface/mesh.hh	(revision 142)
@@ -94,5 +94,5 @@
 		{
 			map::iterator i = m_map.find( attr );
-			if ( i != m_map.end() && i->second->get_type() != type_to_enum<T>::type ) 
+			if ( i != m_map.end() && i->second->get_type() == type_to_enum<T>::type ) 
 			{
 				return ((vertex_attribute<T>*)(i->second));
Index: trunk/src/gfx/texture_atlas.cc
===================================================================
--- trunk/src/gfx/texture_atlas.cc	(revision 141)
+++ trunk/src/gfx/texture_atlas.cc	(revision 142)
@@ -12,8 +12,8 @@
 using namespace nv;
 
-texture_atlas::texture_atlas( glm::ivec2 size, size_t depth )
+texture_atlas::texture_atlas( glm::ivec2 size, size_t depth, size_t border /*= 1*/ )
 	: image( size, depth ), m_used( 0 )
 {
-	m_nodes.push_back( glm::ivec3( 1, 1, m_size.x - 2 ) );
+	m_nodes.push_back( glm::ivec3( border, border, m_size.x - 2 * border ) );
 	fill( 0 );
 }
@@ -79,5 +79,5 @@
 	}
 	merge();
-	m_used += static_cast<uint16>(size.x * size.y);
+	m_used += static_cast<uint32>(size.x * size.y);
 	return r;
 }
