mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 23:32:02 +00:00
- made necessary adjustments for the coordinate refactoring in ZDoom.
This commit is contained in:
parent
8f7be01dd4
commit
5816049510
10 changed files with 56 additions and 52 deletions
|
@ -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 };
|
||||
|
|
|
@ -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++;
|
||||
|
||||
|
|
|
@ -1085,7 +1085,7 @@ void gl_AttachLight(AActor *actor, unsigned int count, const FLightDefaults *lig
|
|||
}
|
||||
else
|
||||
{
|
||||
light = Spawn<ADynamicLight>(actor->x, actor->y, actor->z, NO_REPLACE);
|
||||
light = Spawn<ADynamicLight>(actor->Pos(), NO_REPLACE);
|
||||
light->target = actor;
|
||||
light->owned = true;
|
||||
actor->dynamiclights.Push(light);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 && ((planeh<light->z && ceiling) || (planeh>light->z && !ceiling)))
|
||||
fixed_t planeh = plane.plane.ZatPoint(light);
|
||||
if (gl_lights_checkside && ((planeh<light->Z() && ceiling) || (planeh>light->Z() && !ceiling)))
|
||||
{
|
||||
node=node->nextLight;
|
||||
continue;
|
||||
|
|
|
@ -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 (viewz<floorh+4*FRACUNIT) viewz=floorh+4*FRACUNIT;
|
||||
if (viewz>ceilh-4*FRACUNIT) viewz=ceilh-4*FRACUNIT;
|
||||
|
||||
|
|
|
@ -339,8 +339,8 @@ void GLSprite::SplitSprite(sector_t * frontsector, bool translucent)
|
|||
for(i=0;i<lightlist.Size();i++)
|
||||
{
|
||||
// Particles don't go through here so we can safely assume that actor is not NULL
|
||||
if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor->x,actor->y);
|
||||
else lightbottom=frontsector->floorplane.ZatPoint(actor->x,actor->y);
|
||||
if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor);
|
||||
else lightbottom=frontsector->floorplane.ZatPoint(actor);
|
||||
|
||||
maplightbottom=FIXED2FLOAT(lightbottom);
|
||||
if (maplightbottom<z2) maplightbottom=z2;
|
||||
|
@ -379,8 +379,8 @@ void GLSprite::SetSpriteColor(sector_t *sector, fixed_t center_y)
|
|||
for(i=0;i<lightlist.Size();i++)
|
||||
{
|
||||
// Particles don't go through here so we can safely assume that actor is not NULL
|
||||
if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor->x,actor->y);
|
||||
else lightbottom=sector->floorplane.ZatPoint(actor->x,actor->y);
|
||||
if (i<lightlist.Size()-1) lightbottom=lightlist[i+1].plane.ZatPoint(actor);
|
||||
else lightbottom=sector->floorplane.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<short>(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)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue