diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h index 859f8de1af..c8067b3ba7 100644 --- a/src/gl/data/gl_data.h +++ b/src/gl/data/gl_data.h @@ -58,7 +58,7 @@ struct FGLLinePortal { // defines the complete span of this portal 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. }; diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index de030ad305..b7ba9d2027 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -444,7 +444,7 @@ void gl_InitPortals() tempindex[i] = glLinePortals.Size(); line_t *pSrcLine = linePortals[i].mOrigin; 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); // 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) { - glport.dx = glport.v2->fixX() - glport.v1->fixX(); - glport.dy = glport.v2->fixY() - glport.v1->fixY(); + glport.delta = glport.v2->fPos() - glport.v1->fPos(); } linePortalToGL.Resize(linePortals.Size()); for (unsigned i = 0; i < linePortals.Size(); i++) diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 6b869ef178..8cb6a412ac 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -161,8 +161,8 @@ struct FDrawInfo { seg_t * seg; subsector_t * sub; - fixed_t planez; - fixed_t planezfront; + float Planez; + float Planezfront; }; struct MissingSegInfo @@ -204,10 +204,10 @@ struct FDrawInfo ~FDrawInfo(); void ClearBuffers(); - bool DoOneSectorUpper(subsector_t * subsec, fixed_t planez); - bool DoOneSectorLower(subsector_t * subsec, fixed_t planez); - bool DoFakeBridge(subsector_t * subsec, fixed_t planez); - bool DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez); + bool DoOneSectorUpper(subsector_t * subsec, float planez); + bool DoOneSectorLower(subsector_t * subsec, float planez); + bool DoFakeBridge(subsector_t * subsec, float planez); + bool DoFakeCeilingBridge(subsector_t * subsec, float planez); bool CheckAnchorFloor(subsector_t * sub); bool CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor); @@ -216,8 +216,8 @@ struct FDrawInfo void CollectSectorStacksCeiling(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 AddLowerMissingTexture(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, float backheight); void HandleMissingTextures(); void DrawUnhandledMissingTextures(); void AddHackedSubsector(subsector_t * sub); diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 97cefabd6e..80f64d02e4 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -140,12 +140,12 @@ void FDrawInfo::AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node) // 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; totalms.Clock(); - for(int i=0; inumsegs; i++) + for (int i = 0; i < side->numsegs; i++) { seg_t *seg = side->segs[i]; @@ -156,35 +156,35 @@ void FDrawInfo::AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t MissingSegInfo msi; - if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) + if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) { totalms.Unclock(); return; } - for(unsigned int i=0;isegs[0]->backsector; if (!backsec) return; @@ -209,7 +209,7 @@ void FDrawInfo::AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t totalms.Clock(); // we need to check all segs of this sidedef - for(int i=0; inumsegs; i++) + for (int i = 0; i < side->numsegs; i++) { seg_t *seg = side->segs[i]; @@ -221,42 +221,42 @@ void FDrawInfo::AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t subsector_t * sub = seg->Subsector; - if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) + if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) { totalms.Unclock(); return; } // 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(); return; } - for(unsigned int i=0;i MissingLowerTextures[i].planez) + if (Backheight > MissingLowerTextures[i].Planez) { - MissingLowerTextures[i].planez = backheight; + MissingLowerTextures[i].Planez = Backheight; MissingLowerTextures[i].seg = seg; } msi.MTI_Index = i; - msi.seg=seg; + msi.seg = seg; MissingLowerSegs.Push(msi); totalms.Unclock(); return; } } - mti.seg=seg; + mti.seg = seg; mti.sub = sub; - mti.planez=backheight; + mti.Planez = Backheight; msi.MTI_Index = MissingLowerTextures.Push(mti); - msi.seg=seg; + msi.seg = seg; 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? // 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].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; // already checked? - if (backsub->validcount == validcount) continue; - backsub->validcount=validcount; + if (backsub->validcount == validcount) continue; + backsub->validcount = validcount; 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; // Is the neighboring ceiling lower than the desired height? - if (sec->GetPlaneTexZ(sector_t::ceiling)GetPlaneTexZF(sector_t::ceiling) < Planez) { // todo: check for missing textures. return false; } // 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 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; } } - if (!DoOneSectorUpper(backsub, planez)) return false; + if (!DoOneSectorUpper(backsub, Planez)) return false; } // 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? // 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].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; subsector_t * backsub = seg->PartnerSeg->Subsector; // already checked? - if (backsub->validcount == validcount) continue; - backsub->validcount=validcount; + if (backsub->validcount == validcount) continue; + backsub->validcount = validcount; 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; // 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. return false; } // 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 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; } } - if (!DoOneSectorLower(backsub, planez)) return false; + if (!DoOneSectorLower(backsub, Planez)) return false; } // 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? // 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].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; subsector_t * backsub = seg->PartnerSeg->Subsector; // already checked? - if (backsub->validcount == validcount) continue; - backsub->validcount=validcount; + if (backsub->validcount == validcount) continue; + backsub->validcount = validcount; 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; // Is the neighboring floor higher than the desired height? - if (sec->GetPlaneTexZ(sector_t::floor)GetPlaneTexZF(sector_t::floor) < Planez) { // todo: check for missing textures. 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 // 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 @@ -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? // 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].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; subsector_t * backsub = seg->PartnerSeg->Subsector; // already checked? - if (backsub->validcount == validcount) continue; - backsub->validcount=validcount; + if (backsub->validcount == validcount) continue; + backsub->validcount = validcount; 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; // 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. 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 // 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 @@ -497,49 +497,49 @@ void FDrawInfo::HandleMissingTextures() { sector_t fake; totalms.Clock(); - totalupper=MissingUpperTextures.Size(); - totallower=MissingLowerTextures.Size(); + totalupper = MissingUpperTextures.Size(); + totallower = MissingLowerTextures.Size(); - for(unsigned int i=0;i FLOAT2FIXED(ViewPos.Z)) + if (MissingUpperTextures[i].Planez > ViewPos.Z) { // close the hole only if all neighboring sectors are an exact height match // Otherwise just fill in the missing textures. - MissingUpperTextures[i].sub->validcount=validcount; - if (DoOneSectorUpper(MissingUpperTextures[i].sub, MissingUpperTextures[i].planez)) + MissingUpperTextures[i].sub->validcount = validcount; + if (DoOneSectorUpper(MissingUpperTextures[i].sub, MissingUpperTextures[i].Planez)) { sector_t * sec = MissingUpperTextures[i].seg->backsector; // 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 - for(unsigned int j=0;jsub = HandledSubsectors[j]; AddOtherCeilingPlane(sec->sectornum, node); } - if (HandledSubsectors.Size()!=1) + if (HandledSubsectors.Size() != 1) { // mark all subsectors in the missing list that got processed by this - for(unsigned int j=0;jfrontsector, &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)) { // 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 - for(unsigned int j=0;jsub = HandledSubsectors[j]; AddOtherCeilingPlane(fakesector->sectornum, node); @@ -572,45 +572,45 @@ void FDrawInfo::HandleMissingTextures() } } - for(unsigned int i=0;ivalidcount=validcount; - if (DoOneSectorLower(MissingLowerTextures[i].sub, MissingLowerTextures[i].planez)) + MissingLowerTextures[i].sub->validcount = validcount; + if (DoOneSectorLower(MissingLowerTextures[i].sub, MissingLowerTextures[i].Planez)) { sector_t * sec = MissingLowerTextures[i].seg->backsector; // 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 - for(unsigned int j=0;jsub = HandledSubsectors[j]; AddOtherFloorPlane(sec->sectornum, node); } - if (HandledSubsectors.Size()!=1) + if (HandledSubsectors.Size() != 1) { // mark all subsectors in the missing list that got processed by this - for(unsigned int j=0;jfrontsector, &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)) { // 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 - for(unsigned int j=0;jsub = HandledSubsectors[j]; AddOtherFloorPlane(fakesector->sectornum, node); @@ -644,7 +644,7 @@ void FDrawInfo::HandleMissingTextures() } totalms.Unclock(); - showtotalms=totalms; + showtotalms = totalms; totalms.Reset(); } @@ -658,43 +658,43 @@ void FDrawInfo::HandleMissingTextures() void FDrawInfo::DrawUnhandledMissingTextures() { 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; - if (index>=0 && MissingUpperTextures[index].seg==NULL) continue; + if (index >= 0 && MissingUpperTextures[index].seg == NULL) continue; seg_t * seg = MissingUpperSegs[i].seg; // already done! - if (seg->linedef->validcount==validcount) continue; // already done - seg->linedef->validcount=validcount; + if (seg->linedef->validcount == validcount) continue; // already done + seg->linedef->validcount = validcount; if (seg->frontsector->GetPlaneTexZF(sector_t::ceiling) < ViewPos.Z) continue; // out of sight //if (seg->frontsector->ceilingpic==skyflatnum) continue; // FIXME: The check for degenerate subsectors should be more precise if (seg->PartnerSeg && (seg->PartnerSeg->Subsector->flags & SSECF_DEGENERATE)) 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 (!glset.notexturefill) FloodUpperGap(seg); } 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; - if (index>=0 && MissingLowerTextures[index].seg==NULL) continue; + if (index >= 0 && MissingLowerTextures[index].seg == NULL) continue; seg_t * seg = MissingLowerSegs[i].seg; // already done! - if (seg->linedef->validcount==validcount) continue; // already done - seg->linedef->validcount=validcount; + if (seg->linedef->validcount == validcount) continue; // already done + seg->linedef->validcount = validcount; if (!(sectorrenderflags[seg->backsector->sectornum] & SSRF_RENDERFLOOR)) continue; if (seg->frontsector->GetPlaneTexZF(sector_t::floor) > ViewPos.Z) continue; // out of sight 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 (!glset.notexturefill) FloodLowerGap(seg); diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index d5340d7ff1..2826236b2c 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -92,8 +92,8 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor) texture[0] = FMaterial::ValidateTexture(texno, false, true); if (!texture[0] || texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; skytexno1 = texno; - x_offset[0] = AngleToFloat(s->GetTextureXOffset(pos)); - y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos)); + x_offset[0] = s->GetTextureXOffsetF(pos) * (360.f/65536.f); + y_offset = s->GetTextureYOffsetF(pos); mirrored = !l->args[2]; } else diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index a9d9204204..69968ddf7f 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -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 fixed_t scale = 10000 << FRACBITS; + static const FAngle maxSideAngle = 60.f; + static const float scale = 10000.; - angle_t topAngle= (angle_t)(c / (float)mColumns * ANGLE_MAX); - angle_t sideAngle = maxSideAngle * (mRows - r) / mRows; - fixed_t height = finesine[sideAngle>>ANGLETOFINESHIFT]; - fixed_t realRadius = FixedMul(scale, finecosine[sideAngle>>ANGLETOFINESHIFT]); - fixed_t x = FixedMul(realRadius, finecosine[topAngle>>ANGLETOFINESHIFT]); - fixed_t y = (!yflip) ? FixedMul(scale, height) : FixedMul(scale, height) * -1; - fixed_t z = FixedMul(realRadius, finesine[topAngle>>ANGLETOFINESHIFT]); + FAngle topAngle= (c / (float)mColumns * 360.f); + FAngle sideAngle = maxSideAngle * (mRows - r) / mRows; + float height = sideAngle.Sin(); + float realRadius = scale * sideAngle.Cos(); + FVector2 pos = topAngle.ToVector(realRadius); + float z = (!zflip) ? scale * height : -scale * height; FSkyVertex vert; vert.color = r == 0 ? 0xffffff : 0xffffffff; // 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.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); } - if (r != 4) y+=FRACUNIT*300; + if (r != 4) z+=300; // And finally the vertex. - vert.x =-FIXED2FLOAT(x); // Doom mirrors the sky vertically! - vert.y = FIXED2FLOAT(y) - 1.f; - vert.z = FIXED2FLOAT(z); + vert.x = -pos.X; // Doom mirrors the sky vertically! + vert.y = z - 1.f; + vert.z = pos.Y; mVertices.Push(vert); } @@ -149,13 +148,13 @@ void FSkyVertexBuffer::SkyVertex(int r, int c, bool yflip) void FSkyVertexBuffer::CreateSkyHemisphere(int hemi) { int r, c; - bool yflip = !!(hemi & SKYHEMI_LOWER); + bool zflip = !!(hemi & SKYHEMI_LOWER); mPrimStart.Push(mVertices.Size()); for (c = 0; c < mColumns; c++) { - SkyVertex(1, c, yflip); + SkyVertex(1, c, zflip); } // The total number of triangles per hemisphere can be calculated @@ -165,8 +164,8 @@ void FSkyVertexBuffer::CreateSkyHemisphere(int hemi) mPrimStart.Push(mVertices.Size()); for (c = 0; c <= mColumns; c++) { - SkyVertex(r + yflip, c, yflip); - SkyVertex(r + 1 - yflip, c, yflip); + SkyVertex(r + zflip, c, zflip); + SkyVertex(r + 1 - zflip, c, zflip); } } } diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 86b330d7e1..02401e2835 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -620,7 +620,7 @@ void GLWall::DoTexture(int _type,seg_t * seg, int peg, FTexCoordInfo tci; - gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(texpos), seg->sidedef->GetTextureYScale(texpos)); + gltexture->GetTexCoordInfo(&tci, seg->sidedef, texpos); type = _type; @@ -679,12 +679,12 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, // 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 - 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) { mirrory = true; tci.mRenderHeight = -tci.mRenderHeight; - tci.mScaleY = -tci.mScaleY; + tci.mScale.Y = -tci.mScale.Y; } float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffsetF(side_t::mid)); if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0) @@ -847,7 +847,7 @@ void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, if (mirrory) { tci.mRenderHeight = -tci.mRenderHeight; - tci.mScaleY = -tci.mScaleY; + tci.mScale.Y = -tci.mScale.Y; } 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); 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) { gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true); 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 { gltexture = FMaterial::ValidateTexture(mastersd->GetTexture(side_t::mid), false, true); 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)); @@ -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 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 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; type = RENDERWALL_BOTTOM; - gltexture->GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT); + gltexture->GetTexCoordInfo(&tci, 1.f, 1.f); SetWallCoordinates(seg, &tci, bfh, bfh, bfh, ffh, ffh, 0); PutWall(false); } diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index 3b2ee60af3..40e2931a6e 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -329,15 +329,15 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla float FTexCoordInfo::RowOffset(float rowoffset) const { - if (mTempScaleY == FRACUNIT) + if (mTempScale.Y == 1.f) { - if (mScaleY==FRACUNIT || mWorldPanning) return rowoffset; - else return rowoffset * FIXED2FLOAT(mScaleY); + if (mScale.Y == 1.f || mWorldPanning) return rowoffset; + else return rowoffset * mScale.Y; } else { - if (mWorldPanning) return rowoffset * FIXED2FLOAT(mTempScaleY); - else return rowoffset * FIXED2FLOAT(mScaleY); + if (mWorldPanning) return rowoffset * mTempScale.Y; + else return rowoffset * mScale.Y; } } @@ -349,15 +349,15 @@ float FTexCoordInfo::RowOffset(float rowoffset) const float FTexCoordInfo::TextureOffset(float textureoffset) const { - if (mTempScaleX == FRACUNIT) + if (mTempScale.X == 1.f) { - if (mScaleX==FRACUNIT || mWorldPanning) return textureoffset; - else return textureoffset * FIXED2FLOAT(mScaleX); + if (mScale.X == 1.f || mWorldPanning) return textureoffset; + else return textureoffset * mScale.X; } else { - if (mWorldPanning) return textureoffset * FIXED2FLOAT(mTempScaleX); - else return textureoffset * FIXED2FLOAT(mScaleX); + if (mWorldPanning) return textureoffset * mTempScale.X; + 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 (mTempScaleX == FRACUNIT) return mRenderWidth; - else return FixedDiv(mWidth, mTempScaleX); + if (mTempScale.X == 1.f) return mRenderWidth; + else return mWidth * mTempScale.X; } 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->mScaleX = FLOAT2FIXED(tex->Scale.X); - tci->mTempScaleX = FRACUNIT; + tci->mScale.X = tex->Scale.X; + tci->mTempScale.X = 1.f; } else { - 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; - tci->mTempScaleX = x; + float scale_x = x * tex->Scale.X; + tci->mRenderWidth = xs_CeilToInt(mWidth / scale_x); + tci->mScale.X = scale_x; + tci->mTempScale.X = x; } - if (y == FRACUNIT) + if (y == 1.f) { tci->mRenderHeight = mRenderHeight; - tci->mScaleY = FLOAT2FIXED(tex->Scale.Y); - tci->mTempScaleY = FRACUNIT; + tci->mScale.Y = tex->Scale.Y; + tci->mTempScale.Y = 1.f; } else { - 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; - tci->mTempScaleY = y; + float scale_y = y * tex->Scale.Y; + tci->mRenderHeight = xs_CeilToInt(mHeight / scale_y); + tci->mScale.Y = scale_y; + tci->mTempScale.Y = y; } if (tex->bHasCanvas) { - tci->mScaleY = -tci->mScaleY; + tci->mScale.Y = -tci->mScale.Y; tci->mRenderHeight = -tci->mRenderHeight; } tci->mWorldPanning = tex->bWorldPanning; diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 525d506704..b8a71c7ce8 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -7,6 +7,7 @@ #include "gl/textures/gl_hwtexture.h" #include "gl/renderer/gl_colormap.h" #include "i_system.h" +#include "r_defs.h" EXTERN_CVAR(Bool, gl_precache) @@ -31,17 +32,15 @@ struct FTexCoordInfo int mRenderWidth; int mRenderHeight; int mWidth; - fixed_t mScaleX; - fixed_t mScaleY; - fixed_t mTempScaleX; - fixed_t mTempScaleY; + FVector2 mScale; + FVector2 mTempScale; bool mWorldPanning; float FloatToTexU(float v) const { return v / mRenderWidth; } float FloatToTexV(float v) const { return v / mRenderHeight; } float RowOffset(float ofs) const; float TextureOffset(float ofs) const; - fixed_t TextureAdjustWidth() const; + float TextureAdjustWidth() const; }; //=========================================================================== @@ -157,7 +156,12 @@ public: *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 int TextureHeight() const { return mRenderHeight; } diff --git a/src/gl/utility/gl_geometric.cpp b/src/gl/utility/gl_geometric.cpp index c2ea6da59c..15b01f254d 100644 --- a/src/gl/utility/gl_geometric.cpp +++ b/src/gl/utility/gl_geometric.cpp @@ -227,9 +227,9 @@ void Plane::Init(float a, float b, float c, float d) 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_d = plane.fD(); + m_d = (float)plane.fD(); } diff --git a/src/r_defs.h b/src/r_defs.h index 89df08cab1..8eb982384f 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1308,6 +1308,10 @@ struct side_t { return textures[which].xscale; } + double GetTextureXScaleF(int which) const + { + return FIXED2DBL(textures[which].xscale); + } void MultiplyTextureXScale(int which, double delta) { textures[which].xscale = fixed_t(textures[which].xscale * delta);