Update lazyvec / vec api as well as rect are mostly constexpr now

This commit is contained in:
2026-03-22 00:15:14 +01:00
parent 4db5d98cb2
commit b49c0bd3dc
10 changed files with 108 additions and 105 deletions
+28 -28
View File
@@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// This file is generated by lazyvec 2.0.0
// This file is generated by lazyvec 2.1.0
#include <pd/common.hpp>
// Extended includes (rename if you use other filenames/paths)
@@ -84,7 +84,7 @@ class vec4 {
// Operations
template <typename T1>
vec4<T>& operator+=(T1 v) {
constexpr vec4<T>& operator+=(T1 v) {
x += (T)v;
y += (T)v;
z += (T)v;
@@ -93,7 +93,7 @@ class vec4 {
}
template <typename T1>
vec4<T>& operator+=(const vec4<T1>& v) {
constexpr vec4<T>& operator+=(const vec4<T1>& v) {
x += (T)v.x;
y += (T)v.y;
z += (T)v.z;
@@ -102,17 +102,17 @@ class vec4 {
}
template <typename T1>
vec4<T> operator+(T1 v) const {
constexpr vec4<T> operator+(T1 v) const {
return vec4<T>(x + (T)v, y + (T)v, z + (T)v, w + (T)v);
}
template <typename T1>
vec4<T> operator+(const vec4<T1>& v) const {
constexpr vec4<T> operator+(const vec4<T1>& v) const {
return vec4<T>(x + (T)v.x, y + (T)v.y, z + (T)v.z, w + (T)v.w);
}
template <typename T1>
vec4<T>& operator-=(T1 v) {
constexpr vec4<T>& operator-=(T1 v) {
x -= (T)v;
y -= (T)v;
z -= (T)v;
@@ -121,7 +121,7 @@ class vec4 {
}
template <typename T1>
vec4<T>& operator-=(const vec4<T1>& v) {
constexpr vec4<T>& operator-=(const vec4<T1>& v) {
x -= (T)v.x;
y -= (T)v.y;
z -= (T)v.z;
@@ -130,17 +130,17 @@ class vec4 {
}
template <typename T1>
vec4<T> operator-(T1 v) const {
constexpr vec4<T> operator-(T1 v) const {
return vec4<T>(x - (T)v, y - (T)v, z - (T)v, w - (T)v);
}
template <typename T1>
vec4<T> operator-(const vec4<T1>& v) const {
constexpr vec4<T> operator-(const vec4<T1>& v) const {
return vec4<T>(x - (T)v.x, y - (T)v.y, z - (T)v.z, w - (T)v.w);
}
template <typename T1>
vec4<T>& operator*=(T1 v) {
constexpr vec4<T>& operator*=(T1 v) {
x *= (T)v;
y *= (T)v;
z *= (T)v;
@@ -149,7 +149,7 @@ class vec4 {
}
template <typename T1>
vec4<T>& operator*=(const vec4<T1>& v) {
constexpr vec4<T>& operator*=(const vec4<T1>& v) {
x *= (T)v.x;
y *= (T)v.y;
z *= (T)v.z;
@@ -158,17 +158,17 @@ class vec4 {
}
template <typename T1>
vec4<T> operator*(T1 v) const {
constexpr vec4<T> operator*(T1 v) const {
return vec4<T>(x * (T)v, y * (T)v, z * (T)v, w * (T)v);
}
template <typename T1>
vec4<T> operator*(const vec4<T1>& v) const {
constexpr vec4<T> operator*(const vec4<T1>& v) const {
return vec4<T>(x * (T)v.x, y * (T)v.y, z * (T)v.z, w * (T)v.w);
}
template <typename T1>
vec4<T>& operator/=(T1 v) {
constexpr vec4<T>& operator/=(T1 v) {
x /= (T)v;
y /= (T)v;
z /= (T)v;
@@ -177,7 +177,7 @@ class vec4 {
}
template <typename T1>
vec4<T>& operator/=(const vec4<T1>& v) {
constexpr vec4<T>& operator/=(const vec4<T1>& v) {
x /= (T)v.x;
y /= (T)v.y;
z /= (T)v.z;
@@ -186,31 +186,31 @@ class vec4 {
}
template <typename T1>
vec4<T> operator/(T1 v) const {
constexpr vec4<T> operator/(T1 v) const {
return vec4<T>(x / (T)v, y / (T)v, z / (T)v, w / (T)v);
}
template <typename T1>
vec4<T> operator/(const vec4<T1>& v) const {
constexpr vec4<T> operator/(const vec4<T1>& v) const {
return vec4<T>(x / (T)v.x, y / (T)v.y, z / (T)v.z, w / (T)v.w);
}
// Generic Operations
vec4 operator-() const { return vec4(-x, -y, -z, -w); }
constexpr vec4 operator-() const { return vec4(-x, -y, -z, -w); }
template <typename T1>
bool operator==(const vec4<T1>& v) const {
constexpr bool operator==(const vec4<T1>& v) const {
return x == (T)v.x && y == (T)v.y && z == (T)v.z && w == (T)v.w;
}
template <typename T1>
bool operator!=(const vec4<T1>& v) const {
constexpr bool operator!=(const vec4<T1>& v) const {
return !(*this == v);
}
// Functions
double Len() const { return std::sqrt(SqLen()); }
double SqLen() const { return x * x + y * y + z * z + w * w; }
constexpr double SqLen() const { return x * x + y * y + z * z + w * w; }
template <typename T1>
double Distance(const vec4<T1>& v) const {
@@ -226,37 +226,37 @@ class vec4 {
}
template <typename T1>
T Dot(const vec4<T1>& v) const {
constexpr T Dot(const vec4<T1>& v) const {
return x * (T)v.x + y * (T)v.y + z * (T)v.z + w * (T)v.w;
}
// Swap Functions
void SwapXY() {
constexpr void SwapXY() {
T t = x;
x = y;
y = t;
}
void SwapXZ() {
constexpr void SwapXZ() {
T t = x;
x = z;
z = t;
}
void SwapXW() {
constexpr void SwapXW() {
T t = x;
x = w;
w = t;
}
void SwapYZ() {
constexpr void SwapYZ() {
T t = y;
y = z;
z = t;
}
void SwapYW() {
constexpr void SwapYW() {
T t = y;
y = w;
w = t;
}
void SwapZW() {
constexpr void SwapZW() {
T t = z;
z = w;
w = t;