summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debugdraw.cpp15
-rw-r--r--debugdraw.hpp1
2 files changed, 16 insertions, 0 deletions
diff --git a/debugdraw.cpp b/debugdraw.cpp
index 43527ab..8331a38 100644
--- a/debugdraw.cpp
+++ b/debugdraw.cpp
@@ -67,6 +67,21 @@ void Line_Renderer::add_line(const v3f& s, const v3f& e) {
cur++;
}
+void Line_Renderer::add_arrow(const v3f& s, const v3f& e) {
+ v3f tang(0.0f, 1.0f, 0.0f);
+ v3f dir = v3f::normalised(e - s);
+ v4f dir4 = v4f(dir, 0.0f);
+ float d = v3f::dot(tang, dir);
+ if (d > 0.999f || d < -0.999f)
+ tang = v3f(1.0f, 0.0f, 0.0f);
+ tang = v3f::cross(tang, dir);
+ const m4f a = m4f::rotate(m4f::identity(), 2.8f, tang);
+ const m4f b = m4f::rotate(m4f::identity(), 3.5f, tang);
+ add_line(s, e);
+ add_line(e, e + (a * dir4).xyz() * 0.1f);
+ add_line(e, e + (b * dir4).xyz() * 0.1f);
+}
+
void Line_Renderer::add_box(const AABB& b) {
add_line(v3f(b.max.x, b.max.y, b.max.z), v3f(b.max.x, b.max.y, b.min.z));
add_line(v3f(b.max.x, b.max.y, b.max.z), v3f(b.max.x, b.min.y, b.max.z));
diff --git a/debugdraw.hpp b/debugdraw.hpp
index e5142dc..0463eb3 100644
--- a/debugdraw.hpp
+++ b/debugdraw.hpp
@@ -30,6 +30,7 @@ struct Line_Renderer {
void begin(int wi, int he);
void colour(const v3f& c);
void add_line(const v3f& s, const v3f& e);
+ void add_arrow(const v3f& s, const v3f& e);
void add_box(const AABB& b);
void flush(
const Camera& cam,