Clamp constant falloff to 8 minimum (#840)

This commit is contained in:
Reonu
2024-10-10 03:18:04 +02:00
committed by GitHub
parent 057914b16b
commit 2c3644ccac
2 changed files with 6 additions and 6 deletions

View File

@@ -770,13 +770,13 @@ static s32 bhv_cmd_set_light_color(void) {
// Command 0x39: Sets an object's light falloff
// Usage: SET_LIGHT_FALLOFF(constant, linear, quadratic)
static s32 bhv_cmd_set_light_falloff(void) {
s32 constantFalloff = BHV_CMD_GET_2ND_S16(0);
s32 linearFalloff = BHV_CMD_GET_1ST_S16(1);
s32 quadraticFalloff = BHV_CMD_GET_2ND_S16(1);
u32 constantFalloff = BHV_CMD_GET_2ND_S16(0);
u32 linearFalloff = BHV_CMD_GET_1ST_S16(1);
u32 quadraticFalloff = BHV_CMD_GET_2ND_S16(1);
gCurrentObject->oLightQuadraticFalloff = quadraticFalloff;
gCurrentObject->oLightLinearFalloff = linearFalloff;
gCurrentObject->oLightConstantFalloff = constantFalloff;
gCurrentObject->oLightConstantFalloff = MAX(constantFalloff, 8U);
gCurBhvCommand += 2;
return BHV_PROC_CONTINUE;

View File

@@ -775,7 +775,7 @@ void emit_light(Vec3f pos, s32 red, s32 green, s32 blue, u32 quadraticFalloff, u
gPointLights[gPointLightCount].l.pl.colc[0] = gPointLights[gPointLightCount].l.pl.col[0] = red;
gPointLights[gPointLightCount].l.pl.colc[1] = gPointLights[gPointLightCount].l.pl.col[1] = green;
gPointLights[gPointLightCount].l.pl.colc[2] = gPointLights[gPointLightCount].l.pl.col[2] = blue;
gPointLights[gPointLightCount].l.pl.constant_attenuation = (constantFalloff == 0) ? 8 : constantFalloff;
gPointLights[gPointLightCount].l.pl.constant_attenuation = MAX(constantFalloff, 8U);
gPointLights[gPointLightCount].l.pl.linear_attenuation = linearFalloff;
gPointLights[gPointLightCount].l.pl.quadratic_attenuation = quadraticFalloff;
gPointLights[gPointLightCount].worldPos[0] = pos[0];
@@ -1507,7 +1507,7 @@ void geo_process_scene_light(struct GraphNodeSceneLight *node)
node->light->l.pl.quadratic_attenuation = node->a;
node->light->l.pl.linear_attenuation = node->b;
node->light->l.pl.constant_attenuation = (node->c == 0) ? 8 : node->c;
node->light->l.pl.constant_attenuation = MAX(node->c, 8U);
break;
case LIGHT_TYPE_AMBIENT:
if (!gOverrideAmbientLight)