small refactor of model loading
[carveJwlIkooP6JGAAIwe30JlM.git] / player_ragdoll.h
1 #pragma once
2
3 /*
4 * Copyright (C) 2021-2024 Mt.ZERO Software - All Rights Reserved
5 *
6 * Ragdoll system
7 */
8
9 #include "player_api.h"
10 #include "skeleton.h"
11 #include "vg/vg_rigidbody.h"
12 #include "vg/vg_rigidbody_constraints.h"
13
14 struct player_ragdoll{
15 struct ragdoll_part{
16 u32 bone_id;
17
18 /* Collider transform relative to bone */
19 m4x3f collider_mtx,
20 inv_collider_mtx;
21
22 v4f prev_q;
23 v3f prev_co;
24
25 u32 use_limits;
26 v3f limits[2];
27
28 u32 parent;
29 u32 colour;
30
31 rigidbody rb;
32 enum bone_collider type;
33
34 union {
35 rb_capsule capsule;
36 boxf box;
37 }
38 inf;
39 }
40 parts[32];
41 u32 part_count;
42
43 rb_constr_pos position_constraints[32];
44 u32 position_constraints_count;
45
46 rb_constr_swingtwist cone_constraints[32];
47 u32 cone_constraints_count;
48
49 /* TODO: Fix duplicated data */
50 u32 constraint_associations[32][2];
51 int shoes[2];
52 };
53
54 enum player_die_type {
55 k_player_die_type_generic,
56 k_player_die_type_head,
57 k_player_die_type_feet
58 };
59
60 void player_ragdoll_init(void);
61 void player_init_ragdoll_bone_collider( struct skeleton_bone *bone,
62 struct ragdoll_part *rp );
63 u32 ragdoll_bone_parent( struct player_ragdoll *rd, u32 bone_id );
64 void setup_ragdoll_from_skeleton( struct skeleton *sk,
65 struct player_ragdoll *rd );
66 void copy_ragdoll_pose_to_localplayer( struct player_ragdoll *rd );
67 void copy_localplayer_to_ragdoll( struct player_ragdoll *rd,
68 enum player_die_type type );
69
70 void player_debug_ragdoll(void);
71 void player_ragdoll_iter( struct player_ragdoll *rd );