Leviathan  0.8.0.0
Leviathan game engine
Leviathan::Int3 Struct Reference

#include <Types.h>

Public Member Functions

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

Public Attributes

int X = 0
 
int Y = 0
 
int Z = 0
 

Detailed Description

Definition at line 341 of file Types.h.

Constructor & Destructor Documentation

◆ Int3() [1/4]

DLLEXPORT constexpr Leviathan::Int3::Int3 ( )
defaultnoexcept

◆ Int3() [2/4]

DLLEXPORT constexpr Leviathan::Int3::Int3 ( int  x,
int  y,
int  z 
)
inline

Definition at line 345 of file Types.h.

345 : X(x), Y(y), Z(z) {}

◆ Int3() [3/4]

DLLEXPORT constexpr Leviathan::Int3::Int3 ( Int2  ints,
int  z 
)
inline

Definition at line 346 of file Types.h.

346 : X(ints.X), Y(ints.Y), Z(z) {}

◆ Int3() [4/4]

DLLEXPORT constexpr Leviathan::Int3::Int3 ( int  data)
inlineexplicit

Definition at line 347 of file Types.h.

347 : X(data), Y(data), Z(data) {}

Member Function Documentation

◆ Clamp()

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

Definition at line 550 of file Types.h.

551  {
552  const Int3 minval = this->MinElements(max);
553  return min.MaxElements(minval);
554  }
DLLEXPORT constexpr Int3 MinElements(const Int3 &other) const noexcept
Definition: Types.h:537
DLLEXPORT constexpr Int3() noexcept=default

◆ GetX()

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

Definition at line 493 of file Types.h.

494  {
495  return X;
496  }

◆ GetY()

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

Definition at line 498 of file Types.h.

499  {
500  return Y;
501  }

◆ GetZ()

DLLEXPORT constexpr int Leviathan::Int3::GetZ ( ) const
inlinenoexcept

Definition at line 503 of file Types.h.

504  {
505  return Z;
506  }

◆ HAdd()

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

Definition at line 525 of file Types.h.

526  {
527  return X + Y + Z;
528  }

◆ HAddAbs()

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

Definition at line 531 of file Types.h.

532  {
533  return std::abs(X) + std::abs(Y) + std::abs(Z);
534  }

◆ Length()

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

Definition at line 558 of file Types.h.

559  {
560  return std::sqrt(static_cast<float>(LengthSquared()));
561  }
DLLEXPORT constexpr unsigned int LengthSquared() const noexcept
Definition: Types.h:563

◆ LengthSquared()

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

Definition at line 563 of file Types.h.

564  {
565  return X * X + Y * Y + Z * Z;
566  }

◆ MaxElements()

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

Definition at line 543 of file Types.h.

544  {
545  return Int3(
546  X > other.X ? X : other.X, Y > other.Y ? Y : other.Y, Z > other.Z ? Z : other.Z);
547  }
DLLEXPORT constexpr Int3() noexcept=default

◆ MinElements()

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

Definition at line 537 of file Types.h.

538  {
539  return Int3(
540  X < other.X ? X : other.X, Y < other.Y ? Y : other.Y, Z < other.Z ? Z : other.Z);
541  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator!=()

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

Definition at line 486 of file Types.h.

487  {
488  return X != other.X || Y != other.Y || Z != other.Z;
489  }

◆ operator*() [1/2]

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

Definition at line 404 of file Types.h.

405  {
406  return Int3(X * other.X, Y * other.Y, Z * other.Z);
407  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator*() [2/2]

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

Definition at line 432 of file Types.h.

433  {
434  return Int3(X * val, Y * val, Z * val);
435  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator*=() [1/2]

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

Definition at line 409 of file Types.h.

410  {
411  X *= other.X;
412  Y *= other.Y;
413  Z *= other.Z;
414  return *this;
415  }

◆ operator*=() [2/2]

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

Definition at line 437 of file Types.h.

438  {
439  X *= val;
440  Y *= val;
441  Z *= val;
442  return *this;
443  }

◆ operator+() [1/2]

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

Definition at line 364 of file Types.h.

365  {
366  return Int3(X + other.X, Y + other.Y, Z + other.Z);
367  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator+() [2/2]

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

Definition at line 398 of file Types.h.

399  {
400  return Int3(*this);
401  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator+=()

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

Definition at line 369 of file Types.h.

370  {
371  X += other.X;
372  Y += other.Y;
373  Z += other.Z;
374  return *this;
375  }

◆ operator-() [1/2]

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

Definition at line 378 of file Types.h.

379  {
380  return Int3(X - other.X, Y - other.Y, Z - other.Z);
381  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator-() [2/2]

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

Definition at line 392 of file Types.h.

393  {
394  return Int3(-X, -Y, -Z);
395  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator-=()

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

Definition at line 383 of file Types.h.

384  {
385  X -= other.X;
386  Y -= other.Y;
387  Z -= other.Z;
388  return *this;
389  }

◆ operator/() [1/2]

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

Definition at line 418 of file Types.h.

419  {
420  return Int3(X / val, Y / val, Z / val);
421  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator/() [2/2]

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

Definition at line 446 of file Types.h.

447  {
448  return Int3(X / other.X, Y / other.Y, Z / other.Z);
449  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator/=() [1/2]

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

Definition at line 423 of file Types.h.

424  {
425  X /= val;
426  Y /= val;
427  Z /= val;
428  return *this;
429  }

◆ operator/=() [2/2]

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

Definition at line 451 of file Types.h.

452  {
453  X /= other.X;
454  Y /= other.Y;
455  Z /= other.Z;
456  return *this;
457  }

◆ operator<()

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

Definition at line 461 of file Types.h.

462  {
463  return std::tie(X, Y, Z) < std::tie(other.X, other.Y, other.Z);
464  }

◆ operator<=()

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

Definition at line 466 of file Types.h.

467  {
468  return std::tie(X, Y, Z) <= std::tie(other.X, other.Y, other.Z);
469  }

◆ operator==()

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

Definition at line 481 of file Types.h.

482  {
483  return X == other.X && Y == other.Y && Z == other.Z;
484  }

◆ operator>()

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

Definition at line 471 of file Types.h.

472  {
473  return std::tie(X, Y, Z) > std::tie(other.X, other.Y, other.Z);
474  }

◆ operator>=()

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

Definition at line 476 of file Types.h.

477  {
478  return std::tie(X, Y, Z) >= std::tie(other.X, other.Y, other.Z);
479  }

◆ operator[]()

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

Definition at line 350 of file Types.h.

351  {
352  switch(nindex) {
353  case 0: return X;
354  case 1: return Y;
355  case 2: return Z;
356  default: break;
357  }
358  LEVIATHAN_ASSERT(0, "invalid [] access");
359  return X;
360  }
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:92

◆ SetX()

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

Definition at line 509 of file Types.h.

510  {
511  X = val;
512  }

◆ SetY()

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

Definition at line 514 of file Types.h.

515  {
516  Y = val;
517  }

◆ SetZ()

DLLEXPORT void Leviathan::Int3::SetZ ( int  val)
inline

Definition at line 519 of file Types.h.

520  {
521  Z = val;
522  }

◆ VALUE_TYPE()

Leviathan::Int3::VALUE_TYPE ( Int3  )

Member Data Documentation

◆ X

int Leviathan::Int3::X = 0

Definition at line 572 of file Types.h.

◆ Y

int Leviathan::Int3::Y = 0

Definition at line 573 of file Types.h.

◆ Z

int Leviathan::Int3::Z = 0

Definition at line 574 of file Types.h.


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