Przeglądaj źródła

base: port all existing codebase to safe enums where absolutely required.

undefined
Sam Hocevar 10 lat temu
rodzic
commit
99db2f0c11
3 zmienionych plików z 12 dodań i 20 usunięć
  1. +2
    -2
      src/light.h
  2. +5
    -10
      src/lol/math/geometry.h
  3. +5
    -8
      src/utils.h

+ 2
- 2
src/light.h Wyświetl plik

@@ -34,9 +34,9 @@ struct LightType
}
m_value;

static char const *GetName(Value v)
String ToString()
{
switch (v)
switch (m_value)
{
case Directional:
return "<Directional>";


+ 5
- 10
src/lol/math/geometry.h Wyświetl plik

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


+ 5
- 8
src/utils.h Wyświetl plik

@@ -59,19 +59,16 @@ template< class T > inline int GetRandom(Array<T> 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<class T> 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;
}


Ładowanie…
Anuluj
Zapisz