- floatified the decal code.

This commit is contained in:
Christoph Oelckers 2016-03-22 22:07:38 +01:00
parent 6b3c0ecbd3
commit 301f5abadc
12 changed files with 178 additions and 158 deletions

View File

@ -2382,7 +2382,8 @@ void Net_DoCommand (int type, BYTE **stream, int player)
{ {
if (trace.HitType == TRACE_HitWall) if (trace.HitType == TRACE_HitWall)
{ {
DImpactDecal::StaticCreate (s, trace.HitPos, trace.Line->sidedef[trace.Side], NULL); DVector3 hp(FIXED2DBL(trace.HitPos.x), FIXED2DBL(trace.HitPos.y), FIXED2DBL(trace.HitPos.z));
DImpactDecal::StaticCreate (s, hp, trace.Line->sidedef[trace.Side], NULL);
} }
} }
} }

View File

@ -52,7 +52,7 @@
FDecalLib DecalLibrary; FDecalLib DecalLibrary;
static fixed_t ReadScale (FScanner &sc); static double ReadScale (FScanner &sc);
static TArray<BYTE> DecalTranslations; static TArray<BYTE> DecalTranslations;
// A decal group holds multiple decals and returns one randomly // A decal group holds multiple decals and returns one randomly
@ -148,7 +148,7 @@ public:
int TimeToStartDecay; int TimeToStartDecay;
int TimeToEndDecay; int TimeToEndDecay;
fixed_t StartTrans; double StartTrans;
private: private:
DDecalFader () {} DDecalFader () {}
}; };
@ -186,7 +186,7 @@ struct FDecalStretcherAnim : public FDecalAnimator
int StretchStart; int StretchStart;
int StretchTime; int StretchTime;
fixed_t GoalX, GoalY; double GoalX, GoalY;
}; };
class DDecalStretcher : public DDecalThinker class DDecalStretcher : public DDecalThinker
@ -199,10 +199,10 @@ public:
int TimeToStart; int TimeToStart;
int TimeToStop; int TimeToStop;
fixed_t GoalX; double GoalX;
fixed_t StartX; double StartX;
fixed_t GoalY; double GoalY;
fixed_t StartY; double StartY;
bool bStretchX; bool bStretchX;
bool bStretchY; bool bStretchY;
bool bStarted; bool bStarted;
@ -217,7 +217,7 @@ struct FDecalSliderAnim : public FDecalAnimator
int SlideStart; int SlideStart;
int SlideTime; int SlideTime;
fixed_t /*DistX,*/ DistY; double /*DistX,*/ DistY;
}; };
class DDecalSlider : public DDecalThinker class DDecalSlider : public DDecalThinker
@ -230,10 +230,10 @@ public:
int TimeToStart; int TimeToStart;
int TimeToStop; int TimeToStop;
/* fixed_t DistX; */ /* double DistX; */
fixed_t DistY; double DistY;
fixed_t StartX; double StartX;
fixed_t StartY; double StartY;
bool bStarted; bool bStarted;
private: private:
DDecalSlider () {} DDecalSlider () {}
@ -453,10 +453,10 @@ void FDecalLib::ParseDecal (FScanner &sc)
memset ((void *)&newdecal, 0, sizeof(newdecal)); memset ((void *)&newdecal, 0, sizeof(newdecal));
newdecal.PicNum.SetInvalid(); newdecal.PicNum.SetInvalid();
newdecal.ScaleX = newdecal.ScaleY = FRACUNIT; newdecal.ScaleX = newdecal.ScaleY = 1.;
newdecal.RenderFlags = RF_WALLSPRITE; newdecal.RenderFlags = RF_WALLSPRITE;
newdecal.RenderStyle = STYLE_Normal; newdecal.RenderStyle = STYLE_Normal;
newdecal.Alpha = 0x8000; newdecal.Alpha = 1.;
for (;;) for (;;)
{ {
@ -492,13 +492,13 @@ void FDecalLib::ParseDecal (FScanner &sc)
case DECAL_ADD: case DECAL_ADD:
sc.MustGetFloat (); sc.MustGetFloat ();
newdecal.Alpha = (WORD)(32768.f * sc.Float); newdecal.Alpha = sc.Float;
newdecal.RenderStyle = STYLE_Add; newdecal.RenderStyle = STYLE_Add;
break; break;
case DECAL_TRANSLUCENT: case DECAL_TRANSLUCENT:
sc.MustGetFloat (); sc.MustGetFloat ();
newdecal.Alpha = (WORD)(32768.f * sc.Float); newdecal.Alpha = sc.Float;
newdecal.RenderStyle = STYLE_Translucent; newdecal.RenderStyle = STYLE_Translucent;
break; break;
@ -681,7 +681,7 @@ void FDecalLib::ParseFader (FScanner &sc)
void FDecalLib::ParseStretcher (FScanner &sc) void FDecalLib::ParseStretcher (FScanner &sc)
{ {
FString stretcherName; FString stretcherName;
fixed_t goalX = -1, goalY = -1; double goalX = -1, goalY = -1;
int startTime = 0, takeTime = 0; int startTime = 0, takeTime = 0;
sc.MustGetString (); sc.MustGetString ();
@ -732,7 +732,7 @@ void FDecalLib::ParseStretcher (FScanner &sc)
void FDecalLib::ParseSlider (FScanner &sc) void FDecalLib::ParseSlider (FScanner &sc)
{ {
FString sliderName; FString sliderName;
fixed_t distX = 0, distY = 0; double distX = 0, distY = 0;
int startTime = 0, takeTime = 0; int startTime = 0, takeTime = 0;
sc.MustGetString (); sc.MustGetString ();
@ -773,7 +773,7 @@ void FDecalLib::ParseSlider (FScanner &sc)
else if (sc.Compare ("DistY")) else if (sc.Compare ("DistY"))
{ {
sc.MustGetFloat (); sc.MustGetFloat ();
distY = (fixed_t)(sc.Float * FRACUNIT); distY = sc.Float;
} }
else else
{ {
@ -1046,7 +1046,7 @@ void FDecalTemplate::ApplyToDecal (DBaseDecal *decal, side_t *wall) const
decal->ScaleX = ScaleX; decal->ScaleX = ScaleX;
decal->ScaleY = ScaleY; decal->ScaleY = ScaleY;
decal->PicNum = PicNum; decal->PicNum = PicNum;
decal->Alpha = Alpha << 1; decal->Alpha = Alpha;
decal->RenderStyle = RenderStyle; decal->RenderStyle = RenderStyle;
decal->RenderFlags = (RenderFlags & ~(DECAL_RandomFlipX|DECAL_RandomFlipY)) | decal->RenderFlags = (RenderFlags & ~(DECAL_RandomFlipX|DECAL_RandomFlipY)) |
(decal->RenderFlags & (RF_RELMASK|RF_CLIPMASK|RF_INVISIBLE|RF_ONESIDED)); (decal->RenderFlags & (RF_RELMASK|RF_CLIPMASK|RF_INVISIBLE|RF_ONESIDED));
@ -1184,7 +1184,7 @@ void DDecalFader::Tick ()
int distanceToEnd = TimeToEndDecay - level.maptime; int distanceToEnd = TimeToEndDecay - level.maptime;
int fadeDistance = TimeToEndDecay - TimeToStartDecay; int fadeDistance = TimeToEndDecay - TimeToStartDecay;
TheDecal->Alpha = Scale (StartTrans, distanceToEnd, fadeDistance); TheDecal->Alpha = StartTrans * distanceToEnd / fadeDistance;
} }
} }
@ -1278,11 +1278,11 @@ void DDecalStretcher::Tick ()
int maxDistance = TimeToStop - TimeToStart; int maxDistance = TimeToStop - TimeToStart;
if (bStretchX) if (bStretchX)
{ {
TheDecal->ScaleX = StartX + Scale (GoalX - StartX, distance, maxDistance); TheDecal->ScaleX = StartX + (GoalX - StartX) * distance / maxDistance;
} }
if (bStretchY) if (bStretchY)
{ {
TheDecal->ScaleY = StartY + Scale (GoalY - StartY, distance, maxDistance); TheDecal->ScaleY = StartY + (GoalY - StartY) * distance / maxDistance;
} }
} }
@ -1339,8 +1339,8 @@ void DDecalSlider::Tick ()
int distance = level.maptime - TimeToStart; int distance = level.maptime - TimeToStart;
int maxDistance = TimeToStop - TimeToStart; int maxDistance = TimeToStop - TimeToStart;
/*TheDecal->LeftDistance = StartX + Scale (DistX, distance, maxDistance);*/ /*TheDecal->LeftDistance = StartX + DistX * distance / maxDistance);*/
TheDecal->Z = StartY + Scale (DistY, distance, maxDistance); TheDecal->Z = StartY + DistY * distance / maxDistance;
} }
DThinker *FDecalCombinerAnim::CreateThinker (DBaseDecal *actor, side_t *wall) const DThinker *FDecalCombinerAnim::CreateThinker (DBaseDecal *actor, side_t *wall) const
@ -1428,8 +1428,8 @@ DThinker *FDecalColorerAnim::CreateThinker (DBaseDecal *actor, side_t *wall) con
return Colorer; return Colorer;
} }
static fixed_t ReadScale (FScanner &sc) static double ReadScale (FScanner &sc)
{ {
sc.MustGetFloat (); sc.MustGetFloat ();
return fixed_t(clamp (sc.Float * FRACUNIT, 256.0, 256.0*FRACUNIT)); return clamp (sc.Float, 1/256.0, 256.0);
} }

View File

@ -74,13 +74,13 @@ public:
const FDecalTemplate *GetDecal () const; const FDecalTemplate *GetDecal () const;
void ReplaceDecalRef (FDecalBase *from, FDecalBase *to); void ReplaceDecalRef (FDecalBase *from, FDecalBase *to);
fixed_t ScaleX, ScaleY; double ScaleX, ScaleY;
DWORD ShadeColor; DWORD ShadeColor;
DWORD Translation; DWORD Translation;
FRenderStyle RenderStyle; FRenderStyle RenderStyle;
FTextureID PicNum; FTextureID PicNum;
WORD RenderFlags; WORD RenderFlags;
WORD Alpha; // same as (actor->alpha >> 1) double Alpha; // same as actor->alpha
const FDecalAnimator *Animator; const FDecalAnimator *Animator;
const FDecalBase *LowerDecal; const FDecalBase *LowerDecal;

View File

@ -28,8 +28,8 @@ static FRandom pr_orbit ("Orbit");
233: -30° / seconds 233: -30° / seconds
244: -15° / seconds 244: -15° / seconds
This value only matters if args[2] is not zero. This value only matters if args[2] is not zero.
args[4]: Rotation _f_radius() of bridge balls, in bridge _f_radius() %. args[4]: Rotation radius of bridge balls, in bridge radius %.
If 0, use Hexen default: ORBIT_RADIUS, regardless of bridge _f_radius(). If 0, use Hexen default: ORBIT_RADIUS, regardless of bridge radius.
This value only matters if args[2] is not zero. This value only matters if args[2] is not zero.
*/ */
@ -102,17 +102,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit)
// Set default values // Set default values
// Every five tics, Hexen moved the ball 3/256th of a revolution. // Every five tics, Hexen moved the ball 3/256th of a revolution.
DAngle rotationspeed = 45./32*3/5; DAngle rotationspeed = 45./32*3/5;
int rotationradius = ORBIT_RADIUS; double rotationradius = ORBIT_RADIUS;
// If the bridge is custom, set non-default values if any. // If the bridge is custom, set non-default values if any.
// Set angular speed; 1--128: counterclockwise rotation ~=1--180°; 129--255: clockwise rotation ~= 180--1° // Set angular speed; 1--128: counterclockwise rotation ~=1--180°; 129--255: clockwise rotation ~= 180--1°
if (self->target->args[3] > 128) rotationspeed = 45./32 * (self->target->args[3]-256) / TICRATE; if (self->target->args[3] > 128) rotationspeed = 45./32 * (self->target->args[3]-256) / TICRATE;
else if (self->target->args[3] > 0) rotationspeed = 45./32 * (self->target->args[3]) / TICRATE; else if (self->target->args[3] > 0) rotationspeed = 45./32 * (self->target->args[3]) / TICRATE;
// Set rotation _f_radius() // Set rotation radius
if (self->target->args[4]) rotationradius = ((self->target->args[4] * self->target->_f_radius()) / 100); if (self->target->args[4]) rotationradius = ((self->target->args[4] * self->target->radius) / 100);
self->Angles.Yaw += rotationspeed; self->Angles.Yaw += rotationspeed;
self->SetOrigin(self->target->Vec3Angle(rotationradius*FRACUNIT, self->Angles.Yaw, 0), true); self->SetOrigin(self->target->Vec3Angle(rotationradius, self->Angles.Yaw, 0), true);
self->floorz = self->target->floorz; self->floorz = self->target->floorz;
self->ceilingz = self->target->ceilingz; self->ceilingz = self->target->ceilingz;
return 0; return 0;

View File

@ -173,9 +173,8 @@ void AAimingCamera::Tick ()
} }
if (MaxPitchChange != 0) if (MaxPitchChange != 0)
{ // Aim camera's pitch; use floats for precision { // Aim camera's pitch; use floats for precision
fixedvec2 fv3 = tracer->_f_Vec2To(this); DVector2 vect = tracer->Vec2To(this);
DVector2 vect(fv3.x, fv3.y); double dz = Z() - tracer->Z() - tracer->Height/2;
double dz = _f_Z() - tracer->_f_Z() - tracer->_f_height()/2;
double dist = vect.Length(); double dist = vect.Length();
DAngle desiredPitch = dist != 0.f ? VecToAngle(dist, dz) : 0.; DAngle desiredPitch = dist != 0.f ? VecToAngle(dist, dz) : 0.;
DAngle diff = deltaangle(Angles.Pitch, desiredPitch); DAngle diff = deltaangle(Angles.Pitch, desiredPitch);

View File

@ -47,8 +47,8 @@
#include "farchive.h" #include "farchive.h"
#include "doomdata.h" #include "doomdata.h"
static fixed_t DecalWidth, DecalLeft, DecalRight; static double DecalWidth, DecalLeft, DecalRight;
static fixed_t SpreadZ; static double SpreadZ;
static const DBaseDecal *SpreadSource; static const DBaseDecal *SpreadSource;
static const FDecalTemplate *SpreadTemplate; static const FDecalTemplate *SpreadTemplate;
static TArray<side_t *> SpreadStack; static TArray<side_t *> SpreadStack;
@ -65,25 +65,25 @@ IMPLEMENT_CLASS (DImpactDecal)
DBaseDecal::DBaseDecal () DBaseDecal::DBaseDecal ()
: DThinker(STAT_DECAL), : DThinker(STAT_DECAL),
WallNext(0), WallPrev(0), LeftDistance(0), Z(0), ScaleX(FRACUNIT), ScaleY(FRACUNIT), Alpha(OPAQUE), WallNext(0), WallPrev(0), LeftDistance(0), Z(0), ScaleX(1.), ScaleY(1.), Alpha(1.),
AlphaColor(0), Translation(0), RenderFlags(0) AlphaColor(0), Translation(0), RenderFlags(0)
{ {
RenderStyle = STYLE_None; RenderStyle = STYLE_None;
PicNum.SetInvalid(); PicNum.SetInvalid();
} }
DBaseDecal::DBaseDecal (fixed_t z) DBaseDecal::DBaseDecal (double z)
: DThinker(STAT_DECAL), : DThinker(STAT_DECAL),
WallNext(0), WallPrev(0), LeftDistance(0), Z(z), ScaleX(FRACUNIT), ScaleY(FRACUNIT), Alpha(OPAQUE), WallNext(0), WallPrev(0), LeftDistance(0), Z(z), ScaleX(1.), ScaleY(1.), Alpha(1.),
AlphaColor(0), Translation(0), RenderFlags(0) AlphaColor(0), Translation(0), RenderFlags(0)
{ {
RenderStyle = STYLE_None; RenderStyle = STYLE_None;
PicNum.SetInvalid(); PicNum.SetInvalid();
} }
DBaseDecal::DBaseDecal (int statnum, fixed_t z) DBaseDecal::DBaseDecal (int statnum, double z)
: DThinker(statnum), : DThinker(statnum),
WallNext(0), WallPrev(0), LeftDistance(0), Z(z), ScaleX(FRACUNIT), ScaleY(FRACUNIT), Alpha(OPAQUE), WallNext(0), WallPrev(0), LeftDistance(0), Z(z), ScaleX(1.), ScaleY(1.), Alpha(1.),
AlphaColor(0), Translation(0), RenderFlags(0) AlphaColor(0), Translation(0), RenderFlags(0)
{ {
RenderStyle = STYLE_None; RenderStyle = STYLE_None;
@ -92,8 +92,8 @@ DBaseDecal::DBaseDecal (int statnum, fixed_t z)
DBaseDecal::DBaseDecal (const AActor *basis) DBaseDecal::DBaseDecal (const AActor *basis)
: DThinker(STAT_DECAL), : DThinker(STAT_DECAL),
WallNext(0), WallPrev(0), LeftDistance(0), Z(basis->_f_Z()), ScaleX(FLOAT2FIXED(basis->Scale.X)), ScaleY(FLOAT2FIXED(basis->Scale.Y)), WallNext(0), WallPrev(0), LeftDistance(0), Z(basis->Z()), ScaleX(basis->Scale.X), ScaleY(basis->Scale.Y),
Alpha(FLOAT2FIXED(basis->Alpha)), AlphaColor(basis->fillcolor), Translation(basis->Translation), PicNum(basis->picnum), Alpha(basis->Alpha), AlphaColor(basis->fillcolor), Translation(basis->Translation), PicNum(basis->picnum),
RenderFlags(basis->renderflags), RenderStyle(basis->RenderStyle) RenderFlags(basis->renderflags), RenderStyle(basis->RenderStyle)
{ {
} }
@ -101,7 +101,7 @@ DBaseDecal::DBaseDecal (const AActor *basis)
DBaseDecal::DBaseDecal (const DBaseDecal *basis) DBaseDecal::DBaseDecal (const DBaseDecal *basis)
: DThinker(STAT_DECAL), : DThinker(STAT_DECAL),
WallNext(0), WallPrev(0), LeftDistance(basis->LeftDistance), Z(basis->Z), ScaleX(basis->ScaleX), WallNext(0), WallPrev(0), LeftDistance(basis->LeftDistance), Z(basis->Z), ScaleX(basis->ScaleX),
ScaleY(basis->ScaleY), Alpha(basis->Alpha), AlphaColor(basis->AlphaColor), Translation(basis->Translation), ScaleY(basis->ScaleY), Alpha(basis->Alpha), AlphaColor(basis->AlphaColor), Translation(basis->Translation),
PicNum(basis->PicNum), RenderFlags(basis->RenderFlags), RenderStyle(basis->RenderStyle) PicNum(basis->PicNum), RenderFlags(basis->RenderFlags), RenderStyle(basis->RenderStyle)
{ {
} }
@ -174,7 +174,7 @@ void DBaseDecal::SerializeChain (FArchive &arc, DBaseDecal **first)
} }
} }
void DBaseDecal::GetXY (side_t *wall, fixed_t &ox, fixed_t &oy) const void DBaseDecal::GetXY (side_t *wall, double &ox, double &oy) const
{ {
line_t *line = wall->linedef; line_t *line = wall->linedef;
vertex_t *v1, *v2; vertex_t *v1, *v2;
@ -190,11 +190,11 @@ void DBaseDecal::GetXY (side_t *wall, fixed_t &ox, fixed_t &oy) const
v2 = line->v1; v2 = line->v1;
} }
fixed_t dx = v2->x - v1->x; double dx = v2->fX() - v1->fX();
fixed_t dy = v2->y - v1->y; double dy = v2->fY() - v1->fY();
ox = v1->x + MulScale30 (LeftDistance, dx); ox = v1->fX() + LeftDistance * dx;
oy = v1->y + MulScale30 (LeftDistance, dy); oy = v1->fY() + LeftDistance * dy;
} }
void DBaseDecal::SetShade (DWORD rgb) void DBaseDecal::SetShade (DWORD rgb)
@ -209,7 +209,7 @@ void DBaseDecal::SetShade (int r, int g, int b)
} }
// Returns the texture the decal stuck to. // Returns the texture the decal stuck to.
FTextureID DBaseDecal::StickToWall (side_t *wall, fixed_t x, fixed_t y, F3DFloor *ffloor) FTextureID DBaseDecal::StickToWall (side_t *wall, double x, double y, F3DFloor *ffloor)
{ {
// Stick the decal at the end of the chain so it appears on top // Stick the decal at the end of the chain so it appears on top
DBaseDecal *next, **prev; DBaseDecal *next, **prev;
@ -250,27 +250,27 @@ FTextureID DBaseDecal::StickToWall (side_t *wall, fixed_t x, fixed_t y, F3DFloor
{ {
RenderFlags |= RF_RELMID; RenderFlags |= RF_RELMID;
if (line->flags & ML_DONTPEGBOTTOM) if (line->flags & ML_DONTPEGBOTTOM)
Z -= front->GetPlaneTexZ(sector_t::floor); Z -= front->GetPlaneTexZF(sector_t::floor);
else else
Z -= front->GetPlaneTexZ(sector_t::ceiling); Z -= front->GetPlaneTexZF(sector_t::ceiling);
tex = wall->GetTexture(side_t::mid); tex = wall->GetTexture(side_t::mid);
} }
else if (back->floorplane.ZatPoint (x, y) >= Z) else if (back->floorplane.ZatPoint (x, y) >= Z)
{ {
RenderFlags |= RF_RELLOWER|RF_CLIPLOWER; RenderFlags |= RF_RELLOWER|RF_CLIPLOWER;
if (line->flags & ML_DONTPEGBOTTOM) if (line->flags & ML_DONTPEGBOTTOM)
Z -= front->GetPlaneTexZ(sector_t::ceiling); Z -= front->GetPlaneTexZF(sector_t::ceiling);
else else
Z -= back->GetPlaneTexZ(sector_t::floor); Z -= back->GetPlaneTexZF(sector_t::floor);
tex = wall->GetTexture(side_t::bottom); tex = wall->GetTexture(side_t::bottom);
} }
else if (back->ceilingplane.ZatPoint (x, y) <= Z) else if (back->ceilingplane.ZatPoint (x, y) <= Z)
{ {
RenderFlags |= RF_RELUPPER|RF_CLIPUPPER; RenderFlags |= RF_RELUPPER|RF_CLIPUPPER;
if (line->flags & ML_DONTPEGTOP) if (line->flags & ML_DONTPEGTOP)
Z -= front->GetPlaneTexZ(sector_t::ceiling); Z -= front->GetPlaneTexZF(sector_t::ceiling);
else else
Z -= back->GetPlaneTexZ(sector_t::ceiling); Z -= back->GetPlaneTexZF(sector_t::ceiling);
tex = wall->GetTexture(side_t::top); tex = wall->GetTexture(side_t::top);
} }
else if (ffloor) // this is a 3d-floor segment - do this only if we know which one! else if (ffloor) // this is a 3d-floor segment - do this only if we know which one!
@ -278,9 +278,9 @@ FTextureID DBaseDecal::StickToWall (side_t *wall, fixed_t x, fixed_t y, F3DFloor
Sector=ffloor->model; Sector=ffloor->model;
RenderFlags |= RF_RELMID|RF_CLIPMID; RenderFlags |= RF_RELMID|RF_CLIPMID;
if (line->flags & ML_DONTPEGBOTTOM) if (line->flags & ML_DONTPEGBOTTOM)
Z -= Sector->GetPlaneTexZ(sector_t::floor); Z -= Sector->GetPlaneTexZF(sector_t::floor);
else else
Z -= Sector->GetPlaneTexZ(sector_t::ceiling); Z -= Sector->GetPlaneTexZF(sector_t::ceiling);
if (ffloor->flags & FF_UPPERTEXTURE) if (ffloor->flags & FF_UPPERTEXTURE)
{ {
@ -308,7 +308,7 @@ FTextureID DBaseDecal::StickToWall (side_t *wall, fixed_t x, fixed_t y, F3DFloor
return tex; return tex;
} }
fixed_t DBaseDecal::GetRealZ (const side_t *wall) const double DBaseDecal::GetRealZ (const side_t *wall) const
{ {
const line_t *line = wall->linedef; const line_t *line = wall->linedef;
const sector_t *front, *back; const sector_t *front, *back;
@ -335,34 +335,34 @@ fixed_t DBaseDecal::GetRealZ (const side_t *wall) const
case RF_RELUPPER: case RF_RELUPPER:
if (line->flags & ML_DONTPEGTOP) if (line->flags & ML_DONTPEGTOP)
{ {
return Z + front->GetPlaneTexZ(sector_t::ceiling); return Z + front->GetPlaneTexZF(sector_t::ceiling);
} }
else else
{ {
return Z + back->GetPlaneTexZ(sector_t::ceiling); return Z + back->GetPlaneTexZF(sector_t::ceiling);
} }
case RF_RELLOWER: case RF_RELLOWER:
if (line->flags & ML_DONTPEGBOTTOM) if (line->flags & ML_DONTPEGBOTTOM)
{ {
return Z + front->GetPlaneTexZ(sector_t::ceiling); return Z + front->GetPlaneTexZF(sector_t::ceiling);
} }
else else
{ {
return Z + back->GetPlaneTexZ(sector_t::floor); return Z + back->GetPlaneTexZF(sector_t::floor);
} }
case RF_RELMID: case RF_RELMID:
if (line->flags & ML_DONTPEGBOTTOM) if (line->flags & ML_DONTPEGBOTTOM)
{ {
return Z + front->GetPlaneTexZ(sector_t::floor); return Z + front->GetPlaneTexZF(sector_t::floor);
} }
else else
{ {
return Z + front->GetPlaneTexZ(sector_t::ceiling); return Z + front->GetPlaneTexZF(sector_t::ceiling);
} }
} }
} }
void DBaseDecal::CalcFracPos (side_t *wall, fixed_t x, fixed_t y) void DBaseDecal::CalcFracPos (side_t *wall, double x, double y)
{ {
line_t *line = wall->linedef; line_t *line = wall->linedef;
vertex_t *v1, *v2; vertex_t *v1, *v2;
@ -378,16 +378,16 @@ void DBaseDecal::CalcFracPos (side_t *wall, fixed_t x, fixed_t y)
v2 = line->v1; v2 = line->v1;
} }
fixed_t dx = v2->x - v1->x; double dx = v2->fX() - v1->fX();
fixed_t dy = v2->y - v1->y; double dy = v2->fY() - v1->fY();
if (abs(dx) > abs(dy)) if (fabs(dx) > fabs(dy))
{ {
LeftDistance = SafeDivScale30 (x - v1->x, dx); LeftDistance = (x - v1->fX()) / dx;
} }
else if (dy != 0) else if (dy != 0)
{ {
LeftDistance = SafeDivScale30 (y - v1->y, dy); LeftDistance = (y - v1->fY()) / dy;
} }
else else
{ {
@ -395,26 +395,26 @@ void DBaseDecal::CalcFracPos (side_t *wall, fixed_t x, fixed_t y)
} }
} }
static void GetWallStuff (side_t *wall, vertex_t *&v1, fixed_t &ldx, fixed_t &ldy) static void GetWallStuff (side_t *wall, vertex_t *&v1, double &ldx, double &ldy)
{ {
line_t *line = wall->linedef; line_t *line = wall->linedef;
if (line->sidedef[0] == wall) if (line->sidedef[0] == wall)
{ {
v1 = line->v1; v1 = line->v1;
ldx = line->dx; ldx = line->Delta().X;
ldy = line->dy; ldy = line->Delta().Y;
} }
else else
{ {
v1 = line->v2; v1 = line->v2;
ldx = -line->dx; ldx = -line->Delta().X;
ldy = -line->dy; ldy = -line->Delta().Y;
} }
} }
static fixed_t Length (fixed_t dx, fixed_t dy) static double Length (double dx, double dy)
{ {
return (fixed_t)g_sqrt ((double)dx*(double)dx+(double)dy*(double)dy); return DVector2(dx, dy).Length();
} }
static side_t *NextWall (const side_t *wall) static side_t *NextWall (const side_t *wall)
@ -435,25 +435,25 @@ static side_t *NextWall (const side_t *wall)
return NULL; return NULL;
} }
void DBaseDecal::SpreadLeft (fixed_t r, vertex_t *v1, side_t *feelwall, F3DFloor *ffloor) void DBaseDecal::SpreadLeft (double r, vertex_t *v1, side_t *feelwall, F3DFloor *ffloor)
{ {
fixed_t ldx, ldy; double ldx, ldy;
SpreadStack.Push (feelwall); SpreadStack.Push (feelwall);
while (r < 0 && feelwall->LeftSide != NO_SIDE) while (r < 0 && feelwall->LeftSide != NO_SIDE)
{ {
fixed_t startr = r; double startr = r;
fixed_t x = v1->x; double x = v1->fX();
fixed_t y = v1->y; double y = v1->fY();
feelwall = &sides[feelwall->LeftSide]; feelwall = &sides[feelwall->LeftSide];
GetWallStuff (feelwall, v1, ldx, ldy); GetWallStuff (feelwall, v1, ldx, ldy);
fixed_t wallsize = Length (ldx, ldy); double wallsize = Length (ldx, ldy);
r += DecalLeft; r += DecalLeft;
x += Scale (r, ldx, wallsize); x += r*ldx / wallsize;
y += Scale (r, ldy, wallsize); y += r*ldy / wallsize;
r = wallsize + startr; r = wallsize + startr;
SpreadSource->CloneSelf (SpreadTemplate, x, y, SpreadZ, feelwall, ffloor); SpreadSource->CloneSelf (SpreadTemplate, x, y, SpreadZ, feelwall, ffloor);
SpreadStack.Push (feelwall); SpreadStack.Push (feelwall);
@ -479,10 +479,10 @@ void DBaseDecal::SpreadLeft (fixed_t r, vertex_t *v1, side_t *feelwall, F3DFloor
} }
} }
void DBaseDecal::SpreadRight (fixed_t r, side_t *feelwall, fixed_t wallsize, F3DFloor *ffloor) void DBaseDecal::SpreadRight (double r, side_t *feelwall, double wallsize, F3DFloor *ffloor)
{ {
vertex_t *v1; vertex_t *v1;
fixed_t x, y, ldx, ldy; double x, y, ldx, ldy;
SpreadStack.Push (feelwall); SpreadStack.Push (feelwall);
@ -508,25 +508,25 @@ void DBaseDecal::SpreadRight (fixed_t r, side_t *feelwall, fixed_t wallsize, F3D
r = DecalWidth - r + wallsize - DecalLeft; r = DecalWidth - r + wallsize - DecalLeft;
GetWallStuff (feelwall, v1, ldx, ldy); GetWallStuff (feelwall, v1, ldx, ldy);
x = v1->x; x = v1->fX();
y = v1->y; y = v1->fY();
wallsize = Length (ldx, ldy); wallsize = Length (ldx, ldy);
x -= Scale (r, ldx, wallsize); x -= r*ldx / wallsize;
y -= Scale (r, ldy, wallsize); y -= r*ldy / wallsize;
r = DecalRight - r; r = DecalRight - r;
SpreadSource->CloneSelf (SpreadTemplate, x, y, SpreadZ, feelwall, ffloor); SpreadSource->CloneSelf (SpreadTemplate, x, y, SpreadZ, feelwall, ffloor);
SpreadStack.Push (feelwall); SpreadStack.Push (feelwall);
} }
} }
void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, fixed_t x, fixed_t y, fixed_t z, F3DFloor * ffloor) void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, double x, double y, double z, F3DFloor * ffloor)
{ {
FTexture *tex; FTexture *tex;
vertex_t *v1; vertex_t *v1;
fixed_t rorg, ldx, ldy; double rorg, ldx, ldy;
GetWallStuff (wall, v1, ldx, ldy); GetWallStuff (wall, v1, ldx, ldy);
rorg = Length (x - v1->x, y - v1->y); rorg = Length (x - v1->fX(), y - v1->fY());
if ((tex = TexMan[PicNum]) == NULL) if ((tex = TexMan[PicNum]) == NULL)
{ {
@ -548,11 +548,11 @@ void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, fixed_t x, fix
// Then try spreading right // Then try spreading right
SpreadRight (rorg + DecalRight, wall, SpreadRight (rorg + DecalRight, wall,
Length (wall->linedef->dx, wall->linedef->dy), ffloor); Length (wall->linedef->Delta().X, wall->linedef->Delta().Y), ffloor);
SpreadStack.Clear (); SpreadStack.Clear ();
} }
DBaseDecal *DBaseDecal::CloneSelf (const FDecalTemplate *tpl, fixed_t ix, fixed_t iy, fixed_t iz, side_t *wall, F3DFloor * ffloor) const DBaseDecal *DBaseDecal::CloneSelf (const FDecalTemplate *tpl, double ix, double iy, double iz, side_t *wall, F3DFloor * ffloor) const
{ {
DBaseDecal *decal = new DBaseDecal(iz); DBaseDecal *decal = new DBaseDecal(iz);
if (decal != NULL) if (decal != NULL)
@ -615,12 +615,12 @@ void DImpactDecal::Serialize (FArchive &arc)
} }
DImpactDecal::DImpactDecal () DImpactDecal::DImpactDecal ()
: DBaseDecal (STAT_AUTODECAL, 0) : DBaseDecal (STAT_AUTODECAL, 0.)
{ {
ImpactCount++; ImpactCount++;
} }
DImpactDecal::DImpactDecal (fixed_t z) DImpactDecal::DImpactDecal (double z)
: DBaseDecal (STAT_AUTODECAL, z) : DBaseDecal (STAT_AUTODECAL, z)
{ {
ImpactCount++; ImpactCount++;
@ -638,7 +638,7 @@ void DImpactDecal::CheckMax ()
} }
} }
DImpactDecal *DImpactDecal::StaticCreate (const char *name, const fixedvec3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color) DImpactDecal *DImpactDecal::StaticCreate (const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color)
{ {
if (cl_maxdecals > 0) if (cl_maxdecals > 0)
{ {
@ -652,7 +652,7 @@ DImpactDecal *DImpactDecal::StaticCreate (const char *name, const fixedvec3 &pos
return NULL; return NULL;
} }
DImpactDecal *DImpactDecal::StaticCreate (const FDecalTemplate *tpl, const fixedvec3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color) DImpactDecal *DImpactDecal::StaticCreate (const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color)
{ {
DImpactDecal *decal = NULL; DImpactDecal *decal = NULL;
if (tpl != NULL && cl_maxdecals > 0 && !(wall->Flags & WALLF_NOAUTODECALS)) if (tpl != NULL && cl_maxdecals > 0 && !(wall->Flags & WALLF_NOAUTODECALS))
@ -669,13 +669,13 @@ DImpactDecal *DImpactDecal::StaticCreate (const FDecalTemplate *tpl, const fixed
StaticCreate (tpl_low, pos, wall, ffloor, lowercolor); StaticCreate (tpl_low, pos, wall, ffloor, lowercolor);
} }
DImpactDecal::CheckMax(); DImpactDecal::CheckMax();
decal = new DImpactDecal (pos.z); decal = new DImpactDecal (pos.Z);
if (decal == NULL) if (decal == NULL)
{ {
return NULL; return NULL;
} }
if (!decal->StickToWall (wall, pos.x, pos.y, ffloor).isValid()) if (!decal->StickToWall (wall, pos.X, pos.Y, ffloor).isValid())
{ {
return NULL; return NULL;
} }
@ -692,12 +692,12 @@ DImpactDecal *DImpactDecal::StaticCreate (const FDecalTemplate *tpl, const fixed
} }
// Spread decal to nearby walls if it does not all fit on this one // Spread decal to nearby walls if it does not all fit on this one
decal->Spread (tpl, wall, pos.x, pos.y, pos.z, ffloor); decal->Spread (tpl, wall, pos.X, pos.Y, pos.Z, ffloor);
} }
return decal; return decal;
} }
DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, fixed_t ix, fixed_t iy, fixed_t iz, side_t *wall, F3DFloor * ffloor) const DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, double ix, double iy, double iz, side_t *wall, F3DFloor * ffloor) const
{ {
if (wall->Flags & WALLF_NOAUTODECALS) if (wall->Flags & WALLF_NOAUTODECALS)
{ {
@ -758,7 +758,7 @@ CCMD (spray)
Net_WriteString (argv[1]); Net_WriteString (argv[1]);
} }
DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t *sec, fixed_t x, fixed_t y, fixed_t z, angle_t angle, fixed_t tracedist, bool permanent) DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t *sec, double x, double y, double z, DAngle angle, double tracedist, bool permanent)
{ {
if (tpl == NULL || (tpl = tpl->GetDecal()) == NULL) if (tpl == NULL || (tpl = tpl->GetDecal()) == NULL)
{ {
@ -769,30 +769,28 @@ DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t *
DBaseDecal *decal; DBaseDecal *decal;
side_t *wall; side_t *wall;
angle >>= ANGLETOFINESHIFT; Trace(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), sec,
FLOAT2FIXED(angle.Cos()), FLOAT2FIXED(angle.Sin()), 0,
Trace(x, y, z, sec, FLOAT2FIXED(tracedist), 0, 0, NULL, trace, TRACE_NoSky);
finecosine[angle], finesine[angle], 0,
tracedist, 0, 0, NULL, trace, TRACE_NoSky);
if (trace.HitType == TRACE_HitWall) if (trace.HitType == TRACE_HitWall)
{ {
if (permanent) if (permanent)
{ {
decal = new DBaseDecal(trace.HitPos.z); decal = new DBaseDecal(FIXED2DBL(trace.HitPos.z));
wall = trace.Line->sidedef[trace.Side]; wall = trace.Line->sidedef[trace.Side];
decal->StickToWall(wall, trace.HitPos.x, trace.HitPos.y, trace.ffloor); decal->StickToWall(wall, FIXED2DBL(trace.HitPos.x), FIXED2DBL(trace.HitPos.y), trace.ffloor);
tpl->ApplyToDecal(decal, wall); tpl->ApplyToDecal(decal, wall);
// Spread decal to nearby walls if it does not all fit on this one // Spread decal to nearby walls if it does not all fit on this one
if (cl_spreaddecals) if (cl_spreaddecals)
{ {
decal->Spread(tpl, wall, trace.HitPos.x, trace.HitPos.y, trace.HitPos.z, trace.ffloor); decal->Spread(tpl, wall, FIXED2DBL(trace.HitPos.x), FIXED2DBL(trace.HitPos.y), FIXED2DBL(trace.HitPos.z), trace.ffloor);
} }
return decal; return decal;
} }
else else
{ {
return DImpactDecal::StaticCreate(tpl, trace.HitPos, trace.Line->sidedef[trace.Side], NULL); return DImpactDecal::StaticCreate(tpl, DVector3(FIXED2DBL(trace.HitPos.x), FIXED2DBL(trace.HitPos.y), FIXED2DBL(trace.HitPos.z)), trace.Line->sidedef[trace.Side], NULL);
} }
} }
return NULL; return NULL;
@ -827,7 +825,7 @@ void ADecal::BeginPlay ()
// Look for a wall within 64 units behind the actor. If none can be // Look for a wall within 64 units behind the actor. If none can be
// found, then no decal is created, and this actor is destroyed // found, then no decal is created, and this actor is destroyed
// without effectively doing anything. // without effectively doing anything.
if (NULL == ShootDecal(tpl, this, Sector, _f_X(), _f_Y(), _f_Z(), FLOAT2ANGLE(Angles.Yaw.Degrees) + ANGLE_180, 64*FRACUNIT, true)) if (NULL == ShootDecal(tpl, this, Sector, X(), Y(), Z(), Angles.Yaw + 180, 64., true))
{ {
DPrintf ("Could not find a wall to stick decal to at (%f,%f)\n", X(), Y()); DPrintf ("Could not find a wall to stick decal to at (%f,%f)\n", X(), Y());
} }

View File

@ -8,9 +8,10 @@ class FDecalTemplate;
struct vertex_t; struct vertex_t;
struct side_t; struct side_t;
struct F3DFloor; struct F3DFloor;
class DBaseDecal;
void P_SpawnDirt (AActor *actor, double radius); void P_SpawnDirt (AActor *actor, double radius);
class DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t *sec, fixed_t x, fixed_t y, fixed_t z, angle_t angle, fixed_t tracedist, bool permanent); class DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t *sec, double x, double y, double z, DAngle angle, double tracedist, bool permanent);
class DBaseDecal : public DThinker class DBaseDecal : public DThinker
{ {
@ -18,28 +19,28 @@ class DBaseDecal : public DThinker
HAS_OBJECT_POINTERS HAS_OBJECT_POINTERS
public: public:
DBaseDecal (); DBaseDecal ();
DBaseDecal (fixed_t z); DBaseDecal(double z);
DBaseDecal (int statnum, fixed_t z); DBaseDecal(int statnum, double z);
DBaseDecal (const AActor *actor); DBaseDecal (const AActor *actor);
DBaseDecal (const DBaseDecal *basis); DBaseDecal (const DBaseDecal *basis);
void Serialize (FArchive &arc); void Serialize (FArchive &arc);
void Destroy (); void Destroy ();
FTextureID StickToWall (side_t *wall, fixed_t x, fixed_t y, F3DFloor * ffloor); FTextureID StickToWall(side_t *wall, double x, double y, F3DFloor * ffloor);
fixed_t GetRealZ (const side_t *wall) const; double GetRealZ (const side_t *wall) const;
void SetShade (DWORD rgb); void SetShade (DWORD rgb);
void SetShade (int r, int g, int b); void SetShade (int r, int g, int b);
void Spread (const FDecalTemplate *tpl, side_t *wall, fixed_t x, fixed_t y, fixed_t z, F3DFloor * ffloor); void Spread (const FDecalTemplate *tpl, side_t *wall, double x, double y, double z, F3DFloor * ffloor);
void GetXY (side_t *side, fixed_t &x, fixed_t &y) const; void GetXY (side_t *side, double &x, double &y) const;
static void SerializeChain (FArchive &arc, DBaseDecal **firstptr); static void SerializeChain (FArchive &arc, DBaseDecal **firstptr);
DBaseDecal *WallNext, **WallPrev; DBaseDecal *WallNext, **WallPrev;
fixed_t LeftDistance; double LeftDistance;
fixed_t Z; double Z;
fixed_t ScaleX, ScaleY; double ScaleX, ScaleY;
fixed_t Alpha; double Alpha;
DWORD AlphaColor; DWORD AlphaColor;
int Translation; int Translation;
FTextureID PicNum; FTextureID PicNum;
@ -48,23 +49,23 @@ public:
sector_t * Sector; // required for 3D floors sector_t * Sector; // required for 3D floors
protected: protected:
virtual DBaseDecal *CloneSelf (const FDecalTemplate *tpl, fixed_t x, fixed_t y, fixed_t z, side_t *wall, F3DFloor * ffloor) const; virtual DBaseDecal *CloneSelf(const FDecalTemplate *tpl, double x, double y, double z, side_t *wall, F3DFloor * ffloor) const;
void CalcFracPos (side_t *wall, fixed_t x, fixed_t y); void CalcFracPos(side_t *wall, double x, double y);
void Remove (); void Remove ();
static void SpreadLeft (fixed_t r, vertex_t *v1, side_t *feelwall, F3DFloor *ffloor); static void SpreadLeft (double r, vertex_t *v1, side_t *feelwall, F3DFloor *ffloor);
static void SpreadRight (fixed_t r, side_t *feelwall, fixed_t wallsize, F3DFloor *ffloor); static void SpreadRight (double r, side_t *feelwall, double wallsize, F3DFloor *ffloor);
}; };
class DImpactDecal : public DBaseDecal class DImpactDecal : public DBaseDecal
{ {
DECLARE_CLASS (DImpactDecal, DBaseDecal) DECLARE_CLASS (DImpactDecal, DBaseDecal)
public: public:
DImpactDecal (fixed_t z); DImpactDecal(double z);
DImpactDecal (side_t *wall, const FDecalTemplate *templ); DImpactDecal (side_t *wall, const FDecalTemplate *templ);
static DImpactDecal *StaticCreate (const char *name, const fixedvec3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color=0); static DImpactDecal *StaticCreate(const char *name, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0);
static DImpactDecal *StaticCreate (const FDecalTemplate *tpl, const fixedvec3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color=0); static DImpactDecal *StaticCreate(const FDecalTemplate *tpl, const DVector3 &pos, side_t *wall, F3DFloor * ffloor, PalEntry color = 0);
void BeginPlay (); void BeginPlay ();
void Destroy (); void Destroy ();
@ -73,7 +74,7 @@ public:
static void SerializeTime (FArchive &arc); static void SerializeTime (FArchive &arc);
protected: protected:
DBaseDecal *CloneSelf (const FDecalTemplate *tpl, fixed_t x, fixed_t y, fixed_t z, side_t *wall, F3DFloor * ffloor) const; DBaseDecal *CloneSelf(const FDecalTemplate *tpl, double x, double y, double z, side_t *wall, F3DFloor * ffloor) const;
static void CheckMax (); static void CheckMax ();
private: private:

View File

@ -4768,9 +4768,9 @@ static bool DoSpawnDecal(AActor *actor, const FDecalTemplate *tpl, int flags, an
{ {
angle += actor->_f_angle(); angle += actor->_f_angle();
} }
return NULL != ShootDecal(tpl, actor, actor->Sector, actor->_f_X(), actor->_f_Y(), return NULL != ShootDecal(tpl, actor, actor->Sector, actor->X(), actor->Y(),
actor->_f_Z() + (actor->_f_height()>>1) - actor->_f_floorclip() + actor->GetBobOffset() + zofs, actor->Center() - actor->Floorclip + actor->GetBobOffset() + FIXED2DBL(zofs),
angle, distance, !!(flags & SDF_PERMANENT)); DAngle(ANGLE2DBL(angle)), FIXED2DBL(distance), !!(flags & SDF_PERMANENT));
} }
static void SetActorAngle(AActor *activator, int tid, int angle, bool interpolate) static void SetActorAngle(AActor *activator, int tid, int angle, bool interpolate)

View File

@ -4540,7 +4540,8 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an
bloodcolor.a = 1; bloodcolor.a = 1;
} }
DImpactDecal::StaticCreate(bloodType, bleedtrace.HitPos, DVector3 hp(FIXED2DBL(bleedtrace.HitPos.x), FIXED2DBL(bleedtrace.HitPos.y), FIXED2DBL(bleedtrace.HitPos.z));
DImpactDecal::StaticCreate(bloodType, hp,
bleedtrace.Line->sidedef[bleedtrace.Side], bleedtrace.ffloor, bloodcolor); bleedtrace.Line->sidedef[bleedtrace.Side], bleedtrace.ffloor, bloodcolor);
} }
} }
@ -6418,8 +6419,9 @@ void SpawnShootDecal(AActor *t1, const FTraceResults &trace)
} }
if (decalbase != NULL) if (decalbase != NULL)
{ {
DVector3 hp(FIXED2DBL(trace.HitPos.x), FIXED2DBL(trace.HitPos.y), FIXED2DBL(trace.HitPos.z));
DImpactDecal::StaticCreate(decalbase->GetDecal(), DImpactDecal::StaticCreate(decalbase->GetDecal(),
trace.HitPos, trace.Line->sidedef[trace.Side], trace.ffloor); hp, trace.Line->sidedef[trace.Side], trace.ffloor);
} }
} }

View File

@ -1445,7 +1445,7 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target)
} }
} }
DImpactDecal::StaticCreate(base->GetDecal(), { x, y, z }, line->sidedef[side], ffloor); DImpactDecal::StaticCreate(base->GetDecal(), DVector3(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)), line->sidedef[side], ffloor);
} }
} }
} }

View File

@ -95,6 +95,16 @@ struct vertex_t
{ {
fixed_t x, y; fixed_t x, y;
double fX() const
{
return FIXED2DBL(x);
}
double fY() const
{
return FIXED2DBL(y);
}
bool operator== (const vertex_t &other) bool operator== (const vertex_t &other)
{ {
return x == other.x && y == other.y; return x == other.x && y == other.y;
@ -724,6 +734,11 @@ struct sector_t
return planes[pos].TexZ; return planes[pos].TexZ;
} }
double GetPlaneTexZF(int pos) const
{
return FIXED2DBL(planes[pos].TexZ);
}
void SetPlaneTexZ(int pos, fixed_t val) void SetPlaneTexZ(int pos, fixed_t val)
{ {
planes[pos].TexZ = val; planes[pos].TexZ = val;

View File

@ -3022,7 +3022,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
fixed_t xscale, yscale; fixed_t xscale, yscale;
fixed_t topoff; fixed_t topoff;
BYTE flipx; BYTE flipx;
fixed_t zpos; double zpos;
int needrepeat = 0; int needrepeat = 0;
sector_t *front, *back; sector_t *front, *back;
bool calclighting; bool calclighting;
@ -3044,36 +3044,36 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
case RF_RELUPPER: case RF_RELUPPER:
if (curline->linedef->flags & ML_DONTPEGTOP) if (curline->linedef->flags & ML_DONTPEGTOP)
{ {
zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling); zpos = decal->Z + front->GetPlaneTexZF(sector_t::ceiling);
} }
else else
{ {
zpos = decal->Z + back->GetPlaneTexZ(sector_t::ceiling); zpos = decal->Z + back->GetPlaneTexZF(sector_t::ceiling);
} }
break; break;
case RF_RELLOWER: case RF_RELLOWER:
if (curline->linedef->flags & ML_DONTPEGBOTTOM) if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{ {
zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling); zpos = decal->Z + front->GetPlaneTexZF(sector_t::ceiling);
} }
else else
{ {
zpos = decal->Z + back->GetPlaneTexZ(sector_t::floor); zpos = decal->Z + back->GetPlaneTexZF(sector_t::floor);
} }
break; break;
case RF_RELMID: case RF_RELMID:
if (curline->linedef->flags & ML_DONTPEGBOTTOM) if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{ {
zpos = decal->Z + front->GetPlaneTexZ(sector_t::floor); zpos = decal->Z + front->GetPlaneTexZF(sector_t::floor);
} }
else else
{ {
zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling); zpos = decal->Z + front->GetPlaneTexZF(sector_t::ceiling);
} }
} }
xscale = decal->ScaleX; xscale = FLOAT2FIXED(decal->ScaleX);
yscale = decal->ScaleY; yscale = FLOAT2FIXED(decal->ScaleY);
WallSpriteTile = TexMan(decal->PicNum, true); WallSpriteTile = TexMan(decal->PicNum, true);
flipx = (BYTE)(decal->RenderFlags & RF_XFLIP); flipx = (BYTE)(decal->RenderFlags & RF_XFLIP);
@ -3096,7 +3096,10 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
x1 *= xscale; x1 *= xscale;
x2 *= xscale; x2 *= xscale;
decal->GetXY (wall, decalx, decaly); double dcx, dcy;
decal->GetXY(wall, dcx, dcy);
decalx = FLOAT2FIXED(dcx);
decaly = FLOAT2FIXED(dcy);
angle_t ang = R_PointToAngle2 (curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y) >> ANGLETOFINESHIFT; angle_t ang = R_PointToAngle2 (curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y) >> ANGLETOFINESHIFT;
lx = decalx - FixedMul (x1, finecosine[ang]) - viewx; lx = decalx - FixedMul (x1, finecosine[ang]) - viewx;
@ -3169,8 +3172,9 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
break; break;
} }
fixed_t fzpos = FLOAT2FIXED(zpos);
topoff = WallSpriteTile->TopOffset << FRACBITS; topoff = WallSpriteTile->TopOffset << FRACBITS;
dc_texturemid = topoff + FixedDiv (zpos - viewz, yscale); dc_texturemid = topoff + FixedDiv (fzpos - viewz, yscale);
// Clip sprite to drawseg // Clip sprite to drawseg
x1 = MAX<int>(clipper->x1, x1); x1 = MAX<int>(clipper->x1, x1);
@ -3235,7 +3239,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper,
dc_x = x1; dc_x = x1;
ESPSResult mode; ESPSResult mode;
mode = R_SetPatchStyle (decal->RenderStyle, decal->Alpha, decal->Translation, decal->AlphaColor); mode = R_SetPatchStyle (decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor);
// R_SetPatchStyle can modify basecolormap. // R_SetPatchStyle can modify basecolormap.
if (rereadcolormap) if (rereadcolormap)