}
// 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
// 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;
}
is_displacement = 1;
+ */
}
int it = 0;
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 );
// 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;
+}