mirror of https://github.com/AxioDL/zeus.git
hsh vector type implicit casts
This commit is contained in:
parent
6c46735ab1
commit
e64b7c4d17
|
@ -62,5 +62,10 @@ if(TARGET athena-core)
|
||||||
target_compile_definitions(zeus PUBLIC ZE_ATHENA_TYPES=1)
|
target_compile_definitions(zeus PUBLIC ZE_ATHENA_TYPES=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(TARGET hsh)
|
||||||
|
target_link_libraries(zeus PUBLIC hsh)
|
||||||
|
target_compile_definitions(zeus PUBLIC ZE_HSH_TYPES=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,15 @@ public:
|
||||||
writer.writeUByte(atUint8(f[3] * 255));
|
writer.writeUByte(atUint8(f[3] * 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ZE_HSH_TYPES
|
||||||
|
|
||||||
|
operator hsh::float4() const {
|
||||||
|
simd_floats floats(mSimd);
|
||||||
|
return hsh::float4{floats[0], floats[1], floats[2], floats[3]};
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] bool operator==(const CColor& rhs) const {
|
[[nodiscard]] bool operator==(const CColor& rhs) const {
|
||||||
|
|
|
@ -67,6 +67,16 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ZE_HSH_TYPES
|
||||||
|
|
||||||
|
operator hsh::float3x3() const {
|
||||||
|
return hsh::float3x3{hsh::float3(m[0]), hsh::float3(m[1]), hsh::float3(m[2])};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr CMatrix3f(const hsh::float3x3& vec) : m{vec.cols[0], vec.cols[1], vec.cols[2]} {}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CMatrix3f(const CQuaternion& quat);
|
CMatrix3f(const CQuaternion& quat);
|
||||||
|
|
|
@ -49,6 +49,16 @@ public:
|
||||||
m[3].mSimd = CVector4f(0.f, 0.f, 0.f, 1.0f).mSimd;
|
m[3].mSimd = CVector4f(0.f, 0.f, 0.f, 1.0f).mSimd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ZE_HSH_TYPES
|
||||||
|
|
||||||
|
operator hsh::float4x4() const {
|
||||||
|
return hsh::float4x4{hsh::float4(m[0]), hsh::float4(m[1]), hsh::float4(m[2]), hsh::float4(m[3])};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr CMatrix4f(const hsh::float4x4& vec) : m{vec.cols[0], vec.cols[1], vec.cols[2], vec.cols[3]} {}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
constexpr CMatrix4f& operator=(const CMatrix4f& other) = default;
|
constexpr CMatrix4f& operator=(const CMatrix4f& other) = default;
|
||||||
|
|
||||||
[[nodiscard]] CVector4f operator*(const CVector4f& other) const {
|
[[nodiscard]] CVector4f operator*(const CVector4f& other) const {
|
||||||
|
|
|
@ -39,6 +39,17 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ZE_HSH_TYPES
|
||||||
|
|
||||||
|
operator hsh::float2() const {
|
||||||
|
simd_floats floats(mSimd);
|
||||||
|
return hsh::float2{floats[0], floats[1]};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr CVector2f(const hsh::float2& vec) : mSimd(vec.x, vec.y) {}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
explicit constexpr CVector2f(float xy) : mSimd(xy) {}
|
explicit constexpr CVector2f(float xy) : mSimd(xy) {}
|
||||||
|
|
|
@ -47,6 +47,17 @@ public:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ZE_HSH_TYPES
|
||||||
|
|
||||||
|
operator hsh::float3() const {
|
||||||
|
simd_floats floats(mSimd);
|
||||||
|
return hsh::float3{floats[0], floats[1], floats[2]};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr CVector3f(const hsh::float3& vec) : mSimd(vec.x, vec.y, vec.z) {}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline CVector3f(const CVector3d& vec);
|
inline CVector3f(const CVector3d& vec);
|
||||||
|
|
|
@ -40,6 +40,17 @@ public:
|
||||||
mSimd.copy_from(f);
|
mSimd.copy_from(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ZE_HSH_TYPES
|
||||||
|
|
||||||
|
operator hsh::float4() const {
|
||||||
|
simd_floats floats(mSimd);
|
||||||
|
return hsh::float4{floats[0], floats[1], floats[2], floats[3]};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr CVector4f(const hsh::float4& vec) : mSimd(vec.x, vec.y, vec.z, vec.w) {}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
explicit constexpr CVector4f(float xyzw) : mSimd(xyzw) {}
|
explicit constexpr CVector4f(float xyzw) : mSimd(xyzw) {}
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
#include "simd/simd.hpp"
|
#include "simd/simd.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ZE_HSH_TYPES
|
||||||
|
#include "hsh/hsh.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace zeus {
|
namespace zeus {
|
||||||
#if ZE_ATHENA_TYPES
|
#if ZE_ATHENA_TYPES
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -718,54 +718,78 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
__simd_reference operator++() && { return std::move(*this) = __ptr_->__get(__index_) + 1; }
|
__simd_reference operator++() && { return std::move(*this) = _Vp(*this) + 1; }
|
||||||
|
|
||||||
_Vp operator++(int) && {
|
_Vp operator++(int) && {
|
||||||
auto __val = __ptr_->__get(__index_);
|
auto __val = _Vp(*this);
|
||||||
__ptr_->__set(__index_, __val + 1);
|
__ptr_->__set(__index_, __val + 1);
|
||||||
return __val;
|
return __val;
|
||||||
}
|
}
|
||||||
|
|
||||||
__simd_reference operator--() && { return std::move(*this) = __ptr_->__get(__index_) - 1; }
|
__simd_reference operator--() && { return std::move(*this) = _Vp(*this) - 1; }
|
||||||
|
|
||||||
_Vp operator--(int) && {
|
_Vp operator--(int) && {
|
||||||
auto __val = __ptr_->__get(__index_);
|
auto __val = _Vp(*this);
|
||||||
__ptr_->__set(__index_, __val - 1);
|
__ptr_->__set(__index_, __val - 1);
|
||||||
return __val;
|
return __val;
|
||||||
}
|
}
|
||||||
|
|
||||||
__simd_reference operator+=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) + __value; }
|
__simd_reference operator+=(_Vp __value) && { return std::move(*this) = _Vp(*this) + __value; }
|
||||||
|
|
||||||
__simd_reference operator-=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) - __value; }
|
__simd_reference operator-=(_Vp __value) && { return std::move(*this) = _Vp(*this) - __value; }
|
||||||
|
|
||||||
__simd_reference operator*=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) * __value; }
|
__simd_reference operator*=(_Vp __value) && { return std::move(*this) = _Vp(*this) * __value; }
|
||||||
|
|
||||||
__simd_reference operator/=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) / __value; }
|
__simd_reference operator/=(_Vp __value) && { return std::move(*this) = _Vp(*this) / __value; }
|
||||||
|
|
||||||
__simd_reference operator%=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) % __value; }
|
__simd_reference operator%=(_Vp __value) && { return std::move(*this) = _Vp(*this) % __value; }
|
||||||
|
|
||||||
__simd_reference operator>>=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) >> __value; }
|
__simd_reference operator>>=(_Vp __value) && { return std::move(*this) = _Vp(*this) >> __value; }
|
||||||
|
|
||||||
__simd_reference operator<<=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) << __value; }
|
__simd_reference operator<<=(_Vp __value) && { return std::move(*this) = _Vp(*this) << __value; }
|
||||||
|
|
||||||
__simd_reference operator&=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) & __value; }
|
__simd_reference operator&=(_Vp __value) && { return std::move(*this) = _Vp(*this) & __value; }
|
||||||
|
|
||||||
__simd_reference operator|=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) | __value; }
|
__simd_reference operator|=(_Vp __value) && { return std::move(*this) = _Vp(*this) | __value; }
|
||||||
|
|
||||||
__simd_reference operator^=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) ^ __value; }
|
__simd_reference operator^=(_Vp __value) && { return std::move(*this) = _Vp(*this) ^ __value; }
|
||||||
|
|
||||||
bool operator<(_Vp __value) const { return __ptr_->__get(__index_) < __value; }
|
bool operator<(const __simd_reference& __value) const { return _Vp(*this) < _Vp(__value); }
|
||||||
|
|
||||||
bool operator<=(_Vp __value) const { return __ptr_->__get(__index_) <= __value; }
|
bool operator<=(const __simd_reference& __value) const { return _Vp(*this) <= _Vp(__value); }
|
||||||
|
|
||||||
bool operator>(_Vp __value) const { return __ptr_->__get(__index_) > __value; }
|
bool operator>(const __simd_reference& __value) const { return _Vp(*this) > _Vp(__value); }
|
||||||
|
|
||||||
bool operator>=(_Vp __value) const { return __ptr_->__get(__index_) >= __value; }
|
bool operator>=(const __simd_reference& __value) const { return _Vp(*this) >= _Vp(__value); }
|
||||||
|
|
||||||
bool operator==(_Vp __value) const { return __ptr_->__get(__index_) == __value; }
|
bool operator==(const __simd_reference& __value) const { return _Vp(*this) == _Vp(__value); }
|
||||||
|
|
||||||
bool operator!=(_Vp __value) const { return __ptr_->__get(__index_) != __value; }
|
bool operator!=(const __simd_reference& __value) const { return _Vp(*this) != _Vp(__value); }
|
||||||
|
|
||||||
|
bool operator<(_Vp __value) const { return _Vp(*this) < __value; }
|
||||||
|
|
||||||
|
bool operator<=(_Vp __value) const { return _Vp(*this) <= __value; }
|
||||||
|
|
||||||
|
bool operator>(_Vp __value) const { return _Vp(*this) > __value; }
|
||||||
|
|
||||||
|
bool operator>=(_Vp __value) const { return _Vp(*this) >= __value; }
|
||||||
|
|
||||||
|
bool operator==(_Vp __value) const { return _Vp(*this) == __value; }
|
||||||
|
|
||||||
|
bool operator!=(_Vp __value) const { return _Vp(*this) != __value; }
|
||||||
};
|
};
|
||||||
|
template <class _Vp, class _Tp, class _Abi>
|
||||||
|
inline bool operator<(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a < _Vp(b); }
|
||||||
|
template <class _Vp, class _Tp, class _Abi>
|
||||||
|
inline bool operator<=(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a <= _Vp(b); }
|
||||||
|
template <class _Vp, class _Tp, class _Abi>
|
||||||
|
inline bool operator>(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a > _Vp(b); }
|
||||||
|
template <class _Vp, class _Tp, class _Abi>
|
||||||
|
inline bool operator>=(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a >= _Vp(b); }
|
||||||
|
template <class _Vp, class _Tp, class _Abi>
|
||||||
|
inline bool operator==(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a == _Vp(b); }
|
||||||
|
template <class _Vp, class _Tp, class _Abi>
|
||||||
|
inline bool operator!=(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a != _Vp(b); }
|
||||||
|
|
||||||
template <class _Tp, class _Abi>
|
template <class _Tp, class _Abi>
|
||||||
class __simd_mask_reference {
|
class __simd_mask_reference {
|
||||||
|
|
Loading…
Reference in New Issue