seperate gamestate and animator memory (BREAKS: SMOOTHED UPPER YAW)
[carveJwlIkooP6JGAAIwe30JlM.git] / player_drive.c
1 #ifndef PLAYER_DRIVE_C
2 #define PLAYER_DRIVE_C
3
4 #include "player.h"
5 #include "input.h"
6
7 VG_STATIC void player__drive_pre_update( player_instance *player )
8 {
9 struct player_drive *drive = &player->_drive;
10 drivable_vehicle *vehc = drive->vehicle;
11
12 v2f steer;
13 joystick_state( k_srjoystick_steer, steer );
14
15 vehc->steer = vg_lerpf( vehc->steer, steer[0] * 0.4f, k_rb_delta * 8.0f );
16 vehc->drive = steer[1];
17 }
18
19 VG_STATIC void player__drive_update( player_instance *player )
20 {
21 }
22
23 VG_STATIC void player__drive_post_update( player_instance *player )
24 {
25 struct player_drive *drive = &player->_drive;
26 v3_copy( drive->vehicle->obj.rb.co, player->rb.co );
27 v3_copy( drive->vehicle->obj.rb.v, player->rb.v );
28 v4_copy( drive->vehicle->obj.rb.q, player->rb.q );
29 v3_copy( drive->vehicle->obj.rb.w, player->rb.w );
30 }
31
32 VG_STATIC void player__drive_animate( player_instance *player ){}
33
34 VG_STATIC void player__drive_pose( player_instance *player ){
35 struct player_drive *drive = &player->_drive;
36 struct skeleton *sk = &player->playeravatar->sk;
37 player_pose *pose = &player->pose;
38
39 skeleton_sample_anim( sk, drive->anim_drive, 0.0f, pose->keyframes );
40 v3_copy( player->rb.co, pose->root_co );
41 v4_copy( player->rb.q, pose->root_q );
42 }
43
44 VG_STATIC void player__drive_post_animate( player_instance *player )
45 {
46 if( player->cam_control.camera_mode == k_cam_firstperson )
47 player->cam_velocity_influence = 0.0f;
48 else
49 player->cam_velocity_influence = 1.0f;
50
51 rigidbody *rb = &gzoomer.obj.rb;
52 float yaw = atan2f( -rb->to_world[2][0], rb->to_world[2][2] ),
53 pitch = atan2f
54 (
55 -rb->to_world[2][1],
56 sqrtf
57 (
58 rb->to_world[2][0]*rb->to_world[2][0] +
59 rb->to_world[2][2]*rb->to_world[2][2]
60 )
61 );
62
63 player->angles[0] = yaw;
64 player->angles[1] = pitch;
65 }
66
67 VG_STATIC void player__drive_im_gui( player_instance *player )
68 {
69 player__debugtext( 1, "Nothing here" );
70 }
71
72 VG_STATIC void player__drive_bind( player_instance *player )
73 {
74 struct player_drive *drive = &player->_drive;
75 struct player_avatar *av = player->playeravatar;
76 struct skeleton *sk = &av->sk;
77
78 drive->vehicle = &gzoomer;
79 drive->anim_drive = skeleton_get_anim( sk, "idle_cycle+y" );
80 }
81
82 VG_STATIC void player__drive_reset( player_instance *player, ent_spawn *rp )
83 {
84 }
85
86 #endif /* PLAYER_DRIVE_C */