mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-03-15 23:52:38 +00:00
Squashed SRB2 2.2 Public uncapped without UDMF merge
Implement interpolation at the renderer level
Instead of interpolating thinkers, we interpolate mobjs inside the
renderer. Further interpolation is TBI.
Place Frame Interpolation in "Experimental" video options header
This seems like an appropriate way to describe the feature for now.
Add smooth level platter under interpolation, `renderdeltatics`
`renderdeltatics` can be used as a standard delta time in any place,
allowing for smooth menus. It will always be equal to `realtics`
when frame interpolation is turned off, producing consistent
framerate behavior everywhere it is used.
Add smooth rendering to save select screen
Add smooth rendering to Record/NiGHTS Attack, F_SkyScroll
Ensure viewsector is accurate to viewx/viewy
This fixes a potential crash in OpenGL when changing between levels.
Ensure + commands get executed before map start
Always have precise_t defined
Fix misc dropshadow issues
Reset view interpolation on level load
Remove unnecessary precipmobj thinker hack
Add reset interpolation state functions
Reset precip interpolation on snap to ceil
Reset mobj interp state on TeleportMove
Only swap view interp state if a tick is run
Run anti-lag chasecam at tic frequency
Fixes jittery and unstable chasecam in high latency netgames
Homogenize mobj interpolations
Add sector plane level interpolations
Add SectorScroll interpolator
Add SideScroll interpolator
Add Polyobj interpolator
Intialize interpolator list at a better time
Delete interpolators associated with thinkers
Interpolate mobj angles and player drawangle
Interpolate HWR_DrawModel
Add functions to handle interpolation
Much less code duplication
P_InitAngle, to fix angle interpolation on spawning objects
Fully fix drop shadows
It used the thing's floorz / ceilingz directly -- that wouldn't account for interpolated coordinates.
Do not speed up underwater/heatwave effect in OpenGL
Closer OpenGL underwater/heatwave effect to Software
Interpolate from time of previous tic
Previously interpolated from last 35th of a second, which
may be offset from game time due to connection lag.
Consider this the proper fix to 6ecac4159a too.
Calculate FPS stuff even if frame is skipped
I decided ultimately to actually keep the frame skip optimization disabled, because I think it is actually a little bit helpful that you can still get accurate rendering perfstats while paused, however if we decide otherwise then we can have this optimization back without making the game act like it's lagging.
Keep rect in memory
Feel better about this than creating one all da time
Lots of FPS stuff
- Disabled VSync, due to the numerous problems it has.
- Instead, added an FPS cap.
- Frame interpolation is now tied to fpscap != 35.
- By default, the FPS cap is set to the monitor's refresh rate.
- Rewrote the FPS counter.
(This also consolidates several more commits ahead of this
fixing various issues. -eid)
Misc changes after Kart cherry-picks
Fix renderdeltatics with new timing data
Update mobj oldstates before all thinkers
Allow FPS cap values
Adjust how FPS cap is checked to improve FPS stability
Fix precip crash from missing vars
Improve the framerate limiter's timing for extreme stable FPS
Handle the sleep at the end of D_SRB2Loop instead of the start
Simplifies logic in the other parts of the loop, and fixes problems with it frequently waiting too long.
Reset mobj interp state on add
Add mobj interpolator on load netgame
Move mobj interpolators to r_fps
Dynamic slope interpolators
I_GetFrameTime to try and improve frame pace
(It doesn't feel that much better though.)
Move I_FinishUpdate to D_SRB2Loop to sync screen updates with FPS cap, use timestamps in I_FrameCapSleep to simplify the code
Fix plane interpolation light level flickering
Fix flickering plane interpolation for OpenGL in the exact same way
Funny OpenGL renderer being at least 50% copy-pasted Software code :)
P_SetOrigin & P_MoveOrigin to replace P_TeleportMove
Convert P_TeleportMove use to origin funcs
Revert "P_InitAngle, to fix angle interpolation on spawning objects"
This reverts commit a80c98bd164a2748cbbfad9027b34601185d93f5.
Waypoint polyobjects interpolate z & children
Add interpolation to more moving plane types
Adds interpolation to the following:
- Crumbling platforms
- Mario blocks
- Floatbob platforms (this one works really strangely due to two thinkers, maybe double-check this one?)
Reset overlays interp states each TryRunTics
Interpolate model interpolation (lol)
Use interp tracer pos for GL linkdraw
Papersprite angle interpolation
Makes the ending signpost smooth
Move intermission emerald bounce to ticker
Bring back shadows on polyobjects
Also optimizes the method used so rings can show their shadows too. Using just the subsector is a tad bit imprecise admittedly but any more precise methods get really laggy.
Fix a bunch of ticking in hu_ drawing functions
Revert "Reset overlays interp states each TryRunTics"
This reverts commit a71a216faa20e8751b3bd0157354e8d748940c92.
Move intro ticking out of the drawer
Adjust 1up monitor icon z offsets
Fixes interpolation issues with 1up monitors.
Delta time choose player menu animations
Add drawerlib deltaTime function
Interpolate afterimages further back
Use old sleep in dedicated mode
Clamp cechotimer to 0
Fixes issues with cechos staying on-screen and glitching out
(NiGHTS items for example).
Revert "Remove unnecessary precipmobj thinker hack"
This reverts commit 0e38208620d19ec2ab690740438ac2fc7862a49e.
Fix frame pacing when game lags behind
The frame timestamp should've been made at the start of the frame, not the end.
Fix I_FrameCapSleep not respecting cpusleep
Jonathan Joestar bruh
Allow dedicated to use precise sleep timing again
Instead of only using one old sleep, just enforce framerate cap to match TICRATE.
Make Lua TeleportMove call MoveOrigin
Reset Metal fume interp state on appear
Add interpdebug
Put interpdebug stuff in perfstats instead
Add timescale cvar
Slow the game down to debug animations / interpolation problems! Speed it up if you need to get somewhere quickly while mapping!
Enable timescale outside of DEVELOP builds
It has NETVAR, so it should be fine -- put an end to useful debugging features excluded in multiplayer!
Force interpolation when timescale != 1.0
Reset old_z in MT_LOCKON think
Fixes interpolation artifacting due to spawn pos.
Fix cutscenes in interp
Fix boss1 laser in interp
Interpolate mobj scale
Precalculate refresh rate
Slower PCs can have issue querying mode over and over. This might kinda suck for windowed mode if you have different refresh rate displays but oh well
Fix interp scaling crashing software
Reset interp scale when Lua sets .scale
Disable angle interp on fresh mobjs
Fix interp scale crash for hires sprites
Interp shadow scales
Copy interp state in P_SpawnMobjFromMobj
Fix multiplayer character select
Don't interpolate mobj state if frac = 1.0
Fix Mario block item placement
Interpolate spritescale/offset x/y
Fix offset copies for SpawnMobjFromMobj
THANKS SAL
Add Lua HUD drawlists
Buffers draw calls between tics to ensure hooks
run at the originally intended rate.
Rename drawerlib deltaTime to getDeltaTime
Make renderisnewtic is false between tics
I know what I'm doing! I swear
Completely refactor timing system
Time is now tracked internally in the game using I_GetPreciseTime
and I_UpdateTime. I_Time now pulls from this internal timer. The
system code no longer needs to keep track of time itself.
This significantly improves frame and tic timing in interp mode,
resulting in a much smoother image with essentially no judder at
any framerate.
Ensure mobj interpolators reset on level load
Ensure view is not interpolated on first frame
Disable sprite offset interpolation (for now)
Refactor timing code even more
System layer is greatly simplified and framecap
logic has been moved internally. I_Sleep now
takes a sleep duration and I_SleepDuration
generically implements a precise sleep with spin
loop.
Adjust spawned mobj z by gravity inversion
Only check VERTICALFLIP for old_z calc
Fix Marathon Mode menu for uncapped
Move screenshot code before timing
Only play emerald hunt sounds on new tics
Restore deleted zofs (fixes signpost sparkles etc)
Revert to before screenUpdate boolean was added
Was done this way for the sake of an older version of uncapped's timing; now that the new timing is much better, I decided it should remain as close to pre-uncapped as it can be.
Run UpdateLevelInterpolators in preticker
Fixes KartKrew/Kart-Public#10
Run UpdateMobjInterpolators in preticker
Reset view interp in preticker
Add per-split player view resets
307 lines
8.6 KiB
C
307 lines
8.6 KiB
C
// SONIC ROBO BLAST 2
|
|
//-----------------------------------------------------------------------------
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
|
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
|
//
|
|
// This program is free software distributed under the
|
|
// terms of the GNU General Public License, version 2.
|
|
// See the 'LICENSE' file for more details.
|
|
//-----------------------------------------------------------------------------
|
|
/// \file r_things.h
|
|
/// \brief Rendering of moving objects, sprites
|
|
|
|
#ifndef __R_THINGS__
|
|
#define __R_THINGS__
|
|
|
|
#include "r_plane.h"
|
|
#include "r_patch.h"
|
|
#include "r_picformats.h"
|
|
#include "r_portal.h"
|
|
#include "r_defs.h"
|
|
#include "r_skins.h"
|
|
|
|
// --------------
|
|
// SPRITE LOADING
|
|
// --------------
|
|
|
|
#define FEETADJUST (4<<FRACBITS) // R_AddSingleSpriteDef
|
|
|
|
boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 wadnum, UINT16 startlump, UINT16 endlump);
|
|
|
|
//faB: find sprites in wadfile, replace existing, add new ones
|
|
// (only sprites from namelist are added or replaced)
|
|
void R_AddSpriteDefs(UINT16 wadnum);
|
|
|
|
// ---------------------
|
|
// MASKED COLUMN DRAWING
|
|
// ---------------------
|
|
|
|
// vars for R_DrawMaskedColumn
|
|
extern INT16 *mfloorclip;
|
|
extern INT16 *mceilingclip;
|
|
extern fixed_t spryscale;
|
|
extern fixed_t sprtopscreen;
|
|
extern fixed_t sprbotscreen;
|
|
extern fixed_t windowtop;
|
|
extern fixed_t windowbottom;
|
|
extern INT32 lengthcol;
|
|
|
|
void R_DrawMaskedColumn(column_t *column, column_t *brightmap);
|
|
void R_DrawFlippedMaskedColumn(column_t *column, column_t *brightmap);
|
|
|
|
// ----------------
|
|
// SPRITE RENDERING
|
|
// ----------------
|
|
|
|
// Constant arrays used for psprite clipping
|
|
// and initializing clipping.
|
|
extern INT16 negonearray[MAXVIDWIDTH];
|
|
extern INT16 screenheightarray[MAXVIDWIDTH];
|
|
|
|
fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope);
|
|
|
|
//SoM: 6/5/2000: Light sprites correctly!
|
|
void R_AddSprites(sector_t *sec, INT32 lightlevel);
|
|
void R_InitSprites(void);
|
|
void R_ClearSprites(void);
|
|
|
|
boolean R_ThingVisible (mobj_t *thing);
|
|
|
|
boolean R_ThingVisibleWithinDist (mobj_t *thing,
|
|
fixed_t draw_dist);
|
|
|
|
boolean R_PrecipThingVisible (precipmobj_t *precipthing,
|
|
fixed_t precip_draw_dist);
|
|
|
|
boolean R_ThingHorizontallyFlipped (mobj_t *thing);
|
|
boolean R_ThingVerticallyFlipped (mobj_t *thing);
|
|
|
|
boolean R_ThingIsPaperSprite (mobj_t *thing);
|
|
boolean R_ThingIsFloorSprite (mobj_t *thing);
|
|
|
|
boolean R_ThingIsFullBright (mobj_t *thing);
|
|
boolean R_ThingIsSemiBright (mobj_t *thing);
|
|
boolean R_ThingIsFullDark (mobj_t *thing);
|
|
|
|
boolean R_ThingIsFlashing(mobj_t *thing);
|
|
|
|
// --------------
|
|
// MASKED DRAWING
|
|
// --------------
|
|
/** Used to count the amount of masked elements
|
|
* per portal to later group them in separate
|
|
* drawnode lists.
|
|
*/
|
|
typedef struct
|
|
{
|
|
size_t drawsegs[2];
|
|
size_t vissprites[2];
|
|
fixed_t viewx, viewy, viewz; /**< View z stored at the time of the BSP traversal for the view/portal. Masked sorting/drawing needs it. */
|
|
sector_t* viewsector;
|
|
} maskcount_t;
|
|
|
|
void R_DrawMasked(maskcount_t* masks, INT32 nummasks);
|
|
|
|
// ----------
|
|
// VISSPRITES
|
|
// ----------
|
|
|
|
// number of sprite lumps for spritewidth,offset,topoffset lookup tables
|
|
// Fab: this is a hack : should allocate the lookup tables per sprite
|
|
#define MAXVISSPRITES 2048 // added 2-2-98 was 128
|
|
|
|
#define VISSPRITECHUNKBITS 6 // 2^6 = 64 sprites per chunk
|
|
#define VISSPRITESPERCHUNK (1 << VISSPRITECHUNKBITS)
|
|
#define VISSPRITEINDEXMASK (VISSPRITESPERCHUNK - 1)
|
|
|
|
typedef enum
|
|
{
|
|
// actual cuts
|
|
SC_NONE = 0,
|
|
SC_TOP = 1,
|
|
SC_BOTTOM = 1<<1,
|
|
// other flags
|
|
SC_PRECIP = 1<<2,
|
|
SC_LINKDRAW = 1<<3,
|
|
SC_FULLBRIGHT = 1<<4,
|
|
SC_FULLDARK = 1<<5,
|
|
SC_VFLIP = 1<<6,
|
|
SC_ISSCALED = 1<<7,
|
|
SC_ISROTATED = 1<<8,
|
|
SC_SHADOW = 1<<9,
|
|
SC_SHEAR = 1<<10,
|
|
SC_SPLAT = 1<<11,
|
|
// srb2kart
|
|
SC_SEMIBRIGHT = 1<<12,
|
|
// masks
|
|
SC_CUTMASK = SC_TOP|SC_BOTTOM,
|
|
SC_FLAGMASK = ~SC_CUTMASK
|
|
} spritecut_e;
|
|
|
|
// A vissprite_t is a thing that will be drawn during a refresh,
|
|
// i.e. a sprite object that is partly visible.
|
|
typedef struct vissprite_s
|
|
{
|
|
// Doubly linked list.
|
|
struct vissprite_s *prev;
|
|
struct vissprite_s *next;
|
|
|
|
// Bonus linkdraw pointer.
|
|
struct vissprite_s *linkdraw;
|
|
|
|
mobj_t *mobj; // for easy access
|
|
|
|
INT32 x1, x2;
|
|
|
|
fixed_t gx, gy; // for line side calculation
|
|
fixed_t gz, gzt; // global bottom/top for silhouette clipping and sorting with 3D floors
|
|
fixed_t pz, pzt; // physical bottom/top
|
|
|
|
fixed_t startfrac; // horizontal position of x1
|
|
fixed_t xscale, scale; // projected horizontal and vertical scales
|
|
fixed_t thingscale; // the object's scale
|
|
fixed_t sortscale; // sortscale only differs from scale for paper sprites, floor sprites, and MF2_LINKDRAW
|
|
fixed_t sortsplat; // the sortscale from behind the floor sprite
|
|
fixed_t scalestep; // only for paper sprites, 0 otherwise
|
|
fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle
|
|
fixed_t xiscale; // negative if flipped
|
|
|
|
angle_t centerangle; // for paper sprites
|
|
|
|
// for floor sprites
|
|
struct {
|
|
fixed_t x, y, z; // the viewpoint's current position
|
|
angle_t angle; // the viewpoint's current angle
|
|
} viewpoint;
|
|
|
|
struct {
|
|
fixed_t tan; // The amount to shear the sprite vertically per row
|
|
INT32 offset; // The center of the shearing location offset from x1
|
|
} shear;
|
|
|
|
fixed_t texturemid;
|
|
patch_t *patch;
|
|
|
|
lighttable_t *colormap; // for color translation and shadow draw
|
|
// maxbright frames as well
|
|
|
|
UINT8 *transmap; // which translucency table to use
|
|
|
|
INT32 mobjflags;
|
|
|
|
INT32 heightsec; // height sector for underwater/fake ceiling support
|
|
|
|
extracolormap_t *extra_colormap; // global colormaps
|
|
|
|
fixed_t thingheight; // The actual height of the thing (for 3D floors)
|
|
|
|
sector_t *sector; // The sector containing the thing.
|
|
|
|
// Precalculated top and bottom screen coords for the sprite.
|
|
INT16 sz, szt;
|
|
|
|
spritecut_e cut;
|
|
UINT32 renderflags;
|
|
UINT8 rotateflags;
|
|
|
|
fixed_t spritexscale, spriteyscale;
|
|
fixed_t spritexoffset, spriteyoffset;
|
|
|
|
fixed_t shadowscale;
|
|
|
|
INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH];
|
|
|
|
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
|
|
} vissprite_t;
|
|
|
|
extern UINT32 visspritecount;
|
|
|
|
void R_ClipSprites(drawseg_t* dsstart, portal_t* portal);
|
|
void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, drawseg_t* dsstart, portal_t* portal);
|
|
|
|
UINT8 *R_GetSpriteTranslation(vissprite_t *vis);
|
|
|
|
// ----------
|
|
// DRAW NODES
|
|
// ----------
|
|
|
|
// A drawnode is something that points to a 3D floor, 3D side, or masked
|
|
// middle texture. This is used for sorting with sprites.
|
|
typedef struct drawnode_s
|
|
{
|
|
visplane_t *plane;
|
|
drawseg_t *seg;
|
|
drawseg_t *thickseg;
|
|
ffloor_t *ffloor;
|
|
vissprite_t *sprite;
|
|
|
|
struct drawnode_s *next;
|
|
struct drawnode_s *prev;
|
|
} drawnode_t;
|
|
|
|
void R_InitDrawNodes(void);
|
|
|
|
// -----------------------
|
|
// SPRITE FRAME CHARACTERS
|
|
// -----------------------
|
|
|
|
// Functions to go from sprite character ID to frame number
|
|
// for 2.1 compatibility this still uses the old 'A' + frame code
|
|
// The use of symbols tends to be painful for wad editors though
|
|
// So the future version of this tries to avoid using symbols
|
|
// as much as possible while also defining all 64 slots in a sane manner
|
|
// 2.1: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ]]
|
|
// Future: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz!@ ]]
|
|
FUNCMATH FUNCINLINE static ATTRINLINE char R_Frame2Char(UINT8 frame)
|
|
{
|
|
#if 0 // 2.1 compat
|
|
return 'A' + frame;
|
|
#else
|
|
if (frame < 26) return 'A' + frame;
|
|
if (frame < 36) return '0' + (frame - 26);
|
|
if (frame < 62) return 'a' + (frame - 36);
|
|
if (frame == 62) return '!';
|
|
if (frame == 63) return '@';
|
|
return '\xFF';
|
|
#endif
|
|
}
|
|
|
|
FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Frame(char cn)
|
|
{
|
|
#if 0 // 2.1 compat
|
|
if (cn == '+') return '\\' - 'A'; // PK3 can't use backslash, so use + instead
|
|
return cn - 'A';
|
|
#else
|
|
if (cn >= 'A' && cn <= 'Z') return (cn - 'A');
|
|
if (cn >= '0' && cn <= '9') return (cn - '0') + 26;
|
|
if (cn >= 'a' && cn <= 'z') return (cn - 'a') + 36;
|
|
if (cn == '!') return 62;
|
|
if (cn == '@') return 63;
|
|
return 255;
|
|
#endif
|
|
}
|
|
|
|
// "Left" and "Right" character symbols for additional rotation functionality
|
|
#define ROT_L 17
|
|
#define ROT_R 18
|
|
|
|
FUNCMATH FUNCINLINE static ATTRINLINE char R_Rotation2Char(UINT8 rot)
|
|
{
|
|
if (rot <= 9) return '0' + rot;
|
|
if (rot <= 16) return 'A' + (rot - 10);
|
|
if (rot == ROT_L) return 'L';
|
|
if (rot == ROT_R) return 'R';
|
|
return '\xFF';
|
|
}
|
|
|
|
FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Rotation(char cn)
|
|
{
|
|
if (cn >= '0' && cn <= '9') return (cn - '0');
|
|
if (cn >= 'A' && cn <= 'G') return (cn - 'A') + 10;
|
|
if (cn == 'L') return ROT_L;
|
|
if (cn == 'R') return ROT_R;
|
|
return 255;
|
|
}
|
|
|
|
#endif //__R_THINGS__
|