diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 7841512e0..6640d2d4a 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -359,7 +359,7 @@ static void CollectPortalSectors(FPortalMap &collection) ASkyViewpoint *SkyBox = sec->SkyBoxes[j]; if (SkyBox != NULL && SkyBox->bAlways && SkyBox->Mate != NULL) { - FPortalID id = { SkyBox->x - SkyBox->Mate->x, SkyBox->y - SkyBox->Mate->y }; + FPortalID id = { SkyBox->X() - SkyBox->Mate->X(), SkyBox->Y() - SkyBox->Mate->Y() }; FPortalSectors &sss = collection[id]; FPortalSector ss = { sec, j }; diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 4507e783c..575fa2e11 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -89,7 +89,7 @@ void AVavoomLight::BeginPlay () { // This must not call Super::BeginPlay! ChangeStatNum(STAT_DLIGHT); - if (Sector) z -= Sector->floorplane.ZatPoint(x, y); + if (Sector) AddZ(-Sector->floorplane.ZatPoint(this), false); lighttype = PointLight; } @@ -170,7 +170,7 @@ void ADynamicLight::PostBeginPlay() Activate (NULL); } - subsector = R_PointInSubsector(x,y); + subsector = R_PointInSubsector(X(), Y()); } @@ -333,8 +333,8 @@ void ADynamicLight::Tick() //========================================================================== void ADynamicLight::UpdateLocation() { - fixed_t oldx=x; - fixed_t oldy=y; + fixed_t oldx=X(); + fixed_t oldy=Y(); fixed_t oldradius=radius; float intensity; @@ -343,10 +343,15 @@ void ADynamicLight::UpdateLocation() if (target) { angle_t angle = target->angle>>ANGLETOFINESHIFT; - PrevX = x = target->x + FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]); - PrevY = y = target->y + FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]); - PrevZ = z = target->z + m_offY + target->GetBobOffset(); - subsector = R_PointInSubsector(x, y); + fixedvec3 pos = target->Vec3Offset( + FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]), + FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]), + m_offY + target->GetBobOffset()); + SetXYZ(pos); // attached lights do not need to go into the regular blockmap + PrevX = pos.x; + PrevY = pos.y; + PrevZ = pos.z; + subsector = R_PointInSubsector(pos.x, pos.y); Sector = subsector->sector; } @@ -364,7 +369,7 @@ void ADynamicLight::UpdateLocation() } radius = FLOAT2FIXED(intensity * 2.0f * gl_lights_size); - if (x!=oldx || y!=oldy || radius!=oldradius) + if (X()!=oldx || Y()!=oldy || radius!=oldradius) { //Update the light lists LinkLight(); @@ -495,15 +500,15 @@ float ADynamicLight::DistToSeg(seg_t *seg) float seg_dy = FIXED2FLOAT(seg->v2->y - seg->v1->y); float seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy; - u = ( FIXED2FLOAT(x - seg->v1->x) * seg_dx + FIXED2FLOAT(y - seg->v1->y) * seg_dy) / seg_length_sq; + u = ( FIXED2FLOAT(X() - seg->v1->x) * seg_dx + FIXED2FLOAT(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; px = FIXED2FLOAT(seg->v1->x) + (u * seg_dx); py = FIXED2FLOAT(seg->v1->y) + (u * seg_dy); - px -= FIXED2FLOAT(x); - py -= FIXED2FLOAT(y); + px -= FIXED2FLOAT(X()); + py -= FIXED2FLOAT(Y()); return (px*px) + (py*py); } @@ -536,7 +541,7 @@ void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) if (seg->sidedef && seg->linedef && seg->linedef->validcount!=::validcount) { // light is in front of the seg - if (DMulScale32 (y-seg->v1->y, seg->v2->x-seg->v1->x, seg->v1->x-x, seg->v2->y-seg->v1->y) <=0) + if (DMulScale32 (Y()-seg->v1->y, seg->v2->x-seg->v1->x, seg->v1->x-X(), seg->v2->y-seg->v1->y) <=0) { seg->linedef->validcount=validcount; touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); @@ -592,7 +597,7 @@ void ADynamicLight::LinkLight() if (radius>0) { // passing in radius*radius allows us to do a distance check without any calls to sqrtf - subsector_t * subSec = R_PointInSubsector(x, y); + subsector_t * subSec = R_PointInSubsector(X(), Y()); if (subSec) { float fradius = FIXED2FLOAT(radius); @@ -702,7 +707,7 @@ CCMD(listlights) subsecs = 0; Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f ", dl->target? dl->target->GetClass()->TypeName.GetChars() : dl->GetClass()->TypeName.GetChars(), - FIXED2FLOAT(dl->x), FIXED2FLOAT(dl->y), FIXED2FLOAT(dl->z), dl->args[LIGHT_RED], + FIXED2FLOAT(dl->X()), FIXED2FLOAT(dl->Y()), FIXED2FLOAT(dl->Z()), dl->args[LIGHT_RED], dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], FIXED2FLOAT(dl->radius)); i++; diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index f143a479b..4afacc7d1 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -1085,7 +1085,7 @@ void gl_AttachLight(AActor *actor, unsigned int count, const FLightDefaults *lig } else { - light = Spawn(actor->x, actor->y, actor->z, NO_REPLACE); + light = Spawn(actor->Pos(), NO_REPLACE); light->target = actor; light->owned = true; actor->dynamiclights.Push(light); diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index c504a33c4..864a9f3ce 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -90,9 +90,9 @@ bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadd Vector fn, pos; int i = 0; - float x = FIXED2FLOAT(light->x); - float y = FIXED2FLOAT(light->y); - float z = FIXED2FLOAT(light->z); + float x = FIXED2FLOAT(light->X()); + float y = FIXED2FLOAT(light->Y()); + float z = FIXED2FLOAT(light->Z()); float dist = fabsf(p.DistToPoint(x, z, y)); float radius = (light->GetRadius() * gl_lights_size); diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 78d9b44bd..16b892b15 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -141,8 +141,8 @@ void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) // we must do the side check here because gl_SetupLight needs the correct plane orientation // which we don't have for Legacy-style 3D-floors - fixed_t planeh = plane.plane.ZatPoint(light->x, light->y); - if (gl_lights_checkside && ((planehz && ceiling) || (planeh>light->z && !ceiling))) + fixed_t planeh = plane.plane.ZatPoint(light); + if (gl_lights_checkside && ((planehZ() && ceiling) || (planeh>light->Z() && !ceiling))) { node=node->nextLight; continue; diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index cb8f361a9..5b6c8e27d 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -641,14 +641,15 @@ void GLSkyboxPortal::DrawContents() PlaneMirrorMode=0; bool oldclamp = gl_RenderState.SetDepthClamp(false); - viewx = origin->PrevX + FixedMul(r_TicFrac, origin->x - origin->PrevX); - viewy = origin->PrevY + FixedMul(r_TicFrac, origin->y - origin->PrevY); - viewz = origin->PrevZ + FixedMul(r_TicFrac, origin->z - origin->PrevZ); + fixedvec3 viewpos = origin->InterpolatedPosition(r_TicFrac); + viewx = viewpos.x; + viewy = viewpos.y; + viewz = viewpos.z; viewangle += origin->PrevAngle + FixedMul(r_TicFrac, origin->angle - origin->PrevAngle); - // Don't let the viewpoint be too close to a floor or ceiling! - fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin->x, origin->y); - fixed_t ceilh = origin->Sector->ceilingplane.ZatPoint(origin->x, origin->y); + // Don't let the viewpoint be too close to a floor or ceiling + fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin); + fixed_t ceilh = origin->Sector->ceilingplane.ZatPoint(origin); if (viewzceilh-4*FRACUNIT) viewz=ceilh-4*FRACUNIT; diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index e8d919a28..75e698762 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -339,8 +339,8 @@ void GLSprite::SplitSprite(sector_t * frontsector, bool translucent) for(i=0;ix,actor->y); - else lightbottom=frontsector->floorplane.ZatPoint(actor->x,actor->y); + if (ifloorplane.ZatPoint(actor); maplightbottom=FIXED2FLOAT(lightbottom); if (maplightbottomx,actor->y); - else lightbottom=sector->floorplane.ZatPoint(actor->x,actor->y); + if (ifloorplane.ZatPoint(actor); //maplighttop=FIXED2FLOAT(lightlist[i].height); maplightbottom=FIXED2FLOAT(lightbottom); @@ -538,12 +538,10 @@ 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 - fixed_t thingx = thing->PrevX + FixedMul (r_TicFrac, thing->x - thing->PrevX); - fixed_t thingy = thing->PrevY + FixedMul (r_TicFrac, thing->y - thing->PrevY); - fixed_t thingz = thing->PrevZ + FixedMul (r_TicFrac, thing->z - thing->PrevZ); + fixedvec3 thingpos = thing->InterpolatedPosition(r_TicFrac); // Too close to the camera. This doesn't look good if it is a sprite. - if (P_AproxDistance(thingx-viewx, thingy-viewy)<2*FRACUNIT) + if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy)<2*FRACUNIT) { // exclude vertically moving objects from this check. if (!(thing->velx==0 && thing->vely==0 && thing->velz!=0)) @@ -558,12 +556,12 @@ void GLSprite::Process(AActor* thing,sector_t * sector) // don't draw first frame of a player missile if (thing->flags&MF_MISSILE && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) { - if (P_AproxDistance(thingx-viewx, thingy-viewy) < thing->Speed ) return; + if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy) < thing->Speed ) return; } if (GLRenderer->mCurrentPortal) { - int clipres = GLRenderer->mCurrentPortal->ClipPoint(thingx, thingy); + int clipres = GLRenderer->mCurrentPortal->ClipPoint(thingpos.x, thingpos.y); if (clipres == GLPortal::PClip_InFront) return; } @@ -580,9 +578,9 @@ void GLSprite::Process(AActor* thing,sector_t * sector) } - x = FIXED2FLOAT(thingx); - z = FIXED2FLOAT(thingz-thing->floorclip); - y = FIXED2FLOAT(thingy); + x = FIXED2FLOAT(thingpos.x); + z = FIXED2FLOAT(thingpos.z-thing->floorclip); + y = FIXED2FLOAT(thingpos.y); // [RH] Make floatbobbing a renderer-only effect. if (thing->flags2 & MF2_FLOATBOB) @@ -594,7 +592,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) modelframe = gl_FindModelFrame(RUNTIME_TYPE(thing), spritenum, thing->frame, !!(thing->flags & MF_DROPPED)); if (!modelframe) { - angle_t ang = R_PointToAngle(thingx, thingy); + angle_t ang = R_PointToAngle(thingpos.x, thingpos.y); bool mirror; FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->angle, &mirror); @@ -631,7 +629,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, thingx, thingy, spriteheight); + PerformSpriteClipAdjustment(thing, thingpos.x, thingpos.y, spriteheight); } float viewvecX; @@ -667,7 +665,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) gltexture=NULL; } - depth = DMulScale20 (thing->x-viewx, viewtancos, thing->y-viewy, viewtansin); + depth = DMulScale20 (thingpos.x-viewx, viewtancos, thingpos.y-viewy, viewtansin); // light calculation @@ -683,7 +681,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, thingx, thingy, thingz); + lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingpos.x, thingpos.y, thingpos.z); ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff; ThingColor.a = 255; @@ -835,7 +833,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector) if (drawWithXYBillboard || modelframe) { - if (!gl_fixedcolormap && !fullbright) SetSpriteColor(actor->Sector, actor->y + (actor->height>>1)); + if (!gl_fixedcolormap && !fullbright) SetSpriteColor(actor->Sector, thingpos.y + (actor->height>>1)); PutSprite(hw_styleflags != STYLEHW_Solid); } else if (thing->Sector->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || fullbright) diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index 97f326844..9740448f4 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -80,7 +80,7 @@ void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsect if (!(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) { - float dist = FVector3(FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z)).Length(); + float dist = FVector3(FIXED2FLOAT(x - light->X()), FIXED2FLOAT(y - light->Y()), FIXED2FLOAT(z - light->Z())).Length(); radius = light->GetRadius() * gl_lights_size; if (dist < radius) @@ -117,7 +117,7 @@ void gl_SetDynSpriteLight(AActor *thing, particle_t *particle) { if (thing != NULL) { - gl_SetDynSpriteLight(thing, thing->x, thing->y, thing->z + (thing->height >> 1), thing->subsector); + gl_SetDynSpriteLight(thing, thing->X(), thing->Y(), thing->Z() + (thing->height >> 1), thing->subsector); } else if (particle != NULL) { diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 5135a5947..5cf321ec8 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -118,9 +118,9 @@ void GLWall::SetupLights() Vector fn, pos; - float x = FIXED2FLOAT(node->lightsource->x); - float y = FIXED2FLOAT(node->lightsource->y); - float z = FIXED2FLOAT(node->lightsource->z); + float x = FIXED2FLOAT(node->lightsource->X()); + float y = FIXED2FLOAT(node->lightsource->Y()); + float z = FIXED2FLOAT(node->lightsource->Z()); float dist = fabsf(p.DistToPoint(x, z, y)); float radius = (node->lightsource->GetRadius() * gl_lights_size); float scale = 1.0f / ((2.f * radius) - dist); diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 71b4a8fdc..3fcc0c251 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->x, playermo->y, playermo->z); + lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->X(), playermo->Y(), playermo->Z()); // calculate colormap for weapon sprites if (viewsector->e->XFloor.ffloors.Size() && !glset.nocoloredspritelighting)