// Create matrix describing this entities transform
void vmf_entity_transform( vdf_node *ent, m4x3f mat );
-u32 vmf_visgroup_id( vdf_node *root, const char *name );
+int vmf_visgroup_id( vdf_node *root, const char *name );
int vmf_visgroup_match( vdf_node *ent, u32 target );
// Currently unused
{
v3f co;
v3f nrm;
- v2f xy;
+ v3f origin;
};
struct vmf_face
v3_divs( center, (float)numpoints, center );
for( ; vert_start < csr_sb_count( ctx->verts ); vert_start ++ )
{
- v2_copy( center, ctx->verts[ vert_start ].xy );
+ v3_copy( center, ctx->verts[ vert_start ].origin );
}
// Sort each faces and trianglulalate them
// Todo, put correct normal
v3_copy( (v3f){ 0.f, 0.f, 1.f }, vert->nrm );
+
+ // Todo: use real bounds of displaced vertices
+ v3_copy( center, vert->origin );
}
}
void vmf_load_all_instances( vmf_map *map, vdf_node *vmf )
{
+ char nextvmf[ 512 ];
+ const char *base = kv_get( vmf, "csr_path", "" );
+
vdf_foreach( vmf, "entity", ent )
{
if( !strcmp( kv_get( ent, "classname", "" ), "func_instance" ))
{
// Entity is in use if file is specified, if not just ignore the entity.
- const char *path = kv_get( ent, "file", "" );
- if( strcmp( path, "" ) )
+ const char *path = kv_get( ent, "file", NULL );
+
+ if( path )
{
- if( (ent->user1 = vmf_init_subvmf( map, path )))
+ // Make relative path real
+ strcpy( nextvmf, base );
+ csr_downlvl( nextvmf );
+ strcat( nextvmf, path );
+
+ if( (ent->user1 = vmf_init_subvmf( map, nextvmf )))
{
ent->user1 --;
ent->user = VMF_FLAG_IS_INSTANCE;
strcpy( inst->name, subvmf );
if( (inst->root = vdf_open_file( subvmf )) )
- {
+ {
+ vdf_kv_append( inst->root, "csr_path", subvmf );
+
// Recursive load other instances
vmf_load_all_instances( map, inst->root );
return id+1;
return NULL;
}
+ vdf_kv_append( map->root, "csr_path", path );
+
// Prepare instances
vmf_load_all_instances( map, map->root );
m4x3_scale( mat, scale );
}
-u32 vmf_visgroup_id( vdf_node *root, const char *name )
+int vmf_visgroup_id( vdf_node *root, const char *name )
{
vdf_node *dict = vdf_next( root, "visgroups", NULL );
}
}
- return 0;
+ return -1;
}
int vmf_visgroup_match( vdf_node *ent, u32 target )