X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=ent_skateshop.c;h=b47dacf9be0780707e9ab3a874b42f263da98a79;hb=0310bab3c018e23f5516c3e3c3653b844a8106ed;hp=e7049b5a6309b03c7a1b1088528bb16c795ae024;hpb=ec90a4b46865009c1e1b1679f6926e35d2ee3f12;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/ent_skateshop.c b/ent_skateshop.c index e7049b5..b47dacf 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -9,6 +9,7 @@ #include "player.h" #include "gui.h" #include "menu.h" +#include "pointcloud.h" /* * Checks string equality but does a hash check first @@ -104,7 +105,7 @@ VG_STATIC void skateshop_update_viewpage(void) /* generic reciever */ VG_STATIC void workshop_async_any_complete( void *data, u32 size ) { - workshop_end_op(); + skaterift_end_op(); } /* @@ -348,7 +349,7 @@ next_file: tinydir_next( &dir ); */ VG_STATIC void workshop_op_item_scan(void) { - workshop_begin_op( k_workshop_op_item_scan ); + skaterift_begin_op( k_workshop_op_item_scan ); vg_loader_start( workshop_scan_thread, NULL ); } @@ -470,10 +471,12 @@ 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( localplayer.cam_override_angles, dir, 1.0f, 0.0f ); v3f lookat; - if( shop->type == k_skateshop_type_boardshop ){ + if( shop->type == k_skateshop_type_boardshop || + shop->type == k_skateshop_type_worldshop ){ ent_marker *display = mdl_arritm( &world->ent_marker, mdl_entity_id_id(shop->boards.id_display) ); @@ -569,6 +572,25 @@ VG_STATIC void global_skateshop_preupdate(void) global_skateshop_exit(); } } + else if( shop->type == k_skateshop_type_worldshop ){ + gui_helper_action( axis_display_string( k_sraxis_mbrowse_h ), "browse" ); + + v2f input; + joystick_state( k_srjoystick_steer, input ); + pointcloud.control[0] += input[0] * vg.time_delta; + pointcloud.control[2] += input[1] * vg.time_delta; + + pointcloud.control[0] = vg_clampf( pointcloud.control[0], -10.0f, 10.0f ); + pointcloud.control[2] = vg_clampf( pointcloud.control[2], -10.0f, 10.0f ); + + if( button_press( k_srbind_trick1 ) ){ + pointcloud.control[3] += vg.time_delta*0.2f; + } + if( button_press( k_srbind_trick0 ) ){ + pointcloud.control[3] -= vg.time_delta*0.2f; +} + pointcloud.control[3] = vg_clampf( pointcloud.control[3], 0.001f, 10.0f ); + } else{ vg_fatal_error( "Unknown store (%u)\n", shop->type ); } @@ -716,6 +738,55 @@ VG_STATIC void skateshop_render_charshop(void) { } +VG_STATIC void skateshop_render_worldshop(void) +{ + world_instance *world = get_active_world(); + + m4x3f mmdl; + ent_skateshop *shop = global_skateshop.ptr_ent; + ent_marker *mark_display = mdl_arritm( &world->ent_marker, + mdl_entity_id_id(shop->worlds.id_display)); + mdl_transform_m4x3( &mark_display->transform, mmdl ); + + /* TODO? ... */ + v3f vol; + v3_sub( world->scene_geo.bbx[1], world->scene_geo.bbx[0], vol ); + + v2f rect = { 1.0f, 1.0f }, + map = { vol[0], vol[2] }, + result; + + f32 rp = rect[0] * map[1], + rc = rect[1] * map[0]; + + u32 axis, other; + if( rc > rp ) axis = 0; + else axis = 1; + other = axis ^ 0x1; + + result[axis] = rect[axis]; + result[other] = (rect[axis] * map[other]) / map[axis]; + + m4x3f mlocal, mx; + m4x3_identity( mlocal ); + + mlocal[0][0] = result[0]; + mlocal[2][2] = result[1]; + mlocal[1][1] = (vol[1]/vol[0]) * mlocal[0][0]; + mlocal[3][0] = (rect[0]-result[0])*0.5f - rect[0]*0.5f; /* sea level? */ + mlocal[3][2] = (rect[1]-result[1])*0.5f - rect[1]*0.5f; + m4x3_mul( mmdl, mlocal, mx ); + +#if 1 + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE); + glDisable(GL_DEPTH_TEST); +#endif + pointcloud_render( world, &main_camera, mx ); + glDisable(GL_BLEND); + glEnable(GL_DEPTH_TEST); +} + /* * World: render event */ @@ -731,6 +802,9 @@ VG_STATIC void skateshop_render(void) else if( shop->type == k_skateshop_type_charshop ){ skateshop_render_charshop(); } + else if( shop->type == k_skateshop_type_worldshop ){ + skateshop_render_worldshop(); + } else{ vg_fatal_error( "Unknown store (%u)\n", shop->type ); } @@ -746,6 +820,7 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call ) vg_info( "skateshop_call\n" ); if( menu.active ) return; + if( skaterift.async_op != k_async_op_none ) return; if( call->function == k_ent_function_trigger ){ if( localplayer.subsystem != k_player_subsystem_walk ){