X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=model.c;h=19f45f2d0466c8d3c55e1aca8160595b6e242431;hb=refs%2Fheads%2Fmaster;hp=b8bacf280eac9863a5e5c8fcec4d240887196fde;hpb=93790b71d3a89724255dc73239e38c08ad4bbac7;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/model.c b/model.c index b8bacf2..19f45f2 100644 --- a/model.c +++ b/model.c @@ -5,15 +5,18 @@ #pragma once #include "vg/vg_io.h" + +#ifndef C0_STOPGAP #include "vg/vg_async.h" #include "vg/vg_tex.h" +#endif #include "vg/vg_msg.h" #include "vg/vg_string.h" #include #include #include #include "model.h" -#include "render.h" +#include "shader_props.h" static void mdl_load_fatal_corrupt( mdl_context *mdl ) { @@ -81,7 +84,8 @@ static void mdl_load_array_file( mdl_context *mdl, mdl_array_ptr *ptr, if( arr->item_count ) { u32 size = stride*arr->item_count; - ptr->data = vg_linear_alloc( lin_alloc, vg_align8(size) ); + ptr->data = lin_alloc? vg_linear_alloc( lin_alloc, vg_align8(size) ): + malloc( size ); mdl_load_array_file_buffer( mdl, arr, ptr->data, stride ); } else @@ -283,6 +287,9 @@ int mdl_load_materials( mdl_context *mdl, void *lin_alloc ) mdl_array_ptr data; _mdl_load_array( mdl, &data, "shader_data", vg_mem.scratch, 1 ); + if( !lin_alloc ) + return 1; + for( u32 i=0; imaterials); i ++ ) { mdl_material *mat = mdl_arritm( &mdl->materials, i ); @@ -409,6 +416,7 @@ int mdl_pstreq( mdl_context *mdl, u32 pstr, const char *str, u32 djb2 ) * ---------------------------------------------------------------------------- */ +#ifndef C0_STOPGAP static void mesh_upload( glmesh *mesh, mdl_vert *verts, u32 vert_count, u32 *indices, u32 indice_count ) @@ -494,6 +502,7 @@ void mdl_draw_submesh( mdl_submesh *sm ) { mesh_drawn( sm->indice_start, sm->indice_count ); } +#endif mdl_mesh *mdl_find_mesh( mdl_context *mdl, const char *name ) { @@ -508,6 +517,17 @@ mdl_mesh *mdl_find_mesh( mdl_context *mdl, const char *name ) return NULL; } +mdl_submesh *mdl_find_submesh( mdl_context *mdl, const char *mesh_name ) +{ + mdl_mesh *mesh = mdl_find_mesh( mdl, mesh_name ); + + if( !mesh ) return NULL; + if( !mesh->submesh_count ) return NULL; + + return mdl_arritm( &mdl->submeshs, mesh->submesh_start ); +} + +#ifndef C0_STOPGAP struct payload_glmesh_load { mdl_vert *verts; @@ -619,3 +639,4 @@ void mdl_async_full_load_std( mdl_context *mdl ) VG_TEX2D_CLAMP|VG_TEX2D_NEAREST, &tex->glname ); } } +#endif