From 2e51f26d1e10eb3c3b96b09e80357d3d74ce5394 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sat, 20 Jan 2024 21:35:32 -0800 Subject: [PATCH] PointLight_t --- include/PR/gbi.h | 12 ++++++------ src/code/z_lights.c | 38 +++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/include/PR/gbi.h b/include/PR/gbi.h index c6fcdc1e22..554a2789fd 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -1277,12 +1277,12 @@ typedef struct { // Added in MM typedef struct { - unsigned char col[3]; - unsigned char unk3; - unsigned char colc[3]; - unsigned char unk7; - short pos[3]; - unsigned char unkE; + unsigned char col[3]; + unsigned char kc; + unsigned char colc[3]; + unsigned char kl; + short pos[3]; + unsigned char kq; } PointLight_t; typedef struct { diff --git a/src/code/z_lights.c b/src/code/z_lights.c index d38f15529e..86e572d128 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -132,39 +132,43 @@ void Lights_BindPointWithReference(Lights* lights, LightParams* params, Vec3f* p void Lights_BindPoint(Lights* lights, LightParams* params, PlayState* play) { Light* light; - f32 radiusF = params->point.radius; - Vec3f posF; + f32 kq = params->point.radius; + Vec3f pos; Vec3f adjustedPos; s32 pad; - if (radiusF > 0) { - posF.x = params->point.x; - posF.y = params->point.y; - posF.z = params->point.z; - SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &posF, &adjustedPos); - if ((adjustedPos.z > -radiusF) && (600 + radiusF > adjustedPos.z) && (400 > fabsf(adjustedPos.x) - radiusF) && - (400 > fabsf(adjustedPos.y) - radiusF)) { + if (kq > 0.0f) { + pos.x = params->point.x; + pos.y = params->point.y; + pos.z = params->point.z; + SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &pos, &adjustedPos); + if ((-kq < adjustedPos.z) && ((600.0f + kq) > adjustedPos.z) && ((fabsf(adjustedPos.x) - kq) < 400.0f) && + ((fabsf(adjustedPos.y) - kq) < 400.0f)) { light = Lights_FindSlot(lights); if (light != NULL) { - radiusF = 4500000.0f / (radiusF * radiusF); - if (radiusF > 255) { - radiusF = 255; - } else if (20 > radiusF) { - radiusF = 20; + kq = 4500000.0f / SQ(kq); + if (kq > 255.0f) { + kq = 255.0f; + } else if (20.0f > kq) { + kq = 20.0f; } light->p.col[0] = params->point.color[0]; light->p.colc[0] = light->p.col[0]; + light->p.col[1] = params->point.color[1]; light->p.colc[1] = light->p.col[1]; + light->p.col[2] = params->point.color[2]; light->p.colc[2] = light->p.col[2]; + light->p.pos[0] = params->point.x; light->p.pos[1] = params->point.y; light->p.pos[2] = params->point.z; - light->p.unk3 = 0x8; - light->p.unk7 = 0xFF; - light->p.unkE = (s32)radiusF; + + light->p.kc = 8; + light->p.kl = -1; + light->p.kq = (s32)kq; } } }