- adjustments to GL code for texture scale and vertex coordinate access.

This commit is contained in:
Christoph Oelckers 2016-03-29 11:26:33 +02:00
parent ae14268989
commit a87c292f10
13 changed files with 100 additions and 102 deletions

View file

@ -512,13 +512,13 @@ CCMD(dumpgeometry)
if (seg->linedef)
{
Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, linedef %d, side %d",
FIXED2FLOAT(seg->v1->x), FIXED2FLOAT(seg->v1->y), FIXED2FLOAT(seg->v2->x), FIXED2FLOAT(seg->v2->y),
seg->v1->fX(), seg->v1->fY(), seg->v2->fX(), seg->v2->fY(),
int(seg-segs), int(seg->linedef-lines), seg->sidedef != seg->linedef->sidedef[0]);
}
else
{
Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, miniseg",
FIXED2FLOAT(seg->v1->x), FIXED2FLOAT(seg->v1->y), FIXED2FLOAT(seg->v2->x), FIXED2FLOAT(seg->v2->y),
seg->v1->fX(), seg->v1->fY(), seg->v2->fX(), seg->v2->fY(),
int(seg-segs));
}
if (seg->PartnerSeg)

View file

@ -331,8 +331,8 @@ void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, F
shape.Resize(subsector->numlines);
for(unsigned i=0; i<subsector->numlines; i++)
{
centerx += (shape[i].x = subsector->firstline[i].v1->x + portal->xDisplacement);
centery += (shape[i].y = subsector->firstline[i].v1->y + portal->yDisplacement);
centerx += (shape[i].x = subsector->firstline[i].v1->fixX() + portal->xDisplacement);
centery += (shape[i].y = subsector->firstline[i].v1->fixY() + portal->yDisplacement);
}
FCoverageBuilder build(subsector, portal);
@ -487,8 +487,8 @@ void gl_InitPortals()
}
for (auto glport : glLinePortals)
{
glport.dx = glport.v2->x - glport.v1->x;
glport.dy = glport.v2->y - glport.v1->y;
glport.dx = glport.v2->fixX() - glport.v1->fixX();
glport.dy = glport.v2->fixY() - glport.v1->fixY();
}
linePortalToGL.Resize(linePortals.Size());
for (unsigned i = 0; i < linePortals.Size(); i++)
@ -496,7 +496,7 @@ void gl_InitPortals()
linePortalToGL[i] = &glLinePortals[tempindex[i]];
/*
Printf("portal at line %d translates to GL portal %d, range = %f,%f to %f,%f\n",
int(linePortals[i].mOrigin - lines), tempindex[i], linePortalToGL[i]->v1->x / 65536., linePortalToGL[i]->v1->y / 65536., linePortalToGL[i]->v2->x / 65536., linePortalToGL[i]->v2->y / 65536.);
int(linePortals[i].mOrigin - lines), tempindex[i], linePortalToGL[i]->v1->fixX() / 65536., linePortalToGL[i]->v1->fixY() / 65536., linePortalToGL[i]->v2->fixX() / 65536., linePortalToGL[i]->v2->fixY() / 65536.);
*/
}
}
@ -519,7 +519,7 @@ CCMD(dumpportals)
Printf(PRINT_LOG, "\tSubsector %d (%d):\n\t\t", j, sub->render_sector->sectornum);
for(unsigned k = 0;k< sub->numlines; k++)
{
Printf(PRINT_LOG, "(%.3f,%.3f), ", sub->firstline[k].v1->x/65536. + xdisp, sub->firstline[k].v1->y/65536. + ydisp);
Printf(PRINT_LOG, "(%.3f,%.3f), ", sub->firstline[k].v1->fixX()/65536. + xdisp, sub->firstline[k].v1->fixY()/65536. + ydisp);
}
Printf(PRINT_LOG, "\n\t\tCovered by subsectors:\n");
FPortalCoverage *cov = &sub->portalcoverage[portals[i]->plane];
@ -529,7 +529,7 @@ CCMD(dumpportals)
Printf(PRINT_LOG, "\t\t\t%5d (%4d): ", cov->subsectors[l], csub->render_sector->sectornum);
for(unsigned m = 0;m< csub->numlines; m++)
{
Printf(PRINT_LOG, "(%.3f,%.3f), ", csub->firstline[m].v1->x/65536., csub->firstline[m].v1->y/65536.);
Printf(PRINT_LOG, "(%.3f,%.3f), ", csub->firstline[m].v1->fixX()/65536., csub->firstline[m].v1->fixY()/65536.);
}
Printf(PRINT_LOG, "\n");
}

View file

@ -106,7 +106,7 @@ struct cvertex_t
operator int () const { return ((x>>16)&0xffff) | y; }
bool operator!= (const cvertex_t &other) const { return x != other.x || y != other.y; }
cvertex_t& operator =(const vertex_t *v) { x = v->x; y = v->y; return *this; }
cvertex_t& operator =(const vertex_t *v) { x = v->fixX(); y = v->fixY(); return *this; }
};
typedef TMap<cvertex_t, int> FSectionVertexMap;
@ -286,7 +286,7 @@ static void PrepareSectorData()
seg[j].PartnerSeg!=NULL &&
subsectors[i].render_sector != seg[j].PartnerSeg->Subsector->render_sector)
{
DPrintf("Found hack: (%d,%d) (%d,%d)\n", seg[j].v1->x>>16, seg[j].v1->y>>16, seg[j].v2->x>>16, seg[j].v2->y>>16);
DPrintf("Found hack: (%f,%f) (%f,%f)\n", seg[j].v1->fX(), seg[j].v1->fY(), seg[j].v2->fX(), seg[j].v2->fY());
subsectors[i].hacked|=5;
SpreadHackedFlag(&subsectors[i]);
}
@ -512,8 +512,8 @@ static void PrepareSegs()
// Get floatng point coordinates of vertices
for(int i = 0; i < numvertexes; i++)
{
vertexes[i].fx = FIXED2FLOAT(vertexes[i].x);
vertexes[i].fy = FIXED2FLOAT(vertexes[i].y);
vertexes[i].fx = vertexes[i].fX();
vertexes[i].fy = vertexes[i].fY();
vertexes[i].dirty = true;
}

View file

@ -354,9 +354,7 @@ void ADynamicLight::UpdateLocation()
DVector3 pos = target->Vec3Offset(m_off.X * c + m_off.Y * s, m_off.X * s - m_off.Y * c, m_off.Z + target->GetBobOffset());
SetXYZ(pos); // attached lights do not need to go into the regular blockmap
PrevX = target->_f_X();
PrevY = target->_f_Y();
PrevZ = target->_f_Z();
Prev = target->Pos();
subsector = R_PointInSubsector(target->_f_X(), target->_f_Y());
Sector = subsector->sector;
}
@ -509,23 +507,23 @@ static FLightNode * DeleteLightNode(FLightNode * node)
//
//==========================================================================
float ADynamicLight::DistToSeg(const fixedvec3 &pos, seg_t *seg)
double ADynamicLight::DistToSeg(const fixedvec3 &pos, seg_t *seg)
{
float u, px, py;
double u, px, py;
float seg_dx = FIXED2FLOAT(seg->v2->x - seg->v1->x);
float seg_dy = FIXED2FLOAT(seg->v2->y - seg->v1->y);
float seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy;
double seg_dx = seg->v2->fX() - seg->v1->fX();
double seg_dy = seg->v2->fY() - seg->v1->fY();
double seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy;
u = (FIXED2FLOAT(pos.x - seg->v1->x) * seg_dx + FIXED2FLOAT(pos.y - seg->v1->y) * seg_dy) / seg_length_sq;
if (u < 0.f) u = 0.f; // clamp the test point to the line segment
if (u > 1.f) u = 1.f;
u = ((FIXED2DBL(pos.x) - seg->v1->fX()) * seg_dx + (FIXED2DBL(pos.y) - seg->v1->fY()) * seg_dy) / seg_length_sq;
if (u < 0.) u = 0.; // clamp the test point to the line segment
if (u > 1.) u = 1.;
px = FIXED2FLOAT(seg->v1->x) + (u * seg_dx);
py = FIXED2FLOAT(seg->v1->y) + (u * seg_dy);
px = seg->v1->fX() + (u * seg_dx);
py = seg->v1->fY() + (u * seg_dy);
px -= FIXED2FLOAT(pos.x);
py -= FIXED2FLOAT(pos.y);
px -= FIXED2DBL(pos.x);
py -= FIXED2DBL(pos.y);
return (px*px) + (py*py);
}
@ -558,7 +556,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe
if (seg->sidedef && seg->linedef && seg->linedef->validcount!=::validcount)
{
// light is in front of the seg
if (DMulScale32(pos.y - seg->v1->y, seg->v2->x - seg->v1->x, seg->v1->x - pos.x, seg->v2->y - seg->v1->y) <= 0)
if (DMulScale32(pos.y - seg->v1->fixY(), seg->v2->fixX() - seg->v1->fixX(), seg->v1->fixX() - pos.x, seg->v2->fixY() - seg->v1->fixY()) <= 0)
{
seg->linedef->validcount = validcount;
touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides);
@ -574,7 +572,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe
line_t *other = port->mDestination;
if (other->validcount != ::validcount)
{
subsector_t *othersub = R_PointInSubsector(other->v1->x + other->dx / 2, other->v1->y + other->dy / 2);
subsector_t *othersub = R_PointInSubsector(other->v1->fixX() + other->dx / 2, other->v1->fixY() + other->dy / 2);
if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(other), othersub, radius);
}
}
@ -601,7 +599,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe
AActor *sb = subSec->sector->SkyBoxes[sector_t::ceiling];
if (sb->specialf1 < Z() + radius)
{
fixedvec2 refpos = { other->v1->x + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->y + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) };
fixedvec2 refpos = { other->v1->fixX() + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->fixY() + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) };
subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y);
if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(othersub->sector), othersub, radius);
}
@ -612,7 +610,7 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe
AActor *sb = subSec->sector->SkyBoxes[sector_t::floor];
if (sb->specialf1 > Z() - radius)
{
fixedvec2 refpos = { other->v1->x + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->y + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) };
fixedvec2 refpos = { other->v1->fixX() + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->fixY() + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) };
subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y);
if (othersub->validcount != ::validcount) CollectWithinRadius(_f_PosRelative(othersub->sector), othersub, radius);
}

View file

@ -99,7 +99,7 @@ public:
FLightNode * touching_sector;
private:
float DistToSeg(const fixedvec3 &pos, seg_t *seg);
double DistToSeg(const fixedvec3 &pos, seg_t *seg);
void CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSec, float radius);
protected:

View file

@ -1182,10 +1182,10 @@ void FDrawInfo::FloodUpperGap(seg_t * seg)
v2=seg->linedef->v1;
}
ws.x1= FIXED2FLOAT(v1->x);
ws.y1= FIXED2FLOAT(v1->y);
ws.x2= FIXED2FLOAT(v2->x);
ws.y2= FIXED2FLOAT(v2->y);
ws.x1 = v1->fX();
ws.y1 = v1->fY();
ws.x2 = v2->fX();
ws.y2 = v2->fY();
ws.z1= FIXED2FLOAT(frontz);
ws.z2= FIXED2FLOAT(backz);
@ -1235,10 +1235,10 @@ void FDrawInfo::FloodLowerGap(seg_t * seg)
v2=seg->linedef->v1;
}
ws.x1= FIXED2FLOAT(v1->x);
ws.y1= FIXED2FLOAT(v1->y);
ws.x2= FIXED2FLOAT(v2->x);
ws.y2= FIXED2FLOAT(v2->y);
ws.x1 = v1->fX();
ws.y1 = v1->fY();
ws.x2 = v2->fX();
ws.y2 = v2->fY();
ws.z2= FIXED2FLOAT(frontz);
ws.z1= FIXED2FLOAT(backz);

View file

@ -655,10 +655,10 @@ void GLSkyboxPortal::DrawContents()
PlaneMirrorMode=0;
bool oldclamp = gl_RenderState.SetDepthClamp(false);
fixedvec3 viewpos = origin->InterpolatedPosition(r_TicFrac);
viewx = viewpos.x;
viewy = viewpos.y;
viewz = viewpos.z;
DVector3 viewpos = origin->InterpolatedPosition(r_TicFracF);
viewx = FLOAT2FIXED(viewpos.X);
viewy = FLOAT2FIXED(viewpos.Y);
viewz = FLOAT2FIXED(viewpos.Z);
viewangle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * FIXED2DBL(r_TicFrac)).BAMs();
// Don't let the viewpoint be too close to a floor or ceiling
@ -883,19 +883,19 @@ void GLMirrorPortal::DrawContents()
if (linedef->dx == 0)
{
// vertical mirror
viewx = v1->x - startx + v1->x;
viewx = v1->fixX() - startx + v1->fixX();
// Compensation for reendering inaccuracies
if (startx<v1->x) viewx -= FRACUNIT/2;
if (startx<v1->fixX()) viewx -= FRACUNIT/2;
else viewx += FRACUNIT/2;
}
else if (linedef->dy == 0)
{
// horizontal mirror
viewy = v1->y - starty + v1->y;
viewy = v1->fixY() - starty + v1->fixY();
// Compensation for reendering inaccuracies
if (starty<v1->y) viewy -= FRACUNIT/2;
if (starty<v1->fixY()) viewy -= FRACUNIT/2;
else viewy += FRACUNIT/2;
}
else
@ -903,10 +903,10 @@ void GLMirrorPortal::DrawContents()
// any mirror--use floats to avoid integer overflow.
// Use doubles to avoid losing precision which is very important here.
double dx = FIXED2DBL(v2->x - v1->x);
double dy = FIXED2DBL(v2->y - v1->y);
double x1 = FIXED2DBL(v1->x);
double y1 = FIXED2DBL(v1->y);
double dx = v2->fX() - v1->fX();
double dy = v2->fY() - v1->fY();
double x1 = v1->fX();
double y1 = v1->fY();
double x = FIXED2DBL(startx);
double y = FIXED2DBL(starty);
@ -924,8 +924,8 @@ void GLMirrorPortal::DrawContents()
viewy+= FLOAT2FIXED(v[0] * renderdepth / 2);
}
// we cannot afford any imprecisions caused by R_PointToAngle2 here. They'd be visible as seams around the mirror.
viewangle = 2*R_PointToAnglePrecise (linedef->v1->x, linedef->v1->y,
linedef->v2->x, linedef->v2->y) - startang;
viewangle = 2*R_PointToAnglePrecise (linedef->v1->fixX(), linedef->v1->fixY(),
linedef->v2->fixX(), linedef->v2->fixY()) - startang;
GLRenderer->mViewActor = NULL;
r_showviewer = true;
@ -960,7 +960,7 @@ int GLLinePortal::ClipSubsector(subsector_t *sub)
// this seg is completely behind the mirror!
for(unsigned int i=0;i<sub->numlines;i++)
{
if (P_PointOnLineSidePrecise(sub->firstline[i].v1->x, sub->firstline[i].v1->y, line()) == 0) return PClip_Inside;
if (P_PointOnLineSidePrecise(sub->firstline[i].v1->fixX(), sub->firstline[i].v1->fixY(), line()) == 0) return PClip_Inside;
}
return PClip_InFront;
}
@ -1015,7 +1015,7 @@ void GLLineToLinePortal::DrawContents()
line_t *line = lines[i].seg->linedef->getPortalDestination();
subsector_t *sub;
if (line->sidedef[0]->Flags & WALLF_POLYOBJ)
sub = R_PointInSubsector(line->v1->x, line->v1->y);
sub = R_PointInSubsector(line->v1->fixX(), line->v1->fixY());
else sub = line->frontsector->subsectors[0];
int mapsection = sub->mapsection;
currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7);

View file

@ -508,12 +508,12 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
if (!(currentmapsection[thing->subsector->mapsection>>3] & (1 << (thing->subsector->mapsection & 7)))) return;
// [RH] Interpolate the sprite's position to make it look smooth
fixedvec3 thingpos = thing->InterpolatedPosition(r_TicFrac);
DVector3 thingpos = thing->InterpolatedPosition(r_TicFracF);
// Too close to the camera. This doesn't look good if it is a sprite.
if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy)<2*FRACUNIT)
if (fabs(thingpos.X - FIXED2DBL(viewx) < 2 && fabs(thingpos.Y - FIXED2DBL(viewy) < 2)))
{
if (viewz >= thingpos.z - 2 * FRACUNIT && viewz <= thingpos.z + FLOAT2FIXED(thing->Height) + 2 * FRACUNIT)
if (FIXED2DBL(viewz) >= thingpos.Z - 2 && FIXED2DBL(viewz) <= thingpos.Z + thing->Height + 2)
{
// exclude vertically moving objects from this check.
if (!thing->Vel.isZero())
@ -532,14 +532,14 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL)
{
fixed_t clipdist = FLOAT2FIXED(clamp(thing->Speed, thing->target->radius, thing->target->radius*2));
if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy) < clipdist) return;
if (P_AproxDistance(FLOAT2FIXED(thingpos.X)-viewx, FLOAT2FIXED(thingpos.Y)-viewy) < clipdist) return;
}
thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again.
}
if (GLRenderer->mCurrentPortal)
{
int clipres = GLRenderer->mCurrentPortal->ClipPoint(thingpos.x, thingpos.y);
int clipres = GLRenderer->mCurrentPortal->ClipPoint(FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y));
if (clipres == GLPortal::PClip_InFront) return;
}
@ -556,21 +556,21 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
}
x = FIXED2FLOAT(thingpos.x);
z = FIXED2FLOAT(thingpos.z)-thing->Floorclip;
y = FIXED2FLOAT(thingpos.y);
x = thingpos.X;
z = thingpos.Z - thing->Floorclip;
y = thingpos.Y;
// [RH] Make floatbobbing a renderer-only effect.
if (thing->flags2 & MF2_FLOATBOB)
{
float fz = FIXED2FLOAT(thing->GetBobOffset(r_TicFrac));
float fz = thing->GetBobOffset(r_TicFracF);
z += fz;
}
modelframe = gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
if (!modelframe)
{
angle_t ang = R_PointToAngle(thingpos.x, thingpos.y);
angle_t ang = R_PointToAngle(FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y));
bool mirror;
FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->Angles.Yaw.BAMs(), &mirror);
@ -607,7 +607,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
// Tests show that this doesn't look good for many decorations and corpses
if (spriteheight > 0 && gl_spriteclip > 0 && (thing->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE)
{
PerformSpriteClipAdjustment(thing, thingpos.x, thingpos.y, spriteheight);
PerformSpriteClipAdjustment(thing, FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y), spriteheight);
}
float viewvecX;
@ -643,7 +643,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
gltexture=NULL;
}
depth = DMulScale20 (thingpos.x-viewx, viewtancos, thingpos.y-viewy, viewtansin);
depth = DMulScale20 (FLOAT2FIXED(thingpos.X)-viewx, viewtancos, FLOAT2FIXED(thingpos.Y)-viewy, viewtansin);
// light calculation
@ -659,7 +659,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
rendersector->GetCeilingLight() : rendersector->GetFloorLight());
foglevel = (BYTE)clamp<short>(rendersector->lightlevel, 0, 255);
lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingpos.x, thingpos.y, thingpos.z);
lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y), FLOAT2FIXED(thingpos.Z));
ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff;
ThingColor.a = 255;

View file

@ -90,8 +90,8 @@ void gl_SetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t *
int togroup = subsec->sector->PortalGroup;
if (fromgroup == togroup || fromgroup == 0 || togroup == 0) goto direct;
fixedvec2 offset = Displacements.getOffset(fromgroup, togroup);
dist = FVector3(x - light->X() - FIXED2FLOAT(offset.x), y - light->Y() - FIXED2FLOAT(offset.y), z - light->Z()).LengthSquared();
DVector2 offset = Displacements.getOffset(fromgroup, togroup);
dist = FVector3(x - light->X() - offset.X, y - light->Y() - offset.Y, z - light->Z()).LengthSquared();
}
else
{

View file

@ -134,8 +134,8 @@ void GLWall::PutWall(bool translucent)
if (translucent) // translucent walls
{
viewdistance = P_AproxDistance(((seg->linedef->v1->x + seg->linedef->v2->x) >> 1) - viewx,
((seg->linedef->v1->y + seg->linedef->v2->y) >> 1) - viewy);
viewdistance = P_AproxDistance(((seg->linedef->v1->fixX() + seg->linedef->v2->fixX()) >> 1) - viewx,
((seg->linedef->v1->fixY() + seg->linedef->v2->fixY()) >> 1) - viewy);
gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this);
}
else
@ -1396,15 +1396,15 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
}
else // polyobjects must be rendered per seg.
{
if (abs(v1->x - v2->x) > abs(v1->y - v2->y))
if (fabs(v1->fX() - v2->fX()) > fabs(v1->fY() - v2->fY()))
{
glseg.fracleft = float(seg->v1->x - v1->x) / float(v2->x - v1->x);
glseg.fracright = float(seg->v2->x - v1->x) / float(v2->x - v1->x);
glseg.fracleft = (seg->v1->fX() - v1->fX()) / (v2->fX() - v1->fX());
glseg.fracright = (seg->v2->fX() - v1->fX()) / float(v2->fX() - v1->fX());
}
else
{
glseg.fracleft = float(seg->v1->y - v1->y) / float(v2->y - v1->y);
glseg.fracright = float(seg->v2->y - v1->y) / float(v2->y - v1->y);
glseg.fracleft = (seg->v1->fY() - v1->fY()) / (v2->fY() - v1->fY());
glseg.fracright = (seg->v2->fY() - v1->fY()) / (v2->fY() - v1->fY());
}
v1 = seg->v1;
v2 = seg->v2;
@ -1414,10 +1414,10 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
vertexes[0] = v1;
vertexes[1] = v2;
glseg.x1 = FIXED2FLOAT(v1->x);
glseg.y1 = FIXED2FLOAT(v1->y);
glseg.x2 = FIXED2FLOAT(v2->x);
glseg.y2 = FIXED2FLOAT(v2->y);
glseg.x1 = v1->fX();
glseg.y1 = v1->fY();
glseg.x2 = v2->fX();
glseg.y2 = v2->fY();
Colormap = frontsector->ColorMap;
flags = 0;
dynlightindex = UINT_MAX;
@ -1700,10 +1700,10 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t *
vertexes[0] = v1;
vertexes[1] = v2;
glseg.x1 = FIXED2FLOAT(v1->x);
glseg.y1 = FIXED2FLOAT(v1->y);
glseg.x2 = FIXED2FLOAT(v2->x);
glseg.y2 = FIXED2FLOAT(v2->y);
glseg.x1 = v1->fX();
glseg.y1 = v1->fY();
glseg.x2 = v2->fX();
glseg.y2 = v2->fY();
glseg.fracleft = 0;
glseg.fracright = 1;

View file

@ -264,7 +264,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u
return inputBuffer;
// already scaled?
if (inputTexture->xScale >= FRACUNIT*2 && inputTexture->yScale >= FRACUNIT*2)
if (inputTexture->Scale.X >= 2 && inputTexture->Scale.Y >= 2)
return inputBuffer;
switch (inputTexture->UseType)

View file

@ -457,13 +457,13 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
FTexture *basetex = tx->GetRedirect(false);
// allow the redirect only if the textute is not expanded or the scale matches.
if (!expanded || (tx->xScale == basetex->xScale && tx->yScale == basetex->yScale))
if (!expanded || (tx->Scale.X == basetex->Scale.X && tx->Scale.Y == basetex->Scale.Y))
{
mBaseLayer = ValidateSysTexture(basetex, expanded);
}
float fxScale = FIXED2FLOAT(tx->xScale);
float fyScale = FIXED2FLOAT(tx->yScale);
float fxScale = tx->Scale.X;
float fyScale = tx->Scale.Y;
// mSpriteRect is for positioning the sprite in the scene.
mSpriteRect.left = -mLeftOffset / fxScale;
@ -646,7 +646,7 @@ void FMaterial::Bind(int clampmode, int translation)
int usebright = false;
int maxbound = 0;
bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT && clampmode <= CLAMP_XY && !mExpanded;
bool allowhires = tex->Scale.X == 1 && tex->Scale.Y == 1 && clampmode <= CLAMP_XY && !mExpanded;
if (tex->bHasCanvas) clampmode = CLAMP_CAMTEX;
else if (tex->bWarped && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
@ -701,12 +701,12 @@ void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const
if (x == FRACUNIT)
{
tci->mRenderWidth = mRenderWidth;
tci->mScaleX = tex->xScale;
tci->mScaleX = FLOAT2FIXED(tex->Scale.X);
tci->mTempScaleX = FRACUNIT;
}
else
{
fixed_t scale_x = FixedMul(x, tex->xScale);
fixed_t scale_x = fixed_t(x * tex->Scale.X);
int foo = (mWidth << 17) / scale_x;
tci->mRenderWidth = (foo >> 1) + (foo & 1);
tci->mScaleX = scale_x;
@ -716,12 +716,12 @@ void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const
if (y == FRACUNIT)
{
tci->mRenderHeight = mRenderHeight;
tci->mScaleY = tex->yScale;
tci->mScaleY = FLOAT2FIXED(tex->Scale.Y);
tci->mTempScaleY = FRACUNIT;
}
else
{
fixed_t scale_y = FixedMul(y, tex->yScale);
fixed_t scale_y = fixed_t(y * tex->Scale.Y);
int foo = (mHeight << 17) / scale_y;
tci->mRenderHeight = (foo >> 1) + (foo & 1);
tci->mScaleY = scale_y;

View file

@ -187,33 +187,33 @@ public:
int GetScaledLeftOffset() const
{
return DivScale16(mLeftOffset, tex->xScale);
return int(mLeftOffset / tex->Scale.X);
}
int GetScaledTopOffset() const
{
return DivScale16(mTopOffset, tex->yScale);
return int(mTopOffset / tex->Scale.Y);
}
float GetScaledLeftOffsetFloat() const
{
return mLeftOffset / FIXED2FLOAT(tex->xScale);
return float(mLeftOffset / tex->Scale.X);
}
float GetScaledTopOffsetFloat() const
{
return mTopOffset/ FIXED2FLOAT(tex->yScale);
return float(mTopOffset/ tex->Scale.Y);
}
// This is scaled size in floating point as needed by sprites
float GetScaledWidthFloat() const
{
return mWidth / FIXED2FLOAT(tex->xScale);
return float(mWidth / tex->Scale.X);
}
float GetScaledHeightFloat() const
{
return mHeight / FIXED2FLOAT(tex->yScale);
return float(mHeight / tex->Scale.Y);
}
// Get right/bottom UV coordinates for patch drawing