mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-28 22:52:45 +00:00
- floatified vertices and removed the now redundant fx and fy members. This needs an added check for polyobject origins, though, so that such subsectors don't get rendered.
This commit is contained in:
parent
8a20f901a3
commit
5a2eac8f15
9 changed files with 67 additions and 70 deletions
|
@ -472,22 +472,18 @@ static void InitVertexData()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void GetSideVertices(int sdnum, FVector2 *v1, FVector2 *v2)
|
static void GetSideVertices(int sdnum, DVector2 *v1, DVector2 *v2)
|
||||||
{
|
{
|
||||||
line_t *ln = sides[sdnum].linedef;
|
line_t *ln = sides[sdnum].linedef;
|
||||||
if (ln->sidedef[0] == &sides[sdnum])
|
if (ln->sidedef[0] == &sides[sdnum])
|
||||||
{
|
{
|
||||||
v1->X = ln->v1->fx;
|
*v1 = ln->v1->fPos();
|
||||||
v1->Y = ln->v1->fy;
|
*v2 = ln->v2->fPos();
|
||||||
v2->X = ln->v2->fx;
|
|
||||||
v2->Y = ln->v2->fy;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v2->X = ln->v1->fx;
|
*v2 = ln->v1->fPos();
|
||||||
v2->Y = ln->v1->fy;
|
*v1 = ln->v2->fPos();
|
||||||
v1->X = ln->v2->fx;
|
|
||||||
v1->Y = ln->v2->fy;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,8 +508,6 @@ static void PrepareSegs()
|
||||||
// Get floatng point coordinates of vertices
|
// Get floatng point coordinates of vertices
|
||||||
for(int i = 0; i < numvertexes; i++)
|
for(int i = 0; i < numvertexes; i++)
|
||||||
{
|
{
|
||||||
vertexes[i].fx = vertexes[i].fX();
|
|
||||||
vertexes[i].fy = vertexes[i].fY();
|
|
||||||
vertexes[i].dirty = true;
|
vertexes[i].dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,7 +553,7 @@ static void PrepareSegs()
|
||||||
|
|
||||||
realsegs++;
|
realsegs++;
|
||||||
segcount[sidenum]++;
|
segcount[sidenum]++;
|
||||||
FVector2 sidestart, sideend, segend(seg->v2->fx, seg->v2->fy);
|
DVector2 sidestart, sideend, segend = seg->v2->fPos();
|
||||||
GetSideVertices(sidenum, &sidestart, &sideend);
|
GetSideVertices(sidenum, &sidestart, &sideend);
|
||||||
|
|
||||||
sideend -=sidestart;
|
sideend -=sidestart;
|
||||||
|
|
|
@ -155,11 +155,11 @@ void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offs
|
||||||
|
|
||||||
void FFlatVertex::SetFlatVertex(vertex_t *vt, const secplane_t & plane)
|
void FFlatVertex::SetFlatVertex(vertex_t *vt, const secplane_t & plane)
|
||||||
{
|
{
|
||||||
x = vt->fx;
|
x = vt->fX();
|
||||||
y = vt->fy;
|
y = vt->fY();
|
||||||
z = plane.ZatPoint(vt->fx, vt->fy); // this is the original position without polyobject translation.
|
z = plane.ZatPoint(vt);
|
||||||
u = vt->fx/64.f;
|
u = vt->fX()/64.f;
|
||||||
v = -vt->fy/64.f;
|
v = -vt->fY()/64.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -374,6 +374,7 @@ static void DoSubsector(subsector_t * sub)
|
||||||
|
|
||||||
// If the mapsections differ this subsector can't possibly be visible from the current view point
|
// If the mapsections differ this subsector can't possibly be visible from the current view point
|
||||||
if (!(currentmapsection[sub->mapsection>>3] & (1 << (sub->mapsection & 7)))) return;
|
if (!(currentmapsection[sub->mapsection>>3] & (1 << (sub->mapsection & 7)))) return;
|
||||||
|
if (sub->flags & SSECF_POLYORG) return; // never render polyobject origin subsectors because their vertices no longer are where one may expect.
|
||||||
|
|
||||||
if (gl_drawinfo->ss_renderflags[sub-subsectors] & SSRF_SEEN)
|
if (gl_drawinfo->ss_renderflags[sub-subsectors] & SSRF_SEEN)
|
||||||
{
|
{
|
||||||
|
|
|
@ -396,7 +396,6 @@ void R_SetView()
|
||||||
|
|
||||||
angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y)
|
angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y)
|
||||||
{
|
{
|
||||||
// Note: float won't work here as it's less precise than the BAM values being passed as parameters
|
|
||||||
double vecx = double(x-viewx);
|
double vecx = double(x-viewx);
|
||||||
double vecy = double(y-viewy);
|
double vecy = double(y-viewy);
|
||||||
|
|
||||||
|
@ -416,6 +415,26 @@ angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
angle_t R_PointToPseudoAngle(double x, double y)
|
||||||
|
{
|
||||||
|
double vecx = x - ViewPos.X;
|
||||||
|
double vecy = y - ViewPos.Y;
|
||||||
|
|
||||||
|
if (vecx == 0 && vecy == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
double result = vecy / (fabs(vecx) + fabs(vecy));
|
||||||
|
if (vecx < 0)
|
||||||
|
{
|
||||||
|
result = 2.f - result;
|
||||||
|
}
|
||||||
|
return xs_Fix<30>::ToFix(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -137,12 +137,13 @@ public:
|
||||||
extern Clipper clipper;
|
extern Clipper clipper;
|
||||||
|
|
||||||
angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y);
|
angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y);
|
||||||
|
angle_t R_PointToPseudoAngle(double x, double y);
|
||||||
void R_SetView();
|
void R_SetView();
|
||||||
|
|
||||||
// Used to speed up angle calculations during clipping
|
// Used to speed up angle calculations during clipping
|
||||||
inline angle_t vertex_t::GetClipAngle()
|
inline angle_t vertex_t::GetClipAngle()
|
||||||
{
|
{
|
||||||
return angletime == Clipper::anglecache? viewangle : (angletime = Clipper::anglecache, viewangle = R_PointToPseudoAngle(x,y));
|
return angletime == Clipper::anglecache? viewangle : (angletime = Clipper::anglecache, viewangle = R_PointToPseudoAngle(p.X, p.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -174,33 +174,16 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli)
|
||||||
void GLFlat::DrawSubsector(subsector_t * sub)
|
void GLFlat::DrawSubsector(subsector_t * sub)
|
||||||
{
|
{
|
||||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||||
if (plane.plane.isSlope())
|
|
||||||
{
|
|
||||||
for (unsigned int k = 0; k < sub->numlines; k++)
|
for (unsigned int k = 0; k < sub->numlines; k++)
|
||||||
{
|
{
|
||||||
vertex_t *vt = sub->firstline[k].v1;
|
vertex_t *vt = sub->firstline[k].v1;
|
||||||
ptr->x = vt->fx;
|
ptr->x = vt->fX();
|
||||||
ptr->y = vt->fy;
|
ptr->y = vt->fY();
|
||||||
ptr->z = plane.plane.ZatPoint(vt->fx, vt->fy) + dz;
|
ptr->z = plane.plane.ZatPoint(vt) + dz;
|
||||||
ptr->u = vt->fx / 64.f;
|
ptr->u = vt->fX() / 64.f;
|
||||||
ptr->v = -vt->fy / 64.f;
|
ptr->v = -vt->fY() / 64.f;
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float zc = FIXED2FLOAT(plane.plane.Zat0()) + dz;
|
|
||||||
for (unsigned int k = 0; k < sub->numlines; k++)
|
|
||||||
{
|
|
||||||
vertex_t *vt = sub->firstline[k].v1;
|
|
||||||
ptr->x = vt->fx;
|
|
||||||
ptr->y = vt->fy;
|
|
||||||
ptr->z = zc;
|
|
||||||
ptr->u = vt->fx / 64.f;
|
|
||||||
ptr->v = -vt->fy / 64.f;
|
|
||||||
ptr++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
|
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
|
||||||
|
|
||||||
flatvertices += sub->numlines;
|
flatvertices += sub->numlines;
|
||||||
|
|
|
@ -82,8 +82,8 @@ void GLWall::SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr)
|
||||||
|
|
||||||
float fracfac = sidefrac - glseg.fracleft;
|
float fracfac = sidefrac - glseg.fracleft;
|
||||||
|
|
||||||
ptr->x = cseg->v2->fx;
|
ptr->x = cseg->v2->fX();
|
||||||
ptr->y = cseg->v2->fy;
|
ptr->y = cseg->v2->fY();
|
||||||
ptr->z = ztop[0] + fact * fracfac;
|
ptr->z = ztop[0] + fact * fracfac;
|
||||||
ptr->u = tcs[1].u + facu * fracfac;
|
ptr->u = tcs[1].u + facu * fracfac;
|
||||||
ptr->v = tcs[1].v + facv * fracfac;
|
ptr->v = tcs[1].v + facv * fracfac;
|
||||||
|
@ -118,8 +118,8 @@ void GLWall::SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr)
|
||||||
|
|
||||||
float fracfac = sidefrac - glseg.fracleft;
|
float fracfac = sidefrac - glseg.fracleft;
|
||||||
|
|
||||||
ptr->x = cseg->v2->fx;
|
ptr->x = cseg->v2->fX();
|
||||||
ptr->y = cseg->v2->fy;
|
ptr->y = cseg->v2->fY();
|
||||||
ptr->z = zbottom[0] + facb * fracfac;
|
ptr->z = zbottom[0] + facb * fracfac;
|
||||||
ptr->u = tcs[0].u + facu * fracfac;
|
ptr->u = tcs[0].u + facu * fracfac;
|
||||||
ptr->v = tcs[0].v + facv * fracfac;
|
ptr->v = tcs[0].v + facv * fracfac;
|
||||||
|
|
|
@ -33,8 +33,8 @@ public:
|
||||||
|
|
||||||
Vector(vertex_t * v)
|
Vector(vertex_t * v)
|
||||||
{
|
{
|
||||||
SetX(v->fx);
|
SetX((float)v->fX());
|
||||||
SetY(v->fy);
|
SetY((float)v->fY());
|
||||||
SetZ(0);
|
SetZ(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
39
src/r_defs.h
39
src/r_defs.h
|
@ -105,48 +105,48 @@ typedef double vtype;
|
||||||
struct vertex_t
|
struct vertex_t
|
||||||
{
|
{
|
||||||
//private:
|
//private:
|
||||||
fixed_t x, y;
|
DVector2 p;
|
||||||
|
//fixed_t x, y;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void set(fixed_t x, fixed_t y)
|
void set(fixed_t x, fixed_t y)
|
||||||
{
|
{
|
||||||
this->x = x;
|
p.X = x / 65536.;
|
||||||
this->y = y;
|
p.Y = y / 65536.;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set(double x, double y)
|
void set(double x, double y)
|
||||||
{
|
{
|
||||||
this->x = FLOAT2FIXED(x);
|
p.X = x;
|
||||||
this->y = FLOAT2FIXED(y);
|
p.Y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
double fX() const
|
double fX() const
|
||||||
{
|
{
|
||||||
return FIXED2DBL(x);
|
return p.X;
|
||||||
}
|
}
|
||||||
|
|
||||||
double fY() const
|
double fY() const
|
||||||
{
|
{
|
||||||
return FIXED2DBL(y);
|
return p.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_t fixX() const
|
fixed_t fixX() const
|
||||||
{
|
{
|
||||||
return x;
|
return FLOAT2FIXED(p.X);
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_t fixY() const
|
fixed_t fixY() const
|
||||||
{
|
{
|
||||||
return y;
|
return FLOAT2FIXED(p.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector2 fPos()
|
DVector2 fPos()
|
||||||
{
|
{
|
||||||
return{ fX(), fY() };
|
return { p.X, p.Y };
|
||||||
}
|
}
|
||||||
|
|
||||||
float fx, fy; // Floating point coordinates of this vertex (excluding polyoblect translation!)
|
|
||||||
angle_t viewangle; // precalculated angle for clipping
|
angle_t viewangle; // precalculated angle for clipping
|
||||||
int angletime; // recalculation time for view angle
|
int angletime; // recalculation time for view angle
|
||||||
bool dirty; // something has changed and needs to be recalculated
|
bool dirty; // something has changed and needs to be recalculated
|
||||||
|
@ -157,8 +157,7 @@ public:
|
||||||
|
|
||||||
vertex_t()
|
vertex_t()
|
||||||
{
|
{
|
||||||
x = y = 0;
|
p = { 0,0 };
|
||||||
fx = fy = 0;
|
|
||||||
angletime = 0;
|
angletime = 0;
|
||||||
viewangle = 0;
|
viewangle = 0;
|
||||||
dirty = true;
|
dirty = true;
|
||||||
|
@ -169,17 +168,17 @@ public:
|
||||||
|
|
||||||
bool operator== (const vertex_t &other)
|
bool operator== (const vertex_t &other)
|
||||||
{
|
{
|
||||||
return x == other.x && y == other.y;
|
return p == other.p;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!= (const vertex_t &other)
|
bool operator!= (const vertex_t &other)
|
||||||
{
|
{
|
||||||
return x != other.x || y != other.y;
|
return p != other.p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
x = y = 0;
|
p.Zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
angle_t GetClipAngle();
|
angle_t GetClipAngle();
|
||||||
|
@ -397,12 +396,12 @@ public:
|
||||||
// This is for the software renderer
|
// This is for the software renderer
|
||||||
fixed_t ZatPointFixed(const DVector2 &pos) const
|
fixed_t ZatPointFixed(const DVector2 &pos) const
|
||||||
{
|
{
|
||||||
return xs_CRoundToInt((d + a*pos.X + b*pos.Y) * ic / (-65536.0));
|
return FLOAT2FIXED(ZatPoint(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed_t ZatPointFixed(const vertex_t *v) const
|
fixed_t ZatPointFixed(const vertex_t *v) const
|
||||||
{
|
{
|
||||||
return FixedMul(ic, -d - DMulScale16(a, v->fixX(), b, v->fixY()));
|
return FLOAT2FIXED(ZatPoint(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -420,7 +419,7 @@ public:
|
||||||
|
|
||||||
double ZatPoint(const vertex_t *v) const
|
double ZatPoint(const vertex_t *v) const
|
||||||
{
|
{
|
||||||
return FIXED2DBL(FixedMul(ic, -d - DMulScale16(a, v->fixX(), b, v->fixY())));
|
return (d + a*v->fX() + b*v->fY()) * ic / (-65536.0 * 65536.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double ZatPoint(const AActor *ac) const
|
double ZatPoint(const AActor *ac) const
|
||||||
|
@ -431,7 +430,7 @@ public:
|
||||||
// Returns the value of z at vertex v if d is equal to dist
|
// Returns the value of z at vertex v if d is equal to dist
|
||||||
double ZatPointDist(const vertex_t *v, double dist)
|
double ZatPointDist(const vertex_t *v, double dist)
|
||||||
{
|
{
|
||||||
return FIXED2DBL(FixedMul(ic, -FLOAT2FIXED(dist) - DMulScale16(a, v->fixX(), b, v->fixY())));
|
return (dist + a*v->fX() + b*v->fY()) * ic / (-65536.0 * 65536.0);
|
||||||
}
|
}
|
||||||
// Flips the plane's vertical orientiation, so that if it pointed up,
|
// Flips the plane's vertical orientiation, so that if it pointed up,
|
||||||
// it will point down, and vice versa.
|
// it will point down, and vice versa.
|
||||||
|
|
Loading…
Reference in a new issue