Index: trunk/src/formats/assimp_loader.cc
===================================================================
--- trunk/src/formats/assimp_loader.cc	(revision 425)
+++ trunk/src/formats/assimp_loader.cc	(revision 427)
@@ -190,5 +190,5 @@
 }
 
-bool nv::assimp_loader::load_bones( size_t index, array_ref< mesh_node_data > bones )
+bool nv::assimp_loader::load_bones( size_t index, array_ref< data_channel_set* > bones )
 {
 	if ( m_scene == nullptr ) return false;
@@ -200,6 +200,6 @@
 		aiBone* bone   = mesh->mBones[m];
 		mat4    offset = assimp_mat4_cast( bone->mOffsetMatrix );
-		bones[m].data = data_channel_set_creator::create_set( 0 );
-		data_channel_set_creator access( bones[m].data );
+		bones[m] = data_channel_set_creator::create_set( 0 );
+		data_channel_set_creator access( bones[m] );
 		const char* name = bone->mName.data;
 		access.set_name( make_name( name ) );
@@ -287,10 +287,10 @@
 {
 	const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
-	vector< mesh_node_data > final_bones;
+	mesh_nodes_data* result = new mesh_nodes_data( make_name( "bones" ) );
 	unordered_map< uint64, uint16 > names;
 	for ( unsigned int m = 0; m < m_mesh_count; ++m )
 	{
 		uint16 translate[MAX_BONES];
-		vector< mesh_node_data > bones;
+		vector< data_channel_set* > bones;
 		const aiMesh*  mesh  = scene->mMeshes[ m ];
 		if ( mesh->mNumBones != 0 )
@@ -301,12 +301,12 @@
 			{
 
-				mesh_node_data& bone = bones[b];
-				auto iname = names.find( bone.data->get_name() );
+				data_channel_set* bone = bones[b];
+				auto iname = names.find( bone->get_name() );
 				if ( iname == names.end() )
 				{
-					NV_ASSERT( final_bones.size() < MAX_BONES, "Too many bones to merge!" );
-					uint16 index = uint16( final_bones.size() );
-					final_bones.push_back( bone );
-					names[ bone.data->get_name() ] = index;
+					NV_ASSERT( result->get_count() < MAX_BONES, "Too many bones to merge!" );
+					uint16 index = uint16( result->get_count() );
+					result->push_back( bone );
+					names[ bone->get_name() ] = index;
 					translate[b] = index;
 				}
@@ -334,7 +334,6 @@
 		}	
 	}
-	mesh_node_data* bones = new mesh_node_data[ final_bones.size() ];
-	raw_copy( final_bones.begin(), final_bones.end(), bones );
-	return new mesh_nodes_data( make_name( "bones" ), final_bones.size(), bones );
+
+	return result;
 }
 
@@ -349,5 +348,4 @@
 
 	uint32 count = count_nodes( scene->mRootNode );
-	mesh_node_data* data    = new mesh_node_data[count];
 
 	uint16 frame_rate     = static_cast<uint16>( anim->mTicksPerSecond );
@@ -355,7 +353,15 @@
 	bool   flat           = false;
 
-	load_node( index, data, root, 0, -1 );
-
-	return new mesh_nodes_data( make_name( static_cast<const char*>( anim->mName.data ) ), count, data, frame_rate, duration, flat );
+	data_channel_set** temp = new data_channel_set*[ count ];
+	array_ref< data_channel_set* > temp_ref( temp, count );
+	load_node( index, temp_ref, root, 0, -1 );
+
+	mesh_nodes_data* result = new mesh_nodes_data( make_name( static_cast<const char*>( anim->mName.data ) ), frame_rate, duration, flat );
+	for ( auto set : temp_ref )
+	{
+		result->push_back( set );
+	}
+	delete temp;
+	return result;
 }
 
@@ -371,5 +377,5 @@
 }
 
-nv::sint16 nv::assimp_loader::load_node( uint32 anim_id, mesh_node_data* nodes, const void* vnode, sint16 this_id, sint16 parent_id )
+nv::sint16 nv::assimp_loader::load_node( uint32 anim_id, array_ref< data_channel_set* > nodes, const void* vnode, sint16 this_id, sint16 parent_id )
 {
 	const aiScene* scene = reinterpret_cast<const aiScene*>( m_scene );
@@ -386,12 +392,7 @@
 	}
 
-	mesh_node_data& a_data = nodes[ this_id ];
-
-	if (anode) 
-		create_keys( &a_data, anode );
-	else
-		a_data.data = data_channel_set_creator::create_set( 0 );
-
-	data_channel_set_creator access( a_data.data );
+	nodes[ this_id ] = anode ? create_keys( anode ) : data_channel_set_creator::create_set( 0 );
+
+	data_channel_set_creator access( nodes[this_id] );
 	access.set_name( make_name( name ) );
 	access.set_parent_id( parent_id );
@@ -412,14 +413,14 @@
 }
 
-void nv::assimp_loader::create_keys( mesh_node_data* data, const void* vnode )
+data_channel_set* nv::assimp_loader::create_keys( const void* vnode )
 {
 	const aiNodeAnim* node = reinterpret_cast< const aiNodeAnim* >( vnode );
 	if ( node->mNumPositionKeys == 0 && node->mNumRotationKeys == 0 && node->mNumScalingKeys == 0 )
 	{
-		return;
-	}
-
-	data->data = data_channel_set_creator::create_set( 2 );
-	data_channel_set_creator key_set( data->data );
+		return data_channel_set_creator::create_set( 0 );
+	}
+	
+	data_channel_set* set = data_channel_set_creator::create_set( 2 );
+	data_channel_set_creator key_set( set );
 
 	assimp_key_p* pchannel = key_set.add_channel< assimp_key_p >( node->mNumPositionKeys ).data();
@@ -456,5 +457,5 @@
 // 		}
 // 	}
-
+	return set;
 }
 
