2021-02-16 10:36:08 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "gamecontrol.h"
|
|
|
|
#include "binaryangle.h"
|
2021-03-22 22:40:25 +00:00
|
|
|
#include "build.h"
|
2021-02-16 10:36:08 +00:00
|
|
|
|
|
|
|
extern int cameradist, cameraclock;
|
|
|
|
|
2021-03-18 09:19:13 +00:00
|
|
|
bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, short *psectnum, binangle ang, fixedhoriz horiz, double const smoothratio);
|
2021-03-19 19:40:44 +00:00
|
|
|
void PlanesAtPoint(const sectortype* sec, float dax, float day, float* ceilz, float* florz);
|
|
|
|
void setWallSectors();
|
2021-03-27 12:22:34 +00:00
|
|
|
void GetWallSpritePosition(const spritetype* spr, vec2_t pos, vec2_t* out, bool render = false);
|
2021-03-26 19:28:44 +00:00
|
|
|
void GetFlatSpritePosition(const spritetype* spr, vec2_t pos, vec2_t* out, bool render = false);
|
2021-03-20 22:01:16 +00:00
|
|
|
void checkRotatedWalls();
|
2021-03-18 20:50:02 +00:00
|
|
|
|
2021-03-18 11:49:33 +00:00
|
|
|
// y is negated so that the orientation is the same as in GZDoom, in order to use its utilities.
|
|
|
|
// The render code should NOT use Build coordinates for anything!
|
|
|
|
|
|
|
|
inline double WallStartX(int wallnum)
|
|
|
|
{
|
|
|
|
return wall[wallnum].x * (1 / 16.);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double WallStartY(int wallnum)
|
|
|
|
{
|
|
|
|
return wall[wallnum].y * (1 / -16.);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double WallEndX(int wallnum)
|
|
|
|
{
|
|
|
|
return wall[wall[wallnum].point2].x * (1 / 16.);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double WallEndY(int wallnum)
|
|
|
|
{
|
|
|
|
return wall[wall[wallnum].point2].y * (1 / -16.);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double WallStartX(const walltype* wallnum)
|
|
|
|
{
|
|
|
|
return wallnum->x * (1 / 16.);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double WallStartY(const walltype* wallnum)
|
|
|
|
{
|
|
|
|
return wallnum->y * (1 / -16.);
|
|
|
|
}
|
|
|
|
|
2021-03-21 17:41:23 +00:00
|
|
|
inline DVector2 WallStart(const walltype* wallnum)
|
|
|
|
{
|
|
|
|
return { WallStartX(wallnum), WallStartY(wallnum) };
|
|
|
|
}
|
|
|
|
|
2021-03-18 11:49:33 +00:00
|
|
|
inline double WallEndX(const walltype* wallnum)
|
|
|
|
{
|
|
|
|
return wall[wallnum->point2].x * (1 / 16.);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double WallEndY(const walltype* wallnum)
|
|
|
|
{
|
|
|
|
return wall[wallnum->point2].y * (1 / -16.);
|
|
|
|
}
|
|
|
|
|
2021-03-21 17:41:23 +00:00
|
|
|
inline DVector2 WallEnd(const walltype* wallnum)
|
|
|
|
{
|
|
|
|
return { WallEndX(wallnum), WallEndY(wallnum) };
|
|
|
|
}
|
|
|
|
|
|
|
|
inline DVector2 WallDelta(const walltype* wallnum)
|
|
|
|
{
|
|
|
|
return WallEnd(wallnum) - WallStart(wallnum);
|
|
|
|
}
|
|
|
|
|
2021-03-18 11:49:33 +00:00
|
|
|
inline double SpriteX(int wallnum)
|
|
|
|
{
|
|
|
|
return sprite[wallnum].x * (1 / 16.);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double SpriteY(int wallnum)
|
|
|
|
{
|
|
|
|
return sprite[wallnum].y * (1 / -16.);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double PointOnLineSide(double x, double y, double linex, double liney, double deltax, double deltay)
|
|
|
|
{
|
|
|
|
return (x - linex) * deltay - (y - liney) * deltax;
|
|
|
|
}
|
|
|
|
|
2021-03-21 17:41:23 +00:00
|
|
|
inline double PointOnLineSide(const DVector2 &pos, const walltype *line)
|
|
|
|
{
|
|
|
|
return (pos.X - WallStartX(line)) * WallDelta(line).Y - (pos.Y - WallStartY(line)) * WallDelta(line).X;
|
|
|
|
}
|
|
|
|
|
2021-03-19 19:40:44 +00:00
|
|
|
inline int sectorofwall(int wallNum)
|
|
|
|
{
|
|
|
|
if ((unsigned)wallNum < (unsigned)numwalls) return wall[wallNum].sector;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-03-25 08:13:16 +00:00
|
|
|
extern int numshades;
|
|
|
|
|
|
|
|
// Return type is int because this gets passed to variadic functions where structs may produce undefined behavior.
|
|
|
|
inline int shadeToLight(int shade)
|
|
|
|
{
|
|
|
|
shade = clamp(shade, 0, numshades - 1);
|
|
|
|
int light = Scale(numshades - 1 - shade, 255, numshades - 1);
|
|
|
|
return PalEntry(255, light, light, light);
|
|
|
|
}
|
|
|
|
|
2021-03-19 19:40:44 +00:00
|
|
|
|