- floatified the texture coordinate code.

This commit is contained in:
Christoph Oelckers 2016-04-08 01:42:43 +02:00
parent eaf055dff4
commit 4d5671d654
11 changed files with 188 additions and 184 deletions

View File

@ -58,7 +58,7 @@ struct FGLLinePortal
{ {
// defines the complete span of this portal // defines the complete span of this portal
vertex_t *v1, *v2; // vertices, from v1 to v2 vertex_t *v1, *v2; // vertices, from v1 to v2
fixed_t dx, dy; // precalculated v2 - v1 for side checking DVector2 delta; // precalculated v2 - v1 for side checking
FLinePortal *reference; // one of the associated line portals, for retrieving translation info etc. FLinePortal *reference; // one of the associated line portals, for retrieving translation info etc.
}; };

View File

@ -444,7 +444,7 @@ void gl_InitPortals()
tempindex[i] = glLinePortals.Size(); tempindex[i] = glLinePortals.Size();
line_t *pSrcLine = linePortals[i].mOrigin; line_t *pSrcLine = linePortals[i].mOrigin;
line_t *pLine = linePortals[i].mDestination; line_t *pLine = linePortals[i].mDestination;
FGLLinePortal glport = { pLine->v1, pLine->v2, 0, 0, &linePortals[i] }; FGLLinePortal glport = { pLine->v1, pLine->v2, {0, 0}, &linePortals[i] };
glLinePortals.Push(glport); glLinePortals.Push(glport);
// We cannot do this grouping for non-linked portals because they can be changed at run time. // We cannot do this grouping for non-linked portals because they can be changed at run time.
@ -484,8 +484,7 @@ void gl_InitPortals()
} }
for (auto glport : glLinePortals) for (auto glport : glLinePortals)
{ {
glport.dx = glport.v2->fixX() - glport.v1->fixX(); glport.delta = glport.v2->fPos() - glport.v1->fPos();
glport.dy = glport.v2->fixY() - glport.v1->fixY();
} }
linePortalToGL.Resize(linePortals.Size()); linePortalToGL.Resize(linePortals.Size());
for (unsigned i = 0; i < linePortals.Size(); i++) for (unsigned i = 0; i < linePortals.Size(); i++)

View File

@ -161,8 +161,8 @@ struct FDrawInfo
{ {
seg_t * seg; seg_t * seg;
subsector_t * sub; subsector_t * sub;
fixed_t planez; float Planez;
fixed_t planezfront; float Planezfront;
}; };
struct MissingSegInfo struct MissingSegInfo
@ -204,10 +204,10 @@ struct FDrawInfo
~FDrawInfo(); ~FDrawInfo();
void ClearBuffers(); void ClearBuffers();
bool DoOneSectorUpper(subsector_t * subsec, fixed_t planez); bool DoOneSectorUpper(subsector_t * subsec, float planez);
bool DoOneSectorLower(subsector_t * subsec, fixed_t planez); bool DoOneSectorLower(subsector_t * subsec, float planez);
bool DoFakeBridge(subsector_t * subsec, fixed_t planez); bool DoFakeBridge(subsector_t * subsec, float planez);
bool DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez); bool DoFakeCeilingBridge(subsector_t * subsec, float planez);
bool CheckAnchorFloor(subsector_t * sub); bool CheckAnchorFloor(subsector_t * sub);
bool CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor); bool CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor);
@ -216,8 +216,8 @@ struct FDrawInfo
void CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor); void CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor);
void CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor); void CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor);
void AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight); void AddUpperMissingTexture(side_t * side, subsector_t *sub, float backheight);
void AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight); void AddLowerMissingTexture(side_t * side, subsector_t *sub, float backheight);
void HandleMissingTextures(); void HandleMissingTextures();
void DrawUnhandledMissingTextures(); void DrawUnhandledMissingTextures();
void AddHackedSubsector(subsector_t * sub); void AddHackedSubsector(subsector_t * sub);

View File

@ -140,12 +140,12 @@ void FDrawInfo::AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node)
// Collects all sectors that might need a fake ceiling // Collects all sectors that might need a fake ceiling
// //
//========================================================================== //==========================================================================
void FDrawInfo::AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight) void FDrawInfo::AddUpperMissingTexture(side_t * side, subsector_t *sub, float Backheight)
{ {
if (!side->segs[0]->backsector) return; if (!side->segs[0]->backsector) return;
totalms.Clock(); totalms.Clock();
for(int i=0; i<side->numsegs; i++) for (int i = 0; i < side->numsegs; i++)
{ {
seg_t *seg = side->segs[i]; seg_t *seg = side->segs[i];
@ -162,29 +162,29 @@ void FDrawInfo::AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t
return; return;
} }
for(unsigned int i=0;i<MissingUpperTextures.Size();i++) for (unsigned int i = 0; i < MissingUpperTextures.Size(); i++)
{ {
if (MissingUpperTextures[i].sub == sub) if (MissingUpperTextures[i].sub == sub)
{ {
// Use the lowest adjoining height to draw a fake ceiling if necessary // Use the lowest adjoining height to draw a fake ceiling if necessary
if (backheight < MissingUpperTextures[i].planez) if (Backheight < MissingUpperTextures[i].Planez)
{ {
MissingUpperTextures[i].planez = backheight; MissingUpperTextures[i].Planez = Backheight;
MissingUpperTextures[i].seg = seg; MissingUpperTextures[i].seg = seg;
} }
msi.MTI_Index = i; msi.MTI_Index = i;
msi.seg=seg; msi.seg = seg;
MissingUpperSegs.Push(msi); MissingUpperSegs.Push(msi);
totalms.Unclock(); totalms.Unclock();
return; return;
} }
} }
mti.seg=seg; mti.seg = seg;
mti.sub=sub; mti.sub = sub;
mti.planez=backheight; mti.Planez = Backheight;
msi.MTI_Index = MissingUpperTextures.Push(mti); msi.MTI_Index = MissingUpperTextures.Push(mti);
msi.seg=seg; msi.seg = seg;
MissingUpperSegs.Push(msi); MissingUpperSegs.Push(msi);
} }
} }
@ -196,7 +196,7 @@ void FDrawInfo::AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t
// Collects all sectors that might need a fake floor // Collects all sectors that might need a fake floor
// //
//========================================================================== //==========================================================================
void FDrawInfo::AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight) void FDrawInfo::AddLowerMissingTexture(side_t * side, subsector_t *sub, float Backheight)
{ {
sector_t *backsec = side->segs[0]->backsector; sector_t *backsec = side->segs[0]->backsector;
if (!backsec) return; if (!backsec) return;
@ -209,7 +209,7 @@ void FDrawInfo::AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t
totalms.Clock(); totalms.Clock();
// we need to check all segs of this sidedef // we need to check all segs of this sidedef
for(int i=0; i<side->numsegs; i++) for (int i = 0; i < side->numsegs; i++)
{ {
seg_t *seg = side->segs[i]; seg_t *seg = side->segs[i];
@ -228,35 +228,35 @@ void FDrawInfo::AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t
} }
// Ignore FF_FIX's because they are designed to abuse missing textures // Ignore FF_FIX's because they are designed to abuse missing textures
if (seg->backsector->e->XFloor.ffloors.Size() && (seg->backsector->e->XFloor.ffloors[0]->flags&(FF_FIX|FF_SEETHROUGH)) == FF_FIX) if (seg->backsector->e->XFloor.ffloors.Size() && (seg->backsector->e->XFloor.ffloors[0]->flags&(FF_FIX | FF_SEETHROUGH)) == FF_FIX)
{ {
totalms.Unclock(); totalms.Unclock();
return; return;
} }
for(unsigned int i=0;i<MissingLowerTextures.Size();i++) for (unsigned int i = 0; i < MissingLowerTextures.Size(); i++)
{ {
if (MissingLowerTextures[i].sub == sub) if (MissingLowerTextures[i].sub == sub)
{ {
// Use the highest adjoining height to draw a fake floor if necessary // Use the highest adjoining height to draw a fake floor if necessary
if (backheight > MissingLowerTextures[i].planez) if (Backheight > MissingLowerTextures[i].Planez)
{ {
MissingLowerTextures[i].planez = backheight; MissingLowerTextures[i].Planez = Backheight;
MissingLowerTextures[i].seg = seg; MissingLowerTextures[i].seg = seg;
} }
msi.MTI_Index = i; msi.MTI_Index = i;
msi.seg=seg; msi.seg = seg;
MissingLowerSegs.Push(msi); MissingLowerSegs.Push(msi);
totalms.Unclock(); totalms.Unclock();
return; return;
} }
} }
mti.seg=seg; mti.seg = seg;
mti.sub = sub; mti.sub = sub;
mti.planez=backheight; mti.Planez = Backheight;
msi.MTI_Index = MissingLowerTextures.Push(mti); msi.MTI_Index = MissingLowerTextures.Push(mti);
msi.seg=seg; msi.seg = seg;
MissingLowerSegs.Push(msi); MissingLowerSegs.Push(msi);
} }
} }
@ -269,24 +269,24 @@ void FDrawInfo::AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t
// //
// //
//========================================================================== //==========================================================================
bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez) bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, float Planez)
{ {
// Is there a one-sided wall in this sector? // Is there a one-sided wall in this sector?
// Do this first to avoid unnecessary recursion // Do this first to avoid unnecessary recursion
for(DWORD i=0; i< subsec->numlines; i++) for (DWORD i = 0; i < subsec->numlines; i++)
{ {
if (subsec->firstline[i].backsector == NULL) return false; if (subsec->firstline[i].backsector == NULL) return false;
if (subsec->firstline[i].PartnerSeg == NULL) return false; if (subsec->firstline[i].PartnerSeg == NULL) return false;
} }
for(DWORD i=0; i< subsec->numlines; i++) for (DWORD i = 0; i < subsec->numlines; i++)
{ {
seg_t * seg = subsec->firstline +i; seg_t * seg = subsec->firstline + i;
subsector_t * backsub = seg->PartnerSeg->Subsector; subsector_t * backsub = seg->PartnerSeg->Subsector;
// already checked? // already checked?
if (backsub->validcount == validcount) continue; if (backsub->validcount == validcount) continue;
backsub->validcount=validcount; backsub->validcount = validcount;
if (seg->frontsector != seg->backsector && seg->linedef) if (seg->frontsector != seg->backsector && seg->linedef)
{ {
@ -299,22 +299,22 @@ bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez)
if (sec->ceilingplane.isSlope()) return false; if (sec->ceilingplane.isSlope()) return false;
// Is the neighboring ceiling lower than the desired height? // Is the neighboring ceiling lower than the desired height?
if (sec->GetPlaneTexZ(sector_t::ceiling)<planez) if (sec->GetPlaneTexZF(sector_t::ceiling) < Planez)
{ {
// todo: check for missing textures. // todo: check for missing textures.
return false; return false;
} }
// This is an exact height match which means we don't have to do any further checks for this sector // This is an exact height match which means we don't have to do any further checks for this sector
if (sec->GetPlaneTexZ(sector_t::ceiling)==planez) if (sec->GetPlaneTexZF(sector_t::ceiling) == Planez)
{ {
// If there's a texture abort // If there's a texture abort
FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::top)]; FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::top)];
if (!tex || tex->UseType==FTexture::TEX_Null) continue; if (!tex || tex->UseType == FTexture::TEX_Null) continue;
else return false; else return false;
} }
} }
if (!DoOneSectorUpper(backsub, planez)) return false; if (!DoOneSectorUpper(backsub, Planez)) return false;
} }
// all checked ok. This subsector is part of the current fake plane // all checked ok. This subsector is part of the current fake plane
@ -327,24 +327,24 @@ bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez)
// //
// //
//========================================================================== //==========================================================================
bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez) bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, float Planez)
{ {
// Is there a one-sided wall in this subsector? // Is there a one-sided wall in this subsector?
// Do this first to avoid unnecessary recursion // Do this first to avoid unnecessary recursion
for(DWORD i=0; i< subsec->numlines; i++) for (DWORD i = 0; i < subsec->numlines; i++)
{ {
if (subsec->firstline[i].backsector == NULL) return false; if (subsec->firstline[i].backsector == NULL) return false;
if (subsec->firstline[i].PartnerSeg == NULL) return false; if (subsec->firstline[i].PartnerSeg == NULL) return false;
} }
for(DWORD i=0; i< subsec->numlines; i++) for (DWORD i = 0; i < subsec->numlines; i++)
{ {
seg_t * seg = subsec->firstline + i; seg_t * seg = subsec->firstline + i;
subsector_t * backsub = seg->PartnerSeg->Subsector; subsector_t * backsub = seg->PartnerSeg->Subsector;
// already checked? // already checked?
if (backsub->validcount == validcount) continue; if (backsub->validcount == validcount) continue;
backsub->validcount=validcount; backsub->validcount = validcount;
if (seg->frontsector != seg->backsector && seg->linedef) if (seg->frontsector != seg->backsector && seg->linedef)
{ {
@ -357,22 +357,22 @@ bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez)
if (sec->floorplane.isSlope()) return false; if (sec->floorplane.isSlope()) return false;
// Is the neighboring floor higher than the desired height? // Is the neighboring floor higher than the desired height?
if (sec->GetPlaneTexZ(sector_t::floor)>planez) if (sec->GetPlaneTexZF(sector_t::floor) > Planez)
{ {
// todo: check for missing textures. // todo: check for missing textures.
return false; return false;
} }
// This is an exact height match which means we don't have to do any further checks for this sector // This is an exact height match which means we don't have to do any further checks for this sector
if (sec->GetPlaneTexZ(sector_t::floor)==planez) if (sec->GetPlaneTexZF(sector_t::floor) == Planez)
{ {
// If there's a texture abort // If there's a texture abort
FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::bottom)]; FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::bottom)];
if (!tex || tex->UseType==FTexture::TEX_Null) continue; if (!tex || tex->UseType == FTexture::TEX_Null) continue;
else return false; else return false;
} }
} }
if (!DoOneSectorLower(backsub, planez)) return false; if (!DoOneSectorLower(backsub, Planez)) return false;
} }
// all checked ok. This sector is part of the current fake plane // all checked ok. This sector is part of the current fake plane
@ -386,24 +386,24 @@ bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez)
// //
// //
//========================================================================== //==========================================================================
bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez) bool FDrawInfo::DoFakeBridge(subsector_t * subsec, float Planez)
{ {
// Is there a one-sided wall in this sector? // Is there a one-sided wall in this sector?
// Do this first to avoid unnecessary recursion // Do this first to avoid unnecessary recursion
for(DWORD i=0; i< subsec->numlines; i++) for (DWORD i = 0; i < subsec->numlines; i++)
{ {
if (subsec->firstline[i].backsector == NULL) return false; if (subsec->firstline[i].backsector == NULL) return false;
if (subsec->firstline[i].PartnerSeg == NULL) return false; if (subsec->firstline[i].PartnerSeg == NULL) return false;
} }
for(DWORD i=0; i< subsec->numlines; i++) for (DWORD i = 0; i < subsec->numlines; i++)
{ {
seg_t * seg = subsec->firstline + i; seg_t * seg = subsec->firstline + i;
subsector_t * backsub = seg->PartnerSeg->Subsector; subsector_t * backsub = seg->PartnerSeg->Subsector;
// already checked? // already checked?
if (backsub->validcount == validcount) continue; if (backsub->validcount == validcount) continue;
backsub->validcount=validcount; backsub->validcount = validcount;
if (seg->frontsector != seg->backsector && seg->linedef) if (seg->frontsector != seg->backsector && seg->linedef)
{ {
@ -416,7 +416,7 @@ bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez)
if (sec->floorplane.isSlope()) return false; if (sec->floorplane.isSlope()) return false;
// Is the neighboring floor higher than the desired height? // Is the neighboring floor higher than the desired height?
if (sec->GetPlaneTexZ(sector_t::floor)<planez) if (sec->GetPlaneTexZF(sector_t::floor) < Planez)
{ {
// todo: check for missing textures. // todo: check for missing textures.
return false; return false;
@ -424,9 +424,9 @@ bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez)
// This is an exact height match which means we don't have to do any further checks for this sector // This is an exact height match which means we don't have to do any further checks for this sector
// No texture checks though! // No texture checks though!
if (sec->GetPlaneTexZ(sector_t::floor)==planez) continue; if (sec->GetPlaneTexZF(sector_t::floor) == Planez) continue;
} }
if (!DoFakeBridge(backsub, planez)) return false; if (!DoFakeBridge(backsub, Planez)) return false;
} }
// all checked ok. This sector is part of the current fake plane // all checked ok. This sector is part of the current fake plane
@ -439,24 +439,24 @@ bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez)
// //
// //
//========================================================================== //==========================================================================
bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez) bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, float Planez)
{ {
// Is there a one-sided wall in this sector? // Is there a one-sided wall in this sector?
// Do this first to avoid unnecessary recursion // Do this first to avoid unnecessary recursion
for(DWORD i=0; i< subsec->numlines; i++) for (DWORD i = 0; i < subsec->numlines; i++)
{ {
if (subsec->firstline[i].backsector == NULL) return false; if (subsec->firstline[i].backsector == NULL) return false;
if (subsec->firstline[i].PartnerSeg == NULL) return false; if (subsec->firstline[i].PartnerSeg == NULL) return false;
} }
for(DWORD i=0; i< subsec->numlines; i++) for (DWORD i = 0; i < subsec->numlines; i++)
{ {
seg_t * seg = subsec->firstline + i; seg_t * seg = subsec->firstline + i;
subsector_t * backsub = seg->PartnerSeg->Subsector; subsector_t * backsub = seg->PartnerSeg->Subsector;
// already checked? // already checked?
if (backsub->validcount == validcount) continue; if (backsub->validcount == validcount) continue;
backsub->validcount=validcount; backsub->validcount = validcount;
if (seg->frontsector != seg->backsector && seg->linedef) if (seg->frontsector != seg->backsector && seg->linedef)
{ {
@ -469,7 +469,7 @@ bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez)
if (sec->ceilingplane.isSlope()) return false; if (sec->ceilingplane.isSlope()) return false;
// Is the neighboring ceiling higher than the desired height? // Is the neighboring ceiling higher than the desired height?
if (sec->GetPlaneTexZ(sector_t::ceiling)>planez) if (sec->GetPlaneTexZF(sector_t::ceiling) > Planez)
{ {
// todo: check for missing textures. // todo: check for missing textures.
return false; return false;
@ -477,9 +477,9 @@ bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez)
// This is an exact height match which means we don't have to do any further checks for this sector // This is an exact height match which means we don't have to do any further checks for this sector
// No texture checks though! // No texture checks though!
if (sec->GetPlaneTexZ(sector_t::ceiling)==planez) continue; if (sec->GetPlaneTexZF(sector_t::ceiling) == Planez) continue;
} }
if (!DoFakeCeilingBridge(backsub, planez)) return false; if (!DoFakeCeilingBridge(backsub, Planez)) return false;
} }
// all checked ok. This sector is part of the current fake plane // all checked ok. This sector is part of the current fake plane
@ -497,27 +497,27 @@ void FDrawInfo::HandleMissingTextures()
{ {
sector_t fake; sector_t fake;
totalms.Clock(); totalms.Clock();
totalupper=MissingUpperTextures.Size(); totalupper = MissingUpperTextures.Size();
totallower=MissingLowerTextures.Size(); totallower = MissingLowerTextures.Size();
for(unsigned int i=0;i<MissingUpperTextures.Size();i++) for (unsigned int i = 0; i < MissingUpperTextures.Size(); i++)
{ {
if (!MissingUpperTextures[i].seg) continue; if (!MissingUpperTextures[i].seg) continue;
HandledSubsectors.Clear(); HandledSubsectors.Clear();
validcount++; validcount++;
if (MissingUpperTextures[i].planez > FLOAT2FIXED(ViewPos.Z)) if (MissingUpperTextures[i].Planez > ViewPos.Z)
{ {
// close the hole only if all neighboring sectors are an exact height match // close the hole only if all neighboring sectors are an exact height match
// Otherwise just fill in the missing textures. // Otherwise just fill in the missing textures.
MissingUpperTextures[i].sub->validcount=validcount; MissingUpperTextures[i].sub->validcount = validcount;
if (DoOneSectorUpper(MissingUpperTextures[i].sub, MissingUpperTextures[i].planez)) if (DoOneSectorUpper(MissingUpperTextures[i].sub, MissingUpperTextures[i].Planez))
{ {
sector_t * sec = MissingUpperTextures[i].seg->backsector; sector_t * sec = MissingUpperTextures[i].seg->backsector;
// The mere fact that this seg has been added to the list means that the back sector // The mere fact that this seg has been added to the list means that the back sector
// will be rendered so we can safely assume that it is already in the render list // will be rendered so we can safely assume that it is already in the render list
for(unsigned int j=0;j<HandledSubsectors.Size();j++) for (unsigned int j = 0; j < HandledSubsectors.Size(); j++)
{ {
gl_subsectorrendernode * node = SSR_List.GetNew(); gl_subsectorrendernode * node = SSR_List.GetNew();
node->sub = HandledSubsectors[j]; node->sub = HandledSubsectors[j];
@ -525,21 +525,21 @@ void FDrawInfo::HandleMissingTextures()
AddOtherCeilingPlane(sec->sectornum, node); AddOtherCeilingPlane(sec->sectornum, node);
} }
if (HandledSubsectors.Size()!=1) if (HandledSubsectors.Size() != 1)
{ {
// mark all subsectors in the missing list that got processed by this // mark all subsectors in the missing list that got processed by this
for(unsigned int j=0;j<HandledSubsectors.Size();j++) for (unsigned int j = 0; j < HandledSubsectors.Size(); j++)
{ {
for(unsigned int k=0;k<MissingUpperTextures.Size();k++) for (unsigned int k = 0; k < MissingUpperTextures.Size(); k++)
{ {
if (MissingUpperTextures[k].sub==HandledSubsectors[j]) if (MissingUpperTextures[k].sub == HandledSubsectors[j])
{ {
MissingUpperTextures[k].seg=NULL; MissingUpperTextures[k].seg = NULL;
} }
} }
} }
} }
else MissingUpperTextures[i].seg=NULL; else MissingUpperTextures[i].seg = NULL;
continue; continue;
} }
} }
@ -553,15 +553,15 @@ void FDrawInfo::HandleMissingTextures()
{ {
// It isn't a hole. Now check whether it might be a fake bridge // It isn't a hole. Now check whether it might be a fake bridge
sector_t * fakesector = gl_FakeFlat(MissingUpperTextures[i].seg->frontsector, &fake, false); sector_t * fakesector = gl_FakeFlat(MissingUpperTextures[i].seg->frontsector, &fake, false);
fixed_t planez = fakesector->GetPlaneTexZ(sector_t::ceiling); float planez = (float)fakesector->GetPlaneTexZF(sector_t::ceiling);
backsub->validcount=validcount; backsub->validcount = validcount;
if (DoFakeCeilingBridge(backsub, planez)) if (DoFakeCeilingBridge(backsub, planez))
{ {
// The mere fact that this seg has been added to the list means that the back sector // The mere fact that this seg has been added to the list means that the back sector
// will be rendered so we can safely assume that it is already in the render list // will be rendered so we can safely assume that it is already in the render list
for(unsigned int j=0;j<HandledSubsectors.Size();j++) for (unsigned int j = 0; j < HandledSubsectors.Size(); j++)
{ {
gl_subsectorrendernode * node = SSR_List.GetNew(); gl_subsectorrendernode * node = SSR_List.GetNew();
node->sub = HandledSubsectors[j]; node->sub = HandledSubsectors[j];
@ -572,45 +572,45 @@ void FDrawInfo::HandleMissingTextures()
} }
} }
for(unsigned int i=0;i<MissingLowerTextures.Size();i++) for (unsigned int i = 0; i < MissingLowerTextures.Size(); i++)
{ {
if (!MissingLowerTextures[i].seg) continue; if (!MissingLowerTextures[i].seg) continue;
HandledSubsectors.Clear(); HandledSubsectors.Clear();
validcount++; validcount++;
if (MissingLowerTextures[i].planez < FLOAT2FIXED(ViewPos.Z)) if (MissingLowerTextures[i].Planez < ViewPos.Z)
{ {
// close the hole only if all neighboring sectors are an exact height match // close the hole only if all neighboring sectors are an exact height match
// Otherwise just fill in the missing textures. // Otherwise just fill in the missing textures.
MissingLowerTextures[i].sub->validcount=validcount; MissingLowerTextures[i].sub->validcount = validcount;
if (DoOneSectorLower(MissingLowerTextures[i].sub, MissingLowerTextures[i].planez)) if (DoOneSectorLower(MissingLowerTextures[i].sub, MissingLowerTextures[i].Planez))
{ {
sector_t * sec = MissingLowerTextures[i].seg->backsector; sector_t * sec = MissingLowerTextures[i].seg->backsector;
// The mere fact that this seg has been added to the list means that the back sector // The mere fact that this seg has been added to the list means that the back sector
// will be rendered so we can safely assume that it is already in the render list // will be rendered so we can safely assume that it is already in the render list
for(unsigned int j=0;j<HandledSubsectors.Size();j++) for (unsigned int j = 0; j < HandledSubsectors.Size(); j++)
{ {
gl_subsectorrendernode * node = SSR_List.GetNew(); gl_subsectorrendernode * node = SSR_List.GetNew();
node->sub = HandledSubsectors[j]; node->sub = HandledSubsectors[j];
AddOtherFloorPlane(sec->sectornum, node); AddOtherFloorPlane(sec->sectornum, node);
} }
if (HandledSubsectors.Size()!=1) if (HandledSubsectors.Size() != 1)
{ {
// mark all subsectors in the missing list that got processed by this // mark all subsectors in the missing list that got processed by this
for(unsigned int j=0;j<HandledSubsectors.Size();j++) for (unsigned int j = 0; j < HandledSubsectors.Size(); j++)
{ {
for(unsigned int k=0;k<MissingLowerTextures.Size();k++) for (unsigned int k = 0; k < MissingLowerTextures.Size(); k++)
{ {
if (MissingLowerTextures[k].sub==HandledSubsectors[j]) if (MissingLowerTextures[k].sub == HandledSubsectors[j])
{ {
MissingLowerTextures[k].seg=NULL; MissingLowerTextures[k].seg = NULL;
} }
} }
} }
} }
else MissingLowerTextures[i].seg=NULL; else MissingLowerTextures[i].seg = NULL;
continue; continue;
} }
} }
@ -624,15 +624,15 @@ void FDrawInfo::HandleMissingTextures()
{ {
// It isn't a hole. Now check whether it might be a fake bridge // It isn't a hole. Now check whether it might be a fake bridge
sector_t * fakesector = gl_FakeFlat(MissingLowerTextures[i].seg->frontsector, &fake, false); sector_t * fakesector = gl_FakeFlat(MissingLowerTextures[i].seg->frontsector, &fake, false);
fixed_t planez = fakesector->GetPlaneTexZ(sector_t::floor); float planez = (float)fakesector->GetPlaneTexZF(sector_t::floor);
backsub->validcount=validcount; backsub->validcount = validcount;
if (DoFakeBridge(backsub, planez)) if (DoFakeBridge(backsub, planez))
{ {
// The mere fact that this seg has been added to the list means that the back sector // The mere fact that this seg has been added to the list means that the back sector
// will be rendered so we can safely assume that it is already in the render list // will be rendered so we can safely assume that it is already in the render list
for(unsigned int j=0;j<HandledSubsectors.Size();j++) for (unsigned int j = 0; j < HandledSubsectors.Size(); j++)
{ {
gl_subsectorrendernode * node = SSR_List.GetNew(); gl_subsectorrendernode * node = SSR_List.GetNew();
node->sub = HandledSubsectors[j]; node->sub = HandledSubsectors[j];
@ -644,7 +644,7 @@ void FDrawInfo::HandleMissingTextures()
} }
totalms.Unclock(); totalms.Unclock();
showtotalms=totalms; showtotalms = totalms;
totalms.Reset(); totalms.Reset();
} }
@ -658,43 +658,43 @@ void FDrawInfo::HandleMissingTextures()
void FDrawInfo::DrawUnhandledMissingTextures() void FDrawInfo::DrawUnhandledMissingTextures()
{ {
validcount++; validcount++;
for(int i=MissingUpperSegs.Size()-1; i>=0; i--) for (int i = MissingUpperSegs.Size() - 1; i >= 0; i--)
{ {
int index = MissingUpperSegs[i].MTI_Index; int index = MissingUpperSegs[i].MTI_Index;
if (index>=0 && MissingUpperTextures[index].seg==NULL) continue; if (index >= 0 && MissingUpperTextures[index].seg == NULL) continue;
seg_t * seg = MissingUpperSegs[i].seg; seg_t * seg = MissingUpperSegs[i].seg;
// already done! // already done!
if (seg->linedef->validcount==validcount) continue; // already done if (seg->linedef->validcount == validcount) continue; // already done
seg->linedef->validcount=validcount; seg->linedef->validcount = validcount;
if (seg->frontsector->GetPlaneTexZF(sector_t::ceiling) < ViewPos.Z) continue; // out of sight if (seg->frontsector->GetPlaneTexZF(sector_t::ceiling) < ViewPos.Z) continue; // out of sight
//if (seg->frontsector->ceilingpic==skyflatnum) continue; //if (seg->frontsector->ceilingpic==skyflatnum) continue;
// FIXME: The check for degenerate subsectors should be more precise // FIXME: The check for degenerate subsectors should be more precise
if (seg->PartnerSeg && (seg->PartnerSeg->Subsector->flags & SSECF_DEGENERATE)) continue; if (seg->PartnerSeg && (seg->PartnerSeg->Subsector->flags & SSECF_DEGENERATE)) continue;
if (seg->backsector->transdoor) continue; if (seg->backsector->transdoor) continue;
if (seg->backsector->GetTexture(sector_t::ceiling)==skyflatnum) continue; if (seg->backsector->GetTexture(sector_t::ceiling) == skyflatnum) continue;
if (seg->backsector->portals[sector_t::ceiling] != NULL) continue; if (seg->backsector->portals[sector_t::ceiling] != NULL) continue;
if (!glset.notexturefill) FloodUpperGap(seg); if (!glset.notexturefill) FloodUpperGap(seg);
} }
validcount++; validcount++;
for(int i=MissingLowerSegs.Size()-1; i>=0; i--) for (int i = MissingLowerSegs.Size() - 1; i >= 0; i--)
{ {
int index = MissingLowerSegs[i].MTI_Index; int index = MissingLowerSegs[i].MTI_Index;
if (index>=0 && MissingLowerTextures[index].seg==NULL) continue; if (index >= 0 && MissingLowerTextures[index].seg == NULL) continue;
seg_t * seg = MissingLowerSegs[i].seg; seg_t * seg = MissingLowerSegs[i].seg;
// already done! // already done!
if (seg->linedef->validcount==validcount) continue; // already done if (seg->linedef->validcount == validcount) continue; // already done
seg->linedef->validcount=validcount; seg->linedef->validcount = validcount;
if (!(sectorrenderflags[seg->backsector->sectornum] & SSRF_RENDERFLOOR)) continue; if (!(sectorrenderflags[seg->backsector->sectornum] & SSRF_RENDERFLOOR)) continue;
if (seg->frontsector->GetPlaneTexZF(sector_t::floor) > ViewPos.Z) continue; // out of sight if (seg->frontsector->GetPlaneTexZF(sector_t::floor) > ViewPos.Z) continue; // out of sight
if (seg->backsector->transdoor) continue; if (seg->backsector->transdoor) continue;
if (seg->backsector->GetTexture(sector_t::floor)==skyflatnum) continue; if (seg->backsector->GetTexture(sector_t::floor) == skyflatnum) continue;
if (seg->backsector->portals[sector_t::floor] != NULL) continue; if (seg->backsector->portals[sector_t::floor] != NULL) continue;
if (!glset.notexturefill) FloodLowerGap(seg); if (!glset.notexturefill) FloodLowerGap(seg);

View File

@ -92,8 +92,8 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor)
texture[0] = FMaterial::ValidateTexture(texno, false, true); texture[0] = FMaterial::ValidateTexture(texno, false, true);
if (!texture[0] || texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; if (!texture[0] || texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky;
skytexno1 = texno; skytexno1 = texno;
x_offset[0] = AngleToFloat(s->GetTextureXOffset(pos)); x_offset[0] = s->GetTextureXOffsetF(pos) * (360.f/65536.f);
y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos)); y_offset = s->GetTextureYOffsetF(pos);
mirrored = !l->args[2]; mirrored = !l->args[2];
} }
else else

View File

@ -101,25 +101,24 @@ FSkyVertexBuffer::~FSkyVertexBuffer()
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void FSkyVertexBuffer::SkyVertex(int r, int c, bool yflip) void FSkyVertexBuffer::SkyVertex(int r, int c, bool zflip)
{ {
static const angle_t maxSideAngle = ANGLE_180 / 3; static const FAngle maxSideAngle = 60.f;
static const fixed_t scale = 10000 << FRACBITS; static const float scale = 10000.;
angle_t topAngle= (angle_t)(c / (float)mColumns * ANGLE_MAX); FAngle topAngle= (c / (float)mColumns * 360.f);
angle_t sideAngle = maxSideAngle * (mRows - r) / mRows; FAngle sideAngle = maxSideAngle * (mRows - r) / mRows;
fixed_t height = finesine[sideAngle>>ANGLETOFINESHIFT]; float height = sideAngle.Sin();
fixed_t realRadius = FixedMul(scale, finecosine[sideAngle>>ANGLETOFINESHIFT]); float realRadius = scale * sideAngle.Cos();
fixed_t x = FixedMul(realRadius, finecosine[topAngle>>ANGLETOFINESHIFT]); FVector2 pos = topAngle.ToVector(realRadius);
fixed_t y = (!yflip) ? FixedMul(scale, height) : FixedMul(scale, height) * -1; float z = (!zflip) ? scale * height : -scale * height;
fixed_t z = FixedMul(realRadius, finesine[topAngle>>ANGLETOFINESHIFT]);
FSkyVertex vert; FSkyVertex vert;
vert.color = r == 0 ? 0xffffff : 0xffffffff; vert.color = r == 0 ? 0xffffff : 0xffffffff;
// And the texture coordinates. // And the texture coordinates.
if(!yflip) // Flipped Y is for the lower hemisphere. if(!zflip) // Flipped Y is for the lower hemisphere.
{ {
vert.u = (-c / (float)mColumns) ; vert.u = (-c / (float)mColumns) ;
vert.v = (r / (float)mRows); vert.v = (r / (float)mRows);
@ -130,11 +129,11 @@ void FSkyVertexBuffer::SkyVertex(int r, int c, bool yflip)
vert.v = 1.0f + ((mRows - r) / (float)mRows); vert.v = 1.0f + ((mRows - r) / (float)mRows);
} }
if (r != 4) y+=FRACUNIT*300; if (r != 4) z+=300;
// And finally the vertex. // And finally the vertex.
vert.x =-FIXED2FLOAT(x); // Doom mirrors the sky vertically! vert.x = -pos.X; // Doom mirrors the sky vertically!
vert.y = FIXED2FLOAT(y) - 1.f; vert.y = z - 1.f;
vert.z = FIXED2FLOAT(z); vert.z = pos.Y;
mVertices.Push(vert); mVertices.Push(vert);
} }
@ -149,13 +148,13 @@ void FSkyVertexBuffer::SkyVertex(int r, int c, bool yflip)
void FSkyVertexBuffer::CreateSkyHemisphere(int hemi) void FSkyVertexBuffer::CreateSkyHemisphere(int hemi)
{ {
int r, c; int r, c;
bool yflip = !!(hemi & SKYHEMI_LOWER); bool zflip = !!(hemi & SKYHEMI_LOWER);
mPrimStart.Push(mVertices.Size()); mPrimStart.Push(mVertices.Size());
for (c = 0; c < mColumns; c++) for (c = 0; c < mColumns; c++)
{ {
SkyVertex(1, c, yflip); SkyVertex(1, c, zflip);
} }
// The total number of triangles per hemisphere can be calculated // The total number of triangles per hemisphere can be calculated
@ -165,8 +164,8 @@ void FSkyVertexBuffer::CreateSkyHemisphere(int hemi)
mPrimStart.Push(mVertices.Size()); mPrimStart.Push(mVertices.Size());
for (c = 0; c <= mColumns; c++) for (c = 0; c <= mColumns; c++)
{ {
SkyVertex(r + yflip, c, yflip); SkyVertex(r + zflip, c, zflip);
SkyVertex(r + 1 - yflip, c, yflip); SkyVertex(r + 1 - zflip, c, zflip);
} }
} }
} }

View File

@ -620,7 +620,7 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg,
FTexCoordInfo tci; FTexCoordInfo tci;
gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(texpos), seg->sidedef->GetTextureYScale(texpos)); gltexture->GetTexCoordInfo(&tci, seg->sidedef, texpos);
type = _type; type = _type;
@ -679,12 +679,12 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
// Align the texture to the ORIGINAL sector's height!! // Align the texture to the ORIGINAL sector's height!!
// At this point slopes don't matter because they don't affect the texture's z-position // At this point slopes don't matter because they don't affect the texture's z-position
gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::mid), seg->sidedef->GetTextureYScale(side_t::mid)); gltexture->GetTexCoordInfo(&tci, seg->sidedef, side_t::mid);
if (tci.mRenderHeight < 0) if (tci.mRenderHeight < 0)
{ {
mirrory = true; mirrory = true;
tci.mRenderHeight = -tci.mRenderHeight; tci.mRenderHeight = -tci.mRenderHeight;
tci.mScaleY = -tci.mScaleY; tci.mScale.Y = -tci.mScale.Y;
} }
float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffsetF(side_t::mid)); float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffsetF(side_t::mid));
if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0) if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0)
@ -847,7 +847,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary,
if (mirrory) if (mirrory)
{ {
tci.mRenderHeight = -tci.mRenderHeight; tci.mRenderHeight = -tci.mRenderHeight;
tci.mScaleY = -tci.mScaleY; tci.mScale.Y = -tci.mScale.Y;
} }
SetWallCoordinates(seg, &tci, texturetop, topleft, topright, bottomleft, bottomright, t_ofs); SetWallCoordinates(seg, &tci, texturetop, topleft, topright, bottomleft, bottomright, t_ofs);
@ -1019,19 +1019,19 @@ void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover,
{ {
gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true); gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true);
if (!gltexture) return; if (!gltexture) return;
gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::top), seg->sidedef->GetTextureYScale(side_t::top)); gltexture->GetTexCoordInfo(&tci, seg->sidedef, side_t::top);
} }
else if (rover->flags&FF_LOWERTEXTURE) else if (rover->flags&FF_LOWERTEXTURE)
{ {
gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true); gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true);
if (!gltexture) return; if (!gltexture) return;
gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::bottom), seg->sidedef->GetTextureYScale(side_t::bottom)); gltexture->GetTexCoordInfo(&tci, seg->sidedef, side_t::bottom);
} }
else else
{ {
gltexture = FMaterial::ValidateTexture(mastersd->GetTexture(side_t::mid), false, true); gltexture = FMaterial::ValidateTexture(mastersd->GetTexture(side_t::mid), false, true);
if (!gltexture) return; if (!gltexture) return;
gltexture->GetTexCoordInfo(&tci, mastersd->GetTextureXScale(side_t::mid), mastersd->GetTextureYScale(side_t::mid)); gltexture->GetTexCoordInfo(&tci, mastersd, side_t::mid);
} }
to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? 0 : tci.TextureOffset(mastersd->GetTextureXOffsetF(side_t::mid)); to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? 0 : tci.TextureOffset(mastersd->GetTextureXOffsetF(side_t::mid));
@ -1525,7 +1525,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
// skip processing if the back is a malformed subsector // skip processing if the back is a malformed subsector
if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4))
{ {
gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, FLOAT2FIXED(bch1a)); gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a);
} }
} }
} }
@ -1608,7 +1608,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
// skip processing if the back is a malformed subsector // skip processing if the back is a malformed subsector
if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4))
{ {
gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, FLOAT2FIXED(bfh1)); gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1);
} }
} }
} }
@ -1669,7 +1669,7 @@ void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t *
{ {
FTexCoordInfo tci; FTexCoordInfo tci;
type = RENDERWALL_BOTTOM; type = RENDERWALL_BOTTOM;
gltexture->GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT); gltexture->GetTexCoordInfo(&tci, 1.f, 1.f);
SetWallCoordinates(seg, &tci, bfh, bfh, bfh, ffh, ffh, 0); SetWallCoordinates(seg, &tci, bfh, bfh, bfh, ffh, ffh, 0);
PutWall(false); PutWall(false);
} }

View File

@ -329,15 +329,15 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
float FTexCoordInfo::RowOffset(float rowoffset) const float FTexCoordInfo::RowOffset(float rowoffset) const
{ {
if (mTempScaleY == FRACUNIT) if (mTempScale.Y == 1.f)
{ {
if (mScaleY==FRACUNIT || mWorldPanning) return rowoffset; if (mScale.Y == 1.f || mWorldPanning) return rowoffset;
else return rowoffset * FIXED2FLOAT(mScaleY); else return rowoffset * mScale.Y;
} }
else else
{ {
if (mWorldPanning) return rowoffset * FIXED2FLOAT(mTempScaleY); if (mWorldPanning) return rowoffset * mTempScale.Y;
else return rowoffset * FIXED2FLOAT(mScaleY); else return rowoffset * mScale.Y;
} }
} }
@ -349,15 +349,15 @@ float FTexCoordInfo::RowOffset(float rowoffset) const
float FTexCoordInfo::TextureOffset(float textureoffset) const float FTexCoordInfo::TextureOffset(float textureoffset) const
{ {
if (mTempScaleX == FRACUNIT) if (mTempScale.X == 1.f)
{ {
if (mScaleX==FRACUNIT || mWorldPanning) return textureoffset; if (mScale.X == 1.f || mWorldPanning) return textureoffset;
else return textureoffset * FIXED2FLOAT(mScaleX); else return textureoffset * mScale.X;
} }
else else
{ {
if (mWorldPanning) return textureoffset * FIXED2FLOAT(mTempScaleX); if (mWorldPanning) return textureoffset * mTempScale.X;
else return textureoffset * FIXED2FLOAT(mScaleX); else return textureoffset * mScale.X;
} }
} }
@ -367,12 +367,12 @@ float FTexCoordInfo::TextureOffset(float textureoffset) const
// //
//=========================================================================== //===========================================================================
fixed_t FTexCoordInfo::TextureAdjustWidth() const float FTexCoordInfo::TextureAdjustWidth() const
{ {
if (mWorldPanning) if (mWorldPanning)
{ {
if (mTempScaleX == FRACUNIT) return mRenderWidth; if (mTempScale.X == 1.f) return mRenderWidth;
else return FixedDiv(mWidth, mTempScaleX); else return mWidth * mTempScale.X;
} }
else return mWidth; else return mWidth;
} }
@ -696,40 +696,38 @@ void FMaterial::Precache()
// //
//=========================================================================== //===========================================================================
void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, float x, float y) const
{ {
if (x == FRACUNIT) if (x == 1.f)
{ {
tci->mRenderWidth = mRenderWidth; tci->mRenderWidth = mRenderWidth;
tci->mScaleX = FLOAT2FIXED(tex->Scale.X); tci->mScale.X = tex->Scale.X;
tci->mTempScaleX = FRACUNIT; tci->mTempScale.X = 1.f;
} }
else else
{ {
fixed_t scale_x = fixed_t(x * tex->Scale.X); float scale_x = x * tex->Scale.X;
int foo = (mWidth << 17) / scale_x; tci->mRenderWidth = xs_CeilToInt(mWidth / scale_x);
tci->mRenderWidth = (foo >> 1) + (foo & 1); tci->mScale.X = scale_x;
tci->mScaleX = scale_x; tci->mTempScale.X = x;
tci->mTempScaleX = x;
} }
if (y == FRACUNIT) if (y == 1.f)
{ {
tci->mRenderHeight = mRenderHeight; tci->mRenderHeight = mRenderHeight;
tci->mScaleY = FLOAT2FIXED(tex->Scale.Y); tci->mScale.Y = tex->Scale.Y;
tci->mTempScaleY = FRACUNIT; tci->mTempScale.Y = 1.f;
} }
else else
{ {
fixed_t scale_y = fixed_t(y * tex->Scale.Y); float scale_y = y * tex->Scale.Y;
int foo = (mHeight << 17) / scale_y; tci->mRenderHeight = xs_CeilToInt(mHeight / scale_y);
tci->mRenderHeight = (foo >> 1) + (foo & 1); tci->mScale.Y = scale_y;
tci->mScaleY = scale_y; tci->mTempScale.Y = y;
tci->mTempScaleY = y;
} }
if (tex->bHasCanvas) if (tex->bHasCanvas)
{ {
tci->mScaleY = -tci->mScaleY; tci->mScale.Y = -tci->mScale.Y;
tci->mRenderHeight = -tci->mRenderHeight; tci->mRenderHeight = -tci->mRenderHeight;
} }
tci->mWorldPanning = tex->bWorldPanning; tci->mWorldPanning = tex->bWorldPanning;

View File

@ -7,6 +7,7 @@
#include "gl/textures/gl_hwtexture.h" #include "gl/textures/gl_hwtexture.h"
#include "gl/renderer/gl_colormap.h" #include "gl/renderer/gl_colormap.h"
#include "i_system.h" #include "i_system.h"
#include "r_defs.h"
EXTERN_CVAR(Bool, gl_precache) EXTERN_CVAR(Bool, gl_precache)
@ -31,17 +32,15 @@ struct FTexCoordInfo
int mRenderWidth; int mRenderWidth;
int mRenderHeight; int mRenderHeight;
int mWidth; int mWidth;
fixed_t mScaleX; FVector2 mScale;
fixed_t mScaleY; FVector2 mTempScale;
fixed_t mTempScaleX;
fixed_t mTempScaleY;
bool mWorldPanning; bool mWorldPanning;
float FloatToTexU(float v) const { return v / mRenderWidth; } float FloatToTexU(float v) const { return v / mRenderWidth; }
float FloatToTexV(float v) const { return v / mRenderHeight; } float FloatToTexV(float v) const { return v / mRenderHeight; }
float RowOffset(float ofs) const; float RowOffset(float ofs) const;
float TextureOffset(float ofs) const; float TextureOffset(float ofs) const;
fixed_t TextureAdjustWidth() const; float TextureAdjustWidth() const;
}; };
//=========================================================================== //===========================================================================
@ -157,7 +156,12 @@ public:
*r = mSpriteRect; *r = mSpriteRect;
} }
void GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const; void GetTexCoordInfo(FTexCoordInfo *tci, float x, float y) const;
void GetTexCoordInfo(FTexCoordInfo *tci, side_t *side, int texpos) const
{
GetTexCoordInfo(tci, (float)side->GetTextureXScaleF(texpos), (float)side->GetTextureYScaleF(texpos));
}
// This is scaled size in integer units as needed by walls and flats // This is scaled size in integer units as needed by walls and flats
int TextureHeight() const { return mRenderHeight; } int TextureHeight() const { return mRenderHeight; }

View File

@ -227,9 +227,9 @@ void Plane::Init(float a, float b, float c, float d)
void Plane::Set(secplane_t &plane) void Plane::Set(secplane_t &plane)
{ {
m_normal.Set(plane.Normal().X, plane.Normal().Z, plane.Normal().Y); m_normal.Set((float)plane.Normal().X, (float)plane.Normal().Z, (float)plane.Normal().Y);
//m_normal.Normalize(); the vector is already normalized //m_normal.Normalize(); the vector is already normalized
m_d = plane.fD(); m_d = (float)plane.fD();
} }

View File

@ -1308,6 +1308,10 @@ struct side_t
{ {
return textures[which].xscale; return textures[which].xscale;
} }
double GetTextureXScaleF(int which) const
{
return FIXED2DBL(textures[which].xscale);
}
void MultiplyTextureXScale(int which, double delta) void MultiplyTextureXScale(int which, double delta)
{ {
textures[which].xscale = fixed_t(textures[which].xscale * delta); textures[which].xscale = fixed_t(textures[which].xscale * delta);