diff --git a/changes.txt b/changes.txt index 2d9a97d..47da246 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) +- vector3d scalar operator/ and operator/= no longer multiply by the inverse but use the expected division. + Costs some speed, but fixes floating point troubles caused by this optimization (like x/x no longer being 1.0). - Bugfix: XML reader dropped last character in strings if there was a special character replacement for the second-last character. - Avoid allocating more than 16k on stack in OCT loader. Also avoid potential heap overwrites in there. - obj file loader now allows using mtl files with spaces in the filename. diff --git a/include/vector3d.h b/include/vector3d.h index c348cd7..ebea7c4 100644 --- a/include/vector3d.h +++ b/include/vector3d.h @@ -54,8 +54,8 @@ namespace core vector3d operator/(const vector3d& other) const { return vector3d(X / other.X, Y / other.Y, Z / other.Z); } vector3d& operator/=(const vector3d& other) { X/=other.X; Y/=other.Y; Z/=other.Z; return *this; } - vector3d operator/(const T v) const { T i=(T)1.0/v; return vector3d(X * i, Y * i, Z * i); } - vector3d& operator/=(const T v) { T i=(T)1.0/v; X*=i; Y*=i; Z*=i; return *this; } + vector3d operator/(const T v) const { return vector3d(X/v, Y/v, Z/v); } + vector3d& operator/=(const T v) { X/=v; Y/=v; Z/=v; return *this; } T& operator [](u32 index) { diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index 93887ee..6cf9531 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 72 tests of 72 passed. Compiled as DEBUG -Test suite pass at GMT Sat Jan 22 16:40:25 2022 +Test suite pass at GMT Thu Feb 03 14:40:09 2022