+
+ // Actual entity loop
+ m4x3f model;
+
+ vdf_foreach( root, "entity", ent )
+ {
+ if( filter_visgroups && !vmf_visgroup_match( ent, group_id ) )
+ continue;
+
+ if( filter_classname )
+ if( strcmp( kv_get( ent, "classname", "" ), filter->classname ) )
+ continue;
+
+ if( ent->user & VMF_FLAG_IS_PROP )
+ {
+ // Create model transform
+ m4x3_identity( model );
+
+ vmf_entity_transform( ent, model );
+ m4x3_mul( transform, model, model );
+
+ // Draw model
+ mdl_mesh_t *mdl = &map->models[ ent->user1 ].mdl;
+
+ if( compute_bounds_only )
+ {
+ box_copy( mdl->bounds, trf_bounds );
+ m4x3_transform_aabb( model, trf_bounds );
+
+ // Join
+ //box_concat( rt->bounds, trf_bounds );
+ }
+ else
+ {
+ for( int i = 0; i < mdl->num_indices/3; i ++ )
+ {
+ for( int j = 0; j < 3; j ++ )
+ {
+ v3_copy( &mdl->vertices[ mdl->indices[ i*3+j ] *8 ], tri[j].co );
+ v3_copy( &mdl->vertices[ mdl->indices[ i*3+j ] *8+3 ], tri[j].nrm );
+ tri[j].xy[0] = 0.f;
+ tri[j].xy[1] = 0.f;
+ }
+
+ csr_draw( rt, tri, 1, model );
+ }
+ }
+ }
+ else if( ent->user & VMF_FLAG_IS_INSTANCE )
+ {
+ m4x3_identity( model );
+ vmf_entity_transform( ent, model );
+
+ draw_vmf_group( rt, map, map->cache[ ent->user1 ].root, filter, transform, model );
+ }
+ else
+ {
+ // Brush entity
+ if( (ent_solid = vdf_next( ent, "solid", NULL )) )
+ {
+ solidgen_push( &solid, ent_solid );
+ }
+ }
+ }
+
+ if( compute_bounds_only )
+ {
+ solidgen_bounds( &solid, trf_bounds );
+ m4x3_transform_aabb( transform, trf_bounds );
+ box_concat( rt->bounds, trf_bounds );
+ }
+ else
+ {
+ // Draw brushes
+ for( int i = 0; i < csr_sb_count( solid.indices )/3; i ++ )
+ {
+ u32 * base = solid.indices + i*3;
+
+ tri[0] = solid.verts[ base[0] ];
+ tri[1] = solid.verts[ base[1] ];
+ tri[2] = solid.verts[ base[2] ];
+
+ csr_draw( rt, tri, 1, transform );
+ }
+ }
+
+ solidgen_ctx_reset( &solid );
+ solidgen_ctx_free( &solid );
+
+ printf( "Bounds resolved to: (%.3f, %.3f, %.3f) -> (%.3f, %.3f, %.3f)\n",
+ rt->bounds[0][0],rt->bounds[0][1],rt->bounds[0][2],
+ rt->bounds[1][0],rt->bounds[1][1],rt->bounds[1][2] );