X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_model.h;h=a4a626c666cfe7db46d171d571d4251d66efccca;hb=a9f402f2e336dadff2207dacf69416a66f50c8f8;hp=a067b033d2a9c290aba32db78f83665ba7972f8c;hpb=b4c9550f206c476bb38b0bb2855d35e6b31bee83;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_model.h b/player_model.h index a067b03..a4a626c 100644 --- a/player_model.h +++ b/player_model.h @@ -1,4 +1,4 @@ -#ifndef CHARACTER_H +#ifndef CHARACTER_H #define CHARACTER_H #include "common.h" @@ -10,6 +10,9 @@ #include "skeleton_animator.h" #include "shaders/viewchar.h" +static float k_ragdoll_floatyiness = 10.0f, + k_ragdoll_floatydrag = 1.0f; + vg_tex2d tex_characters = { .path = "textures/ch_gradient.qoi" }; static void character_register(void) @@ -31,7 +34,9 @@ struct character *anim_slide, *anim_air, *anim_push, *anim_push_reverse, - *anim_ollie; + *anim_ollie, *anim_ollie_reverse, + *anim_grabs, *anim_stop, + *anim_walk, *anim_run, *anim_idle; u32 id_hip, id_ik_hand_l, @@ -79,6 +84,11 @@ static int character_load( struct character *ch, const char *name ) ch->anim_push = skeleton_get_anim( &ch->sk, "push" ); ch->anim_push_reverse = skeleton_get_anim( &ch->sk, "push_reverse" ); ch->anim_ollie = skeleton_get_anim( &ch->sk, "ollie" ); + ch->anim_ollie_reverse = skeleton_get_anim( &ch->sk, "ollie_reverse" ); + ch->anim_grabs = skeleton_get_anim( &ch->sk, "grabs" ); + ch->anim_walk = skeleton_get_anim( &ch->sk, "walk" ); + ch->anim_run = skeleton_get_anim( &ch->sk, "run" ); + ch->anim_idle = skeleton_get_anim( &ch->sk, "idle_cycle" ); ch->id_hip = skeleton_bone_id( &ch->sk, "hips" ); ch->id_ik_hand_l = skeleton_bone_id( &ch->sk, "hand.IK.L" ); @@ -153,6 +163,21 @@ static void character_draw( struct character *ch, float temp, m4x3f camera ){} static void character_init_ragdoll_joints( struct character *ch ){} static void character_init_ragdoll( struct character *ch ){} static void character_ragdoll_go( struct character *ch, v3f pos ){} + +static void character_mimic_ragdoll( struct character *ch ) +{ + for( int i=0; iragdoll_count; i++ ) + { + struct ragdoll_part *part = &ch->ragdoll[i]; + m4x3f offset; + m3x3_identity(offset); + v3_negate( part->offset, offset[3] ); + m4x3_mul( part->rb.to_world, offset, ch->sk.final_mtx[part->bone_id] ); + } + + skeleton_apply_inverses( &ch->sk ); +} + static void character_ragdoll_copypose( struct character *ch, v3f v ) { for( int i=0; iragdoll_count; i++ ) @@ -217,6 +242,10 @@ static void character_ragdoll_iter( struct character *ch ) rb_debug_constraint_limits( &pj->rb, &pp->rb, lca, pj->limits ); } } + + v4f plane = {0.0f,1.0f,0.0f,0.0f}; + rb_effect_simple_bouyency( &pj->rb, plane, k_ragdoll_floatyiness, + k_ragdoll_floatydrag ); } /* CONSTRAINTS */ @@ -229,7 +258,7 @@ static void character_ragdoll_iter( struct character *ch ) struct ragdoll_part *pj = &ch->ragdoll[j]; struct skeleton_bone *bj = &ch->sk.bones[pj->bone_id]; - if( pj->parent != 0xffffffff ) + if( pj->parent != 0xffffffff && pj->use_limits ) { struct ragdoll_part *pp = &ch->ragdoll[pj->parent]; struct skeleton_bone *bp = &ch->sk.bones[pp->bone_id]; @@ -241,10 +270,7 @@ static void character_ragdoll_iter( struct character *ch ) rb_constraint_position( &pj->rb, lca, &pp->rb, lcb ); - if( pj->use_limits ) - { - rb_constraint_limits( &pj->rb, lca, &pp->rb, lcb, pj->limits ); - } + rb_constraint_limits( &pj->rb, lca, &pp->rb, lcb, pj->limits ); } } }