Browse Source

Mesh CSG update.

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 10 years ago
parent
commit
fe877b6509
1 changed files with 33 additions and 0 deletions
  1. +33
    -0
      src/lol/math/geometry.h

+ 33
- 0
src/lol/math/geometry.h View File

@@ -261,6 +261,39 @@ bool TestRayVsPlane(const TV &ray_p0, const TV &ray_p1,
return true;
}

/* A safe enum for Primitive edge face. */
struct PlaneIntersection
{
enum Value
{
Invalid=-1,
Back,
Front,
Plane,

MAX
}
m_value;

inline PlaneIntersection() : m_value(Invalid) {}
inline PlaneIntersection(Value v) : m_value(v) {}
inline PlaneIntersection(int v) : m_value((Value)v) {}
inline operator Value() { return m_value; }
};

//Point/Plane : Normal must be given normalized.
template <typename TV>
PlaneIntersection TestPointVsPlane(const TV &point, const TV &plane_p, const TV &plane_n)
{
float d = dot(normalize(point - plane_p), plane_n);
if (d > TestEpsilon::Get())
return PlaneIntersection::Front;
else if (d < -TestEpsilon::Get())
return PlaneIntersection::Back;
else
return PlaneIntersection::Plane;
}

//Project points functions
//Plane
template <typename TV>


Loading…
Cancel
Save