Browse Source

Added basic crude array funcs

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

+ 32
- 0
src/lol/base/array.h View File

@@ -192,6 +192,38 @@ public:
return false; return false;
} }


//PushFirst, insert, etc : CRUDE VERSION
inline void PushFirst(T const &x)
{
ArrayBase<T, ARRAY> tmp;
tmp.Push(x);
tmp += *this;
*this = tmp;
}

inline bool PushUniqueFirst(T const &x)
{
int idx = Find(x);
if (idx == INDEX_NONE)
{
PushFirst(x);
return true;
}
return false;
}

inline void Insert(T const &x, int pos)
{
ArrayBase<T, ARRAY> tmp;
for (int i = 0; i < m_count; i++)
{
if (i == pos)
tmp.Push(x);
tmp.Push(m_data[i]);
}
*this = tmp;
}

inline int Find(T const &x) inline int Find(T const &x)
{ {
for (int i = 0; i < m_count; ++i) for (int i = 0; i < m_count; ++i)


+ 1
- 1
src/lol/math/geometry.h View File

@@ -254,7 +254,7 @@ bool TestRayVsPlane(const TV &ray_p0, const TV &ray_p1,


float t = (dot(ProjectPointOnPlane(ray_p0, plane_p, plane_n) - ray_p0, plane_n)) / dot(ray_dir, plane_n); float t = (dot(ProjectPointOnPlane(ray_p0, plane_p, plane_n) - ray_p0, plane_n)) / dot(ray_dir, plane_n);


if (!test_line_only && (t < -TestEpsilon::Get() || t > 1.0f))
if (!test_line_only && (t < -TestEpsilon::Get() || t > 1.f + TestEpsilon::Get()))
return false; return false;


isec_p = ray_p0 + t * ray_dir; isec_p = ray_p0 + t * ray_dir;


Loading…
Cancel
Save