Skip to content
Permalink
Browse files

Merge pull request #2001 from RubioJr9/disappearing_scene

Closes #1990
  • Loading branch information...
dcwhite committed Oct 7, 2019
2 parents 5deb514 + 275efdf commit 1c761994188b2a74b277244bc1df20407f4ee6c8
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/Externals/spire/arc-ball/ArcBall.cpp
@@ -60,7 +60,7 @@ void ArcBall::drag(const glm::vec2& msc)
glm::vec3 mVSphereNow = mouseOnSphere((mScreenToTCS * glm::vec4(msc, 0.0, 1.0)).xyz());

// Construct a quaternion from two points on the unit sphere.
glm:: quat mQDrag = quatFromUnitSphere(mVSphereDown, mVSphereNow);
glm::quat mQDrag = quatFromUnitSphere(mVSphereDown, mVSphereNow);
mQNow = mQDrag * mQDown;
if(glm::dot(mVSphereDown, mVSphereNow) < 0.0)
beginDrag(msc);
@@ -77,9 +77,14 @@ void ArcBall::setLocationOnSphere(glm::vec3 location, glm::vec3 up)
glm::quat ArcBall::quatFromUnitSphere(const glm::vec3& from, const glm::vec3& to)
{
glm::vec3 axis = glm::normalize(glm::cross(from, to));

// Give arbitrary non-zero vector because no rotation
if (std::isnan(axis[0]))
axis = from;

float angle = std::acos(glm::dot(from, to));

if(angle <= 0.00001)
if(angle <= 0.00001 || std::isnan(angle))
return glm::quat(1.0, 0.0, 0.0, 0.0);

return glm::angleAxis(angle, axis);

0 comments on commit 1c76199

Please sign in to comment.
You can’t perform that action at this time.