X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2Fmesh.cpp;h=5cd38832174c4f040d56a6f063ea4405bbddeb2f;hb=afc50302943e4000a8621c23960d63b208c8a400;hp=3aa631eb77e5e266f156d9516e75760ed92f5c28;hpb=75172fd735e34082c34b47ae7c194445b53038d9;p=blank.git diff --git a/src/graphics/mesh.cpp b/src/graphics/mesh.cpp index 3aa631e..5cd3883 100644 --- a/src/graphics/mesh.cpp +++ b/src/graphics/mesh.cpp @@ -4,6 +4,8 @@ #include "SkyBoxMesh.hpp" #include "SpriteMesh.hpp" +#include "../geometry/primitive.hpp" + #include #include @@ -90,6 +92,28 @@ void PrimitiveMesh::Buffer::FillRect( indices.assign({ 0, 2, 1, 1, 2, 3 }); } +void PrimitiveMesh::Buffer::OutlineBox(const AABB &box, const glm::vec4 &color) { + Clear(); + Reserve(8, 24); + + vertices.emplace_back(box.min.x, box.min.y, box.min.z); + vertices.emplace_back(box.min.x, box.min.y, box.max.z); + vertices.emplace_back(box.min.x, box.max.y, box.min.z); + vertices.emplace_back(box.min.x, box.max.y, box.max.z); + vertices.emplace_back(box.max.x, box.min.y, box.min.z); + vertices.emplace_back(box.max.x, box.min.y, box.max.z); + vertices.emplace_back(box.max.x, box.max.y, box.min.z); + vertices.emplace_back(box.max.x, box.max.y, box.max.z); + + colors.resize(8, color); + + indices.assign({ + 0, 1, 1, 3, 3, 2, 2, 0, // left + 4, 5, 5, 7, 7, 6, 6, 4, // right + 0, 4, 1, 5, 3, 7, 2, 6, // others + }); +} + void PrimitiveMesh::Update(const Buffer &buf) noexcept { #ifndef NDEBUG