Merge branch 'floorsprite-fixes' into 'next'

Floorsprite fixes

See merge request STJr/SRB2!1443
This commit is contained in:
LJ Sonic 2021-03-31 12:36:39 -04:00
commit 7ab1a82d09
8 changed files with 23 additions and 53 deletions

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team. // 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 // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -30,10 +30,6 @@
#include "byteptr.h" #include "byteptr.h"
#include "dehacked.h" #include "dehacked.h"
#ifdef _WIN32
#include <malloc.h> // alloca(sizeof)
#endif
// //
// Graphics. // Graphics.
// SRB2 graphics for walls and sprites // SRB2 graphics for walls and sprites

View file

@ -1,7 +1,7 @@
// SONIC ROBO BLAST 2 // SONIC ROBO BLAST 2
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team. // 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 // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // 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 // 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 // have the uber complicated math to calculate it now, so that was a memory write we didn't
// need! // need!
//
// <Callum> 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size)
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[0] = colormap[translation[val & 0xFF]]; dest[0] = colormap[translation[val & 0xFF]];
@ -1458,7 +1455,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[1] = colormap[translation[val & 0xFF]]; dest[1] = colormap[translation[val & 0xFF]];
@ -1466,7 +1462,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[2] = colormap[translation[val & 0xFF]]; dest[2] = colormap[translation[val & 0xFF]];
@ -1474,7 +1469,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[3] = colormap[translation[val & 0xFF]]; dest[3] = colormap[translation[val & 0xFF]];
@ -1482,7 +1476,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[4] = colormap[translation[val & 0xFF]]; dest[4] = colormap[translation[val & 0xFF]];
@ -1490,7 +1483,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[5] = colormap[translation[val & 0xFF]]; dest[5] = colormap[translation[val & 0xFF]];
@ -1498,7 +1490,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[6] = colormap[translation[val & 0xFF]]; dest[6] = colormap[translation[val & 0xFF]];
@ -1506,7 +1497,6 @@ void R_DrawFloorSprite_8 (void)
yposition += ystep; yposition += ystep;
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
val &= 4194303;
val = source[val]; val = source[val];
if (val & 0xFF00) if (val & 0xFF00)
dest[7] = colormap[translation[val & 0xFF]]; dest[7] = colormap[translation[val & 0xFF]];

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team. // 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 // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -154,14 +154,10 @@ static void R_UpdatePlaneRipple(void)
// R_MapPlane // R_MapPlane
// //
// Uses global vars: // Uses global vars:
// planeheight
// basexscale // basexscale
// baseyscale // baseyscale
// centerx // centerx
// viewx
// viewy
// viewsin
// viewcos
// viewheight
void R_MapPlane(INT32 y, INT32 x1, INT32 x2) 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) 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 (t1 >= vid.height) t1 = vid.height-1;
if (b1 >= vid.height) b1 = vid.height-1; if (b1 >= vid.height) b1 = vid.height-1;
if (t2 >= vid.height) t2 = 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) void R_DrawPlanes(void)
{ {
visplane_t *pl; visplane_t *pl;
angle_t va = viewangle;
INT32 i; INT32 i;
R_UpdatePlaneRipple(); R_UpdatePlaneRipple();
@ -622,8 +617,6 @@ void R_DrawPlanes(void)
R_DrawSinglePlane(pl); R_DrawSinglePlane(pl);
} }
} }
viewangle = va;
} }
// R_DrawSkyPlane // R_DrawSkyPlane

View file

@ -1,7 +1,7 @@
// SONIC ROBO BLAST 2 // SONIC ROBO BLAST 2
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team. // 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 // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -28,11 +28,12 @@ static void prepare_rastertab(void);
// FLOOR SPLATS // FLOOR SPLATS
// ========================================================================== // ==========================================================================
static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis);
#ifdef USEASM #ifdef USEASM
void ASMCALL rasterize_segment_tex_asm(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir); void ASMCALL rasterize_segment_tex_asm(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir);
#endif #endif
// Lactozilla
static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir) static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir)
{ {
#ifdef USEASM #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; floorsplat_t splat;
mobj_t *mobj = spr->mobj; mobj_t *mobj = spr->mobj;
@ -187,7 +188,7 @@ void R_DrawFloorSprite(vissprite_t *spr)
if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD) if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD)
splatangle = mobj->angle; splatangle = mobj->angle;
else else
splatangle = viewangle; splatangle = spr->viewangle;
if (!(spr->cut & SC_ISROTATED)) if (!(spr->cut & SC_ISROTATED))
splatangle += mobj->rollangle; splatangle += mobj->rollangle;
@ -265,7 +266,6 @@ void R_DrawFloorSprite(vissprite_t *spr)
if (splat.tilted) if (splat.tilted)
{ {
// Lactozilla: Just copy the entire slope LMFAOOOO
pslope_t *s = &splat.slope; pslope_t *s = &splat.slope;
s->o.x = slope->o.x; 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; 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 // fill the polygon with linear interpolation, call span drawer for each
// scan line // 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 // rasterizing
INT32 miny = viewheight + 1, maxy = 0; 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()) if (R_CheckPowersOfTwo())
R_CheckFlatLength(ds_flatwidth * ds_flatheight); R_CheckFlatLength(ds_flatwidth * ds_flatheight);
// Lactozilla: I don't know what I'm doing
if (pSplat->tilted) if (pSplat->tilted)
{ {
R_SetTiltedSpan(0); 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; spanfunctype = SPANDRAWFUNC_TILTEDSPRITE;
} }
else else
@ -533,7 +532,7 @@ void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis
fixed_t xstep, ystep; fixed_t xstep, ystep;
fixed_t distance, span; 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 planecos = FINECOSINE(angle);
angle_t planesin = FINESINE(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]); distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]);
span = abs(centery - y); span = abs(centery - y);
if (span) // don't divide by zero if (span) // Don't divide by zero
{ {
xstep = FixedMul(planesin, planeheight) / span; xstep = FixedMul(planesin, planeheight) / span;
ystep = FixedMul(planecos, planeheight) / span; ystep = FixedMul(planecos, planeheight) / span;
} }
else else
{ xstep = ystep = FRACUNIT;
// ah
xstep = FRACUNIT;
ystep = FRACUNIT;
}
cachedxstep[y] = xstep; cachedxstep[y] = xstep;
cachedystep[y] = ystep; cachedystep[y] = ystep;

View file

@ -42,7 +42,6 @@ typedef struct floorsplat_s
mobj_t *mobj; // Mobj it is tied to mobj_t *mobj; // Mobj it is tied to
} floorsplat_t; } floorsplat_t;
void R_DrawFloorSprite(vissprite_t *spr); void R_DrawFloorSplat(vissprite_t *spr);
void R_RenderFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis);
#endif /*__R_SPLATS_H__*/ #endif /*__R_SPLATS_H__*/

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team. // 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 // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -28,11 +28,6 @@
#include "byteptr.h" #include "byteptr.h"
#include "dehacked.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 #ifdef HWRENDER
#include "hardware/hw_glob.h" // HWR_LoadMapTextures #include "hardware/hw_glob.h" // HWR_LoadMapTextures
#endif #endif
@ -626,7 +621,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat)
// //
// R_CheckPowersOfTwo // R_CheckPowersOfTwo
// //
// Self-explanatory? // Sets ds_powersoftwo true if the flat's dimensions are powers of two, and returns that.
// //
boolean R_CheckPowersOfTwo(void) boolean R_CheckPowersOfTwo(void)
{ {

View file

@ -2,7 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team. // 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 // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -1956,6 +1956,7 @@ static void R_ProjectSprite(mobj_t *thing)
vis->paperoffset = paperoffset; vis->paperoffset = paperoffset;
vis->paperdistance = paperdistance; vis->paperdistance = paperdistance;
vis->centerangle = centerangle; vis->centerangle = centerangle;
vis->viewangle = viewangle;
vis->shear.tan = sheartan; vis->shear.tan = sheartan;
vis->shear.offset = 0; vis->shear.offset = 0;
@ -2783,7 +2784,7 @@ static void R_DrawSprite(vissprite_t *spr)
mceilingclip = spr->cliptop; mceilingclip = spr->cliptop;
if (spr->cut & SC_SPLAT) if (spr->cut & SC_SPLAT)
R_DrawFloorSprite(spr); R_DrawFloorSplat(spr);
else else
R_DrawVisSprite(spr); R_DrawVisSprite(spr);
} }

View file

@ -164,6 +164,7 @@ typedef struct vissprite_s
fixed_t xiscale; // negative if flipped fixed_t xiscale; // negative if flipped
angle_t centerangle; // for paper sprites angle_t centerangle; // for paper sprites
angle_t viewangle; // for floor sprites, the viewpoint's current angle
struct { struct {
fixed_t tan; // The amount to shear the sprite vertically per row fixed_t tan; // The amount to shear the sprite vertically per row