- adjustments for floating point changes.

This commit is contained in:
Christoph Oelckers 2016-03-21 02:57:02 +01:00
parent 48afdd7dcb
commit b54b34a512
19 changed files with 107 additions and 91 deletions

View file

@ -3,6 +3,7 @@
#define __GLC_DATA_H
#include "doomtype.h"
#include "vectors.h"
struct GLRenderSettings
{

View file

@ -361,7 +361,7 @@ static void CollectPortalSectors(FPortalMap &collection)
ASkyViewpoint *SkyBox = barrier_cast<ASkyViewpoint*>(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->_f_X() - SkyBox->Mate->_f_X(), SkyBox->_f_Y() - SkyBox->Mate->_f_Y() };
FPortalSectors &sss = collection[id];
FPortalSector ss = { sec, j };

View file

@ -35,6 +35,8 @@
**
*/
#include "gl/system/gl_system.h"
#include "templates.h"
#include "m_random.h"
#include "p_local.h"
@ -174,7 +176,7 @@ void ADynamicLight::PostBeginPlay()
Activate (NULL);
}
subsector = R_PointInSubsector(X(), Y());
subsector = R_PointInSubsector(_f_X(), _f_Y());
}
@ -193,7 +195,7 @@ void ADynamicLight::Activate(AActor *activator)
if (lighttype == PulseLight)
{
float pulseTime = ANGLE_TO_FLOAT(this->angle) / TICRATE;
float pulseTime = Angles.Yaw.Degrees / TICRATE;
m_lastUpdate = level.maptime;
m_cycler.SetParams(float(m_intensity[1]), float(m_intensity[0]), pulseTime);
@ -257,7 +259,7 @@ void ADynamicLight::Tick()
case FlickerLight:
{
BYTE rnd = randLight();
float pct = ANGLE_TO_FLOAT(angle)/360.f;
float pct = Angles.Yaw.Degrees / 360.f;
m_currentIntensity = float(m_intensity[rnd >= pct * 255]);
break;
@ -270,7 +272,7 @@ void ADynamicLight::Tick()
m_tickCount++;
if (m_tickCount > ANGLE_TO_FLOAT(angle))
if (m_tickCount > Angles.Yaw.Degrees)
{
m_currentIntensity = float(m_intensity[0] + (amt * flickerRange));
m_tickCount = 0;
@ -283,7 +285,7 @@ void ADynamicLight::Tick()
case ColorFlickerLight:
{
BYTE rnd = randLight();
float pct = ANGLE_TO_FLOAT(angle)/360.f;
float pct = ANGLE2FLOAT(angle)/360.f;
m_currentIntensity = m_intensity[rnd >= pct * 255];
break;
@ -296,7 +298,7 @@ void ADynamicLight::Tick()
m_tickCount++;
if (m_tickCount > ANGLE_TO_FLOAT(angle))
if (m_tickCount > ANGLE2FLOAT(angle))
{
m_currentIntensity = m_intensity[0] + (amt * flickerRange);
m_tickCount = 0;
@ -337,16 +339,16 @@ void ADynamicLight::Tick()
//==========================================================================
void ADynamicLight::UpdateLocation()
{
fixed_t oldx=X();
fixed_t oldy=Y();
fixed_t oldradius=radius;
double oldx= X();
double oldy= Y();
double oldradius= radius;
float intensity;
if (IsActive())
{
if (target)
{
angle_t angle = target->angle>>ANGLETOFINESHIFT;
angle_t angle = target->_f_angle() >> ANGLETOFINESHIFT;
fixedvec3 pos = target->Vec3Offset(
FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]),
FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]),
@ -363,7 +365,7 @@ void ADynamicLight::UpdateLocation()
// The radius being used here is always the maximum possible with the
// current settings. This avoids constant relinking of flickering lights
if (lighttype == FlickerLight || lighttype == RandomFlickerLight)
if (lighttype == FlickerLight || lighttype == RandomFlickerLight)
{
intensity = float(MAX(m_intensity[0], m_intensity[1]));
}
@ -371,9 +373,9 @@ void ADynamicLight::UpdateLocation()
{
intensity = m_currentIntensity;
}
radius = FLOAT2FIXED(intensity * 2.0f * gl_lights_size);
radius = 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();
@ -599,9 +601,9 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe
{
line_t *other = subSec->firstline->linedef;
AActor *sb = subSec->sector->SkyBoxes[sector_t::ceiling];
if (sb->threshold < Z() + radius)
if (sb->specialf1 < Z() + radius)
{
fixedvec2 refpos = { other->v1->x + other->dx / 2 + sb->scaleX, other->v1->y + other->dy / 2 + sb->scaleY };
fixedvec2 refpos = { other->v1->x + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->y + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) };
subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y);
if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius);
}
@ -610,9 +612,9 @@ void ADynamicLight::CollectWithinRadius(const fixedvec3 &pos, subsector_t *subSe
{
line_t *other = subSec->firstline->linedef;
AActor *sb = subSec->sector->SkyBoxes[sector_t::floor];
if (sb->threshold > Z() - radius)
if (sb->specialf1 > Z() - radius)
{
fixedvec2 refpos = { other->v1->x + other->dx / 2 + sb->scaleX, other->v1->y + other->dy / 2 + sb->scaleY };
fixedvec2 refpos = { other->v1->x + other->dx / 2 + FLOAT2FIXED(sb->Scale.X), other->v1->y + other->dy / 2 + FLOAT2FIXED(sb->Scale.Y) };
subsector_t *othersub = R_PointInSubsector(refpos.x, refpos.y);
if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius);
}
@ -652,10 +654,9 @@ 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());
float fradius = FIXED2FLOAT(radius);
subsector_t * subSec = R_PointInSubsector(_f_X(), _f_Y());
::validcount++;
CollectWithinRadius(Pos(), subSec, fradius*fradius);
CollectWithinRadius(_f_Pos(), subSec, radius*radius);
}
@ -760,8 +761,8 @@ 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],
dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], FIXED2FLOAT(dl->radius));
dl->X(), dl->Y(), dl->Z(), dl->args[LIGHT_RED],
dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], dl->radius);
i++;
if (dl->target)

View file

@ -171,7 +171,7 @@ FLightDefaults::FLightDefaults(FName name, ELightType type)
void FLightDefaults::ApplyProperties(ADynamicLight * light) const
{
light->lighttype = m_type;
light->angle = m_Angle;
light->Angles.Yaw = ANGLE2DBL(m_Angle);
light->SetOffset(m_X, m_Y, m_Z);
light->halo = m_halo;
for (int a = 0; a < 3; a++) light->args[a] = clamp<int>((int)(m_Args[a] * gl_lights_intensity), 0, 255);
@ -423,7 +423,7 @@ void gl_ParsePulseLight(FScanner &sc)
break;
case LIGHTTAG_INTERVAL:
floatVal = gl_ParseFloat(sc);
defaults->SetAngle(FLOAT_TO_ANGLE(floatVal * TICRATE));
defaults->SetAngle(FLOAT2ANGLE(floatVal * TICRATE));
break;
case LIGHTTAG_SUBTRACTIVE:
defaults->SetSubtractive(gl_ParseInt(sc) != 0);

View file

@ -523,7 +523,7 @@ void gl_InitModels()
else if (sc.Compare("angleoffset"))
{
sc.MustGetFloat();
smf.angleoffset = FLOAT_TO_ANGLE(sc.Float);
smf.angleoffset = FLOAT2ANGLE(sc.Float);
}
else if (sc.Compare("pitchoffset"))
{
@ -854,20 +854,20 @@ void gl_RenderModel(GLSprite * spr)
// y scale for a sprite means height, i.e. z in the world!
float scaleFactorX = FIXED2FLOAT(spr->actor->scaleX) * smf->xscale;
float scaleFactorY = FIXED2FLOAT(spr->actor->scaleX) * smf->yscale;
float scaleFactorZ = FIXED2FLOAT(spr->actor->scaleY) * smf->zscale;
float scaleFactorX = spr->actor->Scale.X * smf->xscale;
float scaleFactorY = spr->actor->Scale.X * smf->yscale;
float scaleFactorZ = spr->actor->Scale.Y * smf->zscale;
float pitch = 0;
float roll = 0;
float rotateOffset = 0;
float angle = ANGLE_TO_FLOAT(spr->actor->angle);
float angle = spr->actor->Angles.Yaw.Degrees;
// [BB] Workaround for the missing pitch information.
if ( (smf->flags & MDL_PITCHFROMMOMENTUM) )
{
const double x = static_cast<double>(spr->actor->vel.x);
const double y = static_cast<double>(spr->actor->vel.y);
const double z = static_cast<double>(spr->actor->vel.z);
const double x = spr->actor->Vel.X;
const double y = spr->actor->Vel.Y;
const double z = spr->actor->Vel.Z;
// [BB] Calculate the pitch using spherical coordinates.
if(z || x || y) pitch = float(atan( z/sqrt(x*x+y*y) ) / M_PI * 180);
@ -888,9 +888,8 @@ void gl_RenderModel(GLSprite * spr)
// Added MDL_INHERITACTORPITCH and MDL_INHERITACTORROLL flags processing.
// If both flags MDL_INHERITACTORPITCH and MDL_PITCHFROMMOMENTUM are set, the pitch sums up the actor pitch and the momentum vector pitch.
// This is rather crappy way to transfer fixet_t type into angle in degrees, but its works!
if(smf->flags & MDL_INHERITACTORPITCH) pitch += float(static_cast<double>(spr->actor->pitch >> 16) / (1 << 13) * 45 + static_cast<double>(spr->actor->pitch & 0x0000FFFF) / (1 << 29) * 45);
if(smf->flags & MDL_INHERITACTORROLL) roll += float(static_cast<double>(spr->actor->roll >> 16) / (1 << 13) * 45 + static_cast<double>(spr->actor->roll & 0x0000FFFF) / (1 << 29) * 45);
if(smf->flags & MDL_INHERITACTORPITCH) pitch += spr->actor->Angles.Pitch.Degrees;
if(smf->flags & MDL_INHERITACTORROLL) roll += spr->actor->Angles.Roll.Degrees;
gl_RenderState.mModelMatrix.loadIdentity();
@ -920,7 +919,7 @@ void gl_RenderModel(GLSprite * spr)
gl_RenderState.mModelMatrix.translate(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale);
// 5) Applying model rotations.
gl_RenderState.mModelMatrix.rotate(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0);
gl_RenderState.mModelMatrix.rotate(-ANGLE2FLOAT(smf->angleoffset), 0, 1, 0);
gl_RenderState.mModelMatrix.rotate(smf->pitchoffset, 0, 0, 1);
gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0);
@ -983,7 +982,7 @@ void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy)
gl_RenderState.mViewMatrix.rotate(90.f, 0, 1, 0);
// Applying angleoffset, pitchoffset, rolloffset.
gl_RenderState.mViewMatrix.rotate(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0);
gl_RenderState.mViewMatrix.rotate(-ANGLE2FLOAT(smf->angleoffset), 0, 1, 0);
gl_RenderState.mViewMatrix.rotate(smf->pitchoffset, 0, 0, 1);
gl_RenderState.mViewMatrix.rotate(-smf->rolloffset, 1, 0, 0);
gl_RenderState.ApplyMatrices();

View file

@ -88,7 +88,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
mMirrorCount = 0;
mPlaneMirrorCount = 0;
mLightCount = 0;
mAngles = FRotator(0,0,0);
mAngles = FRotator(0.f, 0.f, 0.f);
mViewVector = FVector2(0,0);
mVBO = NULL;
mSkyVBO = NULL;

View file

@ -19,6 +19,16 @@ class GLPortal;
class FLightBuffer;
class FSamplerManager;
inline float DEG2RAD(float deg)
{
return deg * float(M_PI / 180.0);
}
inline float RAD2DEG(float deg)
{
return deg * float(180. / M_PI);
}
enum SectorRenderFlags
{
// This is used to avoid creating too many drawinfos
@ -94,7 +104,7 @@ public:
void DrawScene(bool toscreen = false);
void DrawBlend(sector_t * viewsector);
void DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader, bool alphatexture);
void DrawPSprite (player_t * player,pspdef_t *psp,float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture);
void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep);
void DrawTargeterSprites();

View file

@ -93,7 +93,7 @@ void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte
{
yscale1 = 0 - yscale1;
}
float angle=-ANGLE_TO_FLOAT(secplane->angle);
float angle=-ANGLE2FLOAT(secplane->angle);
float xscale2=64.f/gltexture->TextureWidth();
float yscale2=64.f/gltexture->TextureHeight();
@ -143,7 +143,7 @@ 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);
if (gl_lights_checkside && ((planeh<light->Z() && ceiling) || (planeh>light->Z() && !ceiling)))
if (gl_lights_checkside && ((planeh<light->_f_Z() && ceiling) || (planeh>light->_f_Z() && !ceiling)))
{
node=node->nextLight;
continue;

View file

@ -659,7 +659,7 @@ void GLSkyboxPortal::DrawContents()
viewx = viewpos.x;
viewy = viewpos.y;
viewz = viewpos.z;
viewangle += origin->PrevAngle + FixedMul(r_TicFrac, origin->angle - origin->PrevAngle);
viewangle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * FIXED2DBL(r_TicFrac)).BAMs();
// Don't let the viewpoint be too close to a floor or ceiling
fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin);
@ -1003,7 +1003,9 @@ void GLLineToLinePortal::DrawContents()
line_t *origin = glport->reference->mOrigin;
P_TranslatePortalXY(origin, viewx, viewy);
P_TranslatePortalAngle(origin, viewangle);
DAngle va = ANGLE2DBL(viewangle);
P_TranslatePortalAngle(origin, va);
viewangle = va.BAMs();
P_TranslatePortalZ(origin, viewz);
SaveMapSection();

View file

@ -110,7 +110,7 @@ void gl_ParseDefs();
//-----------------------------------------------------------------------------
angle_t FGLRenderer::FrustumAngle()
{
float tilt= fabs(mAngles.Pitch);
float tilt= fabs(mAngles.Pitch.Degrees);
// If the pitch is larger than this you can look all around at a FOV of 90°
if (tilt>46.0f) return 0xffffffff;
@ -118,7 +118,7 @@ angle_t FGLRenderer::FrustumAngle()
// ok, this is a gross hack that barely works...
// but at least it doesn't overestimate too much...
double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/BaseRatioSizes[WidescreenRatio][3]/90.0;
angle_t a1 = FLOAT_TO_ANGLE(floatangle);
angle_t a1 = FLOAT2ANGLE(floatangle);
if (a1>=ANGLE_180) return 0xffffffff;
return a1;
}
@ -264,9 +264,9 @@ void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, boo
float planemult = planemirror? -glset.pixelstretch : glset.pixelstretch;
gl_RenderState.mViewMatrix.loadIdentity();
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll, 0.0f, 0.0f, 1.0f);
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch, 1.0f, 0.0f, 0.0f);
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw, 0.0f, mult, 0.0f);
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll.Degrees, 0.0f, 0.0f, 1.0f);
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch.Degrees, 1.0f, 0.0f, 0.0f);
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw.Degrees, 0.0f, mult, 0.0f);
gl_RenderState.mViewMatrix.translate(FIXED2FLOAT(viewx) * mult, -FIXED2FLOAT(viewz) * planemult , -FIXED2FLOAT(viewy));
gl_RenderState.mViewMatrix.scale(-mult, planemult, 1);
}
@ -780,7 +780,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
double alen = sqrt(angx*angx + angy*angy);
mAngles.Pitch = (float)RAD2DEG(asin(angy / alen));
mAngles.Roll = (float)(camera->roll>>ANGLETOFINESHIFT)*360.0f/FINEANGLES;
mAngles.Roll.Degrees = camera->Angles.Roll.Degrees;
// Scroll the sky
mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f;
@ -817,7 +817,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
// SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper
SetViewAngle(viewangle);
// Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz
eye->GetViewShift(GLRenderer->mAngles.Yaw, viewShift);
eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift);
s3d::ScopedViewShifter viewShifter(viewShift);
SetViewMatrix(viewx, viewy, viewz, false, false);
gl_RenderState.ApplyMatrices();

View file

@ -92,7 +92,7 @@ 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] = ANGLE_TO_FLOAT(s->GetTextureXOffset(pos));
x_offset[0] = ANGLE2FLOAT(s->GetTextureXOffset(pos));
y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos));
mirrored = !l->args[2];
}

View file

@ -281,12 +281,12 @@ void GLSprite::Draw(int pass)
float xcenter = (x1 + x2)*0.5;
float ycenter = (y1 + y2)*0.5;
float zcenter = (z1 + z2)*0.5;
float angleRad = DEG2RAD(270. - float(GLRenderer->mAngles.Yaw));
float angleRad = ToRadians(270. - GLRenderer->mAngles.Yaw);
Matrix3x4 mat;
mat.MakeIdentity();
mat.Translate(xcenter, zcenter, ycenter);
mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch);
mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees);
mat.Translate(-xcenter, -zcenter, -ycenter);
v1 = mat * Vector(x1, z1, y1);
v2 = mat * Vector(x2, z1, y2);
@ -387,8 +387,8 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_
thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE ||
!(thing->flags&MF_CORPSE))) || (gl_spriteclip == 3 && (smarterclip = true)) || gl_spriteclip > 1)
{
float btm = 1000000.0f;
float top = -1000000.0f;
float btm = 100000000.0f;
float top = -100000000.0f;
extsector_t::xfloor &x = thing->Sector->e->XFloor;
if (x.ffloors.Size())
@ -396,17 +396,17 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_
for (unsigned int i = 0; i < x.ffloors.Size(); i++)
{
F3DFloor * ff = x.ffloors[i];
fixed_t floorh = ff->top.plane->ZatPoint(thingx, thingy);
fixed_t ceilingh = ff->bottom.plane->ZatPoint(thingx, thingy);
float floorh = FIXED2FLOAT(ff->top.plane->ZatPoint(thingx, thingy));
float ceilingh = FIXED2FLOAT(ff->bottom.plane->ZatPoint(thingx, thingy));
if (floorh == thing->floorz)
{
btm = FIXED2FLOAT(floorh);
btm = floorh;
}
if (ceilingh == thing->ceilingz)
{
top = FIXED2FLOAT(ceilingh);
top = ceilingh;
}
if (btm != 1000000.0f && top != -1000000.0f)
if (btm != 100000000.0f && top != -100000000.0f)
{
break;
}
@ -415,14 +415,14 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_
else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
{
if (thing->flags2&MF2_ONMOBJ && thing->floorz ==
thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy))
FIXED2FLOAT(thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy)))
{
btm = FIXED2FLOAT(thing->floorz);
top = FIXED2FLOAT(thing->ceilingz);
btm = thing->floorz;
top = thing->ceilingz;
}
}
if (btm == 1000000.0f)
btm = FIXED2FLOAT(thing->Sector->floorplane.ZatPoint(thingx, thingy) - thing->floorclip);
btm = FIXED2FLOAT(thing->Sector->floorplane.ZatPoint(thing)) - thing->Floorclip;
if (top == -1000000.0f)
top = FIXED2FLOAT(thing->Sector->ceilingplane.ZatPoint(thingx, thingy));
@ -492,11 +492,10 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
}
int spritenum = thing->sprite;
fixed_t spritescaleX = thing->scaleX;
fixed_t spritescaleY = thing->scaleY;
DVector2 sprscale = thing->Scale;
if (thing->player != NULL)
{
P_CheckPlayerSprite(thing, spritenum, spritescaleX, spritescaleY);
P_CheckPlayerSprite(thing, spritenum, sprscale);
}
if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->alpha))
@ -514,10 +513,10 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
// Too close to the camera. This doesn't look good if it is a sprite.
if (P_AproxDistance(thingpos.x-viewx, thingpos.y-viewy)<2*FRACUNIT)
{
if (viewz >= thingpos.z - 2 * FRACUNIT && viewz <= thingpos.z + thing->height + 2 * FRACUNIT)
if (viewz >= thingpos.z - 2 * FRACUNIT && viewz <= thingpos.z + FLOAT2FIXED(thing->Height) + 2 * FRACUNIT)
{
// exclude vertically moving objects from this check.
if (!(thing->vel.x == 0 && thing->vel.y == 0 && thing->vel.z != 0))
if (!thing->Vel.isZero())
{
if (!gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, false))
{
@ -532,7 +531,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
{
if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL)
{
fixed_t clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius*2);
fixed_t clipdist = FLOAT2FIXED(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.
@ -558,7 +557,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
x = FIXED2FLOAT(thingpos.x);
z = FIXED2FLOAT(thingpos.z-thing->floorclip);
z = FIXED2FLOAT(thingpos.z)-thing->Floorclip;
y = FIXED2FLOAT(thingpos.y);
// [RH] Make floatbobbing a renderer-only effect.
@ -574,7 +573,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
angle_t ang = R_PointToAngle(thingpos.x, thingpos.y);
bool mirror;
FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->angle, &mirror);
FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->Angles.Yaw.BAMs(), &mirror);
if (!patch.isValid()) return;
int type = thing->renderflags & RF_SPRITETYPEMASK;
gltexture = FMaterial::ValidateTexture(patch, (type == RF_FACESPRITE), false);
@ -595,7 +594,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
ur = gltexture->GetSpriteUL();
}
r.Scale(FIXED2FLOAT(spritescaleX), FIXED2FLOAT(spritescaleY));
r.Scale(sprscale.X, sprscale.Y);
float rightfac = -r.left;
float leftfac = rightfac - r.width;
@ -603,7 +602,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
z1 = z - r.top;
z2 = z1 - r.height;
float spriteheight = FIXED2FLOAT(spritescaleY) * r.height;
float spriteheight = sprscale.Y * r.height;
// 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)
@ -626,8 +625,8 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
break;
case RF_WALLSPRITE:
viewvecX = FIXED2FLOAT(finecosine[thing->angle >> ANGLETOFINESHIFT]);
viewvecY = FIXED2FLOAT(finesine[thing->angle >> ANGLETOFINESHIFT]);
viewvecX = thing->Angles.Yaw.Cos();
viewvecY = thing->Angles.Yaw.Sin();
x1 = x + viewvecY*leftfac;
x2 = x + viewvecY*rightfac;

View file

@ -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->_f_X()), FIXED2FLOAT(y - light->_f_Y()), FIXED2FLOAT(z - light->_f_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->_f_X(), thing->_f_Y(), thing->_f_Z() + (thing->_f_height() >> 1), thing->subsector);
}
else if (particle != NULL)
{

View file

@ -117,9 +117,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 = node->lightsource->X();
float y = node->lightsource->Y();
float z = 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);

View file

@ -71,7 +71,7 @@ EXTERN_CVAR (Bool, r_deathcamera)
//
//==========================================================================
void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader, bool alphatexture)
void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp, float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture)
{
float fU1,fV1;
float fU2,fV2;
@ -109,7 +109,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed
// calculate edges of the shape
scalex = xratio[WidescreenRatio] * vw / 320;
tx = FIXED2FLOAT(sx) - (160 - r.left);
tx = sx - (160 - r.left);
x1 = tx * scalex + vw/2;
if (x1 > vw) return; // off the right side
x1 += viewwindowx;
@ -121,7 +121,7 @@ void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed
// killough 12/98: fix psprite positioning problem
ftexturemid = 100.f - FIXED2FLOAT(sy) - r.top;
ftexturemid = 100.f - sy - r.top;
AWeapon * wi=player->ReadyWeapon;
if (wi && wi->YAdjust)
@ -188,7 +188,7 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
unsigned int i;
pspdef_t *psp;
int lightlevel=0;
fixed_t ofsx, ofsy;
float ofsx, ofsy;
FColormap cm;
sector_t * fakesec, fs;
AActor * playermo=players[consoleplayer].camera;
@ -202,7 +202,10 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
(r_deathcamera && camera->health <= 0))
return;
P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy);
fixed_t ox, oy;
P_BobWeapon (player, &player->psprites[ps_weapon], &ox, &oy);
ofsx = FIXED2FLOAT(ox);
ofsy = FIXED2FLOAT(oy);
// check for fullbright
if (player->fixedcolormap==NOFIXEDCOLORMAP)
@ -250,7 +253,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->_f_X(), playermo->_f_Y(), playermo->_f_Z());
// calculate colormap for weapon sprites
if (viewsector->e->XFloor.ffloors.Size() && !glset.nocoloredspritelighting)

View file

@ -33,7 +33,9 @@
**
*/
#include "gl/system/gl_system.h"
#include "gl/stereo3d/gl_stereo3d.h"
#include "gl/renderer/gl_renderer.h"
#include "vectors.h" // RAD2DEG
#include "doomtype.h" // M_PI

View file

@ -37,6 +37,7 @@
#include "vectors.h" // RAD2DEG
#include "doomtype.h" // M_PI
#include "gl/system/gl_cvars.h"
#include "gl/renderer/gl_renderer.h"
#include <cmath>
EXTERN_CVAR(Float, vr_screendist)

View file

@ -185,7 +185,7 @@ void CheckBench()
compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n",
level.MapName.GetChars(), level.LevelName.GetChars(), FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz),
ANGLE_TO_FLOAT(viewangle), ANGLE_TO_FLOAT(viewpitch));
ANGLE2FLOAT(viewangle), ANGLE2FLOAT(viewpitch));
AppendRenderStats(compose);
AppendRenderTimes(compose);

View file

@ -3,7 +3,5 @@
#define __GLC_CONVERT
#include "m_fixed.h"
#define ANGLE_TO_FLOAT(ang) ((float)((ang) * 180. / ANGLE_180))
#define FLOAT_TO_ANGLE(ang) xs_RoundToUInt((ang) / 180. * ANGLE_180)
#endif