HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends
tt::ivec Class Reference

#include <TTauri/Foundation/ivec.hpp>

Public Member Functions

tt_force_inline ivec (ivec const &rhs)=default
 
tt_force_inline ivecoperator= (ivec const &rhs)=default
 
tt_force_inline ivec (ivec &&rhs)=default
 
tt_force_inline ivecoperator= (ivec &&rhs)=default
 
tt_force_inline ivec (__m128i rhs) noexcept
 Create a ivec out of a __m128i.
 
tt_force_inline ivecoperator= (__m128i rhs) noexcept
 Create a ivec out of a __m128i.
 
tt_force_inline operator __m128i () const noexcept
 Convert a ivec to a __m128i.
 
tt_force_inline ivec (vec const &rhs) noexcept
 
tt_force_inline ivecoperator= (vec const &rhs) noexcept
 
tt_force_inline operator vec () const noexcept
 
tt_force_inline operator std::array< int32_t, 4 > () const noexcept
 
template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
tt_force_inline ivec (T rhs) noexcept
 Initialize a ivec with all elements set to a value.
 
template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
tt_force_inline ivecoperator= (T rhs) noexcept
 Initialize a ivec with all elements set to a value.
 
template<typename T , typename U , typename V = int, typename W = int, std::enable_if_t< std::is_arithmetic_v< T > &&std::is_arithmetic_v< U > &&std::is_arithmetic_v< V > &&std::is_arithmetic_v< W >, int > = 0>
tt_force_inline ivec (T x, U y, V z=0, W w=0) noexcept
 Create a ivec out of 2 to 4 values.
 
template<size_t I, typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
tt_force_inline ivecset (T rhs) noexcept
 
template<size_t I>
tt_force_inline int get () const noexcept
 
constexpr size_t size () const noexcept
 
template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
tt_force_inline ivecx (T rhs) noexcept
 
template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
tt_force_inline ivecy (T rhs) noexcept
 
template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
tt_force_inline ivecz (T rhs) noexcept
 
template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
tt_force_inline ivecw (T rhs) noexcept
 
tt_force_inline int x () const noexcept
 
tt_force_inline int y () const noexcept
 
tt_force_inline int z () const noexcept
 
tt_force_inline int w () const noexcept
 
tt_force_inline int width () const noexcept
 
tt_force_inline int height () const noexcept
 
tt_force_inline ivecoperator+= (ivec const &rhs) noexcept
 
tt_force_inline ivecoperator-= (ivec const &rhs) noexcept
 
tt_force_inline ivecoperator*= (ivec const &rhs) noexcept
 
template<char a, char b, char c, char d>
tt_force_inline ivec swizzle () const noexcept
 

Static Public Member Functions

template<typename T , typename U , typename V = int, typename W = int, std::enable_if_t< std::is_arithmetic_v< T > &&std::is_arithmetic_v< U > &&std::is_arithmetic_v< V > &&std::is_arithmetic_v< W >, int > = 0>
static tt_force_inline ivec point (T x, U y, V z=0, W w=1) noexcept
 Create a ivec out of 2 to 4 values.
 
template<char a, char b, char c, char d>
static constexpr int swizzle_permute_mask () noexcept
 

Friends

tt_force_inline friend ivec operator+ (ivec const &lhs, ivec const &rhs) noexcept
 
tt_force_inline friend ivec operator- (ivec const &lhs, ivec const &rhs) noexcept
 
tt_force_inline friend ivec operator* (ivec const &lhs, ivec const &rhs) noexcept
 
tt_force_inline friend ivec max (ivec const &lhs, ivec const &rhs) noexcept
 
tt_force_inline friend ivec min (ivec const &lhs, ivec const &rhs) noexcept
 
tt_force_inline friend bool operator== (ivec const &lhs, ivec const &rhs) noexcept
 
tt_force_inline friend bool operator!= (ivec const &lhs, ivec const &rhs) noexcept
 
tt_force_inline friend int eq (ivec const &lhs, ivec const &rhs) noexcept
 Equal to.
 
tt_force_inline friend int operator< (ivec const &lhs, ivec const &rhs) noexcept
 Less than.
 
tt_force_inline friend int operator> (ivec const &lhs, ivec const &rhs) noexcept
 Greater than.
 
tt_force_inline friend int operator<= (ivec const &lhs, ivec const &rhs) noexcept
 
tt_force_inline friend int operator>= (ivec const &lhs, ivec const &rhs) noexcept
 
std::string to_string (ivec const &rhs) noexcept
 
std::ostream friend & operator<< (std::ostream &lhs, ivec const &rhs) noexcept
 
template<std::size_t I>
tt_force_inline friend int get (ivec const &rhs) noexcept
 

Detailed Description

A 4D vector.

If you need a 3D vector or point, you can use this vector class as a homogenious coordinate.

This class supports swizzeling. Swizzeling is done using member functions which will return a vec. The name of the member function consists of 2 to 4 of the following characters: 'x', 'y', 'z', 'w', 'r', 'g', 'b', 'a', '0' & '1'. If the swizzle member function name would start with a '0' or '1' character it will be prefixed with an underscore '_'.

Since swizzle member functions always return a 4D vec, the third and forth element will default to '0' and 'w'. This allows a 2D vector to maintain its homogeniousness.

Constructor & Destructor Documentation

◆ ivec() [1/3]

tt_force_inline tt::ivec::ivec ( __m128i rhs)
inlinenoexcept

Create a ivec out of a __m128i.

◆ ivec() [2/3]

template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
tt_force_inline tt::ivec::ivec ( T rhs)
inlineexplicitnoexcept

Initialize a ivec with all elements set to a value.

Useful as a scalar converter, when combined with an arithmetic operator.

◆ ivec() [3/3]

template<typename T , typename U , typename V = int, typename W = int, std::enable_if_t< std::is_arithmetic_v< T > &&std::is_arithmetic_v< U > &&std::is_arithmetic_v< V > &&std::is_arithmetic_v< W >, int > = 0>
tt_force_inline tt::ivec::ivec ( T x,
U y,
V z = 0,
W w = 0 )
inlinenoexcept

Create a ivec out of 2 to 4 values.

This vector is used as a homogeneous coordinate, meaning:

  • vectors have w=0 (A direction and distance)
  • points have w=1 (A position in space)

Member Function Documentation

◆ operator __m128i()

tt_force_inline tt::ivec::operator __m128i ( ) const
inlinenoexcept

Convert a ivec to a __m128i.

◆ operator=() [1/2]

tt_force_inline ivec & tt::ivec::operator= ( __m128i rhs)
inlinenoexcept

Create a ivec out of a __m128i.

◆ operator=() [2/2]

template<typename T , std::enable_if_t< std::is_arithmetic_v< T >, int > = 0>
tt_force_inline ivec & tt::ivec::operator= ( T rhs)
inlinenoexcept

Initialize a ivec with all elements set to a value.

Useful as a scalar converter, when combined with an arithmetic operator.

◆ point()

template<typename T , typename U , typename V = int, typename W = int, std::enable_if_t< std::is_arithmetic_v< T > &&std::is_arithmetic_v< U > &&std::is_arithmetic_v< V > &&std::is_arithmetic_v< W >, int > = 0>
static tt_force_inline ivec tt::ivec::point ( T x,
U y,
V z = 0,
W w = 1 )
inlinestaticnoexcept

Create a ivec out of 2 to 4 values.

This vector is used as a homogeneous coordinate, meaning:

  • vectors have w=0 (A direction and distance)
  • points have w=1 (A position in space)

Friends And Related Symbol Documentation

◆ eq

tt_force_inline friend int eq ( ivec const & lhs,
ivec const & rhs )
friend

Equal to.

Returns
boolean nibble field, bit [3:0]=x, [7:4]=y, [11:8]=z, [15:12]=w.

◆ operator<

tt_force_inline friend int operator< ( ivec const & lhs,
ivec const & rhs )
friend

Less than.

Returns
boolean nibble field, bit [3:0]=x, [7:4]=y, [11:8]=z, [15:12]=w.

◆ operator>

tt_force_inline friend int operator> ( ivec const & lhs,
ivec const & rhs )
friend

Greater than.

Returns
boolean nibble field, bit [3:0]=x, [7:4]=y, [11:8]=z, [15:12]=w.

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