mirror of https://github.com/AxioDL/zeus.git
Add CLine
This commit is contained in:
parent
726fff8299
commit
76e20eb4c8
|
@ -74,6 +74,7 @@ add_library(zeus
|
|||
include/zeus/CFrustum.hpp
|
||||
include/zeus/CAABox.hpp
|
||||
include/zeus/COBBox.hpp
|
||||
include/zeus/CLine.hpp
|
||||
include/zeus/CLineSeg.hpp
|
||||
include/zeus/CSphere.hpp
|
||||
include/zeus/CUnitVector.hpp
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef CLINE_HPP
|
||||
#define CLINE_HPP
|
||||
|
||||
#include "Global.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
||||
namespace zeus
|
||||
{
|
||||
class CLine
|
||||
{
|
||||
public:
|
||||
CLine(const CVector3f& origin, const CVector3f& dir) : origin(origin), dir(dir) {}
|
||||
CVector3f origin;
|
||||
CVector3f dir;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef CLINE_HPP
|
||||
#define CLINE_HPP
|
||||
#ifndef CLINESEG_HPP
|
||||
#define CLINESEG_HPP
|
||||
|
||||
#include "Global.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
|
@ -13,12 +13,12 @@ public:
|
|||
{
|
||||
CVector3f tmp = (end - start).normalized();
|
||||
if (tmp.x != 0 || tmp.y != 0 || tmp.z != 0)
|
||||
normal = tmp.normalized();
|
||||
dir = tmp.normalized();
|
||||
else
|
||||
normal = CVector3f::skZero;
|
||||
dir = CVector3f::skZero;
|
||||
}
|
||||
|
||||
CVector3f normal;
|
||||
CVector3f dir;
|
||||
CVector3f start;
|
||||
CVector3f end;
|
||||
};
|
||||
|
|
|
@ -8,30 +8,32 @@ namespace zeus
|
|||
{
|
||||
struct CMRay
|
||||
{
|
||||
CMRay(const CVector3f& start, const CVector3f& end, float d) : start(start), d(d), invD(1.f / d), end(end)
|
||||
CMRay(const CVector3f& start, const CVector3f& dirin, float len)
|
||||
: start(start), length(len), invLength(1.f / len), dir(dirin)
|
||||
{
|
||||
normal = start + (d * end);
|
||||
delta = normal - start;
|
||||
end = start + (len * dirin);
|
||||
delta = dirin - start;
|
||||
}
|
||||
|
||||
CMRay(const CVector3f& start, const CVector3f& norm, float d, float invD) : start(start), normal(norm), d(d), invD(invD)
|
||||
CMRay(const CVector3f& start, const CVector3f& end, float len, float invLen)
|
||||
: start(start), end(end), length(len), invLength(invLen)
|
||||
{
|
||||
delta = normal - start;
|
||||
end = invD * delta;
|
||||
delta = end - start;
|
||||
dir = invLen * delta;
|
||||
}
|
||||
|
||||
CMRay getInvUnscaledTransformRay(const CTransform& xfrm) const
|
||||
{
|
||||
const CTransform inv = xfrm.inverse();
|
||||
return CMRay(inv * start, inv * normal, d, invD);
|
||||
return CMRay(inv * start, inv * end, length, invLength);
|
||||
}
|
||||
|
||||
CVector3f start; // x0
|
||||
CVector3f normal; // xc
|
||||
CVector3f end; // xc
|
||||
CVector3f delta; // x18
|
||||
float d; // x24
|
||||
float invD; // x28
|
||||
CVector3f end; // x2c
|
||||
float length; // x24
|
||||
float invLength; // x28
|
||||
CVector3f dir; // x2c
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class alignas(16) CPlane
|
|||
public:
|
||||
ZE_DECLARE_ALIGNED_ALLOCATOR();
|
||||
|
||||
inline CPlane() {}
|
||||
inline CPlane() : a(1.f), d(0.f) {}
|
||||
CPlane(float a, float b, float c, float d) : a(a), b(b), c(c), d(d) {}
|
||||
CPlane(const CVector3f& a, const CVector3f& b, const CVector3f& c)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue