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 418 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 422 of file Types.h.

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

◆ Int3() [3/4]

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

Definition at line 423 of file Types.h.

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

◆ Int3() [4/4]

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

Definition at line 424 of file Types.h.

424 : 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 627 of file Types.h.

628  {
629  const Int3 minval = this->MinElements(max);
630  return min.MaxElements(minval);
631  }
DLLEXPORT constexpr Int3 MinElements(const Int3 &other) const noexcept
Definition: Types.h:614
DLLEXPORT constexpr Int3() noexcept=default

◆ GetX()

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

Definition at line 570 of file Types.h.

571  {
572  return X;
573  }

◆ GetY()

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

Definition at line 575 of file Types.h.

576  {
577  return Y;
578  }

◆ GetZ()

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

Definition at line 580 of file Types.h.

581  {
582  return Z;
583  }

◆ HAdd()

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

Definition at line 602 of file Types.h.

603  {
604  return X + Y + Z;
605  }

◆ HAddAbs()

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

Definition at line 608 of file Types.h.

609  {
610  return std::abs(X) + std::abs(Y) + std::abs(Z);
611  }

◆ Length()

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

Definition at line 635 of file Types.h.

636  {
637  return std::sqrt(static_cast<float>(LengthSquared()));
638  }
DLLEXPORT constexpr unsigned int LengthSquared() const noexcept
Definition: Types.h:640

◆ LengthSquared()

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

Definition at line 640 of file Types.h.

641  {
642  return X * X + Y * Y + Z * Z;
643  }

◆ MaxElements()

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

Definition at line 620 of file Types.h.

621  {
622  return Int3(
623  X > other.X ? X : other.X, Y > other.Y ? Y : other.Y, Z > other.Z ? Z : other.Z);
624  }
DLLEXPORT constexpr Int3() noexcept=default

◆ MinElements()

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

Definition at line 614 of file Types.h.

615  {
616  return Int3(
617  X < other.X ? X : other.X, Y < other.Y ? Y : other.Y, Z < other.Z ? Z : other.Z);
618  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator!=()

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

Definition at line 563 of file Types.h.

564  {
565  return X != other.X || Y != other.Y || Z != other.Z;
566  }

◆ operator*() [1/2]

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

Definition at line 481 of file Types.h.

482  {
483  return Int3(X * other.X, Y * other.Y, Z * other.Z);
484  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator*() [2/2]

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

Definition at line 509 of file Types.h.

510  {
511  return Int3(X * val, Y * val, Z * val);
512  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator*=() [1/2]

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

Definition at line 486 of file Types.h.

487  {
488  X *= other.X;
489  Y *= other.Y;
490  Z *= other.Z;
491  return *this;
492  }

◆ operator*=() [2/2]

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

Definition at line 514 of file Types.h.

515  {
516  X *= val;
517  Y *= val;
518  Z *= val;
519  return *this;
520  }

◆ operator+() [1/2]

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

Definition at line 441 of file Types.h.

442  {
443  return Int3(X + other.X, Y + other.Y, Z + other.Z);
444  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator+() [2/2]

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

Definition at line 475 of file Types.h.

476  {
477  return Int3(*this);
478  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator+=()

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

Definition at line 446 of file Types.h.

447  {
448  X += other.X;
449  Y += other.Y;
450  Z += other.Z;
451  return *this;
452  }

◆ operator-() [1/2]

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

Definition at line 455 of file Types.h.

456  {
457  return Int3(X - other.X, Y - other.Y, Z - other.Z);
458  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator-() [2/2]

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

Definition at line 469 of file Types.h.

470  {
471  return Int3(-X, -Y, -Z);
472  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator-=()

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

Definition at line 460 of file Types.h.

461  {
462  X -= other.X;
463  Y -= other.Y;
464  Z -= other.Z;
465  return *this;
466  }

◆ operator/() [1/2]

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

Definition at line 495 of file Types.h.

496  {
497  return Int3(X / val, Y / val, Z / val);
498  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator/() [2/2]

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

Definition at line 523 of file Types.h.

524  {
525  return Int3(X / other.X, Y / other.Y, Z / other.Z);
526  }
DLLEXPORT constexpr Int3() noexcept=default

◆ operator/=() [1/2]

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

Definition at line 500 of file Types.h.

501  {
502  X /= val;
503  Y /= val;
504  Z /= val;
505  return *this;
506  }

◆ operator/=() [2/2]

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

Definition at line 528 of file Types.h.

529  {
530  X /= other.X;
531  Y /= other.Y;
532  Z /= other.Z;
533  return *this;
534  }

◆ operator<()

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

Definition at line 538 of file Types.h.

539  {
540  return std::tie(X, Y, Z) < std::tie(other.X, other.Y, other.Z);
541  }

◆ operator<=()

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

Definition at line 543 of file Types.h.

544  {
545  return std::tie(X, Y, Z) <= std::tie(other.X, other.Y, other.Z);
546  }

◆ operator==()

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

Definition at line 558 of file Types.h.

559  {
560  return X == other.X && Y == other.Y && Z == other.Z;
561  }

◆ operator>()

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

Definition at line 548 of file Types.h.

549  {
550  return std::tie(X, Y, Z) > std::tie(other.X, other.Y, other.Z);
551  }

◆ operator>=()

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

Definition at line 553 of file Types.h.

554  {
555  return std::tie(X, Y, Z) >= std::tie(other.X, other.Y, other.Z);
556  }

◆ operator[]()

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

Definition at line 427 of file Types.h.

428  {
429  switch(nindex) {
430  case 0: return X;
431  case 1: return Y;
432  case 2: return Z;
433  default: break;
434  }
435  LEVIATHAN_ASSERT(0, "invalid [] access");
436  return X;
437  }
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:100

◆ SetX()

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

Definition at line 586 of file Types.h.

587  {
588  X = val;
589  }

◆ SetY()

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

Definition at line 591 of file Types.h.

592  {
593  Y = val;
594  }

◆ SetZ()

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

Definition at line 596 of file Types.h.

597  {
598  Z = val;
599  }

◆ VALUE_TYPE()

Leviathan::Int3::VALUE_TYPE ( Int3  )

Member Data Documentation

◆ X

int Leviathan::Int3::X = 0

Definition at line 649 of file Types.h.

◆ Y

int Leviathan::Int3::Y = 0

Definition at line 650 of file Types.h.

◆ Z

int Leviathan::Int3::Z = 0

Definition at line 651 of file Types.h.


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