From 0987464cf99120b6728949496ee41bd14a35b225 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sat, 24 Dec 2022 17:08:15 +0800 Subject: Make it compile with MSVC. --- vec.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'vec.h') diff --git a/vec.h b/vec.h index 99f5f46..a9b72c3 100644 --- a/vec.h +++ b/vec.h @@ -53,11 +53,11 @@ struct vec3 { } vec3 operator+(const vec3 &b) const { - return vec3{.x=x + b.x, .y=y + b.y, .z=z + b.z}; + return vec3{x + b.x, y + b.y, z + b.z}; } vec3 operator-() const { - return vec3{.x = -x, .y = -y, .z = -z}; + return vec3{-x, -y, -z}; } vec3 operator-(const vec3 &b) const { @@ -75,12 +75,12 @@ struct vec3 { // cross product (aka outer product, or vector product, producing a vector) vec3 cross(const vec3 &b) const { - return vec3{.x=y * b.z - z * b.y, .y=z * b.x - x * b.z, .z=x * b.y - y * b.x}; + return vec3{y * b.z - z * b.y, z * b.x - x * b.z, x * b.y - y * b.x}; } // Multiply with b on every dimension. vec3 scale(const vec3 &b) const { - return vec3{.x=x * b.x, .y=y * b.y, .z=z * b.z}; + return vec3{x * b.x, y * b.y, z * b.z}; } // norm value @@ -140,7 +140,7 @@ inline vec3 operator*(const vec3 &vec, const S &b) { if (std::is_floating_point::value) { assert(std::isfinite(b));; } - return vec3{.x=(T) (vec.x * b), .y=(T) (vec.y * b), .z=(T) (vec.z * b)}; + return vec3{(T) (vec.x * b), (T) (vec.y * b), (T) (vec.z * b)}; } // product vec3 by a scalar, with fp assertions @@ -152,7 +152,7 @@ inline vec3 operator*(const S &b, const vec3 &vec) { if (std::is_floating_point::value) { assert(std::isfinite(b)); } - return vec3{.x=(T) (vec.x * b), .y=(T) (vec.y * b), .z=(T) (vec.z * b)}; + return vec3{(T) (vec.x * b), (T) (vec.y * b), (T) (vec.z * b)}; } // product vec3 by the inversion of a scalar (div by a scalar), with fp assertions @@ -166,7 +166,7 @@ inline vec3 operator/(const vec3 &vec, const S &b) { assert(std::isfinite(b)); assert(b != 0); } - return vec3{.x=(T) (vec.x / b), .y=(T) (vec.y / b), .z=(T) (vec.z / b)}; + return vec3{(T) (vec.x / b), (T) (vec.y / b), (T) (vec.z / b)}; } // scalar product (inner product) @@ -208,7 +208,7 @@ public: inline vec3 range01() { while (true) { const auto x = uni(mt), y = uni(mt), z = uni(mt); - const auto vec = vec3{.x=x, .y=y, .z=z}; + const auto vec = vec3{x, y, z}; if (vec.mod2() <= 1.0) return vec.unit_vec(); } } -- cgit v1.2.3