48 lines
1.0 KiB
C++
48 lines
1.0 KiB
C++
|
/***
|
||
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||
|
|
||
|
File: auVector.hpp
|
||
|
Date: 2022-2-1
|
||
|
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<int N>
|
||
|
struct AuFVec
|
||
|
{
|
||
|
float elements[N];
|
||
|
|
||
|
inline bool operator ==(const AuFVec<N> &other) const
|
||
|
{
|
||
|
return AuMemcmp(other.elements, elements, sizeof(elements)) == 0;
|
||
|
}
|
||
|
|
||
|
inline float operator [](int idx) const
|
||
|
{
|
||
|
return elements[N];
|
||
|
}
|
||
|
|
||
|
inline float &operator [](int idx)
|
||
|
{
|
||
|
return elements[N];
|
||
|
}
|
||
|
};
|
||
|
|
||
|
using AuVec3 = AuFVec<3>;
|
||
|
using AuVec4 = AuFVec<4>;
|
||
|
#else
|
||
|
#include <glm/glm.hpp>
|
||
|
|
||
|
using AuVec3 = glm::vec3;
|
||
|
using AuVec4 = glm::vec4;
|
||
|
#endif
|