fixed aabb transform func
[csRadar.git] / vmf.h
diff --git a/vmf.h b/vmf.h
index ea91d17ed7e78e59cb180c2f88eca79aea522266..ff3804d8c29691add5a67d82ba4f2eb64305f4e4 100644 (file)
--- 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 );