diff options
| author | engineer124 <47598039+engineer124@users.noreply.github.com> | 2024-12-06 15:48:38 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-05 20:48:38 -0800 |
| commit | 3c16f534de369221f9f1d5d9542fd902b54743bc (patch) | |
| tree | 68248ec8bb50ad7ca25d5c6bc7b69e45a091842a /src/code | |
| parent | 33e4afd4d5e39fe89f414730bd2cc225f869bd44 (diff) | |
Document Light-Based Actor Flags (#1754)
* light flags template
* first attempt
* typo
* improve names
* improve comments
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/z_actor.c | 8 | ||||
| -rw-r--r-- | src/code/z_lights.c | 24 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 4ed9ead9b..09ff56811 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -2770,12 +2770,16 @@ void Actor_Draw(PlayState* play, Actor* actor) { OPEN_DISPS(play->state.gfxCtx); light = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx); - if ((actor->flags & ACTOR_FLAG_10000000) && (play->roomCtx.curRoom.enablePosLights || (MREG(93) != 0))) { + if ((actor->flags & ACTOR_FLAG_UCODE_POINT_LIGHT_ENABLED) && + (play->roomCtx.curRoom.enablePosLights || (MREG(93) != 0))) { light->enablePosLights = true; } Lights_BindAll(light, play->lightCtx.listHead, - (actor->flags & (ACTOR_FLAG_10000000 | ACTOR_FLAG_400000)) ? NULL : &actor->world.pos, play); + (actor->flags & (ACTOR_FLAG_UCODE_POINT_LIGHT_ENABLED | ACTOR_FLAG_IGNORE_LEGACY_POINT_LIGHTS)) + ? NULL + : &actor->world.pos, + play); Lights_Draw(light, play->state.gfxCtx); if (actor->flags & ACTOR_FLAG_IGNORE_QUAKE) { diff --git a/src/code/z_lights.c b/src/code/z_lights.c index bf13917e0..d7917a678 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -191,8 +191,8 @@ void Lights_BindDirectional(Lights* lights, LightParams* params, void* unused) { } } -typedef void (*LightsBindFunc)(Lights* lights, LightParams* params, Vec3f* vec); -typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, struct PlayState* play); +typedef void (*LightsBindFuncLegacy)(Lights* lights, LightParams* params, Vec3f* vec); +typedef void (*LightsBindFunc)(Lights* lights, LightParams* params, struct PlayState* play); /** * For every light in a provided list, try to find a free slot in the provided Lights group and bind @@ -201,28 +201,32 @@ typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, struct Pl * * Note: Lights in a given list can only be binded to however many free slots are * available in the Lights group. This is at most 7 slots for a new group, but could be less. + * + * Note: In F3DZEX2 versions that predate MM, microcode point lights didn't exist so `PointLight_t` could not be used. + * Instead, fake point lights by using a directional light that constantly changes to face a reference position. + * `sBindFuncs` maps to the new microcode point lights, and `sBindFuncsLegacy` maps to the old fake point lights. */ void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, PlayState* play) { - static LightsPosBindFunc sPosBindFuncs[] = { + static LightsBindFunc sBindFuncs[] = { Lights_BindPoint, - (LightsPosBindFunc)Lights_BindDirectional, + (LightsBindFunc)Lights_BindDirectional, Lights_BindPoint, }; - static LightsBindFunc sDirBindFuncs[] = { + static LightsBindFuncLegacy sBindFuncsLegacy[] = { Lights_BindPointWithReference, - (LightsBindFunc)Lights_BindDirectional, + (LightsBindFuncLegacy)Lights_BindDirectional, Lights_BindPointWithReference, }; if (listHead != NULL) { if ((refPos == NULL) && (lights->enablePosLights == 1)) { do { - sPosBindFuncs[listHead->info->type](lights, &listHead->info->params, play); + sBindFuncs[listHead->info->type](lights, &listHead->info->params, play); listHead = listHead->next; } while (listHead != NULL); } else { do { - sDirBindFuncs[listHead->info->type](lights, &listHead->info->params, refPos); + sBindFuncsLegacy[listHead->info->type](lights, &listHead->info->params, refPos); listHead = listHead->next; } while (listHead != NULL); } @@ -400,7 +404,7 @@ void Lights_GlowCheck(PlayState* play) { worldPos.z = params->z; Actor_GetProjectedPos(play, &worldPos, &projectedPos, &invW); - params->drawGlow = 0; + params->drawGlow = false; if ((projectedPos.z > 1) && (fabsf(projectedPos.x * invW) < 1) && (fabsf(projectedPos.y * invW) < 1)) { s32 screenPosX = PROJECTED_TO_SCREEN_X(projectedPos, invW); @@ -409,7 +413,7 @@ void Lights_GlowCheck(PlayState* play) { s32 zBuf = SysCfb_GetZBufferInt(screenPosX, screenPosY); if (wZ < zBuf) { - params->drawGlow = 1; + params->drawGlow = true; } } } |
