X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=character.h;h=df05295611492ecb41cbafafd266bf9623830c50;hb=86dbcd5796ed674ca9433cce1ace8bef322cd121;hp=39ee472ab436a5805e49f8694cd825af37215ee0;hpb=6d66c67945f84476d6ac75a0497007cc30bcf58c;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/character.h b/character.h index 39ee472..df05295 100644 --- a/character.h +++ b/character.h @@ -4,8 +4,10 @@ #include "common.h" #include "model.h" #include "scene.h" +#include "world.h" #include "ik.h" #include "rigidbody.h" +#include "render.h" #include "shaders/character.h" vg_tex2d tex_pallet = { .path = "textures/ch_gradient.qoi" }; @@ -432,6 +434,7 @@ void character_pose_blend( struct character *ch, character_pose *pose, float q ) v3_muladds( ch->cam_pos, pose->cam, q, ch->cam_pos ); } +#if 1 static void character_final_pose( struct character *ch, v3f cog, character_pose *pose, float q ) @@ -464,6 +467,34 @@ void character_final_pose( struct character *ch, v3f cog, character_pose_blend( ch, &npose, q ); } +#else +static +void character_final_pose( struct character *ch, v4f rot, + character_pose *pose, float q ) +{ + character_pose npose; + + m4x3f tr; + q_m3x3( rot, tr ); + v3_zero( tr[3] ); + + m4x3_mulv( tr, pose->b0, npose.b0 ); + m4x3_mulv( tr, pose->b1, npose.b1 ); + m4x3_mulv( tr, pose->p, npose.p ); + m4x3_mulv( tr, pose->pl, npose.pl ); + m4x3_mulv( tr, pose->pr, npose.pr ); + m4x3_mulv( tr, pose->hl, npose.hl ); + m4x3_mulv( tr, pose->hr, npose.hr ); + m4x3_mulv( tr, pose->apl, npose.apl ); + m4x3_mulv( tr, pose->apr, npose.apr ); + + v3_copy( pose->fr, npose.fr ); + v3_copy( pose->fl, npose.fl ); + v3_copy( pose->cam, npose.cam ); + + character_pose_blend( ch, &npose, q ); +} +#endif static void character_yaw_upper( struct character *ch, float yaw ) { @@ -556,8 +587,7 @@ static void character_testpose( struct character *ch, float t ) m4x3_identity( ch->matrices[k_chpart_wf] ); } -static float *player_cam_pos(void); -static void character_draw( struct character *ch, float temp ) +static void character_draw( struct character *ch, float temp, m4x3f camera ) { shader_character_use(); shader_character_uPv( vg_pv ); @@ -565,7 +595,7 @@ static void character_draw( struct character *ch, float temp ) vg_tex2d_bind( &tex_pallet, 0 ); shader_character_uTexMain( 0 ); shader_character_uOpacity( temp ); - shader_character_uCamera( player_cam_pos() ); + shader_character_uCamera( camera[3] ); shader_link_standard_ub( _shader_character.id, 2 ); glEnable( GL_CULL_FACE ); @@ -825,8 +855,7 @@ static void character_ragdoll_copypose( struct character *ch, v3f v ) m4x3_mulv( ch->matrices[i], rb->delta, rb->co ); m3x3_q( ch->matrices[i], rb->q ); v3_copy( v, rb->v ); - v3_zero( rb->I ); - rb->manifold_count = 0; /* ? */ + v3_zero( rb->w ); rb_update_transform( rb ); } @@ -884,34 +913,29 @@ static void character_debug_ragdoll( struct character *ch ) static void character_ragdoll_iter( struct character *ch ) { + rb_solver_reset(); + for( int i=0; iragdoll[i] ); - rb_build_manifold_terrain( &ch->ragdoll[i] ); - - u32 colliders[16]; - int len = bh_select( &world.bhcubes, ch->ragdoll[i].bbx_world, - colliders, 16 ); - - for( int j=0; jragdoll[i], - &world.temp_rbs[colliders[j]] ); + rb_collide( &ch->ragdoll[i], &world.rb_geo ); } + rb_presolve_contacts( rb_contact_buffer, rb_contact_count ); + v3f rv; - float shoe_vel[2]; + float shoe_vel[2] = {0.0f,0.0f}; for( int i=0; i<2; i++ ) if( ch->shoes[i] ) shoe_vel[i] = v3_length( ch->ragdoll[i].v ); - - for( int i=0; i<20; i++ ) + + /* This used to be 20 iterations */ + for( int i=0; i<10; i++ ) { float const k_springfactor = 1.0f/20.0f; - - for( int j=0; jragdoll[j] ); - + + rb_solve_contacts( rb_contact_buffer, rb_contact_count ); + for( int j=0; jco, dst->co ); v3_copy( src->v, dst->v ); v3_copy( src->q, dst->q ); - v3_copy( src->I, dst->I ); + v3_copy( src->w, dst->w ); } } }