From: hgn Date: Mon, 12 Jul 2021 20:26:00 +0000 (+0100) Subject: fixed aabb transform func X-Git-Url: https://harrygodden.com/git/?p=csRadar.git;a=commitdiff_plain;h=a53095e1511fecb8cc83c692e7ce7b23852fff16 fixed aabb transform func --- diff --git a/csRadar.c b/csRadar.c index 2bde602..b05b6a6 100644 --- a/csRadar.c +++ b/csRadar.c @@ -55,6 +55,8 @@ int main( int argc, char *argv[] ) exit(0); } + printf( "got: %s\n", arg ); + strings[ num_strings ++ ] = arg; } @@ -154,28 +156,32 @@ int main( int argc, char *argv[] ) .visgroup = NULL, .compute_bounds_only = 1 }; - draw_vmf_group( &target, map, map->root, &filter, NULL, NULL ); - csr_auto_fit( &target, padding ); - filter.compute_bounds_only = 0; - if( num_strings == 1 ) - { - // Draw everything - draw_vmf_group( &target, map, map->root, NULL, NULL, NULL ); - csr_rt_save_buffers( &target, output_path, "all" ); - } - else + // One pass for fitting, second pass for drawing + for( int i = 0; i < 2; i ++ ) { - // Draw groups - for( int i = 1; i < num_strings; i ++ ) + if( num_strings == 1 ) { - filter.visgroup = strings[ i ]; - - draw_vmf_group( &target, map, map->root, NULL, NULL, NULL ); - csr_rt_save_buffers( &target, output_path, strings[i] ); - - csr_rt_clear( &target ); + // Draw everything + draw_vmf_group( &target, map, map->root, &filter, NULL, NULL ); + csr_rt_save_buffers( &target, output_path, "all" ); + } + else + { + // Draw groups + for( int i = 1; i < num_strings; i ++ ) + { + filter.visgroup = strings[ i ]; + + draw_vmf_group( &target, map, map->root, &filter, NULL, NULL ); + csr_rt_save_buffers( &target, output_path, strings[i] ); + + csr_rt_clear( &target ); + } } + + filter.compute_bounds_only = 0; + csr_auto_fit( &target, padding ); } if( write_txt ) diff --git a/csrDraw.h b/csrDraw.h index 29189a1..14c91c2 100644 --- a/csrDraw.h +++ b/csrDraw.h @@ -81,18 +81,17 @@ void csr_auto_fit( csr_target *rt, float padding ) dx = rt->bounds[1][0] - rt->bounds[0][0]; dy = rt->bounds[1][1] - rt->bounds[0][1]; - l = fmaxf( dx, dy ); - d = l * ( l / dx ) * .5f; + l = fmaxf( dx, dy ) * .5f; cx = (rt->bounds[1][0] + rt->bounds[0][0]) * .5f; cy = (rt->bounds[1][1] + rt->bounds[0][1]) * .5f; - rt->bounds[0][0] = cx - d - padding; - rt->bounds[1][0] = cx + d + padding; - rt->bounds[0][1] = cy - d - padding; - rt->bounds[1][1] = cy + d + padding; + rt->bounds[0][0] = cx - l - padding; + rt->bounds[1][0] = cx + l + padding; + rt->bounds[0][1] = cy - l - padding; + rt->bounds[1][1] = cy + l + padding; - rt->scale = d + padding; + rt->scale = l + padding; csr_update_subsamples( rt ); } @@ -225,7 +224,6 @@ void draw_vmf_group( csr_target *rt, vmf_map *map, vdf_node *root, csr_filter *f m4x3f transform = M4X3_IDENTITY; vmf_solid solid; vmf_vert tri[3]; - vdf_node *ent_solid; boxf trf_bounds; u32 group_id = 0; @@ -326,7 +324,7 @@ void draw_vmf_group( csr_target *rt, vmf_map *map, vdf_node *root, csr_filter *f else { // Brush entity - if( (ent_solid = vdf_next( ent, "solid", NULL )) ) + vdf_foreach( ent, "solid", ent_solid ) { solidgen_push( &solid, ent_solid ); } diff --git a/csrMath.h b/csrMath.h index 31891f8..c14234f 100644 --- a/csrMath.h +++ b/csrMath.h @@ -408,6 +408,8 @@ void m4x3_transform_aabb( m4x3f m, boxf box ) v3_copy( box[0], a ); v3_copy( box[1], b ); + v3_fill( box[0], INFINITY ); + v3_fill( box[1], -INFINITY ); m4x3_expand_aabb_point( m, box, a ); m4x3_expand_aabb_point( m, box, (v3f){ a[0], b[1], a[2] } ); diff --git a/csrOpt.h b/csrOpt.h index 9195790..94639e3 100644 --- a/csrOpt.h +++ b/csrOpt.h @@ -167,7 +167,7 @@ char *csr_arg(void) if( carg[0] != '-' ) { - csr_argi ++; + csr_consume_next = 1; return carg; } diff --git a/makeradar.sh b/makeradar.sh index df2e713..85ae274 100755 --- a/makeradar.sh +++ b/makeradar.sh @@ -1 +1 @@ -./csRadar testmap.vmf -g "/home/harry/SteamLibrary/steamapps/common/Counter-Strike Global Offensive/csgo/gameinfo.txt" +./csRadar cs_apollo.vmf -g "/home/harry/SteamLibrary/steamapps/common/Counter-Strike Global Offensive/csgo/gameinfo.txt" tar_layout diff --git a/vmdl.h b/vmdl.h index 59d6acb..d6564a3 100644 --- a/vmdl.h +++ b/vmdl.h @@ -523,8 +523,8 @@ int mdl_from_find_files( const char *mdlname, mdl_mesh_t *ctx ) return 0; } - v3_copy( pMdl->view_bbmin, ctx->bounds[0] ); - v3_copy( pMdl->view_bbmax, ctx->bounds[1] ); + v3_copy( pMdl->hull_min, ctx->bounds[0] ); + v3_copy( pMdl->hull_max, ctx->bounds[1] ); ctx->num_indices = vtx_count_indices( pVtxHdr ); diff --git a/vmf.h b/vmf.h index ec9573a..ff3804d 100644 --- a/vmf.h +++ b/vmf.h @@ -288,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; @@ -302,6 +305,7 @@ ESolidResult solidgen_push( vmf_solid *ctx, vdf_node *node ) } is_displacement = 1; + */ } int it = 0;