+
+void draw_vmf_group( csr_target *rt, vmf_map *map, vdf_node *root, int const group, m4x3f prev, m4x3f inst )
+{
+ m4x3f transform = M4X3_IDENTITY;
+ vmf_solid solid;
+ vmf_vert tri[3];
+
+ // Multiply previous transform with instance transform to create basis
+ if( prev )
+ {
+ m4x3_mul( prev, inst, transform );
+ }
+
+ // Draw brushes
+ solidgen_ctx_init( &solid );
+ vdf_node *world = vdf_next( root, "world", NULL );
+
+ vdf_foreach( world, "solid", brush )
+ {
+ solidgen_push( &solid, brush );
+ }
+
+ 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 );
+
+ // Actual entity loop
+ m4x3f model;
+
+ vdf_foreach( root, "entity", ent )
+ {
+ 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;
+ 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, group, transform, model );
+ }
+ else if( ent->user & VMF_FLAG_BRUSH_ENT )
+ {
+ // ...
+ }
+ }
+
+ solidgen_ctx_free( &solid );
+}