X-Git-Url: https://harrygodden.com/git/?p=csRadar.git;a=blobdiff_plain;f=vmf.h;h=ff3804d8c29691add5a67d82ba4f2eb64305f4e4;hp=4793e0bda61af53b28c06a4bc521193369c9bc0a;hb=a53095e1511fecb8cc83c692e7ce7b23852fff16;hpb=1bdd02062cda9b107c4d66586d3c036ea15f6ae2 diff --git a/vmf.h b/vmf.h index 4793e0b..ff3804d 100644 --- a/vmf.h +++ b/vmf.h @@ -101,27 +101,20 @@ void solidgen_ctx_free( vmf_solid *ctx ) } // Compute bounds of solid gen ctx -void solidgen_bounds( vmf_solid *ctx, u32 start, u32 end, v3f min, v3f max ) +void solidgen_bounds( vmf_solid *ctx, boxf box ) { v3f mine = { INFINITY, INFINITY, INFINITY }; v3f maxe = {-INFINITY,-INFINITY,-INFINITY }; - for( int i = start; i < end; i ++ ) + for( int i = 0; i < csr_sb_count( ctx->verts ); i ++ ) { vmf_vert *vert = ctx->verts + i; - float *co = vert->co; - - mine[0] = fminf( mine[0], co[0] ); - mine[1] = fminf( mine[1], co[1] ); - mine[2] = fminf( mine[2], co[2] ); - - maxe[0] = fmaxf( maxe[0], co[0] ); - maxe[1] = fmaxf( maxe[1], co[1] ); - maxe[2] = fmaxf( maxe[2], co[2] ); + v3_minv( mine, vert->co, mine ); + v3_maxv( maxe, vert->co, maxe ); } - v3_copy( mine, min ); - v3_copy( maxe, max ); + v3_copy( mine, box[0] ); + v3_copy( maxe, box[1] ); } struct @@ -295,6 +288,9 @@ ESolidResult solidgen_push( vmf_solid *ctx, vdf_node *node ) // TODO: What is this for again? surely it should be the other way around... i think... if( solid_has_displacement( node ) ) { + is_displacement = 1; + /* + printf( "solid_has_displacement\n" ); num_planes = vmf_api.bisectors; @@ -309,6 +305,7 @@ ESolidResult solidgen_push( vmf_solid *ctx, vdf_node *node ) } is_displacement = 1; + */ } int it = 0; @@ -732,6 +729,12 @@ vmf_map *vmf_init( const char *path, int load_models ) vmf_map *map = csr_calloc( sizeof( vmf_map ) ); map->root = vdf_open_file( path ); + if( !map->root ) + { + free( map ); + return NULL; + } + // Prepare instances vmf_load_all_instances( map, map->root ); @@ -831,3 +834,37 @@ void vmf_entity_transform( vdf_node *ent, m4x3f mat ) // Scale m4x3_scale( mat, scale ); } + +u32 vmf_visgroup_id( vdf_node *root, const char *name ) +{ + vdf_node *dict = vdf_next( root, "visgroups", NULL ); + + if( dict ) + { + vdf_foreach( dict, "visgroup", group ) + { + if( !strcmp( kv_get( group, "name", "" ), name ) ) + { + return kv_get_int( group, "visgroupid", 0 ); + } + } + } + + return 0; +} + +int vmf_visgroup_match( vdf_node *ent, u32 target ) +{ + vdf_node *editor = vdf_next( ent, "editor", NULL ); + + if( editor ) + { + kv_foreach( editor, "visgroupid", groupe ) + { + if( target == atoi( groupe ) ) + return 1; + } + } + + return 0; +}