v3f dir = {0.0f,-1.0f,0.0f};
mdl_transform_vector( &ref->transform, dir, dir );
- m3x3_mulv( localplayer.invbasis, dir, dir );
- player_vector_angles( world_static.focus_cam.angles, dir, 1.0f, 0.0f );
+ v3_angles( dir, world_static.focus_cam.angles );
v3f lookat;
if( shop->type == k_skateshop_type_boardshop ||
v3f v0;
mdl_transform_vector( &menu.cam->transform, (v3f){0.0f,-1.0f,0.0f}, v0 );
- player_vector_angles( target.angles, v0, 1.0f, 0.0f );
+ v3_angles( v0, target.angles );
camera_lerp( &menu.view, &target, rate, &menu.view );
m4x3_mulv( gate->transport, cc->tpv_lpf, cc->tpv_lpf );
m3x3_mulv( gate->transport, cc->cam_velocity_smooth,
cc->cam_velocity_smooth );
- m3x3_copy( localplayer.basis, localplayer.basis_gate );
-
- v4f q;
- m3x3_q( gate->transport, q );
- q_mul( q, localplayer.qbasis, localplayer.qbasis );
- q_normalize( localplayer.qbasis );
- q_m3x3( localplayer.qbasis, localplayer.basis );
- m3x3_transpose( localplayer.basis, localplayer.invbasis );
m4x3_mulv( gate->transport, localplayer.cam.pos, localplayer.cam.pos );
+
+ v3f v0;
+ v3_angles_vector( localplayer.angles, v0 );
+ m3x3_mulv( gate->transport, v0, v0 );
+ v3_angles( v0, localplayer.angles );
audio_lock();
audio_oneshot( &audio_gate_pass, 1.0f, 0.0f );
player__debugtext( 2, "player" );
player__debugtext( 1, "angles: " PRINTF_v3f( localplayer.cam.angles ) );
- player__debugtext( 1, "basis: " PRINTF_v4f( localplayer.qbasis ) );
if( player_subsystems[ localplayer.subsystem ]->im_gui )
player_subsystems[ localplayer.subsystem ]->im_gui();
rb_update_transform( &localplayer.rb );
- q_identity( localplayer.qbasis );
- m3x3_identity( localplayer.basis );
- m3x3_identity( localplayer.invbasis );
-
localplayer.subsystem = k_player_subsystem_walk;
player__walk_reset();
rigidbody rb;
v3f angles;
+#if 0
v4f qbasis;
m3x3f basis, invbasis, basis_gate;
+#endif
world_instance *viewable_world;
/*
#include "menu.h"
#include "vg/vg_perlin.h"
-static void player_vector_angles( v3f angles, v3f v, float C, float k ){
- float yaw = atan2f( v[0], -v[2] ),
- pitch = atan2f
- (
- -v[1],
- sqrtf
- (
- v[0]*v[0] + v[2]*v[2]
- )
- ) * C + k;
-
- angles[0] = yaw;
- angles[1] = pitch;
- angles[2] = 0.0f;
-}
-
static float player_get_heading_yaw(void){
v3f xz;
q_mulv( localplayer.rb.q, (v3f){ 0.0f,0.0f,1.0f }, xz );
- m3x3_mulv( localplayer.invbasis, xz, xz );
return atan2f( xz[0], xz[2] );
}
m4x3_invert_affine( localplayer.gate_waiting->transport, inverse );
m4x3_mulv( inverse, localplayer.cam.pos, localplayer.cam.pos );
+ v3f v0;
+ v3_angles_vector( localplayer.cam.angles, v0 );
+ m3x3_mulv( inverse, v0, v0 );
+ v3_angles( v0, localplayer.cam.angles );
+
skeleton_apply_transform( &localplayer.skeleton, inverse,
localplayer.final_mtx );
}
v3_lerp( cc->cam_velocity_smooth, localplayer.rb.v, 4.0f*vg.time_frame_delta,
cc->cam_velocity_smooth );
- v3f velocity_local;
- m3x3_mulv( localplayer.invbasis, cc->cam_velocity_smooth, velocity_local );
- player_vector_angles( velocity_angles, velocity_local,
- localplayer.cam_velocity_coefficient_smooth,
- localplayer.cam_velocity_constant_smooth );
+ v3_angles( cc->cam_velocity_smooth, velocity_angles );
+ velocity_angles[1] *= localplayer.cam_velocity_coefficient_smooth;
+ velocity_angles[1] += localplayer.cam_velocity_constant_smooth;
float inf_fpv = localplayer.cam_velocity_influence_smooth *
cc->camera_type_blend,
v3f future;
v3_muls( localplayer.rb.v, 0.4f*vg.time_frame_delta, future );
- m3x3_mulv( localplayer.invbasis, future, future );
v3f camera_follow_dir =
{ -sinf( localplayer.angles[0] ) * cosf( localplayer.angles[1] ),
follow_angles[0] = atan2f( -v0[0], v0[2] );
follow_angles[1] = 0.3f + velocity_angles[1] * 0.2f;
- float ya = atan2f( -velocity_local[1], 30.0f );
+ float ya = atan2f( -cc->cam_velocity_smooth[1], 30.0f );
follow_angles[1] = 0.3f + ya;
camera_lerp_angles( localplayer.angles, follow_angles,
v3_add( tpv_origin, cc->tpv_lpf, tpv_origin );
/* offset */
- m3x3_mulv( localplayer.basis, camera_follow_dir, camera_follow_dir );
v3_muls( camera_follow_dir, 1.8f, tpv_offset );
v3_muladds( tpv_offset, cc->cam_velocity_smooth, -0.025f, tpv_offset );
v3f v0;
if( k_cinema_fixed )
mdl_transform_vector( &cam->transform, (v3f){0.0f,-1.0f,0.0f}, v0 );
- else v3_sub( localplayer.rb.co, cam->transform.co, v0 );
- m3x3_mulv( localplayer.invbasis, v0, v0 );
- player_vector_angles( localplayer.cam.angles, v0, 1.0f, 0.0f );
+ else
+ v3_sub( localplayer.rb.co, cam->transform.co, v0 );
+
+ v3_angles( v0, localplayer.cam.angles );
}
}
static void player_look( v3f angles, float speed );
static void player__cam_iterate(void);
-static void player_vector_angles( v3f angles, v3f v, float C, float k );
static struct player_board
*player_get_player_board( struct player_instance *player );
static struct player_model
v3f lookdir = { 0.0f, 0.0f, -1.0f },
sidedir = { 1.0f, 0.0f, 0.0f };
-
- m3x3f mtx;
- m3x3_mul( cam->transform, localplayer.basis, mtx );
- m3x3_mulv( mtx, lookdir, lookdir );
- m3x3_mulv( mtx, sidedir, sidedir );
+ m3x3_mulv( cam->transform, lookdir, lookdir );
+ m3x3_mulv( cam->transform, sidedir, sidedir );
v2f input;
joystick_state( k_srjoystick_steer, input );
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 );
}
}
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,
}
}
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_walk_drop_in_vector( v3f vec ){
v3f axis, init_dir;
- v3_cross( localplayer.basis[1], player_walk.state.drop_in_normal, axis );
+ v3_cross( (v3f){0.0f,1.0f,0.0f}, player_walk.state.drop_in_normal, axis );
v3_cross( axis, player_walk.state.drop_in_normal, init_dir );
v3_normalize( init_dir );
v3_muls( init_dir, 4.25f, vec );
}
static float player_xyspeed2(void){
- v3f xy;
- v3_muladds( localplayer.rb.v, localplayer.basis[1],
- -v3_dot( localplayer.basis[1], localplayer.rb.v ), xy );
-
- return v3_length2(xy);
+ return v3_length2( (v3f){localplayer.rb.v[0], 0.0f, localplayer.rb.v[2]} );
}
static void player_walk_generic_to_skate( enum skate_activity init, f32 yaw ){
v3f dir;
v3_copy( v, dir );
v3_normalize( dir );
- m3x3_mulv( localplayer.invbasis, dir, dir );
q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f},
atan2f(-dir[0],-dir[2]) );
- q_mul( localplayer.qbasis, localplayer.rb.q, localplayer.rb.q );
q_normalize( localplayer.rb.q );
q_mulv( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, player_skate.state.cog );
static void player_walk_drop_in_overhang_transform( f32 t, v3f co, v4f q ){
v3f axis;
- v3_cross( localplayer.basis[1], player_walk.state.drop_in_normal, axis );
+ v3_cross( (v3f){0,1,0}, player_walk.state.drop_in_normal, axis );
v3_normalize( axis );
float a = acosf( player_walk.state.drop_in_normal[1] ) * t;
}
static int player_walk_normal_standable( v3f n ){
- return v3_dot( n, localplayer.basis[1] ) > 0.70710678118f;
+ return n[1] > 0.70710678118f;
}
static void player_accelerate( v3f v, v3f movedir, f32 speed, f32 accel ){
m4x3f mtx;
m3x3_copy( localplayer.rb.to_world, mtx );
- v3_add( localplayer.rb.co, localplayer.basis[1], mtx[3] );
+ v3_add( localplayer.rb.co, (v3f){0,1,0}, mtx[3] );
vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__WHITE );
v3f forward_dir = { -sinf(yaw), 0.0f, cosf(yaw) };
v3f right_dir = { forward_dir[2], 0.0f, -forward_dir[0] };
- m3x3_mulv( localplayer.basis, forward_dir, forward_dir );
- m3x3_mulv( localplayer.basis, right_dir, right_dir );
-
-
w->move_speed = localplayer.immobile? 0.0f: v2_length( steer );
/*
f32 t = vg.time - w->state.jump_input_time;
if( t < PLAYER_JUMP_EPSILON ){
- float d = v3_dot( localplayer.basis[1], localplayer.rb.v );
- v3_muladds( localplayer.rb.v, localplayer.basis[1], -d,
- localplayer.rb.v );
- v3_muladds( localplayer.rb.v, localplayer.basis[1], 5.0f,
- localplayer.rb.v );
+ localplayer.rb.v[1] = 5.0f;
w->state.activity = k_walk_activity_air;
prev_state = k_walk_activity_air;
accel_speed = k_walk_air_accel;
v3f pa, pb;
v3_copy( localplayer.rb.co, pa );
- v3_muladds( pa, localplayer.basis[1], w->collider.radius + max_dist, pa );
- v3_muladds( pa, localplayer.basis[1], -max_dist * 2.0f, pb );
+ pa[1] += w->collider.radius + max_dist;
+ v3_add( pa, (v3f){0, -max_dist * 2.0f, 0}, pb );
vg_line( pa, pb, 0xff000000 );
v3f n;
w->collider.radius, &t, n, 0 ) != -1 ){
if( player_walk_normal_standable(n) ){
v3_lerp( pa, pb, t, localplayer.rb.co );
- v3_muladds( localplayer.rb.co, localplayer.basis[1],
- -w->collider.radius - k_penetration_slop,
- localplayer.rb.co );
+ localplayer.rb.co[1] += -w->collider.radius - k_penetration_slop;
w->state.activity = k_walk_activity_ground;
- float d = -v3_dot(n,localplayer.rb.v),
- g = -k_gravity * k_rb_delta;
+ float d = -v3_dot(n,localplayer.rb.v);
v3_muladds( localplayer.rb.v, n, d, localplayer.rb.v );
- v3_muladds( localplayer.rb.v, localplayer.basis[1], g,
- localplayer.rb.v );
+ localplayer.rb.v[1] += -k_gravity * k_rb_delta;
}
}
}
/* integrate */
if( w->state.activity == k_walk_activity_air ){
- v3_muladds( localplayer.rb.v, localplayer.basis[1], -k_gravity*k_rb_delta,
- localplayer.rb.v );
+ localplayer.rb.v[1] += -k_gravity*k_rb_delta;
}
if( localplayer.immobile ){
v3_muladds( localplayer.rb.co, localplayer.rb.v, k_rb_delta,
localplayer.rb.co );
- v3_add( localplayer.rb.co, localplayer.basis[1], mtx[3] );
+ v3_add( localplayer.rb.co, (v3f){0,1,0}, mtx[3] );
vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__GREEN );
/*
localplayer.rb.co[1] -= w->collider.radius;
rb_update_transform( &localplayer.rb );
- v3_add( localplayer.rb.co, localplayer.basis[1], mtx[3] );
+ v3_add( localplayer.rb.co, (v3f){0,1,0}, mtx[3] );
vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__RED);
}
}
m4x3f mtx;
m3x3_copy( localplayer.rb.to_world, mtx );
- v3_add( localplayer.rb.co, localplayer.basis[1], mtx[3] );
+ v3_add( localplayer.rb.co, (v3f){0,1,0}, mtx[3] );
float substep = vg.time_fixed_extrapolate;
v3_muladds( mtx[3], localplayer.rb.v, k_rb_delta*substep, mtx[3] );
/* Calculate header */
v3f v;
- if( player_xyspeed2() > 0.1f*0.1f )
- {
- v3f v_xy;
- m3x3_mulv( localplayer.invbasis, localplayer.rb.v, v_xy );
- float a = atan2f( v_xy[0], v_xy[2] );
-
+ if( player_xyspeed2() > 0.1f*0.1f ){
+ float a = atan2f( localplayer.rb.v[0], localplayer.rb.v[2] );
q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, a );
- q_mul( localplayer.qbasis, localplayer.rb.q, localplayer.rb.q );
- q_normalize( localplayer.rb.q );
}
vg_line_point( w->state.drop_in_target, 0.1f, VG__GREEN );
p1[0] = sinf( a );
p1[1] = 0.0f;
p1[2] = cosf( a );
- m3x3_mulv( localplayer.basis, p1, p1 );
v3_add( localplayer.rb.co, p1, p1 );
vg_line( localplayer.rb.co, p1, VG__PINK );
-
int walk_phase = 0;
if( vg_fractf(w->state.walk_timer) > 0.5f )
walk_phase = 1;
}
q_axis_angle( animator->root_q, (v3f){0.0f,1.0f,0.0f}, walk_yaw + VG_PIf );
- q_mul( localplayer.qbasis, animator->root_q, animator->root_q );
- q_normalize( animator->root_q );
}
static void player__walk_pose( void *_animator, player_pose *pose ){
v3f fwd = { 0.0f, 0.0f, 1.0f };
q_mulv( localplayer.rb.q, fwd, fwd );
- m3x3_mulv( localplayer.invbasis, fwd, fwd );
-
q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f},
atan2f(fwd[0], fwd[2]) );
- q_mul( localplayer.qbasis, localplayer.rb.q, localplayer.rb.q );
- q_normalize( localplayer.rb.q );
rb_update_transform( &localplayer.rb );
}
camera_update_transform( &skaterift.cam );
+#if 0
if( skaterift.activity != k_skaterift_respawning ){
if( localplayer.gate_waiting ){
m3x3_mul( localplayer.basis_gate, skaterift.cam.transform,
skaterift.cam.transform );
}
}
+#endif
camera_update_view( &skaterift.cam );
camera_update_projection( &skaterift.cam );
float dist = v3_length( basevector );
v3f baseangles;
- player_vector_angles( baseangles, basevector, 1.0f, 0.0f );
+ v3_angles( basevector, baseangles );
v2_add( workshop_form.view_angles, baseangles, cam.angles );
cam.angles[2] = 0.0f;
v3f dir = {0.0f,-1.0f,0.0f};
mdl_transform_vector( &cam->transform, dir, dir );
- m3x3_mulv( localplayer.invbasis, dir, dir );
- player_vector_angles( world_static.focus_cam.angles, dir, 1.0f, 0.0f );
+ v3_angles( dir, world_static.focus_cam.angles );
v3_copy( cam->transform.co, world_static.focus_cam.pos );
world_static.focus_cam.fov = cam->fov;
}