Leviathan  0.8.0.0
Leviathan game engine
Leviathan::Int2 Struct Reference

#include <Types.h>

Public Member Functions

DLLEXPORT constexpr Int2 () noexcept=default
 
DLLEXPORT constexpr Int2 (int x, int y) noexcept
 
DLLEXPORT constexpr Int2 (int data) noexcept
 
DLLEXPORT int & operator[] (int nindex)
 
DLLEXPORT constexpr Int2 operator+ (const Int2 &other) const noexcept
 
DLLEXPORT Int2operator+= (const Int2 &other) noexcept
 
DLLEXPORT constexpr Int2 operator- (const Int2 &other) const noexcept
 
DLLEXPORT Int2operator-= (const Int2 &other) noexcept
 
DLLEXPORT constexpr Int2 operator- () const noexcept
 
DLLEXPORT constexpr Int2 operator+ () const noexcept
 
DLLEXPORT constexpr Int2 operator* (const Int2 &other) const noexcept
 
DLLEXPORT Int2operator*= (const Int2 &other) noexcept
 
DLLEXPORT constexpr Int2 operator/ (int val) const
 
DLLEXPORT Int2operator/= (int val)
 
DLLEXPORT constexpr Int2 operator* (int val) const noexcept
 
DLLEXPORT Int2operator*= (int val) noexcept
 
DLLEXPORT constexpr Int2 operator/ (const Int2 &other) const
 
DLLEXPORT Int2operator/= (const Int2 &other)
 
DLLEXPORT constexpr bool operator< (const Int2 &other) const noexcept
 
DLLEXPORT constexpr bool operator<= (const Int2 &other) const noexcept
 
DLLEXPORT constexpr bool operator> (const Int2 &other) const noexcept
 
DLLEXPORT constexpr bool operator>= (const Int2 &other) const noexcept
 
DLLEXPORT constexpr bool operator== (const Int2 &other) const noexcept
 
DLLEXPORT constexpr bool operator!= (const Int2 &other) const noexcept
 
DLLEXPORT constexpr int GetX () const noexcept
 
DLLEXPORT constexpr int GetY () const noexcept
 
DLLEXPORT void SetX (int val)
 
DLLEXPORT void SetY (int val)
 
DLLEXPORT constexpr int HAdd () const noexcept
 
DLLEXPORT unsigned int HAddAbs () const noexcept
 
DLLEXPORT constexpr Int2 MinElements (const Int2 &other) const noexcept
 
DLLEXPORT constexpr Int2 MaxElements (const Int2 &other) const noexcept
 
DLLEXPORT constexpr Int2 Clamp (const Int2 &min, const Int2 &max) const noexcept
 
DLLEXPORT float Length () const noexcept
 
DLLEXPORT constexpr unsigned int LengthSquared () const noexcept
 
 VALUE_TYPE (Int2)
 

Public Attributes

int X = 0
 
int Y = 0
 

Detailed Description

Definition at line 126 of file Types.h.

Constructor & Destructor Documentation

◆ Int2() [1/3]

DLLEXPORT constexpr Leviathan::Int2::Int2 ( )
defaultnoexcept

◆ Int2() [2/3]

DLLEXPORT constexpr Leviathan::Int2::Int2 ( int  x,
int  y 
)
inlinenoexcept

Definition at line 130 of file Types.h.

130 : X(x), Y(y) {}

◆ Int2() [3/3]

DLLEXPORT constexpr Leviathan::Int2::Int2 ( int  data)
inlineexplicitnoexcept

Definition at line 131 of file Types.h.

131 : X(data), Y(data) {}

Member Function Documentation

◆ Clamp()

DLLEXPORT constexpr Int2 Leviathan::Int2::Clamp ( const Int2 min,
const Int2 max 
) const
inlinenoexcept

Definition at line 316 of file Types.h.

317  {
318  const Int2 minval = this->MinElements(max);
319  return min.MaxElements(minval);
320  }
DLLEXPORT constexpr Int2 MinElements(const Int2 &other) const noexcept
Definition: Types.h:305
DLLEXPORT constexpr Int2() noexcept=default

◆ GetX()

DLLEXPORT constexpr int Leviathan::Int2::GetX ( ) const
inlinenoexcept

Definition at line 271 of file Types.h.

272  {
273  return X;
274  }

◆ GetY()

DLLEXPORT constexpr int Leviathan::Int2::GetY ( ) const
inlinenoexcept

Definition at line 276 of file Types.h.

277  {
278  return Y;
279  }

◆ HAdd()

DLLEXPORT constexpr int Leviathan::Int2::HAdd ( ) const
inlinenoexcept

Definition at line 293 of file Types.h.

294  {
295  return X + Y;
296  }

◆ HAddAbs()

DLLEXPORT unsigned int Leviathan::Int2::HAddAbs ( ) const
inlinenoexcept

Definition at line 299 of file Types.h.

300  {
301  return std::abs(X) + std::abs(Y);
302  }

◆ Length()

DLLEXPORT float Leviathan::Int2::Length ( ) const
inlinenoexcept

Definition at line 324 of file Types.h.

325  {
326  return std::sqrt(static_cast<float>(LengthSquared()));
327  }
DLLEXPORT constexpr unsigned int LengthSquared() const noexcept
Definition: Types.h:329

◆ LengthSquared()

DLLEXPORT constexpr unsigned int Leviathan::Int2::LengthSquared ( ) const
inlinenoexcept

Definition at line 329 of file Types.h.

330  {
331  return X * X + Y * Y;
332  }

◆ MaxElements()

DLLEXPORT constexpr Int2 Leviathan::Int2::MaxElements ( const Int2 other) const
inlinenoexcept

Definition at line 310 of file Types.h.

311  {
312  return Int2(X > other.X ? X : other.X, Y > other.Y ? Y : other.Y);
313  }
DLLEXPORT constexpr Int2() noexcept=default

◆ MinElements()

DLLEXPORT constexpr Int2 Leviathan::Int2::MinElements ( const Int2 other) const
inlinenoexcept

Definition at line 305 of file Types.h.

306  {
307  return Int2(X < other.X ? X : other.X, Y < other.Y ? Y : other.Y);
308  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator!=()

DLLEXPORT constexpr bool Leviathan::Int2::operator!= ( const Int2 other) const
inlinenoexcept

Definition at line 264 of file Types.h.

265  {
266  return X != other.X || Y != other.Y;
267  }

◆ operator*() [1/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator* ( const Int2 other) const
inlinenoexcept

Definition at line 186 of file Types.h.

187  {
188  return Int2(X * other.X, Y * other.Y);
189  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator*() [2/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator* ( int  val) const
inlinenoexcept

Definition at line 212 of file Types.h.

213  {
214  return Int2(X * val, Y * val);
215  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator*=() [1/2]

DLLEXPORT Int2& Leviathan::Int2::operator*= ( const Int2 other)
inlinenoexcept

Definition at line 191 of file Types.h.

192  {
193  X *= other.X;
194  Y *= other.Y;
195  return *this;
196  }

◆ operator*=() [2/2]

DLLEXPORT Int2& Leviathan::Int2::operator*= ( int  val)
inlinenoexcept

Definition at line 217 of file Types.h.

218  {
219  X *= val;
220  Y *= val;
221  return *this;
222  }

◆ operator+() [1/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator+ ( const Int2 other) const
inlinenoexcept

Definition at line 148 of file Types.h.

149  {
150  return Int2(X + other.X, Y + other.Y);
151  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator+() [2/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator+ ( ) const
inlinenoexcept

Definition at line 180 of file Types.h.

181  {
182  return Int2(*this);
183  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator+=()

DLLEXPORT Int2& Leviathan::Int2::operator+= ( const Int2 other)
inlinenoexcept

Definition at line 153 of file Types.h.

154  {
155  X += other.X;
156  Y += other.Y;
157  return *this;
158  }

◆ operator-() [1/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator- ( const Int2 other) const
inlinenoexcept

Definition at line 161 of file Types.h.

162  {
163  return Int2(X - other.X, Y - other.Y);
164  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator-() [2/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator- ( ) const
inlinenoexcept

Definition at line 174 of file Types.h.

175  {
176  return Int2(-X, -Y);
177  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator-=()

DLLEXPORT Int2& Leviathan::Int2::operator-= ( const Int2 other)
inlinenoexcept

Definition at line 166 of file Types.h.

167  {
168  X -= other.X;
169  Y -= other.Y;
170  return *this;
171  }

◆ operator/() [1/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator/ ( int  val) const
inline

Definition at line 199 of file Types.h.

200  {
201  return Int2(X / val, Y / val);
202  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator/() [2/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator/ ( const Int2 other) const
inline

Definition at line 225 of file Types.h.

226  {
227  return Int2(X / other.X, Y / other.Y);
228  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator/=() [1/2]

DLLEXPORT Int2& Leviathan::Int2::operator/= ( int  val)
inline

Definition at line 204 of file Types.h.

205  {
206  X /= val;
207  Y /= val;
208  return *this;
209  }

◆ operator/=() [2/2]

DLLEXPORT Int2& Leviathan::Int2::operator/= ( const Int2 other)
inline

Definition at line 230 of file Types.h.

231  {
232  X /= other.X;
233  Y /= other.Y;
234  return *this;
235  }

◆ operator<()

DLLEXPORT constexpr bool Leviathan::Int2::operator< ( const Int2 other) const
inlinenoexcept

Definition at line 239 of file Types.h.

240  {
241  return std::tie(X, Y) < std::tie(other.X, other.Y);
242  }

◆ operator<=()

DLLEXPORT constexpr bool Leviathan::Int2::operator<= ( const Int2 other) const
inlinenoexcept

Definition at line 244 of file Types.h.

245  {
246  return std::tie(X, Y) <= std::tie(other.X, other.Y);
247  }

◆ operator==()

DLLEXPORT constexpr bool Leviathan::Int2::operator== ( const Int2 other) const
inlinenoexcept

Definition at line 259 of file Types.h.

260  {
261  return X == other.X && Y == other.Y;
262  }

◆ operator>()

DLLEXPORT constexpr bool Leviathan::Int2::operator> ( const Int2 other) const
inlinenoexcept

Definition at line 249 of file Types.h.

250  {
251  return std::tie(X, Y) > std::tie(other.X, other.Y);
252  }

◆ operator>=()

DLLEXPORT constexpr bool Leviathan::Int2::operator>= ( const Int2 other) const
inlinenoexcept

Definition at line 254 of file Types.h.

255  {
256  return std::tie(X, Y) >= std::tie(other.X, other.Y);
257  }

◆ operator[]()

DLLEXPORT int& Leviathan::Int2::operator[] ( int  nindex)
inline

Definition at line 134 of file Types.h.

135  {
136  switch(nindex) {
137  case 0: return X;
138  case 1: return Y;
139  default: break;
140  }
141 
142  LEVIATHAN_ASSERT(0, "invalid [] access");
143  return X;
144  }
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:92

◆ SetX()

DLLEXPORT void Leviathan::Int2::SetX ( int  val)
inline

Definition at line 282 of file Types.h.

283  {
284  X = val;
285  }

◆ SetY()

DLLEXPORT void Leviathan::Int2::SetY ( int  val)
inline

Definition at line 287 of file Types.h.

288  {
289  Y = val;
290  }

◆ VALUE_TYPE()

Leviathan::Int2::VALUE_TYPE ( Int2  )

Member Data Documentation

◆ X

int Leviathan::Int2::X = 0

Definition at line 337 of file Types.h.

◆ Y

int Leviathan::Int2::Y = 0

Definition at line 338 of file Types.h.


The documentation for this struct was generated from the following file: