diff --git a/src/light.h b/src/light.h index 08817779..b8ba8865 100644 --- a/src/light.h +++ b/src/light.h @@ -34,9 +34,9 @@ struct LightType } m_value; - static char const *GetName(Value v) + String ToString() { - switch (v) + switch (m_value) { case Directional: return ""; diff --git a/src/lol/math/geometry.h b/src/lol/math/geometry.h index 296b049d..76fe152c 100644 --- a/src/lol/math/geometry.h +++ b/src/lol/math/geometry.h @@ -296,16 +296,11 @@ bool TestRayVsPlane(const TV &ray_p0, const TV &ray_p1, } /* A safe enum for Primitive edge face. */ -struct PlaneIntersection -{ - DEF_VALUE - ADD_VALUE(Back) - ADD_VALUE(Front) - ADD_VALUE(Plane) - END_E_VALUE - - LOL_DECLARE_ENUM_METHODS(PlaneIntersection) -}; +LOL_SAFE_ENUM(PlaneIntersection, + Back, + Front, + Plane, +); //Point/Plane : Normal must be given normalized. template diff --git a/src/utils.h b/src/utils.h index 77e8040d..9a5c2816 100644 --- a/src/utils.h +++ b/src/utils.h @@ -59,19 +59,16 @@ template< class T > inline int GetRandom(Array src) return (r_total > .0f)?(r_j):(-1); } -//Gets the value for the given safe-enum, considering you have implemented what follows : -//NEEDS : Contructor(Value) -//NEEDS : static char const *GetName(Value v) -//NEEDS : T::Max -template< class T > inline T FindValue(const char* name) +// Gets the value for the given LOL_SAFE_ENUM type. +template inline T FindValue(const char* name) { String n = name; n.ToLower(); for (int i = 0; i < T::Max; ++i) { - String s = T::GetName(typename T::Value(i)); - if (s.ToLower().IndexOf(n.C()) > -1) - return T(typename T::Value(i)); + String s = T(i).ToString().ToLower(); + if (s == n) + return T(i); } return T::Max; }