From 2a2832c75fe80bf5c4dbf6b3e295fdb70799c9bb Mon Sep 17 00:00:00 2001 From: Orange Date: Tue, 27 Jan 2026 00:33:35 +0300 Subject: [PATCH] added opengl primitives --- include/omath/3d_primitives/box.hpp | 10 +++------- include/omath/3d_primitives/plane.hpp | 4 +--- .../omath/engines/opengl_engine/primitives.hpp | 17 +++++++++++++++++ tests/general/unit_test_primitive_box.cpp | 3 ++- 4 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 include/omath/engines/opengl_engine/primitives.hpp diff --git a/include/omath/3d_primitives/box.hpp b/include/omath/3d_primitives/box.hpp index 1454e85..0e1a7e1 100644 --- a/include/omath/3d_primitives/box.hpp +++ b/include/omath/3d_primitives/box.hpp @@ -12,14 +12,10 @@ namespace omath::primitives { - using BoxMesh = Mesh, - std::array, 8>, std::array, 12>>; - - template + template [[nodiscard]] - BoxMeshType - create_box(const Vector3& top, const Vector3& bottom, const Vector3& dir_forward, - const Vector3& dir_right, const float ratio = 4.f) noexcept + BoxMeshType create_box(const Vector3& top, const Vector3& bottom, const Vector3& dir_forward, + const Vector3& dir_right, const float ratio = 4.f) noexcept { const auto height = top.distance_to(bottom); const auto side_size = height / ratio; diff --git a/include/omath/3d_primitives/plane.hpp b/include/omath/3d_primitives/plane.hpp index ea7f3cb..d5c8332 100644 --- a/include/omath/3d_primitives/plane.hpp +++ b/include/omath/3d_primitives/plane.hpp @@ -13,11 +13,9 @@ namespace omath::primitives { - using PlaneMesh = Mesh, - std::array, 4>, std::array, 2>>; template [[nodiscard]] - PlaneMesh create_plane(const Vector3& vertex_a, const Vector3& vertex_b, + PlaneMeshType create_plane(const Vector3& vertex_a, const Vector3& vertex_b, const Vector3& direction, const float size) noexcept { const auto second_vertex_a = vertex_a + direction * size; diff --git a/include/omath/engines/opengl_engine/primitives.hpp b/include/omath/engines/opengl_engine/primitives.hpp new file mode 100644 index 0000000..9390237 --- /dev/null +++ b/include/omath/engines/opengl_engine/primitives.hpp @@ -0,0 +1,17 @@ +// +// Created by Vladislav on 27.01.2026. +// + +#pragma once +#include "mesh.hpp" +#include "omath/engines/opengl_engine/traits/mesh_trait.hpp" +#include "omath/linear_algebra/vector3.hpp" +#include +namespace omath::opengl_engine +{ + using BoxMesh = primitives::Mesh, std::array, 8>, + std::array, 12>>; + + using PlaneMesh = primitives::Mesh, + std::array, 4>, std::array, 2>>; +} // namespace omath::opengl_engine \ No newline at end of file diff --git a/tests/general/unit_test_primitive_box.cpp b/tests/general/unit_test_primitive_box.cpp index bac7a98..3d7345f 100644 --- a/tests/general/unit_test_primitive_box.cpp +++ b/tests/general/unit_test_primitive_box.cpp @@ -2,10 +2,11 @@ // Created by Vladislav on 11.01.2026. // #include "omath/3d_primitives/box.hpp" +#include "omath/engines/opengl_engine/primitives.hpp" #include TEST(test, test) { - auto result = omath::primitives::create_box({0.f, 30.f, 0.f}, {}, omath::opengl_engine::k_abs_forward, + auto result = omath::primitives::create_box({0.f, 30.f, 0.f}, {}, omath::opengl_engine::k_abs_forward, omath::opengl_engine::k_abs_right); } \ No newline at end of file