add return statement to matrix class
parent
94624bddec
commit
4b0226929b
|
@ -62,6 +62,7 @@ namespace blt {
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
data.single[i] = copy.data.single[i];
|
data.single[i] = copy.data.single[i];
|
||||||
}
|
}
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit mat4x4(const float dat[16]) {
|
explicit mat4x4(const float dat[16]) {
|
||||||
|
|
|
@ -23,12 +23,7 @@ namespace blt {
|
||||||
#define MSVC_COMPILER (!defined(__GNUC__) && !defined(__clang__))
|
#define MSVC_COMPILER (!defined(__GNUC__) && !defined(__clang__))
|
||||||
|
|
||||||
|
|
||||||
#ifdef MSVC_COMPILER
|
|
||||||
template<typename T, uint32_t size>
|
template<typename T, uint32_t size>
|
||||||
#else
|
|
||||||
// STFINAE is broken in MSVC?
|
|
||||||
template<typename T, uint32_t size, typename std::enable_if<std::is_arithmetic<T>::value>::type* = nullptr>
|
|
||||||
#endif
|
|
||||||
struct vec {
|
struct vec {
|
||||||
private:
|
private:
|
||||||
T elements[size]{};
|
T elements[size]{};
|
||||||
|
@ -159,7 +154,9 @@ namespace blt {
|
||||||
return dot;
|
return dot;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline constexpr vec<T, size> cross(const vec<T, size>& left, const vec<T, size>& right) {
|
static inline constexpr vec<T, size> cross(
|
||||||
|
const vec<T, size>& left, const vec<T, size>& right
|
||||||
|
) {
|
||||||
// cross is only defined on vectors of size 3. 2D could be implemented, which is a TODO
|
// cross is only defined on vectors of size 3. 2D could be implemented, which is a TODO
|
||||||
static_assert(size == 3);
|
static_assert(size == 3);
|
||||||
return {left.y() * right.z() - left.z() * right.y(),
|
return {left.y() * right.z() - left.z() * right.y(),
|
||||||
|
@ -167,7 +164,9 @@ namespace blt {
|
||||||
left.x() * right.y() - left.y() * right.x()};
|
left.x() * right.y() - left.y() * right.x()};
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline constexpr vec<T, size> project(const vec<T, size>& u, const vec<T, size>& v){
|
static inline constexpr vec<T, size> project(
|
||||||
|
const vec<T, size>& u, const vec<T, size>& v
|
||||||
|
) {
|
||||||
T du = dot(u);
|
T du = dot(u);
|
||||||
T dv = dot(v);
|
T dv = dot(v);
|
||||||
return (du / dv) * v;
|
return (du / dv) * v;
|
||||||
|
@ -313,7 +312,7 @@ namespace blt {
|
||||||
|
|
||||||
// Gram-Schmidt orthonormalization algorithm
|
// Gram-Schmidt orthonormalization algorithm
|
||||||
static inline void gramSchmidt(std::vector<vec3>& vectors) {
|
static inline void gramSchmidt(std::vector<vec3>& vectors) {
|
||||||
int n = (int)vectors.size();
|
int n = (int) vectors.size();
|
||||||
std::vector<vec3> basis;
|
std::vector<vec3> basis;
|
||||||
|
|
||||||
// normalize first vector
|
// normalize first vector
|
||||||
|
|
Loading…
Reference in New Issue