Index: trunk/src/gfx/mesh_creator.cc
===================================================================
--- trunk/src/gfx/mesh_creator.cc	(revision 411)
+++ trunk/src/gfx/mesh_creator.cc	(revision 412)
@@ -57,11 +57,11 @@
 			size_t chan_count = old_keys->get_channel_count();
 			if ( chan_count == 1 
-				&& old_keys->get_channel(0)->desc.slot_count() == 1 
-				&& old_keys->get_channel(0)->desc[0].etype == TRANSFORM ) continue;
+				&& old_keys->get_channel(0)->descriptor().slot_count() == 1 
+				&& old_keys->get_channel(0)->descriptor()[0].etype == TRANSFORM ) continue;
 
 			size_t max_keys = 0;
 			for ( size_t c = 0; c < chan_count; ++c )
 			{
-				max_keys = nv::max( max_keys, old_keys->get_channel(c)->count );
+				max_keys = nv::max( max_keys, old_keys->get_channel(c)->element_count() );
 			}
 
@@ -79,5 +79,5 @@
 				for ( uint16 c = 0; c < chan_count; ++c )
 				{
-					size_t idx = nv::min( old_keys->get_channel(c)->count - 1, n );
+					size_t idx = nv::min( old_keys->get_channel(c)->element_count() - 1, n );
 					pkey += old_keys->get_raw( old_keys->get_channel(c), idx, pkey );
 				}
@@ -107,8 +107,8 @@
 			{
 				const raw_data_channel* channel = kdata->get_channel(c);
-				size_t key_size = channel->desc.element_size();
-				for ( size_t n = 0; n < channel->count; ++n )
-				{
-					transform_key_raw( channel->desc, channel->data + n * key_size, scale, r33, ri33 );
+				size_t key_size = channel->element_size();
+				for ( size_t n = 0; n < channel->element_count(); ++n )
+				{
+					transform_key_raw( channel->descriptor(), channel->data + n * key_size, scale, r33, ri33 );
 				}
 			}
@@ -126,5 +126,5 @@
 	{
 		const raw_data_channel* channel = m_data->get_channel(c);
-		const data_descriptor&  desc    = channel->desc;
+		const data_descriptor&  desc    = channel->descriptor();
 		uint8* raw_data = channel->data;
 		uint32 vtx_size = desc.element_size();
@@ -142,5 +142,5 @@
 
 		if ( p_offset != -1 )
-			for ( uint32 i = 0; i < channel->count; i++)
+			for ( uint32 i = 0; i < channel->element_count(); i++)
 			{
 				vec3& p = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + p_offset );
@@ -149,5 +149,5 @@
 
 		if ( n_offset != -1 )
-			for ( uint32 i = 0; i < channel->count; i++)
+			for ( uint32 i = 0; i < channel->element_count(); i++)
 			{
 				vec3& n = *reinterpret_cast<vec3*>( raw_data + vtx_size*i + n_offset );
@@ -155,5 +155,5 @@
 			}
 		if ( t_offset != -1 )
-			for ( uint32 i = 0; i < channel->count; i++)
+			for ( uint32 i = 0; i < channel->element_count(); i++)
 			{
 				vec4& t = *reinterpret_cast<vec4*>(raw_data + vtx_size*i + t_offset );
@@ -174,5 +174,5 @@
 	if ( ch_n == -1 ) return;
 	raw_data_channel* channel = m_data->m_channels[ unsigned( ch_n ) ];
-	for ( const auto& cslot : channel->desc )
+	for ( const auto& cslot : channel->descriptor() )
 		if ( cslot.vslot == slot::NORMAL )
 		{
@@ -180,7 +180,7 @@
 		}
 
-	for ( uint32 i = 0; i < channel->count; ++i )
-	{
-		vec3& normal = *reinterpret_cast<vec3*>( channel->data + channel->desc.element_size() * i + n_offset );
+	for ( uint32 i = 0; i < channel->element_count(); ++i )
+	{
+		vec3& normal = *reinterpret_cast<vec3*>( channel->data + channel->element_size() * i + n_offset );
 		normal = -normal;
 	}
@@ -205,5 +205,5 @@
 		const raw_data_channel* channel = m_data->get_channel(c);
 
-		for ( const auto& cslot : channel->desc )
+		for ( const auto& cslot : channel->descriptor() )
 		switch ( cslot.vslot )
 		{
@@ -242,15 +242,17 @@
 	if ( !p_channel || !n_channel || !t_channel ) return;
 
-	if ( p_channel->count != n_channel->count || p_channel->count % t_channel->count != 0 || ( i_type != UINT && i_type != USHORT && i_type != NONE ) )
+	if ( p_channel->element_count() != n_channel->element_count() 
+		|| p_channel->element_count() % t_channel->element_count() != 0 
+		|| ( i_type != UINT && i_type != USHORT && i_type != NONE ) )
 	{
 		return;
 	}
 
-	raw_data_channel* g_channel = raw_data_channel::create<vertex_g>( p_channel->count );
+	raw_data_channel* g_channel = raw_data_channel::create<vertex_g>( p_channel->element_count() );
 	vec4* tangents              = reinterpret_cast<vec4*>( g_channel->data );
-	vec3* tangents2             = new vec3[ p_channel->count ];
-	uint32 tri_count = i_channel ? i_channel->count / 3 : t_channel->count / 3;
-	uint32 vtx_count = p_channel->count;
-	uint32 sets      = p_channel->count / t_channel->count;
+	vec3* tangents2             = new vec3[ p_channel->element_count() ];
+	uint32 tri_count = i_channel ? i_channel->element_count() / 3 : t_channel->element_count() / 3;
+	uint32 vtx_count = p_channel->element_count();
+	uint32 sets      = p_channel->element_count() / t_channel->element_count();
 
 	for ( unsigned int i = 0; i < tri_count; ++i )
@@ -280,7 +282,7 @@
 		}
 
-		const vec2& w1 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti0 + t_offset );
-		const vec2& w2 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti1 + t_offset );
-		const vec2& w3 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->desc.element_size()*ti2 + t_offset );
+		const vec2& w1 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->element_size()*ti0 + t_offset );
+		const vec2& w2 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->element_size()*ti1 + t_offset );
+		const vec2& w3 = *reinterpret_cast<vec2*>(t_channel->data + t_channel->element_size()*ti2 + t_offset );
 		vec2 st1 = w3 - w1;
 		vec2 st2 = w2 - w1;
@@ -290,10 +292,10 @@
 		for ( uint32 set = 0; set < sets; ++set )
 		{
-			uint32 nti0 = t_channel->count * set + ti0;
-			uint32 nti1 = t_channel->count * set + ti1;
-			uint32 nti2 = t_channel->count * set + ti2;
-			vec3 v1 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti0 + p_offset );
-			vec3 v2 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti1 + p_offset );
-			vec3 v3 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->desc.element_size()*nti2 + p_offset );
+			uint32 nti0 = t_channel->element_count() * set + ti0;
+			uint32 nti1 = t_channel->element_count() * set + ti1;
+			uint32 nti2 = t_channel->element_count() * set + ti2;
+			vec3 v1 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->element_size()*nti0 + p_offset );
+			vec3 v2 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->element_size()*nti1 + p_offset );
+			vec3 v3 = *reinterpret_cast<vec3*>(p_channel->data + p_channel->element_size()*nti2 + p_offset );
 			vec3 xyz1 = v3 - v1;
 			vec3 xyz2 = v2 - v1;
@@ -319,5 +321,5 @@
 	for ( unsigned int i = 0; i < vtx_count; ++i )
 	{
-		const vec3 n = *reinterpret_cast<vec3*>( n_channel->data + n_channel->desc.element_size()*i + n_offset );
+		const vec3 n = *reinterpret_cast<vec3*>( n_channel->data + n_channel->element_size()*i + n_offset );
 		const vec3 t = vec3(tangents[i]);
 		if ( ! ( t.x == 0.0f && t.y == 0.0f && t.z == 0.0f ) )
@@ -336,23 +338,18 @@
 nv::raw_data_channel* nv::mesh_data_creator::merge_channels( raw_data_channel* a, raw_data_channel* b )
 {
-	NV_ASSERT( a->count == b->count, "merge_channel - bad channels!" );
-	data_descriptor adesc = a->desc;
-	data_descriptor bdesc = b->desc;
-	uint32          count = a->count;
-
-	data_descriptor desc  = a->desc;
-	for ( auto bslot : bdesc )
-	{
-		desc.push_slot( bslot.etype, bslot.vslot );
-	}
-	uint8* data = new uint8[ count * desc.element_size() ];
-	for ( uint32 i = 0; i < count; ++i )
-	{
-		raw_copy_n( a->data + i * adesc.element_size(), adesc.element_size(), data + i*desc.element_size() );
-		raw_copy_n( b->data + i * bdesc.element_size(), bdesc.element_size(), data + i*desc.element_size() + adesc.element_size() );
-	}
+	NV_ASSERT( a->element_count() == b->element_count(), "merge_channel - bad channels!" );
+	data_descriptor desc  = a->descriptor();
+	desc.append( b->descriptor() );
+
+	uint8* data = new uint8[a->element_count() * desc.element_size() ];
+	for ( uint32 i = 0; i < a->element_count(); ++i )
+	{
+		raw_copy_n( a->data + i * a->element_size(), a->element_size(), data + i*desc.element_size() );
+		raw_copy_n( b->data + i * b->element_size(), b->element_size(), data + i*desc.element_size() + a->element_size() );
+	}
+
 	raw_data_channel* result = new raw_data_channel;
-	result->count = count;
-	result->desc  = desc;
+	result->m_count = a->element_count();
+	result->m_desc  = desc;
 	result->data  = data;
 	return result;
@@ -361,22 +358,22 @@
 nv::raw_data_channel* nv::mesh_data_creator::append_channels( raw_data_channel* a, raw_data_channel* b, uint32 frame_count )
 {
-	if ( a->desc != b->desc ) return nullptr;
-	if ( a->count % frame_count != 0 ) return nullptr;
-	if ( b->count % frame_count != 0 ) return nullptr;
-	size_t vtx_size = a->desc.element_size();
-
-	uint8* data = new uint8[ ( a->count + b->count ) * vtx_size ];
+	if ( a->descriptor() != b->descriptor() ) return nullptr;
+	if ( a->element_count() % frame_count != 0 ) return nullptr;
+	if ( b->element_count() % frame_count != 0 ) return nullptr;
+	size_t vtx_size = a->element_size();
+
+	uint8* data = new uint8[ ( a->element_count() + b->element_count() ) * vtx_size ];
 	
 
 	if ( frame_count == 1 )
 	{
-		size_t a_size = vtx_size * a->count;
+		size_t a_size = vtx_size * a->element_count();
 		raw_copy_n( a->data, a_size, data );
-		raw_copy_n( b->data, vtx_size * b->count, data + a_size );
+		raw_copy_n( b->data, vtx_size * b->element_count(), data + a_size );
 	}
 	else
 	{
-		size_t frame_size_a = ( a->count / frame_count ) * vtx_size;
-		size_t frame_size_b = ( b->count / frame_count ) * vtx_size;
+		size_t frame_size_a = ( a->element_count() / frame_count ) * vtx_size;
+		size_t frame_size_b = ( b->element_count() / frame_count ) * vtx_size;
 		size_t pos_a = 0;
 		size_t pos_b = 0;
@@ -392,6 +389,6 @@
 
 	raw_data_channel* result = new raw_data_channel;
-	result->count = a->element_count() + b->element_count();
-	result->desc  = a->descriptor();
+	result->m_count = a->element_count() + b->element_count();
+	result->m_desc  = a->descriptor();
 	result->data  = data;
 	return result;
@@ -429,10 +426,11 @@
 	{
 		raw_data_channel* old = m_data->m_channels[c];
-		size_t frame_count = ( old->get_buffer_type() == INDEX_BUFFER ? 1 : old->element_count() / size );
+		bool old_is_index = old->element_count() > 0 && old->descriptor()[0].vslot == slot::INDEX;
+		size_t frame_count = ( old_is_index ? 1 : old->element_count() / size );
 		m_data->m_channels[c] = append_channels( old, other->m_channels[c], frame_count );
 		NV_ASSERT( m_data->m_channels[c], "Merge problem!" );
-		if ( old->get_buffer_type() == INDEX_BUFFER )
-		{
-			switch ( old->desc[0].etype )
+		if ( old_is_index )
+		{
+			switch ( old->descriptor()[0].etype )
 			{
 			case USHORT : 
