render placeholder boards at store
authorhgn <hgodden00@gmail.com>
Mon, 27 Nov 2023 13:57:12 +0000 (13:57 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 27 Nov 2023 13:57:12 +0000 (13:57 +0000)
ent_skateshop.c
ent_skateshop.h
world_entity.c

index ec3269435fa0f76c437624ac38c030e89d2caf57..da8a0d3c492f36e0c89d74fd46687cff56181cc7 100644 (file)
@@ -726,6 +726,37 @@ static void skateshop_render( ent_skateshop *shop ){
       vg_fatal_error( "Unknown store (%u)\n", shop->type );
 }
 
+static void skateshop_render_nonfocused( world_instance *world, camera *cam ){
+   for( u32 j=0; j<mdl_arrcount( &world->ent_skateshop ); j ++ ){
+      ent_skateshop *shop = mdl_arritm(&world->ent_skateshop, j );
+
+      if( shop->type != k_skateshop_type_boardshop ) continue;
+
+      f32 dist2 = v3_dist2( cam->pos, shop->transform.co ),
+          maxdist = 50.0f;
+
+      if( dist2 > maxdist*maxdist ) continue;
+      ent_marker *mark_rack = mdl_arritm( &world->ent_marker, 
+                                     mdl_entity_id_id(shop->boards.id_rack));
+
+      u32 slot_count = vg_list_size(global_skateshop.shop_view_slots);
+      for( u32 i=0; i<slot_count; i++ ){
+         struct player_board *board = &localplayer.fallback_board;
+
+         mdl_transform xform;
+         transform_identity( &xform );
+
+         xform.co[0] = -((float)i - ((float)slot_count)*0.5f)*0.45f;
+         mdl_transform_mul( &mark_rack->transform, &xform, &xform );
+
+         struct player_board_pose pose = {0};
+         m4x3f mmdl;
+         mdl_transform_m4x3( &xform, mmdl );
+         render_board( cam, world, board, mmdl, &pose, k_board_shader_entity );
+      }
+   }
+}
+
 static void ent_skateshop_helpers_pickable( const char *acceptance ){
    vg_str text;
 
index d39e3d94dbb66bb2cf49cbc67a180efe9f80a720..455c61df16c2e02dc687a64121f89d547708de68 100644 (file)
@@ -49,5 +49,6 @@ static global_skateshop={
 
 static void ent_skateshop_preupdate( ent_skateshop *shop, int active );
 static void skateshop_render( ent_skateshop *shop );
+static void skateshop_render_nonfocused( world_instance *world, camera *cam );
 
 #endif /* ENT_SKATESHOP_H */
index 04bbec9891749740e2cc8d51534e710b16371077..947a3bdc387c11a13ffa6b980231c5e42fefa619 100644 (file)
@@ -81,12 +81,14 @@ static void world_entity_focus_preupdate(void){
 
 /* additional renderings like text etc.. */
 static void world_entity_focus_render(void){
-   if( skaterift.activity != k_skaterift_ent_focus )
+   world_instance *world = world_current_instance();
+   if( skaterift.activity != k_skaterift_ent_focus ){
+      skateshop_render_nonfocused( world, &skaterift.cam );
       return;
+   }
 
    u32 type = mdl_entity_id_type( world_static.focused_entity ),
        index = mdl_entity_id_id( world_static.focused_entity );
-   world_instance *world = world_current_instance();
 
    if( type == k_ent_skateshop ){
       ent_skateshop *skateshop = mdl_arritm( &world->ent_skateshop, index );