diff --git a/Matrix.hpp b/Matrix.hpp index 10485da..ac9f0ba 100644 --- a/Matrix.hpp +++ b/Matrix.hpp @@ -317,9 +317,10 @@ inline Mat33f getRotationMatrix(const Vec3f& axis, const float angle) { // (0,0,1) -> dir rotator inline Mat33f getRotatorTo(const Vec3f& dir) { - const Vec3f up(0, 0, 1); - if (dir == up) { - return Mat33f::identity(); + Vec3f up(0, 0, 1); + const float dot = dotProd(dir, up); + if (fabs(dot) > 0.999999f) { + up = Vec3f(1, 0, 0); } const Vec3f x = normalize(crossProd(up, dir)); diff --git a/UniformGrid.hpp b/UniformGrid.hpp index 34558c7..bd07afb 100644 --- a/UniformGrid.hpp +++ b/UniformGrid.hpp @@ -57,7 +57,8 @@ class UniformGrid { Idxs dims_; public: - UniformGrid() = default; + UniformGrid() + : dims_(0) {} UniformGrid(const Idxs& dims) : dims_(dims) {