diff --git a/engine/include/cubos/engine/gizmos/gizmos.hpp b/engine/include/cubos/engine/gizmos/gizmos.hpp index f71f1db7e..aec6b06c1 100644 --- a/engine/include/cubos/engine/gizmos/gizmos.hpp +++ b/engine/include/cubos/engine/gizmos/gizmos.hpp @@ -21,6 +21,7 @@ namespace cubos::engine void color(const glm::vec3& color); void drawLine(std::string id, glm::vec3 from, glm::vec3 to, float lifespan = 0); void drawBox(std::string id, glm::vec3 corner, glm::vec3 oppositeCorner, float lifespan = 0); + void drawWireBox(std::string id, glm::vec3 corner, glm::vec3 oppositeCorner, float lifespan = 0); void drawQueuedGizmos(DeltaTime deltaTime); diff --git a/engine/samples/gizmos/main.cpp b/engine/samples/gizmos/main.cpp index dc5008bfd..a5973d037 100644 --- a/engine/samples/gizmos/main.cpp +++ b/engine/samples/gizmos/main.cpp @@ -30,7 +30,7 @@ static void drawSystem(Write gizmos) gizmos->drawBox("test box", {0.4, 0.4, 0}, {0.6, 0.6, 1}, 0); gizmos->color({1, 0, 1}); - gizmos->drawBox("test box", {0.2, 0.7, 0}, {0.3, 0.1, 0}, 0); + gizmos->drawWireBox("test box", {0.2, 0.7, 0}, {0.3, 0.1, 0}, 0); } /// [System] diff --git a/engine/src/cubos/engine/gizmos/gizmos.cpp b/engine/src/cubos/engine/gizmos/gizmos.cpp index 28a4dcbe4..a5a24242b 100644 --- a/engine/src/cubos/engine/gizmos/gizmos.cpp +++ b/engine/src/cubos/engine/gizmos/gizmos.cpp @@ -174,6 +174,47 @@ void Gizmos::drawBox(std::string id, glm::vec3 corner, glm::vec3 oppositeCorner, std::make_shared(id, corner, oppositeCorner, mColor, lifespan, *mRenderDevice, mPipeline)); } +void Gizmos::drawWireBox(std::string id, glm::vec3 corner, glm::vec3 oppositeCorner, float lifespan) +{ + // Front + mGizmosVector.push_back(std::make_shared(id, corner, glm::vec3{oppositeCorner[0], corner[1], corner[2]}, + mColor, lifespan, *mRenderDevice, mPipeline)); + mGizmosVector.push_back(std::make_shared(id, corner, glm::vec3{corner[0], oppositeCorner[1], corner[2]}, + mColor, lifespan, *mRenderDevice, mPipeline)); + mGizmosVector.push_back(std::make_shared(id, glm::vec3{oppositeCorner[0], oppositeCorner[1], corner[2]}, + glm::vec3{corner[0], oppositeCorner[1], corner[2]}, mColor, + lifespan, *mRenderDevice, mPipeline)); + mGizmosVector.push_back(std::make_shared(id, glm::vec3{oppositeCorner[0], oppositeCorner[1], corner[2]}, + glm::vec3{oppositeCorner[0], corner[1], corner[2]}, mColor, + lifespan, *mRenderDevice, mPipeline)); + + // Back + mGizmosVector.push_back(std::make_shared(id, oppositeCorner, + glm::vec3{corner[0], oppositeCorner[1], oppositeCorner[2]}, + mColor, lifespan, *mRenderDevice, mPipeline)); + mGizmosVector.push_back(std::make_shared(id, oppositeCorner, + glm::vec3{oppositeCorner[0], corner[1], oppositeCorner[2]}, + mColor, lifespan, *mRenderDevice, mPipeline)); + mGizmosVector.push_back(std::make_shared(id, glm::vec3{corner[0], corner[1], oppositeCorner[2]}, + glm::vec3{corner[0], oppositeCorner[1], oppositeCorner[2]}, + mColor, lifespan, *mRenderDevice, mPipeline)); + mGizmosVector.push_back(std::make_shared(id, glm::vec3{corner[0], corner[1], oppositeCorner[2]}, + glm::vec3{oppositeCorner[0], corner[1], oppositeCorner[2]}, + mColor, lifespan, *mRenderDevice, mPipeline)); + + // Sides + mGizmosVector.push_back(std::make_shared(id, corner, glm::vec3{corner[0], corner[1], oppositeCorner[2]}, + mColor, lifespan, *mRenderDevice, mPipeline)); + mGizmosVector.push_back(std::make_shared(id, glm::vec3{corner[0], oppositeCorner[1], corner[2]}, + glm::vec3{corner[0], oppositeCorner[1], oppositeCorner[2]}, + mColor, lifespan, *mRenderDevice, mPipeline)); + mGizmosVector.push_back(std::make_shared(id, glm::vec3{oppositeCorner[0], corner[1], corner[2]}, + glm::vec3{oppositeCorner[0], corner[1], oppositeCorner[2]}, + mColor, lifespan, *mRenderDevice, mPipeline)); + mGizmosVector.push_back(std::make_shared(id, glm::vec3{oppositeCorner[0], oppositeCorner[1], corner[2]}, + oppositeCorner, mColor, lifespan, *mRenderDevice, mPipeline)); +} + void Gizmos::drawQueuedGizmos(DeltaTime deltaTime) { std::vector toRemove;