void (*fn_set_uPvmPrev)( m4x4f pvm );
};
-/* TODO: high level control pass renders. */
+VG_STATIC
+void world_render_traffic( world_instance *world, u32 material_id,
+ struct world_pass *pass ){
+ if( !mdl_arrcount( &world->ent_traffic ) ) return;
+
+ /* HACK: use the first material for every traffic entity */
+ ent_traffic *first = mdl_arritm( &world->ent_traffic, 0 );
+ if( !first->submesh_count ) return;
+
+ mdl_submesh *sm = mdl_arritm( &world->meta.submeshs, first->submesh_start );
+ if( sm->material_id != material_id ) return;
+
+ struct world_surface *mat = &world->surfaces[ material_id ];
+ pass->fn_bind_textures( world, mat );
+
+ for( u32 j=0; j<mdl_arrcount( &world->ent_traffic ); j++ ){
+ ent_traffic *traffic = mdl_arritm( &world->ent_traffic, j );
+
+ for( u32 k=0; k<traffic->submesh_count; k++ ){
+ sm = mdl_arritm( &world->meta.submeshs,
+ traffic->submesh_start+k );
+
+ m4x3f mmdl;
+ q_m3x3( traffic->transform.q, mmdl );
+ v3_copy( traffic->transform.co, mmdl[3] );
+
+ m4x4f m4mdl;
+ m4x3_expand( mmdl, m4mdl );
+ m4x4_mul( pass->cam->mtx_prev.pv, m4mdl, m4mdl );
+
+ pass->fn_set_mdl( mmdl );
+ pass->fn_set_uPvmPrev( m4mdl );
+
+ mdl_draw_submesh( sm );
+ }
+ }
+}
VG_STATIC
-void world_render_if( world_instance *world, struct world_pass *pass )
-{
+void world_render_pass( world_instance *world, struct world_pass *pass ){
for( int i=0; i<world->surface_count; i++ ){
struct world_surface *mat = &world->surfaces[i];
if( mat->info.shader == pass->shader ){
mdl_submesh *sm;
- if( pass->geo_type == k_world_geo_type_solid )
+ if( pass->geo_type == k_world_geo_type_solid ){
sm = &mat->sm_geo;
- else
+ }
+ else{
+ world_render_traffic( world, i, pass );
sm = &mat->sm_no_collide;
+ }
if( !sm->indice_count )
continue;
pass->fn_bind_textures( world, mat );
mdl_draw_submesh( sm );
-
- for( u32 j=0; j<mdl_arrcount( &world->ent_traffic ); j++ ){
- ent_traffic *traffic = mdl_arritm( &world->ent_traffic, j );
-
- for( u32 k=0; k<traffic->submesh_count; k++ ){
- sm = mdl_arritm( &world->meta.submeshs,
- traffic->submesh_start+k );
-
- q_m3x3( traffic->transform.q, mmdl );
- v3_copy( traffic->transform.co, mmdl[3] );
-
- m4x4f m4mdl;
- m4x3_expand( mmdl, m4mdl );
- m4x4_mul( pass->cam->mtx_prev.pv, m4mdl, m4mdl );
-
- pass->fn_set_mdl( mmdl );
- pass->fn_set_uPvmPrev( m4mdl );
-
- mdl_draw_submesh( sm );
- }
- }
}
}
}
{
mesh_bind( &world->mesh_geo );
pass->geo_type = k_world_geo_type_solid;
- world_render_if( world, pass );
+ world_render_pass( world, pass );
glDisable( GL_CULL_FACE );
mesh_bind( &world->mesh_no_collide );
pass->geo_type = k_world_geo_type_nonsolid;
- world_render_if( world, pass );
+ world_render_pass( world, pass );
glEnable( GL_CULL_FACE );
}