Translation gizmo transform functionality implemented

This commit is contained in:
parax0
2015-08-19 21:01:58 -04:00
parent 08dbdb337a
commit 63c8351dcf
23 changed files with 567 additions and 107 deletions

View File

@@ -3,6 +3,11 @@
namespace Math
{
float Abs(float v)
{
return fabs(v);
}
float Pow(float Base, float Exponent)
{
return pow(Base, Exponent);
@@ -15,6 +20,23 @@ float Distance(const CVector3f& A, const CVector3f& B)
Pow(B.z - A.z, 2.f) );
}
std::pair<bool,float> RayPlaneIntersecton(const CRay& ray, const CPlane& plane)
{
// Code based on ray/plane intersect code from Ogre
// https://bitbucket.org/sinbad/ogre/src/197116fd2ac62c57cdeed1666f9866c3dddd4289/OgreMain/src/OgreMath.cpp?at=default#OgreMath.cpp-350
// Are ray and plane parallel?
float denom = plane.Normal().Dot(ray.Direction());
if (Abs(denom) < FLT_EPSILON)
return std::pair<bool,float>(false, 0.f);
// Not parallel
float nom = plane.Normal().Dot(ray.Origin()) + plane.Dist();
float t = -(nom / denom);
return std::pair<bool,float>(t >= 0.f, t);
}
std::pair<bool,float> RayBoxIntersection(const CRay& Ray, const CAABox& Box)
{
// Code slightly modified from Ogre