mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
[Software] A few floorsprite fixes
This fixes the texture of the floorsprite sometimes facing the wrong way, since plane rendering can change the view angle.
This commit is contained in:
parent
df9b5c4312
commit
4025a1d517
8 changed files with 23 additions and 53 deletions
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2021 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -30,10 +30,6 @@
|
|||
#include "byteptr.h"
|
||||
#include "dehacked.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h> // alloca(sizeof)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Graphics.
|
||||
// SRB2 graphics for walls and sprites
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2021 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -1447,10 +1447,7 @@ void R_DrawFloorSprite_8 (void)
|
|||
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
|
||||
// have the uber complicated math to calculate it now, so that was a memory write we didn't
|
||||
// need!
|
||||
//
|
||||
// <Callum> 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size)
|
||||
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val & 0xFF00)
|
||||
dest[0] = colormap[translation[val & 0xFF]];
|
||||
|
@ -1458,7 +1455,6 @@ void R_DrawFloorSprite_8 (void)
|
|||
yposition += ystep;
|
||||
|
||||
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val & 0xFF00)
|
||||
dest[1] = colormap[translation[val & 0xFF]];
|
||||
|
@ -1466,7 +1462,6 @@ void R_DrawFloorSprite_8 (void)
|
|||
yposition += ystep;
|
||||
|
||||
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val & 0xFF00)
|
||||
dest[2] = colormap[translation[val & 0xFF]];
|
||||
|
@ -1474,7 +1469,6 @@ void R_DrawFloorSprite_8 (void)
|
|||
yposition += ystep;
|
||||
|
||||
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val & 0xFF00)
|
||||
dest[3] = colormap[translation[val & 0xFF]];
|
||||
|
@ -1482,7 +1476,6 @@ void R_DrawFloorSprite_8 (void)
|
|||
yposition += ystep;
|
||||
|
||||
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val & 0xFF00)
|
||||
dest[4] = colormap[translation[val & 0xFF]];
|
||||
|
@ -1490,7 +1483,6 @@ void R_DrawFloorSprite_8 (void)
|
|||
yposition += ystep;
|
||||
|
||||
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val & 0xFF00)
|
||||
dest[5] = colormap[translation[val & 0xFF]];
|
||||
|
@ -1498,7 +1490,6 @@ void R_DrawFloorSprite_8 (void)
|
|||
yposition += ystep;
|
||||
|
||||
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val & 0xFF00)
|
||||
dest[6] = colormap[translation[val & 0xFF]];
|
||||
|
@ -1506,7 +1497,6 @@ void R_DrawFloorSprite_8 (void)
|
|||
yposition += ystep;
|
||||
|
||||
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val & 0xFF00)
|
||||
dest[7] = colormap[translation[val & 0xFF]];
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2021 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -154,14 +154,10 @@ static void R_UpdatePlaneRipple(void)
|
|||
// R_MapPlane
|
||||
//
|
||||
// Uses global vars:
|
||||
// planeheight
|
||||
// basexscale
|
||||
// baseyscale
|
||||
// centerx
|
||||
// viewx
|
||||
// viewy
|
||||
// viewsin
|
||||
// viewcos
|
||||
// viewheight
|
||||
|
||||
void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
|
||||
{
|
||||
|
@ -580,7 +576,7 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop)
|
|||
//
|
||||
void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2)
|
||||
{
|
||||
// Alam: from r_splats's R_RenderFloorSplat
|
||||
// Alam: from r_splats's R_RasterizeFloorSplat
|
||||
if (t1 >= vid.height) t1 = vid.height-1;
|
||||
if (b1 >= vid.height) b1 = vid.height-1;
|
||||
if (t2 >= vid.height) t2 = vid.height-1;
|
||||
|
@ -607,7 +603,6 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2)
|
|||
void R_DrawPlanes(void)
|
||||
{
|
||||
visplane_t *pl;
|
||||
angle_t va = viewangle;
|
||||
INT32 i;
|
||||
|
||||
R_UpdatePlaneRipple();
|
||||
|
@ -622,8 +617,6 @@ void R_DrawPlanes(void)
|
|||
R_DrawSinglePlane(pl);
|
||||
}
|
||||
}
|
||||
|
||||
viewangle = va;
|
||||
}
|
||||
|
||||
// R_DrawSkyPlane
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2021 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -28,11 +28,12 @@ static void prepare_rastertab(void);
|
|||
// FLOOR SPLATS
|
||||
// ==========================================================================
|
||||
|
||||
static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis);
|
||||
|
||||
#ifdef USEASM
|
||||
void ASMCALL rasterize_segment_tex_asm(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir);
|
||||
#endif
|
||||
|
||||
// Lactozilla
|
||||
static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir)
|
||||
{
|
||||
#ifdef USEASM
|
||||
|
@ -137,7 +138,7 @@ static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32
|
|||
}
|
||||
}
|
||||
|
||||
void R_DrawFloorSprite(vissprite_t *spr)
|
||||
void R_DrawFloorSplat(vissprite_t *spr)
|
||||
{
|
||||
floorsplat_t splat;
|
||||
mobj_t *mobj = spr->mobj;
|
||||
|
@ -187,7 +188,7 @@ void R_DrawFloorSprite(vissprite_t *spr)
|
|||
if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD)
|
||||
splatangle = mobj->angle;
|
||||
else
|
||||
splatangle = viewangle;
|
||||
splatangle = spr->viewangle;
|
||||
|
||||
if (!(spr->cut & SC_ISROTATED))
|
||||
splatangle += mobj->rollangle;
|
||||
|
@ -265,7 +266,6 @@ void R_DrawFloorSprite(vissprite_t *spr)
|
|||
|
||||
if (splat.tilted)
|
||||
{
|
||||
// Lactozilla: Just copy the entire slope LMFAOOOO
|
||||
pslope_t *s = &splat.slope;
|
||||
|
||||
s->o.x = slope->o.x;
|
||||
|
@ -330,7 +330,7 @@ void R_DrawFloorSprite(vissprite_t *spr)
|
|||
v2d[i].y = (centeryfrac + FixedMul(rot_z, yscale))>>FRACBITS;
|
||||
}
|
||||
|
||||
R_RenderFloorSplat(&splat, v2d, spr);
|
||||
R_RasterizeFloorSplat(&splat, v2d, spr);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
@ -338,7 +338,7 @@ void R_DrawFloorSprite(vissprite_t *spr)
|
|||
// fill the polygon with linear interpolation, call span drawer for each
|
||||
// scan line
|
||||
// --------------------------------------------------------------------------
|
||||
void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis)
|
||||
static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis)
|
||||
{
|
||||
// rasterizing
|
||||
INT32 miny = viewheight + 1, maxy = 0;
|
||||
|
@ -416,11 +416,10 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis
|
|||
if (R_CheckPowersOfTwo())
|
||||
R_CheckFlatLength(ds_flatwidth * ds_flatheight);
|
||||
|
||||
// Lactozilla: I don't know what I'm doing
|
||||
if (pSplat->tilted)
|
||||
{
|
||||
R_SetTiltedSpan(0);
|
||||
R_CalculateSlopeVectors(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, viewangle, pSplat->angle, 1.0f);
|
||||
R_CalculateSlopeVectors(&pSplat->slope, viewx, viewy, viewz, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewangle, pSplat->angle, 1.0f);
|
||||
spanfunctype = SPANDRAWFUNC_TILTEDSPRITE;
|
||||
}
|
||||
else
|
||||
|
@ -533,7 +532,7 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis
|
|||
fixed_t xstep, ystep;
|
||||
fixed_t distance, span;
|
||||
|
||||
angle_t angle = (viewangle + pSplat->angle)>>ANGLETOFINESHIFT;
|
||||
angle_t angle = (vis->viewangle + pSplat->angle)>>ANGLETOFINESHIFT;
|
||||
angle_t planecos = FINECOSINE(angle);
|
||||
angle_t planesin = FINESINE(angle);
|
||||
|
||||
|
@ -543,17 +542,13 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis
|
|||
distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]);
|
||||
span = abs(centery - y);
|
||||
|
||||
if (span) // don't divide by zero
|
||||
if (span) // Don't divide by zero
|
||||
{
|
||||
xstep = FixedMul(planesin, planeheight) / span;
|
||||
ystep = FixedMul(planecos, planeheight) / span;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ah
|
||||
xstep = FRACUNIT;
|
||||
ystep = FRACUNIT;
|
||||
}
|
||||
xstep = ystep = FRACUNIT;
|
||||
|
||||
cachedxstep[y] = xstep;
|
||||
cachedystep[y] = ystep;
|
||||
|
|
|
@ -42,7 +42,6 @@ typedef struct floorsplat_s
|
|||
mobj_t *mobj; // Mobj it is tied to
|
||||
} floorsplat_t;
|
||||
|
||||
void R_DrawFloorSprite(vissprite_t *spr);
|
||||
void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis);
|
||||
void R_DrawFloorSplat(vissprite_t *spr);
|
||||
|
||||
#endif /*__R_SPLATS_H__*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2021 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -28,11 +28,6 @@
|
|||
#include "byteptr.h"
|
||||
#include "dehacked.h"
|
||||
|
||||
// I don't know what this is even for, but r_data.c had it.
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h> // alloca(sizeof)
|
||||
#endif
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_glob.h" // HWR_LoadMapTextures
|
||||
#endif
|
||||
|
@ -626,7 +621,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat)
|
|||
//
|
||||
// R_CheckPowersOfTwo
|
||||
//
|
||||
// Self-explanatory?
|
||||
// Sets ds_powersoftwo true if the flat's dimensions are powers of two, and returns that.
|
||||
//
|
||||
boolean R_CheckPowersOfTwo(void)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2021 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -1956,6 +1956,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
vis->paperoffset = paperoffset;
|
||||
vis->paperdistance = paperdistance;
|
||||
vis->centerangle = centerangle;
|
||||
vis->viewangle = viewangle;
|
||||
vis->shear.tan = sheartan;
|
||||
vis->shear.offset = 0;
|
||||
|
||||
|
@ -2783,7 +2784,7 @@ static void R_DrawSprite(vissprite_t *spr)
|
|||
mceilingclip = spr->cliptop;
|
||||
|
||||
if (spr->cut & SC_SPLAT)
|
||||
R_DrawFloorSprite(spr);
|
||||
R_DrawFloorSplat(spr);
|
||||
else
|
||||
R_DrawVisSprite(spr);
|
||||
}
|
||||
|
|
|
@ -164,6 +164,7 @@ typedef struct vissprite_s
|
|||
fixed_t xiscale; // negative if flipped
|
||||
|
||||
angle_t centerangle; // for paper sprites
|
||||
angle_t viewangle; // for floor sprites, the viewpoint's current angle
|
||||
|
||||
struct {
|
||||
fixed_t tan; // The amount to shear the sprite vertically per row
|
||||
|
|
Loading…
Reference in a new issue