fork/training-mode-ce
git clone https://git.julia.blue/fork/training-mode-ce
1da5d99
master
1#ifndef MEX_H_COLLISION 2#define MEX_H_COLLISION 3 4#include "structs.h" 5#include "datatypes.h" 6#include "obj.h" 7 8// ECB Flags 9#define ECB_GROUND 0x18000 10#define ECB_CEIL 0x6000 11#define ECB_WALLLEFT 0xfc0 12#define ECB_WALLRIGHT 0x3f 13 14// Line Directions 15#define LINE_GROUND 1 16#define LINE_CEIL 2 17#define LINE_WALLRIGHT 4 18#define LINE_WALLLEFT 8 19 20/*** Enums ***/ 21enum LineDirection 22{ 23LINEDIR_GROUND = 1 <<0 , 24LINEDIR_CEIL = 1 <<1 , 25LINEDIR_LEFTWALL = 1 <<2 , 26LINEDIR_RIGHTWALL = 1 <<3 , 27}; 28 29/*** Structs ***/ 30 31struct ECBSize 32{ 33float topY ; 34float botY ; 35Vec2 left ; 36Vec2 right ; 37}; 38 39struct CollData 40{ 41GOBJ * gobj ;// 0x0 42Vec3 topN_Curr ;// 0x4 43Vec3 topN_CurrCorrect ;// 0x10 44Vec3 topN_Prev ;// 0x1c 45Vec3 topN_Proj ;// 0x28 46int flags1 ;// 0x34 47int coll_test ;// 0x38, is the ID of the most recent collision test for this object 48int ignore_line ;// 0x3c, ignores this line ID during collision 49int ledge_left ;// 0x40, ledge ID in contact with 50int ledge_right ;// 0x44, ledge ID in contact with 51int ignore_group ;// 0x48 ignores this line group during collision 52int check_group ;// 0x4c checks only this line group during collision 53float weight ;// 0x50 54float cliffgrab_width ;// 0x54 55float cliffgrab_y_offset ;// 0x58 56float cliffgrab_height ;// 0x5c 57int x60 ;// 0x60 58int x64 ;// 0x64 59int x68 ;// 0x68 60int x6c ;// 0x6c 61int x70 ;// 0x70 62int x74 ;// 0x74 63int x78 ;// 0x78 64int x7c ;// 0x7c 65int x80 ;// 0x80 66Vec2 ecbCurr_top ;// 0x84 67Vec2 ecbCurr_bot ;// 0x8C 68Vec2 ecbCurr_right ;// 0x94 69Vec2 ecbCurr_left ;// 0x9C 70Vec2 ecbCurrCorrect_top ;// 0xA4 71Vec2 ecbCurrCorrect_bot ;// 0xAC 72Vec2 ecbCurrCorrect_right ;// 0xB4 73Vec2 ecbCurrCorrect_left ;// 0xBC 74Vec2 ecbPrev_top ;// 0xC4 75Vec2 ecbPrev_bot ;// 0xCC 76Vec2 ecbPrev_right ;// 0xD4 77Vec2 ecbPrev_left ;// 0xDC 78Vec2 ecbProj_top ;// 0xE4 79Vec2 ecbProj_bot ;// 0xEC 80Vec2 ecbProj_right ;// 0xF4 81Vec2 ecbProj_left ;// 0xFC 82int is_use_joints ;// 0x104, bool that signals to use the jobjs below for ecb edge positions 83JOBJ * joint_1 ;// 0x108 84JOBJ * joint_2 ;// 0x10c 85JOBJ * joint_3 ;// 0x110 86JOBJ * joint_4 ;// 0x114 87JOBJ * joint_5 ;// 0x118 88JOBJ * joint_6 ;// 0x11c 89JOBJ * joint_7 ;// 0x120 90int x124 ;// 0x124 91int x128 ;// 0x128 92int x12c ;// 0x12c 93int flags ;// 0x130, for fighters 0x10 is ecb lock enabled 94int envFlags ;// 0x134 95int envFlags_prev ;// 0x138 96int x13c ;// 0x13c 97Vec2 coll_pos ;// 0x140, only updates for ceiling and ground? 98int x148 ;// 0x148 99int ground_index ;// 0x14c, ground 100u8 ground_info ;// 0x150 101u8 ground_unk ;// 0x151 102u8 ground_type ;// 0x152, platform/ledgegrab 103u8 ground_mat ;// 0x153, grass/ice etc 104Vec3 ground_slope ;// 0x154 105int rightwall_index ;// 0x160 106u8 rightwall_info ;// 0x164 107u8 rightwall_unk ;// 0x165 108u8 rightwall_type ;// 0x166, platform/ledgegrab 109u8 rightwall_mat ;// 0x167, grass/ice etc 110Vec3 rightwall_slope ;// 0x168 111int leftwall_index ;// 0x174 112u8 leftwall_info ;// 0x178 113u8 leftwall_unk ;// 0x179 114u8 leftwall_type ;// 0x17A, platform/ledgegrab 115u8 leftwall_mat ;// 0x17B, grass/ice etc 116Vec3 leftwall_slope ;// 0x17C 117int ceil_index ;// 0x188 118u8 ceil_info ;// 0x18C 119u8 ceil_unk ;// 0x18D 120u8 ceil_type ;// 0x18E, platform/ledgegrab 121u8 ceil_mat ;// 0x18F, grass/ice etc 122Vec3 ceil_slope ;// 0x190 123union // 0x19c, 124 {// 125int ecb_bot_lock_frames ;// fighters use this. frames until ecb bottom offset is no longer locked 126 }u ;// 127}; 128 129struct CollGroupDesc // exists in stage file 130{ 131u16 floor_start ;// 0x0 132u16 floor_num ; 133u16 ceil_start ;// 0x4 134u16 ceil_num ; 135u16 rwall_start ;// 0x8 136u16 rwall_num ; 137u16 lwall_start ;// 0xC 138u16 lwall_num ; 139u16 dyn_start ;// 0x10 140u16 dyn_num ; 141Vec2 area_min ;// 0x14 142Vec2 area_max ;// 0x1C 143u16 vert_start ;// 0x24 144u16 vert_num ;// 0x26 145}; 146 147struct CollGroup // runtime struct 148{ 149CollGroup * next ;// 0x0 150CollGroupDesc * desc ;// 0x4 151u16 x8 :15 ;// 0x8, unk 152u16 is_enabled :1 ;// 0x8, bit 0x01 153u16 xa ;// unk, padding maybe 154u16 ray_id ;// 0xC, id of the last raycast 155u16 xe ;// 0xE, flags 156Vec2 area_min ;// 0x10 157Vec2 area_max ;// 0x18 158JOBJ * jobj ;// 0x20 159void * cb_floor ;// 0x24 160void * map_data_floor ;// 0x28 161void * cb_ceil ;// 0x2C 162void * map_data_ceil ;// 0x30 163}; 164 165struct CollLineDesc // exists in stage file 166{ 167s16 vert_prev ;// 0x0 168s16 vert_next ;// 0x2 169s16 line_prev ;// 0x4 170s16 line_next ;// 0x6 171s16 line_prev_altgroup ;// 0x8 172s16 line_next_altgroup ;// 0xA 173u8 xc ; 174u8 xd_1 :1 ;// 0xD, 0x80 175u8 xd_2 :1 ;// 0xD, 0x40 176u8 xd_3 :1 ;// 0xD, 0x20 177u8 disabled :1 ;// 0xD, 0x10 178u8 is_left :1 ;// 0xD, 0x08 179u8 is_right :1 ;// 0xD, 0x04 180u8 is_ceil :1 ;// 0xD, 0x02 181u8 is_floor :1 ;// 0xD, 0x01 182u8 xe_1 :1 ;// 0xE, 0x80 183u8 xe_2 :1 ;// 0xE, 0x40 184u8 xe_3 :1 ;// 0xE, 0x20 185u8 xe_4 :1 ;// 0xE, 0x10 186u8 xe_5 :1 ;// 0xE, 0x08 187u8 is_drop :1 ;// 0xE, 0x04 188u8 is_ledge :1 ;// 0xE, 0x02 189u8 is_unk :1 ;// 0xE, 0x01 190u8 material ;// 0xF, 191}; 192 193struct CollLine // runtime struct 194{ 195CollLineDesc * desc ;// 0x0, (previously info) 196u8 x4 ;// 0x4 197u8 x5_x80 :1 ;// 0x5, 0x80 198u8 x5_x40 :1 ;// 0x5, 0x40 199u8 x5_x20 :1 ;// 0x5, 0x20 200u8 x5_x10 :1 ;// 0x5, 0x10 201u8 x5_x08 :1 ;// 0x5, 0x08 202u8 x5_x04 :1 ;// 0x5, 0x04 203u8 x5_x02 :1 ;// 0x5, 0x02 204u8 is_enabled :1 ;// 0x5, 0x01 205u8 x6 ;// 0x6 206u8 x7 :4 ;// 0x7 207u8 is_rwall :1 ;// 0x7, 0x8 208u8 is_lwall :1 ;// 0x7, 0x4 209u8 is_ceil :1 ;// 0x7, 0x2 210u8 is_floor :1 ;// 0x7, 0x1 211}; 212 213struct CollVert 214{ 215Vec2 pos_orig ; 216Vec2 pos_curr ; 217Vec2 pos_prev ; 218}; 219 220struct CollLineUnk 221{ 222int x0 ; 223s16 x4 ; 224s16 x6 ; 225Vec3 left ;// 0x8 226Vec3 right ;// 0x14 227}; 228 229struct CollDataStage 230{ 231Vec2 * verts ;// 0x0, array of vec2's 232int vert_num ;// 0x4 233CollLineDesc * lines ;// 0x8, array of line descs 234int line_num ;// 0xC 235u16 floor_start ;// 0x10 236u16 floor_num ;// 0x12 237u16 ceil_start ;// 0x14 238u16 ceil_num ;// 0x16 239u16 rwall_start ;// 0x18 240u16 rwall_num ;// 0x1a 241u16 lwall_start ;// 0x1c 242u16 lwall_num ;// 0x1e 243u16 dyn_start ;// 0x20 244u16 dyn_num ;// 0x22 245CollGroupDesc * groups ;// 0x24 246int group_num ;// 0x28 247}; 248 249struct CollLineConnection // runtime struct, is created @ 8005a7cc, static array of these for each line direction @ 80458e88 250{ 251CollLineConnection * next ;// 0x0 252int x4 ;// 0x4 253Vec3 start_pos ;// 0x8 254Vec3 end_pos ;// 0x14 255int x20 ;// 0x20 256int x24 ;// 0x24 257}; 258 259/*** Functions ***/ 260void Shield_CreateBubble (GOBJ * ft ,ShieldDesc * desc ,void * (on_hit )(GOBJ * fighter )); 261void Shield_HitShield (GOBJ * ft ); 262void GuardReflectInitIDK (GOBJ * ft ); 263void GuardOnInitIDK (GOBJ * ft ); 264void Animation_GuardAgain (GOBJ * ft ); 265void EnvironmentCollision_WaitLanding (GOBJ * ft ); 266void Coll_CopyPosToECBs (CollData * coll_data ,Vec3 * pos ); 267void Coll_ECBCurrToPrev (CollData * coll_data ); 268void Coll_InitECB (CollData * coll_data ); 269void Coll_SetECBScale (CollData * coll_data ,float scale1 ,float scale2 ,float scale3 ,float scale4 ); 270int Coll_CheckLedge (CollData * coll_data ); 271float Coll_GetCurrGroundsFrictionMult (CollData * ); 272int ECB_CollGround_PassLedge (CollData * ecb ,ECBSize * bones );// returns is touching ground bool 273int ECB_CollGround3 (CollData * ecb ); 274void ECB_CollAir (CollData * ecb ,ECBSize * bones ); 275int ECB_CollAir2 (CollData * ecb ); 276int ECB_CollAir3 (CollData * ecb ); 277int ECB_CollAirCheckLedge (CollData * ecb ); 278int ECB_CollGround (CollData * ecb ); 279int ECB_StoreLedgeCheckDirection (CollData * ecb ,int ledge_check_dir ); 280int GrColl_SearchLedgeLeft (CollData * coll_data ,int * return_ledge_index ); 281int GrColl_SearchLedgeRight (CollData * coll_data ,int * return_ledge_index ); 282void GrColl_GetGroundLineEndLeft (int floor_index ,Vec3 * pos );// returns the leftmost grounded coordinate of the inputted line index within its group // this functon will crawl along the entire line sequence and find the end of the ledge 283void GrColl_GetGroundLineEndRight (int floor_index ,Vec3 * pos );// returns the rightmost grounded coordinate of the inputted line index within its group 284void GrColl_GetGroundLineEndLeft_AllGroups (int floor_index ,Vec3 * pos );// returns the leftmost grounded coordinate of the inputted line index regardless of the group 285void GrColl_GetGroundLineEndRight_AllGroups (int floor_index ,Vec3 * pos );// returns the rightmost grounded coordinate of the inputted line index regardless of the group 286int GrColl_RaycastGround (Vec3 * coll_pos ,int * line_index ,int * line_kind ,Vec3 * unk1 ,int unk2 ,int unk3 ,int unk4 ,void * cb ,float fromX ,float fromY ,float toX ,float toY ,float unk5 );// make unk5 287int GrColl_RaycastUnk (Vec3 * coll_pos ,int * line_index ,int * line_kind ,Vec3 * direction ,void * cb ,void * unk2 ,float from_x ,float from_y ,float to_x ,float to_y );// unk = 0, unk2 = -1; 288int GrColl_RaycastAll (Vec3 * coll_pos ,int * line_index ,int * line_kind ,Vec3 * direction ,void * cb ,void * unk2 ,float from_x ,float from_y ,float to_x ,float to_y ); 289int GrColl_CrawlGround (int line_index ,Vec3 * pos ,int * return_line ,Vec3 * return_pos ,int * return_flags ,Vec3 * return_slope ,float x_offset ,float y_offset );// returns bool for if position on line series exists 290int GrColl_GetPosDifference (int line_index ,Vec3 * pos ,Vec3 * return_pos ); 291int GrColl_GetLineInfo (int line_index ,Vec3 * r4 ,void * r5 ,int * flags ,Vec3 * return_slope ); 292void GrColl_GetLineSlope (int line_index ,Vec3 * return_slope ); 293int GrColl_CheckIfLineEnabled (int line_index ); 294 295static int * stc_colltest = R13_OFFSET (-0x51F4 ); 296static CollGroup ** stc_firstcollgroup = R13_OFFSET (-0x51DC ); 297static CollGroup ** stc_collgroup = R13_OFFSET (-0x51E0 ); 298static CollLine ** stc_collline = R13_OFFSET (-0x51E4 ); 299static CollVert ** stc_collvert = R13_OFFSET (-0x51E8 ); 300static CollDataStage ** stc_colldata = R13_OFFSET (-0x51EC ); 301static CollLineConnection ** stc_first_line_connect = (void * )0x80458e88 ;// array of 9 302 303#endif