#include "debug_draw.h"

DebugLineMesh DebugDraw::makeBlockOutline(int x, int y, int z) {
    DebugLineMesh mesh;

    const float e = 0.003f;

    const float x0 = static_cast<float>(x) - e;
    const float y0 = static_cast<float>(y) - e;
    const float z0 = static_cast<float>(z) - e;
    const float x1 = static_cast<float>(x) + 1.0f + e;
    const float y1 = static_cast<float>(y) + 1.0f + e;
    const float z1 = static_cast<float>(z) + 1.0f + e;

    const float c[3] = {0.02f, 0.02f, 0.02f};

    auto v = [&](float px, float py, float pz) -> DebugLineVertex {
        return {
            {px, py, pz},
            {c[0], c[1], c[2]},
            {0.0f, 0.0f},
            -1.0f
        };
    };

    mesh.vertices = {
        v(x0, y0, z0),
        v(x1, y0, z0),
        v(x1, y1, z0),
        v(x0, y1, z0),
        v(x0, y0, z1),
        v(x1, y0, z1),
        v(x1, y1, z1),
        v(x0, y1, z1)
    };

    mesh.indices = {
        0,1, 1,2, 2,3, 3,0,
        4,5, 5,6, 6,7, 7,4,
        0,4, 1,5, 2,6, 3,7
    };

    return mesh;
}