cleanup: use spaceship operator where possible
This commit is contained in:
parent
bbe39c7c82
commit
4c1d4af2ed
|
|
@ -177,30 +177,9 @@ std::string contentflags_t::to_string() const
|
|||
|
||||
// surfflags_t
|
||||
|
||||
static auto as_tuple(const surfflags_t &flags)
|
||||
{
|
||||
return std::tie(flags.native, flags.is_nodraw, flags.is_hintskip, flags.is_hint, flags.no_dirt, flags.no_shadow,
|
||||
flags.no_bounce, flags.no_minlight, flags.no_expand, flags.no_phong, flags.light_ignore,
|
||||
flags.surflight_rescale, flags.surflight_style, flags.surflight_color, flags.surflight_minlight_scale,
|
||||
flags.surflight_atten, flags.surflight_targetname, flags.phong_angle, flags.phong_angle_concave,
|
||||
flags.phong_group, flags.minlight, flags.minlight_color, flags.light_alpha, flags.light_twosided,
|
||||
flags.maxlight, flags.lightcolorscale, flags.surflight_group, flags.world_units_per_luxel,
|
||||
flags.object_channel_mask);
|
||||
}
|
||||
|
||||
bool surfflags_t::needs_write() const
|
||||
{
|
||||
return as_tuple(*this) != as_tuple(surfflags_t());
|
||||
}
|
||||
|
||||
bool surfflags_t::operator<(const surfflags_t &other) const
|
||||
{
|
||||
return as_tuple(*this) < as_tuple(other);
|
||||
}
|
||||
|
||||
bool surfflags_t::operator>(const surfflags_t &other) const
|
||||
{
|
||||
return as_tuple(*this) > as_tuple(other);
|
||||
return *this != surfflags_t();
|
||||
}
|
||||
|
||||
bool surfflags_t::is_valid(const gamedef_t *game) const
|
||||
|
|
|
|||
|
|
@ -320,8 +320,7 @@ struct surfflags_t
|
|||
|
||||
public:
|
||||
// sort support
|
||||
bool operator<(const surfflags_t &other) const;
|
||||
bool operator>(const surfflags_t &other) const;
|
||||
auto operator<=>(const surfflags_t &other) const = default;
|
||||
|
||||
bool is_valid(const gamedef_t *game) const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -137,12 +137,7 @@ public:
|
|||
[[nodiscard]] constexpr size_t size() const { return N; }
|
||||
|
||||
// Sort support
|
||||
[[nodiscard]] constexpr bool operator<(const qvec &other) const { return v < other.v; }
|
||||
[[nodiscard]] constexpr bool operator<=(const qvec &other) const { return v <= other.v; }
|
||||
[[nodiscard]] constexpr bool operator>(const qvec &other) const { return v > other.v; }
|
||||
[[nodiscard]] constexpr bool operator>=(const qvec &other) const { return v >= other.v; }
|
||||
[[nodiscard]] constexpr bool operator==(const qvec &other) const { return v == other.v; }
|
||||
[[nodiscard]] constexpr bool operator!=(const qvec &other) const { return v != other.v; }
|
||||
[[nodiscard]] constexpr auto operator<=>(const qvec &) const = default;
|
||||
|
||||
[[nodiscard]] constexpr const T &at(const size_t idx) const
|
||||
{
|
||||
|
|
@ -780,17 +775,9 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
private:
|
||||
auto as_tuple() const { return std::tie(normal, dist); }
|
||||
|
||||
public:
|
||||
// Sort support
|
||||
[[nodiscard]] constexpr bool operator<(const qplane3 &other) const { return as_tuple() < other.as_tuple(); }
|
||||
[[nodiscard]] constexpr bool operator<=(const qplane3 &other) const { return as_tuple() <= other.as_tuple(); }
|
||||
[[nodiscard]] constexpr bool operator>(const qplane3 &other) const { return as_tuple() > other.as_tuple(); }
|
||||
[[nodiscard]] constexpr bool operator>=(const qplane3 &other) const { return as_tuple() >= other.as_tuple(); }
|
||||
[[nodiscard]] constexpr bool operator==(const qplane3 &other) const { return as_tuple() == other.as_tuple(); }
|
||||
[[nodiscard]] constexpr bool operator!=(const qplane3 &other) const { return as_tuple() != other.as_tuple(); }
|
||||
[[nodiscard]] constexpr auto operator<=>(const qplane3 &other) const = default;
|
||||
|
||||
[[nodiscard]] constexpr const qvec<T, 4> vec4() const { return qvec<T, 4>(normal[0], normal[1], normal[2], dist); }
|
||||
|
||||
|
|
@ -905,12 +892,7 @@ public:
|
|||
}
|
||||
|
||||
// Sort support
|
||||
[[nodiscard]] constexpr bool operator<(const qmat &other) const { return m_values < other.m_values; }
|
||||
[[nodiscard]] constexpr bool operator<=(const qmat &other) const { return m_values <= other.m_values; }
|
||||
[[nodiscard]] constexpr bool operator>(const qmat &other) const { return m_values > other.m_values; }
|
||||
[[nodiscard]] constexpr bool operator>=(const qmat &other) const { return m_values >= other.m_values; }
|
||||
[[nodiscard]] constexpr bool operator==(const qmat &other) const { return m_values == other.m_values; }
|
||||
[[nodiscard]] constexpr bool operator!=(const qmat &other) const { return m_values != other.m_values; }
|
||||
[[nodiscard]] constexpr auto operator<=>(const qmat &other) const = default;
|
||||
|
||||
// access to elements
|
||||
|
||||
|
|
|
|||
|
|
@ -152,9 +152,7 @@ private:
|
|||
float opacity = 1.f;
|
||||
bool alpha_test = false;
|
||||
|
||||
auto as_tuple() const { return std::make_tuple(program, texname, opacity, alpha_test); }
|
||||
|
||||
bool operator<(const material_key &other) const { return as_tuple() < other.as_tuple(); }
|
||||
auto operator<=>(const material_key &other) const = default;
|
||||
};
|
||||
|
||||
std::shared_ptr<QOpenGLTexture> placeholder_texture;
|
||||
|
|
|
|||
Loading…
Reference in New Issue