Merge pull request #668 from joshuarwood/light_fix_for_bg_glass

Fix for background lights
This commit is contained in:
fgsfds authored and GitHub committed 2025-11-09 10:39:11 +01:00
commit 79711364bb
2 files changed
+19 -5

No files matched your search

+14
View File
@@ -135,6 +135,9 @@ s32 g_BgMostAttemptedDrawSlots = 0;
s32 g_BgNumRoomLoadCandidates = 0;
u16 g_BgFrameCount = 0xfffe;
s32 g_BgNumPortalCameraCacheItems = 0;
#ifndef PLATFORM_N64
bool g_BgHitXluDisabled = false;
#endif
void bgUnpausePropsInRoom(u32 roomnum, bool tintedglassonly)
{
@@ -4590,6 +4593,10 @@ bool bgTestHitInRoom(struct coord *frompos, struct coord *topos, s32 roomnum, st
numbatches = g_Rooms[roomnum].numvtxbatches;
for (i = 0; i < numbatches; batch++, i++) {
#ifndef PLATFORM_N64
if (g_BgHitXluDisabled && batch->type == VTXBATCHTYPE_XLU)
continue;
#endif
j = bg0f1612e4(&batch->bbmin, &batch->bbmax, &from, &dist, &sp94, &hitthing->pos);
if (j == 0) {
@@ -6417,6 +6424,10 @@ void bgCalculateGlaresForVisibleRooms(void)
g_NumRoomsWithGlares = 0;
// disable line-of-sight hits for transparent background
// surfaces before testing for light obstructions
g_BgHitXluDisabled = true;
if (!g_Vars.mplayerisrunning) {
for (i = 1; i < g_Vars.roomcount; i++) {
if (g_Rooms[i].flags & ROOMFLAG_ONSCREEN) {
@@ -6427,6 +6438,9 @@ void bgCalculateGlaresForVisibleRooms(void)
}
}
}
// re-enable background hits for transparent surfaces
g_BgHitXluDisabled = false;
}
#endif
+5 -5
View File
@@ -983,7 +983,7 @@ struct prop *shotCalculateHits(s32 handnum, bool isshooting, struct coord *gunpo
bool shotTestLos(struct coord *gunpos2d, struct coord *gundir2d, struct coord *gunpos3d, struct coord *gundir3d, struct coord *endpos3d)
{
struct prop **propptr;
struct hitthing sp664;
struct hitthing hitthing;
struct coord delta;
struct shotdata shotdata;
s32 i;
@@ -1042,11 +1042,11 @@ bool shotTestLos(struct coord *gunpos2d, struct coord *gundir2d, struct coord *g
// Check for BG hits first
for (i = 0; rooms[i] != -1; i++) {
if (bgTestHitInRoom(&shotdata.gunpos3d, endpos3d, rooms[i], &sp664)) {
if (bgTestHitInRoom(&shotdata.gunpos3d, endpos3d, rooms[i], &hitthing)) {
// check if it's far enough away from the end point
if (fabsf(sp664.pos.x - endpos3d->x) >= 0.1f ||
fabsf(sp664.pos.y - endpos3d->y) >= 0.1f ||
fabsf(sp664.pos.z - endpos3d->z) >= 0.1f) {
if (fabsf(hitthing.pos.x - endpos3d->x) >= 0.1f ||
fabsf(hitthing.pos.y - endpos3d->y) >= 0.1f ||
fabsf(hitthing.pos.z - endpos3d->z) >= 0.1f) {
return false;
}
}