Skip to content

Commit c8cede6

Browse files
author
RubioJr9
committed
Fixed disappearing scene.
1 parent db06eda commit c8cede6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 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);
@@ -76,7 +76,13 @@ void ArcBall::setLocationOnSphere(glm::vec3 location, glm::vec3 up)
7676
//------------------------------------------------------------------------------
7777
glm::quat ArcBall::quatFromUnitSphere(const glm::vec3& from, const glm::vec3& to)
7878
{
79-
glm::vec3 axis = glm::normalize(glm::cross(from, to));
79+
glm::vec3 cross = glm::cross(from, to);
80+
glm::vec3 axis = glm::normalize(cross);
81+
82+
// Give arbitrary non-zero vector because no rotation
83+
if (glm::length(cross) == 0.0)
84+
axis = from;
85+
8086
float angle = std::acos(glm::dot(from, to));
8187

8288
if(angle <= 0.00001)

0 commit comments

Comments
 (0)