From b225a910a0b9ad2223f354c15c42f2e68e8739b1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 9 Oct 2022 13:44:43 +0200 Subject: [PATCH] - Backend update from Raze --- src/common/cutscenes/movieplayer.cpp | 1 + src/common/rendering/gles/gles_samplers.cpp | 21 +++++++------ src/common/utility/basics.h | 19 ++++++++--- src/common/utility/vectors.h | 35 +++++++++++++++++++-- 4 files changed, 59 insertions(+), 17 deletions(-) diff --git a/src/common/cutscenes/movieplayer.cpp b/src/common/cutscenes/movieplayer.cpp index afd710e2cd..a13d0c91e4 100644 --- a/src/common/cutscenes/movieplayer.cpp +++ b/src/common/cutscenes/movieplayer.cpp @@ -55,6 +55,7 @@ protected: { NOSOUNDCUTOFF = 1, FIXEDVIEWPORT = 2, // Forces fixed 640x480 screen size like for Blood's intros. + NOMUSICCUTOFF = 4, }; int flags; diff --git a/src/common/rendering/gles/gles_samplers.cpp b/src/common/rendering/gles/gles_samplers.cpp index b651889e3c..17efe78ca6 100644 --- a/src/common/rendering/gles/gles_samplers.cpp +++ b/src/common/rendering/gles/gles_samplers.cpp @@ -67,6 +67,7 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) { int filter = sysCallbacks.DisableTextureFilter && sysCallbacks.DisableTextureFilter() ? 0 : gl_texture_filter; + bool anisoAvailable = gles.anistropicFilterAvailable && (!sysCallbacks.DisableTextureFilter || !sysCallbacks.DisableTextureFilter()); glActiveTexture(GL_TEXTURE0 + texunit); switch (num) @@ -78,7 +79,7 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); - if (gles.anistropicFilterAvailable) + if (anisoAvailable) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); } break; @@ -90,7 +91,7 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); - if (gles.anistropicFilterAvailable) + if (anisoAvailable) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); } break; @@ -102,7 +103,7 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); - if (gles.anistropicFilterAvailable) + if (anisoAvailable) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); } break; @@ -114,7 +115,7 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].minfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); - if (gles.anistropicFilterAvailable) + if (anisoAvailable) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); } break; @@ -124,7 +125,7 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].magfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); - if (gles.anistropicFilterAvailable) + if (anisoAvailable) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; @@ -133,7 +134,7 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - if (gles.anistropicFilterAvailable) + if (anisoAvailable) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; @@ -142,7 +143,7 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - if (gles.anistropicFilterAvailable) + if (anisoAvailable) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; @@ -151,7 +152,7 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - if (gles.anistropicFilterAvailable) + if (anisoAvailable) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; @@ -160,7 +161,7 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - if (gles.anistropicFilterAvailable) + if (anisoAvailable) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; @@ -169,7 +170,7 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[filter].magfilter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[filter].magfilter); - if (gles.anistropicFilterAvailable) + if (anisoAvailable) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0); break; } diff --git a/src/common/utility/basics.h b/src/common/utility/basics.h index 8661372e96..4ebc2cc888 100644 --- a/src/common/utility/basics.h +++ b/src/common/utility/basics.h @@ -91,16 +91,27 @@ inline double DEG2RAD(double deg) return deg * (M_PI / 180.0); } -inline float RAD2DEG(float deg) +inline float RAD2DEG(float rad) { - return deg * float(180. / M_PI); + return rad * float(180. / M_PI); } -inline double RAD2DEG(double deg) +inline double RAD2DEG(double rad) { - return deg * (180. / M_PI); + return rad * (180. / M_PI); } +inline angle_t RAD2BAM(float rad) +{ + return angle_t(rad * float(0x80000000u / M_PI)); +} + +inline angle_t RAD2BAM(double rad) +{ + return angle_t(rad * (0x80000000u / M_PI)); +} + + // This is needed in common code, despite being Doom specific. enum EStateUseFlags { diff --git a/src/common/utility/vectors.h b/src/common/utility/vectors.h index c009cb5059..7a8ef53213 100644 --- a/src/common/utility/vectors.h +++ b/src/common/utility/vectors.h @@ -46,6 +46,7 @@ #include #include "xs_Float.h" #include "math/cmath.h" +#include "basics.h" #define EQUAL_EPSILON (1/65536.) @@ -307,6 +308,8 @@ template struct TVector3 { typedef TVector2 Vector2; + // this does not compile - should be true on all relevant hardware. + //static_assert(myoffsetof(TVector3, X) == myoffsetof(Vector2, X) && myoffsetof(TVector3, Y) == myoffsetof(Vector2, Y), "TVector2 and TVector3 are not aligned"); vec_t X, Y, Z; @@ -343,7 +346,7 @@ struct TVector3 return X == 0 && Y == 0 && Z == 0; } - TVector3 plusZ(double z) + TVector3 plusZ(double z) const { return { X, Y, Z + z }; } @@ -491,9 +494,14 @@ struct TVector3 } // returns the XY fields as a 2D-vector. - Vector2 XY() const + const Vector2& XY() const { - return{ X, Y }; + return *reinterpret_cast(this); + } + + Vector2& XY() + { + return *reinterpret_cast(this); } // Add a 3D vector and a 2D vector. @@ -1212,6 +1220,11 @@ public: return TAngle(bang * (90. / 512)); } + static constexpr TAngle fromBuildf(double bang) + { + return TAngle(bang * (90. / 512)); + } + static constexpr TAngle fromQ16(int bang) { return TAngle(bang * (90. / 16384)); @@ -1334,6 +1347,11 @@ public: return int(Degrees_ * (512 / 90.0)); } + constexpr double Buildfang() const + { + return Degrees_ * (512 / 90.0); + } + constexpr int Q16() const { return int(Degrees_ * (16384 / 90.0)); @@ -1364,6 +1382,12 @@ public: { return clamp(Tan(), -max, max); } + + int Sgn() const + { + const auto normalized = (signed int)BAMs(); + return (normalized > 0) - (normalized < 0); + } }; template @@ -1611,6 +1635,11 @@ typedef TAngle DAngle; constexpr DAngle nullAngle = DAngle::fromDeg(0.); constexpr FAngle nullFAngle = FAngle::fromDeg(0.); +constexpr DAngle DAngle90 = DAngle::fromBam(ANGLE_90); +constexpr DAngle DAngle180 = DAngle::fromBam(ANGLE_180); +constexpr DAngle DAngle270 = DAngle::fromBam(ANGLE_270); +constexpr DAngle DAngle360 = DAngle::fromBam(ANGLE_MAX); + class Plane { public: