Index: trunk/src/formats/md5_loader.cc
===================================================================
--- trunk/src/formats/md5_loader.cc	(revision 425)
+++ trunk/src/formats/md5_loader.cc	(revision 427)
@@ -46,5 +46,4 @@
 	std_stream sstream( &source );
 	std::string command;
-	mesh_node_data* nodes = nullptr;
 	size_t num_joints = 0;
 
@@ -111,6 +110,5 @@
 			assert( m_type == MESH );
 			assert( m_nodes == nullptr );
-			nodes = new mesh_node_data[ num_joints ];
-			m_nodes = new mesh_nodes_data( make_name( "md5_bones"), num_joints, nodes );
+			m_nodes = new mesh_nodes_data( make_name( "md5_bones") );
 			discard( sstream, "{" );
 			for ( size_t i = 0; i < m_nodes->get_count(); ++i )
@@ -128,10 +126,11 @@
 				unit_quat_w( orient );
 				remove_quotes( name );
-				nodes[i].data       = data_channel_set_creator::create_set( 0 );
-				data_channel_set_creator access( nodes[i].data );
+				data_channel_set* set = data_channel_set_creator::create_set( 0 );
+				data_channel_set_creator access( set );
 				access.set_parent_id( parent_id );
 				access.set_transform( transform( pos, orient ).inverse().extract() );
 				access.set_name( make_name( name.c_str() ) );
 				next_line( sstream );
+				m_nodes->push_back( set );
 			}
 			discard( sstream, "}" );
@@ -233,5 +232,5 @@
 			}
 
-			prepare_mesh( nodes, weight_info.size(), mesh, weights.data(), weight_info.data() );
+			prepare_mesh( m_nodes, weight_info.size(), mesh, weights.data(), weight_info.data() );
 
 			m_meshes[ num_meshes ] = mesh;
@@ -241,7 +240,6 @@
 		{
 			assert( m_type == ANIMATION );
-			assert( nodes == nullptr );
-			nodes = new mesh_node_data[ num_joints ];
-			m_nodes = new mesh_nodes_data( make_name( "md5_animation" ), num_joints, nodes, static_cast< nv::uint16 >( frame_rate ), static_cast< float >( num_frames ), true );
+			assert( m_nodes == nullptr );
+			m_nodes = new mesh_nodes_data( make_name( "md5_animation" ), static_cast< nv::uint16 >( frame_rate ), static_cast< float >( num_frames ), true );
 			joint_infos.resize( num_joints );
 
@@ -253,9 +251,10 @@
 				sstream >> name >> parent_id >> joint_infos[i].flags >> joint_infos[i].start_index;
 				remove_quotes( name );
-				nodes[i].data = data_channel_set_creator::create_set( 1 );
-				data_channel_set_creator access( nodes[i].data );
+				data_channel_set* set = data_channel_set_creator::create_set( 1 );
+				data_channel_set_creator access( set );
 				access.add_channel< md5_key_t >( num_frames );
 				access.set_name( make_name( name.c_str() ) );
 				access.set_parent_id( parent_id );
+				m_nodes->push_back( set );
 				next_line( sstream );
 			}
@@ -322,5 +321,5 @@
 			}
 
-			build_frame_skeleton( nodes, frame_id, joint_infos, base_frames, frame );
+			build_frame_skeleton( m_nodes, frame_id, joint_infos, base_frames, frame );
 
 			discard( sstream, "}" );
@@ -334,5 +333,5 @@
 }
 
-bool md5_loader::prepare_mesh( mesh_node_data* nodes, uint32 vtx_count, data_channel_set* mdata, md5_weight* weights, md5_weight_info* weight_info )
+bool md5_loader::prepare_mesh( mesh_nodes_data* nodes, uint32 vtx_count, data_channel_set* mdata, md5_weight* weights, md5_weight_info* weight_info )
 {
 	assert( m_type == MESH );
@@ -389,7 +388,7 @@
 			if ( j < weight_count )
 			{
-				md5_weight& weight           = weights[start_weight + j];
-				const mesh_node_data&  joint = nodes[weight.joint_id];
-				const transform tr = transform( joint.data->get_transform() ).inverse();
+				md5_weight& weight             = weights[start_weight + j];
+				const data_channel_set*  joint = (*nodes)[weight.joint_id];
+				const transform tr = transform( joint->get_transform() ).inverse();
 				vec3 rot_pos = tr.get_orientation() * weight.pos;
 
@@ -453,6 +452,6 @@
  		for ( int j = 0; j < 4; ++j )
  		{
-			const mesh_node_data&  joint = nodes[vdata.boneindex[j]];
-			const transform tr = transform( joint.data->get_transform() ).inverse();
+			const data_channel_set*  joint = ( *nodes )[vdata.boneindex[j]];
+			const transform tr = transform( joint->get_transform() ).inverse();
  			vdata.normal  += ( normal  * tr.get_orientation() ) * vdata.boneweight[j];
  			vdata.tangent += ( tangent * tr.get_orientation() ) * vdata.boneweight[j];
@@ -463,5 +462,5 @@
 }
 
-void md5_loader::build_frame_skeleton( mesh_node_data* nodes, uint32 index, const array_view<md5_joint_info>& joint_infos, const array_view<transform>& base_frames, const array_view<float>& frame_data )
+void md5_loader::build_frame_skeleton( mesh_nodes_data* nodes, uint32 index, const array_view<md5_joint_info>& joint_infos, const array_view<transform>& base_frames, const array_view<float>& frame_data )
 {
 	assert( m_type == ANIMATION );
@@ -471,6 +470,6 @@
 
 		const md5_joint_info& jinfo = joint_infos[i];
-		mesh_node_data& joint = nodes[i];
-		int parent_id         = joint.data->get_parent_id();
+		const data_channel_set* joint = (*nodes)[i];
+		int parent_id         = joint->get_parent_id();
 
 		vec3 pos    = base_frames[i].get_position();
@@ -486,8 +485,8 @@
 		if ( parent_id >= 0 ) // Has a parent joint
 		{
-			const mesh_node_data& pjoint = nodes[parent_id];
-			const transform* ptv = reinterpret_cast< const transform* >( pjoint.data->get_channel(0)->raw_data() );
+			const data_channel_set* pjoint = ( *nodes )[i];
+			const transform* ptv = reinterpret_cast< const transform* >( pjoint->get_channel(0)->raw_data() );
 			transform ptr;
-			if ( pjoint.data->get_channel(0)->size() > index ) ptr = ptv[ index ];
+			if ( pjoint->get_channel(0)->size() > index ) ptr = ptv[ index ];
 			vec3 rot_pos = ptr.get_orientation() * pos;
 
@@ -498,5 +497,5 @@
 		}
 
-		reinterpret_cast< transform* >( const_cast< uint8* >( joint.data->get_channel(0)->raw_data() ) )[index] = transform( pos, orient );
+		reinterpret_cast< transform* >( const_cast< uint8* >( joint->get_channel(0)->raw_data() ) )[index] = transform( pos, orient );
 	}
 }
