Zelda64Recomp/patches/culling.c

91 lines
3.3 KiB
C
Raw Normal View History

#include "patches.h"
// Disable frustum culling for actors, but leave distance culling intact
s32 func_800BA2FC(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projectedW) {
if ((-actor->uncullZoneScale < projectedPos->z) &&
(projectedPos->z < (actor->uncullZoneForward + actor->uncullZoneScale))) {
// f32 phi_f12;
// f32 phi_f2 = CLAMP_MIN(projectedW, 1.0f);
// f32 phi_f14;
// f32 phi_f16;
// if (play->view.fovy != 60.0f) {
// phi_f12 = actor->uncullZoneScale * play->projectionMtxFDiagonal.x * 0.76980036f; // sqrt(16/27)
// phi_f14 = play->projectionMtxFDiagonal.y * 0.57735026f; // 1 / sqrt(3)
// phi_f16 = actor->uncullZoneScale * phi_f14;
// phi_f14 *= actor->uncullZoneDownward;
// } else {
// phi_f16 = phi_f12 = actor->uncullZoneScale;
// phi_f14 = actor->uncullZoneDownward;
// }
// if (((fabsf(projectedPos->x) - phi_f12) < phi_f2) && ((-phi_f2 < (projectedPos->y + phi_f14))) &&
// ((projectedPos->y - phi_f16) < phi_f2)) {
return true;
// }
}
return false;
}
// Disable frustum culling for bush spawning
// s32 EnWood02_SpawnZoneCheck(EnWood02* this, PlayState* play, Vec3f* arg2) {
// f32 phi_f12;
// SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, arg2, &this->actor.projectedPos, &this->actor.projectedW);
// if (this->actor.projectedW == 0.0f) {
// phi_f12 = 1000.0f;
// } else {
// phi_f12 = fabsf(1.0f / this->actor.projectedW);
// }
// if (((-this->actor.uncullZoneScale < this->actor.projectedPos.z) &&
// (this->actor.projectedPos.z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale)) /* &&
// (((fabsf(this->actor.projectedPos.x) - this->actor.uncullZoneScale) * phi_f12) < 1.0f)) &&
// (((this->actor.projectedPos.y + this->actor.uncullZoneDownward) * phi_f12) > -1.0f) &&
// (((this->actor.projectedPos.y - this->actor.uncullZoneScale) * phi_f12) < 1.0f */)) {
// return true;
// }
// return false;
// }
// Disable frustum culling for grass
s32 func_809A9110(PlayState* play, Vec3f* pos) {
f32 w;
Vec3f projectedPos;
SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, pos, &projectedPos, &w);
if ((play->projectionMtxFDiagonal.z * -130.13191f) < projectedPos.z) {
if (w < 1.0f) {
w = 1.0f;
}
// if (((fabsf(projectedPos.x) - (130.13191f * play->projectionMtxFDiagonal.x)) < w) &&
// ((fabsf(projectedPos.y) - (130.13191f * play->projectionMtxFDiagonal.y)) < w)) {
return true;
// }
}
return false;
}
// Override LOD to 0
void Player_DrawGameplay(PlayState* play, Player* this, s32 lod, Gfx* cullDList,
OverrideLimbDrawFlex overrideLimbDraw) {
OPEN_DISPS(play->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0x0C, cullDList);
gSPSegment(POLY_XLU_DISP++, 0x0C, cullDList);
lod = 0; // Force the closest LOD
Player_DrawImpl(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, lod,
this->transformation, 0, this->actor.shape.face, overrideLimbDraw, Player_PostLimbDrawGameplay,
&this->actor);
CLOSE_DISPS(play->state.gfxCtx);
}