File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/Externals/spire/arc-ball Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff 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// ------------------------------------------------------------------------------
7777glm::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 )
You can’t perform that action at this time.
0 commit comments