From 86d1b2955a77b649bb366671bda87724957c9bb9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 14:10:06 +0100 Subject: [PATCH 1/3] - floatified most of r_data (The interpolations cannot be done yet.) --- src/r_data/r_translate.cpp | 33 +++++++++++++++---------------- src/r_data/renderstyle.cpp | 40 +++++++++++++------------------------- src/r_data/renderstyle.h | 2 -- src/r_data/voxels.cpp | 26 ++++++++++++------------- src/r_data/voxels.h | 8 +++----- src/r_draw.cpp | 12 ++++++++++++ src/r_things.cpp | 25 ++++++++++++++---------- 7 files changed, 71 insertions(+), 75 deletions(-) diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index 3cea74cf2..37a3fb854 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -310,7 +310,7 @@ FNativePalette *FRemapTable::GetNative() void FRemapTable::AddIndexRange(int start, int end, int pal1, int pal2) { - fixed_t palcol, palstep; + double palcol, palstep; if (start > end) { @@ -326,11 +326,11 @@ void FRemapTable::AddIndexRange(int start, int end, int pal1, int pal2) Palette[start].a = start == 0 ? 0 : 255; return; } - palcol = pal1 << FRACBITS; - palstep = ((pal2 << FRACBITS) - palcol) / (end - start); + palcol = pal1; + palstep = (pal2 - palcol) / (end - start); for (int i = start; i <= end; palcol += palstep, ++i) { - int j = GPalette.Remap[i], k = GPalette.Remap[palcol >> FRACBITS]; + int j = GPalette.Remap[i], k = GPalette.Remap[int(palcol)]; Remap[j] = k; Palette[j] = GPalette.BaseColors[k]; Palette[j].a = j == 0 ? 0 : 255; @@ -345,14 +345,14 @@ void FRemapTable::AddIndexRange(int start, int end, int pal1, int pal2) void FRemapTable::AddColorRange(int start, int end, int _r1,int _g1, int _b1, int _r2, int _g2, int _b2) { - fixed_t r1 = _r1 << FRACBITS; - fixed_t g1 = _g1 << FRACBITS; - fixed_t b1 = _b1 << FRACBITS; - fixed_t r2 = _r2 << FRACBITS; - fixed_t g2 = _g2 << FRACBITS; - fixed_t b2 = _b2 << FRACBITS; - fixed_t r, g, b; - fixed_t rs, gs, bs; + double r1 = _r1; + double g1 = _g1; + double b1 = _b1; + double r2 = _r2; + double g2 = _g2; + double b2 = _b2; + double r, g, b; + double rs, gs, bs; if (start > end) { @@ -376,9 +376,8 @@ void FRemapTable::AddColorRange(int start, int end, int _r1,int _g1, int _b1, in if (start == end) { start = GPalette.Remap[start]; - Remap[start] = ColorMatcher.Pick(r >> FRACBITS, g >> FRACBITS, b >> FRACBITS); - Palette[start] = PalEntry(r >> FRACBITS, g >> FRACBITS, b >> FRACBITS); - Palette[start].a = start == 0 ? 0 : 255; + Palette[start] = PalEntry(start == 0 ? 0 : 255, int(r), int(g), int(b)); + Remap[start] = ColorMatcher.Pick(Palette[start]); } else { @@ -388,8 +387,8 @@ void FRemapTable::AddColorRange(int start, int end, int _r1,int _g1, int _b1, in for (int i = start; i <= end; ++i) { int j = GPalette.Remap[i]; - Remap[j] = ColorMatcher.Pick(r >> FRACBITS, g >> FRACBITS, b >> FRACBITS); - Palette[j] = PalEntry(j == 0 ? 0 : 255, r >> FRACBITS, g >> FRACBITS, b >> FRACBITS); + Palette[j] = PalEntry(j == 0 ? 0 : 255, int(r), int(g), int(b)); + Remap[j] = ColorMatcher.Pick(Palette[j]); r += rs; g += gs; b += bs; diff --git a/src/r_data/renderstyle.cpp b/src/r_data/renderstyle.cpp index 5ddb58a27..fdd20aa17 100644 --- a/src/r_data/renderstyle.cpp +++ b/src/r_data/renderstyle.cpp @@ -105,6 +105,18 @@ FArchive &operator<< (FArchive &arc, FRenderStyle &style) return arc; } +double GetAlpha(int type, double alpha) +{ + switch (type) + { + case STYLEALPHA_Zero: return 0; + case STYLEALPHA_One: return OPAQUE; + case STYLEALPHA_Src: return alpha; + case STYLEALPHA_InvSrc: return 1. - alpha; + default: return 0; + } +} + //========================================================================== // // FRenderStyle :: IsVisible @@ -130,7 +142,7 @@ bool FRenderStyle::IsVisible(double alpha) const throw() { alpha = clamp(alpha, 0., 1.); } - return GetAlpha(SrcAlpha, alpha) != 0 || GetAlpha(DestAlpha, alpha) != OPAQUE; + return GetAlpha(SrcAlpha, alpha) != 0 || GetAlpha(DestAlpha, alpha) != 1; } // Treat anything else as visible. return true; @@ -186,29 +198,3 @@ void FRenderStyle::CheckFuzz() BlendOp = STYLEOP_Fuzz; } } - -fixed_t GetAlpha(int type, fixed_t alpha) -{ - switch (type) - { - case STYLEALPHA_Zero: return 0; - case STYLEALPHA_One: return OPAQUE; - case STYLEALPHA_Src: return alpha; - case STYLEALPHA_InvSrc: return OPAQUE - alpha; - default: return 0; - } -} - -fixed_t GetAlpha(int type, double alpha) -{ - switch (type) - { - case STYLEALPHA_Zero: return 0; - case STYLEALPHA_One: return OPAQUE; - case STYLEALPHA_Src: return FLOAT2FIXED(alpha); - case STYLEALPHA_InvSrc: return FLOAT2FIXED(1. - alpha); - default: return 0; - } -} - - diff --git a/src/r_data/renderstyle.h b/src/r_data/renderstyle.h index e453efd6c..c103610ef 100644 --- a/src/r_data/renderstyle.h +++ b/src/r_data/renderstyle.h @@ -165,7 +165,5 @@ inline FRenderStyle &FRenderStyle::operator= (ERenderStyle legacy) class FArchive; FArchive &operator<< (FArchive &arc, FRenderStyle &style); -fixed_t GetAlpha(int type, fixed_t alpha); -fixed_t GetAlpha(int type, double alpha); #endif diff --git a/src/r_data/voxels.cpp b/src/r_data/voxels.cpp index 48a5744ba..8ca6d4f5f 100644 --- a/src/r_data/voxels.cpp +++ b/src/r_data/voxels.cpp @@ -71,13 +71,13 @@ TDeletingArray VoxelDefs; struct VoxelOptions { VoxelOptions() - : DroppedSpin(0), PlacedSpin(0), Scale(FRACUNIT), AngleOffset(ANGLE_90), OverridePalette(false) + : DroppedSpin(0), PlacedSpin(0), Scale(1.), AngleOffset(90.), OverridePalette(false) {} int DroppedSpin; int PlacedSpin; - fixed_t Scale; - angle_t AngleOffset; + double Scale; + DAngle AngleOffset; bool OverridePalette; }; @@ -213,9 +213,9 @@ FVoxel *R_LoadKVX(int lumpnum) mipl->SizeX = GetInt(rawmip + 0); mipl->SizeY = GetInt(rawmip + 4); mipl->SizeZ = GetInt(rawmip + 8); - mipl->PivotX = GetInt(rawmip + 12); - mipl->PivotY = GetInt(rawmip + 16); - mipl->PivotZ = GetInt(rawmip + 20); + mipl->Pivot.X = GetInt(rawmip + 12) / 256.; + mipl->Pivot.Y = GetInt(rawmip + 16) / 256.; + mipl->Pivot.Z = GetInt(rawmip + 20) / 256.; // How much space do we have for voxdata? int offsetsize = (mipl->SizeX + 1) * 4 + mipl->SizeX * (mipl->SizeY + 1) * 2; @@ -300,9 +300,7 @@ FVoxel *R_LoadKVX(int lumpnum) // Fix pivot data for submips, since some tools seem to like to just center these. for (i = 1; i < mip; ++i) { - voxel->Mips[i].PivotX = voxel->Mips[0].PivotX >> i; - voxel->Mips[i].PivotY = voxel->Mips[0].PivotY >> i; - voxel->Mips[i].PivotZ = voxel->Mips[0].PivotZ >> i; + voxel->Mips[i].Pivot = voxel->Mips[i - 1].Pivot / 2; } for (i = 0; i < mip; ++i) @@ -339,9 +337,9 @@ FVoxelDef *R_LoadVoxelDef(int lumpnum, int spin) { FVoxelDef *voxdef = new FVoxelDef; voxdef->Voxel = vox; - voxdef->Scale = FRACUNIT; + voxdef->Scale = 1.; voxdef->DroppedSpin = voxdef->PlacedSpin = spin; - voxdef->AngleOffset = ANGLE_90; + voxdef->AngleOffset = 90.; Voxels.Push(vox); VoxelDefs.Push(voxdef); @@ -358,7 +356,7 @@ FVoxelDef *R_LoadVoxelDef(int lumpnum, int spin) FVoxelMipLevel::FVoxelMipLevel() { SizeZ = SizeY = SizeX = 0; - PivotZ = PivotY = PivotX = 0; + Pivot.Zero(); OffsetX = NULL; OffsetXY = NULL; SlabData = NULL; @@ -499,7 +497,7 @@ static void VOX_ReadOptions(FScanner &sc, VoxelOptions &opts) { sc.MustGetToken('='); sc.MustGetToken(TK_FloatConst); - opts.Scale = FLOAT2FIXED(sc.Float); + opts.Scale = sc.Float; } else if (sc.Compare("spin")) { @@ -531,7 +529,7 @@ static void VOX_ReadOptions(FScanner &sc, VoxelOptions &opts) { sc.TokenMustBe(TK_FloatConst); } - opts.AngleOffset = ANGLE_90 + FLOAT2ANGLE(sc.Float); + opts.AngleOffset = sc.Float + 90.; } else if (sc.Compare("overridepalette")) { diff --git a/src/r_data/voxels.h b/src/r_data/voxels.h index 221cddb2f..85095c52f 100644 --- a/src/r_data/voxels.h +++ b/src/r_data/voxels.h @@ -23,9 +23,7 @@ struct FVoxelMipLevel int SizeX; int SizeY; int SizeZ; - fixed_t PivotX; // 24.8 fixed point - fixed_t PivotY; // "" - fixed_t PivotZ; // "" + DVector3 Pivot; int *OffsetX; short *OffsetXY; BYTE *SlabData; @@ -51,8 +49,8 @@ struct FVoxelDef int PlacedSpin; // degrees/sec to spin actors without MF_DROPPED set int DroppedSpin; // degrees/sec to spin actors with MF_DROPPED set int VoxeldefIndex; // Needed by GZDoom - fixed_t Scale; - angle_t AngleOffset; // added to actor's angle to compensate for wrong-facing voxels + double Scale; + DAngle AngleOffset;// added to actor's angle to compensate for wrong-facing voxels }; extern TDeletingArray Voxels; // used only to auto-delete voxels on exit. diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 2f8f04403..48fae68ca 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2350,6 +2350,18 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) } } +static fixed_t GetAlpha(int type, fixed_t alpha) +{ + switch (type) + { + case STYLEALPHA_Zero: return 0; + case STYLEALPHA_One: return OPAQUE; + case STYLEALPHA_Src: return alpha; + case STYLEALPHA_InvSrc: return OPAQUE - alpha; + default: return 0; + } +} + ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, DWORD color) { fixed_t fglevel, bglevel; diff --git a/src/r_things.cpp b/src/r_things.cpp index 580dad557..6313e0cab 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -918,10 +918,11 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } else { - xscale = FixedMul(spritescaleX, voxel->Scale); - yscale = FixedMul(spritescaleY, voxel->Scale); - gzt = fz + MulScale8(yscale, voxel->Voxel->Mips[0].PivotZ) - FLOAT2FIXED(thing->Floorclip); - gzb = fz + MulScale8(yscale, voxel->Voxel->Mips[0].PivotZ - (voxel->Voxel->Mips[0].SizeZ << 8)); + xscale = fixed_t(spritescaleX * voxel->Scale); + yscale = fixed_t(spritescaleY * voxel->Scale); + fixed_t piv = fixed_t(voxel->Voxel->Mips[0].Pivot.Z*256.); + gzt = fz + MulScale8(yscale, piv) - FLOAT2FIXED(thing->Floorclip); + gzb = fz + MulScale8(yscale, piv - (voxel->Voxel->Mips[0].SizeZ << 8)); if (gzt <= gzb) return; } @@ -1030,7 +1031,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor fz -= FLOAT2FIXED(thing->Floorclip); - vis->angle = thing->_f_angle() + voxel->AngleOffset; + vis->angle = thing->Angles.Yaw.BAMs() + voxel->AngleOffset.BAMs(); int voxelspin = (thing->flags & MF_DROPPED) ? voxel->DroppedSpin : voxel->PlacedSpin; if (voxelspin != 0) @@ -2728,18 +2729,22 @@ void R_DrawVoxel(fixed_t globalposx, fixed_t globalposy, fixed_t globalposz, ang daxscalerecip = (1<<30) / daxscale; dayscalerecip = (1<<30) / dayscale; + fixed_t piv_x = fixed_t(mip->Pivot.X*256.); + fixed_t piv_y = fixed_t(mip->Pivot.Y*256.); + fixed_t piv_z = fixed_t(mip->Pivot.Z*256.); + x = FixedMul(globalposx - dasprx, daxscalerecip); y = FixedMul(globalposy - daspry, daxscalerecip); - backx = (DMulScale10(x, sprcosang, y, sprsinang) + mip->PivotX) >> 8; - backy = (DMulScale10(y, sprcosang, x, -sprsinang) + mip->PivotY) >> 8; + backx = (DMulScale10(x, sprcosang, y, sprsinang) + piv_x) >> 8; + backy = (DMulScale10(y, sprcosang, x, -sprsinang) + piv_y) >> 8; cbackx = clamp(backx, 0, mip->SizeX - 1); cbacky = clamp(backy, 0, mip->SizeY - 1); sprcosang = MulScale14(daxscale, sprcosang); sprsinang = MulScale14(daxscale, sprsinang); - x = (dasprx - globalposx) - DMulScale18(mip->PivotX, sprcosang, mip->PivotY, -sprsinang); - y = (daspry - globalposy) - DMulScale18(mip->PivotY, sprcosang, mip->PivotX, sprsinang); + x = (dasprx - globalposx) - DMulScale18(piv_x, sprcosang, piv_y, -sprsinang); + y = (daspry - globalposy) - DMulScale18(piv_y, sprcosang, piv_x, sprsinang); cosang = FixedMul(cosang, dayscalerecip); sinang = FixedMul(sinang, dayscalerecip); @@ -2759,7 +2764,7 @@ void R_DrawVoxel(fixed_t globalposx, fixed_t globalposy, fixed_t globalposz, ang ggyinc[i] = y; y += gyinc; } - syoff = DivScale21(globalposz - dasprz, FixedMul(dazscale, 0xE800)) + (mip->PivotZ << 7); + syoff = DivScale21(globalposz - dasprz, FixedMul(dazscale, 0xE800)) + (piv_z << 7); yoff = (abs(gxinc) + abs(gyinc)) >> 1; for (cnt = 0; cnt < 8; cnt++) From 5bf806e478a9e87de885db86266d10533172e555 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 16:16:45 +0100 Subject: [PATCH 2/3] - renamed some fixed point stuff in the texture composition code. --- src/p_3dmidtex.cpp | 6 +++--- src/textures/bitmap.cpp | 12 ++++++------ src/textures/bitmap.h | 24 ++++++++++++++++-------- src/textures/multipatchtexture.cpp | 14 +++++++------- src/textures/textures.h | 4 +++- 5 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index ffeb32e6f..b86e46e2d 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -230,12 +230,12 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, f FTexture * tex= TexMan(texnum); if (!tex) return false; - fixed_t totalscale = abs(FixedMul(side->GetTextureYScale(side_t::mid), tex->yScale)); + double totalscale = fabs(FIXED2DBL(side->GetTextureYScale(side_t::mid)) * tex->GetScaleY()); fixed_t y_offset = side->GetTextureYOffset(side_t::mid); fixed_t textureheight = tex->GetScaledHeight(totalscale) << FRACBITS; - if (totalscale != FRACUNIT && !tex->bWorldPanning) + if (totalscale != 1. && !tex->bWorldPanning) { - y_offset = FixedDiv(y_offset, totalscale); + y_offset = fixed_t(y_offset * totalscale); } if(line->flags & ML_DONTPEGBOTTOM) diff --git a/src/textures/bitmap.cpp b/src/textures/bitmap.cpp index 346ffd65e..7873e35cb 100644 --- a/src/textures/bitmap.cpp +++ b/src/textures/bitmap.cpp @@ -146,9 +146,9 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in a = TSrc::A(pin, tr, tg, tb); if (TBlend::ProcessAlpha0() || a) { - r = (TSrc::R(pin)*inf->blendcolor[0])>>FRACBITS; - g = (TSrc::G(pin)*inf->blendcolor[1])>>FRACBITS; - b = (TSrc::B(pin)*inf->blendcolor[2])>>FRACBITS; + r = (TSrc::R(pin)*inf->blendcolor[0])>>BLENDBITS; + g = (TSrc::G(pin)*inf->blendcolor[1])>>BLENDBITS; + b = (TSrc::B(pin)*inf->blendcolor[2])>>BLENDBITS; TBlend::OpC(pout[TDest::RED], r, a, inf); TBlend::OpC(pout[TDest::GREEN], g, a, inf); @@ -167,9 +167,9 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in a = TSrc::A(pin, tr, tg, tb); if (TBlend::ProcessAlpha0() || a) { - r = (TSrc::R(pin)*inf->blendcolor[3] + inf->blendcolor[0]) >> FRACBITS; - g = (TSrc::G(pin)*inf->blendcolor[3] + inf->blendcolor[1]) >> FRACBITS; - b = (TSrc::B(pin)*inf->blendcolor[3] + inf->blendcolor[2]) >> FRACBITS; + r = (TSrc::R(pin)*inf->blendcolor[3] + inf->blendcolor[0]) >> BLENDBITS; + g = (TSrc::G(pin)*inf->blendcolor[3] + inf->blendcolor[1]) >> BLENDBITS; + b = (TSrc::B(pin)*inf->blendcolor[3] + inf->blendcolor[2]) >> BLENDBITS; TBlend::OpC(pout[TDest::RED], r, a, inf); TBlend::OpC(pout[TDest::GREEN], g, a, inf); diff --git a/src/textures/bitmap.h b/src/textures/bitmap.h index 8519c8b80..27d3c0b4b 100644 --- a/src/textures/bitmap.h +++ b/src/textures/bitmap.h @@ -48,6 +48,14 @@ struct FClipRect bool Intersect(int ix, int iy, int iw, int ih); }; +typedef int blend_t; + +enum +{ + BLENDBITS = 16, + BLENDUNIT = (1<alpha) >> FRACBITS; } + static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = (s*i->alpha) >> BLENDBITS; } static __forceinline bool ProcessAlpha0() { return false; } }; @@ -380,28 +388,28 @@ struct bOverlay struct bBlend { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (d*i->invalpha + s*i->alpha) >> FRACBITS; } + static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (d*i->invalpha + s*i->alpha) >> BLENDBITS; } static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; struct bAdd { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MIN((d*FRACUNIT + s*i->alpha) >> FRACBITS, 255); } + static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MIN((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); } static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; struct bSubtract { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX((d*FRACUNIT - s*i->alpha) >> FRACBITS, 0); } + static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); } static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; struct bReverseSubtract { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX((-d*FRACUNIT + s*i->alpha) >> FRACBITS, 0); } + static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); } static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 5a9b8d491..31af81a56 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -180,7 +180,7 @@ protected: FRemapTable *Translation; PalEntry Blend; FTexture *Texture; - fixed_t Alpha; + blend_t Alpha; TexPart(); }; @@ -593,7 +593,7 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rota memset (&info, 0, sizeof(info)); info.alpha = Parts[i].Alpha; - info.invalpha = OPAQUE - info.alpha; + info.invalpha = BLENDUNIT - info.alpha; info.op = ECopyOp(Parts[i].op); PalEntry b = Parts[i].Blend; if (b.a == 0 && b != BLEND_NONE) @@ -604,14 +604,14 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rota { if (b.a == 255) { - info.blendcolor[0] = b.r * FRACUNIT / 255; - info.blendcolor[1] = b.g * FRACUNIT / 255; - info.blendcolor[2] = b.b * FRACUNIT / 255; + info.blendcolor[0] = b.r * BLENDUNIT / 255; + info.blendcolor[1] = b.g * BLENDUNIT / 255; + info.blendcolor[2] = b.b * BLENDUNIT / 255; info.blend = BLEND_MODULATE; } else { - fixed_t blendalpha = b.a * FRACUNIT / 255; + blend_t blendalpha = b.a * BLENDUNIT / 255; info.blendcolor[0] = b.r * blendalpha; info.blendcolor[1] = b.g * blendalpha; info.blendcolor[2] = b.b * blendalpha; @@ -1165,7 +1165,7 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part, bool silent, i else if (sc.Compare("alpha")) { sc.MustGetFloat(); - part.Alpha = clamp(FLOAT2FIXED(sc.Float), 0, OPAQUE); + part.Alpha = clamp(int(sc.Float / BLENDUNIT), 0, BLENDUNIT); // bComplex is not set because it is only needed when the style is not OP_COPY. } else if (sc.Compare("style")) diff --git a/src/textures/textures.h b/src/textures/textures.h index 13f5b0eab..0057214d6 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -2,6 +2,7 @@ #define __TEXTURES_H #include "doomtype.h" +#include "m_fixed.h" class FBitmap; struct FRemapTable; @@ -204,9 +205,10 @@ public: int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); } int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); } - int GetScaledHeight(fixed_t scale) { int foo = (Height << 17) / scale; return (foo >> 1) + (foo & 1); } + int GetScaledHeight(double scale) { return GetScaledHeight(FLOAT2FIXED(scale)); } double GetScaledWidthDouble () { return (Width * 65536.) / xScale; } double GetScaledHeightDouble () { return (Height * 65536.) / yScale; } + double GetScaleY() const { return FIXED2DBL(yScale); } int GetScaledLeftOffset () { int foo = (LeftOffset << 17) / xScale; return (foo >> 1) + (foo & 1); } int GetScaledTopOffset () { int foo = (TopOffset << 17) / yScale; return (foo >> 1) + (foo & 1); } From 41387622f2b9de21ce6440874e3d3c854fdcd600 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 16:36:43 +0100 Subject: [PATCH 3/3] - changed angle parameter of FillSimplePoly. --- src/am_map.cpp | 2 +- src/v_draw.cpp | 10 +++++----- src/v_video.h | 2 +- src/win32/fb_d3d9.cpp | 9 ++++----- src/win32/win32iface.h | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 7a556542a..a8076550c 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2070,7 +2070,7 @@ void AM_drawSubsectors() originx, originy, scale / (FIXED2DBL(scalex) * float(1 << MAPBITS)), scale / (FIXED2DBL(scaley) * float(1 << MAPBITS)), - rotation, + ANGLE2DBL(rotation), colormap, floorlight ); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 8d3453fa4..2d3b1e3e2 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1152,7 +1152,7 @@ void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uin //========================================================================== void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, - double originx, double originy, double scalex, double scaley, angle_t rotation, + double originx, double originy, double scalex, double scaley, DAngle rotation, FDynamicColormap *colormap, int lightlevel) { #ifndef NO_SWRENDER @@ -1163,8 +1163,7 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, int i; int y1, y2, y; fixed_t x; - double rot = rotation * M_PI / double(1u << 31); - bool dorotate = rot != 0; + bool dorotate = rotation != 0.; double cosrot, sinrot; if (--npoints < 2 || Buffer == NULL) @@ -1205,8 +1204,9 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, scalex /= FIXED2DBL(tex->xScale); scaley /= FIXED2DBL(tex->yScale); - cosrot = cos(rot); - sinrot = sin(rot); + // Use the CRT's functions here. + cosrot = cos(ToRadians(rotation)); + sinrot = sin(ToRadians(rotation)); // Setup constant texture mapping parameters. R_SetupSpanBits(tex); diff --git a/src/v_video.h b/src/v_video.h index 269641373..533adb52e 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -180,7 +180,7 @@ public: // Fill a simple polygon with a texture virtual void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, - double originx, double originy, double scalex, double scaley, angle_t rotation, + double originx, double originy, double scalex, double scaley, DAngle rotation, struct FDynamicColormap *colormap, int lightlevel); // Set an area to a specified color diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 17c548c29..8a6e7e50f 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -3071,7 +3071,7 @@ void D3DFB::FlatFill(int left, int top, int right, int bottom, FTexture *src, bo void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - angle_t rotation, FDynamicColormap *colormap, int lightlevel) + DAngle rotation, FDynamicColormap *colormap, int lightlevel) { // Use an equation similar to player sprites to determine shade fixed_t shade = LIGHT2SHADE(lightlevel) - 12*FRACUNIT; @@ -3083,8 +3083,7 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, D3DCOLOR color0, color1; float ox, oy; float cosrot, sinrot; - float rot = float(rotation * M_PI / float(1u << 31)); - bool dorotate = rot != 0; + bool dorotate = rotation != 0; if (npoints < 3) { // This is no polygon. @@ -3105,8 +3104,8 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, return; } - cosrot = cos(rot); - sinrot = sin(rot); + cosrot = (float)cos(ToRadians(rotation)); + sinrot = (float)sin(ToRadians(rotation)); CheckQuadBatch(npoints - 2, npoints); quad = &QuadExtra[QuadBatchPos]; diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 00a34578a..f8fcd1fba 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -265,7 +265,7 @@ public: void DrawPixel(int x, int y, int palcolor, uint32 rgbcolor); void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, double originx, double originy, double scalex, double scaley, - angle_t rotation, FDynamicColormap *colormap, int lightlevel); + DAngle rotation, FDynamicColormap *colormap, int lightlevel); bool WipeStartScreen(int type); void WipeEndScreen(); bool WipeDo(int ticks);