From c79a001f5fb02b9ad585d8889cff2ec2b58665a4 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+Agent-11@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:02:43 -0400 Subject: [PATCH] Make fixed collision rounded corners toggleable (#315) --- autogen/lua_definitions/structs.lua | 1 + docs/lua/structs.md | 1 + src/engine/surface_collision.c | 4 +- src/game/hardcoded.c | 129 ++++++++++++++-------------- src/game/hardcoded.h | 1 + src/pc/lua/smlua_cobject_autogen.c | 79 ++++++++--------- 6 files changed, 110 insertions(+), 105 deletions(-) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 21d8f6376..3fb2679c1 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -642,6 +642,7 @@ --- @field public exitCastleWarpNode integer --- @field public extendedPauseDisplay integer --- @field public fixCollisionBugs integer +--- @field public fixCollisionBugsRoundedCorners integer --- @field public fixVanishFloors integer --- @field public floatingStarDance integer --- @field public floorLowerLimit integer diff --git a/docs/lua/structs.md b/docs/lua/structs.md index fc4333a61..df0172c02 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -940,6 +940,7 @@ | exitCastleWarpNode | `integer` | | | extendedPauseDisplay | `integer` | | | fixCollisionBugs | `integer` | | +| fixCollisionBugsRoundedCorners | `integer` | | | fixVanishFloors | `integer` | | | floatingStarDance | `integer` | | | floorLowerLimit | `integer` | | diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index 24d008a43..d7fc692b4 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -134,7 +134,7 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode, continue; } - if (gLevelValues.fixCollisionBugs) { + if (gLevelValues.fixCollisionBugs && gLevelValues.fixCollisionBugsRoundedCorners) { // Check AABB to exclude walls before doing expensive triangle check f32 minX = MIN(MIN(surf->vertex1[0], surf->vertex2[0]), surf->vertex3[0]) - radius; f32 minZ = MIN(MIN(surf->vertex1[2], surf->vertex2[2]), surf->vertex3[2]) - radius; @@ -277,7 +277,7 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode, //! (Wall Overlaps) Because this doesn't update the x and z local variables, // multiple walls can push mario more than is required. // - if (gLevelValues.fixCollisionBugs) { + if (gLevelValues.fixCollisionBugs && gLevelValues.fixCollisionBugsRoundedCorners) { data->x = cPos[0] + cNorm[0] * radius; data->z = cPos[2] + cNorm[2] * radius; x = data->x; diff --git a/src/game/hardcoded.c b/src/game/hardcoded.c index 8bb10077d..d088aa506 100644 --- a/src/game/hardcoded.c +++ b/src/game/hardcoded.c @@ -42,75 +42,76 @@ extern Trajectory sThiTinyMetalBallTraj[]; //////////// struct LevelValues gDefaultLevelValues = { - .fixCollisionBugs = 0, - .fixVanishFloors = 0, - .hudCapTimer = 0, - .hudRedCoinsRadar = 0, - .hudSecretsRadar = 0, - .starHeal = 0, - .mushroom1UpHeal = 0, - .floatingStarDance = 0, - .previewBlueCoins = 0, - .respawnBlueCoinsSwitch = 0, - .visibleSecrets = 0, - .showStarNumber = 0, - .extendedPauseDisplay = 0, - .entryLevel = LEVEL_CASTLE_GROUNDS, - .exitCastleLevel = LEVEL_CASTLE, - .exitCastleArea = 1, - .exitCastleWarpNode = 0x1F, - .skipCreditsAt = (LEVEL_MAX+1), - .pssSlideStarTime = 630, - .pssSlideStarIndex = 1, - .coinsRequiredForCoinStar = 100, - .wingCapDuration = 1800, - .metalCapDuration = 600, - .vanishCapDuration = 600, - .wingCapDurationTotwc = 1200, - .metalCapDurationCotmc = 600, - .vanishCapDurationVcutm = 600, - .wingCapSequence = SEQ_EVENT_POWERUP, - .metalCapSequence = SEQ_EVENT_METAL_CAP, - .vanishCapSequence = SEQ_EVENT_POWERUP, + .fixCollisionBugs = 0, + .fixCollisionBugsRoundedCorners = 1, + .fixVanishFloors = 0, + .hudCapTimer = 0, + .hudRedCoinsRadar = 0, + .hudSecretsRadar = 0, + .starHeal = 0, + .mushroom1UpHeal = 0, + .floatingStarDance = 0, + .previewBlueCoins = 0, + .respawnBlueCoinsSwitch = 0, + .visibleSecrets = 0, + .showStarNumber = 0, + .extendedPauseDisplay = 0, + .entryLevel = LEVEL_CASTLE_GROUNDS, + .exitCastleLevel = LEVEL_CASTLE, + .exitCastleArea = 1, + .exitCastleWarpNode = 0x1F, + .skipCreditsAt = (LEVEL_MAX + 1), + .pssSlideStarTime = 630, + .pssSlideStarIndex = 1, + .coinsRequiredForCoinStar = 100, + .wingCapDuration = 1800, + .metalCapDuration = 600, + .vanishCapDuration = 600, + .wingCapDurationTotwc = 1200, + .metalCapDurationCotmc = 600, + .vanishCapDurationVcutm = 600, + .wingCapSequence = SEQ_EVENT_POWERUP, + .metalCapSequence = SEQ_EVENT_METAL_CAP, + .vanishCapSequence = SEQ_EVENT_POWERUP, .starPositions = { - .KoopaBobStarPos = { 3030.0f, 4500.0f, -4600.0f }, - .KoopaThiStarPos = { 7100.0f, -1300.0f, -6000.0f }, - .KingBobombStarPos = { 2000.0f, 4500.0f, -4500.0f }, - .KingWhompStarPos = { 180.0f, 3880.0f, 340.0f }, - .EyerockStarPos = { 0.0f, -900.0f, -3700.0f }, - .BigBullyStarPos = { 3700.0f, 600.0f, -5500.0f }, - .ChillBullyStarPos = { 130.0f, 1600.0f, -4335.0f }, - .BigPiranhasStarPos = { -6300.0f, -1850.0f, -6300.0f }, + .KoopaBobStarPos = { 3030.0f, 4500.0f, -4600.0f }, + .KoopaThiStarPos = { 7100.0f, -1300.0f, -6000.0f }, + .KingBobombStarPos = { 2000.0f, 4500.0f, -4500.0f }, + .KingWhompStarPos = { 180.0f, 3880.0f, 340.0f }, + .EyerockStarPos = { 0.0f, -900.0f, -3700.0f }, + .BigBullyStarPos = { 3700.0f, 600.0f, -5500.0f }, + .ChillBullyStarPos = { 130.0f, 1600.0f, -4335.0f }, + .BigPiranhasStarPos = { -6300.0f, -1850.0f, -6300.0f }, #ifdef VERSION_JP - .TuxieMotherStarPos = { 3500.0f, -4300.0f, 4650.0f }, + .TuxieMotherStarPos = { 3500.0f, -4300.0f, 4650.0f }, #else - .TuxieMotherStarPos = { 3167.0f, -4300.0f, 5108.0f }, + .TuxieMotherStarPos = { 3167.0f, -4300.0f, 5108.0f }, #endif - .WigglerStarPos = { 0.0f, 2048.0f, 0.0f }, - .PssSlideStarPos = { -6358.0f, -4300.0f, 4700.0f }, - .RacingPenguinStarPos = { -7339.0f, -5700.0f, -6774.0f }, - .TreasureJrbStarPos = { -1800.0f, -2500.0f, -1700.0f }, - .TreasureChestStarPos = { -1900.0f, -4000.0f, -1400.0f }, - .GhostHuntBooStarPos = { 980.0f, 1100.0f, 250.0f }, - .KleptoStarPos = { -5550.0f, 300.0f, -930.0f }, - .MerryGoRoundStarPos = { -1600.0f, -2100.0f, 205.0f }, - .MrIStarPos = { 1370.0f, 2000.0f, -320.0f }, - .BalconyBooStarPos = { 700.0f, 3200.0f, 1900.0f }, - .BigBullyTrioStarPos = { 0.0f, 950.0f, -6800.0f }, - .MantaRayStarPos = { -3180.0f, -3600.0f, 120.0f }, - .SnowmanHeadStarPos = { -4700.0f, -1024.0f, 1890.0f }, - .CcmSlideStarPos = { 2500.0f, -4350.0f, 5750.0f }, - .UkikiCageStarPos = { 2500.0f, -1200.0f, 1300.0f }, - .UnagiStarPos = { 6833.0f, -3654.0f, 2230.0f }, - .JetstreamRingStarPos = { 3400.0f, -3200.0f, -500.0f }, + .WigglerStarPos = { 0.0f, 2048.0f, 0.0f }, + .PssSlideStarPos = { -6358.0f, -4300.0f, 4700.0f }, + .RacingPenguinStarPos = { -7339.0f, -5700.0f, -6774.0f }, + .TreasureJrbStarPos = { -1800.0f, -2500.0f, -1700.0f }, + .TreasureChestStarPos = { -1900.0f, -4000.0f, -1400.0f }, + .GhostHuntBooStarPos = { 980.0f, 1100.0f, 250.0f }, + .KleptoStarPos = { -5550.0f, 300.0f, -930.0f }, + .MerryGoRoundStarPos = { -1600.0f, -2100.0f, 205.0f }, + .MrIStarPos = { 1370.0f, 2000.0f, -320.0f }, + .BalconyBooStarPos = { 700.0f, 3200.0f, 1900.0f }, + .BigBullyTrioStarPos = { 0.0f, 950.0f, -6800.0f }, + .MantaRayStarPos = { -3180.0f, -3600.0f, 120.0f }, + .SnowmanHeadStarPos = { -4700.0f, -1024.0f, 1890.0f }, + .CcmSlideStarPos = { 2500.0f, -4350.0f, 5750.0f }, + .UkikiCageStarPos = { 2500.0f, -1200.0f, 1300.0f }, + .UnagiStarPos = { 6833.0f, -3654.0f, 2230.0f }, + .JetstreamRingStarPos = { 3400.0f, -3200.0f, -500.0f }, }, - .cellHeightLimit = CELL_HEIGHT_LIMIT, - .floorLowerLimit = FLOOR_LOWER_LIMIT, - .floorLowerLimitMisc = FLOOR_LOWER_LIMIT_MISC, - .floorLowerLimitShadow = FLOOR_LOWER_LIMIT_SHADOW, - .pauseExitAnywhere = 1, - .disableActs = false, - .wingCapLookUpReq = 10, + .cellHeightLimit = CELL_HEIGHT_LIMIT, + .floorLowerLimit = FLOOR_LOWER_LIMIT, + .floorLowerLimitMisc = FLOOR_LOWER_LIMIT_MISC, + .floorLowerLimitShadow = FLOOR_LOWER_LIMIT_SHADOW, + .pauseExitAnywhere = 1, + .disableActs = false, + .wingCapLookUpReq = 10, }; struct LevelValues gLevelValues = { 0 }; diff --git a/src/game/hardcoded.h b/src/game/hardcoded.h index 1fc5e4ec1..75621ed55 100644 --- a/src/game/hardcoded.h +++ b/src/game/hardcoded.h @@ -41,6 +41,7 @@ struct StarPositions { struct LevelValues { u8 fixCollisionBugs; + u8 fixCollisionBugsRoundedCorners; u8 wingCapLookUpReq; u8 fixVanishFloors; u8 hudCapTimer; diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index c99ba093f..e7234a571 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -733,46 +733,47 @@ static struct LuaObjectField sLakituStateFields[LUA_LAKITU_STATE_FIELD_COUNT] = { "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE }, }; -#define LUA_LEVEL_VALUES_FIELD_COUNT 38 +#define LUA_LEVEL_VALUES_FIELD_COUNT 39 static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = { - { "cellHeightLimit", LVT_S16, offsetof(struct LevelValues, cellHeightLimit), false, LOT_NONE }, - { "coinsRequiredForCoinStar", LVT_S16, offsetof(struct LevelValues, coinsRequiredForCoinStar), false, LOT_NONE }, - { "disableActs", LVT_BOOL, offsetof(struct LevelValues, disableActs), false, LOT_NONE }, - { "entryLevel", LVT_S32, offsetof(struct LevelValues, entryLevel), false, LOT_NONE }, - { "exitCastleArea", LVT_S16, offsetof(struct LevelValues, exitCastleArea), false, LOT_NONE }, - { "exitCastleLevel", LVT_S32, offsetof(struct LevelValues, exitCastleLevel), false, LOT_NONE }, - { "exitCastleWarpNode", LVT_U8, offsetof(struct LevelValues, exitCastleWarpNode), false, LOT_NONE }, - { "extendedPauseDisplay", LVT_U8, offsetof(struct LevelValues, extendedPauseDisplay), false, LOT_NONE }, - { "fixCollisionBugs", LVT_U8, offsetof(struct LevelValues, fixCollisionBugs), false, LOT_NONE }, - { "fixVanishFloors", LVT_U8, offsetof(struct LevelValues, fixVanishFloors), false, LOT_NONE }, - { "floatingStarDance", LVT_U8, offsetof(struct LevelValues, floatingStarDance), false, LOT_NONE }, - { "floorLowerLimit", LVT_S16, offsetof(struct LevelValues, floorLowerLimit), false, LOT_NONE }, - { "floorLowerLimitMisc", LVT_S16, offsetof(struct LevelValues, floorLowerLimitMisc), false, LOT_NONE }, - { "floorLowerLimitShadow", LVT_S16, offsetof(struct LevelValues, floorLowerLimitShadow), false, LOT_NONE }, - { "hudCapTimer", LVT_U8, offsetof(struct LevelValues, hudCapTimer), false, LOT_NONE }, - { "hudRedCoinsRadar", LVT_U8, offsetof(struct LevelValues, hudRedCoinsRadar), false, LOT_NONE }, - { "hudSecretsRadar", LVT_U8, offsetof(struct LevelValues, hudSecretsRadar), false, LOT_NONE }, - { "metalCapDuration", LVT_U16, offsetof(struct LevelValues, metalCapDuration), false, LOT_NONE }, - { "metalCapDurationCotmc", LVT_U16, offsetof(struct LevelValues, metalCapDurationCotmc), false, LOT_NONE }, - { "metalCapSequence", LVT_U8, offsetof(struct LevelValues, metalCapSequence), false, LOT_NONE }, - { "mushroom1UpHeal", LVT_U8, offsetof(struct LevelValues, mushroom1UpHeal), false, LOT_NONE }, - { "pauseExitAnywhere", LVT_BOOL, offsetof(struct LevelValues, pauseExitAnywhere), false, LOT_NONE }, - { "previewBlueCoins", LVT_U8, offsetof(struct LevelValues, previewBlueCoins), false, LOT_NONE }, - { "pssSlideStarIndex", LVT_U8, offsetof(struct LevelValues, pssSlideStarIndex), false, LOT_NONE }, - { "pssSlideStarTime", LVT_U16, offsetof(struct LevelValues, pssSlideStarTime), false, LOT_NONE }, - { "respawnBlueCoinsSwitch", LVT_U8, offsetof(struct LevelValues, respawnBlueCoinsSwitch), false, LOT_NONE }, - { "showStarNumber", LVT_U8, offsetof(struct LevelValues, showStarNumber), false, LOT_NONE }, - { "skipCreditsAt", LVT_S32, offsetof(struct LevelValues, skipCreditsAt), false, LOT_NONE }, - { "starHeal", LVT_U8, offsetof(struct LevelValues, starHeal), false, LOT_NONE }, - { "starPositions", LVT_COBJECT, offsetof(struct LevelValues, starPositions), true, LOT_STARPOSITIONS }, - { "vanishCapDuration", LVT_U16, offsetof(struct LevelValues, vanishCapDuration), false, LOT_NONE }, - { "vanishCapDurationVcutm", LVT_U16, offsetof(struct LevelValues, vanishCapDurationVcutm), false, LOT_NONE }, - { "vanishCapSequence", LVT_U8, offsetof(struct LevelValues, vanishCapSequence), false, LOT_NONE }, - { "visibleSecrets", LVT_U8, offsetof(struct LevelValues, visibleSecrets), false, LOT_NONE }, - { "wingCapDuration", LVT_U16, offsetof(struct LevelValues, wingCapDuration), false, LOT_NONE }, - { "wingCapDurationTotwc", LVT_U16, offsetof(struct LevelValues, wingCapDurationTotwc), false, LOT_NONE }, - { "wingCapLookUpReq", LVT_U8, offsetof(struct LevelValues, wingCapLookUpReq), false, LOT_NONE }, - { "wingCapSequence", LVT_U8, offsetof(struct LevelValues, wingCapSequence), false, LOT_NONE }, + { "cellHeightLimit", LVT_S16, offsetof(struct LevelValues, cellHeightLimit), false, LOT_NONE }, + { "coinsRequiredForCoinStar", LVT_S16, offsetof(struct LevelValues, coinsRequiredForCoinStar), false, LOT_NONE }, + { "disableActs", LVT_BOOL, offsetof(struct LevelValues, disableActs), false, LOT_NONE }, + { "entryLevel", LVT_S32, offsetof(struct LevelValues, entryLevel), false, LOT_NONE }, + { "exitCastleArea", LVT_S16, offsetof(struct LevelValues, exitCastleArea), false, LOT_NONE }, + { "exitCastleLevel", LVT_S32, offsetof(struct LevelValues, exitCastleLevel), false, LOT_NONE }, + { "exitCastleWarpNode", LVT_U8, offsetof(struct LevelValues, exitCastleWarpNode), false, LOT_NONE }, + { "extendedPauseDisplay", LVT_U8, offsetof(struct LevelValues, extendedPauseDisplay), false, LOT_NONE }, + { "fixCollisionBugs", LVT_U8, offsetof(struct LevelValues, fixCollisionBugs), false, LOT_NONE }, + { "fixCollisionBugsRoundedCorners", LVT_U8, offsetof(struct LevelValues, fixCollisionBugsRoundedCorners), false, LOT_NONE }, + { "fixVanishFloors", LVT_U8, offsetof(struct LevelValues, fixVanishFloors), false, LOT_NONE }, + { "floatingStarDance", LVT_U8, offsetof(struct LevelValues, floatingStarDance), false, LOT_NONE }, + { "floorLowerLimit", LVT_S16, offsetof(struct LevelValues, floorLowerLimit), false, LOT_NONE }, + { "floorLowerLimitMisc", LVT_S16, offsetof(struct LevelValues, floorLowerLimitMisc), false, LOT_NONE }, + { "floorLowerLimitShadow", LVT_S16, offsetof(struct LevelValues, floorLowerLimitShadow), false, LOT_NONE }, + { "hudCapTimer", LVT_U8, offsetof(struct LevelValues, hudCapTimer), false, LOT_NONE }, + { "hudRedCoinsRadar", LVT_U8, offsetof(struct LevelValues, hudRedCoinsRadar), false, LOT_NONE }, + { "hudSecretsRadar", LVT_U8, offsetof(struct LevelValues, hudSecretsRadar), false, LOT_NONE }, + { "metalCapDuration", LVT_U16, offsetof(struct LevelValues, metalCapDuration), false, LOT_NONE }, + { "metalCapDurationCotmc", LVT_U16, offsetof(struct LevelValues, metalCapDurationCotmc), false, LOT_NONE }, + { "metalCapSequence", LVT_U8, offsetof(struct LevelValues, metalCapSequence), false, LOT_NONE }, + { "mushroom1UpHeal", LVT_U8, offsetof(struct LevelValues, mushroom1UpHeal), false, LOT_NONE }, + { "pauseExitAnywhere", LVT_BOOL, offsetof(struct LevelValues, pauseExitAnywhere), false, LOT_NONE }, + { "previewBlueCoins", LVT_U8, offsetof(struct LevelValues, previewBlueCoins), false, LOT_NONE }, + { "pssSlideStarIndex", LVT_U8, offsetof(struct LevelValues, pssSlideStarIndex), false, LOT_NONE }, + { "pssSlideStarTime", LVT_U16, offsetof(struct LevelValues, pssSlideStarTime), false, LOT_NONE }, + { "respawnBlueCoinsSwitch", LVT_U8, offsetof(struct LevelValues, respawnBlueCoinsSwitch), false, LOT_NONE }, + { "showStarNumber", LVT_U8, offsetof(struct LevelValues, showStarNumber), false, LOT_NONE }, + { "skipCreditsAt", LVT_S32, offsetof(struct LevelValues, skipCreditsAt), false, LOT_NONE }, + { "starHeal", LVT_U8, offsetof(struct LevelValues, starHeal), false, LOT_NONE }, + { "starPositions", LVT_COBJECT, offsetof(struct LevelValues, starPositions), true, LOT_STARPOSITIONS }, + { "vanishCapDuration", LVT_U16, offsetof(struct LevelValues, vanishCapDuration), false, LOT_NONE }, + { "vanishCapDurationVcutm", LVT_U16, offsetof(struct LevelValues, vanishCapDurationVcutm), false, LOT_NONE }, + { "vanishCapSequence", LVT_U8, offsetof(struct LevelValues, vanishCapSequence), false, LOT_NONE }, + { "visibleSecrets", LVT_U8, offsetof(struct LevelValues, visibleSecrets), false, LOT_NONE }, + { "wingCapDuration", LVT_U16, offsetof(struct LevelValues, wingCapDuration), false, LOT_NONE }, + { "wingCapDurationTotwc", LVT_U16, offsetof(struct LevelValues, wingCapDurationTotwc), false, LOT_NONE }, + { "wingCapLookUpReq", LVT_U8, offsetof(struct LevelValues, wingCapLookUpReq), false, LOT_NONE }, + { "wingCapSequence", LVT_U8, offsetof(struct LevelValues, wingCapSequence), false, LOT_NONE }, }; #define LUA_LINEAR_TRANSITION_POINT_FIELD_COUNT 5