summaryrefslogtreecommitdiff
path: root/mm/src/code
diff options
context:
space:
mode:
authorGarrett Cox <garrettjcox@gmail.com>2024-11-22 21:57:35 -0600
committerGarrett Cox <garrettjcox@gmail.com>2024-11-22 21:57:35 -0600
commita5208afdf73ef7b11b38eb1602afd607f70f57a0 (patch)
treea4a097bb53657bf3c59af63da97523ff6cfd5f16 /mm/src/code
parent0ac48cdc918f4004332d6ebe86071371305ee41b (diff)
parent8c8b9ad591f93d6d4c0d6eb70d5848226691f416 (diff)
Merge branch 'develop' of garrettjoecox.github.com:HarbourMasters/2ship2harkinian into develop-rando
Diffstat (limited to 'mm/src/code')
-rw-r--r--mm/src/code/z_actor.c60
-rw-r--r--mm/src/code/z_bgcheck.c6
-rw-r--r--mm/src/code/z_play.c10
3 files changed, 49 insertions, 27 deletions
diff --git a/mm/src/code/z_actor.c b/mm/src/code/z_actor.c
index 7e7281822..7f193158a 100644
--- a/mm/src/code/z_actor.c
+++ b/mm/src/code/z_actor.c
@@ -3103,20 +3103,27 @@ s32 func_800BA2FC(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projec
// #region 2S2H [Enhancements] Allows us to increase the draw and update distance independently, mostly a modified
// version of the function above
-void Ship_CalcShouldDrawAndUpdate(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projectedW, bool* shouldDraw,
- bool* shouldUpdate) {
- s32 updateMulti = CVarGetInteger("gEnhancements.Graphics.IncreaseActorUpdateDistance", 1);
- s32 drawMulti = CVarGetInteger("gEnhancements.Graphics.IncreaseActorDrawDistance", 1);
- bool updateCheck =
- (-(actor->uncullZoneScale * updateMulti) < projectedPos->z) &&
- (projectedPos->z < ((actor->uncullZoneForward * updateMulti) + (actor->uncullZoneScale * updateMulti)));
- bool drawCheck =
- (-(actor->uncullZoneScale * drawMulti) < projectedPos->z) &&
- (projectedPos->z < ((actor->uncullZoneForward * drawMulti) + (actor->uncullZoneScale * drawMulti)));
-
- if (updateCheck || drawCheck) {
+s32 Ship_CalcShouldDrawAndUpdate(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projectedW, bool* shouldDraw,
+ bool* shouldUpdate) {
+ // Check if the actor passes its original/vanilla culling requirements
+ if (func_800BA2FC(play, actor, projectedPos, projectedW)) {
+ *shouldUpdate = true;
+ *shouldDraw = true;
+ return true;
+ }
+
+ s32 multiplier = CVarGetInteger("gEnhancements.Graphics.IncreaseActorDrawDistance", 1);
+ multiplier = MAX(multiplier, 1);
+
+ // Apply distance scale to forward cullzone check
+ bool isWithingForwardCullZone =
+ (-actor->uncullZoneScale < projectedPos->z) &&
+ (projectedPos->z < ((actor->uncullZoneForward * multiplier) + actor->uncullZoneScale));
+
+ if (isWithingForwardCullZone) {
// Ensure the projected W value is at least 1.0
f32 clampedProjectedW = CLAMP_MIN(projectedW, 1.0f);
+ f32 ratioAdjusted = 1.0f;
f32 uncullZoneScaleDiagonal;
f32 uncullZoneScaleVertical;
f32 uncullZoneDownwardAdjusted;
@@ -3137,20 +3144,25 @@ void Ship_CalcShouldDrawAndUpdate(PlayState* play, Actor* actor, Vec3f* projecte
if (CVarGetInteger("gEnhancements.Graphics.ActorCullingAccountsForWidescreen", 0)) {
float originalAspectRatio = 4.0f / 3.0f;
float currentAspectRatio = OTRGetAspectRatio();
- float aspectRatioMultiplier = MAX(currentAspectRatio / originalAspectRatio, 1.0f);
-
- clampedProjectedW *= aspectRatioMultiplier;
+ ratioAdjusted = MAX(currentAspectRatio / originalAspectRatio, 1.0f);
}
- bool isWithinHorizontalCullZone = ((fabsf(projectedPos->x) - uncullZoneScaleDiagonal) < clampedProjectedW);
+ // Apply adjsuted aspect ratio to just the horizontal cullzone check
+ bool isWithinHorizontalCullZone =
+ ((fabsf(projectedPos->x) - uncullZoneScaleDiagonal) < (clampedProjectedW * ratioAdjusted));
bool isAboveBottomOfCullZone = ((-clampedProjectedW < (projectedPos->y + uncullZoneScaleVertical)));
bool isBelowTopOfCullZone = ((projectedPos->y - uncullZoneDownwardAdjusted) < clampedProjectedW);
if (isWithinHorizontalCullZone && isAboveBottomOfCullZone && isBelowTopOfCullZone) {
- *shouldDraw = drawCheck;
- *shouldUpdate = updateCheck;
+ // Add additional overries here for glitch useful actors when those are reported
+
+ *shouldDraw = true;
+ *shouldUpdate = true;
+ return true;
}
}
+
+ return false;
}
// #endregion
@@ -3189,11 +3201,10 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) {
Actor_UpdateFlaggedAudio(actor);
}
- // #region 2S2H
+ // #region 2S2H [Enhancement] Extended culling updates
bool shipShouldDraw = false;
bool shipShouldUpdate = false;
if (CVarGetInteger("gEnhancements.Graphics.IncreaseActorDrawDistance", 1) > 1 ||
- CVarGetInteger("gEnhancements.Graphics.IncreaseActorUpdateDistance", 1) > 1 ||
CVarGetInteger("gEnhancements.Graphics.ActorCullingAccountsForWidescreen", 0)) {
Ship_CalcShouldDrawAndUpdate(play, actor, &actor->projectedPos, actor->projectedW, &shipShouldDraw,
&shipShouldUpdate);
@@ -3211,8 +3222,15 @@ void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) {
}
}
+ // Copied flags so we can set the "is active" flag for the draw check below without modifying the actor.
+ // This ensures that overrides for song of soaring or song of time cutscenes still hide actors.
+ s32 shipActorFlagsCopy = actor->flags;
+ if (shipShouldDraw) {
+ shipActorFlagsCopy |= ACTOR_FLAG_40;
+ }
+
actor->isDrawn = false;
- if ((actor->init == NULL) && (actor->draw != NULL) && ((actor->flags & actorFlags) || shipShouldDraw)) {
+ if ((actor->init == NULL) && (actor->draw != NULL) && (shipActorFlagsCopy & actorFlags)) {
// #endregion
if ((actor->flags & ACTOR_FLAG_REACT_TO_LENS) &&
((play->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) ||
diff --git a/mm/src/code/z_bgcheck.c b/mm/src/code/z_bgcheck.c
index 4b1992e94..9576334ab 100644
--- a/mm/src/code/z_bgcheck.c
+++ b/mm/src/code/z_bgcheck.c
@@ -4,9 +4,10 @@
#include "fixed_point.h"
#include "vt.h"
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
-#include <stdio.h>
+#include <stdio.h>
#include "2s2h/BenPort.h"
+#include "2s2h/GameInteractor/GameInteractor.h"
#define DYNA_RAYCAST_FLOORS 1
#define DYNA_RAYCAST_WALLS 2
@@ -4276,7 +4277,8 @@ u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId)
}
u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
- return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 17 & 1;
+ return GameInteractor_Should(VB_BE_HOOKSHOT_SURFACE, SurfaceType_GetData(colCtx, poly, bgId, 1) >> 17 & 1, poly,
+ bgId);
}
s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
diff --git a/mm/src/code/z_play.c b/mm/src/code/z_play.c
index d9cfd954f..2d6491ffc 100644
--- a/mm/src/code/z_play.c
+++ b/mm/src/code/z_play.c
@@ -1184,16 +1184,17 @@ void Play_DrawMain(PlayState* this) {
// Track render size when paused and that a copy was performed
static u32 lastPauseWidth;
static u32 lastPauseHeight;
- static u8 hasCapturedPauseBuffer;
+ static bool lastAltAssets;
+ static bool hasCapturedPauseBuffer;
u8 recapturePauseBuffer = false;
- // If the size has changed or dropped frames leading to the buffer not being copied,
+ // If the size has changed, alt assets toggled or dropped frames leading to the buffer not being copied,
// set the prerender state back to setup to copy a new frame.
- // This requires not rendering kaleido during this copy to avoid kaleido being copied
+ // This requires not rendering kaleido during this copy to avoid kaleido itself being copied too.
if ((R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_PROCESS ||
R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_READY) &&
(lastPauseWidth != OTRGetGameRenderWidth() || lastPauseHeight != OTRGetGameRenderHeight() ||
- !hasCapturedPauseBuffer || sJustClosedBomberNotebook)) {
+ lastAltAssets != ResourceMgr_IsAltAssetsEnabled() || !hasCapturedPauseBuffer || sJustClosedBomberNotebook)) {
R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP;
recapturePauseBuffer = true;
}
@@ -1487,6 +1488,7 @@ void Play_DrawMain(PlayState* this) {
// #region 2S2H [Port] Custom handling for pause prerender background capture
lastPauseWidth = OTRGetGameRenderWidth();
lastPauseHeight = OTRGetGameRenderHeight();
+ lastAltAssets = ResourceMgr_IsAltAssetsEnabled();
hasCapturedPauseBuffer = false;
FB_CopyToFramebuffer(&sp74, 0, gPauseFrameBuffer, false, &hasCapturedPauseBuffer);