Do actual domain resolution
[carveJwlIkooP6JGAAIwe30JlM.git] / player_drive.c
1 #include "player_drive.h"
2 #include "input.h"
3
4 struct player_drive player_drive;
5 struct player_subsystem_interface player_subsystem_drive =
6 {
7 .pre_update = player__drive_pre_update,
8 .update = player__drive_update,
9 .post_update = player__drive_post_update,
10 .animate = player__drive_animate,
11 .pose = player__drive_pose,
12 .post_animate = player__drive_post_animate,
13 .im_gui = player__drive_im_gui,
14 .bind = player__drive_bind,
15
16 .animator_data = NULL,
17 .animator_size = 0,
18 .name = "Drive"
19 };
20
21 void player__drive_pre_update(void)
22 {
23 drivable_vehicle *vehc = player_drive.vehicle;
24
25 v2f steer;
26 joystick_state( k_srjoystick_steer, steer );
27
28 vehc->steer = vg_lerpf( vehc->steer, steer[0] * 0.4f,
29 vg.time_fixed_delta * 8.0f );
30 vehc->drive = steer[1];
31 }
32
33 void player__drive_update(void){}
34
35 void player__drive_post_update(void)
36 {
37 v3_copy( player_drive.vehicle->rb.co,localplayer.rb.co );
38 v3_copy( player_drive.vehicle->rb.v, localplayer.rb.v );
39 v4_copy( player_drive.vehicle->rb.q, localplayer.rb.q );
40 v3_copy( player_drive.vehicle->rb.w, localplayer.rb.w );
41 }
42
43 void player__drive_animate(void){}
44
45 void player__drive_pose( void *animator, player_pose *pose )
46 {
47 struct skeleton *sk = &localplayer.skeleton;
48
49 skeleton_sample_anim( sk, player_drive.anim_drive, 0.0f, pose->keyframes );
50 v3_copy( localplayer.rb.co, pose->root_co );
51 v4_copy( localplayer.rb.q, pose->root_q );
52 }
53
54 void player__drive_post_animate(void)
55 {
56 if( localplayer.cam_control.camera_mode == k_cam_firstperson )
57 localplayer.cam_velocity_influence = 0.0f;
58 else
59 localplayer.cam_velocity_influence = 1.0f;
60
61 rigidbody *rb = &gzoomer.rb;
62 float yaw = atan2f( -rb->to_world[2][0], rb->to_world[2][2] ),
63 pitch = atan2f
64 (
65 -rb->to_world[2][1],
66 sqrtf
67 (
68 rb->to_world[2][0]*rb->to_world[2][0] +
69 rb->to_world[2][2]*rb->to_world[2][2]
70 )
71 );
72
73 localplayer.angles[0] = yaw;
74 localplayer.angles[1] = pitch;
75 }
76
77 void player__drive_im_gui(void)
78 {
79 player__debugtext( 1, "Nothing here" );
80 }
81
82 void player__drive_bind(void)
83 {
84 struct skeleton *sk = &localplayer.skeleton;
85 player_drive.vehicle = &gzoomer;
86 player_drive.anim_drive = skeleton_get_anim( sk, "idle_cycle+y" );
87 }