+ mesh_upload( mesh, mdl->vertex_buffer, mdl->info.vertex_count,
+ mdl->index_buffer, mdl->info.indice_count );
+}
+
+VG_STATIC void mdl_draw_submesh( mdl_submesh *sm )
+{
+ mesh_drawn( sm->indice_start, sm->indice_count );
+}
+
+VG_STATIC void *mdl_get_entdata( mdl_context *mdl, mdl_node *pnode )
+{
+ return mdl->entdata_buffer + pnode->offset;
+}
+
+VG_STATIC mdl_keyframe *mdl_get_animdata( mdl_context *mdl, mdl_animation *anim )
+{
+ return mdl->keyframe_buffer + anim->offset;
+}
+
+VG_STATIC void mdl_link_materials( mdl_context *root, mdl_context *child )
+{
+ u32 lookup[MDL_MATERIAL_MAX];
+
+ for( int i=0; i<child->info.material_count; i++ )
+ {
+ mdl_material *mi = &child->material_buffer[i];
+ const char *si = mdl_pstr( child, mi->pstr_name );
+
+ lookup[i] = 0;
+
+ for( int j=0; j<root->info.material_count; j++ )
+ {
+ mdl_material *mj = &root->material_buffer[j];
+ const char *sj = mdl_pstr( root, mj->pstr_name );
+
+ if( !strcmp( si, sj ) )
+ {
+ lookup[i] = j;
+ break;
+ }
+ }
+
+ if( lookup[i] == 0 && i != 0 )
+ {
+ vg_warn( "Could not link material '%s' (not present in root model)\n",
+ si );
+ }
+ }
+
+ for( int i=0; i<child->info.submesh_count; i++ )
+ {
+ mdl_submesh *sm = &child->submesh_buffer[i];
+ sm->material_id = lookup[sm->material_id];
+ }