Skip to content

Commit 18dfd89

Browse files
authored
Merge branch 'master' into qt4-tag
2 parents aa1911a + 1c76199 commit 18dfd89

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Externals/spire/arc-ball/ArcBall.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void ArcBall::drag(const glm::vec2& msc)
6060
glm::vec3 mVSphereNow = mouseOnSphere((mScreenToTCS * glm::vec4(msc, 0.0, 1.0)).xyz());
6161

6262
// Construct a quaternion from two points on the unit sphere.
63-
glm:: quat mQDrag = quatFromUnitSphere(mVSphereDown, mVSphereNow);
63+
glm::quat mQDrag = quatFromUnitSphere(mVSphereDown, mVSphereNow);
6464
mQNow = mQDrag * mQDown;
6565
if(glm::dot(mVSphereDown, mVSphereNow) < 0.0)
6666
beginDrag(msc);
@@ -77,9 +77,14 @@ void ArcBall::setLocationOnSphere(glm::vec3 location, glm::vec3 up)
7777
glm::quat ArcBall::quatFromUnitSphere(const glm::vec3& from, const glm::vec3& to)
7878
{
7979
glm::vec3 axis = glm::normalize(glm::cross(from, to));
80+
81+
// Give arbitrary non-zero vector because no rotation
82+
if (std::isnan(axis[0]))
83+
axis = from;
84+
8085
float angle = std::acos(glm::dot(from, to));
8186

82-
if(angle <= 0.00001)
87+
if(angle <= 0.00001 || std::isnan(angle))
8388
return glm::quat(1.0, 0.0, 0.0, 0.0);
8489

8590
return glm::angleAxis(angle, axis);

0 commit comments

Comments
 (0)