mirror of
https://github.com/ZDoom/Raze.git
synced 2025-03-13 20:42:11 +00:00
- Eliminate last remaining uses of binangle
and the class itself.
* https://www.youtube.com/watch?v=RgKAFK5djSk
This commit is contained in:
parent
6aaee85875
commit
951734beae
4 changed files with 4 additions and 124 deletions
|
@ -110,126 +110,6 @@ inline double bcosf(const double ang, const int shift = 0)
|
|||
return g_cosbam(ang * BAMUNIT) * sinscale(shift);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
class binangle
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
constexpr binangle(uint32_t v) : value(v) {}
|
||||
|
||||
friend constexpr binangle bamang(uint32_t v);
|
||||
friend constexpr binangle q16ang(uint32_t v);
|
||||
friend constexpr binangle buildang(uint32_t v);
|
||||
friend binangle buildfang(double v);
|
||||
friend binangle radang(double v);
|
||||
friend binangle degang(double v);
|
||||
|
||||
friend FSerializer &Serialize(FSerializer &arc, const char *key, binangle &obj, binangle *defval);
|
||||
|
||||
constexpr int32_t tosigned() const { return int32_t(value); }
|
||||
|
||||
public:
|
||||
binangle() = default;
|
||||
binangle(const binangle &other) = default;
|
||||
binangle& operator=(const binangle& other) = default;
|
||||
// This class intentionally makes no allowances for implicit type conversions because those would render it ineffective.
|
||||
constexpr short asbuild() const { return value >> BAMBITS; }
|
||||
constexpr double asbuildf() const { return value * (1. / +BAMUNIT); }
|
||||
constexpr fixed_t asq16() const { return value >> 5; }
|
||||
constexpr uint32_t asbam() const { return value; }
|
||||
constexpr double asrad() const { return value * (pi::pi() / 0x80000000u); }
|
||||
constexpr double asdeg() const { return DAngle::fromBam(value).Degrees(); }
|
||||
constexpr short signedbuild() const { return tosigned() >> BAMBITS; }
|
||||
constexpr double signedbuildf() const { return tosigned() * (1. / +BAMUNIT); }
|
||||
constexpr fixed_t signedq16() const { return tosigned() >> 5; }
|
||||
constexpr int32_t signedbam() const { return tosigned(); }
|
||||
constexpr double signedrad() const { return tosigned() * (pi::pi() / 0x80000000u); }
|
||||
constexpr double signeddeg() const { return DAngle::fromBam(tosigned()).Degrees(); }
|
||||
|
||||
double fsin() const { return g_sinbam(asbam()); }
|
||||
double fcos() const { return g_cosbam(asbam()); }
|
||||
double ftan() const { return g_tan(asrad()); }
|
||||
int bsin(const int8_t& shift = 0) const { return ::bsin(asbuild(), shift); }
|
||||
int bcos(const int8_t& shift = 0) const { return ::bcos(asbuild(), shift); }
|
||||
|
||||
constexpr bool operator== (binangle other) const
|
||||
{
|
||||
return value == other.value;
|
||||
}
|
||||
|
||||
constexpr bool operator!= (binangle other) const
|
||||
{
|
||||
return value != other.value;
|
||||
}
|
||||
|
||||
constexpr binangle &operator+= (binangle other)
|
||||
{
|
||||
value += other.value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr binangle &operator-= (binangle other)
|
||||
{
|
||||
value -= other.value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr binangle operator+ (binangle other) const
|
||||
{
|
||||
return binangle(value + other.value);
|
||||
}
|
||||
|
||||
constexpr binangle operator- (binangle other) const
|
||||
{
|
||||
return binangle(value - other.value);
|
||||
}
|
||||
|
||||
constexpr binangle operator- () const
|
||||
{
|
||||
return binangle(0 - value);
|
||||
}
|
||||
|
||||
constexpr binangle &operator<<= (const uint8_t shift)
|
||||
{
|
||||
value = tosigned() << shift;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr binangle &operator>>= (const uint8_t shift)
|
||||
{
|
||||
value = tosigned() >> shift;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr binangle operator<< (const uint8_t shift) const
|
||||
{
|
||||
return binangle(tosigned() << shift);
|
||||
}
|
||||
|
||||
constexpr binangle operator>> (const uint8_t shift) const
|
||||
{
|
||||
return binangle(tosigned() >> shift);
|
||||
}
|
||||
};
|
||||
|
||||
inline constexpr binangle bamang(uint32_t v) { return binangle(v); }
|
||||
inline constexpr binangle q16ang(uint32_t v) { return binangle(v << 5); }
|
||||
inline constexpr binangle buildang(uint32_t v) { return binangle(v << BAMBITS); }
|
||||
inline binangle buildfang(double v) { return binangle(xs_ToFixed(BAMBITS, v)); }
|
||||
inline binangle radang(double v) { return binangle(xs_CRoundToUInt(v * (0x80000000u / pi::pi()))); }
|
||||
inline binangle degang(double v) { return binangle(FloatToAngle(v)); }
|
||||
|
||||
inline FSerializer &Serialize(FSerializer &arc, const char *key, binangle &obj, binangle *defval)
|
||||
{
|
||||
return Serialize(arc, key, obj.value, defval ? &defval->value : nullptr);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Functions for use with fixedhoriz and friendly functions.
|
||||
|
|
|
@ -66,8 +66,8 @@ void BunchDrawer::Init(HWDrawInfo *_di, Clipper* c, vec2_t& view, angle_t a1, an
|
|||
iview = view;
|
||||
StartScene();
|
||||
|
||||
gcosang = bamang(di->Viewpoint.RotAngle).fcos();
|
||||
gsinang = bamang(di->Viewpoint.RotAngle).fsin();
|
||||
gcosang = g_cosbam(di->Viewpoint.RotAngle);
|
||||
gsinang = g_sinbam(di->Viewpoint.RotAngle);
|
||||
|
||||
for (auto& w : wall)
|
||||
{
|
||||
|
|
|
@ -654,6 +654,6 @@ void Clipper::DumpClipper()
|
|||
{
|
||||
for (auto node = cliphead; node; node = node->next)
|
||||
{
|
||||
Printf("Range from %2.3f to %2.3f (top = %2.3f, bottom = %2.3f)\n", bamang(node->start).asdeg(), bamang(node->end).asdeg(), node->topclip, node->bottomclip);
|
||||
Printf("Range from %2.3f to %2.3f (top = %2.3f, bottom = %2.3f)\n", DAngle::fromBam(node->start).Degrees(), DAngle::fromBam(node->end).Degrees(), node->topclip, node->bottomclip);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -524,7 +524,7 @@ bool HWSprite::ProcessVoxel(HWDrawInfo* di, voxmodel_t* vox, tspritetype* spr, s
|
|||
|
||||
rotmat.loadIdentity();
|
||||
rotmat.translate(x + translatevec.X, z - translatevec.Z, y - translatevec.Y);
|
||||
rotmat.rotate(buildang(ang).asdeg() - 90.f, 0, 1, 0);
|
||||
rotmat.rotate(DAngle::fromBuild(ang).Degrees() - 90.f, 0, 1, 0);
|
||||
rotmat.scale(scalevec.X, scalevec.Z, scalevec.Y);
|
||||
// Apply pivot last
|
||||
rotmat.translate(-voxel->piv.X, zoff, voxel->piv.Y);
|
||||
|
|
Loading…
Reference in a new issue