mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 06:42:12 +00:00
- Backend update from Raze.
This commit is contained in:
parent
53c2ac79e1
commit
c55dfbcddd
11 changed files with 100 additions and 22 deletions
|
@ -151,7 +151,7 @@ int ModelFrameHash(FSpriteModelFrame * smf)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
unsigned FindModel(const char * path, const char * modelfile)
|
||||
unsigned FindModel(const char * path, const char * modelfile, bool silent)
|
||||
{
|
||||
FModel * model = nullptr;
|
||||
FString fullname;
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
IModelVertexBuffer *GetVertexBuffer(int type) const { return mVBuf[type]; }
|
||||
void DestroyVertexBuffer();
|
||||
|
||||
bool hasSurfaces = false;
|
||||
FString mFileName;
|
||||
|
||||
private:
|
||||
|
@ -90,5 +91,5 @@ private:
|
|||
};
|
||||
|
||||
int ModelFrameHash(FSpriteModelFrame* smf);
|
||||
unsigned FindModel(const char* path, const char* modelfile);
|
||||
unsigned FindModel(const char* path, const char* modelfile, bool silent = false);
|
||||
|
||||
|
|
|
@ -133,6 +133,7 @@ bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int le
|
|||
|
||||
auto numFrames = LittleLong(hdr->Num_Frames);
|
||||
auto numSurfaces = LittleLong(hdr->Num_Surfaces);
|
||||
hasSurfaces = numSurfaces > 1;
|
||||
|
||||
numTags = LittleLong(hdr->Num_Tags);
|
||||
|
||||
|
|
|
@ -222,6 +222,8 @@ bool FOBJModel::Load(const char* fn, int lumpnum, const char* buffer, int length
|
|||
curSurface->faceStart = aggSurfFaceCount;
|
||||
surfaces.Push(*curSurface);
|
||||
delete curSurface;
|
||||
hasSurfaces = surfaces.Size() > 1;
|
||||
|
||||
|
||||
if (uvs.Size() == 0)
|
||||
{ // Needed so that OBJs without UVs can work
|
||||
|
|
|
@ -48,6 +48,7 @@ float unpackuvert( uint32_t n, int c )
|
|||
bool FUE1Model::Load( const char *filename, int lumpnum, const char *buffer, int length )
|
||||
{
|
||||
int lumpnum2;
|
||||
hasSurfaces = true;
|
||||
FString realfilename = fileSystem.GetFileFullName(lumpnum);
|
||||
if ( (size_t)realfilename.IndexOf("_d.3d") == realfilename.Len()-5 )
|
||||
{
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
#include <stdint.h>
|
||||
// [RH] Voxels from Build
|
||||
|
||||
#define MAXVOXMIPS 5
|
||||
enum
|
||||
{
|
||||
MAXVOXMIPS = 5,
|
||||
};
|
||||
|
||||
struct kvxslab_t
|
||||
{
|
||||
|
|
|
@ -51,12 +51,6 @@ inline double PointOnLineSide(double x, double y, double linex, double liney, do
|
|||
return (x - linex) * deltay - (y - liney) * deltax;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline double PointOnLineSide(const TVector2<T>& pos, const TVector2<T>& linestart, const TVector2<T>& lineend)
|
||||
{
|
||||
return (pos.X - linestart.X) * (lineend.Y - linestart.Y) - (pos.Y - linestart.Y) * (lineend.X - linestart.X);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -146,8 +140,11 @@ inline double InterceptLineSegments(double v2x, double v2y, double v2dx, double
|
|||
{
|
||||
double den = v1dy * v2dx - v1dx * v2dy;
|
||||
|
||||
if (den == 0 || (forcansee && den < 0)) // cansee does this added check here, aside from that its logic is virtually the same.
|
||||
return 0; // parallel
|
||||
if (den == 0)
|
||||
return -2 * (double)FLT_MAX; // parallel (return a magic value different from everything else, just in case it needs to be handled)
|
||||
|
||||
if (forcansee && den < 0) // cansee does this added check here, aside from that its logic is virtually the same.
|
||||
return -1; // hitting the backside
|
||||
|
||||
// perform the division first for better parallelization.
|
||||
den = 1 / den;
|
||||
|
@ -175,3 +172,63 @@ inline double LinePlaneIntersect(const DVector3& start, const DVector3& trace, c
|
|||
return (dist - dotStart) / dotTrace; // we are only interested in the factor
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// BoxOnLineSide
|
||||
//
|
||||
// Based on Doom's, but rewritten to be standalone
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
inline int BoxOnLineSide(const DVector2& boxtl, const DVector2& boxbr, const DVector2& start, const DVector2& delta)
|
||||
{
|
||||
int p1;
|
||||
int p2;
|
||||
|
||||
if (delta.X == 0)
|
||||
{
|
||||
p1 = boxbr.X < start.X;
|
||||
p2 = boxtl.X < start.X;
|
||||
if (delta.Y < 0)
|
||||
{
|
||||
p1 ^= 1;
|
||||
p2 ^= 1;
|
||||
}
|
||||
}
|
||||
else if (delta.Y == 0)
|
||||
{
|
||||
p1 = boxtl.Y > start.Y;
|
||||
p2 = boxbr.Y > start.Y;
|
||||
if (delta.X < 0)
|
||||
{
|
||||
p1 ^= 1;
|
||||
p2 ^= 1;
|
||||
}
|
||||
}
|
||||
else if (delta.X * delta.Y <= 0)
|
||||
{
|
||||
p1 = PointOnLineSide(boxtl.X, boxtl.Y, start.X, start.Y, delta.X, delta.Y) > 0;
|
||||
p2 = PointOnLineSide(boxbr.X, boxbr.Y, start.X, start.Y, delta.X, delta.Y) > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
p1 = PointOnLineSide(boxbr.X, boxtl.Y, start.X, start.Y, delta.X, delta.Y) > 0;
|
||||
p2 = PointOnLineSide(boxtl.X, boxbr.Y, start.X, start.Y, delta.X, delta.Y) > 0;
|
||||
}
|
||||
|
||||
return (p1 == p2) ? p1 : -1;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// BoxInRange
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
inline bool BoxInRange(const DVector2& boxtl, const DVector2& boxbr, const DVector2& start, const DVector2& end)
|
||||
{
|
||||
return boxtl.X < max(start.X, end.X) &&
|
||||
boxbr.X > min(start.X, end.X) &&
|
||||
boxtl.Y < max(start.Y, end.Y) &&
|
||||
boxbr.Y > min(start.Y, end.Y);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ static uint64_t GetClockTimeNS()
|
|||
{
|
||||
auto tp = GetTimePoint() - StartupTimeNS;
|
||||
if (TimeScale == 1.0) return tp;
|
||||
else return tp / 1000 * TimeScale * 1000;
|
||||
else return uint64_t(tp / 1000 * TimeScale * 1000);
|
||||
}
|
||||
|
||||
static uint64_t MSToNS(unsigned int ms)
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
|
||||
__forceinline constexpr int32_t MulScale(int32_t a, int32_t b, int32_t shift) { return (int32_t)(((int64_t)a * b) >> shift); }
|
||||
__forceinline constexpr double MulScaleF(double a, double b, int32_t shift) { return (a * b) * (1. / (uint32_t(1) << shift)); }
|
||||
__forceinline constexpr int32_t DMulScale(int32_t a, int32_t b, int32_t c, int32_t d, int32_t shift) { return (int32_t)(((int64_t)a * b + (int64_t)c * d) >> shift); }
|
||||
__forceinline constexpr int32_t DivScale(int32_t a, int32_t b, int shift) { return (int32_t)(((int64_t)a << shift) / b); }
|
||||
__forceinline constexpr int64_t DivScaleL(int64_t a, int64_t b, int shift) { return ((a << shift) / b); }
|
||||
|
|
|
@ -332,7 +332,7 @@ public:
|
|||
|
||||
unsigned IndexOf(const T* elem) const
|
||||
{
|
||||
return elem - Array;
|
||||
return unsigned(elem - Array);
|
||||
}
|
||||
|
||||
unsigned int Find(const T& item) const
|
||||
|
|
|
@ -271,6 +271,19 @@ struct TVector2
|
|||
return *this;
|
||||
}
|
||||
|
||||
TVector2 Resized(double len) const
|
||||
{
|
||||
double vlen = Length();
|
||||
if (vlen != 0.)
|
||||
{
|
||||
double scale = len / vlen;
|
||||
return{ vec_t(X * scale), vec_t(Y * scale) };
|
||||
}
|
||||
else
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
// Dot product
|
||||
vec_t operator | (const TVector2 &other) const
|
||||
|
@ -644,7 +657,7 @@ struct TVector3
|
|||
return *this;
|
||||
}
|
||||
|
||||
TVector3 Resized(double len)
|
||||
TVector3 Resized(double len) const
|
||||
{
|
||||
double vlen = Length();
|
||||
if (vlen != 0.)
|
||||
|
@ -974,7 +987,7 @@ struct TVector4
|
|||
return *this;
|
||||
}
|
||||
|
||||
TVector4 Resized(double len)
|
||||
TVector4 Resized(double len) const
|
||||
{
|
||||
double vlen = Length();
|
||||
if (vlen != 0.)
|
||||
|
@ -1287,12 +1300,7 @@ public:
|
|||
return TAngle(f * (90. / 0x40000000));
|
||||
}
|
||||
|
||||
static constexpr TAngle fromBuild(int bang)
|
||||
{
|
||||
return TAngle(bang * (90. / 512));
|
||||
}
|
||||
|
||||
static constexpr TAngle fromBuildf(double bang)
|
||||
static constexpr TAngle fromBuild(double bang)
|
||||
{
|
||||
return TAngle(bang * (90. / 512));
|
||||
}
|
||||
|
@ -1349,6 +1357,11 @@ public:
|
|||
return Degrees_ * other;
|
||||
}
|
||||
|
||||
constexpr TAngle operator* (TAngle other) const
|
||||
{
|
||||
return Degrees_ * other.Degrees_;
|
||||
}
|
||||
|
||||
constexpr TAngle operator/ (vec_t other) const
|
||||
{
|
||||
return Degrees_ / other;
|
||||
|
@ -1736,6 +1749,7 @@ constexpr DAngle minAngle = DAngle::fromDeg(1. / 65536.);
|
|||
constexpr FAngle nullFAngle = FAngle::fromDeg(0.);
|
||||
|
||||
constexpr DAngle DAngle1 = DAngle::fromDeg(1);
|
||||
constexpr DAngle DAngle15 = DAngle::fromDeg(15);
|
||||
constexpr DAngle DAngle22_5 = DAngle::fromDeg(22.5);
|
||||
constexpr DAngle DAngle45 = DAngle::fromDeg(45);
|
||||
constexpr DAngle DAngle60 = DAngle::fromDeg(60);
|
||||
|
|
Loading…
Reference in a new issue