diff --git a/CMakeLists.txt b/CMakeLists.txt index 64dce66..413556b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.20) 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_TARGET BLT) diff --git a/include/blt/math/vectors.h b/include/blt/math/vectors.h index cd03f7d..ef0a971 100644 --- a/include/blt/math/vectors.h +++ b/include/blt/math/vectors.h @@ -423,6 +423,52 @@ namespace blt return color4{r, g, b, 1.0f}; } + template + inline blt::vec make_vec2(const blt::vec& t, size_t fill = 0) + { + if constexpr (size >= 2) + { + return blt::vec(t.x(), t.y()); + } else + { + return blt::vec(t.x(), fill); + } + } + + template + inline blt::vec make_vec3(const blt::vec& t, size_t fill = 0) + { + if constexpr (size >= 3) + { + return blt::vec(t.x(), t.y(), t.z()); + } else + { + blt::vec 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 + inline blt::vec make_vec4(const blt::vec& t, size_t fill = 0) + { + if constexpr (size >= 4) + { + return blt::vec(t.x(), t.y(), t.z(), t.w()); + } else + { + blt::vec 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 { static inline void findOrthogonalBasis(const vec3& v, vec3& v1, vec3& v2, vec3& v3)