From 37da0bd76dad694697adcbad8c9d693340c32921 Mon Sep 17 00:00:00 2001 From: Brett Date: Wed, 1 May 2024 21:25:29 -0400 Subject: [PATCH] support vectors with 1/(vec) --- CMakeLists.txt | 2 +- include/blt/math/vectors.h | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 413556b..93185fd 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.18) +set(BLT_VERSION 0.16.19) 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 ef0a971..061362c 100644 --- a/include/blt/math/vectors.h +++ b/include/blt/math/vectors.h @@ -292,20 +292,20 @@ namespace blt } template - inline constexpr vec operator+(const vec& left, T f) + inline constexpr vec operator+(const vec& left, T right) { vec initializer{}; for (blt::u32 i = 0; i < size; i++) - initializer[i] = left[i] + f; + initializer[i] = left[i] + right; return initializer; } template - inline constexpr vec operator-(const vec& left, T f) + inline constexpr vec operator-(const vec& left, T right) { vec initializer{}; for (blt::u32 i = 0; i < size; i++) - initializer[i] = left[i] + f; + initializer[i] = left[i] + right; return initializer; } @@ -337,11 +337,11 @@ namespace blt } template - inline constexpr vec operator*(const vec& left, T f) + inline constexpr vec operator*(const vec& left, T right) { vec initializer{}; for (blt::u32 i = 0; i < size; i++) - initializer[i] = left[i] * f; + initializer[i] = left[i] * right; return initializer; } @@ -355,11 +355,20 @@ namespace blt } template - inline constexpr vec operator/(const vec& left, T f) + inline constexpr vec operator/(const vec& left, T right) { vec initializer{}; for (blt::u32 i = 0; i < size; i++) - initializer[i] = left[i] / f; + initializer[i] = left[i] / right; + return initializer; + } + + template + inline constexpr vec operator/(T left, const vec& right) + { + vec initializer{}; + for (blt::u32 i = 0; i < size; i++) + initializer[i] = left / right[i]; return initializer; }