1 2 #ifndef PHYSICS_RAGDOLL_H 3 #define PHYSICS_RAGDOLL_H 4 5 #include <stdint.h> 6 7 8 // Joint setup struct is used to parse joint script entry to 9 // actual joint. 10 11 typedef struct rd_joint_setup_s 12 { 13 uint16_t body_index; // Primary body index 14 uint16_t joint_type; // See above as RD_CONSTRAINT_* definitions. 15 16 float body1_offset[3]; // Primary pivot point offset 17 float body2_offset[3]; // Secondary pivot point offset 18 19 float body1_angle[3]; // Primary pivot point angle 20 float body2_angle[3]; // Secondary pivot point angle 21 22 float joint_limit[3]; // Only first two are used for hinge constraint. 23 24 }rd_joint_setup_t, *rd_joint_setup_p; 25 26 27 // Ragdoll body setup is used to modify body properties for ragdoll needs. 28 29 typedef struct rd_body_setup_s 30 { 31 float mass; 32 33 float damping[2]; 34 float restitution; 35 float friction; 36 37 }rd_body_setup_t, *rd_body_setup_p; 38 39 40 // Ragdoll setup struct is an unified structure which contains settings 41 // for ALL joints and bodies of a given ragdoll. 42 43 typedef struct rd_setup_s 44 { 45 uint32_t joint_count; 46 uint32_t body_count; 47 48 float joint_cfm; // Constraint force mixing (joint softness) 49 float joint_erp; // Error reduction parameter (joint "inertia") 50 51 rd_joint_setup_s *joint_setup; 52 rd_body_setup_s *body_setup; 53 54 char *hit_func; // Later to be implemented as hit callback function. 55 }rd_setup_t, *rd_setup_p; 56 57 58 /* Ragdoll interface */ 59 #define RD_CONSTRAINT_POINT 0 60 #define RD_CONSTRAINT_HINGE 1 61 #define RD_CONSTRAINT_CONE 2 62 63 #define RD_DEFAULT_SLEEPING_THRESHOLD 10.0 64 65 66 struct rd_setup_s *Ragdoll_GetSetup(struct lua_State *lua, int stack_pos); 67 void Ragdoll_DeleteSetup(struct rd_setup_s *setup); 68 69 #endif /* PHYSICS_RAGDOLL_H */ 70