Skip to content

Commit

Permalink
Fix a few lens flare issues (HarbourMasters#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshDuMan authored Mar 4, 2022
1 parent 78797cf commit b00f3c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions soh/src/code/z_kankyo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1478,11 +1478,12 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env

} else {
if (arg9) {
u32 shrink = ShrinkWindow_GetCurrentVal();
func_800C016C(globalCtx, &pos, &screenPos);
D_8015FD7E = (s16)screenPos.x;
D_8015FD80 = (s16)screenPos.y - 5.0f;
if (D_8011FB44 != 0xFFFC || screenPos.x < 0.0f || screenPos.y < 0.0f || screenPos.x > OTRGetCurrentWidth() ||
screenPos.y > OTRGetCurrentHeight()) {
if (D_8011FB44 != 0xFFFC || screenPos.x < 0.0f || screenPos.y < shrink || screenPos.x > SCREEN_WIDTH ||
screenPos.y > (SCREEN_HEIGHT - shrink)) {
isOffScreen = true;
}
}
Expand Down
12 changes: 10 additions & 2 deletions soh/src/code/z_lights.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ void Lights_GlowCheck(GlobalContext* globalCtx) {
params = &node->info->params.point;

if (node->info->type == LIGHT_POINT_GLOW) {
f32 x, y;
u32 shrink;
uint32_t height;

pos.x = params->x;
pos.y = params->y;
pos.z = params->z;
Expand All @@ -348,9 +352,13 @@ void Lights_GlowCheck(GlobalContext* globalCtx) {
wX = multDest.x * wDest;
wY = multDest.y * wDest;

if ((multDest.z > 1.0f) /*&& (fabsf(wX) < 1.0f)*/ && (fabsf(wY) < 1.0f)) {
x = wX * 160 + 160;
y = wY * 120 + 120;
shrink = ShrinkWindow_GetCurrentVal();

if ((multDest.z > 1.0f) && y >= shrink && y <= SCREEN_HEIGHT - shrink) {
wZ = (s32)((multDest.z * wDest) * 16352.0f) + 16352;
zBuf = OTRGetPixelDepth((s32)((wX * 160) + 160), (s32)((wY * 120) + 120)) * 4;
zBuf = OTRGetPixelDepth(x, y) * 4;
if (1) {}
if (1) {}

Expand Down
2 changes: 1 addition & 1 deletion soh/src/code/z_play.c
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ void func_800C016C(GlobalContext* globalCtx, Vec3f* src, Vec3f* dest) {
globalCtx->viewProjectionMtxF.wz * src->z);

dest->x = 160.0f + ((dest->x / temp) * 160.0f);
dest->y = 120.0f - ((dest->y / temp) * 120.0f);
dest->y = 120.0f + ((dest->y / temp) * 120.0f);
}

s16 Gameplay_CreateSubCamera(GlobalContext* globalCtx) {
Expand Down

0 comments on commit b00f3c7

Please sign in to comment.