X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=model.h;h=686a42849b5e6cdf630ac5d448d0a2e247e1b6e4;hb=c40f8e7332b1fa0f25ad4104f2f2ff34de37035a;hp=664950fc0191b7bf6f9e7f95e3ce6d4cffd3bb25;hpb=02e5027d274fc66fecca0572d0998e2c562da7a7;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/model.h b/model.h index 664950f..686a428 100644 --- a/model.h +++ b/model.h @@ -7,7 +7,7 @@ #include "common.h" -#define MDL_VERSION_NR 100 +#define MDL_VERSION_NR 101 enum mdl_shader { @@ -36,7 +36,8 @@ enum material_flag k_material_flag_grow_grass = 0x00000004, k_material_flag_grindable = 0x00000008, k_material_flag_invisible = 0x00000010, - k_material_flag_boundary = 0x00000020 + k_material_flag_boundary = 0x00000020, + k_material_flag_preview_visibile = 0x00000040 }; #pragma pack(push,1) @@ -407,7 +408,7 @@ VG_STATIC void mdl_open( mdl_context *mdl, const char *path, void *lin_alloc ) if( l != 1 ) mdl_load_fatal_corrupt( mdl ); - if( mdl->info.version != MDL_VERSION_NR ){ + if( mdl->info.version < MDL_VERSION_NR ){ vg_warn( "For model: %s\n", path ); vg_warn( " version: %u (current: %u)\n", mdl->info.version, MDL_VERSION_NR ); @@ -444,9 +445,24 @@ VG_STATIC void mdl_transform_m4x3( mdl_transform *transform, m4x3f mtx ) VG_STATIC const char *mdl_pstr( mdl_context *mdl, u32 pstr ) { - return mdl_arritm( &mdl->strings, pstr ); + return ((char *)mdl_arritm( &mdl->strings, pstr )) + 4; } + +VG_STATIC int +mdl_pstreq( mdl_context *mdl, u32 pstr, const char *str, u32 djb2 ) +{ + u32 hash = *((u32 *)mdl_arritm( &mdl->strings, pstr )); + if( hash == djb2 ){ + if( !strcmp( str, mdl_pstr( mdl, pstr ))) return 1; + else return 0; + } + else return 0; +} + +#define MDL_CONST_PSTREQ( MDL, Q, CONSTSTR )\ + mdl_pstreq( MDL, Q, CONSTSTR, vg_strdjb2( CONSTSTR ) ) + /* * Simple mesh interface for OpenGL * ----------------------------------------------------------------------------