mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-24 14:31:02 +00:00
Fix the two big problems with the lighting
- FULLY fix light offset still being applied on full bright walls - Fix ceiling lighting being reversed
This commit is contained in:
parent
1b5c9e47c5
commit
f05ac93633
8 changed files with 91 additions and 37 deletions
|
|
@ -289,7 +289,7 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg)
|
|||
{
|
||||
INT16 finallight = lightnum;
|
||||
|
||||
if (seg != NULL && P_ApplyLightOffset(lightnum))
|
||||
if (seg != NULL && P_ApplyLightOffsetFine(lightnum))
|
||||
{
|
||||
finallight += seg->hwLightOffset;
|
||||
|
||||
|
|
@ -304,7 +304,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope)
|
|||
{
|
||||
INT16 finallight = lightnum;
|
||||
|
||||
if (slope != NULL && P_ApplyLightOffset(lightnum))
|
||||
if (slope != NULL && P_ApplyLightOffsetFine(lightnum))
|
||||
{
|
||||
finallight += slope->hwLightOffset;
|
||||
|
||||
|
|
|
|||
|
|
@ -2352,9 +2352,17 @@ void P_UpdateSegLightOffset(seg_t *li)
|
|||
#endif
|
||||
}
|
||||
|
||||
boolean P_ApplyLightOffset(UINT8 baselightlevel)
|
||||
boolean P_ApplyLightOffset(UINT8 baselightnum)
|
||||
{
|
||||
// Don't apply light offsets at full bright or full dark.
|
||||
// Is in steps of light num .
|
||||
return (baselightnum < LIGHTLEVELS-1 && baselightnum > 0);
|
||||
}
|
||||
|
||||
boolean P_ApplyLightOffsetFine(UINT8 baselightlevel)
|
||||
{
|
||||
// Don't apply light offsets at full bright or full dark.
|
||||
// Uses exact light levels for more smoothness.
|
||||
return (baselightlevel < 255 && baselightlevel > 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,8 @@ void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num);
|
|||
void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num);
|
||||
void P_WriteThings(void);
|
||||
void P_UpdateSegLightOffset(seg_t *li);
|
||||
boolean P_ApplyLightOffset(UINT8 baselightlevel);
|
||||
boolean P_ApplyLightOffset(UINT8 baselightnum);
|
||||
boolean P_ApplyLightOffsetFine(UINT8 baselightlevel);
|
||||
size_t P_PrecacheLevelFlats(void);
|
||||
void P_AllocMapHeader(INT16 i);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,17 +49,31 @@ void P_UpdateSlopeLightOffset(pslope_t *slope)
|
|||
|
||||
if (maplighting.directional == true)
|
||||
{
|
||||
fixed_t dX = slope->d.x;
|
||||
fixed_t dY = slope->d.y;
|
||||
fixed_t nX = -slope->normal.x;
|
||||
fixed_t nY = -slope->normal.y;
|
||||
fixed_t nLen = FixedHypot(nX, nY);
|
||||
|
||||
if (slope->zdelta < 0)
|
||||
if (nLen == 0)
|
||||
{
|
||||
dX = -dX;
|
||||
dY = -dY;
|
||||
slope->lightOffset = slope->hwLightOffset = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
light = FixedMul(dX, FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT))
|
||||
+ FixedMul(dY, FINESINE(maplighting.angle >> ANGLETOFINESHIFT));
|
||||
nX = FixedDiv(nX, nLen);
|
||||
nY = FixedDiv(nY, nLen);
|
||||
|
||||
/*
|
||||
if (slope is ceiling)
|
||||
{
|
||||
// There is no good way to calculate this condition here.
|
||||
// We reverse it in R_FindPlane now.
|
||||
nX = -nX;
|
||||
nY = -nY;
|
||||
}
|
||||
*/
|
||||
|
||||
light = FixedMul(nX, FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT))
|
||||
+ FixedMul(nY, FINESINE(maplighting.angle >> ANGLETOFINESHIFT));
|
||||
light = (light + FRACUNIT) / 2;
|
||||
}
|
||||
else
|
||||
|
|
@ -177,7 +191,7 @@ void P_ReconfigureViaVertexes (pslope_t *slope, const vector3_t v1, const vector
|
|||
|
||||
// Get angles
|
||||
slope->xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180;
|
||||
slope->zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta));
|
||||
slope->zangle = R_PointToAngle2(0, 0, FRACUNIT, -slope->zdelta);
|
||||
}
|
||||
|
||||
P_UpdateSlopeLightOffset(slope);
|
||||
|
|
@ -210,7 +224,7 @@ static void ReconfigureViaConstants (pslope_t *slope, const fixed_t a, const fix
|
|||
|
||||
// Get angles
|
||||
slope->xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180;
|
||||
slope->zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta));
|
||||
slope->zangle = R_PointToAngle2(0, 0, FRACUNIT, -slope->zdelta);
|
||||
|
||||
P_UpdateSlopeLightOffset(slope);
|
||||
}
|
||||
|
|
@ -597,6 +611,7 @@ static void line_SpawnViaMapthingVertexes(const int linenum, const boolean spawn
|
|||
UINT16 tag2 = line->args[2];
|
||||
UINT16 tag3 = line->args[3];
|
||||
UINT8 flags = 0; // Slope flags
|
||||
|
||||
if (line->args[4] & TMSL_NOPHYSICS)
|
||||
flags |= SL_NOPHYSICS;
|
||||
if (line->args[4] & TMSL_DYNAMIC)
|
||||
|
|
|
|||
51
src/r_bsp.c
51
src/r_bsp.c
|
|
@ -938,9 +938,14 @@ static void R_Subsector(size_t num)
|
|||
|| frontsector->floorpic == skyflatnum
|
||||
|| (frontsector->heightsec != -1 && sectors[frontsector->heightsec].ceilingpic == skyflatnum))
|
||||
{
|
||||
floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel,
|
||||
frontsector->floor_xoffs, frontsector->floor_yoffs, frontsector->floorpic_angle, floorcolormap, NULL, NULL, frontsector->f_slope,
|
||||
R_NoEncore(frontsector, false), R_IsRipplePlane(frontsector, NULL, false));
|
||||
floorplane = R_FindPlane(
|
||||
frontsector->floorheight, frontsector->floorpic, floorlightlevel,
|
||||
frontsector->floor_xoffs, frontsector->floor_yoffs, frontsector->floorpic_angle,
|
||||
floorcolormap, NULL, NULL, frontsector->f_slope,
|
||||
R_NoEncore(frontsector, false),
|
||||
R_IsRipplePlane(frontsector, NULL, false),
|
||||
false
|
||||
);
|
||||
}
|
||||
else
|
||||
floorplane = NULL;
|
||||
|
|
@ -949,10 +954,14 @@ static void R_Subsector(size_t num)
|
|||
|| frontsector->ceilingpic == skyflatnum
|
||||
|| (frontsector->heightsec != -1 && sectors[frontsector->heightsec].floorpic == skyflatnum))
|
||||
{
|
||||
ceilingplane = R_FindPlane(frontsector->ceilingheight, frontsector->ceilingpic,
|
||||
ceilinglightlevel, frontsector->ceiling_xoffs, frontsector->ceiling_yoffs, frontsector->ceilingpic_angle,
|
||||
ceilingplane = R_FindPlane(
|
||||
frontsector->ceilingheight, frontsector->ceilingpic, ceilinglightlevel,
|
||||
frontsector->ceiling_xoffs, frontsector->ceiling_yoffs, frontsector->ceilingpic_angle,
|
||||
ceilingcolormap, NULL, NULL, frontsector->c_slope,
|
||||
R_NoEncore(frontsector, true), R_IsRipplePlane(frontsector, NULL, true));
|
||||
R_NoEncore(frontsector, true),
|
||||
R_IsRipplePlane(frontsector, NULL, true),
|
||||
true
|
||||
);
|
||||
}
|
||||
else
|
||||
ceilingplane = NULL;
|
||||
|
|
@ -993,11 +1002,14 @@ static void R_Subsector(size_t num)
|
|||
light = R_GetPlaneLight(frontsector, planecenterz,
|
||||
viewz < heightcheck);
|
||||
|
||||
ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic,
|
||||
ffloor[numffloors].plane = R_FindPlane(
|
||||
*rover->bottomheight, *rover->bottompic,
|
||||
*frontsector->lightlist[light].lightlevel, *rover->bottomxoffs,
|
||||
*rover->bottomyoffs, *rover->bottomangle, *frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->b_slope,
|
||||
R_NoEncore(rover->master->frontsector, true),
|
||||
R_IsRipplePlane(rover->master->frontsector, rover, true));
|
||||
R_IsRipplePlane(rover->master->frontsector, rover, true),
|
||||
true
|
||||
);
|
||||
|
||||
ffloor[numffloors].slope = *rover->b_slope;
|
||||
|
||||
|
|
@ -1024,11 +1036,14 @@ static void R_Subsector(size_t num)
|
|||
{
|
||||
light = R_GetPlaneLight(frontsector, planecenterz, viewz < heightcheck);
|
||||
|
||||
ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic,
|
||||
ffloor[numffloors].plane = R_FindPlane(
|
||||
*rover->topheight, *rover->toppic,
|
||||
*frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle,
|
||||
*frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->t_slope,
|
||||
R_NoEncore(rover->master->frontsector, false),
|
||||
R_IsRipplePlane(rover->master->frontsector, rover, false));
|
||||
R_IsRipplePlane(rover->master->frontsector, rover, false),
|
||||
false
|
||||
);
|
||||
|
||||
ffloor[numffloors].slope = *rover->t_slope;
|
||||
|
||||
|
|
@ -1069,12 +1084,16 @@ static void R_Subsector(size_t num)
|
|||
{
|
||||
light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight);
|
||||
|
||||
ffloor[numffloors].plane = R_FindPlane(polysec->floorheight, polysec->floorpic,
|
||||
ffloor[numffloors].plane = R_FindPlane(
|
||||
polysec->floorheight, polysec->floorpic,
|
||||
(light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->floor_xoffs, polysec->floor_yoffs,
|
||||
polysec->floorpic_angle-po->angle,
|
||||
(light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po,
|
||||
NULL, // will ffloors be slopable eventually?
|
||||
R_NoEncore(polysec, false), false);/* TODO: wet polyobjects? */
|
||||
R_NoEncore(polysec, false),
|
||||
false, /* TODO: wet polyobjects? */
|
||||
true
|
||||
);
|
||||
|
||||
ffloor[numffloors].height = polysec->floorheight;
|
||||
ffloor[numffloors].polyobj = po;
|
||||
|
|
@ -1095,11 +1114,15 @@ static void R_Subsector(size_t num)
|
|||
{
|
||||
light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight);
|
||||
|
||||
ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic,
|
||||
ffloor[numffloors].plane = R_FindPlane(
|
||||
polysec->ceilingheight, polysec->ceilingpic,
|
||||
(light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->ceiling_xoffs, polysec->ceiling_yoffs, polysec->ceilingpic_angle-po->angle,
|
||||
(light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po,
|
||||
NULL, // will ffloors be slopable eventually?
|
||||
R_NoEncore(polysec, true), false);/* TODO: wet polyobjects? */
|
||||
R_NoEncore(polysec, true),
|
||||
false, /* TODO: wet polyobjects? */
|
||||
false
|
||||
);
|
||||
|
||||
ffloor[numffloors].polyobj = po;
|
||||
ffloor[numffloors].height = polysec->ceilingheight;
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ static visplane_t *new_visplane(unsigned hash)
|
|||
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
||||
fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap,
|
||||
ffloor_t *pfloor, polyobj_t *polyobj, pslope_t *slope, boolean noencore,
|
||||
boolean ripple)
|
||||
boolean ripple, boolean reverseLight)
|
||||
{
|
||||
visplane_t *check;
|
||||
unsigned hash;
|
||||
|
|
@ -386,9 +386,16 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
|||
}
|
||||
}
|
||||
|
||||
if (slope != NULL && P_ApplyLightOffset(lightlevel))
|
||||
if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT))
|
||||
{
|
||||
lightlevel += slope->lightOffset * 8;
|
||||
if (reverseLight)
|
||||
{
|
||||
lightlevel -= slope->lightOffset * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
lightlevel += slope->lightOffset * 8;
|
||||
}
|
||||
}
|
||||
|
||||
// This appears to fix the Nimbus Ruins sky bug.
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void R_ClearFFloorClips (void);
|
|||
void R_DrawPlanes(void);
|
||||
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle,
|
||||
extracolormap_t *planecolormap, ffloor_t *ffloor, polyobj_t *polyobj, pslope_t *slope, boolean noencore,
|
||||
boolean ripple);
|
||||
boolean ripple, boolean reverseLight);
|
||||
visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop);
|
||||
void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop);
|
||||
void R_PlaneBounds(visplane_t *plane);
|
||||
|
|
|
|||
12
src/r_segs.c
12
src/r_segs.c
|
|
@ -286,7 +286,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
|||
|
||||
if (rlight->extra_colormap && (rlight->extra_colormap->flags & CMF_FOG))
|
||||
;
|
||||
else if (P_ApplyLightOffset(lightnum << LIGHTSEGSHIFT))
|
||||
else if (P_ApplyLightOffset(lightnum))
|
||||
lightnum += curline->lightOffset;
|
||||
|
||||
rlight->lightnum = lightnum;
|
||||
|
|
@ -303,7 +303,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
|||
if ((R_CheckColumnFunc(COLDRAWFUNC_FOG) == true)
|
||||
|| (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG)))
|
||||
;
|
||||
else if (P_ApplyLightOffset(lightnum << LIGHTSEGSHIFT))
|
||||
else if (P_ApplyLightOffset(lightnum))
|
||||
lightnum += curline->lightOffset;
|
||||
|
||||
if (lightnum < 0)
|
||||
|
|
@ -770,7 +770,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
|||
|
||||
if (pfloor->flags & FF_FOG || rlight->flags & FF_FOG || (rlight->extra_colormap && (rlight->extra_colormap->flags & CMF_FOG)))
|
||||
;
|
||||
else if (P_ApplyLightOffset(rlight->lightnum << LIGHTSEGSHIFT))
|
||||
else if (P_ApplyLightOffset(rlight->lightnum))
|
||||
rlight->lightnum += curline->lightOffset;
|
||||
|
||||
p++;
|
||||
|
|
@ -793,7 +793,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
|||
|
||||
if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG)))
|
||||
;
|
||||
else if (P_ApplyLightOffset(lightnum << LIGHTSEGSHIFT))
|
||||
else if (P_ApplyLightOffset(lightnum))
|
||||
lightnum += curline->lightOffset;
|
||||
|
||||
if (lightnum < 0)
|
||||
|
|
@ -1383,7 +1383,7 @@ static void R_RenderSegLoop (void)
|
|||
|
||||
if (dc_lightlist[i].extra_colormap)
|
||||
;
|
||||
else if (P_ApplyLightOffset(lightnum << LIGHTSEGSHIFT))
|
||||
else if (P_ApplyLightOffset(lightnum))
|
||||
lightnum += curline->lightOffset;
|
||||
|
||||
if (lightnum < 0)
|
||||
|
|
@ -2436,7 +2436,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
|||
// OPTIMIZE: get rid of LIGHTSEGSHIFT globally
|
||||
lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT);
|
||||
|
||||
if (P_ApplyLightOffset(lightnum << LIGHTSEGSHIFT))
|
||||
if (P_ApplyLightOffset(lightnum))
|
||||
lightnum += curline->lightOffset;
|
||||
|
||||
if (lightnum < 0)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue