From a27181cb0b1fc700202fb8c8da10f3e70fb04cf2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 31 Mar 2016 21:42:27 +0200 Subject: [PATCH] - partial adjustments. No point changing all the viewx/y/z stuff when that is about to get floatified next. --- src/gl/dynlights/gl_glow.cpp | 14 +++++++------- src/gl/dynlights/gl_glow.h | 2 +- src/gl/scene/gl_portal.cpp | 34 +++++++++++++++++----------------- src/gl/scene/gl_portal.h | 8 ++++---- src/gl/scene/gl_sprite.cpp | 6 +++--- src/gl/scene/gl_walls.cpp | 4 ++-- src/gl/scene/gl_weapon.cpp | 2 +- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/gl/dynlights/gl_glow.cpp b/src/gl/dynlights/gl_glow.cpp index ce763109d..eee1788dc 100644 --- a/src/gl/dynlights/gl_glow.cpp +++ b/src/gl/dynlights/gl_glow.cpp @@ -119,19 +119,19 @@ void gl_InitGlow(FScanner &sc) // Checks whether a sprite should be affected by a glow // //========================================================================== -int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, int x, int y, int z) +int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, const DVector3 &pos) { FTextureID floorpic = sec->GetTexture(sector_t::floor); FTexture *tex = TexMan[floorpic]; if (tex != NULL && tex->isGlowing()) { - fixed_t floordiff = z - sec->floorplane.ZatPoint(x, y); - if (floordiff < tex->gl_info.GlowHeight*FRACUNIT && tex->gl_info.GlowHeight != 0) + double floordiff = pos.Z - sec->floorplane.ZatPoint(pos); + if (floordiff < tex->gl_info.GlowHeight && tex->gl_info.GlowHeight != 0) { - int maxlight = (255+lightlevel)>>1; - fixed_t lightfrac = floordiff / tex->gl_info.GlowHeight; - if (lightfrac<0) lightfrac=0; - lightlevel= (lightfrac*lightlevel + maxlight*(FRACUNIT-lightfrac))>>FRACBITS; + int maxlight = (255 + lightlevel) >> 1; + double lightfrac = floordiff / tex->gl_info.GlowHeight; + if (lightfrac < 0) lightfrac = 0; + lightlevel = int(lightfrac*lightlevel + maxlight*(1 - lightfrac)); } } return lightlevel; diff --git a/src/gl/dynlights/gl_glow.h b/src/gl/dynlights/gl_glow.h index bc3235685..7d9ae9f7f 100644 --- a/src/gl/dynlights/gl_glow.h +++ b/src/gl/dynlights/gl_glow.h @@ -5,6 +5,6 @@ struct sector_t; void gl_InitGlow(const char * lumpnm); -int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, int x, int y, int z); +int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, const DVector3 &pos); #endif diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index bc57674ca..860c822bc 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -639,55 +639,55 @@ void GLPortal::RestoreMapSection() static int skyboxrecursion=0; void GLSkyboxPortal::DrawContents() { - int old_pm=PlaneMirrorMode; + int old_pm = PlaneMirrorMode; int saved_extralight = extralight; - if (skyboxrecursion>=3) + if (skyboxrecursion >= 3) { ClearScreen(); return; } skyboxrecursion++; - origin->flags|=MF_JUSTHIT; + origin->flags |= MF_JUSTHIT; extralight = 0; - PlaneMirrorMode=0; + PlaneMirrorMode = 0; bool oldclamp = gl_RenderState.SetDepthClamp(false); 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) * r_TicFracF).BAMs(); // Don't let the viewpoint be too close to a floor or ceiling - fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin->_f_Pos()); - fixed_t ceilh = origin->Sector->ceilingplane.ZatPoint(origin->_f_Pos()); - if (viewzceilh-4*FRACUNIT) viewz=ceilh-4*FRACUNIT; + double floorh = origin->Sector->floorplane.ZatPoint(origin->Pos()); + double ceilh = origin->Sector->ceilingplane.ZatPoint(origin->Pos()); + if (viewpos.Z < floorh + 4) viewpos.Z = floorh + 4; + if (viewpos.Z > ceilh - 4) viewz = ceilh - 4; + viewx = FLOAT2FIXED(viewpos.X); + viewy = FLOAT2FIXED(viewpos.Y); + viewz = FLOAT2FIXED(viewpos.Z); GLRenderer->mViewActor = origin; validcount++; - inskybox=true; - GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + inskybox = true; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); GLRenderer->SetViewArea(); ClearClipper(); int mapsection = R_PointInSubsector(viewx, viewy)->mapsection; SaveMapSection(); - currentmapsection[mapsection>>3] |= 1 << (mapsection & 7); + currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); GLRenderer->DrawScene(); - origin->flags&=~MF_JUSTHIT; - inskybox=false; + origin->flags &= ~MF_JUSTHIT; + inskybox = false; gl_RenderState.SetDepthClamp(oldclamp); skyboxrecursion--; - PlaneMirrorMode=old_pm; + PlaneMirrorMode = old_pm; extralight = saved_extralight; RestoreMapSection(); diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 22955a911..ca22d2d05 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -186,8 +186,8 @@ struct GLLinePortal : public GLPortal { v1 = line->v1; v2 = line->v2; - dx = line->fixDx(); - dy = line->fixDy(); + dx = FLOAT2FIXED(line->Delta().X); + dy = FLOAT2FIXED(line->Delta().Y); } GLLinePortal(FGLLinePortal *line) @@ -198,8 +198,8 @@ struct GLLinePortal : public GLPortal line_t *lline = line->reference->mDestination; v1 = lline->v1; v2 = lline->v2; - dx = lline->fixDy(); - dy = lline->fixDy(); + dx = FLOAT2FIXED(lline->Delta().X); + dy = FLOAT2FIXED(lline->Delta().Y); } else { diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 5dbaa7fec..1ffd07c2d 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -532,8 +532,8 @@ 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(FLOAT2FIXED(thingpos.X)-viewx, FLOAT2FIXED(thingpos.Y)-viewy) < clipdist) return; + double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius*2); + if (P_AproxDistance(thingpos.X-viewx, 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. } @@ -660,7 +660,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) rendersector->GetCeilingLight() : rendersector->GetFloorLight()); foglevel = (BYTE)clamp(rendersector->lightlevel, 0, 255); - lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y), FLOAT2FIXED(thingpos.Z)); + lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingpos); ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff; ThingColor.a = 255; diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 590e7734f..683f83de5 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -134,8 +134,8 @@ void GLWall::PutWall(bool translucent) if (translucent) // translucent walls { - viewdistance = P_AproxDistance(((seg->linedef->v1->fixX() + seg->linedef->v2->fixX()) >> 1) - viewx, - ((seg->linedef->v1->fixY() + seg->linedef->v2->fixY()) >> 1) - viewy); + viewdistance = P_AproxDistance(((seg->linedef->v1->fX() + seg->linedef->v2->fX()) /2) - viewx, + ((seg->linedef->v1->fY() + seg->linedef->v2->fY()) /2) - viewy); gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); } else diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 0712ae328..5ed442318 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -250,7 +250,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) lightlevel = (1.0 - min_L) * 255; } - lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->_f_X(), playermo->_f_Y(), playermo->_f_Z()); + lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->Pos()); // calculate colormap for weapon sprites if (viewsector->e->XFloor.ffloors.Size() && !glset.nocoloredspritelighting)