Various bug fixes

This commit is contained in:
Jack Andersen 2018-06-21 14:33:34 -10:00
parent d9e88babe2
commit b54121ed9c
3 changed files with 8 additions and 7 deletions

View File

@ -12,7 +12,7 @@ public:
CSphere(const CVector3f& position, float radius) : position(position), radius(radius) {}
inline CVector3f getSurfaceNormal(const CVector3f& coord) const { return (position - coord).normalized(); }
inline CVector3f getSurfaceNormal(const CVector3f& coord) const { return (coord - position).normalized(); }
inline bool intersects(const CSphere& other)
{

View File

@ -309,8 +309,8 @@ CQuaternion CQuaternion::shortestRotationArc(const zeus::CVector3f& v0, const ze
}
else
{
float w = (1.f + zeus::clamp(-1.f, v0N.dot(v1N), 1.f)) * 2.f;
return CQuaternion(0.5f * w, cross * (1.f / std::sqrt(w)));
float w = std::sqrt((1.f + zeus::clamp(-1.f, v0N.dot(v1N), 1.f)) * 2.f);
return CQuaternion(0.5f * w, cross * (1.f / w));
}
}

View File

@ -180,11 +180,12 @@ CTransform lookAt(const CVector3f& pos, const CVector3f& lookPos, const CVector3
return CTransform(rmBasis, pos);
}
CVector3f getBezierPoint(const CVector3f& a, const CVector3f& b, const CVector3f& c, const CVector3f& d, float t)
CVector3f getBezierPoint(const CVector3f& a, const CVector3f& b,
const CVector3f& c, const CVector3f& d, float t)
{
const float oneMinusTime = (1.0 - t);
return (a * oneMinusTime * oneMinusTime) + (b * 3.f * t * oneMinusTime) + (c * 3.f * t * t * oneMinusTime) +
(d * t * t * t);
const float omt = 1.f - t;
return ((a * omt + b * t) * omt + (b * omt + c * t) * t) * omt +
((b * omt + c * t) * omt + (c * omt + d * t) * t) * t;
}
int floorPowerOfTwo(int x)