AuROXTL/Include/auROXTL/auVector.hpp

73 lines
1.7 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auVector.hpp
Date: 2022-2-1
File: AuroraUtils.hpp
File: auROXTLUtils.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
#if defined(__has_include) && !defined(_AUHAS_GLM) && defined(_AU_DETECT_GLM)
#if __has_include(<glm/glm.hpp>)
#define _AUHAS_GLM
#endif
#endif
#if !defined(_AUHAS_GLM)
static int AuMemcmp(const void *dest, const void *src, size_t n);
template <typename T, int N>
struct AuGVec
{
T elements[N];
inline bool operator ==(const AuGVec &other) const
{
return AuMemcmp(other.elements, elements, sizeof(elements)) == 0;
}
inline T operator [](AuUInt idx) const
{
return elements[idx];
}
inline T &operator [](AuUInt idx)
{
return elements[idx];
}
};
template <int N>
using AuFVec = AuGVec<float, N>;
template <int N>
using AuDVec = AuGVec<double, N>;
using AuVecF2 = AuFVec<2>;
using AuVecF3 = AuFVec<3>;
using AuVecF4 = AuFVec<4>;
using AuVecD2 = AuDVec<2>;
using AuVecD3 = AuDVec<3>;
using AuVecD4 = AuDVec<4>;
using AuVec2 = AuVecF2;
using AuVec3 = AuVecF3;
using AuVec4 = AuVecF4;
#else
#include <glm/glm.hpp>
using AuVecF2 = glm::vec2;
using AuVecF3 = glm::vec3;
using AuVecF4 = glm::vec4;
using AuVecD2 = glm::vec<2, double, glm::defaultp>;
using AuVecD3 = glm::vec<3, double, glm::defaultp>;
using AuVecD4 = glm::vec<4, double, glm::defaultp>;
using AuVec2 = AuVecF2;
using AuVec3 = AuVecF3;
using AuVec4 = AuVecF4;
#endif