From 15af665eac26f9a29b864617d571ef539a6c42b0 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sun, 2 Dec 2012 02:33:34 +0100 Subject: collisionMgr_c updated --- include/game.h | 302 +++++++++++++++++++++++++++++++++++++----------- kamek_pal.x | 14 +-- src/bossBombDrop.cpp | 18 +-- src/bossKoopaThrow.cpp | 18 +-- src/bossMegaGoomba.cpp | 13 +-- src/bossPlayerClown.cpp | 12 +- src/bossSamurshai.cpp | 34 +++--- src/bossThwompaDomp.cpp | 29 ++--- src/bossTopman.cpp | 34 +++--- src/bossWrenchThrow.cpp | 28 ++--- src/penguin.cpp | 34 +++--- src/shyguy.cpp | 36 +++--- src/topman.cpp | 35 +++--- 13 files changed, 390 insertions(+), 217 deletions(-) diff --git a/include/game.h b/include/game.h index 8afb80b..f907004 100755 --- a/include/game.h +++ b/include/game.h @@ -1635,72 +1635,244 @@ public: class dStageActor_c; // forward declaration + +enum SensorFlags { + SENSOR_POINT = 0, + SENSOR_LINE = 1, + + SENSOR_TYPE_MASK = 1, + SENSOR_2 = 2, // has not shown up yet...? + SENSOR_IGNORE_SIMPLE_COLL = 4, + SENSOR_8 = 8, // can enter pipe? + SENSOR_10 = 0x10, // Related to ice + SENSOR_20 = 0x20, // related to ice, too + SENSOR_40 = 0x40, // checked by simplecollider + SENSOR_80 = 0x80, // checked by simplecollider + SENSOR_100 = 0x100, // checked by simplecollider + SENSOR_200 = 0x200, // checked by simplecollider + SENSOR_400 = 0x400, // checked by simplecollider + SENSOR_800 = 0x800, // checked by simplecollider + SENSOR_NO_QUICKSAND = 0x1000, + SENSOR_2000 = 0x2000, // something to do with fences maybe? + SENSOR_BREAK_BLOCK = 0x4000, + SENSOR_8000 = 0x8000, // used + SENSOR_10000 = 0x10000, // used + SENSOR_COIN_1 = 0x20000, + SENSOR_COIN_2 = 0x40000, + SENSOR_COIN_OUTLINE = 0x80000, + SENSOR_ACTIVATE_QUESTION = 0x100000, + SENSOR_ACTIVATE_DONUTS = 0x200000, + SENSOR_HIT_BRICK = 0x400000, + SENSOR_BREAK_BRICK = 0x800000, + SENSOR_HIT_OR_BREAK_BRICK = 0xC00000, + SENSOR_1000000 = 0x1000000, // has not shown up yet...? + SENSOR_2000000 = 0x2000000, // corresponds to SCF_400? + SENSOR_4000000 = 0x4000000, // something related to hitting blocks + SENSOR_8000000 = 0x8000000, // corresponds to SCF_20? + SENSOR_10000000 = 0x10000000, // used + SENSOR_20000000 = 0x20000000, // used + SENSOR_40000000 = 0x40000000, // used + SENSOR_80000000 = 0x80000000, // used +}; + +// Output is split into... +// Above : +// FC000000: 11111100000000000000000000000000 +// Below : +// 3FFE000: 11111111111110000000000000 +// 1FE000: 111111110000000000000 +// 18000: 11000000000000000 +// Adjacent: +// 1FFF: 1111111111111 + +enum SensorOutputFlags { + CSOUT_ABOVE_ALL = 0xFC000000, + CSOUT_BELOW_ALL = 0x3FFE000, + CSOUT_ADJACENT_ALL = 0x1FFF, +}; + +// 0x8000 : Has object from Class 2DC? +// 0x4000 : Has slope from Class 2DC? + +struct hLine_s { + float x1, x2, y; +}; +struct vLine_s { + float x, y1, y2; +}; + +struct pointSensor_s; +struct lineSensor_s; +struct sensorBase_s { + u32 flags; + inline pointSensor_s *asPoint() const { + return (pointSensor_s*)this; + } + inline lineSensor_s *asLine() const { + return (lineSensor_s*)this; + } +}; +struct pointSensor_s : sensorBase_s { + inline pointSensor_s() { } + inline pointSensor_s(s32 _x, s32 _y) { + x = _x; y = _y; + } + inline pointSensor_s(u32 _flags, s32 _x, s32 _y) { + flags = _flags | SENSOR_POINT; + x = _x; y = _y; + } + s32 x, y; +}; +struct lineSensor_s : sensorBase_s { + inline lineSensor_s() { } + inline lineSensor_s(s32 _a, s32 _b, s32 _d) { + flags = SENSOR_LINE; + lineA = _a; lineB = _b; + distanceFromCenter = _d; + } + inline lineSensor_s(u32 _flags, s32 _a, s32 _b, s32 _d) { + flags = _flags | SENSOR_LINE; + lineA = _a; lineB = _b; + distanceFromCenter = _d; + } + s32 lineA, lineB, distanceFromCenter; +}; + class collisionMgr_c { -public: - collisionMgr_c(); - virtual ~collisionMgr_c(); - - //FIXME params and returns and add more - void Clear1(); - void Clear2(); - void Init(dStageActor_c*,const u8*,const u8*,const u8*); - - void Clear3(); - bool CollidedWithTile(); - int SomethingSemiImportant(u32); - u32 execute(); - - u32 s_8006FA40(void *); - u32 s_80070760(); - bool s_800707E0(); - - dStageActor_c* owner; - void* struct1_ptr; - void* struct2_ptr; - void* some_ptr; - Vec3* parent_pos_ptr; - Vec3* parent_last_pos_ptr; - Vec3* parent_speed_ptr; - Vec3 someVelocityThing; - float xDeltaMaybe; - float yDeltaMaybe; - u8 _34[24]; //FIXME - float someFloat; - void* class2DC_ptr; //FIXME - void* another_ptr; - void* ptr_to_ptr_to_underneath_actor; - u8 _5C[44]; //FIXME - u32 bitfield_for_checks; - u32 bitfield_backup; - u32 _90, _94; - u8 which_player_of_parent; - u8 which_controller; - u16 _9A, _9C; - u8 _9E[2]; //FIXME - u32 another_bitfield; - u8 _A4; - u8 _A5[3]; //FIXME - u32 yet_another_bitfield; - u8 _AC; - u8 _AD[3]; //FIXME - u32 directional_bitfields[2]; // left right - u8 flagsB8; - u8 flagsB9; - u8 _BA[2]; //FIXME - u8 _BC, _BD; - u16 _BE; - u8 _C0, _C1; - u16 _C2; - u8 _C4[4]; //FIXME - u16 _C8; - u8 _CA[22]; //FIXME - u8 _E0, _E1, _E2; - u8 _E3; //FIXME - u8 _E4, _E5; - u8 _E6[2]; //FIXME - u32 current_layer_ptr; - u8 current_layer; - u8 _ED[3]; //FIXME + public: + collisionMgr_c(); + virtual ~collisionMgr_c(); + + dStageActor_c *owner; + sensorBase_s *pBelowInfo, *pAboveInfo, *pAdjacentInfo; + + VEC3 *pPos, *pLastPos, *pSpeed; + VEC3 specialSpeedOffset; + float xDeltaMaybe, yDeltaMaybe; + float _34, _38; + u32 _3C, _40, _44, _48; + float initialXAsSetByJumpDai; + /*dClass2DC_c*/void *pClass2DC; + u32 _54; + Physics *sCollBelow; + Physics *sCollAbove; + Physics *sCollAdjacentLast, *sCollAdjacent[2]; + collisionMgr_c *_6C, *_70, *_74; + collisionMgr_c *_78[2]; + Physics *_80[2]; + u32 outputMaybe; + u32 _8C; + u32 someStoredBehaviourFlags, someStoredProps; + char whichPlayerOfParent____; + char whichController____; + u16 _9A, _9C; + u32 tileBelowProps; + u8 tileBelowSubType, lastTileBelowSubType; + u32 tileAboveProps; + u8 tileAboveSubType, lastTileAboveSubType; + u32 adjacentTileProps[2]; + u8 adjacentTileSubType[2]; + u8 _BA, _BB; + u8 _BC; // &8 makes able to enter mini pipes? + u8 currentSlopeType; + s16 currentSlopeAngle; + u8 currentFlippedSlopeType; + s16 currentFlippedSlopeAngle; + u32 _C4; + u16 currentAdjacentSlopeAngle; + u32 currentFenceType; // 0=null 1=ladder 2=fence + Physics *_D0; + float _D4; + float _D8; + float _DC; + u8 touchedSpikeFlag; + s8 maxTouchedSpikeType; + u8 currentSlopeDirection, _E3, onGround_maybe, chainlinkMode; + u8 *pLayerID; + u8 layer; + bool enteredPipeIsMini; + + // Setup + void clear1(); + void clear2(); + void init(dStageActor_c *owner, const sensorBase_s *belowInfo, const sensorBase_s *aboveInfo, const sensorBase_s *adjacentInfo); + + u32 calculateBelowCollision(); + u32 calculateAboveCollision(u32 value); + u32 calculateAdjacentCollision(float *pFloat=0); + + bool setBelowSubType(u32 magic); // maybe not public? + + u8 getBelowSubType(); + u8 getAboveSubType(); + u8 getAdjacentSubType(int direction); + + int returnSomethingBasedOnSlopeAngle(); + bool doesSlopeGoUp(); + + int getSlopeYDirectionForXDirection(int direction); + int getSlopeYDirectionForXDirection(int direction, int slopeType); + s16 getAngleOfSlopeInDirection(int direction); + s16 getAngleOfSlopeWithXSpeed(float xSpeed); + s16 getAngleOfSlopeInDirection2(int thing); + s16 getAngleOfFlippedSlopeInDirection(int thing); + s16 getAngleOfFlippedSlopeInDirection2(int thing); + + static bool checkPositionForTileOrSColl(float x, float y, u8 layer, u32 unk, u32 mask); + static int getPartialBlockExistenceAtPos(float x, float y, u8 layer); + static bool isPartialBlockOrBlockSolidAtPos(float x, float y, u8 layer); + static u32 getTileBehaviour1At(float x, float y, u8 layer); + static u32 getTileBehaviour2At(float x, float y, u8 layer); + static u32 getTileBehaviour1At(u16 x, u16 y, u8 layer); + static u32 getTileBehaviour2At(u16 x, u16 y, u8 layer); + + u8 getOwnerStageActorType() const; + u32 returnOutputAnd18000() const; + bool isOnTopOfTile() const; + + u32 s_80071210(dStageActor_c *player); + bool tryToEnterPipeBelow(VEC3 *pOutVec, int *pOutEntranceID); + bool tryToEnterPipeAbove(VEC3 *pOutVec, int *pOutEntranceID); + bool tryToEnterAdjacentPipe(VEC3 *pOutVec, int unk, int *pOutEntranceID, float fp1, float fp2); + u32 detectFence(lineSensor_s *info); + bool detectClimbingPole(lineSensor_s *info); + + bool s_80072440(VEC2 *v2one, VEC2 *v2two, float *pOutFloat); + bool s_800728C0(VEC2 *vecParam, float *pOutFloat); + + u32 calculateBelowCollisionWithSmokeEffect(); + + u32 calculateAdjacentCollisionAlternate(float *pFloat=0); + + static void setupEverything(int wrapType); + + bool getBelowSensorHLine(hLine_s *outLine); + bool getAboveSensorHLine(hLine_s *outLine); + bool getAdjacentSensorVLine(vLine_s *outLine, int direction); + + void s_800731E0(Physics *sColl, VEC3 *somePos); + + void clearStoredSColls(); + void s_80075090(); + bool s_800751C0(Physics *sColl, collisionMgr_c *what); + collisionMgr_c *s_80075230(Physics *sColl); + + static int checkPositionForLiquids(float x, float y, int layer, float *unkDestFloat = 0); + static int s_80075560(float x, float y, int layer, float *destFloat); + static bool s_80075750(VEC2 *pVec); + static bool s_80075780(s16 *pAngle); + + enum SlopeTypes { + SLOPE_EDGE = 10, + SLOPE_TYPE_COUNT = 19 + }; + struct slopeParams_s { + float basePos, colHeight; + }; + static const slopeParams_s slopeParams[SLOPE_TYPE_COUNT]; + static const slopeParams_s flippedSlopeParams[SLOPE_TYPE_COUNT]; + static const u8 slopeKinds[SLOPE_TYPE_COUNT]; + static const u8 slopeDirections[SLOPE_TYPE_COUNT]; }; class BasicCollider { diff --git a/kamek_pal.x b/kamek_pal.x index bfe01d5..e3c6bbb 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -330,14 +330,14 @@ SECTIONS { /* collisionMgr_c */ __ct__14collisionMgr_c = 0x8006cf40; __dt__14collisionMgr_c = 0x8006cf40; - Clear1__14collisionMgr_cFv = 0x8006cfe0; - Clear2__14collisionMgr_cFv = 0x8006d000; - Init__14collisionMgr_cFP13dStageActor_cPCUcPCUcPCUc = 0x8006d090; + clear1__14collisionMgr_cFv = 0x8006cfe0; + clear2__14collisionMgr_cFv = 0x8006d000; + init__14collisionMgr_cFP13dStageActor_cPC12sensorBase_sPC12sensorBase_sPC12sensorBase_s = 0x8006d090; Clear3__14collisionMgr_cFv = 0x8006d440; - CollidedWithTile__14collisionMgr_cFv = 0x80070cb0; - SomethingSemiImportant__14collisionMgr_cFUi = 0x8006ef40; - execute__14collisionMgr_cFv = 0x80072bc0; - s_8006FA40__14collisionMgr_cFPv = 0x8006FA40; + isOnTopOfTile__14collisionMgr_cCFv = 0x80070cb0; + calculateAboveCollision__14collisionMgr_cFUi = 0x8006ef40; + calculateBelowCollisionWithSmokeEffect__14collisionMgr_cFv = 0x80072bc0; + calculateAdjacentCollision__14collisionMgr_cFPf = 0x8006FA40; s_80070760__14collisionMgr_cFv = 0x80070760; s_800707E0__14collisionMgr_cFv = 0x800707E0; diff --git a/src/bossBombDrop.cpp b/src/bossBombDrop.cpp index c12d144..da12c34 100644 --- a/src/bossBombDrop.cpp +++ b/src/bossBombDrop.cpp @@ -103,14 +103,14 @@ int dDroppedBomb::onCreate() { _324 = 20.f; // These structs tell stupid collider what to collide with - these are from koopa troopa - static const u8 one[16] = {0,0,0,1, 0,0,0xC0,0, 0,0,0x40,0, 0,0,0,0}; - static const u8 two[12] = {0,0,0,0, 0,0,0,0, 0,0,0xC0,0}; - static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0x60,0}; + static const lineSensor_s below(12<<12, 4<<12, 0<<12); + static const pointSensor_s above(0<<12, 12<<12); + static const lineSensor_s adjacent(6<<12, 9<<12, 6<<12); - collMgr.Init(this, one, two, three); - collMgr.execute(); + collMgr.init(this, &below, &above, &adjacent); + collMgr.calculateBelowCollisionWithSmokeEffect(); - cmgr_returnValue = collMgr.CollidedWithTile(); + cmgr_returnValue = collMgr.isOnTopOfTile(); pos.z = 3300.0; @@ -161,10 +161,10 @@ int dDroppedBomb::onExecute() { HandleYSpeed(); doSpriteMovement(); - cmgr_returnValue = collMgr.CollidedWithTile(); - collMgr.execute(); + cmgr_returnValue = collMgr.isOnTopOfTile(); + collMgr.calculateBelowCollisionWithSmokeEffect(); - if (collMgr.CollidedWithTile() || (collMgr.bitfield_for_checks & (0x15 << direction))) { + if (collMgr.isOnTopOfTile() || (collMgr.outputMaybe & (0x15 << direction))) { this->kill(); } diff --git a/src/bossKoopaThrow.cpp b/src/bossKoopaThrow.cpp index 85c96ca..3efcc82 100644 --- a/src/bossKoopaThrow.cpp +++ b/src/bossKoopaThrow.cpp @@ -207,14 +207,14 @@ int daKoopaThrow::onCreate() { _324 = currentInfo->size; // These structs tell stupid collider what to collide with - these are from koopa troopa - static const u8 one[16] = {0,0,0,1, 0,0,0xC0,0, 0,0,0x40,0, 0,0,0,0}; - static const u8 two[12] = {0,0,0,0, 0,0,0,0, 0,0,0xC0,0}; - static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0x60,0}; + static const lineSensor_s below(12<<12, 4<<12, 0<<12); + static const pointSensor_s above(0<<12, 12<<12); + static const lineSensor_s adjacent(6<<12, 9<<12, 6<<12); - collMgr.Init(this, one, two, three); - collMgr.execute(); + collMgr.init(this, &below, &above, &adjacent); + collMgr.calculateBelowCollisionWithSmokeEffect(); - cmgr_returnValue = collMgr.CollidedWithTile(); + cmgr_returnValue = collMgr.isOnTopOfTile(); if (this->direction == 0) { // Ground Facing Left @@ -297,10 +297,10 @@ void daKoopaThrow::executeState_Straight() { HandleYSpeed(); doSpriteMovement(); - // cmgr_returnValue = collMgr.CollidedWithTile(); - // collMgr.execute(); + // cmgr_returnValue = collMgr.isOnTopOfTile(); + // collMgr.calculateBelowCollisionWithSmokeEffect(); - // if (collMgr.CollidedWithTile() || (collMgr.bitfield_for_checks & (0x15 << direction))) { + // if (collMgr.isOnTopOfTile() || (collMgr.outputMaybe & (0x15 << direction))) { // // hit the ground or wall // PlaySoundAsync(this, currentInfo->breakSound); diff --git a/src/bossMegaGoomba.cpp b/src/bossMegaGoomba.cpp index a6758f4..0214f60 100644 --- a/src/bossMegaGoomba.cpp +++ b/src/bossMegaGoomba.cpp @@ -127,9 +127,6 @@ class daMegaGoomba_c : public dEn_c { // DECLARE_STATE(Outro); }; -u8 struct_1[] = { 0, 0, 0, 1, 0xff, 0xff, 0x40, 0, 0, 0, 0xc0, 0, 0, 0, 0, 0 }; -u8 struct_3[] = { 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0x3f, 0x2a, 0x7e, 0xfa }; - // last 4 bytes not needed. float for scale daMegaGoomba_c *daMegaGoomba_c::build() { void *buffer = AllocFromGameHeap1(sizeof(daMegaGoomba_c)); @@ -316,7 +313,9 @@ void daMegaGoomba_c::setupCollision() { //POINTLESS WITH GROWTH this->scale.x = this->scale.y = this->scale.z = 0.666; - this->collMgr.Init(this, struct_1, 0, struct_3); + static const lineSensor_s below(-12 << 12, 12 << 12, 0); + static const pointSensor_s adjacent(16 << 12, 16 << 12); + this->collMgr.init(this, &below, 0, &adjacent); char foo = this->_391; this->pos_delta2.x = 0.0; @@ -696,13 +695,13 @@ void daMegaGoomba_c::executeState_Walk() { int ret = SomeStrangeModification(this); if(ret & 1) this->speed.y = 0.0; - u32 bitfield = this->collMgr.bitfield_for_checks; + u32 bitfield = this->collMgr.outputMaybe; if(bitfield & (0x15<direction)) { this->pos.x = this->last_pos.x; this->doStateChange(&StateID_Turn); //this->acState.setField10ToOne(); } - u32 bitfield2 = this->collMgr.directional_bitfields[this->direction]; + u32 bitfield2 = this->collMgr.adjacentTileProps[this->direction]; if(bitfield2) { this->doStateChange(&StateID_Turn); } @@ -783,7 +782,7 @@ void daMegaGoomba_c::stunPlayers() { dStageActor_c *player = GetSpecificPlayerActor(i); if (player) { - if (player->collMgr.CollidedWithTile() && player->currentZoneID == currentZoneID) { + if (player->collMgr.isOnTopOfTile() && player->currentZoneID == currentZoneID) { stunPlayer(player, 1); playerStunned[i] = true; } diff --git a/src/bossPlayerClown.cpp b/src/bossPlayerClown.cpp index 6fccee6..c760214 100644 --- a/src/bossPlayerClown.cpp +++ b/src/bossPlayerClown.cpp @@ -213,12 +213,12 @@ int daClownShot::onCreate() { _324 = 0.0f; // These structs tell stupid collider what to collide with - these are from koopa troopa - static const u8 one[16] = {0,0,0,1, 0,0,0xC0,0, 0,0,0x40,0, 0,0,0,0}; - static const u8 two[12] = {0,0,0,0, 0,0,0,0, 0,0,0xC0,0}; - static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0x60,0}; + static const lineSensor_s below(12<<12, 4<<12, 0<<12); + static const pointSensor_s above(0<<12, 12<<12); + static const lineSensor_s adjacent(6<<12, 9<<12, 6<<12); - collMgr.Init(this, one, two, three); - collMgr.execute(); + collMgr.init(this, &below, &above, &adjacent); + collMgr.calculateBelowCollisionWithSmokeEffect(); this->speed.y = 4.0; @@ -246,7 +246,7 @@ int daClownShot::onExecute() { HandleXSpeed(); HandleYSpeed(); doSpriteMovement(); - collMgr.execute(); + collMgr.calculateBelowCollisionWithSmokeEffect(); effect.spawn("Wm_en_killersmoke", 0, &(Vec){pos.x, pos.y, pos.z}, &(S16Vec){0,0,0}, &(Vec){0.7, 0.7, 0.7}); diff --git a/src/bossSamurshai.cpp b/src/bossSamurshai.cpp index 24c8615..9ed5b9a 100644 --- a/src/bossSamurshai.cpp +++ b/src/bossSamurshai.cpp @@ -202,8 +202,8 @@ daSamurshai *daSamurshai::build() { HandleYSpeed(); doSpriteMovement(); - cmgr_returnValue = collMgr.CollidedWithTile(); - collMgr.execute(); + cmgr_returnValue = collMgr.isOnTopOfTile(); + collMgr.calculateBelowCollisionWithSmokeEffect(); if (isBouncing) { stuffRelatingToCollisions(0.1875f, 1.0f, 0.5f); @@ -211,7 +211,7 @@ daSamurshai *daSamurshai::build() { isBouncing = false; } - if (collMgr.CollidedWithTile()) { + if (collMgr.isOnTopOfTile()) { // Walking into a tile branch if (cmgr_returnValue == 0) @@ -223,23 +223,23 @@ daSamurshai *daSamurshai::build() { // Bouncing checks if (_34A & 4) { Vec v = (Vec){0.0f, 1.0f, 0.0f}; - collMgr.parent_speed_ptr = &v; + collMgr.pSpeed = &v; - if (collMgr.SomethingSemiImportant(collMgr.bitfield_for_checks)) + if (collMgr.calculateAboveCollision(collMgr.outputMaybe)) speed.y = 0.0f; - collMgr.parent_speed_ptr = &speed; + collMgr.pSpeed = &speed; } else { - if (collMgr.SomethingSemiImportant(collMgr.bitfield_for_checks)) + if (collMgr.calculateAboveCollision(collMgr.outputMaybe)) speed.y = 0.0f; } - collMgr.s_8006FA40(0); + collMgr.calculateAdjacentCollision(0); // Switch Direction - if (collMgr.bitfield_for_checks & (0x15 << direction)) { - if (collMgr.CollidedWithTile()) { + if (collMgr.outputMaybe & (0x15 << direction)) { + if (collMgr.isOnTopOfTile()) { isBouncing = true; } return true; @@ -316,16 +316,16 @@ int daSamurshai::onCreate() { _324 = 18.0f; // These structs tell stupid collider what to collide with - these are from koopa troopa - static const u8 one[16] = {0,0,0,1, 0,0,0xC0,0, 0,0,0x40,0, 0,0,0,0}; - static const u8 two[12] = {0,0,0,0, 0,0,0,0, 0,0,0xC0,0}; - static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0x60,0}; + static const lineSensor_s below(12<<12, 4<<12, 0<<12); + static const pointSensor_s above(0<<12, 12<<12); + static const lineSensor_s adjacent(6<<12, 9<<12, 6<<12); - collMgr.Init(this, one, two, three); - collMgr.execute(); + collMgr.init(this, &below, &above, &adjacent); + collMgr.calculateBelowCollisionWithSmokeEffect(); - cmgr_returnValue = collMgr.CollidedWithTile(); + cmgr_returnValue = collMgr.isOnTopOfTile(); - if (collMgr.CollidedWithTile()) + if (collMgr.isOnTopOfTile()) isBouncing = false; else isBouncing = true; diff --git a/src/bossThwompaDomp.cpp b/src/bossThwompaDomp.cpp index 860fb90..1d94744 100644 --- a/src/bossThwompaDomp.cpp +++ b/src/bossThwompaDomp.cpp @@ -29,7 +29,7 @@ class daEnMegaDosun_c : public daBoss { m3d::mdl_c bodyModel; // _544 m3d::anmVis_c anmVis; // _584 - u32 collision_struct[4]; // _5BC + lineSensor_s belowSensor; float shakePosXoffset; // _5CC shakePosXoffset u16 puruMoveCounter; // _5D8 u16 shakeIndex; // _5DA 0=shake,1=normal @@ -122,10 +122,12 @@ int daEnMegaDosun_c::onCreate() { this->pos.y -= 21.0; this->pos.z = -280.0; // behind layer1 (hides spikes) - this->collision_struct[0] = 0x11804101; - this->collision_struct[1] = 0xFFFE1000; - this->collision_struct[2] = 0x0001F000; - this->collision_struct[3] = 0x00005000; + belowSensor.flags = + SENSOR_10000000 | SENSOR_1000000 | SENSOR_BREAK_BRICK | + SENSOR_BREAK_BLOCK | SENSOR_100 | SENSOR_LINE; + belowSensor.lineA = -31 << 12; + belowSensor.lineB = 31 << 12; + belowSensor.distanceFromCenter = 5 << 12; ActivePhysics::Info hm; hm.xDistToCenter = 0.0; @@ -140,9 +142,8 @@ int daEnMegaDosun_c::onCreate() { hm.callback = &dEn_c::collisionCallback; this->aPhysics.initWithStruct(this, &hm); - //u8 s3[] = {0,0,0,1,0xff,0xfe,0x10,0,0,1,0xf0,0,0,5,0x50,0}; - u8 s3[] = {0,0,0,1,0xff,0xfe,0x10,0,0,1,0xf0,0,0xff,0xfe,0x10,0}; - this->collMgr.Init(this,(u8*)&this->collision_struct,(u8*)&s3,0); + lineSensor_s aboveSensor(-31 << 12, 31 << 12, -31 << 12); + this->collMgr.init(this, &belowSensor, &aboveSensor, 0); this->pos_delta2.x = 0.0; this->pos_delta2.y = 36.0; @@ -247,7 +248,9 @@ int daEnMegaDosun_c::onDelete() { // StateID_UpWait void daEnMegaDosun_c::beginState_UpWait() { - this->collision_struct[0] = 0x11804101; + belowSensor.flags = + SENSOR_10000000 | SENSOR_1000000 | SENSOR_BREAK_BRICK | + SENSOR_BREAK_BLOCK | SENSOR_100 | SENSOR_LINE; this->timer = 0; } void daEnMegaDosun_c::executeState_UpWait() { @@ -337,7 +340,7 @@ int daEnMegaDosun_c::onDelete() { this->UpdateObjectPosBasedOnSpeedValuesReal(); //FIXME what do I do? - bottom detection - int ret = this->collMgr.execute(); + int ret = this->collMgr.calculateBelowCollisionWithSmokeEffect(); if(!ret) return; @@ -349,10 +352,10 @@ int daEnMegaDosun_c::onDelete() { PlaySoundAsync(this, SE_EMY_BIG_DOSSUN); } else { - this->collision_struct[0] = 0x00000001; + belowSensor.flags = SENSOR_LINE; this->speed.y = 0.0; ShakeScreen(ScreenPositionClass, 0, 1, 0, 0); - this->collMgr.Clear2(); + this->collMgr.clear2(); PlaySoundAsync(this, SE_EMY_BIG_DOSSUN); } @@ -388,7 +391,7 @@ int daEnMegaDosun_c::onDelete() { // StateID_UpMove void daEnMegaDosun_c::beginState_UpMove() { - this->collMgr.Clear2(); + this->collMgr.clear2(); } void daEnMegaDosun_c::executeState_UpMove() { // this->speed.y = 0.0; diff --git a/src/bossTopman.cpp b/src/bossTopman.cpp index d014d57..427682a 100644 --- a/src/bossTopman.cpp +++ b/src/bossTopman.cpp @@ -234,8 +234,8 @@ bool daDreidel::calculateTileCollisions() { HandleYSpeed(); doSpriteMovement(); - cmgr_returnValue = collMgr.CollidedWithTile(); - collMgr.execute(); + cmgr_returnValue = collMgr.isOnTopOfTile(); + collMgr.calculateBelowCollisionWithSmokeEffect(); if (isBouncing) { stuffRelatingToCollisions(0.1875f, 1.0f, 0.5f); @@ -249,7 +249,7 @@ bool daDreidel::calculateTileCollisions() { else direction = 1; - if (collMgr.CollidedWithTile()) { + if (collMgr.isOnTopOfTile()) { // Walking into a tile branch if (cmgr_returnValue == 0) @@ -273,23 +273,23 @@ bool daDreidel::calculateTileCollisions() { // Bouncing checks if (_34A & 4) { Vec v = (Vec){0.0f, 1.0f, 0.0f}; - collMgr.parent_speed_ptr = &v; + collMgr.pSpeed = &v; - if (collMgr.SomethingSemiImportant(collMgr.bitfield_for_checks)) + if (collMgr.calculateAboveCollision(collMgr.outputMaybe)) speed.y = 0.0f; - collMgr.parent_speed_ptr = &speed; + collMgr.pSpeed = &speed; } else { - if (collMgr.SomethingSemiImportant(collMgr.bitfield_for_checks)) + if (collMgr.calculateAboveCollision(collMgr.outputMaybe)) speed.y = 0.0f; } - collMgr.s_8006FA40(0); + collMgr.calculateAdjacentCollision(0); // Switch Direction - if (collMgr.bitfield_for_checks & (0x15 << direction)) { - if (collMgr.CollidedWithTile()) { + if (collMgr.outputMaybe & (0x15 << direction)) { + if (collMgr.isOnTopOfTile()) { isBouncing = true; } return true; @@ -369,16 +369,16 @@ int daDreidel::onCreate() { _324 = 16.0f; // These structs tell stupid collider what to collide with - these are from koopa troopa - static const u8 one[16] = {0,0,0,1, 0,0,0xC0,0, 0,0,0x40,0, 0,0,0,0}; - static const u8 two[12] = {0,0,0,0, 0,0,0,0, 0,0,0xC0,0}; - static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0x60,0}; + static const lineSensor_s below(12<<12, 4<<12, 0<<12); + static const pointSensor_s above(0<<12, 12<<12); + static const lineSensor_s adjacent(6<<12, 9<<12, 6<<12); - collMgr.Init(this, one, two, three); - collMgr.execute(); + collMgr.init(this, &below, &above, &adjacent); + collMgr.calculateBelowCollisionWithSmokeEffect(); - cmgr_returnValue = collMgr.CollidedWithTile(); + cmgr_returnValue = collMgr.isOnTopOfTile(); - if (collMgr.CollidedWithTile()) + if (collMgr.isOnTopOfTile()) isBouncing = false; else isBouncing = true; diff --git a/src/bossWrenchThrow.cpp b/src/bossWrenchThrow.cpp index 5247c62..338e3ec 100644 --- a/src/bossWrenchThrow.cpp +++ b/src/bossWrenchThrow.cpp @@ -134,14 +134,14 @@ int daWrench::onCreate() { _324 = 5.0f; // These structs tell stupid collider what to collide with - these are from koopa troopa - static const u8 one[16] = {0,0,0,1, 0,0,0xC0,0, 0,0,0x40,0, 0,0,0,0}; - static const u8 two[12] = {0,0,0,0, 0,0,0,0, 0,0,0xC0,0}; - static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0x60,0}; + static const lineSensor_s below(12<<12, 4<<12, 0<<12); + static const pointSensor_s above(0<<12, 12<<12); + static const lineSensor_s adjacent(6<<12, 9<<12, 6<<12); - collMgr.Init(this, one, two, three); - collMgr.execute(); + collMgr.init(this, &below, &above, &adjacent); + collMgr.calculateBelowCollisionWithSmokeEffect(); - cmgr_returnValue = collMgr.CollidedWithTile(); + cmgr_returnValue = collMgr.isOnTopOfTile(); if (this->direction == 0) { // Ground Facing Left @@ -222,10 +222,10 @@ void daWrench::executeState_Kaboom() { HandleYSpeed(); doSpriteMovement(); - cmgr_returnValue = collMgr.CollidedWithTile(); - collMgr.execute(); + cmgr_returnValue = collMgr.isOnTopOfTile(); + collMgr.calculateBelowCollisionWithSmokeEffect(); - if (collMgr.CollidedWithTile()) { + if (collMgr.isOnTopOfTile()) { // hit the ground PlaySoundAsync(this, SE_BOSS_JR_BOMB_BURST); @@ -233,7 +233,7 @@ void daWrench::executeState_Kaboom() { SpawnEffect("Wm_mr_wirehit", 0, &this->pos, &(S16Vec){0,0,0}, &(Vec){1.25, 1.25, 1.25}); this->Delete(1); } - if (collMgr.bitfield_for_checks & (0x15 << direction)) { + if (collMgr.outputMaybe & (0x15 << direction)) { // hit the wall PlaySoundAsync(this, SE_BOSS_JR_BOMB_BURST); @@ -281,17 +281,17 @@ void daWrench::executeState_Straight() { HandleYSpeed(); doSpriteMovement(); - cmgr_returnValue = collMgr.CollidedWithTile(); - collMgr.execute(); + cmgr_returnValue = collMgr.isOnTopOfTile(); + collMgr.calculateBelowCollisionWithSmokeEffect(); - if (collMgr.CollidedWithTile()) { + if (collMgr.isOnTopOfTile()) { // hit the ground PlaySoundAsync(this, SE_BOSS_JR_FLOOR_BREAK); SpawnEffect("Wm_en_burst_s", 0, &this->pos, &(S16Vec){0,0,0}, &(Vec){0.75, 0.75, 0.75}); this->Delete(1); } - if (collMgr.bitfield_for_checks & (0x15 << direction)) { + if (collMgr.outputMaybe & (0x15 << direction)) { // hit the wall PlaySoundAsync(this, SE_BOSS_JR_FLOOR_BREAK); diff --git a/src/penguin.cpp b/src/penguin.cpp index 6112285..6febbae 100644 --- a/src/penguin.cpp +++ b/src/penguin.cpp @@ -166,8 +166,8 @@ bool daPengi::calculateTileCollisions() { HandleYSpeed(); doSpriteMovement(); - cmgr_returnValue = collMgr.CollidedWithTile(); - collMgr.execute(); + cmgr_returnValue = collMgr.isOnTopOfTile(); + collMgr.calculateBelowCollisionWithSmokeEffect(); if (isBouncing) { stuffRelatingToCollisions(0.1875f, 1.0f, 0.5f); @@ -181,7 +181,7 @@ bool daPengi::calculateTileCollisions() { else direction = 1; - if (collMgr.CollidedWithTile()) { + if (collMgr.isOnTopOfTile()) { // Walking into a tile branch if (cmgr_returnValue == 0) @@ -205,23 +205,23 @@ bool daPengi::calculateTileCollisions() { // Bouncing checks if (_34A & 4) { Vec v = (Vec){0.0f, 1.0f, 0.0f}; - collMgr.parent_speed_ptr = &v; + collMgr.pSpeed = &v; - if (collMgr.SomethingSemiImportant(collMgr.bitfield_for_checks)) + if (collMgr.calculateAboveCollision(collMgr.outputMaybe)) speed.y = 0.0f; - collMgr.parent_speed_ptr = &speed; + collMgr.pSpeed = &speed; } else { - if (collMgr.SomethingSemiImportant(collMgr.bitfield_for_checks)) + if (collMgr.calculateAboveCollision(collMgr.outputMaybe)) speed.y = 0.0f; } - collMgr.s_8006FA40(0); + collMgr.calculateAdjacentCollision(0); // Switch Direction - if (collMgr.bitfield_for_checks & (0x15 << direction)) { - if (collMgr.CollidedWithTile()) { + if (collMgr.outputMaybe & (0x15 << direction)) { + if (collMgr.isOnTopOfTile()) { isBouncing = true; } return true; @@ -299,16 +299,16 @@ int daPengi::onCreate() { _324 = 16.0f; // These structs tell stupid collider what to collide with - these are from koopa troopa - static const u8 one[16] = {0,0,0,1, 0,0,0xC0,0, 0,0,0x40,0, 0,0,0,0}; - static const u8 two[12] = {0,0,0,0, 0,0,0,0, 0,0,0xC0,0}; - static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0x60,0}; + static const lineSensor_s below(12<<12, 4<<12, 0<<12); + static const pointSensor_s above(0<<12, 12<<12); + static const lineSensor_s adjacent(6<<12, 9<<12, 6<<12); - collMgr.Init(this, one, two, three); - collMgr.execute(); + collMgr.init(this, &below, &above, &adjacent); + collMgr.calculateBelowCollisionWithSmokeEffect(); - cmgr_returnValue = collMgr.CollidedWithTile(); + cmgr_returnValue = collMgr.isOnTopOfTile(); - if (collMgr.CollidedWithTile()) + if (collMgr.isOnTopOfTile()) isBouncing = false; else isBouncing = true; diff --git a/src/shyguy.cpp b/src/shyguy.cpp index 5a21e6c..b2eef75 100644 --- a/src/shyguy.cpp +++ b/src/shyguy.cpp @@ -380,8 +380,8 @@ bool daShyGuy::calculateTileCollisions() { HandleYSpeed(); doSpriteMovement(); - cmgr_returnValue = collMgr.CollidedWithTile(); - collMgr.execute(); + cmgr_returnValue = collMgr.isOnTopOfTile(); + collMgr.calculateBelowCollisionWithSmokeEffect(); if (isBouncing) { stuffRelatingToCollisions(0.1875f, 1.0f, 0.5f); @@ -395,7 +395,7 @@ bool daShyGuy::calculateTileCollisions() { else direction = 1; - if (collMgr.CollidedWithTile()) { + if (collMgr.isOnTopOfTile()) { // Walking into a tile branch if (cmgr_returnValue == 0) @@ -419,23 +419,23 @@ bool daShyGuy::calculateTileCollisions() { // Bouncing checks if (_34A & 4) { Vec v = (Vec){0.0f, 1.0f, 0.0f}; - collMgr.parent_speed_ptr = &v; + collMgr.pSpeed = &v; - if (collMgr.SomethingSemiImportant(collMgr.bitfield_for_checks)) + if (collMgr.calculateAboveCollision(collMgr.outputMaybe)) speed.y = 0.0f; - collMgr.parent_speed_ptr = &speed; + collMgr.pSpeed = &speed; } else { - if (collMgr.SomethingSemiImportant(collMgr.bitfield_for_checks)) + if (collMgr.calculateAboveCollision(collMgr.outputMaybe)) speed.y = 0.0f; } - collMgr.s_8006FA40(0); + collMgr.calculateAdjacentCollision(0); // Switch Direction - if (collMgr.bitfield_for_checks & (0x15 << direction)) { - if (collMgr.CollidedWithTile()) { + if (collMgr.outputMaybe & (0x15 << direction)) { + if (collMgr.isOnTopOfTile()) { isBouncing = true; } return true; @@ -631,16 +631,16 @@ int daShyGuy::onCreate() { _324 = 16.0f; // These structs tell stupid collider what to collide with - these are from koopa troopa - static const u8 one[16] = {0,0,0,1, 0,0,0xC0,0, 0,0,0x40,0, 0,0,0,0}; - static const u8 two[12] = {0,0,0,0, 0,0,0,0, 0,0,0xC0,0}; - static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0x60,0}; + static const lineSensor_s below(12<<12, 4<<12, 0<<12); + static const pointSensor_s above(0<<12, 12<<12); + static const lineSensor_s adjacent(6<<12, 9<<12, 6<<12); - collMgr.Init(this, one, two, three); - collMgr.execute(); + collMgr.init(this, &below, &above, &adjacent); + collMgr.calculateBelowCollisionWithSmokeEffect(); - cmgr_returnValue = collMgr.CollidedWithTile(); + cmgr_returnValue = collMgr.isOnTopOfTile(); - if (collMgr.CollidedWithTile()) + if (collMgr.isOnTopOfTile()) isBouncing = false; else isBouncing = true; @@ -1188,7 +1188,7 @@ void daShyGuy::updateModelMatrices() { // static const u8 three[16] = { // 0x01,0x80,0x41,0x01, 0xFF,0xFF,0x90,0x00, 0x00,0x00,0x80,0x00, 0x00,0x00,0xEF0,0x00 // }; - // spawned->collMgr.Init(spawned, two, one, three); + // spawned->collMgr.init(spawned, two, one, three); } diff --git a/src/topman.cpp b/src/topman.cpp index 56493da..0c2865a 100644 --- a/src/topman.cpp +++ b/src/topman.cpp @@ -213,8 +213,8 @@ bool daTopman::calculateTileCollisions() { HandleYSpeed(); doSpriteMovement(); - cmgr_returnValue = collMgr.CollidedWithTile(); - collMgr.execute(); + cmgr_returnValue = collMgr.isOnTopOfTile(); + collMgr.calculateBelowCollisionWithSmokeEffect(); if (isBouncing) { stuffRelatingToCollisions(0.1875f, 1.0f, 0.5f); @@ -228,7 +228,7 @@ bool daTopman::calculateTileCollisions() { else direction = 1; - if (collMgr.CollidedWithTile()) { + if (collMgr.isOnTopOfTile()) { // Walking into a tile branch if (cmgr_returnValue == 0) @@ -252,23 +252,23 @@ bool daTopman::calculateTileCollisions() { // Bouncing checks if (_34A & 4) { Vec v = (Vec){0.0f, 1.0f, 0.0f}; - collMgr.parent_speed_ptr = &v; + collMgr.pSpeed = &v; - if (collMgr.SomethingSemiImportant(collMgr.bitfield_for_checks)) + if (collMgr.calculateAboveCollision(collMgr.outputMaybe)) speed.y = 0.0f; - collMgr.parent_speed_ptr = &speed; + collMgr.pSpeed = &speed; } else { - if (collMgr.SomethingSemiImportant(collMgr.bitfield_for_checks)) + if (collMgr.calculateAboveCollision(collMgr.outputMaybe)) speed.y = 0.0f; } - collMgr.s_8006FA40(0); + collMgr.calculateAdjacentCollision(0); // Switch Direction - if (collMgr.bitfield_for_checks & (0x15 << direction)) { - if (collMgr.CollidedWithTile()) { + if (collMgr.outputMaybe & (0x15 << direction)) { + if (collMgr.isOnTopOfTile()) { isBouncing = true; } return true; @@ -346,17 +346,16 @@ int daTopman::onCreate() { _320 = 0.0f; _324 = 16.0f; - // These structs tell stupid collider what to collide with - these are from koopa troopa - static const u8 one[16] = {0,0,0,1, 0,0,0xC0,0, 0,0,0x40,0, 0,0,0,0}; - static const u8 two[12] = {0,0,0,0, 0,0,0,0, 0,0,0xC0,0}; - static const u8 three[16] = {0,0,0,1, 0,0,0x60,0, 0,0,0x90,0, 0,0,0xE0,0}; + static const lineSensor_s below(12<<12, 4<<12, 0<<12); + static const pointSensor_s above(0<<12, 12<<12); + static const lineSensor_s adjacent(6<<12, 9<<12, 14<<12); - collMgr.Init(this, one, two, three); - collMgr.execute(); + collMgr.init(this, &below, &above, &adjacent); + collMgr.calculateBelowCollisionWithSmokeEffect(); - cmgr_returnValue = collMgr.CollidedWithTile(); + cmgr_returnValue = collMgr.isOnTopOfTile(); - if (collMgr.CollidedWithTile()) + if (collMgr.isOnTopOfTile()) isBouncing = false; else isBouncing = true; -- cgit v1.2.3