+static u32 mdl_arrcount( mdl_array_ptr *arr )
+{
+ return arr->count;
+}
+
+static mdl_array *mdl_find_array( mdl_context *mdl, const char *name )
+{
+ for( u32 i=0; i<mdl_arrcount(&mdl->index); i++ ){
+ mdl_array *arr = mdl_arritm( &mdl->index, i );
+
+ if( !strncmp(arr->name,name,16) ){
+ return arr;
+ }
+ }
+
+ return NULL;
+}
+
+static int _mdl_load_array( mdl_context *mdl, mdl_array_ptr *ptr,
+ const char *name, void *lin_alloc, u32 stride )
+{
+ mdl_array *arr = mdl_find_array( mdl, name );
+
+ if( arr ){
+ mdl_load_array_file( mdl, ptr, arr, lin_alloc, stride );
+ return 1;
+ }
+ else{
+ ptr->data = NULL;
+ ptr->count = 0;
+ ptr->stride = 0;
+ return 0;
+ }
+}
+
+#define MDL_LOAD_ARRAY( MDL, PTR, STRUCT, ALLOCATOR ) \
+ _mdl_load_array( MDL, PTR, #STRUCT, ALLOCATOR, sizeof(STRUCT) )
+
+static int mdl_load_mesh_block( mdl_context *mdl, void *lin_alloc ){
+ int success = 1;
+
+ success &= MDL_LOAD_ARRAY( mdl, &mdl->verts, mdl_vert, lin_alloc );
+ success &= MDL_LOAD_ARRAY( mdl, &mdl->indices, mdl_indice, lin_alloc );
+
+ return success;
+}
+
+static int mdl_load_metadata_block( mdl_context *mdl, void *lin_alloc ){
+ int success = 1;
+
+ success &= _mdl_load_array( mdl, &mdl->strings, "strings", lin_alloc, 1 );
+ success &= MDL_LOAD_ARRAY( mdl, &mdl->meshs, mdl_mesh, lin_alloc );
+ success &= MDL_LOAD_ARRAY( mdl, &mdl->submeshs, mdl_submesh, lin_alloc );
+ success &= MDL_LOAD_ARRAY( mdl, &mdl->materials, mdl_material, lin_alloc );
+ success &= MDL_LOAD_ARRAY( mdl, &mdl->textures, mdl_texture, lin_alloc );
+ success &= MDL_LOAD_ARRAY( mdl, &mdl->armatures, mdl_armature, lin_alloc );
+ success &= MDL_LOAD_ARRAY( mdl, &mdl->bones, mdl_bone, lin_alloc );
+ success &= MDL_LOAD_ARRAY( mdl, &mdl->animations,mdl_animation,lin_alloc );
+
+ return success;
+}
+
+static int mdl_load_animation_block( mdl_context *mdl, void *lin_alloc ){
+ return MDL_LOAD_ARRAY( mdl, &mdl->keyframes, mdl_keyframe, lin_alloc );
+}