vec silly

v1
Brett 2024-05-01 21:12:16 -04:00
parent e6b4c4a330
commit 8a5794cfee
2 changed files with 47 additions and 1 deletions

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
include(cmake/color.cmake) include(cmake/color.cmake)
set(BLT_VERSION 0.16.17) set(BLT_VERSION 0.16.18)
set(BLT_TEST_VERSION 0.0.1) set(BLT_TEST_VERSION 0.0.1)
set(BLT_TARGET BLT) set(BLT_TARGET BLT)

View File

@ -423,6 +423,52 @@ namespace blt
return color4{r, g, b, 1.0f}; return color4{r, g, b, 1.0f};
} }
template<typename ValueType, u32 size>
inline blt::vec<ValueType, 2> make_vec2(const blt::vec<ValueType, size>& t, size_t fill = 0)
{
if constexpr (size >= 2)
{
return blt::vec<ValueType, 2>(t.x(), t.y());
} else
{
return blt::vec<ValueType, 2>(t.x(), fill);
}
}
template<typename ValueType, u32 size>
inline blt::vec<ValueType, 3> make_vec3(const blt::vec<ValueType, size>& t, size_t fill = 0)
{
if constexpr (size >= 3)
{
return blt::vec<ValueType, 3>(t.x(), t.y(), t.z());
} else
{
blt::vec<ValueType, 3> ret;
for (size_t i = 0; i < size; i++)
ret[i] = t[i];
for (size_t i = size; i < 3; i++)
ret[i] = fill;
return ret;
}
}
template<typename ValueType, u32 size>
inline blt::vec<ValueType, 4> make_vec4(const blt::vec<ValueType, size>& t, size_t fill = 0)
{
if constexpr (size >= 4)
{
return blt::vec<ValueType, 4>(t.x(), t.y(), t.z(), t.w());
} else
{
blt::vec<ValueType, 4> ret;
for (size_t i = 0; i < size; i++)
ret[i] = t[i];
for (size_t i = size; i < 4; i++)
ret[i] = fill;
return ret;
}
}
namespace vec_algorithm namespace vec_algorithm
{ {
static inline void findOrthogonalBasis(const vec3& v, vec3& v1, vec3& v2, vec3& v3) static inline void findOrthogonalBasis(const vec3& v, vec3& v1, vec3& v2, vec3& v3)