mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
improvement
This commit is contained in:
@@ -4,7 +4,6 @@ target_sources(omath PRIVATE
|
||||
color.cpp
|
||||
Vector4.cpp
|
||||
Vector2.cpp
|
||||
Triangle3d.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(prediction)
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
#include "omath/Triangle3d.hpp"
|
||||
|
||||
|
||||
namespace omath
|
||||
{
|
||||
Triangle3d::Triangle3d(const Vector3 &vertex1, const Vector3 &vertex2, const Vector3 &vertex3)
|
||||
: m_vertex1(vertex1), m_vertex2(vertex2), m_vertex3(vertex3)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Vector3 Triangle3d::CalculateNormal() const
|
||||
{
|
||||
return (m_vertex1 - m_vertex2).Cross(m_vertex3 - m_vertex1).Normalized();
|
||||
}
|
||||
|
||||
float Triangle3d::SideALength() const
|
||||
{
|
||||
return m_vertex1.DistTo(m_vertex2);
|
||||
}
|
||||
|
||||
float Triangle3d::SideBLength() const
|
||||
{
|
||||
return m_vertex3.DistTo(m_vertex2);
|
||||
}
|
||||
|
||||
Vector3 Triangle3d::SideAVector() const
|
||||
{
|
||||
return m_vertex1 - m_vertex2;
|
||||
}
|
||||
|
||||
Vector3 Triangle3d::SideBVector() const
|
||||
{
|
||||
return m_vertex3 - m_vertex2;
|
||||
}
|
||||
Vector3 Triangle3d::MidPoint() const
|
||||
{
|
||||
return (m_vertex1 + m_vertex2 + m_vertex3) / 3;
|
||||
}
|
||||
} // namespace omath
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace omath::collision
|
||||
{
|
||||
bool LineTracer::CanTraceLine(const Ray &ray, const Triangle3d &triangle)
|
||||
bool LineTracer::CanTraceLine(const Ray& ray, const Triangle<Vector3>& triangle)
|
||||
{
|
||||
return GetRayHitPoint(ray, triangle) == ray.end;
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace omath::collision
|
||||
return DirectionVector().Normalized();
|
||||
}
|
||||
|
||||
Vector3 LineTracer::GetRayHitPoint(const Ray &ray, const Triangle3d &triangle)
|
||||
Vector3 LineTracer::GetRayHitPoint(const Ray& ray, const Triangle<Vector3>& triangle)
|
||||
{
|
||||
constexpr float kEpsilon = std::numeric_limits<float>::epsilon();
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace omath::collision
|
||||
const auto u = t.Dot(p) * invDet;
|
||||
|
||||
|
||||
if ((u < 0 && std::abs(u) > kEpsilon) || (u > 1 && std::abs(u-1) > kEpsilon))
|
||||
if ((u < 0 && std::abs(u) > kEpsilon) || (u > 1 && std::abs(u - 1) > kEpsilon))
|
||||
return ray.end;
|
||||
|
||||
const auto q = t.Cross(sideA);
|
||||
@@ -59,4 +59,4 @@ namespace omath::collision
|
||||
|
||||
return ray.start + rayDir * tHit;
|
||||
}
|
||||
}
|
||||
} // namespace omath::collision
|
||||
|
||||
Reference in New Issue
Block a user