#include "addon.h"
static void player__skate_bind(void){
- struct player_avatar *av = localplayer.playeravatar;
- struct skeleton *sk = &av->sk;
-
+ struct skeleton *sk = &localplayer.skeleton;
rb_update_transform( &localplayer.rb );
struct { struct skeleton_anim **anim; const char *name; }
support_max;
v3f support_axis;
- v3_cross( plane, localplayer.basis[1], support_axis );
+ v3_cross( plane, (v3f){0,1,0}, support_axis );
v3_normalize( support_axis );
bh_iter it;
v3_cross( va, vb, normal );
sample->normal[0] = v3_dot( support_axis, normal );
- sample->normal[1] = v3_dot( localplayer.basis[1], normal );
+ sample->normal[1] = normal[1];
sample->co[0] = v3_dot( support_axis, d );
- sample->co[1] = v3_dot( localplayer.basis[1], d );
+ sample->co[1] = d[1];
v3_copy( normal, sample->normal3 ); /* normalize later
if we want to us it */
v3_muls( dir, vg_signf(v3_dot(dir,plane)), dir );
v3_add( average_direction, dir, average_direction );
- float yi = v3_dot( localplayer.basis[1], si->normal3 ),
- yj = v3_dot( localplayer.basis[1], sj->normal3 );
+ float yi = si->normal3[1],
+ yj = sj->normal3[1];
if( yi > yj ) v3_add( si->normal3, average_normal, average_normal );
else v3_add( sj->normal3, average_normal, average_normal );
v3f v0;
v3_sub( target, localplayer.rb.co, v0 );
- m3x3_mulv( localplayer.invbasis, v0, v0 );
v3f ax;
v3_copy( v0, ax );
ax[1] = 0.0f;
v3_normalize( ax );
- v3f v_local;
- m3x3_mulv( localplayer.invbasis, localplayer.rb.v, v_local );
-
- v2f d = { v3_dot( ax, v0 ), v0[1] },
- v = { v3_dot( ax, v_local ), v_local[1] };
+ v2f d = { v3_dot( ax, v0 ), v0[1] },
+ v = { v3_dot( ax, localplayer.rb.v ), localplayer.rb.v[1] };
float a = atan2f( v[1], v[0] ),
m = v2_length( v ),
v3_muls( ax, cosf( a0 ) * m, inf->v );
inf->v[1] += sinf( a0 ) * m;
- m3x3_mulv( localplayer.basis, inf->v, inf->v );
inf->land_dist = d[0] / (cosf(a0)*m);
inf->gravity = gravity;
v3_muls( ax, cosf( a1 ) * m, inf->v );
inf->v[1] += sinf( a1 ) * m;
- m3x3_mulv( localplayer.basis, inf->v, inf->v );
inf->land_dist = d[0] / (cosf(a1)*m);
inf->gravity = gravity;
v3_normalize( axis );
/* at high slopes, Y component is low */
- float upness = v3_dot( localplayer.rb.to_world[1], localplayer.basis[1] ),
+ float upness = localplayer.rb.to_world[1][1],
angle_begin = -(1.0f-fabsf( upness )),
angle_end = 1.0f;
inf->gravity = gravity;
v3_copy( launch_v, inf->v );
- m3x3f basis;
- m3x3_copy( localplayer.basis, basis );
-
for( int i=1; i<=50; i++ ){
float t = (float)i * k_trace_delta;
v3_muls( launch_v, t, co1 );
- v3_muladds( co1, basis[1], -0.5f * gravity * t*t, co1 );
+ co1[1] += -0.5f * gravity * t*t;
v3_add( launch_co, co1, co1 );
- float launch_vy = v3_dot( launch_v,basis[1] );
+ float launch_vy = launch_v[1];
int search_for_grind = 1;
if( grind_located ) search_for_grind = 0;
for( int j=0; j<2; j++ ){
v3_muls( launch_v_bounds[j], t, bound[j] );
- v3_muladds( bound[j], basis[1], -0.5f*gravity*t*t, bound[j] );
+ bound[j][1] += -0.5f*gravity*t*t;
v3_add( launch_co, bound[j], bound[j] );
}
if( search_for_grind ){
v3f ve;
v3_copy( launch_v, ve );
- v3_muladds( ve, basis[1], -gravity * t, ve );
+ ve[1] += -gravity * t;
if( skate_grind_scansq( closest, ve, 0.5f, &grind ) ){
/* check alignment */
- v2f v0 = { v3_dot( ve, basis[0] ),
- v3_dot( ve, basis[2] ) },
- v1 = { v3_dot( grind.dir, basis[0] ),
- v3_dot( grind.dir, basis[2] ) };
+ v2f v0 = { ve[0], ve[2] },
+ v1 = { grind.dir[0], grind.dir[2] };
v2_normalize( v0 );
v2_normalize( v1 );
m4x3_mulv( gate->transport, co1, co1 );
m3x3_mulv( gate->transport, launch_v, launch_v);
m4x3_mulv( gate->transport, launch_co, launch_co );
- m3x3_mul( gate->transport, basis, basis );
- if( gate->flags & k_ent_gate_nonlocal ){
+ if( gate->flags & k_ent_gate_nonlocal )
trace_world = &world_static.instances[ gate->target ];
- }
}
}
v3f ve;
v3_copy( launch_v, ve );
- v3_muladds( ve, localplayer.basis[1], -gravity * t, ve );
+ ve[1] += -gravity * t;
inf->score = -v3_dot( ve, inf->n );
inf->land_dist = t + k_trace_delta * t1;
v3_copy( jump->v, launch_v );
v3_copy( localplayer.rb.co, launch_co );
-
- m3x3f basis;
- m3x3_copy( localplayer.basis, basis );
float t = 0.05f * jump->land_dist;
v3_muls( launch_v, t, co0 );
- v3_muladds( co0, basis[1], -0.5f * jump->gravity * t*t, co0 );
+ co0[1] += -0.5f * jump->gravity * t*t;
v3_add( launch_co, co0, co0 );
/* rough scan to make sure we dont collide with anything */
t *= jump->land_dist;
v3_muls( launch_v, t, co1 );
- v3_muladds( co1, basis[1], -0.5f * jump->gravity * t*t, co1 );
+ co1[1] += -0.5f * jump->gravity * t*t;
v3_add( launch_co, co1, co1 );
float t1;
/* determine score */
v3f ve;
v3_copy( jump->v, ve );
- v3_muladds( ve, localplayer.basis[1],
- -jump->gravity*jump->land_dist, ve );
+ ve[1] += -jump->gravity*jump->land_dist;
jump->score = -v3_dot( ve, grind.n ) * 0.9f;
player_skate.possible_jumps[ player_skate.possible_jump_count ++ ] =
v3_zero( state->flip_axis );
}
}
- else{
- v3_copy( localplayer.basis[1], state->land_normal );
- }
+ else
+ v3_copy( (v3f){0,1,0}, state->land_normal );
}
/*
v3f jumpdir;
/* Launch more up if alignment is up else improve velocity */
- float aup = v3_dot( localplayer.basis[1], localplayer.rb.to_world[1] ),
+ float aup = localplayer.rb.to_world[1][1],
mod = 0.5f,
dir = mod + fabsf(aup)*(1.0f-mod);
/* Apply forces & intergrate */
v3_muladds( state->cog_v, F, -rb, state->cog_v );
- v3_muladds( state->cog_v, localplayer.basis[1], -9.8f * k_rb_delta,
- state->cog_v );
-
+ state->cog_v[1] += -9.8f * k_rb_delta;
v3_muladds( state->cog, state->cog_v, k_rb_delta, state->cog );
}
}
else{
v3f avg;
- v3_add( localplayer.rb.to_world[1], localplayer.basis[1], avg );
+ v3_add( localplayer.rb.to_world[1], (v3f){0,1,0}, avg );
v3_normalize( avg );
v3_lerp( state->up_dir, avg,
if( world->water.enabled ){
if( localplayer.rb.co[1]+0.25f < world->water.height ){
-#if 0
player__networked_sfx( k_player_subsystem_walk, 32,
k_player_walk_soundeffect_splash,
localplayer.rb.co, 1.0f );
-#endif
player__skate_kill_audio();
player__dead_transition();
return;
}
}
min_dist -= 0.2f;
- float vy = v3_dot( localplayer.basis[1], localplayer.rb.v );
- vy = vg_maxf( 0.0f, vy );
-
+ float vy = vg_maxf( 0.0f, localplayer.rb.v[1] );
slap = vg_clampf( (min_dist/0.5f) + vy, 0.0f, 1.0f )*0.3f;
}
state->slap = vg_lerpf( state->slap, slap, 10.0f*k_rb_delta );
}
rb_update_transform( &localplayer.rb );
- v3_muladds( localplayer.rb.v, localplayer.basis[1],
- -state->gravity_bias * player_skate.substep_delta,
- localplayer.rb.v );
+ localplayer.rb.v[1] += -state->gravity_bias * player_skate.substep_delta;
player_skate.substep -= player_skate.substep_delta;
}
static void player__skate_pose( void *_animator, player_pose *pose ){
- struct player_avatar *av = localplayer.playeravatar;
- struct skeleton *sk = &av->sk;
+ struct skeleton *sk = &localplayer.skeleton;
struct player_skate_animator *animator = _animator;
pose->type = k_player_pose_type_ik;
skeleton_lerp_pose( sk, ground_pose, air_pose, animator->fly,
pose->keyframes );
- mdl_keyframe *kf_board = &pose->keyframes[av->id_board-1],
- *kf_foot_l = &pose->keyframes[av->id_ik_foot_l-1],
- *kf_foot_r = &pose->keyframes[av->id_ik_foot_r-1],
- *kf_knee_l = &pose->keyframes[av->id_ik_knee_l-1],
- *kf_knee_r = &pose->keyframes[av->id_ik_knee_r-1],
- *kf_hip = &pose->keyframes[av->id_hip-1],
- *kf_wheels[] = { &pose->keyframes[av->id_wheel_r-1],
- &pose->keyframes[av->id_wheel_l-1] };
+ mdl_keyframe *kf_board = &pose->keyframes[localplayer.id_board-1],
+ *kf_foot_l = &pose->keyframes[localplayer.id_ik_foot_l-1],
+ *kf_foot_r = &pose->keyframes[localplayer.id_ik_foot_r-1],
+ *kf_knee_l = &pose->keyframes[localplayer.id_ik_knee_l-1],
+ *kf_knee_r = &pose->keyframes[localplayer.id_ik_knee_r-1],
+ *kf_hip = &pose->keyframes[localplayer.id_hip-1],
+ *kf_wheels[] = { &pose->keyframes[localplayer.id_wheel_r-1],
+ &pose->keyframes[localplayer.id_wheel_l-1] };
mdl_keyframe grind_pose[32];
float add_grab_mod = 1.0f - animator->fly;
/* additive effects */
- u32 apply_to[] = { av->id_hip,
- av->id_ik_hand_l,
- av->id_ik_hand_r,
- av->id_ik_elbow_l,
- av->id_ik_elbow_r };
+ u32 apply_to[] = { localplayer.id_hip,
+ localplayer.id_ik_hand_l,
+ localplayer.id_ik_hand_r,
+ localplayer.id_ik_elbow_l,
+ localplayer.id_ik_elbow_r };
float apply_rates[] = { 1.0f,
0.75f,
/* angle 'correction' */
v3f origin;
- v3_add( av->sk.bones[av->id_hip].co, kf_hip->co, origin );
+ v3_add( sk->bones[localplayer.id_hip].co, kf_hip->co, origin );
for( int i=0; i<vg_list_size(apply_to); i ++ ){
mdl_keyframe *kf = &pose->keyframes[apply_to[i]-1];
- keyframe_rotate_around( kf, origin, av->sk.bones[apply_to[i]].co,
+ keyframe_rotate_around( kf, origin, sk->bones[apply_to[i]].co,
animator->qfixuptotal );
}
q_normalize( kf_wheels[i]->q );
}
-#if 0
{
mdl_keyframe
- *kf_head = &pose->keyframes[av->id_head-1],
- *kf_elbow_l = &pose->keyframes[av->id_ik_elbow_l-1],
- *kf_elbow_r = &pose->keyframes[av->id_ik_elbow_r-1],
- *kf_hand_l = &pose->keyframes[av->id_ik_hand_l-1],
- *kf_hand_r = &pose->keyframes[av->id_ik_hand_r-1];
+ *kf_head = &pose->keyframes[localplayer.id_head-1],
+ *kf_elbow_l = &pose->keyframes[localplayer.id_ik_elbow_l-1],
+ *kf_elbow_r = &pose->keyframes[localplayer.id_ik_elbow_r-1],
+ *kf_hand_l = &pose->keyframes[localplayer.id_ik_hand_l-1],
+ *kf_hand_r = &pose->keyframes[localplayer.id_ik_hand_r-1];
float warble = perlin1d( vg.time, 2.0f, 2, 300 );
warble *= vg_maxf(animator->grind, fabsf(animator->weight)) * 0.3f;
v3f origin = {0.0f,0.2f,0.0f};
keyframe_rotate_around( kf_hand_l, origin,
- av->sk.bones[av->id_ik_hand_l].co, qrot );
+ sk->bones[localplayer.id_ik_hand_l].co, qrot );
keyframe_rotate_around( kf_hand_r, origin,
- av->sk.bones[av->id_ik_hand_r].co, qrot );
+ sk->bones[localplayer.id_ik_hand_r].co, qrot );
keyframe_rotate_around( kf_hip, origin,
- av->sk.bones[av->id_hip].co, qrot );
+ sk->bones[localplayer.id_hip].co, qrot );
keyframe_rotate_around( kf_elbow_r, origin,
- av->sk.bones[av->id_ik_elbow_r].co, qrot );
+ sk->bones[localplayer.id_ik_elbow_r].co, qrot );
keyframe_rotate_around( kf_elbow_l, origin,
- av->sk.bones[av->id_ik_elbow_l].co, qrot );
+ sk->bones[localplayer.id_ik_elbow_l].co, qrot );
q_inv( qrot, qrot );
q_mul( qrot, kf_head->q, kf_head->q );
q_normalize( kf_head->q );
}
-#endif
}
static void player__skate_post_animate(void){
- struct player_avatar *av = localplayer.playeravatar;
struct player_skate_state *state = &player_skate.state;
-
localplayer.cam_velocity_influence = 1.0f;
v3f head = { 0.0f, 1.8f, 0.0f };
- m4x3_mulv( localplayer.final_mtx[ av->id_head ],
+ m4x3_mulv( localplayer.final_mtx[ localplayer.id_head ],
head, state->head_position );
m4x3_mulv( localplayer.rb.to_local,
state->head_position, state->head_position );
v3_zero( player_skate.weight_distribution );
}
-static void player__skate_reset( ent_spawn *rp ){
- struct player_skate_state *state = &player_skate.state;
- v3_zero( localplayer.rb.v );
- v4_copy( rp->transform.q, localplayer.rb.q );
-
- state->activity = k_skate_activity_air;
- state->activity_prev = k_skate_activity_air;
-
- player__skate_clear_mechanics();
- player__skate_reset_animator();
-
- v3_zero( state->head_position );
- state->head_position[1] = 1.8f;
-}
-
#include "network_compression.h"
static void player__skate_animator_exchange( bitpack_ctx *ctx, void *data ){