Parcourir la source

Mesh CSG update.

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> il y a 11 ans
Parent
révision
fe877b6509
1 fichiers modifiés avec 33 ajouts et 0 suppressions
  1. +33
    -0
      src/lol/math/geometry.h

+ 33
- 0
src/lol/math/geometry.h Voir le fichier

@@ -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>


Chargement…
Annuler
Enregistrer