X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_glide.c;h=6b5930b9c2f26bed2d4d17ad1f28d3d902303831;hb=HEAD;hp=f7339373869924086ceb02272a80b1af9a01da89;hpb=5f6a4f9df6c8accc89f1920bfe9ace3cbac4c4b6;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_glide.c b/player_glide.c index f733937..6b5930b 100644 --- a/player_glide.c +++ b/player_glide.c @@ -125,7 +125,7 @@ static void calculate_lift( v3f vl, f32 aoa_bias, f32 windv2 = v3_length2(wind), aoa = atan2f( v3_dot( up, wind ), v3_dot( back, wind ) ) + aoa_bias, - cl = aoa / VG_PIf, /* TODO: make it a curve */ + cl = aoa / VG_PIf, L = windv2 * cl * power; v3f lift_dir; @@ -273,11 +273,15 @@ void player_glide_update(void) v2f steer; joystick_state( k_srjoystick_steer, steer ); - if( glider_physics( steer ) ){ + if( glider_physics( steer ) ) + { vg_info( "player fell off due to glider hitting ground\n" ); player__dead_transition( k_player_die_type_generic ); localplayer.glider_orphan = 1; } + + if( !world_water_player_safe( world_current_instance(), 1.0f ) ) + return; } void player_glide_post_update(void) @@ -453,32 +457,15 @@ void player_glide_bind(void) mdl_open( mdl, "models/glider.mdl", alloc ); mdl_load_metadata_block( mdl, alloc ); - - vg_linear_clear( vg_mem.scratch ); - - u32 count = mdl_arrcount( &mdl->textures ); - player_glide.glider_textures = - vg_linear_alloc( alloc, vg_align8(sizeof(GLuint)*(count+1))); - player_glide.glider_textures[0] = vg.tex_missing; - mdl_async_load_glmesh( mdl, &player_glide.glider_mesh, NULL ); - - for( u32 i=0; itextures, i ); - void *data = vg_linear_alloc( vg_mem.scratch, tex->file.pack_size ); - mdl_fread_pack_file( mdl, &tex->file, data ); - vg_tex2d_load_qoi_async( data, tex->file.pack_size, - VG_TEX2D_LINEAR|VG_TEX2D_CLAMP, - &player_glide.glider_textures[i+1] ); - } + mdl_async_full_load_std( mdl ); /* load trail positions */ mdl_array_ptr markers; MDL_LOAD_ARRAY( mdl, &markers, ent_marker, vg_mem.scratch ); + mdl_close( mdl ); - for( u32 i=0; itransform.co, player_glide.trail_positions[ player_glide.trail_count ++ ] ); @@ -487,10 +474,9 @@ void player_glide_bind(void) break; } - mdl_close( mdl ); - /* allocate effects */ - for( u32 i=0; imeshs); i ++ ){ + for( u32 i=0; imeshs); i ++ ) + { mdl_mesh *mesh = mdl_arritm( &mdl->meshs, i ); m4x3f mmmdl; @@ -548,7 +535,8 @@ void render_glider_model( vg_camera *cam, world_instance *world, if( shader == k_board_shader_player ) shader_model_board_view_uMdl( mmmdl ); - else if( shader == k_board_shader_entity ){ + else if( shader == k_board_shader_entity ) + { m4x4f m4mmmdl; m4x3_expand( mmmdl, m4mmmdl ); m4x4_mul( cam->mtx_prev.pv, m4mmmdl, m4mmmdl ); @@ -557,18 +545,31 @@ void render_glider_model( vg_camera *cam, world_instance *world, shader_model_entity_uPvmPrev( m4mmmdl ); } - for( u32 j=0; jsubmesh_count; j ++ ){ + for( u32 j=0; jsubmesh_count; j ++ ) + { mdl_submesh *sm = mdl_arritm( &mdl->submeshs, mesh->submesh_start+j ); - if( !sm->material_id ) { + if( !sm->material_id ) + { vg_error( "Invalid material ID 0\n" ); continue; } - mdl_material *mat = mdl_arritm( &mdl->materials, sm->material_id-1 ); - if( mat->tex_diffuse != current_tex ){ - glBindTexture( GL_TEXTURE_2D, - player_glide.glider_textures[ mat->tex_diffuse ] ); - current_tex = mat->tex_diffuse; + if( sm->material_id != current_mat ) + { + mdl_material *mat = mdl_arritm( &mdl->materials,sm->material_id-1 ); + GLuint tex = vg.tex_missing; + + if( mat->shader == k_shader_standard ) + { + struct shader_props_standard *props = mat->props.compiled; + + u32 index = props->tex_diffuse-1; + mdl_texture *ptex = mdl_arritm( &mdl->textures, index ); + tex = ptex->glname; + } + + glBindTexture( GL_TEXTURE_2D, tex ); + current_mat = sm->material_id; } mdl_draw_submesh( sm ); @@ -595,8 +596,7 @@ void player_glide_render( vg_camera *cam, world_instance *world, shader_model_board_view_uTexMain( 0 ); shader_model_board_view_uCamera( cam->transform[3] ); shader_model_board_view_uPv( cam->mtx.pv ); - - shader_model_board_view_uDepthCompare(1); + shader_model_board_view_uDepthMode(1); depth_compare_bind( shader_model_board_view_uTexSceneDepth, shader_model_board_view_uInverseRatioDepth,