From 715ab680e68f62a3a00777e81b18f8e64110058d Mon Sep 17 00:00:00 2001 From: ladevieq Date: Tue, 12 Jul 2022 22:16:26 +0200 Subject: Fix BVH & vec3 API --- src/vec3.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/vec3.cpp') diff --git a/src/vec3.cpp b/src/vec3.cpp index 096dde0..43431fc 100644 --- a/src/vec3.cpp +++ b/src/vec3.cpp @@ -16,7 +16,7 @@ vec3::vec3(const vec3 &vec) { v = _mm_load_ps((float *)&vec.v); } vec3::vec3(const vec3 &&vec) { v = _mm_load_ps((float *)&vec.v); } -vec3 vec3::operator-() const { return vec3(_mm_xor_ps(v, _mm_set1_ps(-0.0f))); } +vec3 vec3::operator-() const { return { _mm_xor_ps(v, _mm_set1_ps(-0.0f)) }; } vec3 &vec3::operator=(const vec3 &vec) { v = _mm_load_ps((float *)&vec.v); @@ -68,16 +68,12 @@ vec3 vec3::cross(const vec3 &vec) const { return _mm_sub_ps(tmp3, tmp4); } -vec3 &vec3::min(const vec3 &vec) { - v = _mm_min_ps(v, vec.v); - - return *this; +vec3 vec3::min(const vec3 &vec) const { + return { _mm_min_ps(v, vec.v) }; } -vec3 &vec3::max(const vec3 &vec) { - v = _mm_max_ps(v, vec.v); - - return *this; +vec3 vec3::max(const vec3 &vec) const { + return { _mm_max_ps(v, vec.v) }; } vec3 &vec3::normalize() { @@ -96,9 +92,9 @@ void vec3::print() const { printf("%f %f %f\n", v[0], v[1], v[2]); } -vec3 vec3::random() { return vec3{randd(), randd(), randd()}; } +vec3 vec3::random() { return { randd(), randd(), randd() }; } -vec3 vec3::random(float min, float max) { return vec3{randd(min, max), randd(min, max), randd(min, max)}; } +vec3 vec3::random(float min, float max) { return { randd(min, max), randd(min, max), randd(min, max) }; } // TODO: Use simd instructions -- cgit v1.3