2016-03-01 15:47:10 +00:00
|
|
|
#ifndef __R_UTIL_H
|
|
|
|
#define __R_UTIL_H
|
|
|
|
|
|
|
|
#include "r_state.h"
|
2016-04-01 10:22:16 +00:00
|
|
|
#include "vectors.h"
|
2016-09-20 21:13:12 +00:00
|
|
|
|
|
|
|
class FSerializer;
|
2018-06-19 15:44:11 +00:00
|
|
|
struct FViewWindow;
|
2016-03-01 15:47:10 +00:00
|
|
|
//
|
|
|
|
// Stuff from r_main.h that's needed outside the rendering code.
|
|
|
|
|
|
|
|
// Number of diminishing brightness levels.
|
|
|
|
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
|
|
|
|
#define NUMCOLORMAPS 32
|
|
|
|
|
2017-03-11 10:31:09 +00:00
|
|
|
struct FRenderViewpoint
|
|
|
|
{
|
2017-03-11 22:28:07 +00:00
|
|
|
FRenderViewpoint();
|
|
|
|
|
2017-03-11 10:31:09 +00:00
|
|
|
player_t *player; // For which player is this viewpoint being renderered? (can be null for camera textures)
|
|
|
|
DVector3 Pos; // Camera position
|
|
|
|
DVector3 ActorPos; // Camera actor's position
|
|
|
|
DRotator Angles; // Camera angles
|
2018-06-19 21:16:22 +00:00
|
|
|
FRotator HWAngles; // Actual rotation angles for the hardware renderer
|
2018-06-19 15:55:42 +00:00
|
|
|
DVector2 ViewVector; // HWR only: direction the camera is facing.
|
2018-06-19 16:51:46 +00:00
|
|
|
AActor *ViewActor; // either the same as camera or nullptr
|
2018-04-28 22:09:44 +00:00
|
|
|
|
2017-03-11 22:28:07 +00:00
|
|
|
DVector3 Path[2]; // View path for portal calculations
|
2017-03-11 10:31:09 +00:00
|
|
|
double Cos; // cos(Angles.Yaw)
|
|
|
|
double Sin; // sin(Angles.Yaw)
|
|
|
|
double TanCos; // FocalTangent * cos(Angles.Yaw)
|
|
|
|
double TanSin; // FocalTangent * sin(Angles.Yaw)
|
|
|
|
|
|
|
|
AActor *camera; // camera actor
|
|
|
|
sector_t *sector; // [RH] keep track of sector viewing from
|
|
|
|
DAngle FieldOfView; // current field of view
|
|
|
|
|
|
|
|
double TicFrac; // fraction of tic for interpolation
|
|
|
|
uint32_t FrameTime; // current frame's time in tics.
|
|
|
|
|
|
|
|
int extralight; // extralight to be added to this viewpoint
|
|
|
|
bool showviewer; // show the camera actor?
|
2018-06-19 15:44:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
void SetViewAngle(const FViewWindow &viewwindow);
|
|
|
|
|
2017-03-11 10:31:09 +00:00
|
|
|
};
|
|
|
|
|
2017-03-11 22:28:07 +00:00
|
|
|
extern FRenderViewpoint r_viewpoint;
|
2017-01-12 15:21:46 +00:00
|
|
|
|
2017-03-11 10:31:09 +00:00
|
|
|
//-----------------------------------
|
|
|
|
struct FViewWindow
|
|
|
|
{
|
2017-03-11 22:28:07 +00:00
|
|
|
double FocalTangent = 0.0;
|
|
|
|
int centerx = 0;
|
|
|
|
int centerxwide = 0;
|
|
|
|
int centery = 0;
|
|
|
|
float WidescreenRatio = 0.0f;
|
2017-03-11 10:31:09 +00:00
|
|
|
};
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2017-03-11 22:28:07 +00:00
|
|
|
extern FViewWindow r_viewwindow;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2017-03-11 10:31:09 +00:00
|
|
|
//-----------------------------------
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2017-03-11 10:31:09 +00:00
|
|
|
|
|
|
|
extern int setblocks;
|
2016-03-01 15:47:10 +00:00
|
|
|
extern bool r_NoInterpolate;
|
|
|
|
extern int validcount;
|
2018-11-05 23:13:23 +00:00
|
|
|
extern int dl_validcount; // For use with FSection. validcount is in use by the renderer and any quick section exclusion needs another variable.
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
extern angle_t LocalViewAngle; // [RH] Added to consoleplayer's angle
|
|
|
|
extern int LocalViewPitch; // [RH] Used directly instead of consoleplayer's pitch
|
|
|
|
extern bool LocalKeyboardTurner; // [RH] The local player used the keyboard to turn, so interpolate
|
|
|
|
|
|
|
|
extern unsigned int R_OldBlend;
|
|
|
|
|
2016-04-23 03:54:04 +00:00
|
|
|
const double r_Yaspect = 200.0; // Why did I make this a variable? It's never set anywhere.
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-30 05:08:47 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_PointOnSide
|
|
|
|
//
|
|
|
|
// Traverse BSP (sub) tree, check point against partition plane.
|
|
|
|
// Returns side 0 (front/on) or 1 (back).
|
|
|
|
//
|
|
|
|
// [RH] inlined, stripped down, and made more precise
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
inline int R_PointOnSide (fixed_t x, fixed_t y, const node_t *node)
|
|
|
|
{
|
|
|
|
return DMulScale32 (y-node->y, node->dx, node->x-x, node->dy) > 0;
|
|
|
|
}
|
2016-03-31 15:44:05 +00:00
|
|
|
inline int R_PointOnSide(double x, double y, const node_t *node)
|
|
|
|
{
|
|
|
|
return DMulScale32(FLOAT2FIXED(y) - node->y, node->dx, node->x - FLOAT2FIXED(x), node->dy) > 0;
|
|
|
|
}
|
2016-03-30 22:41:21 +00:00
|
|
|
inline int R_PointOnSide(const DVector2 &pos, const node_t *node)
|
|
|
|
{
|
|
|
|
return DMulScale32(FLOAT2FIXED(pos.Y) - node->y, node->dx, node->x - FLOAT2FIXED(pos.X), node->dy) > 0;
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Used for interpolation waypoints.
|
2016-03-27 11:29:58 +00:00
|
|
|
struct DVector3a
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-03-27 11:29:58 +00:00
|
|
|
DVector3 pos;
|
2016-03-16 11:41:26 +00:00
|
|
|
DAngle angle;
|
2016-03-01 15:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
subsector_t *R_PointInSubsector (fixed_t x, fixed_t y);
|
2016-03-30 22:41:21 +00:00
|
|
|
inline subsector_t *R_PointInSubsector(const DVector2 &pos)
|
|
|
|
{
|
|
|
|
return R_PointInSubsector(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y));
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
void R_ResetViewInterpolation ();
|
|
|
|
void R_RebuildViewInterpolation(player_t *player);
|
|
|
|
bool R_GetViewInterpolationStatus();
|
|
|
|
void R_ClearInterpolationPath();
|
2016-03-27 11:29:58 +00:00
|
|
|
void R_AddInterpolationPoint(const DVector3a &vec);
|
2016-03-01 15:47:10 +00:00
|
|
|
void R_SetViewSize (int blocks);
|
2017-03-11 22:28:07 +00:00
|
|
|
void R_SetFOV (FRenderViewpoint &viewpoint, DAngle fov);
|
|
|
|
void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor * camera);
|
|
|
|
void R_SetViewAngle (FRenderViewpoint &viewpoint, const FViewWindow &viewwindow);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Called by startup code.
|
|
|
|
void R_Init (void);
|
2017-03-11 22:28:07 +00:00
|
|
|
void R_ExecuteSetViewSize (FRenderViewpoint &viewpoint, FViewWindow &viewwindow);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Called by M_Responder.
|
|
|
|
void R_SetViewSize (int blocks);
|
2017-03-11 22:28:07 +00:00
|
|
|
void R_SetWindow (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, int windowSize, int fullWidth, int fullHeight, int stHeight, bool renderingToCanvas = false);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2017-07-09 17:01:34 +00:00
|
|
|
double R_GetGlobVis(const FViewWindow &viewwindow, double vis);
|
|
|
|
double R_ClampVisibility(double vis);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
extern void R_FreePastViewers ();
|
|
|
|
extern void R_ClearPastViewer (AActor *actor);
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|