Added swizzled accessors to KRVector2 and KRVector3
--HG-- branch : nfb
This commit is contained in:
@@ -35,6 +35,20 @@ KRVector2::KRVector2(const KRVector2 &v) {
|
|||||||
y = v.y;
|
y = v.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// KRVector2 swizzle getters
|
||||||
|
KRVector2 KRVector2::yx() const
|
||||||
|
{
|
||||||
|
return KRVector2(y,x);
|
||||||
|
}
|
||||||
|
|
||||||
|
// KRVector2 swizzle setters
|
||||||
|
void KRVector2::yx(const KRVector2 &v)
|
||||||
|
{
|
||||||
|
y = v.x;
|
||||||
|
x = v.y;
|
||||||
|
}
|
||||||
|
|
||||||
KRVector2 KRVector2::Min() {
|
KRVector2 KRVector2::Min() {
|
||||||
return KRVector2(-std::numeric_limits<float>::max());
|
return KRVector2(-std::numeric_limits<float>::max());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ public:
|
|||||||
KRVector2(const KRVector2 &v);
|
KRVector2(const KRVector2 &v);
|
||||||
~KRVector2();
|
~KRVector2();
|
||||||
|
|
||||||
|
// KRVector2 swizzle getters
|
||||||
|
KRVector2 yx() const;
|
||||||
|
|
||||||
|
// KRVector2 swizzle setters
|
||||||
|
void yx(const KRVector2 &v);
|
||||||
|
|
||||||
KRVector2& operator =(const KRVector2& b);
|
KRVector2& operator =(const KRVector2& b);
|
||||||
KRVector2 operator +(const KRVector2& b) const;
|
KRVector2 operator +(const KRVector2& b) const;
|
||||||
KRVector2 operator -(const KRVector2& b) const;
|
KRVector2 operator -(const KRVector2& b) const;
|
||||||
|
|||||||
@@ -65,6 +65,87 @@ KRVector3::KRVector3(double *v) {
|
|||||||
z = (float)v[2];
|
z = (float)v[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KRVector2 KRVector3::xx() const
|
||||||
|
{
|
||||||
|
return KRVector2(x,x);
|
||||||
|
}
|
||||||
|
|
||||||
|
KRVector2 KRVector3::xy() const
|
||||||
|
{
|
||||||
|
return KRVector2(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
KRVector2 KRVector3::xz() const
|
||||||
|
{
|
||||||
|
return KRVector2(x,z);
|
||||||
|
}
|
||||||
|
|
||||||
|
KRVector2 KRVector3::yx() const
|
||||||
|
{
|
||||||
|
return KRVector2(y,x);
|
||||||
|
}
|
||||||
|
|
||||||
|
KRVector2 KRVector3::yy() const
|
||||||
|
{
|
||||||
|
return KRVector2(y,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
KRVector2 KRVector3::yz() const
|
||||||
|
{
|
||||||
|
return KRVector2(y,z);
|
||||||
|
}
|
||||||
|
|
||||||
|
KRVector2 KRVector3::zx() const
|
||||||
|
{
|
||||||
|
return KRVector2(z,x);
|
||||||
|
}
|
||||||
|
|
||||||
|
KRVector2 KRVector3::zy() const
|
||||||
|
{
|
||||||
|
return KRVector2(z,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
KRVector2 KRVector3::zz() const
|
||||||
|
{
|
||||||
|
return KRVector2(z,z);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRVector3::xy(const KRVector2 &v)
|
||||||
|
{
|
||||||
|
x = v.x;
|
||||||
|
y = v.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRVector3::xz(const KRVector2 &v)
|
||||||
|
{
|
||||||
|
x = v.x;
|
||||||
|
z = v.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRVector3::yx(const KRVector2 &v)
|
||||||
|
{
|
||||||
|
y = v.x;
|
||||||
|
x = v.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRVector3::yz(const KRVector2 &v)
|
||||||
|
{
|
||||||
|
y = v.x;
|
||||||
|
z = v.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRVector3::zx(const KRVector2 &v)
|
||||||
|
{
|
||||||
|
z = v.x;
|
||||||
|
x = v.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KRVector3::zy(const KRVector2 &v)
|
||||||
|
{
|
||||||
|
z = v.x;
|
||||||
|
y = v.y;
|
||||||
|
}
|
||||||
|
|
||||||
KRVector3 KRVector3::Min() {
|
KRVector3 KRVector3::Min() {
|
||||||
return KRVector3(-std::numeric_limits<float>::max());
|
return KRVector3(-std::numeric_limits<float>::max());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include "KREngine-common.h"
|
#include "KREngine-common.h"
|
||||||
|
|
||||||
|
class KRVector2;
|
||||||
class KRVector4;
|
class KRVector4;
|
||||||
|
|
||||||
class KRVector3 {
|
class KRVector3 {
|
||||||
@@ -56,6 +56,24 @@ public:
|
|||||||
KRVector3(const KRVector4 &v);
|
KRVector3(const KRVector4 &v);
|
||||||
~KRVector3();
|
~KRVector3();
|
||||||
|
|
||||||
|
// KRVector2 swizzle getters
|
||||||
|
KRVector2 xx() const;
|
||||||
|
KRVector2 xy() const;
|
||||||
|
KRVector2 xz() const;
|
||||||
|
KRVector2 yx() const;
|
||||||
|
KRVector2 yy() const;
|
||||||
|
KRVector2 yz() const;
|
||||||
|
KRVector2 zx() const;
|
||||||
|
KRVector2 zy() const;
|
||||||
|
KRVector2 zz() const;
|
||||||
|
|
||||||
|
// KRVector2 swizzle setters
|
||||||
|
void xy(const KRVector2 &v);
|
||||||
|
void xz(const KRVector2 &v);
|
||||||
|
void yx(const KRVector2 &v);
|
||||||
|
void yz(const KRVector2 &v);
|
||||||
|
void zx(const KRVector2 &v);
|
||||||
|
void zy(const KRVector2 &v);
|
||||||
|
|
||||||
KRVector3& operator =(const KRVector3& b);
|
KRVector3& operator =(const KRVector3& b);
|
||||||
KRVector3& operator =(const KRVector4& b);
|
KRVector3& operator =(const KRVector4& b);
|
||||||
|
|||||||
Reference in New Issue
Block a user