preview for challenges and new system
authorhgn <hgodden00@gmail.com>
Fri, 11 Aug 2023 15:06:46 +0000 (16:06 +0100)
committerhgn <hgodden00@gmail.com>
Fri, 11 Aug 2023 15:06:46 +0000 (16:06 +0100)
40 files changed:
blender_export.py
ent_challenge.c
ent_challenge.h [new file with mode: 0644]
ent_objective.c [new file with mode: 0644]
ent_skateshop.c
ent_skateshop.h
ent_unlock.c [deleted file]
entity.c
entity.h
font.h
maps_src/mp_spawn/main.mdl
player.c
shaders/common_world.glsl
shaders/model_board_view.h
shaders/model_character_view.h
shaders/model_entity.h
shaders/model_sky.h
shaders/scene_cubemapped.h
shaders/scene_depth.h
shaders/scene_font.fs
shaders/scene_font.h
shaders/scene_fxglow.h
shaders/scene_position.h
shaders/scene_route.h
shaders/scene_scoretext.h
shaders/scene_standard.h
shaders/scene_standard_alphatest.h
shaders/scene_terrain.h
shaders/scene_vertex_blend.h
shaders/scene_water.h
shaders/scene_water_fast.h
skaterift.c
skaterift.h
world.h
world_entity.c
world_entity.h
world_gen.c
world_load.c
world_render.c
world_render.h

index d8fb6aec0ba0e5609e853d1287146b82b741783d..1b1c4fb69e9e22ad098c73109230ffeb6303db74 100644 (file)
@@ -37,14 +37,14 @@ sr_entity_list = [
    ('ent_menuitem',     'Menu Item',      '', 15 ),
    ('ent_worldinfo',    'World Info',     '', 16 ),
    ('ent_ccmd',         'CCmd',           '', 17 ),
-   ('ent_challenge',    'Challenge',      '', 18 ),
-   ('ent_unlock',       'Unlockable',     '', 19 ),
+   ('ent_objective',    'Objective',      '', 18 ),
+   ('ent_challenge',    'Challenge',      '', 19 ),
    ('ent_relay',        'Relay',          '', 20 )
 ]
 
 MDL_VERSION_NR = 102
-SR_TRIGGERABLE = [ 'ent_audio', 'ent_ccmd', 'ent_gate', 'ent_unlock', \
-                   'ent_relay', 'ent_skateshop', 'ent_challenge' ]
+SR_TRIGGERABLE = [ 'ent_audio', 'ent_ccmd', 'ent_gate', 'ent_challenge', \
+                   'ent_relay', 'ent_skateshop', 'ent_objective' ]
 
 def get_entity_enum_id( alias ):
 #{
@@ -459,7 +459,7 @@ class ent_ccmd(Structure):
    _fields_ = [("pstr_command",c_uint32)]
 #}
 
-class ent_challenge(Structure):#{
+class ent_objective(Structure):#{
    _fields_ = [("transform",mdl_transform),
                ("submesh_start",c_uint32), ("submesh_count",c_uint32),
                ("flags",c_uint32),
@@ -470,18 +470,23 @@ class ent_challenge(Structure):#{
                ("time_limit",c_float)]
 
    sr_functions = { 0: 'trigger',
-                    1: 'start_challenge',
                     2: 'show',
                     3: 'hide' }
 #}
 
-class ent_unlock(Structure):#{
+class ent_challenge(Structure):#{
    _fields_ = [("transform",mdl_transform),
                ("pstr_alias",c_uint32),
+               ("flags",c_uint32),
                ("target",c_uint32),
                ("target_event",c_uint32),
-               ("status",c_uint32)]
-   sr_functions = { 0: 'unlock' }
+               ("reset",c_uint32),
+               ("reset_event",c_uint32),
+               ("first",c_uint32),
+               ("camera",c_uint32),
+               ("status",c_uint32)] #runtime
+   sr_functions = { 0: 'unlock',
+                    1: 'view/reset' }
 #}
 
 class ent_relay(Structure):#{
@@ -1626,7 +1631,7 @@ def sr_compile( collection ):
          if ent_type == 'ent_font': continue
          if ent_type == 'ent_font_variant': continue
          if ent_type == 'ent_menuitem': continue
-         if ent_type == 'ent_challenge': continue
+         if ent_type == 'ent_objective': continue
 
          #TODO: This is messy.
          if ent_type == 'ent_gate':#{
@@ -1856,32 +1861,38 @@ def sr_compile( collection ):
             ccmd.pstr_command = sr_compile_string( obj_data.command )
             sr_ent_push( ccmd )
          #}
+         elif ent_type == 'ent_objective':#{
+            objective = ent_objective()
+            obj_data = obj.SR_data.ent_objective[0]
+            objective.id_next = sr_entity_id( obj_data.proxima )
+            objective.id_win = sr_entity_id( obj_data.target )
+            objective.win_event = obj_data.target_event
+            objective.filter = int(obj_data.filtrar)
+            objective.filter2 = 0
+            objective.time_limit = obj_data.time_limit
+
+            compile_obj_transform( obj, objective.transform )
+            objective.submesh_start, objective.submesh_count, _ = \
+                  sr_compile_mesh_internal( obj )
+
+            sr_ent_push( objective )
+         #}
          elif ent_type == 'ent_challenge':#{
             challenge = ent_challenge()
             obj_data = obj.SR_data.ent_challenge[0]
-            challenge.id_next = sr_entity_id( obj_data.proxima )
-            challenge.id_win = sr_entity_id( obj_data.target )
-            challenge.win_event = obj_data.target_event
-            challenge.filter = int(obj_data.filtrar)
-            challenge.filter2 = 0
-            challenge.time_limit = obj_data.time_limit
-
             compile_obj_transform( obj, challenge.transform )
-            challenge.submesh_start, challenge.submesh_count, _ = \
-                  sr_compile_mesh_internal( obj )
-
+            challenge.pstr_alias = sr_compile_string( obj_data.alias )
+            challenge.target = sr_entity_id( obj_data.target )
+            challenge.target_event = obj_data.target_event
+            challenge.reset = sr_entity_id( obj_data.reset )
+            challenge.reset_event = obj_data.reset_event
+            challenge.first = sr_entity_id( obj_data.first )
+            challenge.flags = 0x00
+            challenge.camera = sr_entity_id( obj_data.camera )
+            if obj_data.time_limit: challenge.flags |= 0x01
+            challenge.status = 0
             sr_ent_push( challenge )
          #}
-         elif ent_type == 'ent_unlock':#{
-            unlock = ent_unlock()
-            obj_data = obj.SR_data.ent_unlock[0]
-            compile_obj_transform( obj, unlock.transform )
-            unlock.pstr_alias = sr_compile_string( obj_data.alias )
-            unlock.target = sr_entity_id( obj_data.target )
-            unlock.target_event = obj_data.target_event
-            unlock.status = 0
-            sr_ent_push( unlock )
-         #}
          elif ent_type == 'ent_relay':#{
             relay = ent_relay()
             obj_data = obj.SR_data.ent_relay[0]
@@ -3197,10 +3208,10 @@ class SR_OBJECT_ENT_CCMD(bpy.types.PropertyGroup):
    command: bpy.props.StringProperty(name="Command Line")
 #}
 
-class SR_OBJECT_ENT_CHALLENGE(bpy.types.PropertyGroup):#{
+class SR_OBJECT_ENT_OBJECTIVE(bpy.types.PropertyGroup):#{
    proxima: bpy.props.PointerProperty( \
             type=bpy.types.Object, name="Next", \
-            poll=lambda self,obj: sr_filter_ent_type(obj,['ent_challenge']))
+            poll=lambda self,obj: sr_filter_ent_type(obj,['ent_objective']))
    target: bpy.props.PointerProperty( \
            type=bpy.types.Object, name="Win", \
            poll=lambda self,obj: sr_filter_ent_type(obj,SR_TRIGGERABLE))
@@ -3218,7 +3229,8 @@ class SR_OBJECT_ENT_CHALLENGE(bpy.types.PropertyGroup):#{
              (str(0x20),'grind_truck_any',''),
              (str(0x40),'grind_board_any',''),
              (str(0x20|0x40),'grind_any',''),
-             (str(0x80),'footplant','')
+             (str(0x80),'footplant',''),
+             (str(0x100),'passthrough',''),
              ])
 
    @staticmethod
@@ -3230,17 +3242,37 @@ class SR_OBJECT_ENT_CHALLENGE(bpy.types.PropertyGroup):#{
    #}
 #}
 
-class SR_OBJECT_ENT_UNLOCK(bpy.types.PropertyGroup):#{
+class SR_OBJECT_ENT_CHALLENGE(bpy.types.PropertyGroup):#{
    alias: bpy.props.StringProperty( name="Alias" )
+
    target: bpy.props.PointerProperty( \
-            type=bpy.types.Object, name="Target", \
+            type=bpy.types.Object, name="On Complete", \
             poll=lambda self,obj: sr_filter_ent_type(obj,SR_TRIGGERABLE))
    target_event: bpy.props.IntProperty( name="Event/Method" )
+   reset: bpy.props.PointerProperty( \
+           type=bpy.types.Object, name="On Reset", \
+           poll=lambda self,obj: sr_filter_ent_type(obj,SR_TRIGGERABLE))
+   reset_event: bpy.props.IntProperty( name="Event/Method" )
+
+   time_limit: bpy.props.BoolProperty( name="Time Limit" )
+
+   first: bpy.props.PointerProperty( \
+            type=bpy.types.Object, name="First Objective", \
+            poll=lambda self,obj: sr_filter_ent_type(obj,['ent_objective']))
+
+   camera: bpy.props.PointerProperty( \
+           type=bpy.types.Object, name="Camera", \
+           poll=lambda self,obj: sr_filter_ent_type(obj,['ent_camera']))
+
 
    @staticmethod
    def sr_inspector( layout, data ):#{
       layout.prop( data[0], 'alias' )
+      layout.prop( data[0], 'camera' )
+      layout.prop( data[0], 'first' )
+      layout.prop( data[0], 'time_limit' )
       SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'target' )
+      SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'reset' )
    #}
 #}
 
@@ -3289,8 +3321,8 @@ class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup):
    ent_menuitem: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_MENU_ITEM)
    ent_worldinfo: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_WORLD_INFO)
    ent_ccmd: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_CCMD)
+   ent_objective: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_OBJECTIVE)
    ent_challenge: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_CHALLENGE)
-   ent_unlock: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_UNLOCK)
    ent_relay: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_RELAY)
 
    ent_type: bpy.props.EnumProperty(
@@ -4253,10 +4285,10 @@ def cv_draw():#{
          elif ent_type == 'ent_volume':#{
             cv_ent_volume( obj )
          #}
-         elif ent_type == 'ent_challenge':#{
-            data = obj.SR_data.ent_challenge[0]
+         elif ent_type == 'ent_objective':#{
+            data = obj.SR_data.ent_objective[0]
             if data.proxima:#{
-               cv_draw_arrow( obj.location, data.proxima.location, (1,1,1) )
+               cv_draw_arrow( obj.location, data.proxima.location, (1,0.6,0.2) )
             #}
             if data.target:
                cv_draw_arrow( obj.location, data.target.location, (1,1,1) )
@@ -4272,14 +4304,21 @@ def cv_draw():#{
             if data.target3:
                cv_draw_arrow( obj.location, data.target3.location, (1,1,1) )
          #}
-         elif ent_type == 'ent_unlock':#{
-            data = obj.SR_data.ent_unlock[0]
+         elif ent_type == 'ent_challenge':#{
+            data = obj.SR_data.ent_challenge[0]
             if data.target:
                cv_draw_arrow( obj.location, data.target.location, (1,1,1) )
+            if data.reset:
+               cv_draw_arrow( obj.location, data.reset.location, (0.9,0,0) )
+            if data.first:
+               cv_draw_arrow( obj.location, data.first.location, (1,0.6,0.2) )
+
             cc1 = (0.4,0.3,0.2)
             info_cu = Vector((1.2,0.01,0.72))*0.5
             info_co = Vector((0.0,0.0,0.72))*0.5
             cv_draw_ucube( obj.matrix_world, cc1, info_cu, info_co)
+            if data.camera:
+               cv_draw_line_dotted( obj.location, data.camera.location, (1,1,1))
 
             vs = [Vector((-0.2,0.0,0.10)),Vector((-0.2,0.0,0.62)),\
                   Vector(( 0.2,0.0,0.62)),Vector((-0.2,0.0,0.30)),\
@@ -4355,6 +4394,11 @@ def cv_draw():#{
                info_cu = Vector((1.2,0.01,0.3))*0.5
                info_co = Vector((0.0,0.0,0.0))*0.5
             #}
+            elif data.tipo == '3':#{
+               rack = None
+               display = None
+               info = None
+            #}
 
             if rack:
                cv_draw_ucube( rack.matrix_world, cc, rack_cu, rack_co )
@@ -4506,7 +4550,8 @@ classes = [ SR_INTERFACE, SR_MATERIAL_PANEL,\
             SR_OBJECT_ENT_FONT,SR_OBJECT_ENT_TRAFFIC,SR_OBJECT_ENT_SKATESHOP,\
             SR_OBJECT_ENT_WORKSHOP_PREVIEW,SR_OBJECT_ENT_MENU_ITEM,\
             SR_OBJECT_ENT_WORLD_INFO,SR_OBJECT_ENT_CCMD,\
-            SR_OBJECT_ENT_CHALLENGE,SR_OBJECT_ENT_UNLOCK,SR_OBJECT_ENT_RELAY,\
+            SR_OBJECT_ENT_OBJECTIVE,SR_OBJECT_ENT_CHALLENGE,\
+            SR_OBJECT_ENT_RELAY,\
             \
             SR_OBJECT_PROPERTIES, SR_LIGHT_PROPERTIES, SR_BONE_PROPERTIES, 
             SR_MESH_PROPERTIES, SR_MATERIAL_PROPERTIES \
index 6f031bacc1ce93f634b3b2aefdf60fe406e28a8c..515aeb09d5e456b813dbb00c40642cc7fa72348a 100644 (file)
 #ifndef ENT_CHALLENGE_C
 #define ENT_CHALLENGE_C
 
-#include "world.h"
-#include "world_load.h"
 #include "entity.h"
+#include "input.h"
 
-VG_STATIC void ent_challenge_pass( world_instance *world, 
-                                   ent_challenge *challenge ){
-   if( challenge->id_next ){
-      world->challenge_timer += challenge->filter;
-
-      u32 index = mdl_entity_id_id( challenge->id_next );
-      ent_challenge *next = mdl_arritm( &world->ent_challenge, index );
-      world->challenge_target = next;
-
-      vg_info( "pass challenge point\n" );
-   }
-   else {
-      vg_success( "NYU Film school graduate SUCKAH\n" );
-      world->challenge_target = NULL;
-      world->challenge_timer = 0.0f;
+VG_STATIC void ent_challenge_call( world_instance *world, ent_call *call ){
+   u32 index = mdl_entity_id_id( call->id );
+   ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
 
-      if( challenge->id_win ){
+   if( call->function == 0 ){ /* challenge() */
+      if( !challenge->status ){
+         vg_info( "challenge( '%s' )\n", 
+                  mdl_pstr( &world->meta, challenge->pstr_alias) );
          ent_call call;
          call.data = NULL;
-         call.function = challenge->win_event;
-         call.id = challenge->id_win;
+         call.function = challenge->target_event;
+         call.id = challenge->target;
          entity_call( world, &call );
       }
+      challenge->status = 1;
    }
-}
-
-VG_STATIC int ent_challenge_check_filter( ent_challenge *challenge ){
-   if( challenge->filter ){
-      struct player_skate_state *s = &localplayer._skate.state;
-      enum trick_type trick = s->trick_type;
-
-      u32 state = 0x00;
-
-      if( trick == k_trick_type_shuvit ) 
-         state |= k_ent_challenge_filter_trick_shuvit;
-      if( trick == k_trick_type_treflip )
-         state |= k_ent_challenge_filter_trick_treflip;
-      if( trick == k_trick_type_kickflip )
-         state |= k_ent_challenge_filter_trick_kickflip;
-      
-      if( s->flip_rate < -0.0001f ) state |= k_ent_challenge_filter_flip_back;
-      if( s->flip_rate >  0.0001f ) state |= k_ent_challenge_filter_flip_front;
-
-      if( s->activity == k_skate_activity_grind_5050 ||
-          s->activity == k_skate_activity_grind_back50 ||
-          s->activity == k_skate_activity_grind_front50 ) 
-         state |= k_ent_challenge_filter_grind_truck_any;
-
-      if( s->activity == k_skate_activity_grind_boardslide )
-         state |= k_ent_challenge_filter_grind_board_any;
-
-      return ((challenge->filter  & state) || !challenge->filter) && 
-             ((challenge->filter2 & state) || !challenge->filter2);
+   else if( call->function == 1 ){  /* view() */
+      world_entity_focus( call->id );
    }
    else {
-      return 1;
+      vg_print_backtrace();
+      vg_error( "Unhandled function id: %u\n", call->function );
    }
 }
 
-VG_STATIC void ent_challenge_call( world_instance *world, ent_call *call ){
-   u32 index = mdl_entity_id_id( call->id );
-   ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+VG_STATIC void ent_challenge_preupdate( ent_challenge *challenge ){
+   world_instance *world = world_current_instance();
 
-   if( call->function == 0 ){
-      if( challenge->flags & k_ent_challenge_hidden ) return;
+   if( mdl_entity_id_type( challenge->camera ) == k_ent_camera ){
+      u32 index = mdl_entity_id_id( challenge->camera );
+      ent_camera *cam = mdl_arritm( &world->ent_camera, index );
 
-      if( world->challenge_target ){
-         if( (world->challenge_target == challenge) && 
-              ent_challenge_check_filter( challenge )){
-            ent_challenge_pass( world, challenge );
-         }
-         else {
-            vg_error( "womp womp\n" );
-            world->challenge_target = NULL;
-            world->challenge_timer = 0.0f;
-         }
-      }
+      /* TODO COMPRESSION */
+      v3f dir = {0.0f,-1.0f,0.0f};
+      mdl_transform_vector( &cam->transform, dir, dir );
+      m3x3_mulv( localplayer.invbasis, dir, dir );
+      player_vector_angles( world_static.focus_cam.angles, dir, 1.0f, 0.0f );
+      v3_copy( cam->transform.co, world_static.focus_cam.pos );
+      world_static.focus_cam.fov = cam->fov;
    }
-   else if( call->function == 1 ){
-      if( challenge->flags & k_ent_challenge_hidden ) return;
-
-      vg_info( "begin the challenge\n" );
-      world->challenge_timer = 0.0f;
-      ent_challenge_pass( world, challenge );
+   else {
+      /* TODO COMPRESSION */
+      v3_copy( localplayer.cam.pos, world_static.focus_cam.pos );
+      v3_copy( localplayer.cam.angles, world_static.focus_cam.angles );
+      world_static.focus_cam.fov = localplayer.cam.fov;
+      world_static.focus_cam.nearz = localplayer.cam.nearz;
+      world_static.focus_cam.farz = localplayer.cam.farz;
    }
-   else if( call->function == 2 ){
-      challenge->flags &= ~k_ent_challenge_hidden;
 
-      if( mdl_entity_id_type( challenge->id_next ) == k_ent_challenge ){
-         call->id = challenge->id_next;
-         entity_call( world, call );
-      }
+   if( button_down( k_srbind_mback ) ){
+      world_entity_unfocus();
+      return;
    }
-   else if( call->function == 3 ){
-      challenge->flags |=  k_ent_challenge_hidden;
+}
 
-      if( mdl_entity_id_type( challenge->id_next ) == k_ent_challenge ){
-         call->id = challenge->id_next;
-         entity_call( world, call );
-      }
-   }
-   else {
-      vg_print_backtrace();
-      vg_error( "Unhandled function id: %u\n", call->function );
-   }
+VG_STATIC void ent_challenge_render( ent_challenge *challenge ){
+   
 }
 
 #endif /* ENT_CHALLENGE_C */
diff --git a/ent_challenge.h b/ent_challenge.h
new file mode 100644 (file)
index 0000000..01068e8
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef ENT_CHALLENGE_H
+#define ENT_CHALLENGE_H
+
+#include "entity.h"
+
+VG_STATIC void ent_challenge_preupdate( ent_challenge *challenge );
+VG_STATIC void ent_challenge_call( world_instance *world, ent_call *call );
+
+#endif /* ENT_CHALLENGE_H */
diff --git a/ent_objective.c b/ent_objective.c
new file mode 100644 (file)
index 0000000..330e60f
--- /dev/null
@@ -0,0 +1,120 @@
+#ifndef ENT_OBJECTIVE_C
+#define ENT_OBJECTIVE_C
+
+#include "world.h"
+#include "world_load.h"
+#include "entity.h"
+
+VG_STATIC void ent_objective_pass( world_instance *world, 
+                                   ent_objective *objective ){
+   if( objective->id_next ){
+      world->challenge_timer += objective->filter;
+
+      u32 index = mdl_entity_id_id( objective->id_next );
+      ent_objective *next = mdl_arritm( &world->ent_objective, index );
+      world->challenge_target = next;
+
+      if( next->filter & k_ent_objective_filter_passthrough )
+         ent_objective_pass( world, next );
+      else
+         vg_info( "pass challenge point\n" );
+   }
+   else {
+      vg_success( "NYU Film school graduate SUCKAH\n" );
+      world->challenge_target = NULL;
+      world->challenge_timer = 0.0f;
+
+      if( objective->id_win ){
+         ent_call call;
+         call.data = NULL;
+         call.function = objective->win_event;
+         call.id = objective->id_win;
+         entity_call( world, &call );
+      }
+   }
+}
+
+VG_STATIC int ent_objective_check_filter( ent_objective *objective ){
+   if( objective->filter ){
+      struct player_skate_state *s = &localplayer._skate.state;
+      enum trick_type trick = s->trick_type;
+
+      u32 state = 0x00;
+
+      if( trick == k_trick_type_shuvit ) 
+         state |= k_ent_objective_filter_trick_shuvit;
+      if( trick == k_trick_type_treflip )
+         state |= k_ent_objective_filter_trick_treflip;
+      if( trick == k_trick_type_kickflip )
+         state |= k_ent_objective_filter_trick_kickflip;
+      
+      if( s->flip_rate < -0.0001f ) state |= k_ent_objective_filter_flip_back;
+      if( s->flip_rate >  0.0001f ) state |= k_ent_objective_filter_flip_front;
+
+      if( s->activity == k_skate_activity_grind_5050 ||
+          s->activity == k_skate_activity_grind_back50 ||
+          s->activity == k_skate_activity_grind_front50 ) 
+         state |= k_ent_objective_filter_grind_truck_any;
+
+      if( s->activity == k_skate_activity_grind_boardslide )
+         state |= k_ent_objective_filter_grind_board_any;
+
+      return ((objective->filter  & state) || !objective->filter) && 
+             ((objective->filter2 & state) || !objective->filter2);
+   }
+   else {
+      return 1;
+   }
+}
+
+VG_STATIC void ent_objective_call( world_instance *world, ent_call *call ){
+   u32 index = mdl_entity_id_id( call->id );
+   ent_objective *objective = mdl_arritm( &world->ent_objective, index );
+
+   if( call->function == 0 ){
+      if( objective->flags & k_ent_objective_hidden ) return;
+
+      if( world->challenge_target ){
+         if( (world->challenge_target == objective) && 
+              ent_objective_check_filter( objective )){
+            ent_objective_pass( world, objective );
+         }
+         else {
+            vg_error( "womp womp\n" );
+            world->challenge_target = NULL;
+            world->challenge_timer = 0.0f;
+         }
+      }
+   }
+#if 0
+   else if( call->function == 1 ){
+      if( objective->flags & k_ent_objective_hidden ) return;
+
+      vg_info( "begin the challenge\n" );
+      world->challenge_timer = 0.0f;
+      ent_objective_pass( world, objective );
+   }
+#endif
+   else if( call->function == 2 ){
+      objective->flags &= ~k_ent_objective_hidden;
+
+      if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){
+         call->id = objective->id_next;
+         entity_call( world, call );
+      }
+   }
+   else if( call->function == 3 ){
+      objective->flags |=  k_ent_objective_hidden;
+
+      if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){
+         call->id = objective->id_next;
+         entity_call( world, call );
+      }
+   }
+   else {
+      vg_print_backtrace();
+      vg_error( "Unhandled function id: %u\n", call->function );
+   }
+}
+
+#endif /* ENT_OBJECTIVE_C */
index 4c5817dd31e91ca1c9344adf8a450d515842f57b..56d8c01fe8557bcde628799fde5cb8c3d377f988 100644 (file)
@@ -163,20 +163,9 @@ VG_STATIC void skateshop_load_world_preview( addon_reg *reg ){
  * VG event preupdate 
  */
 void temp_update_playermodel(void);
-VG_STATIC void global_skateshop_preupdate(void){
-   float rate = vg_minf( 1.0f, vg.time_frame_delta * 2.0f );
-   int active = 0;
-   if( skaterift.activity == k_skaterift_skateshop )
-      active = 1;
-
-   vg_slewf( &global_skateshop.factive, active, 
-             vg.time_frame_delta * (1.0f/0.5f) );
-
-   if( !active ) return;
-
+VG_STATIC void ent_skateshop_preupdate( ent_skateshop *shop ){
    /* input filter */
    world_instance *world = world_current_instance();
-   ent_skateshop *shop = global_skateshop.ptr_ent;
 
    /* camera positioning */
    ent_camera *ref = mdl_arritm( &world->ent_camera, 
@@ -185,7 +174,7 @@ VG_STATIC void global_skateshop_preupdate(void){
    v3f dir = {0.0f,-1.0f,0.0f};
    mdl_transform_vector( &ref->transform, dir, dir );
    m3x3_mulv( localplayer.invbasis, dir, dir );
-   player_vector_angles( global_skateshop.cam.angles, dir, 1.0f, 0.0f );
+   player_vector_angles( world_static.focus_cam.angles, dir, 1.0f, 0.0f );
 
    v3f lookat;
    if( shop->type == k_skateshop_type_boardshop ||
@@ -202,8 +191,8 @@ VG_STATIC void global_skateshop_preupdate(void){
    q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, 
                  atan2f(lookat[0],lookat[2]) );
 
-   v3_copy( ref->transform.co, global_skateshop.cam.pos );
-   global_skateshop.cam.fov = ref->fov;
+   v3_copy( ref->transform.co, world_static.focus_cam.pos );
+   world_static.focus_cam.fov = ref->fov;
 
    /* input */
    if( shop->type == k_skateshop_type_boardshop ){
@@ -251,7 +240,7 @@ VG_STATIC void global_skateshop_preupdate(void){
          addon_cache_watch( k_addon_type_board, cache_id );
          localplayer.board_view_slot = cache_id;
 
-         global_skateshop_exit();
+         world_entity_unfocus();
          skaterift_autosave(1);
          return;
       }
@@ -295,7 +284,7 @@ VG_STATIC void global_skateshop_preupdate(void){
       }
 
       if( button_down( k_srbind_maccept ) ){
-         global_skateshop_exit();
+         world_entity_unfocus();
       }
    }
    else if( shop->type == k_skateshop_type_worldshop ){
@@ -377,15 +366,13 @@ VG_STATIC void global_skateshop_preupdate(void){
    }
 
    if( button_down( k_srbind_mback ) ){
-      global_skateshop_exit();
+      world_entity_unfocus();
       return;
    }
 }
 
-VG_STATIC void skateshop_render_boardshop(void){
+VG_STATIC void skateshop_render_boardshop( ent_skateshop *shop ){
    world_instance *world = world_current_instance();
-   ent_skateshop *shop = global_skateshop.ptr_ent;
-
    u32 slot_count = vg_list_size(global_skateshop.shop_view_slots);
 
    ent_marker *mark_rack = mdl_arritm( &world->ent_marker, 
@@ -549,15 +536,12 @@ fade_out:;
    SDL_AtomicUnlock( &addon_system.sl_cache_using_resources );
 }
 
-VG_STATIC void skateshop_render_charshop(void)
-{
+VG_STATIC void skateshop_render_charshop( ent_skateshop *shop ){
 }
 
-VG_STATIC void skateshop_render_worldshop(void)
-{
+VG_STATIC void skateshop_render_worldshop( ent_skateshop *shop ){
    world_instance *world = world_current_instance();
 
-   ent_skateshop *shop = global_skateshop.ptr_ent;
    ent_marker *mark_display = mdl_arritm( &world->ent_marker,
                                   mdl_entity_id_id(shop->worlds.id_display)),
               *mark_info = mdl_arritm( &world->ent_marker, 
@@ -659,30 +643,21 @@ VG_STATIC void skateshop_render_worldshop(void)
 /*
  * World: render event
  */
-VG_STATIC void skateshop_render(void){
-   if( skaterift.activity != k_skaterift_skateshop ) return;
-      
-   ent_skateshop *shop = global_skateshop.ptr_ent;
-
-   if( shop->type == k_skateshop_type_boardshop ){
-      skateshop_render_boardshop();
-   }
-   else if( shop->type == k_skateshop_type_charshop ){
-      skateshop_render_charshop();
-   }
-   else if( shop->type == k_skateshop_type_worldshop ){
-      skateshop_render_worldshop();
-   }
-   else{
+VG_STATIC void skateshop_render( ent_skateshop *shop ){
+   if( shop->type == k_skateshop_type_boardshop )
+      skateshop_render_boardshop( shop );
+   else if( shop->type == k_skateshop_type_charshop )
+      skateshop_render_charshop( shop );
+   else if( shop->type == k_skateshop_type_worldshop )
+      skateshop_render_worldshop( shop );
+   else
       vg_fatal_error( "Unknown store (%u)\n", shop->type );
-   }
 }
 
 /*
  * Entity logic: entrance event
  */
-VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
-{
+VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call ){
    u32 index = mdl_entity_id_id( call->id );
    ent_skateshop *shop = mdl_arritm( &world->ent_skateshop, index );
    vg_info( "skateshop_call\n" );
@@ -695,6 +670,8 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
       
       vg_info( "Entering skateshop\n" );
 
+      world_entity_focus( call->id );
+#if 0
       localplayer.immobile = 1;
       menu.disable_open = 1;
       skaterift.activity = k_skaterift_skateshop;
@@ -703,6 +680,7 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
       v3_zero( localplayer.rb.w );
       localplayer._walk.move_speed = 0.0f;
       global_skateshop.ptr_ent = shop;
+#endif
       
       if( shop->type == k_skateshop_type_boardshop ){
          skateshop_update_viewpage();
@@ -718,15 +696,4 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
    }
 }
 
-/*
- * Entity logic: exit event
- */
-VG_STATIC void global_skateshop_exit(void){
-   vg_info( "exit skateshop\n" );
-   localplayer.immobile = 0;
-   skaterift.activity = k_skaterift_default;
-   menu.disable_open = 0;
-   srinput.enabled = 0;
-}
-
 #endif /* ENT_SKATESHOP_C */
index 1d0699a58b97edef1e690e5580e3633732646abf..23e43c07fb2f6196eaa2b5cfca78822ccd556431 100644 (file)
 
 struct{
    v3f look_target;
-   ent_skateshop *ptr_ent;
-   float factive;
+
+#if 0
+   ent_skateshop *ptr_ent;    /* TODO */
+   float factive;             /* TODO */
+   camera cam;
+#endif
 
    struct shop_view_slot{
       u16 cache_id;
@@ -34,11 +38,10 @@ struct{
       u32 world_reg;
    }
    render;
-
-   camera cam;
 }
 static global_skateshop={.render={.reg_id=0xffffffff,.world_reg=0xffffffff}};
 
-VG_STATIC void global_skateshop_exit(void);
+VG_STATIC void ent_skateshop_preupdate( ent_skateshop *shop );
+VG_STATIC void skateshop_render( ent_skateshop *shop );
 
 #endif /* ENT_SKATESHOP_H */
diff --git a/ent_unlock.c b/ent_unlock.c
deleted file mode 100644 (file)
index 8a266ae..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef ENT_UNLOCK_C
-#define ENT_UNLOCK_C
-
-#include "entity.h"
-
-VG_STATIC void ent_unlock_call( world_instance *world, ent_call *call ){
-   u32 index = mdl_entity_id_id( call->id );
-   ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
-
-   if( call->function == 0 ){ /* unlock() */
-      if( !unlock->status ){
-         vg_info( "unlock( '%s' )\n", 
-                  mdl_pstr( &world->meta, unlock->pstr_alias) );
-         ent_call call;
-         call.data = NULL;
-         call.function = unlock->target_event;
-         call.id = unlock->target;
-         entity_call( world, &call );
-      }
-      unlock->status = 1;
-   }
-   else {
-      vg_print_backtrace();
-      vg_error( "Unhandled function id: %u\n", call->function );
-   }
-}
-
-#endif /* ENT_UNLOCK_C */
index 33bed055a2b8d0df0eafa1b84ea6f6a32ff4c3ee..82c3ecde18601037942289e3a9dcb4f02f5091b1 100644 (file)
--- a/entity.c
+++ b/entity.c
@@ -6,8 +6,8 @@
 #include "world_entity.h"
 
 #include "ent_skateshop.c"
+#include "ent_objective.c"
 #include "ent_challenge.c"
-#include "ent_unlock.c"
 #include "ent_relay.c"
 
 typedef void (*fn_entity_call_handler)( world_instance *, ent_call *);
@@ -19,11 +19,11 @@ VG_STATIC void entity_call( world_instance *world, ent_call *call ){
       [k_ent_volume]    = ent_volume_call,
       [k_ent_audio]     = ent_audio_call,
       [k_ent_skateshop] = ent_skateshop_call,
-      [k_ent_challenge] = ent_challenge_call,
+      [k_ent_objective] = ent_objective_call,
       [k_ent_ccmd]      = ent_ccmd_call,
       [k_ent_gate]      = ent_gate_call,
       [k_ent_relay]     = ent_relay_call,
-      [k_ent_unlock]    = ent_unlock_call
+      [k_ent_challenge] = ent_challenge_call
    };
 
    if( type >= vg_list_size(table) ){
index 8920eef3ab5fed3438bf145d53c35222b489a66a..6faa7d99e786a881ee97c4c2bb7eaea4df2699b2 100644 (file)
--- a/entity.h
+++ b/entity.h
@@ -26,8 +26,8 @@ typedef struct ent_camera ent_camera;
 typedef struct ent_swspreview ent_swspreview;
 typedef struct ent_worldinfo ent_worldinfo;
 typedef struct ent_ccmd ent_ccmd;
+typedef struct ent_objective ent_objective;
 typedef struct ent_challenge ent_challenge;
-typedef struct ent_unlock ent_unlock;
 typedef struct ent_relay ent_relay;
 typedef struct ent_cubemap ent_cubemap;
 
@@ -50,8 +50,8 @@ enum entity_alias{
    k_ent_menuitem    = 15,
    k_ent_worldinfo   = 16,
    k_ent_ccmd        = 17,
-   k_ent_challenge   = 18,
-   k_ent_unlock      = 19,
+   k_ent_objective   = 18,
+   k_ent_challenge   = 19,
    k_ent_relay       = 20,
    k_ent_cubemap     = 21
 };
@@ -243,7 +243,7 @@ struct ent_marker{
 enum skateshop_type{
    k_skateshop_type_boardshop,
    k_skateshop_type_charshop,
-   k_skateshop_type_worldshop
+   k_skateshop_type_worldshop,
 };
 
 struct ent_skateshop{
@@ -401,33 +401,34 @@ struct ent_ccmd{
    u32 pstr_command;
 };
 
-enum ent_challenge_filter{
-   k_ent_challenge_filter_none            = 0x00000000,
-   k_ent_challenge_filter_trick_shuvit    = 0x00000001,
-   k_ent_challenge_filter_trick_kickflip  = 0x00000002,
-   k_ent_challenge_filter_trick_treflip   = 0x00000004,
-   k_ent_challenge_filter_trick_any       = 
-      k_ent_challenge_filter_trick_shuvit|
-      k_ent_challenge_filter_trick_treflip|
-      k_ent_challenge_filter_trick_kickflip,
-   k_ent_challenge_filter_flip_back       = 0x00000008,
-   k_ent_challenge_filter_flip_front      = 0x00000010,
-   k_ent_challenge_filter_flip_any        =
-      k_ent_challenge_filter_flip_back|
-      k_ent_challenge_filter_flip_front,
-   k_ent_challenge_filter_grind_truck_any = 0x00000020,
-   k_ent_challenge_filter_grind_board_any = 0x00000040,
-   k_ent_challenge_filter_grind_any       =
-      k_ent_challenge_filter_grind_truck_any|
-      k_ent_challenge_filter_grind_board_any,
-   k_ent_challenge_filter_footplant       = 0x00000080
-};
-
-enum ent_challenge_flag {
-   k_ent_challenge_hidden = 0x1
-};
-
-struct ent_challenge{
+enum ent_objective_filter{
+   k_ent_objective_filter_none            = 0x00000000,
+   k_ent_objective_filter_trick_shuvit    = 0x00000001,
+   k_ent_objective_filter_trick_kickflip  = 0x00000002,
+   k_ent_objective_filter_trick_treflip   = 0x00000004,
+   k_ent_objective_filter_trick_any       = 
+      k_ent_objective_filter_trick_shuvit|
+      k_ent_objective_filter_trick_treflip|
+      k_ent_objective_filter_trick_kickflip,
+   k_ent_objective_filter_flip_back       = 0x00000008,
+   k_ent_objective_filter_flip_front      = 0x00000010,
+   k_ent_objective_filter_flip_any        =
+      k_ent_objective_filter_flip_back|
+      k_ent_objective_filter_flip_front,
+   k_ent_objective_filter_grind_truck_any = 0x00000020,
+   k_ent_objective_filter_grind_board_any = 0x00000040,
+   k_ent_objective_filter_grind_any       =
+      k_ent_objective_filter_grind_truck_any|
+      k_ent_objective_filter_grind_board_any,
+   k_ent_objective_filter_footplant       = 0x00000080,
+   k_ent_objective_filter_passthrough     = 0x00000100
+};
+
+enum ent_objective_flag {
+   k_ent_objective_hidden = 0x1
+};
+
+struct ent_objective{
    mdl_transform transform;
    u32 submesh_start,
        submesh_count,
@@ -439,11 +440,20 @@ struct ent_challenge{
    f32 time_limit;
 };
 
-struct ent_unlock{
+enum ent_challenge_flag {
+   k_ent_challenge_timelimit = 0x1
+};
+
+struct ent_challenge{
    mdl_transform transform;
    u32 pstr_alias,
+       flags,
        target,
        target_event,
+       reset,
+       reset_event,
+       first,
+       camera,
        status;
 };
 
diff --git a/font.h b/font.h
index 1b94b9a664945c48f2627ec35120c8829d0dde8e..76e63c85bb11d16f970375253452073875d9d9ea 100644 (file)
--- a/font.h
+++ b/font.h
@@ -158,7 +158,7 @@ VG_STATIC
 void font3d_begin( const char *text,
                    camera *cam, m4x3f transform, struct font3d_render *render )
 {
-   q_identity( render->offset );
+   v4_copy( (v4f){0.0f,0.0f,0.0f,1.0f}, render->offset );
 
    m4x4f prev_mtx;
    m4x3_expand( transform, prev_mtx );
@@ -169,19 +169,21 @@ void font3d_begin( const char *text,
       shader_model_font_uMdl( transform );
    }
    else if( render->shader == k_font_shader_world ){
+
+
+      vg_info( "-----\n" );
+      for( int i=0; i<4; i++ ){
+         vg_info( PRINTF_v4f( prev_mtx[i] ) );
+      }
+
       shader_scene_font_uPvmPrev( prev_mtx );
       shader_scene_font_uMdl( transform );
    }
 
    render->u8pch = (u8*)text;
-
-#if 0
-   render->font = font;
-   render->variant_id = variant_id;
-#endif
 }
 
-VG_STATIC void font3d_setoffset( struct font3d_render *render, v3f offset ){
+VG_STATIC void font3d_setoffset( struct font3d_render *render, v4f offset ){
    if( render->shader == k_font_shader_default )
       shader_model_font_uOffset( offset );
    else if( render->shader == k_font_shader_world )
index 70e0724743bee5018dfcde1474c9a44b09a0380c..caf82eec3d24dd3f8c889ce4b4c15058d6f2d762 100644 (file)
Binary files a/maps_src/mp_spawn/main.mdl and b/maps_src/mp_spawn/main.mdl differ
index 585fd73e7a14857352b5f16d0766d00f333bc2ac..12f8cbdc1bf11e7dcba48e2dd263c3fd4b9738cd 100644 (file)
--- a/player.c
+++ b/player.c
@@ -245,7 +245,7 @@ PLAYER_API void player__im_gui( player_instance *player ){
    player__debugtext( 1, "activity: %s", 
                      (const char *[]){ [k_skaterift_menu]      = "menu",
                                        [k_skaterift_replay]    = "replay",
-                                       [k_skaterift_skateshop] = "shop",
+                                       [k_skaterift_ent_focus] = "ent_focus",
                                        [k_skaterift_default]   = "default" 
                      } [skaterift.activity] );
    player__debugtext( 1, "time_rate: %.4f", skaterift.time_rate );
@@ -260,7 +260,6 @@ PLAYER_API void player__im_gui( player_instance *player ){
    skaterift_replay_debug_info();
 }
 
-VG_STATIC void global_skateshop_exit(void);
 
 PLAYER_API void player__setpos( player_instance *player, v3f pos ){
    v3_copy( pos, player->rb.co );
@@ -283,8 +282,7 @@ PLAYER_API void player__spawn( player_instance *player, ent_spawn *rp ){
    player->immobile = 0;
    player->gate_waiting = NULL;
    world_static.last_use = 0.0;
-
-   global_skateshop_exit();
+   world_entity_unfocus();
 
    if( _player_reset[ player->subsystem ] )
       _player_reset[ player->subsystem ]( player, rp );
index 8926c21586c40d6cdd59d867a291d9f174dbd5ca..cb68f35a4cf7f2ebac919722825990b4d8a3eca4 100644 (file)
@@ -119,7 +119,7 @@ vec3 scene_calculate_light( int light_index,
    light_delta = normalize( light_delta );
 
    float quadratic = dist2*100.0;
-   float attenuation  = 1.0f/( 1.0f + quadratic );
+   float attenuation  = 1.0/( 1.0 + quadratic );
          attenuation *= max( dot( light_delta, normal ), 0.0 );
 
    float falloff = max( 0.0, 1.0-(dist2*light_co.w) );
index 7c26322c7375bb75ebc7c97c87627cc925d934e6..39956c6a86f426c3f74a4f2cea268a35a567dbc3 100644 (file)
@@ -279,7 +279,7 @@ static struct vg_shader _shader_model_board_view = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index 5394dc8c0445de3e145fc9af09b22cd77dd2d355..6f4c25af9345b7029b6d1e19c1434fd81e11ceb0 100644 (file)
@@ -287,7 +287,7 @@ static struct vg_shader _shader_model_character_view = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index 777f66003bfcd97b792ab91f46c43b8ae7acc9a2..712efc9a47dad11d94c3f2528e6c7338ad24de24 100644 (file)
@@ -275,7 +275,7 @@ static struct vg_shader _shader_model_entity = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index 6c0ba2aa2be919f58169a19942e1890c65f081a7..abe4de7555f6c715643fd718f7a30402bd4f53f9 100644 (file)
@@ -277,7 +277,7 @@ static struct vg_shader _shader_model_sky = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index 0ffb7aeb08452e98b99231cba24d30551520c4f5..78a8e7da154d903adb3635f07f2bc849cbf88f44 100644 (file)
@@ -277,7 +277,7 @@ static struct vg_shader _shader_scene_cubemapped = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index e2a8e017ef0b39e30139a101b3473084adfea484..42613c0b224f8597f74dbfea9b93e25871563992 100644 (file)
@@ -276,7 +276,7 @@ static struct vg_shader _shader_scene_depth = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index 03d6b20c59a067998bec9361a861843a513f17d4..a03b006b766494721f9dd41489280613f8fac987 100644 (file)
@@ -18,7 +18,6 @@ vec3 pal( float t ){
 
 void main(){
    compute_motion_vectors();
-
    vec3 vfrag = vec3(0.5,0.5,0.5);
    vec3 qnorm = aNorm.xyz;
 
@@ -34,7 +33,7 @@ void main(){
    vec4 v1 = step( vec4(0.5), fract(vec4(a) + spread1) );
 
    float d = ( v0.x+v0.y+v0.z+v0.w +
-               v1.x+v1.y+v1.z+v1.w ) * 0.125f;
+               v1.x+v1.y+v1.z+v1.w ) * 0.125;
    
    float dither = fract(dot(vec2(171.0,231.0),gl_FragCoord.xy)/71.0);
    float x = d*0.8+length(p)*0.3;
index 8a2555d1e61d50e09676f846e9551dde7dec800d..eec4b6ce75a025d58297256e7d20dc98a5eec437 100644 (file)
@@ -279,7 +279,7 @@ static struct vg_shader _shader_scene_font = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
@@ -440,7 +440,6 @@ static struct vg_shader _shader_scene_font = {
 "\n"
 "void main(){\n"
 "   compute_motion_vectors();\n"
-"\n"
 "   vec3 vfrag = vec3(0.5,0.5,0.5);\n"
 "   vec3 qnorm = aNorm.xyz;\n"
 "\n"
@@ -456,7 +455,7 @@ static struct vg_shader _shader_scene_font = {
 "   vec4 v1 = step( vec4(0.5), fract(vec4(a) + spread1) );\n"
 "\n"
 "   float d = ( v0.x+v0.y+v0.z+v0.w +\n"
-"               v1.x+v1.y+v1.z+v1.w ) * 0.125f;\n"
+"               v1.x+v1.y+v1.z+v1.w ) * 0.125;\n"
 "   \n"
 "   float dither = fract(dot(vec2(171.0,231.0),gl_FragCoord.xy)/71.0);\n"
 "   float x = d*0.8+length(p)*0.3;\n"
index 3f5e0c69d0fe4e2ea8ba529d978af336980aeae2..82251455ee48d0232ca5ed6978dc8ea0fc23cf88 100644 (file)
@@ -273,7 +273,7 @@ static struct vg_shader _shader_scene_fxglow = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index e0b9982965b21b8de05c7688c807239a1355f437..3fe8c7ee1c2f582f641d6328c23d943f8f2bb7d1 100644 (file)
@@ -276,7 +276,7 @@ static struct vg_shader _shader_scene_position = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index 47f59c0c4a6f167a6e3b79d95ee5d18e51bacd10..b37cf62905335e96218c7fe38cb05e44e5f924fe 100644 (file)
@@ -275,7 +275,7 @@ static struct vg_shader _shader_scene_route = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index d417e45d0a467e8b09865ea4ab0c7ad078aa15d7..75e4ca83b7e57defe7b02f64b0b8b7f53d3a0f9c 100644 (file)
@@ -295,7 +295,7 @@ static struct vg_shader _shader_scene_scoretext = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index bacef090005f3979d1ed31f7be8e1dc89578d0be..d28f7d12b276ba823eb6caada2a7513d3d796bc3 100644 (file)
@@ -275,7 +275,7 @@ static struct vg_shader _shader_scene_standard = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index c512d36190bf952b2af5d49fcd0ed2412c578343..19a42cf98b187e8e5705c3fc55587a298bf2ae37 100644 (file)
@@ -275,7 +275,7 @@ static struct vg_shader _shader_scene_standard_alphatest = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index 9886809ac7a509afeb3279bb01392b84beff1b05..e37e6240d3652186f91896891be85a92268b6a07 100644 (file)
@@ -276,7 +276,7 @@ static struct vg_shader _shader_scene_terrain = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index 5a2afe2c20d4f5a922db721e30e62cca8a1c49c5..2302cc7e8ff0e03c607c1cb427271f306df12c1b 100644 (file)
@@ -274,7 +274,7 @@ static struct vg_shader _shader_scene_vertex_blend = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index cd59ac17bf451e035ece9b0bfe07cad3bd152bae..588477e3d85a741273f18df6e6bc98ceb617f052 100644 (file)
@@ -284,7 +284,7 @@ static struct vg_shader _shader_scene_water = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index 84fc918c61493946fe36612c398b2de086f23f18..318a37a6c9ac5153c2557c45cc36be25bcb4b1e5 100644 (file)
@@ -281,7 +281,7 @@ static struct vg_shader _shader_scene_water_fast = {
 "   light_delta = normalize( light_delta );\n"
 "\n"
 "   float quadratic = dist2*100.0;\n"
-"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"   float attenuation  = 1.0/( 1.0 + quadratic );\n"
 "         attenuation *= max( dot( light_delta, normal ), 0.0 );\n"
 "\n"
 "   float falloff = max( 0.0, 1.0-(dist2*light_co.w) );\n"
index fac82810ed0b7e459ebd5129b33d6709e62ee4e6..e56a43a6cbe53b464443a09c7ec9cd2e2030a670 100644 (file)
@@ -299,7 +299,7 @@ VG_STATIC void vg_pre_update(void){
    vg.time_rate = vg_smoothstepf( skaterift.time_rate );
    
    player__pre_update( &localplayer );
-   global_skateshop_preupdate();
+   world_entity_focus_preupdate();
    skaterift_replay_pre_update();
 
    world_update( world_current_instance(), localplayer.rb.co );
@@ -469,8 +469,8 @@ VG_STATIC void render_scene_gate_subview(void){
 }
 
 VG_STATIC void skaterift_composite_maincamera(void){
-   camera_lerp( &localplayer.cam, &global_skateshop.cam, 
-                vg_smoothstepf(global_skateshop.factive), &skaterift.cam );
+   camera_lerp( &localplayer.cam, &world_static.focus_cam,
+                vg_smoothstepf(world_static.focus_strength), &skaterift.cam );
 
    if( skaterift.activity == k_skaterift_replay ){
       skaterift_get_replay_camera( &skaterift.cam );
index fd5953766091b6a60de4fc5608620028b0bc2477..15a17dec5b05501385619f9c2bd31eff4febddd0 100644 (file)
@@ -48,7 +48,7 @@ struct{
    enum skaterift_activity {
       k_skaterift_default    = 0x00,
       k_skaterift_replay     = 0x01,
-      k_skaterift_skateshop  = 0x02,
+      k_skaterift_ent_focus  = 0x02,
       k_skaterift_menu       = 0x04
    }
    activity;
diff --git a/world.h b/world.h
index 9c1a1cf800c107e11764fdc538654a16a690630e..63bfa9c4f9fb6d0d6e442e074cf5341be211f599 100644 (file)
--- a/world.h
+++ b/world.h
@@ -165,8 +165,8 @@ struct world_instance {
                  ent_camera,
                  ent_swspreview,
                  ent_ccmd,
+                 ent_objective,
                  ent_challenge,
-                 ent_unlock,
                  ent_relay,
                  ent_cubemap;
 
@@ -195,7 +195,7 @@ struct world_instance {
 
    rb_object rb_geo;
 
-   ent_challenge *challenge_target;
+   ent_objective *challenge_target;
    f32 challenge_timer;
 };
 
@@ -215,6 +215,11 @@ struct world_static {
    world_instance instances[4];
    i32            active_instance;
 
+   /* TODO: FOCUSED_INSTANCE */
+   u32            focused_entity; /* like skateshop, challenge.. */
+   f32            focus_strength;
+   camera         focus_cam;
+
    addon_reg *addon_hub,
              *addon_client;
 
index 4a8670d085447d41868e89d0e4c8c8317f554b98..82c9723f90c6459565bd7d0b2b80ed0eb14660b1 100644 (file)
@@ -7,6 +7,77 @@
 #include "world_load.h"
 #include "save.h"
 #include "vg/vg_msg.h"
+#include "menu.h"
+#include "ent_challenge.h"
+#include "ent_skateshop.h"
+
+VG_STATIC void world_entity_focus( u32 entity_id ){
+   localplayer.immobile = 1;
+   menu.disable_open = 1;
+
+   v3_zero( localplayer.rb.v );
+   v3_zero( localplayer.rb.w );
+   localplayer._walk.move_speed = 0.0f;
+   world_static.focused_entity = entity_id;
+   skaterift.activity = k_skaterift_ent_focus;
+}
+
+VG_STATIC void world_entity_unfocus(void){
+   localplayer.immobile = 0;
+   skaterift.activity = k_skaterift_default;
+   menu.disable_open = 0;
+   srinput.enabled = 0;
+}
+
+/* logic preupdate */
+VG_STATIC void world_entity_focus_preupdate(void){
+   f32 rate = vg_minf( 1.0f, vg.time_frame_delta * 2.0f );
+   int active = 0;
+   if( skaterift.activity == k_skaterift_ent_focus )
+      active = 1;
+
+   vg_slewf( &world_static.focus_strength, active, 
+             vg.time_frame_delta * (1.0f/0.5f) );
+
+   if( !active ) 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 );
+      ent_skateshop_preupdate( skateshop );
+   }
+   else if( type == k_ent_challenge ){
+      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+      ent_challenge_preupdate( challenge );
+   }
+   else {
+      vg_fatal_error( "Programming error\n" );
+   }
+}
+
+/* additional renderings like text etc.. */
+VG_STATIC void world_entity_focus_render(void){
+   if( skaterift.activity != k_skaterift_ent_focus )
+      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 );
+      skateshop_render( skateshop );
+   }
+   else if( type == k_ent_challenge ){
+      
+   }
+   else {
+      vg_fatal_error( "Programming error\n" );
+   }
+}
 
 VG_STATIC void world_gen_entities_init( world_instance *world ){
    /* lights */
@@ -96,9 +167,9 @@ VG_STATIC void world_gen_entities_init( world_instance *world ){
    }
    indexables[] = {
       { k_ent_gate, &world->ent_gate },
-      { k_ent_challenge, &world->ent_challenge },
+      { k_ent_objective, &world->ent_objective },
       { k_ent_volume, &world->ent_volume },
-      { k_ent_unlock, &world->ent_unlock }
+      { k_ent_challenge, &world->ent_challenge }
    };
 
    for( u32 i=0; i<vg_list_size(indexables); i++ )
@@ -316,8 +387,8 @@ entity_bh_expand_bound( void *user, boxf bound, u32 item_index ){
 
       m4x3_expand_aabb_aabb( gate->to_world, bound, box );
    }
-   else if( type == k_ent_challenge ){
-      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+   else if( type == k_ent_objective ){
+      ent_objective *objective = mdl_arritm( &world->ent_objective, index );
       
       /* TODO: This might be more work than necessary. could maybe just get
        *       away with representing them as points */
@@ -325,14 +396,14 @@ entity_bh_expand_bound( void *user, boxf bound, u32 item_index ){
       boxf box;
       box_init_inf( box );
 
-      for( u32 i=0; i<challenge->submesh_count; i++ ){
+      for( u32 i=0; i<objective->submesh_count; i++ ){
          mdl_submesh *sm = mdl_arritm( &world->meta.submeshs,
-                                       challenge->submesh_start+i );
+                                       objective->submesh_start+i );
          box_concat( box, sm->bbx );
       }
 
       m4x3f transform;
-      mdl_transform_m4x3( &challenge->transform, transform );
+      mdl_transform_m4x3( &objective->transform, transform );
       m4x3_expand_aabb_aabb( transform, bound, box );
    }
    else if( type == k_ent_volume ){
@@ -340,13 +411,13 @@ entity_bh_expand_bound( void *user, boxf bound, u32 item_index ){
       m4x3_expand_aabb_aabb( volume->to_world, bound,
                               (boxf){{-1.0f,-1.0f,-1.0f},{ 1.0f, 1.0f, 1.0f}} );
    }
-   else if( type == k_ent_unlock ){
-      ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
+   else if( type == k_ent_challenge ){
+      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
 
       boxf box = {{-1.2f*0.5f,-0.72f*0.5f,-0.01f*0.5f},
                   { 1.2f*0.5f, 0.72f*0.5f, 0.01f*0.5f}};
       m4x3f transform;
-      mdl_transform_m4x3( &unlock->transform, transform );
+      mdl_transform_m4x3( &challenge->transform, transform );
       m4x3_expand_aabb_aabb( transform, bound, box );
    }
    else{
@@ -365,17 +436,17 @@ VG_STATIC float entity_bh_centroid( void *user, u32 item_index, int axis ){
       ent_gate *gate = mdl_arritm( &world->ent_gate, index );
       return gate->to_world[3][axis];
    }
-   else if( type == k_ent_challenge ){
-      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
-      return challenge->transform.co[axis];
+   else if( type == k_ent_objective ){
+      ent_objective *objective = mdl_arritm( &world->ent_objective, index );
+      return objective->transform.co[axis];
    }
    else if( type == k_ent_volume ){
       ent_volume *volume = mdl_arritm( &world->ent_volume, index );
       return volume->transform.co[axis];
    }
-   else if( type == k_ent_unlock ){
-      ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
-      return unlock->transform.co[axis];
+   else if( type == k_ent_challenge ){
+      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+      return challenge->transform.co[axis];
    }
    else {
       vg_fatal_error( "Programming error\n" );
@@ -406,19 +477,19 @@ VG_STATIC void entity_bh_debug( void *user, u32 item_index ){
                   {  gate->dimensions[0],  gate->dimensions[1],  0.1f }};
       vg_line_boxf_transformed( gate->to_world, box, 0xf000ff00 );
    }
-   else if( type == k_ent_challenge ){
-      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+   else if( type == k_ent_objective ){
+      ent_objective *objective = mdl_arritm( &world->ent_objective, index );
       boxf box;
       box_init_inf( box );
 
-      for( u32 i=0; i<challenge->submesh_count; i++ ){
+      for( u32 i=0; i<objective->submesh_count; i++ ){
          mdl_submesh *sm = mdl_arritm( &world->meta.submeshs,
-                                       challenge->submesh_start+i );
+                                       objective->submesh_start+i );
          box_concat( box, sm->bbx );
       }
 
       m4x3f transform;
-      mdl_transform_m4x3( &challenge->transform, transform );
+      mdl_transform_m4x3( &objective->transform, transform );
       vg_line_boxf_transformed( transform, box, 0xf000ff00 );
    }
    else if( type == k_ent_volume ){
@@ -427,13 +498,13 @@ VG_STATIC void entity_bh_debug( void *user, u32 item_index ){
                                 (boxf){{-1.0f,-1.0f,-1.0f},{ 1.0f, 1.0f, 1.0f}},
                                 0xf000ff00 );
    }
-   else if( type == k_ent_unlock ){
-      ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
+   else if( type == k_ent_challenge ){
+      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
 
       boxf box = {{-1.2f*0.5f,-0.72f*0.5f,-0.01f*0.5f},
                   { 1.2f*0.5f, 0.72f*0.5f, 0.01f*0.5f}};
       m4x3f transform;
-      mdl_transform_m4x3( &unlock->transform, transform );
+      mdl_transform_m4x3( &challenge->transform, transform );
       vg_line_boxf_transformed( transform, box, 0xf0ff0000 );
    }
    else{
@@ -453,17 +524,17 @@ VG_STATIC void entity_bh_closest( void *user, u32 item_index, v3f point,
       ent_gate *gate = mdl_arritm( &world->ent_gate, index );
       v3_copy( gate->to_world[3], closest );
    }
-   else if( type == k_ent_challenge ){
-      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+   else if( type == k_ent_objective ){
+      ent_objective *challenge = mdl_arritm( &world->ent_objective, index );
       v3_copy( challenge->transform.co, closest );
    }
    else if( type == k_ent_volume ){
       ent_volume *volume = mdl_arritm( &world->ent_volume, index );
       v3_copy( volume->to_world[3], closest );
    }
-   else if( type == k_ent_unlock ){
-      ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
-      v3_copy( unlock->transform.co, closest );
+   else if( type == k_ent_challenge ){
+      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
+      v3_copy( challenge->transform.co, closest );
    }
    else{
       vg_fatal_error( "Programming error\n" );
@@ -488,26 +559,26 @@ VG_STATIC void world_entity_start( world_instance *world, vg_msg *sav ){
    /* read savedata 
     * ----------------------------------------------------------------------- */
 
-   for( u32 i=0; i<mdl_arrcount(&world->ent_unlock); i++ ){
-      ent_unlock *unlock = mdl_arritm( &world->ent_unlock, i );
-      const char *alias = mdl_pstr( &world->meta, unlock->pstr_alias );
+   for( u32 i=0; i<mdl_arrcount(&world->ent_challenge); i++ ){
+      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, i );
+      const char *alias = mdl_pstr( &world->meta, challenge->pstr_alias );
 
       if( vg_msg_seekkvu32( sav, alias, k_vg_msg_first ) ){
          ent_call call;
          call.data = NULL;
          call.function = 0;
-         call.id = mdl_entity_id( k_ent_unlock, i );
+         call.id = mdl_entity_id( k_ent_challenge, i );
          entity_call( world, &call );
       }
    }
 }
 
 VG_STATIC void world_entity_serialize( world_instance *world, vg_msg *sav ){
-   for( u32 i=0; i<mdl_arrcount(&world->ent_unlock); i++ ){
-      ent_unlock *unlock = mdl_arritm(&world->ent_unlock,i);
+   for( u32 i=0; i<mdl_arrcount(&world->ent_challenge); i++ ){
+      ent_challenge *challenge = mdl_arritm(&world->ent_challenge,i);
 
-      const char *alias = mdl_pstr(&world->meta,unlock->pstr_alias);
-      vg_msg_wkvu32( sav, alias, unlock->status );
+      const char *alias = mdl_pstr(&world->meta,challenge->pstr_alias);
+      vg_msg_wkvu32( sav, alias, challenge->status );
    }
 }
 
index c3af72a398d4e717bf986e81322aa9555645df73..ba58df8f60d27793c960c3518a9ca88999554804 100644 (file)
@@ -26,6 +26,11 @@ VG_STATIC void entity_bh_debug( void *user, u32 item_index );
 VG_STATIC void entity_bh_closest( void *user, u32 item_index, v3f point,
                                   v3f closest );
 
+VG_STATIC void world_entity_focus( u32 entity_id );
+VG_STATIC void world_entity_focus_preupdate(void);
+VG_STATIC void world_entity_focus_render(void);
+VG_STATIC void world_entity_unfocus();
+
 static bh_system bh_system_entity_list = {
    .expand_bound = entity_bh_expand_bound,
    .item_centroid = entity_bh_centroid,
index b522cba80fca626acde99aebad4aa650b8075aa9..6bef3ef9ed6e53fd82b6f0c5ca9684bdf49aa09e 100644 (file)
@@ -277,12 +277,12 @@ VG_STATIC void world_gen_generate_meshes( world_instance *world ){
    }
 
    /* unpack challenge models */
-   for( u32 i=0; i<mdl_arrcount( &world->ent_challenge ); i++ ){
-      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, i );
+   for( u32 i=0; i<mdl_arrcount( &world->ent_objective ); i++ ){
+      ent_objective *objective = mdl_arritm( &world->ent_objective, i );
 
-      for( u32 j=0; j<challenge->submesh_count; j ++ ){
+      for( u32 j=0; j<objective->submesh_count; j ++ ){
          mdl_submesh *sm = mdl_arritm( &world->meta.submeshs, 
-                                       challenge->submesh_start+j );
+                                       objective->submesh_start+j );
          world_unpack_submesh_dynamic( world, &world->scene_no_collide, sm );
       }
    }
index b91246f261e2f0e7df5aca2adebfde75ec96388b..2ca957a1cca75b13b04761da3e59122b43dc6166 100644 (file)
@@ -60,8 +60,8 @@ VG_STATIC void world_instance_load_mdl( u32 instance_id, const char *path ){
    mdl_load_array( meta, &world->ent_skateshop, "ent_skateshop",  heap );
    mdl_load_array( meta, &world->ent_swspreview,"ent_swspreview", heap );
    mdl_load_array( meta, &world->ent_ccmd,      "ent_ccmd",       heap );
+   mdl_load_array( meta, &world->ent_objective, "ent_objective",  heap );
    mdl_load_array( meta, &world->ent_challenge, "ent_challenge",  heap );
-   mdl_load_array( meta, &world->ent_unlock,    "ent_unlock",     heap );
    mdl_load_array( meta, &world->ent_relay,     "ent_relay",      heap );
    mdl_load_array( meta, &world->ent_cubemap,   "ent_cubemap",    heap );
 
index 55d13d447a07b067da5042d3d260e8b2e7a9fb29..35730acdc985030dbcb42b7c31998a5151a356f0 100644 (file)
@@ -421,48 +421,48 @@ void world_render_challenges( world_instance *world, struct world_pass *pass,
    bh_iter_init_range( 0, &it, pos, radius+10.0f );
    i32 idx;
 
-   u32 challenge_list[ 32 ],
-       unlock_list[ 32 ];
+   u32 objective_list[ 32 ],
+       challenge_list[ 16 ];
 
-   u32 challenge_count = 0,
-       unlock_count = 0;
+   u32 objective_count = 0,
+       challenge_count = 0;
 
    while( bh_next( world->entity_bh, &it, &idx ) ){
       u32 id    = world->entity_list[ idx ],
           type  = mdl_entity_id_type( id ),
           index = mdl_entity_id_id( id );
 
-      if( type == k_ent_challenge ) {
+      if( type == k_ent_objective ) {
+         if( objective_count < vg_list_size(objective_list) )
+            objective_list[ objective_count ++ ] = index;
+      }
+      else if( type == k_ent_challenge ){
          if( challenge_count < vg_list_size(challenge_list) )
             challenge_list[ challenge_count ++ ] = index;
       }
-      else if( type == k_ent_unlock ){
-         if( unlock_count < vg_list_size(unlock_list) )
-            unlock_list[ unlock_count ++ ] = index;
-      }
    }
 
-   /* render challenges */
+   /* render objectives */
    glDisable( GL_CULL_FACE );
    mesh_bind( &world->mesh_no_collide );
    u32 last_material = 0;
-   for( u32 i=0; i<challenge_count; i++ ){
-      u32 index = challenge_list[ i ];
-      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
-      if( challenge->flags & k_ent_challenge_hidden ) continue;
+   for( u32 i=0; i<objective_count; i++ ){
+      u32 index = objective_list[ i ];
+      ent_objective *objective = mdl_arritm( &world->ent_objective, index );
+      if( objective->flags & k_ent_objective_hidden ) continue;
 
-      f32 dist = v3_dist( challenge->transform.co, pos ) * (1.0f/radius),
+      f32 dist = v3_dist( objective->transform.co, pos ) * (1.0f/radius),
           scale = vg_smoothstepf( vg_clampf( 5.0f-dist*5.0f, 0.0f,1.0f ) );
 
-      v3_fill( challenge->transform.s, scale );
+      v3_fill( objective->transform.s, scale );
 
       m4x3f mmdl;
-      mdl_transform_m4x3( &challenge->transform, mmdl );
+      mdl_transform_m4x3( &objective->transform, mmdl );
       shader_scene_fxglow_uMdl( mmdl );
 
-      for( u32 j=0; j<challenge->submesh_count; j++ ){
+      for( u32 j=0; j<objective->submesh_count; j++ ){
          mdl_submesh *sm = mdl_arritm( &world->meta.submeshs, 
-                                       challenge->submesh_start + j );
+                                       objective->submesh_start + j );
 
          if( sm->material_id != last_material ){
             last_material = sm->material_id;
@@ -478,6 +478,7 @@ void world_render_challenges( world_instance *world, struct world_pass *pass,
    shader_scene_font_use();
    shader_scene_font_uTexGarbage(0);
    shader_scene_font_uTexMain(1);
+
    shader_scene_font_uPv( skaterift.cam.mtx.pv );
    shader_scene_font_uTime( vg.time );
 
@@ -502,16 +503,16 @@ void world_render_challenges( world_instance *world, struct world_pass *pass,
    char buf[32];
    u32 count = 0;
 
-   for( u32 i=0; i<mdl_arrcount(&world->ent_unlock); i++ ){
-      ent_unlock *unlock = mdl_arritm( &world->ent_unlock, i );
-      vg_line_point( unlock->transform.co, 0.2f, VG__GREEN );
-      if( unlock->status ) count ++;
+   for( u32 i=0; i<mdl_arrcount(&world->ent_challenge); i++ ){
+      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, i );
+      vg_line_point( challenge->transform.co, 0.2f, VG__GREEN );
+      if( challenge->status ) count ++;
    }
 
    int c=0;
    c+=highscore_intl( buf+c, count, 3 );
    buf[c++] = '/';
-   c+=highscore_intl( buf+c, mdl_arrcount(&world->ent_unlock), 3 );
+   c+=highscore_intl( buf+c, mdl_arrcount(&world->ent_challenge), 3 );
    buf[c++] = '\0';
 
    f32 w = font3d_string_width( &gui.font, 1, buf );
@@ -519,20 +520,20 @@ void world_render_challenges( world_instance *world, struct world_pass *pass,
    m3x3_identity( mlocal );
    mlocal[3][0] = -w*0.5f;
 
-   for( u32 i=0; i<unlock_count; i++ ){
-      u32 index = unlock_list[ i ];
-      ent_unlock *unlock = mdl_arritm( &world->ent_unlock, index );
+   for( u32 i=0; i<challenge_count; i++ ){
+      u32 index = challenge_list[ i ];
+      ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
       m4x3f mmdl;
-      mdl_transform_m4x3( &unlock->transform, mmdl );
+      mdl_transform_m4x3( &challenge->transform, mmdl );
       m4x3_mul( mmdl, mlocal, mmdl );
 
-      vg_line_point( unlock->transform.co, 0.25f, VG__RED );
+      vg_line_point( challenge->transform.co, 0.25f, VG__RED );
 
-      f32 dist = v3_dist( unlock->transform.co, pos ) * (1.0f/radius),
+      f32 dist = v3_dist( challenge->transform.co, pos ) * (1.0f/radius),
           scale = vg_smoothstepf( vg_clampf( 10.0f-dist*10.0f, 0.0f,1.0f ) ),
           colour = 0.0f;
 
-      if( unlock->status )
+      if( challenge->status )
          colour = 1.0f;
 
       shader_scene_font_uOpacity( scale );
@@ -755,7 +756,6 @@ VG_STATIC void world_prerender( world_instance *world )
                     sizeof(struct ub_world_lighting), &world->ub_lighting );
 }
 
-VG_STATIC void skateshop_render(void);
 VG_STATIC void render_world( world_instance *world, camera *cam,
                              int layer_depth )
 {
@@ -767,32 +767,56 @@ VG_STATIC void render_world( world_instance *world, camera *cam,
 
    render_world_vb( world, cam );
    render_world_alphatest( world, cam );
-   render_world_fxglow( world, cam, layer_depth );
    render_terrain( world, cam );
 
+   if( layer_depth == -1 ) return;
    if( layer_depth == 0 ){
-      skateshop_render();
+      world_entity_focus_render();
 
       /* Render SFD's */
       u32 closest = 0;
       float min_dist = INFINITY;
 
-      if( !mdl_arrcount( &world->ent_route ) )
-         return;
-
-      for( u32 i=0; i<mdl_arrcount( &world->ent_route ); i++ ){
-         ent_route *route = mdl_arritm( &world->ent_route, i );
-         float dist = v3_dist2( route->board_transform[3], cam->pos );
+      if( mdl_arrcount( &world->ent_route ) ){
+         for( u32 i=0; i<mdl_arrcount( &world->ent_route ); i++ ){
+            ent_route *route = mdl_arritm( &world->ent_route, i );
+            float dist = v3_dist2( route->board_transform[3], cam->pos );
 
-         if( dist < min_dist ){
-            min_dist = dist;
-            closest = i;
+            if( dist < min_dist ){
+               min_dist = dist;
+               closest = i;
+            }
          }
+
+         ent_route *route = mdl_arritm( &world->ent_route, closest );
+         sfd_render( world, cam, route->board_transform );
       }
+   }
 
-      ent_route *route = mdl_arritm( &world->ent_route, closest );
-      sfd_render( world, cam, route->board_transform );
+   f32 greyout = 0.0f;
+   if( mdl_entity_id_type(world_static.focused_entity) == k_ent_challenge )
+      greyout = world_static.focus_strength;
+
+   if( greyout > 0.0f ){
+      glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
+      glEnable(GL_BLEND);
+      glDisable(GL_DEPTH_TEST);
+      glDepthMask(GL_FALSE);
+      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+      glBlendEquation(GL_FUNC_ADD);
+
+      shader_blitcolour_use();
+      shader_blitcolour_uColour( (v4f){ 0.5f, 0.5f, 0.5f, greyout*0.5f } );
+      render_fsquad();
+      
+      glDisable(GL_BLEND);
+      glEnable(GL_DEPTH_TEST);
+      glDepthMask(GL_TRUE);
+      glDrawBuffers( 2, (GLenum[]){ GL_COLOR_ATTACHMENT0, 
+                                    GL_COLOR_ATTACHMENT1 } );
    }
+
+   render_world_fxglow( world, cam, layer_depth );
 }
 
 VG_STATIC void render_cubemap_side( world_instance *world, ent_cubemap *cm, 
index dee421694c5031ea88815c79c7998dc9eeb8efc9..d71b44e448fedbbe70dbdf463579f60717585008 100644 (file)
@@ -73,7 +73,7 @@ VG_STATIC void world_bind_light_index( world_instance *world,
                                        int slot );
 VG_STATIC void render_world_position( world_instance *world, camera *cam );
 VG_STATIC void render_world_depth( world_instance *world, camera *cam );
-VG_STATIC void render_world( world_instance *world, camera *cam,
+VG_STATIC void render_world( world_instance *world, camera *cam, 
                              int layer_depth );
 VG_STATIC void render_world_cubemaps( world_instance *world );