proxy models
[carveJwlIkooP6JGAAIwe30JlM.git] / world_render.c
index 14631421c25304a3dc4de936de1987ae999a827f..1d2256b4f6ddf88d7cefc696b68ece318e23e585 100644 (file)
@@ -154,6 +154,45 @@ struct world_pass{
    void (*fn_set_uNormalMtx)( m3x3f mnorm );
 };
 
+/* FIXME: we gotta do something about this crap, maybe batch lists. something..
+ * anything but this. */
+static
+void world_render_props( world_instance *world, u32 material_id,
+                         struct world_pass *pass ){
+   if( !mdl_arrcount( &world->ent_prop ) ) return;
+
+   /* HACK: use the first material for every prop entity */
+   ent_prop *first = mdl_arritm( &world->ent_prop, 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_prop ); j++ ){
+      ent_prop *prop = mdl_arritm( &world->ent_prop, j );
+      if( prop->flags & 0x1 ) continue;
+      
+      for( u32 k=0; k<prop->submesh_count; k++ ){
+         sm = mdl_arritm( &world->meta.submeshs, prop->submesh_start+k );
+
+         m4x3f mmdl;
+         mdl_transform_m4x3( &prop->transform, mmdl );
+
+         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 );
+      }
+   }
+}
+
 static
 void world_render_traffic( world_instance *world, u32 material_id,
                            struct world_pass *pass ){
@@ -205,6 +244,7 @@ void world_render_pass( world_instance *world, struct world_pass *pass ){
          }
          else{
             world_render_traffic( world, i, pass );
+            world_render_props( world, i, pass );
             sm = &mat->sm_no_collide;
          }