Browse Source

DebugDrawContext pass

Seems to still build in lol, will check other works to be sure
legacy
touky 8 years ago
parent
commit
575ef8e497
6 changed files with 330 additions and 326 deletions
  1. +36
    -0
      doc/tutorial/02_cube.cpp
  2. +136
    -181
      src/debug/lines.cpp
  3. +149
    -88
      src/lol/debug/lines.h
  4. +1
    -1
      src/lolimgui.cpp
  5. +7
    -49
      src/scene.cpp
  6. +1
    -7
      src/scene.h

+ 36
- 0
doc/tutorial/02_cube.cpp View File

@@ -44,6 +44,22 @@ public:
4, 5, 1, 1, 0, 4, 3, 2, 6, 6, 7, 3, }),
m_ready(false)
{
m_camera = new Camera();
m_camera->SetProjection(mat4::perspective(radians(30.f), 960.f, 600.f, .1f, 1000.f));
m_camera->SetView(mat4::lookat(vec3(-15.f, 5.f, 0.f),
vec3(0.f, -1.f, 0.f),
vec3(0.f, 1.f, 0.f)));
Scene& scene = Scene::GetScene();
scene.PushCamera(m_camera);
Ticker::Ref(m_camera);

}

~Cube()
{
Scene& scene = Scene::GetScene();
scene.PopCamera(m_camera);
Ticker::Unref(m_camera);
}

virtual void TickGame(float seconds)
@@ -58,6 +74,25 @@ public:
mat4 proj = mat4::perspective(radians(45.0f), 640.0f, 480.0f, 0.1f, 10.0f);

m_matrix = proj * view * model * anim;

{
auto context0 = Debug::DrawContext::New(Color::red);
{
auto context1 = Debug::DrawContext::New(Color::blue);
Debug::DrawBox(box3(vec3(0.f), vec3(1.2f)));
Debug::DrawGrid(vec3(0.f), vec3::axis_x, vec3::axis_y, vec3::axis_z, 10.0f);
{
auto context2 = Debug::DrawContext::New(context0);
Debug::DrawBox(box3(vec3(0.f), vec3(1.3f)));
}
{
auto context2 = Debug::DrawContext::New(context0);
context2.SetColor(Color::yellow);
Debug::DrawBox(box3(vec3(-1.f), vec3(1.4f)));
}
}
Debug::DrawBox(box3(vec3(0.f), vec3(1.1f)));
}
}

virtual void TickDraw(float seconds, Scene &scene)
@@ -115,6 +150,7 @@ public:
}

private:
Camera* m_camera = nullptr;
float m_angle;
mat4 m_matrix;
array<vec3,vec3> m_mesh;


+ 136
- 181
src/debug/lines.cpp View File

@@ -12,60 +12,14 @@

namespace lol
{
Debug::DrawContext::Data Debug::DrawContext::m_global = Debug::DrawContext::Data(vec4(1.f));

//Resets draw infos
void Debug::DrawSetupReset()
{
Scene& scene = Scene::GetScene();
scene.SetLineTime();
scene.SetLineMask();
}
//Sets draw infos
void Debug::DrawSetupTime(float new_time)
{
Scene& scene = Scene::GetScene();
scene.SetLineTime(new_time);
}

//--
void Debug::DrawSetupMask(int new_mask)
{
Scene& scene = Scene::GetScene();
scene.SetLineMask(new_mask);
}

//--
void Debug::DrawSetupSegment(float new_segment_size)
{
Scene& scene = Scene::GetScene();
scene.SetLineSegmentSize(new_segment_size);
}

//--
void Debug::DrawSetupColor(vec4 color)
{
Scene& scene = Scene::GetScene();
scene.SetLineColor(color);
}

//--
void Debug::DrawSetup(float new_time, int new_mask, float segment_size, vec4 color)
{
Debug::DrawSetupTime(new_time);
Debug::DrawSetupMask(new_mask);
Debug::DrawSetupSegment(segment_size);
Debug::DrawSetupColor(color);
}
typedef Debug::DrawContext DC;
typedef Debug::DrawContext::Data DCD;

//Screen to world conversion
vec3 Debug::WorldToScreen(vec3 pos)
{
return Debug::WorldToScreen(vec4(pos, 1.f));
}
vec3 Debug::WorldToScreen(vec3 pos, mat4 view_proj)
{
return Debug::WorldToScreen(vec4(pos, 1.f), view_proj);
}
vec3 Debug::WorldToScreen(vec3 pos) { return Debug::WorldToScreen(vec4(pos, 1.f)); }
vec3 Debug::WorldToScreen(vec3 pos, mat4 view_proj) { return Debug::WorldToScreen(vec4(pos, 1.f), view_proj); }
vec3 Debug::WorldToScreen(vec4 pos)
{
Scene& scene = Scene::GetScene();
@@ -81,8 +35,7 @@ vec3 Debug::WorldToScreen(vec4 pos, mat4 view_proj)
}

//--
vec3 Debug::ScreenToWorld(vec2 pos, float z)
{ return Debug::ScreenToWorld(vec3(pos, z)); }
vec3 Debug::ScreenToWorld(vec2 pos, float z) { return Debug::ScreenToWorld(vec3(pos, z)); }
vec3 Debug::ScreenToWorld(vec3 pos)
{
Scene& scene = Scene::GetScene();
@@ -91,8 +44,7 @@ vec3 Debug::ScreenToWorld(vec3 pos)
mat4 const inv_view_proj = inverse(scene.GetCamera()->GetProjection() * scene.GetCamera()->GetView());
return Debug::ScreenToWorld(pos, inv_view_proj);
}
vec3 Debug::ScreenToWorld(vec2 pos, mat4 inv_view_proj, float z)
{ return Debug::ScreenToWorld(vec3(pos, z), inv_view_proj); }
vec3 Debug::ScreenToWorld(vec2 pos, mat4 inv_view_proj, float z) { return Debug::ScreenToWorld(vec3(pos, z), inv_view_proj); }
vec3 Debug::ScreenToWorld(vec3 pos, mat4 inv_view_proj)
{
vec4 screen_pos = inv_view_proj * vec4(pos, 1.f);
@@ -107,12 +59,16 @@ vec3 Debug::ScreenToWorld(vec3 pos, mat4 view, mat4 proj)
//Draw stuff in World
//-- LINE: 3D -2D - 3D_to_2D --------------------------------------------------

void Debug::DrawLine(vec3 a, vec3 b) { Scene& scene = Scene::GetScene(); Debug::DrawLine(a, b, scene.GetLineColor()); }
void Debug::DrawLine(vec2 a, vec3 b, float az) { Scene& scene = Scene::GetScene(); Debug::DrawLine(a, b, scene.GetLineColor(), az); }
void Debug::DrawLine(vec2 a, vec2 b, float az, float bz) { Scene& scene = Scene::GetScene(); Debug::DrawLine(a, b, scene.GetLineColor(), az, bz); }
void Debug::DrawLine(vec3 a, vec3 b, vec4 color) { Scene& scene = Scene::GetScene(); scene.AddLine(a, b, color); }
void Debug::DrawLine(vec2 a, vec3 b, vec4 color, float az) { Scene& scene = Scene::GetScene(); scene.AddLine(vec3(a, az), b, color); }
void Debug::DrawLine(vec2 a, vec2 b, vec4 color, float az, float bz){ Scene& scene = Scene::GetScene(); scene.AddLine(vec3(a, az), vec3(b, bz), color); }
//Root func
void Debug::DrawLine(vec3 a, vec3 b, DCD data)
{
Scene::GetScene().AddLine(a, b, data.m_color, data.m_duration, data.m_mask);
}
void Debug::DrawLine(vec2 a, vec3 b, DCD data, float az) { DrawLine(vec3(a, az), b, data); }
void Debug::DrawLine(vec2 a, vec2 b, DCD data, float az, float bz) { DrawLine(vec3(a, az), vec3(b, bz), data); }
void Debug::DrawLine(vec3 a, vec3 b) { DrawLine(a, b, DC::GetGlobalData()); }
void Debug::DrawLine(vec2 a, vec3 b, float az) { DrawLine(a, b, DC::GetGlobalData(), az); }
void Debug::DrawLine(vec2 a, vec2 b, float az, float bz) { DrawLine(a, b, DC::GetGlobalData(), az, bz); }

//-- GIZMO --------------------------------------------------------------------
void Debug::DrawGizmo(vec3 pos, vec3 x, vec3 y, vec3 z, float size)
@@ -131,8 +87,7 @@ void Debug::DrawGizmo(vec2 pos, vec3 x, vec3 y, vec3 z, float size, float posz)
//-- GRID ---------------------------------------------------------------------
void Debug::DrawGrid(vec3 pos, vec3 x, vec3 y, vec3 z, float size, bool draw_3d)
{
Scene& scene = Scene::GetScene();
float seg_sz = scene.GetLineSegmentSize();
float seg_sz = DC::GetGlobalData().m_segment_size;
int seg_nb = lol::max((int)(size / seg_sz), 1);
seg_sz = size / (float)seg_nb;

@@ -165,38 +120,38 @@ void Debug::DrawGrid(vec3 pos, vec3 x, vec3 y, vec3 z, float size, bool draw_3d)
}

//-- ARROW: 3D -2D - 3D_to_2D -------------------------------------------------
void Debug::DrawArrow(vec3 a, vec3 b, vec2 s) { Debug::DrawArrow(a, b, vec3(s.x, s.y, s.y)); }
void Debug::DrawArrow(vec2 a, vec3 b, vec2 s, float az) { Debug::DrawArrow(a, b.xy, vec3(s.x, s.y, s.y), az, b.z); }
void Debug::DrawArrow(vec2 a, vec2 b, vec2 s, float az, float bz) { Debug::DrawArrow(a, b, vec3(s.x, s.y, s.y), az, bz); }
void Debug::DrawArrow(vec3 a, vec3 b, vec3 s) { Scene& scene = Scene::GetScene(); Debug::DrawArrow(a, b, vec3(s.x, s.y, s.y), scene.GetLineColor()); }
void Debug::DrawArrow(vec2 a, vec3 b, vec3 s, float az) { Scene& scene = Scene::GetScene(); Debug::DrawArrow(a, b.xy, vec3(s.x, s.y, s.y), scene.GetLineColor(), az, b.z); }
void Debug::DrawArrow(vec2 a, vec2 b, vec3 s, float az, float bz) { Scene& scene = Scene::GetScene(); Debug::DrawArrow(a, b, vec3(s.x, s.y, s.y), scene.GetLineColor(), az, bz); }
void Debug::DrawArrow(vec3 a, vec3 b, vec3 s, vec4 color)
void Debug::DrawArrow(vec3 a, vec3 b, vec2 s) { Debug::DrawArrow(a, b, vec3(s.x, s.y, s.y)); }
void Debug::DrawArrow(vec2 a, vec3 b, vec2 s, float az) { Debug::DrawArrow(a, b.xy, vec3(s.x, s.y, s.y), az, b.z); }
void Debug::DrawArrow(vec2 a, vec2 b, vec2 s, float az, float bz) { Debug::DrawArrow(a, b, vec3(s.x, s.y, s.y), az, bz); }
void Debug::DrawArrow(vec3 a, vec3 b, vec3 s) { Debug::DrawArrow(a, b, vec3(s.x, s.y, s.y), DC::GetGlobalData()); }
void Debug::DrawArrow(vec2 a, vec3 b, vec3 s, float az) { Debug::DrawArrow(a, b.xy, vec3(s.x, s.y, s.y), DC::GetGlobalData(), az, b.z); }
void Debug::DrawArrow(vec2 a, vec2 b, vec3 s, float az, float bz) { Debug::DrawArrow(a, b, vec3(s.x, s.y, s.y), DC::GetGlobalData(), az, bz); }
void Debug::DrawArrow(vec3 a, vec3 b, vec3 s, DCD data)
{
vec3 z = s.x * normalize(b - a);
vec3 x = s.z * orthonormal(b - a);
vec3 y = s.y * cross(normalize(x), normalize(z));

Debug::DrawLine(a, b, color);
Debug::DrawLine(b, b - z + x, color);
Debug::DrawLine(b, b - z - x, color);
Debug::DrawLine(b, b - z + y, color);
Debug::DrawLine(b, b - z - y, color);
Debug::DrawLine(a, b, data);
Debug::DrawLine(b, b - z + x, data);
Debug::DrawLine(b, b - z - x, data);
Debug::DrawLine(b, b - z + y, data);
Debug::DrawLine(b, b - z - y, data);

Debug::DrawLine(b - z + x, b - z + y, color);
Debug::DrawLine(b - z + x, b - z - y, color);
Debug::DrawLine(b - z - x, b - z + y, color);
Debug::DrawLine(b - z - x, b - z - y, color);
Debug::DrawLine(b - z + x, b - z + y, data);
Debug::DrawLine(b - z + x, b - z - y, data);
Debug::DrawLine(b - z - x, b - z + y, data);
Debug::DrawLine(b - z - x, b - z - y, data);

Debug::DrawLine(b - z + x, b - z - x, color);
Debug::DrawLine(b - z + y, b - z - y, color);
Debug::DrawLine(b - z + x, b - z - x, data);
Debug::DrawLine(b - z + y, b - z - y, data);
}
void Debug::DrawArrow(vec2 a, vec3 b, vec3 s, vec4 color, float az)
void Debug::DrawArrow(vec2 a, vec3 b, vec3 s, DCD data, float az)
{
vec3 bn = Debug::WorldToScreen(b);
DrawArrow(a, bn.xy, s, color, az, bn.z);
DrawArrow(a, bn.xy, s, data, az, bn.z);
}
void Debug::DrawArrow(vec2 a, vec2 b, vec3 s, vec4 color, float az, float bz)
void Debug::DrawArrow(vec2 a, vec2 b, vec3 s, DCD data, float az, float bz)
{
vec3 an = vec3(a, az);
vec3 bn = vec3(b, bz);
@@ -204,40 +159,40 @@ void Debug::DrawArrow(vec2 a, vec2 b, vec3 s, vec4 color, float az, float bz)
vec3 x = s.z * orthonormal(bn - an);
vec3 y = s.y * cross(normalize(x), normalize(z));

Debug::DrawLine(a, b, color, az, bz);
Debug::DrawLine(b, b - (z + x).xy, color, bz, bz - (z + x).z);
Debug::DrawLine(b, b - (z - x).xy, color, bz, bz - (z - x).z);
Debug::DrawLine(b, b - (z + y).xy, color, bz, bz - (z + y).z);
Debug::DrawLine(b, b - (z - y).xy, color, bz, bz - (z - y).z);
Debug::DrawLine(a, b, data, az, bz);
Debug::DrawLine(b, b - (z + x).xy, data, bz, bz - (z + x).z);
Debug::DrawLine(b, b - (z - x).xy, data, bz, bz - (z - x).z);
Debug::DrawLine(b, b - (z + y).xy, data, bz, bz - (z + y).z);
Debug::DrawLine(b, b - (z - y).xy, data, bz, bz - (z - y).z);

Debug::DrawLine(b - (z + x).xy, b - (z + y).xy, color, bz - (z + x).z, bz - (z + y).z);
Debug::DrawLine(b - (z + x).xy, b - (z - y).xy, color, bz - (z + x).z, bz - (z - y).z);
Debug::DrawLine(b - (z - x).xy, b - (z + y).xy, color, bz - (z - x).z, bz - (z + y).z);
Debug::DrawLine(b - (z - x).xy, b - (z - y).xy, color, bz - (z - x).z, bz - (z - y).z);
Debug::DrawLine(b - (z + x).xy, b - (z + y).xy, data, bz - (z + x).z, bz - (z + y).z);
Debug::DrawLine(b - (z + x).xy, b - (z - y).xy, data, bz - (z + x).z, bz - (z - y).z);
Debug::DrawLine(b - (z - x).xy, b - (z + y).xy, data, bz - (z - x).z, bz - (z + y).z);
Debug::DrawLine(b - (z - x).xy, b - (z - y).xy, data, bz - (z - x).z, bz - (z - y).z);

Debug::DrawLine(b - (z + x).xy, b - (z - x).xy, color, bz - (z + x).z, bz - (z - x).z);
Debug::DrawLine(b - (z + y).xy, b - (z - y).xy, color, bz - (z + y).z, bz - (z - y).z);
Debug::DrawLine(b - (z + x).xy, b - (z - x).xy, data, bz - (z + x).z, bz - (z - x).z);
Debug::DrawLine(b - (z + y).xy, b - (z - y).xy, data, bz - (z + y).z, bz - (z - y).z);
}

//-- BOX: 3D -2D - 3D_to_2D ---------------------------------------------------
void Debug::DrawBox(box3 a) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a.aa, a.bb, scene.GetLineColor()); }
void Debug::DrawBox(box2 a) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a.aa, a.bb, scene.GetLineColor()); }
void Debug::DrawBox(box3 a, vec4 color) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a.aa, a.bb, color); }
void Debug::DrawBox(box2 a, vec4 color) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a.aa, a.bb, color); }
void Debug::DrawBox(vec3 a, vec3 b) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a, b, scene.GetLineColor()); }
void Debug::DrawBox(vec2 a, vec2 b) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a, b, scene.GetLineColor()); }
void Debug::DrawBox(vec2 a, float s) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a, s, scene.GetLineColor()); }
void Debug::DrawBox(vec3 a, vec3 b, vec4 color) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a, b, mat4::identity, color); }
void Debug::DrawBox(vec2 a, vec2 b, vec4 color) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a, b, mat2::identity, color); }
void Debug::DrawBox(vec2 a, float s, vec4 color) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a, s, mat2::identity, color); }
void Debug::DrawBox(box3 a, mat4 transform) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a.aa, a.bb, transform, scene.GetLineColor()); }
void Debug::DrawBox(box2 a, mat2 transform) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a.aa, a.bb, transform, scene.GetLineColor()); }
void Debug::DrawBox(box3 a, mat4 transform, vec4 color) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a.aa, a.bb, transform, color); }
void Debug::DrawBox(box2 a, mat2 transform, vec4 color) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a.aa, a.bb, transform, color); }
void Debug::DrawBox(vec3 a, vec3 b, mat4 transform) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a, b, transform, scene.GetLineColor()); }
void Debug::DrawBox(vec2 a, vec2 b, mat2 transform) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a, b, transform, scene.GetLineColor()); }
void Debug::DrawBox(vec2 a, float s, mat2 transform) { Scene& scene = Scene::GetScene(); Debug::DrawBox(a, s, transform, scene.GetLineColor()); }
void Debug::DrawBox(vec3 a, vec3 b, mat4 transform, vec4 color)
void Debug::DrawBox(box3 a) { Debug::DrawBox(a.aa, a.bb, DC::GetGlobalData()); }
void Debug::DrawBox(box2 a) { Debug::DrawBox(a.aa, a.bb, DC::GetGlobalData()); }
void Debug::DrawBox(box3 a, DCD data) { Debug::DrawBox(a.aa, a.bb, data); }
void Debug::DrawBox(box2 a, DCD data) { Debug::DrawBox(a.aa, a.bb, data); }
void Debug::DrawBox(vec3 a, vec3 b) { Debug::DrawBox(a, b, DC::GetGlobalData()); }
void Debug::DrawBox(vec2 a, vec2 b) { Debug::DrawBox(a, b, DC::GetGlobalData()); }
void Debug::DrawBox(vec2 a, float s) { Debug::DrawBox(a, s, DC::GetGlobalData()); }
void Debug::DrawBox(vec3 a, vec3 b, DCD data) { Debug::DrawBox(a, b, mat4::identity, data); }
void Debug::DrawBox(vec2 a, vec2 b, DCD data) { Debug::DrawBox(a, b, mat2::identity, data); }
void Debug::DrawBox(vec2 a, float s, DCD data) { Debug::DrawBox(a, s, mat2::identity, data); }
void Debug::DrawBox(box3 a, mat4 transform) { Debug::DrawBox(a.aa, a.bb, transform, DC::GetGlobalData()); }
void Debug::DrawBox(box2 a, mat2 transform) { Debug::DrawBox(a.aa, a.bb, transform, DC::GetGlobalData()); }
void Debug::DrawBox(box3 a, mat4 transform, DCD data) { Debug::DrawBox(a.aa, a.bb, transform, data); }
void Debug::DrawBox(box2 a, mat2 transform, DCD data) { Debug::DrawBox(a.aa, a.bb, transform, data); }
void Debug::DrawBox(vec3 a, vec3 b, mat4 transform) { Debug::DrawBox(a, b, transform, DC::GetGlobalData()); }
void Debug::DrawBox(vec2 a, vec2 b, mat2 transform) { Debug::DrawBox(a, b, transform, DC::GetGlobalData()); }
void Debug::DrawBox(vec2 a, float s, mat2 transform) { Debug::DrawBox(a, s, transform, DC::GetGlobalData()); }
void Debug::DrawBox(vec3 a, vec3 b, mat4 transform, DCD data)
{
vec4 v[8];
for (int i = 0; i < 8; i++)
@@ -252,12 +207,12 @@ void Debug::DrawBox(vec3 a, vec3 b, mat4 transform, vec4 color)
{
int j = ((i & 1) << 1) | ((i >> 1) ^ 1);

Debug::DrawLine((transform * v[i]).xyz, (transform * v[i + 4]).xyz, color);
Debug::DrawLine((transform * v[i]).xyz, (transform * v[j]).xyz, color);
Debug::DrawLine((transform * v[i + 4]).xyz, (transform * v[j + 4]).xyz, color);
Debug::DrawLine((transform * v[i]).xyz, (transform * v[i + 4]).xyz, data);
Debug::DrawLine((transform * v[i]).xyz, (transform * v[j]).xyz, data);
Debug::DrawLine((transform * v[i + 4]).xyz, (transform * v[j + 4]).xyz, data);
}
}
void Debug::DrawBox(vec2 a, vec2 b, mat2 transform, vec4 color)
void Debug::DrawBox(vec2 a, vec2 b, mat2 transform, DCD data)
{
vec2 v[4];
v[0] = a;
@@ -266,41 +221,41 @@ void Debug::DrawBox(vec2 a, vec2 b, mat2 transform, vec4 color)
v[3] = vec2(b.x, a.y);

int i = 0;
Debug::DrawLine((transform * v[0]).xy, (transform * v[1]).xy, color);
Debug::DrawLine((transform * v[1]).xy, (transform * v[2]).xy, color);
Debug::DrawLine((transform * v[2]).xy, (transform * v[3]).xy, color);
Debug::DrawLine((transform * v[3]).xy, (transform * v[0]).xy, color);
Debug::DrawLine((transform * v[0]).xy, (transform * v[1]).xy, data);
Debug::DrawLine((transform * v[1]).xy, (transform * v[2]).xy, data);
Debug::DrawLine((transform * v[2]).xy, (transform * v[3]).xy, data);
Debug::DrawLine((transform * v[3]).xy, (transform * v[0]).xy, data);
}
void Debug::DrawBox(vec2 a, float s, mat2 transform, vec4 color)
void Debug::DrawBox(vec2 a, float s, mat2 transform, DCD data)
{
vec2 b = s * vec2(1.f, Renderer::Get()->GetXYRatio());
Debug::DrawBox(a - b, a + b, transform, color);
Debug::DrawBox(a - b, a + b, transform, data);
}

//-- CIRCLE -------------------------------------------------------------------
void Debug::DrawCircle(vec2 a, float s) { Scene& scene = Scene::GetScene(); Debug::DrawCircle(a, s * vec2(1.f, Renderer::Get()->GetXYRatio()), scene.GetLineColor()); }
void Debug::DrawCircle(vec3 a, vec3 n) { Scene& scene = Scene::GetScene(); Debug::DrawCircle(a, n, scene.GetLineColor()); }
void Debug::DrawCircle(vec2 a, vec2 s) { Scene& scene = Scene::GetScene(); Debug::DrawCircle(a, s * vec2(1.f, Renderer::Get()->GetXYRatio()), scene.GetLineColor()); }
void Debug::DrawCircle(vec3 a, vec3 x, vec3 y) { Scene& scene = Scene::GetScene(); Debug::DrawCircle(a, x, y, scene.GetLineColor()); }
void Debug::DrawCircle(vec2 a, vec2 x, vec2 y) { Scene& scene = Scene::GetScene(); Debug::DrawCircle(a, x, y, scene.GetLineColor()); }
void Debug::DrawCircle(vec3 a, vec3 n, vec4 color)
void Debug::DrawCircle(vec2 a, float s) { Debug::DrawCircle(a, s * vec2(1.f, Renderer::Get()->GetXYRatio()), DC::GetGlobalData()); }
void Debug::DrawCircle(vec3 a, vec3 n) { Debug::DrawCircle(a, n, DC::GetGlobalData()); }
void Debug::DrawCircle(vec2 a, vec2 s) { Debug::DrawCircle(a, s * vec2(1.f, Renderer::Get()->GetXYRatio()), DC::GetGlobalData()); }
void Debug::DrawCircle(vec3 a, vec3 x, vec3 y) { Debug::DrawCircle(a, x, y, DC::GetGlobalData()); }
void Debug::DrawCircle(vec2 a, vec2 x, vec2 y) { Debug::DrawCircle(a, x, y, DC::GetGlobalData()); }
void Debug::DrawCircle(vec3 a, vec3 n, DCD data)
{
vec3 x = orthogonal(n);
vec3 y = cross(normalize(n), normalize(x)) * length(n);
DrawCircle(a, x, y, color);
DrawCircle(a, x, y, data);
}
void Debug::DrawCircle(vec2 a, vec2 s, vec4 color)
void Debug::DrawCircle(vec2 a, vec2 s, DCD data)
{
vec2 x = vec2::axis_x * s.x;
vec2 y = vec2::axis_y * s.y;
DrawCircle(a, x, y, color);
DrawCircle(a, x, y, data);
}
//--
void Debug::DrawCircle(vec3 a, vec3 x, vec3 y, vec4 color)
void Debug::DrawCircle(vec3 a, vec3 x, vec3 y, DCD data)
{
Scene& scene = Scene::GetScene();
float size = F_PI * 2.f * lol::max(length(x), length(y));
int segment_nb = lol::max(1, (int)((size * .25f) / scene.GetLineSegmentSize()));
int segment_nb = lol::max(1, (int)((size * .25f) / data.m_segment_size));
for (int i = 0; i < segment_nb; i++)
{
float a0 = (((float)i) / (float)segment_nb) * F_PI_2;
@@ -308,18 +263,18 @@ void Debug::DrawCircle(vec3 a, vec3 x, vec3 y, vec4 color)
vec2 p0 = vec2(lol::cos(a0), lol::sin(a0));
vec2 p1 = vec2(lol::cos(a1), lol::sin(a1));

Debug::DrawLine(a + p0.x * x + p0.y * y, a + p1.x * x + p1.y * y, color);
Debug::DrawLine(a + p0.x * -x + p0.y * -y, a + p1.x * -x + p1.y * -y, color);
Debug::DrawLine(a + p0.x * x + p0.y * -y, a + p1.x * x + p1.y * -y, color);
Debug::DrawLine(a + p0.x * -x + p0.y * y, a + p1.x * -x + p1.y * y, color);
Debug::DrawLine(a + p0.x * x + p0.y * y, a + p1.x * x + p1.y * y, data);
Debug::DrawLine(a + p0.x * -x + p0.y * -y, a + p1.x * -x + p1.y * -y, data);
Debug::DrawLine(a + p0.x * x + p0.y * -y, a + p1.x * x + p1.y * -y, data);
Debug::DrawLine(a + p0.x * -x + p0.y * y, a + p1.x * -x + p1.y * y, data);
}
}
//--
void Debug::DrawCircle(vec2 a, vec2 x, vec2 y, vec4 color)
void Debug::DrawCircle(vec2 a, vec2 x, vec2 y, DCD data)
{
Scene& scene = Scene::GetScene();
float size = F_PI * 2.f * lol::max(length(x), length(y));
int segment_nb = lol::max(1, (int)((size * .25f) / scene.GetLineSegmentSize()));
int segment_nb = lol::max(1, (int)((size * .25f) / data.m_segment_size));
for (int i = 0; i < segment_nb; i++)
{
float a0 = (((float)i) / (float)segment_nb) * F_PI_2;
@@ -327,52 +282,52 @@ void Debug::DrawCircle(vec2 a, vec2 x, vec2 y, vec4 color)
vec2 p0 = vec2(lol::cos(a0), lol::sin(a0));
vec2 p1 = vec2(lol::cos(a1), lol::sin(a1));

Debug::DrawLine(a + p0.x * x + p0.y * y, a + p1.x * x + p1.y * y, color);
Debug::DrawLine(a + p0.x * -x + p0.y * -y, a + p1.x * -x + p1.y * -y, color);
Debug::DrawLine(a + p0.x * x + p0.y * -y, a + p1.x * x + p1.y * -y, color);
Debug::DrawLine(a + p0.x * -x + p0.y * y, a + p1.x * -x + p1.y * y, color);
Debug::DrawLine(a + p0.x * x + p0.y * y, a + p1.x * x + p1.y * y, data);
Debug::DrawLine(a + p0.x * -x + p0.y * -y, a + p1.x * -x + p1.y * -y, data);
Debug::DrawLine(a + p0.x * x + p0.y * -y, a + p1.x * x + p1.y * -y, data);
Debug::DrawLine(a + p0.x * -x + p0.y * y, a + p1.x * -x + p1.y * y, data);
}
}

//-- SPHERE -------------------------------------------------------------------
void Debug::DrawSphere(vec3 a, float s) { Scene& scene = Scene::GetScene(); Debug::DrawSphere(a, s, scene.GetLineColor()); }
void Debug::DrawSphere(vec3 a, float s, vec4 color) { Debug::DrawSphere(a, vec3::axis_x * s, vec3::axis_y * s, vec3::axis_z * s, color); }
void Debug::DrawSphere(vec3 a, vec3 x, vec3 y, vec3 z) { Scene& scene = Scene::GetScene(); Debug::DrawSphere(a, x, y, z, scene.GetLineColor()); }
void Debug::DrawSphere(vec3 a, vec3 x, vec3 y, vec3 z, vec4 color)
{
Debug::DrawCircle(a, x, y, color);
Debug::DrawCircle(a, x, (y + z) * .707f, color);
Debug::DrawCircle(a, x, (y - z) * .707f, color);
Debug::DrawCircle(a, z, x, color);
Debug::DrawCircle(a, z, (x + y) * .707f, color);
Debug::DrawCircle(a, z, (x - y) * .707f, color);
Debug::DrawCircle(a, y, z, color);
Debug::DrawCircle(a, y, (z + x) * .707f, color);
Debug::DrawCircle(a, y, (z - x) * .707f, color);
void Debug::DrawSphere(vec3 a, float s) { Debug::DrawSphere(a, s, DC::GetGlobalData()); }
void Debug::DrawSphere(vec3 a, float s, DCD data) { Debug::DrawSphere(a, vec3::axis_x * s, vec3::axis_y * s, vec3::axis_z * s, data); }
void Debug::DrawSphere(vec3 a, vec3 x, vec3 y, vec3 z) { Debug::DrawSphere(a, x, y, z, DC::GetGlobalData()); }
void Debug::DrawSphere(vec3 a, vec3 x, vec3 y, vec3 z, DCD data)
{
Debug::DrawCircle(a, x, y, data);
Debug::DrawCircle(a, x, (y + z) * .707f, data);
Debug::DrawCircle(a, x, (y - z) * .707f, data);
Debug::DrawCircle(a, z, x, data);
Debug::DrawCircle(a, z, (x + y) * .707f, data);
Debug::DrawCircle(a, z, (x - y) * .707f, data);
Debug::DrawCircle(a, y, z, data);
Debug::DrawCircle(a, y, (z + x) * .707f, data);
Debug::DrawCircle(a, y, (z - x) * .707f, data);
}

//-- CAPSULE ------------------------------------------------------------------
void Debug::DrawCapsule(vec3 a, float s, vec3 h) { Scene& scene = Scene::GetScene(); Debug::DrawCapsule(a, s, h, scene.GetLineColor()); }
void Debug::DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h) { Scene& scene = Scene::GetScene(); Debug::DrawCapsule(a, x, y, z, h, scene.GetLineColor()); }
void Debug::DrawCapsule(vec3 a, float s, vec3 h, vec4 color)
void Debug::DrawCapsule(vec3 a, float s, vec3 h) { Debug::DrawCapsule(a, s, h, DC::GetGlobalData()); }
void Debug::DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h) { Debug::DrawCapsule(a, x, y, z, h, DC::GetGlobalData()); }
void Debug::DrawCapsule(vec3 a, float s, vec3 h, DCD data)
{
vec3 x = orthonormal(h) * s;
vec3 y = cross(normalize(h), normalize(x)) * s;
Debug::DrawCapsule(a, x, y, normalize(h) * s, h, color);
Debug::DrawCapsule(a, x, y, normalize(h) * s, h, data);
}
//--
void Debug::DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h, vec4 color)
void Debug::DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h, DCD data)
{
Scene& scene = Scene::GetScene();
float size = F_PI * 2.f * lol::max(length(x), length(y));
int segment_nb = lol::max(1, (int)((size * .25f) / scene.GetLineSegmentSize()));
int segment_nb = lol::max(1, (int)((size * .25f) / data.m_segment_size));
for (int i = -1; i < 2; i += 2)
{
vec3 b = a + h * .5f * (float)i;
vec3 c = a - h * .5f * (float)i;
Debug::DrawCircle(b, x, y, color);
Debug::DrawLine(b + x * (float)i, c + x * (float)i, color);
Debug::DrawLine(b + y * (float)i, c + y * (float)i, color);
Debug::DrawCircle(b, x, y, data);
Debug::DrawLine(b + x * (float)i, c + x * (float)i, data);
Debug::DrawLine(b + y * (float)i, c + y * (float)i, data);
for (int j = 0; j < segment_nb; j++)
{
float a0 = (((float)j) / (float)segment_nb) * F_PI_2;
@@ -380,18 +335,18 @@ void Debug::DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h, vec4 color)
vec2 p0 = vec2(lol::cos(a0), lol::sin(a0));
vec2 p1 = vec2(lol::cos(a1), lol::sin(a1));

Debug::DrawLine(b + p0.x * x + p0.y * z * (float)i, b + p1.x * x + p1.y * z * (float)i, color);
Debug::DrawLine(b + p0.x * -x + p0.y * z * (float)i, b + p1.x * -x + p1.y * z * (float)i, color);
Debug::DrawLine(b + p0.x * y + p0.y * z * (float)i, b + p1.x * y + p1.y * z * (float)i, color);
Debug::DrawLine(b + p0.x * -y + p0.y * z * (float)i, b + p1.x * -y + p1.y * z * (float)i, color);
Debug::DrawLine(b + p0.x * x + p0.y * z * (float)i, b + p1.x * x + p1.y * z * (float)i, data);
Debug::DrawLine(b + p0.x * -x + p0.y * z * (float)i, b + p1.x * -x + p1.y * z * (float)i, data);
Debug::DrawLine(b + p0.x * y + p0.y * z * (float)i, b + p1.x * y + p1.y * z * (float)i, data);
Debug::DrawLine(b + p0.x * -y + p0.y * z * (float)i, b + p1.x * -y + p1.y * z * (float)i, data);
}
}
}

//-- VIEW PROJ ----------------------------------------------------------------
void Debug::DrawViewProj(mat4 view, mat4 proj) { Scene& scene = Scene::GetScene(); Debug::DrawViewProj(view, proj, scene.GetLineColor()); }
void Debug::DrawViewProj(mat4 view_proj) { Scene& scene = Scene::GetScene(); Debug::DrawViewProj(view_proj, scene.GetLineColor()); }
void Debug::DrawViewProj(mat4 view, mat4 proj, vec4 color)
void Debug::DrawViewProj(mat4 view, mat4 proj) { Debug::DrawViewProj(view, proj, DC::GetGlobalData()); }
void Debug::DrawViewProj(mat4 view_proj) { Debug::DrawViewProj(view_proj, DC::GetGlobalData()); }
void Debug::DrawViewProj(mat4 view, mat4 proj, DCD data)
{
mat4 const view_proj = proj * view;

@@ -409,13 +364,13 @@ void Debug::DrawViewProj(mat4 view, mat4 proj, vec4 color)

//Draw near
for (int i = 0; i < 4; i++)
Debug::DrawLine(p[i].xyz, p0, color);
Debug::DrawLine(p[i].xyz, p0, data);

Debug::DrawViewProj(view_proj, color);
Debug::DrawViewProj(view_proj, data);
}

//--
void Debug::DrawViewProj(mat4 view_proj, vec4 color)
void Debug::DrawViewProj(mat4 view_proj, DCD data)
{
//Near plane
mat4 const inv_view_proj = inverse(view_proj);
@@ -433,16 +388,16 @@ void Debug::DrawViewProj(mat4 view_proj, vec4 color)

//Draw near
for (int i = 0; i < 4; i++)
Debug::DrawLine(p[i].xyz, p[(i + 1) % 4].xyz, color);
Debug::DrawLine(p[i].xyz, p[(i + 1) % 4].xyz, data);
//Draw far
for (int i = 4; i < 8; i++)
Debug::DrawLine(p[i].xyz, p[(i - 4 + 1) % 4 + 4].xyz, color);
Debug::DrawLine(p[i].xyz, p[(i - 4 + 1) % 4 + 4].xyz, data);
//Draw near to far
for (int i = 0; i < 4; i++)
Debug::DrawLine(p[i].xyz, p[i + 4].xyz, color);
Debug::DrawLine(p[i].xyz, p[i + 4].xyz, data);
//Draw diagonal
for (int i = 2; i < 6; i++)
Debug::DrawLine(p[i].xyz, p[i + ((i < 4)?(-2):(+2))].xyz, color);
Debug::DrawLine(p[i].xyz, p[i + ((i < 4)?(-2):(+2))].xyz, data);
}

} /* namespace lol */


+ 149
- 88
src/lol/debug/lines.h View File

@@ -22,96 +22,157 @@ namespace lol

namespace Debug
{
class DrawContext
{
public:
class Data
{
public:
float m_duration = 0.0f;
int m_mask = 0;
float m_segment_size = 8;

//Resets draw infos
void DrawSetupReset();
//Sets draw infos
void DrawSetupTime(float new_time);
void DrawSetupMask(int new_mask);
void DrawSetupSegment(float segment_size);
void DrawSetupColor(vec4 color);
void DrawSetup(float new_time, int new_mask, float segment_size, vec4 color);

//Screen to world conversion
vec3 WorldToScreen(vec3 pos);
vec3 WorldToScreen(vec3 pos, mat4 view_proj);
vec3 WorldToScreen(vec4 pos);
vec3 WorldToScreen(vec4 pos, mat4 view_proj);
vec3 ScreenToWorld(vec2 pos, float z=-1.f);
vec3 ScreenToWorld(vec3 pos);
vec3 ScreenToWorld(vec2 pos, mat4 inv_view_proj, float z=-1.f);
vec3 ScreenToWorld(vec3 pos, mat4 inv_view_proj);
vec3 ScreenToWorld(vec3 pos, mat4 view, mat4 proj);

//Draw stuff in World
//-- LINE
void DrawLine(vec3 a, vec3 b);
void DrawLine(vec2 a, vec3 b, float az=-1.f);
void DrawLine(vec2 a, vec2 b, float az=-1.f, float bz=-1.f);
void DrawLine(vec3 a, vec3 b, vec4 color);
void DrawLine(vec2 a, vec3 b, vec4 color, float az=-1.f);
void DrawLine(vec2 a, vec2 b, vec4 color, float az=-1.f, float bz=-1.f);
//-- GIZMO
void DrawGizmo(vec3 pos, vec3 x, vec3 y, vec3 z, float size);
void DrawGizmo(vec2 pos, vec3 x, vec3 y, vec3 z, float size, float posz = -1.f);
//-- GRID
void DrawGrid(vec3 pos, vec3 x, vec3 y, vec3 z, float size, bool draw_3d=false);
//-- ARROW
void DrawArrow(vec3 a, vec3 b, vec2 s);
void DrawArrow(vec2 a, vec3 b, vec2 s, float az=-1.f);
void DrawArrow(vec2 a, vec2 b, vec2 s, float az=-1.f, float bz=-1.f);
void DrawArrow(vec3 a, vec3 b, vec3 s);
void DrawArrow(vec2 a, vec3 b, vec3 s, float az=-1.f);
void DrawArrow(vec2 a, vec2 b, vec3 s, float az=-1.f, float bz=-1.f);
void DrawArrow(vec3 a, vec3 b, vec3 s, vec4 color);
void DrawArrow(vec2 a, vec3 b, vec3 s, vec4 color, float az=-1.f);
void DrawArrow(vec2 a, vec2 b, vec3 s, vec4 color, float az=-1.f, float bz=-1.f);
//-- BOX
void DrawBox(box3 a);
void DrawBox(box2 a);
void DrawBox(box3 a, vec4 color);
void DrawBox(box2 a, vec4 color);
void DrawBox(vec3 a, vec3 b);
void DrawBox(vec2 a, vec2 b);
void DrawBox(vec2 a, float s);
void DrawBox(vec3 a, vec3 b, vec4 color);
void DrawBox(vec2 a, vec2 b, vec4 color);
void DrawBox(vec2 a, float s, vec4 color);
void DrawBox(box3 a, mat4 transform);
void DrawBox(box2 a, mat2 transform);
void DrawBox(box3 a, mat4 transform, vec4 color);
void DrawBox(box2 a, mat2 transform, vec4 color);
void DrawBox(vec3 a, vec3 b, mat4 transform);
void DrawBox(vec2 a, vec2 b, mat2 transform);
void DrawBox(vec2 a, float s, mat2 transform);
void DrawBox(vec3 a, vec3 b, mat4 transform, vec4 color);
void DrawBox(vec2 a, vec2 b, mat2 transform, vec4 color);
void DrawBox(vec2 a, float s, mat2 transform, vec4 color);
//-- CIRCLE
void DrawCircle(vec2 a, float s);
void DrawCircle(vec3 a, vec3 n);
void DrawCircle(vec2 a, vec2 s);
void DrawCircle(vec3 a, vec3 n, vec4 color);
void DrawCircle(vec2 a, vec2 s, vec4 color);
void DrawCircle(vec3 a, vec3 x, vec3 y);
void DrawCircle(vec2 a, vec2 x, vec2 y);
void DrawCircle(vec3 a, vec3 x, vec3 y, vec4 color);
void DrawCircle(vec2 a, vec2 x, vec2 y, vec4 color);
//-- SPHERE
void DrawSphere(vec3 a, float s);
void DrawSphere(vec3 a, float s, vec4 color);
void DrawSphere(vec3 a, vec3 x, vec3 y, vec3 z);
void DrawSphere(vec3 a, vec3 x, vec3 y, vec3 z, vec4 color);
//-- CAPSULE
void DrawCapsule(vec3 a, float s, vec3 h);
void DrawCapsule(vec3 a, float s, vec3 h, vec4 color);
void DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h);
void DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h, vec4 color);
//-- VIEW PROJ
void DrawViewProj(mat4 view_proj);
void DrawViewProj(mat4 view_proj, vec4 color);
void DrawViewProj(mat4 view, mat4 proj);
void DrawViewProj(mat4 view, mat4 proj, vec4 color);
Data() {}
Data(vec4 color, float duration = -1.f, int mask = 0xFFFFFFFF, float segment_size = 1.f)
{
m_color = color;
m_duration = duration;
m_mask = mask;
m_segment_size = segment_size;
}
inline Data& operator=(vec4 const& color) { m_color = color; return *this; }
};

private:
static Data m_global;
Data m_previous;
Data m_current;

DrawContext(vec4 color, float duration, int mask, float segment_size)
{
//Store old datas
m_previous.m_color = m_global.m_color;
m_previous.m_duration = m_global.m_duration;
m_previous.m_mask = m_global.m_mask;
m_previous.m_segment_size = m_global.m_segment_size;

//Create new one
SetColor(color);
SetDuration(duration);
SetMask(mask);
SetSegmentSize(segment_size);
}

public:
~DrawContext()
{
m_global.m_color = m_previous.m_color;
m_global.m_duration = m_previous.m_duration;
m_global.m_mask = m_previous.m_mask;
m_global.m_segment_size = m_previous.m_segment_size;
}

static DrawContext New(vec4 color, float duration = -1.f, int mask = 0xFFFFFFFF, float segment_size = 1.f)
{
return DrawContext(color, duration, mask, segment_size);
}

static DrawContext New(DrawContext& dc)
{
return DrawContext(dc.m_current.m_color, dc.m_current.m_duration, dc.m_current.m_mask, dc.m_current.m_segment_size);
}

static Data GetGlobalData() { return m_global; }

//Setup methods
void SetColor(vec4 color) { m_global.m_color = m_current.m_color = color; }
void SetDuration(float duration) { m_global.m_duration = m_current.m_duration = duration; }
void SetMask(int mask) { m_global.m_mask = m_current.m_mask = mask; }
void SetSegmentSize(float segment_size) { m_global.m_segment_size = m_current.m_segment_size = segment_size; }
};

//Screen to world conversion
vec3 WorldToScreen(vec3 pos);
vec3 WorldToScreen(vec3 pos, mat4 view_proj);
vec3 WorldToScreen(vec4 pos);
vec3 WorldToScreen(vec4 pos, mat4 view_proj);
vec3 ScreenToWorld(vec2 pos, float z=-1.f);
vec3 ScreenToWorld(vec3 pos);
vec3 ScreenToWorld(vec2 pos, mat4 inv_view_proj, float z=-1.f);
vec3 ScreenToWorld(vec3 pos, mat4 inv_view_proj);
vec3 ScreenToWorld(vec3 pos, mat4 view, mat4 proj);

//Draw stuff in World
//Draw stuff in World
//-- LINE
void DrawLine(vec3 a, vec3 b, DrawContext::Data data);
void DrawLine(vec2 a, vec3 b, DrawContext::Data data, float az = -1.f);
void DrawLine(vec2 a, vec2 b, DrawContext::Data data, float az = -1.f, float bz = -1.f);
void DrawLine(vec3 a, vec3 b);
void DrawLine(vec2 a, vec3 b, float az = -1.f);
void DrawLine(vec2 a, vec2 b, float az = -1.f, float bz = -1.f);
//-- GIZMO
void DrawGizmo(vec3 pos, vec3 x, vec3 y, vec3 z, float size);
void DrawGizmo(vec2 pos, vec3 x, vec3 y, vec3 z, float size, float posz = -1.f);
//-- GRID
void DrawGrid(vec3 pos, vec3 x, vec3 y, vec3 z, float size, bool draw_3d=false);
//-- ARROW
void DrawArrow(vec3 a, vec3 b, vec2 s);
void DrawArrow(vec2 a, vec3 b, vec2 s, float az=-1.f);
void DrawArrow(vec2 a, vec2 b, vec2 s, float az=-1.f, float bz=-1.f);
void DrawArrow(vec3 a, vec3 b, vec3 s);
void DrawArrow(vec2 a, vec3 b, vec3 s, float az=-1.f);
void DrawArrow(vec2 a, vec2 b, vec3 s, float az=-1.f, float bz=-1.f);
void DrawArrow(vec3 a, vec3 b, vec3 s, DrawContext::Data data);
void DrawArrow(vec2 a, vec3 b, vec3 s, DrawContext::Data data, float az=-1.f);
void DrawArrow(vec2 a, vec2 b, vec3 s, DrawContext::Data data, float az=-1.f, float bz=-1.f);
//-- BOX
void DrawBox(box3 a);
void DrawBox(box2 a);
void DrawBox(box3 a, DrawContext::Data data);
void DrawBox(box2 a, DrawContext::Data data);
void DrawBox(vec3 a, vec3 b);
void DrawBox(vec2 a, vec2 b);
void DrawBox(vec2 a, float s);
void DrawBox(vec3 a, vec3 b, DrawContext::Data data);
void DrawBox(vec2 a, vec2 b, DrawContext::Data data);
void DrawBox(vec2 a, float s, DrawContext::Data data);
void DrawBox(box3 a, mat4 transform);
void DrawBox(box2 a, mat2 transform);
void DrawBox(box3 a, mat4 transform, DrawContext::Data data);
void DrawBox(box2 a, mat2 transform, DrawContext::Data data);
void DrawBox(vec3 a, vec3 b, mat4 transform);
void DrawBox(vec2 a, vec2 b, mat2 transform);
void DrawBox(vec2 a, float s, mat2 transform);
void DrawBox(vec3 a, vec3 b, mat4 transform, DrawContext::Data data);
void DrawBox(vec2 a, vec2 b, mat2 transform, DrawContext::Data data);
void DrawBox(vec2 a, float s, mat2 transform, DrawContext::Data data);
//-- CIRCLE
void DrawCircle(vec2 a, float s);
void DrawCircle(vec3 a, vec3 n);
void DrawCircle(vec2 a, vec2 s);
void DrawCircle(vec3 a, vec3 n, DrawContext::Data data);
void DrawCircle(vec2 a, vec2 s, DrawContext::Data data);
void DrawCircle(vec3 a, vec3 x, vec3 y);
void DrawCircle(vec2 a, vec2 x, vec2 y);
void DrawCircle(vec3 a, vec3 x, vec3 y, DrawContext::Data data);
void DrawCircle(vec2 a, vec2 x, vec2 y, DrawContext::Data data);
//-- SPHERE
void DrawSphere(vec3 a, float s);
void DrawSphere(vec3 a, float s, DrawContext::Data data);
void DrawSphere(vec3 a, vec3 x, vec3 y, vec3 z);
void DrawSphere(vec3 a, vec3 x, vec3 y, vec3 z, DrawContext::Data data);
//-- CAPSULE
void DrawCapsule(vec3 a, float s, vec3 h);
void DrawCapsule(vec3 a, float s, vec3 h, DrawContext::Data data);
void DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h);
void DrawCapsule(vec3 a, vec3 x, vec3 y, vec3 z, vec3 h, DrawContext::Data data);
//-- VIEW PROJ
void DrawViewProj(mat4 view_proj);
void DrawViewProj(mat4 view_proj, DrawContext::Data data);
void DrawViewProj(mat4 view, mat4 proj);
void DrawViewProj(mat4 view, mat4 proj, DrawContext::Data data);

} /* namespace Debug */



+ 1
- 1
src/lolimgui.cpp View File

@@ -419,7 +419,7 @@ void LolImGui::RenderDrawListsMethod(ImDrawData* draw_data)
//<\Debug render> -------------------------------------------------
//-----------------------------------------------------------------
#endif //SHOW_IMGUI_DEBUG
Debug::DrawLine(vec2::zero, vec2::axis_x, Color::green);
//Debug::DrawLine(vec2::zero, vec2::axis_x /*, Color::green*/);

m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, pcmd->ElemCount, (const short*)idx_buffer_offset);



+ 7
- 49
src/scene.cpp View File

@@ -168,10 +168,10 @@ private:
/* Old line API <P0, P1, COLOR, TIME, MASK> */
struct line_api
{
float m_time, m_segment_size;
vec4 m_color;
//float m_duration, m_segment_size;
//vec4 m_color;
array<vec3, vec3, vec4, float, int, bool, bool> m_lines;
int m_mask, m_debug_mask;
int /*m_mask,*/ m_debug_mask;
Shader *m_shader;
VertexDeclaration *m_vdecl;
}
@@ -241,11 +241,6 @@ Scene::Scene(ivec2 size)
data->m_line_api.m_vdecl = new VertexDeclaration(VertexStream<vec4,vec4>(VertexUsage::Position, VertexUsage::Color));

data->m_line_api.m_debug_mask = 1;

SetLineTime();
SetLineMask();
SetLineSegmentSize();
SetLineColor();
}

//-----------------------------------------------------------------------------
@@ -533,56 +528,19 @@ void Scene::AddTile(TileSet *tileset, int id, mat4 model)
}

//-----------------------------------------------------------------------------
void Scene::SetLineTime(float new_time)
{
ASSERT(!!data, "Trying to access a non-ready scene");

data->m_line_api.m_time = new_time;
}

void Scene::SetLineMask(int new_mask)
{
ASSERT(!!data, "Trying to access a non-ready scene");

data->m_line_api.m_mask = new_mask;
}

void Scene::SetLineSegmentSize(float new_segment_size)
{
ASSERT(!!data, "Trying to access a non-ready scene");

data->m_line_api.m_segment_size = new_segment_size;
}

void Scene::SetLineColor(vec4 new_color)
{
ASSERT(!!data, "Trying to access a non-ready scene");

data->m_line_api.m_color = new_color;
}

//-----------------------------------------------------------------------------
float Scene::GetLineSegmentSize()
{
ASSERT(!!data, "Trying to access a non-ready scene");

return data->m_line_api.m_segment_size;
}

vec4 Scene::GetLineColor()
void Scene::AddLine(vec3 a, vec3 b, vec4 color)
{
ASSERT(!!data, "Trying to access a non-ready scene");

return data->m_line_api.m_color;
data->m_line_api.m_lines.push(a, b, color, -1.f, 0xFFFFFFFF, false, false);
}

//-----------------------------------------------------------------------------
void Scene::AddLine(vec3 a, vec3 b, vec4 color)
void Scene::AddLine(vec3 a, vec3 b, vec4 color, float duration, int mask)
{
ASSERT(!!data, "Trying to access a non-ready scene");

data->m_line_api.m_lines.push(a, b, color,
data->m_line_api.m_time, data->m_line_api.m_mask, false, false);
data->m_line_api.m_lines.push(a, b, color, duration, mask, false, false);
}

//-----------------------------------------------------------------------------


+ 1
- 7
src/scene.h View File

@@ -234,14 +234,8 @@ public:
void AddTile(TileSet *tileset, int id, mat4 model);

public:
void SetLineTime(float new_time = -1.f);
void SetLineMask(int new_mask = 0xFFFFFFFF);
void SetLineSegmentSize(float new_segment_size = 1.f);
void SetLineColor(vec4 new_color = vec4(1.f));

float GetLineSegmentSize();
vec4 GetLineColor();
void AddLine(vec3 a, vec3 b, vec4 color);
void AddLine(vec3 a, vec3 b, vec4 color, float duration, int mask);

void AddLight(Light *light);
array<Light *> const &GetLights();


Loading…
Cancel
Save