Merge branch 'mirrorfixes' into 'master'

Mirror fixes

See merge request KartKrew/Kart!385
This commit is contained in:
James R 2021-02-16 11:33:13 -05:00
commit 3ac803be76
11 changed files with 52 additions and 25 deletions

View file

@ -478,7 +478,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
#ifdef GLENCORE
if (encoremap)
grtex->mipmap.colormap += (256*32);
grtex->mipmap.colormap += COLORMAP_REMAPOFFSET;
#endif
blockwidth = texture->width;
@ -833,7 +833,7 @@ void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
#ifdef GLENCORE
if (!noencoremap && encoremap)
grmip->colormap += (256*32);
grmip->colormap += COLORMAP_REMAPOFFSET;
#endif
grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap;

View file

@ -5224,7 +5224,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
vis->colormap = colormaps;
#ifdef GLENCORE
if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK)) && !(thing->flags & MF_DONTENCOREMAP))
vis->colormap += (256*32);
vis->colormap += COLORMAP_REMAPOFFSET;
#endif
}
@ -5331,7 +5331,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
#ifdef GLENCORE
if (encoremap && !(thing->flags & MF_DONTENCOREMAP))
vis->colormap += (256*32);
vis->colormap += COLORMAP_REMAPOFFSET;
#endif
// set top/bottom coords
@ -5526,6 +5526,11 @@ static void HWR_DrawSkyBackground(player_t *player)
else
dometransform.flip = false;
if (*type == postimg_mirror)
dometransform.mirror = true;
else
dometransform.mirror = false;
dometransform.scalex = 1;
dometransform.scaley = (float)vid.width/vid.height;
dometransform.scalez = 1;
@ -5802,6 +5807,11 @@ void HWR_RenderSkyboxView(player_t *player)
else
atransform.flip = false;
if (*type == postimg_mirror)
atransform.mirror = true;
else
atransform.mirror = false;
atransform.x = gl_viewx; // FIXED_TO_FLOAT(viewx)
atransform.y = gl_viewy; // FIXED_TO_FLOAT(viewy)
atransform.z = gl_viewz; // FIXED_TO_FLOAT(viewz)
@ -6005,6 +6015,11 @@ void HWR_RenderPlayerView(void)
else
atransform.flip = false;
if (*type == postimg_mirror)
atransform.mirror = true;
else
atransform.mirror = false;
atransform.x = gl_viewx; // FIXED_TO_FLOAT(viewx)
atransform.y = gl_viewy; // FIXED_TO_FLOAT(viewy)
atransform.z = gl_viewz; // FIXED_TO_FLOAT(viewz)

View file

@ -3080,6 +3080,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
{
// Do not move the camera while in hitlag!
// The camera zooming out after you got hit makes it hard to focus on the vibration.
// of course, if you're in chase, don't forget the postimage - otherwise encore will flip back
if (thiscam->chase)
P_CalcChasePostImg(player, thiscam);
return true;
}

View file

@ -287,7 +287,9 @@ static void R_InitColormaps(void)
// Load in the light tables
lump = W_GetNumForName("COLORMAP");
len = W_LumpLength(lump);
colormaps = Z_MallocAlign(len * 2, PU_STATIC, NULL, 8); // * 2 for encore
if (len < COLORMAP_SIZE*2) // accomodate encore mode later
len = COLORMAP_SIZE*2;
colormaps = Z_MallocAlign(len, PU_STATIC, NULL, 8);
W_ReadLump(lump, colormaps);
// no need to init encoremap at this stage
@ -330,9 +332,9 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap)
encoremap = Z_MallocAlign(256 + 10, PU_LEVEL, NULL, 8);
W_ReadLump(newencoremap, encoremap);
colormap_p = colormap_p2 = colormaps;
colormap_p += (256 * 32);
colormap_p += COLORMAP_REMAPOFFSET;
for (p = 0; p < 32; p++)
for (p = 0; p < LIGHTLEVELS; p++)
{
for (i = 0; i < 256; i++)
{
@ -731,12 +733,12 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
// Now allocate memory for the actual colormap array itself!
// aligned on 8 bit for asm code
colormap_p = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8);
colormap_p = Z_MallocAlign((COLORMAP_SIZE * (encoremap ? 2 : 1)) + 10, PU_LEVEL, NULL, 8);
lighttable = (UINT8 *)colormap_p;
// Calculate the palette index for each palette index, for each light level
// (as well as the two unused colormap lines we inherited from Doom)
for (p = 0; p < 32; p++)
for (p = 0; p < LIGHTLEVELS; p++)
{
for (i = 0; i < 256; i++)
{
@ -776,7 +778,7 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
{
lighttable_t *colormap_p2 = lighttable;
for (p = 0; p < 32; p++)
for (p = 0; p < LIGHTLEVELS; p++)
{
for (i = 0; i < 256; i++)
{

View file

@ -1698,7 +1698,7 @@ void R_DrawColumnShadowed_8(void)
{
dc_colormap = dc_lightlist[i].rcolormap;
if (encoremap)
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
if (solid && dc_yl < bheight)
dc_yl = bheight;
continue;
@ -1716,7 +1716,7 @@ void R_DrawColumnShadowed_8(void)
dc_colormap = dc_lightlist[i].rcolormap;
if (encoremap)
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
}
dc_yh = realyh;
if (dc_yl <= realyh)

View file

@ -41,7 +41,7 @@ extern size_t validcount, linecount, loopcount, framecount;
// Lighting constants.
// Now with 32 levels.
#define LIGHTLEVELS 32
// LIGHTLEVELS is now defined in r_state.h
#define LIGHTSEGSHIFT 3
#define MAXLIGHTSCALE 48

View file

@ -232,7 +232,7 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
ds_colormap = planezlight[pindex];
if (encoremap && !currentplane->noencore)
ds_colormap += (256*32);
ds_colormap += COLORMAP_REMAPOFFSET;
if (currentplane->extra_colormap)
ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps);
@ -644,6 +644,8 @@ static void R_DrawSkyPlane(visplane_t *pl)
// Because of this hack, sky is not affected
// by sector colormaps (INVUL inverse mapping is not implemented in SRB2 so is irrelevant).
dc_colormap = colormaps;
if (encoremap)
dc_colormap += COLORMAP_REMAPOFFSET;
dc_texturemid = skytexturemid;
dc_texheight = textureheight[skytexture]
>>FRACBITS;

View file

@ -203,7 +203,7 @@ static void R_DrawWallSplats(void)
pindex = MAXLIGHTSCALE - 1;
dc_colormap = walllights[pindex];
if (encoremap && !(seg->linedef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
if (frontsector->extra_colormap)
dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
@ -578,7 +578,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
{
dc_colormap = rlight->rcolormap;
if (encoremap && !(ldef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
continue;
}
@ -599,7 +599,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
windowtop = windowbottom + 1;
dc_colormap = rlight->rcolormap;
if (encoremap && !(ldef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
}
windowbottom = realbot;
if (windowtop < windowbottom)
@ -617,7 +617,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
dc_colormap = walllights[pindex];
if (encoremap && !(ldef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
if (frontsector->extra_colormap)
dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
@ -1163,7 +1163,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{
dc_colormap = rlight->rcolormap;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
}
if (solid && windowtop < bheight)
windowtop = bheight;
@ -1195,7 +1195,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{
dc_colormap = rlight->rcolormap;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
}
}
windowbottom = sprbotscreen;
@ -1216,7 +1216,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
dc_colormap = walllights[pindex];
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
if (pfloor->flags & FF_FOG && pfloor->master->frontsector->extra_colormap)
dc_colormap = pfloor->master->frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
@ -1476,7 +1476,7 @@ static void R_RenderSegLoop (void)
dc_colormap = walllights[pindex];
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
dc_x = rw_x;
dc_iscale = 0xffffffffu / (unsigned)rw_scale;

View file

@ -44,6 +44,10 @@ extern UINT8 *encoremap;
extern UINT8 invertmap[256];
#endif
#define LIGHTLEVELS 32
#define COLORMAP_SIZE (256*LIGHTLEVELS)
#define COLORMAP_REMAPOFFSET COLORMAP_SIZE
// Boom colormaps.
extern extracolormap_t *extra_colormaps;

View file

@ -863,7 +863,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
dc_colormap = colormaps;
if (encoremap && !vis->mobj->color && !(vis->mobj->flags & MF_DONTENCOREMAP))
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
dc_texturemid = vis->texturemid;
dc_texheight = 0;
@ -993,7 +993,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
dc_colormap = colormaps;
if (encoremap)
dc_colormap += (256*32);
dc_colormap += COLORMAP_REMAPOFFSET;
dc_iscale = FixedDiv(FRACUNIT, vis->scale);
dc_texturemid = vis->texturemid;

View file

@ -1454,7 +1454,7 @@ void V_DrawCustomFadeScreen(const char *lump, UINT8 strength)
if (lumpnum != LUMPERROR)
{
clm = Z_MallocAlign((256 * 32), PU_STATIC, NULL, 8);
clm = Z_MallocAlign(COLORMAP_SIZE, PU_STATIC, NULL, 8);
W_ReadLump(lumpnum, clm);
if (clm != NULL)