From ee96d2668d7ec85a3e02f0bd66c4a17d24f64ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20=E2=80=98Touky=E2=80=99=20Huet?= Date: Sat, 22 Mar 2014 18:16:45 +0000 Subject: [PATCH] Added basic crude array funcs --- src/lol/base/array.h | 32 ++++++++++++++++++++++++++++++++ src/lol/math/geometry.h | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/lol/base/array.h b/src/lol/base/array.h index 2eaa2685..849ed930 100644 --- a/src/lol/base/array.h +++ b/src/lol/base/array.h @@ -192,6 +192,38 @@ public: return false; } + //PushFirst, insert, etc : CRUDE VERSION + inline void PushFirst(T const &x) + { + ArrayBase 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 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) { for (int i = 0; i < m_count; ++i) diff --git a/src/lol/math/geometry.h b/src/lol/math/geometry.h index 7ce01909..82c80047 100644 --- a/src/lol/math/geometry.h +++ b/src/lol/math/geometry.h @@ -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); - if (!test_line_only && (t < -TestEpsilon::Get() || t > 1.0f)) + if (!test_line_only && (t < -TestEpsilon::Get() || t > 1.f + TestEpsilon::Get())) return false; isec_p = ray_p0 + t * ray_dir;