From 6190deb68aa1c9e92ede62ea05c2a755bf5516de Mon Sep 17 00:00:00 2001 From: hgn Date: Fri, 11 Aug 2023 16:06:46 +0100 Subject: [PATCH] preview for challenges and new system --- blender_export.py | 129 ++++++++++++++++--------- ent_challenge.c | 129 ++++++++----------------- ent_challenge.h | 9 ++ ent_objective.c | 120 ++++++++++++++++++++++++ ent_skateshop.c | 77 +++++---------- ent_skateshop.h | 13 ++- ent_unlock.c | 28 ------ entity.c | 6 +- entity.h | 74 ++++++++------- font.h | 16 ++-- maps_src/mp_spawn/main.mdl | Bin 13228832 -> 13230368 bytes player.c | 6 +- shaders/common_world.glsl | 2 +- shaders/model_board_view.h | 2 +- shaders/model_character_view.h | 2 +- shaders/model_entity.h | 2 +- shaders/model_sky.h | 2 +- shaders/scene_cubemapped.h | 2 +- shaders/scene_depth.h | 2 +- shaders/scene_font.fs | 3 +- shaders/scene_font.h | 5 +- shaders/scene_fxglow.h | 2 +- shaders/scene_position.h | 2 +- shaders/scene_route.h | 2 +- shaders/scene_scoretext.h | 2 +- shaders/scene_standard.h | 2 +- shaders/scene_standard_alphatest.h | 2 +- shaders/scene_terrain.h | 2 +- shaders/scene_vertex_blend.h | 2 +- shaders/scene_water.h | 2 +- shaders/scene_water_fast.h | 2 +- skaterift.c | 6 +- skaterift.h | 2 +- world.h | 9 +- world_entity.c | 145 +++++++++++++++++++++-------- world_entity.h | 5 + world_gen.c | 8 +- world_load.c | 2 +- world_render.c | 114 ++++++++++++++--------- world_render.h | 2 +- 40 files changed, 561 insertions(+), 381 deletions(-) create mode 100644 ent_challenge.h create mode 100644 ent_objective.c delete mode 100644 ent_unlock.c diff --git a/blender_export.py b/blender_export.py index d8fb6ae..1b1c4fb 100644 --- a/blender_export.py +++ b/blender_export.py @@ -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 \ diff --git a/ent_challenge.c b/ent_challenge.c index 6f031ba..515aeb0 100644 --- a/ent_challenge.c +++ b/ent_challenge.c @@ -1,115 +1,66 @@ #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 index 0000000..01068e8 --- /dev/null +++ b/ent_challenge.h @@ -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 index 0000000..330e60f --- /dev/null +++ b/ent_objective.c @@ -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 */ diff --git a/ent_skateshop.c b/ent_skateshop.c index 4c5817d..56d8c01 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -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 */ diff --git a/ent_skateshop.h b/ent_skateshop.h index 1d0699a..23e43c0 100644 --- a/ent_skateshop.h +++ b/ent_skateshop.h @@ -12,8 +12,12 @@ 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 index 8a266ae..0000000 --- a/ent_unlock.c +++ /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 */ diff --git a/entity.c b/entity.c index 33bed05..82c3ecd 100644 --- 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) ){ diff --git a/entity.h b/entity.h index 8920eef..6faa7d9 100644 --- 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 1b94b9a..76e63c8 100644 --- 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 ) diff --git a/maps_src/mp_spawn/main.mdl b/maps_src/mp_spawn/main.mdl index 70e0724743bee5018dfcde1474c9a44b09a0380c..caf82eec3d24dd3f8c889ce4b4c15058d6f2d762 100644 GIT binary patch delta 5044 zcmaLa30xD$9tZH@B0>N;tXgZ3R`G!- zbk%)r1y8D?R1k2h2*Dt>eyj&ptgW?LU+tkiyxOW2dA|+d@g8~e;hWj){AcGsvy+hB zc4)V3n`yVK*sGt9Jw?$JMP+4YCZ{E3;i$6|mnhvBn@EbfUoy|d{XrTxY4;KmEy}uH}_mzL%iS!(4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uzpYaEp>#Dk-!uvG7j`sojYSC(Uq-SD%uhyE_nB)^jrRk-2@&)=vIi2&M z9$8Z2EyqfPIz8h@#?IfY8ZSJ+Exl40n9TSnd`-JFZ#?QZJ)P<0)&Pvox zZ%#kzj>Qo2$+6~v?y86rCib#Wlg#8RF6f-ixqC*j3xx;+Q$XBXN3klQ#eijW7v|2# zXnn-O`HYDsUccQ}?G}5dFvj4HrHFYunC}9+d*0qM_R4x?2=5&ve5Yi*XlHTbf0){# z#JWf!T5cPo_G~L*StVHo`|Bz{l_jd9;3S-auf%rM I=@Hxi1iiz^m;e9( diff --git a/player.c b/player.c index 585fd73..12f8cbd 100644 --- 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 ); diff --git a/shaders/common_world.glsl b/shaders/common_world.glsl index 8926c21..cb68f35 100644 --- a/shaders/common_world.glsl +++ b/shaders/common_world.glsl @@ -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) ); diff --git a/shaders/model_board_view.h b/shaders/model_board_view.h index 7c26322..39956c6 100644 --- a/shaders/model_board_view.h +++ b/shaders/model_board_view.h @@ -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" diff --git a/shaders/model_character_view.h b/shaders/model_character_view.h index 5394dc8..6f4c25a 100644 --- a/shaders/model_character_view.h +++ b/shaders/model_character_view.h @@ -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" diff --git a/shaders/model_entity.h b/shaders/model_entity.h index 777f660..712efc9 100644 --- a/shaders/model_entity.h +++ b/shaders/model_entity.h @@ -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" diff --git a/shaders/model_sky.h b/shaders/model_sky.h index 6c0ba2a..abe4de7 100644 --- a/shaders/model_sky.h +++ b/shaders/model_sky.h @@ -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" diff --git a/shaders/scene_cubemapped.h b/shaders/scene_cubemapped.h index 0ffb7ae..78a8e7d 100644 --- a/shaders/scene_cubemapped.h +++ b/shaders/scene_cubemapped.h @@ -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" diff --git a/shaders/scene_depth.h b/shaders/scene_depth.h index e2a8e01..42613c0 100644 --- a/shaders/scene_depth.h +++ b/shaders/scene_depth.h @@ -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" diff --git a/shaders/scene_font.fs b/shaders/scene_font.fs index 03d6b20..a03b006 100644 --- a/shaders/scene_font.fs +++ b/shaders/scene_font.fs @@ -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; diff --git a/shaders/scene_font.h b/shaders/scene_font.h index 8a2555d..eec4b6c 100644 --- a/shaders/scene_font.h +++ b/shaders/scene_font.h @@ -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" diff --git a/shaders/scene_fxglow.h b/shaders/scene_fxglow.h index 3f5e0c6..8225145 100644 --- a/shaders/scene_fxglow.h +++ b/shaders/scene_fxglow.h @@ -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" diff --git a/shaders/scene_position.h b/shaders/scene_position.h index e0b9982..3fe8c7e 100644 --- a/shaders/scene_position.h +++ b/shaders/scene_position.h @@ -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" diff --git a/shaders/scene_route.h b/shaders/scene_route.h index 47f59c0..b37cf62 100644 --- a/shaders/scene_route.h +++ b/shaders/scene_route.h @@ -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" diff --git a/shaders/scene_scoretext.h b/shaders/scene_scoretext.h index d417e45..75e4ca8 100644 --- a/shaders/scene_scoretext.h +++ b/shaders/scene_scoretext.h @@ -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" diff --git a/shaders/scene_standard.h b/shaders/scene_standard.h index bacef09..d28f7d1 100644 --- a/shaders/scene_standard.h +++ b/shaders/scene_standard.h @@ -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" diff --git a/shaders/scene_standard_alphatest.h b/shaders/scene_standard_alphatest.h index c512d36..19a42cf 100644 --- a/shaders/scene_standard_alphatest.h +++ b/shaders/scene_standard_alphatest.h @@ -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" diff --git a/shaders/scene_terrain.h b/shaders/scene_terrain.h index 9886809..e37e624 100644 --- a/shaders/scene_terrain.h +++ b/shaders/scene_terrain.h @@ -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" diff --git a/shaders/scene_vertex_blend.h b/shaders/scene_vertex_blend.h index 5a2afe2..2302cc7 100644 --- a/shaders/scene_vertex_blend.h +++ b/shaders/scene_vertex_blend.h @@ -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" diff --git a/shaders/scene_water.h b/shaders/scene_water.h index cd59ac1..588477e 100644 --- a/shaders/scene_water.h +++ b/shaders/scene_water.h @@ -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" diff --git a/shaders/scene_water_fast.h b/shaders/scene_water_fast.h index 84fc918..318a37a 100644 --- a/shaders/scene_water_fast.h +++ b/shaders/scene_water_fast.h @@ -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" diff --git a/skaterift.c b/skaterift.c index fac8281..e56a43a 100644 --- a/skaterift.c +++ b/skaterift.c @@ -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 ); diff --git a/skaterift.h b/skaterift.h index fd59537..15a17de 100644 --- a/skaterift.h +++ b/skaterift.h @@ -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 9c1a1cf..63bfa9c 100644 --- 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; diff --git a/world_entity.c b/world_entity.c index 4a8670d..82c9723 100644 --- a/world_entity.c +++ b/world_entity.c @@ -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; ito_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; isubmesh_count; i++ ){ + for( u32 i=0; isubmesh_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; isubmesh_count; i++ ){ + for( u32 i=0; isubmesh_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; ient_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; ient_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; ient_unlock); i++ ){ - ent_unlock *unlock = mdl_arritm(&world->ent_unlock,i); + for( u32 i=0; ient_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 ); } } diff --git a/world_entity.h b/world_entity.h index c3af72a..ba58df8 100644 --- a/world_entity.h +++ b/world_entity.h @@ -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, diff --git a/world_gen.c b/world_gen.c index b522cba..6bef3ef 100644 --- a/world_gen.c +++ b/world_gen.c @@ -277,12 +277,12 @@ VG_STATIC void world_gen_generate_meshes( world_instance *world ){ } /* unpack challenge models */ - for( u32 i=0; ient_challenge ); i++ ){ - ent_challenge *challenge = mdl_arritm( &world->ent_challenge, i ); + for( u32 i=0; ient_objective ); i++ ){ + ent_objective *objective = mdl_arritm( &world->ent_objective, i ); - for( u32 j=0; jsubmesh_count; j ++ ){ + for( u32 j=0; jsubmesh_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 ); } } diff --git a/world_load.c b/world_load.c index b91246f..2ca957a 100644 --- a/world_load.c +++ b/world_load.c @@ -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 ); diff --git a/world_render.c b/world_render.c index 55d13d4..35730ac 100644 --- a/world_render.c +++ b/world_render.c @@ -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; ient_challenge, index ); - if( challenge->flags & k_ent_challenge_hidden ) continue; + for( u32 i=0; ient_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; jsubmesh_count; j++ ){ + for( u32 j=0; jsubmesh_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; ient_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; ient_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; ient_unlock, index ); + for( u32 i=0; ient_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; ient_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; ient_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, diff --git a/world_render.h b/world_render.h index dee4216..d71b44e 100644 --- a/world_render.h +++ b/world_render.h @@ -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 ); -- 2.25.1