fixed aabb transform func
authorhgn <hgodden00@gmail.com>
Mon, 12 Jul 2021 20:26:00 +0000 (21:26 +0100)
committerhgn <hgodden00@gmail.com>
Mon, 12 Jul 2021 20:26:00 +0000 (21:26 +0100)
csRadar.c
csrDraw.h
csrMath.h
csrOpt.h
makeradar.sh
vmdl.h
vmf.h

index 2bde6027f01b26565f53b92a57d957aeb061f202..b05b6a6be3126ae06e7d385c4923f90bd7f99498 100644 (file)
--- 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 )
index 29189a1e9cfd16cc21e10dc6d5367cdcc9627845..14c91c23fd1f1504902f5eeb1f7429239a7e84d2 100644 (file)
--- 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 );
                        }
index 31891f8cd682758faa0c897a6eb758f4f5584c2a..c14234fe6f9da4a44d0278b8cfff498ffc2be8a9 100644 (file)
--- 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] } );
index 9195790ab34253f948eb81853ea79c1d9c6485de..94639e30de8f6ed3cea66d71ec2bfd2989097311 100644 (file)
--- 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;
        }
        
index df2e713c31601406d4a3163e01a3389d13bc0a51..85ae274edf877169bf7340921c0d99e35a26960c 100755 (executable)
@@ -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 59d6acbe8c5288e16858063bd6ee5ed5464fda1c..d6564a3a87dfe4afbb5d1d2eb73d1bb663d51ab8 100644 (file)
--- 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 ec9573aaa8c21feeebca6fe9716e1f976290d742..ff3804d8c29691add5a67d82ba4f2eb64305f4e4 100644 (file)
--- 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;