mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
added box
This commit is contained in:
@@ -18,8 +18,7 @@ option(OMATH_SUPRESS_SAFETY_CHECKS "Supress some safety checks in release build
|
||||
if (OMATH_BUILD_AS_SHARED_LIBRARY)
|
||||
add_library(omath SHARED source/matrix.cpp)
|
||||
else()
|
||||
add_library(omath STATIC source/matrix.cpp
|
||||
source/matrix.cpp)
|
||||
add_library(omath STATIC source/matrix.cpp)
|
||||
endif()
|
||||
|
||||
message(STATUS "Building on ${CMAKE_HOST_SYSTEM_NAME}")
|
||||
|
||||
14
include/omath/3d_primitives/box.hpp
Normal file
14
include/omath/3d_primitives/box.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Created by Vlad on 4/18/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <array>
|
||||
|
||||
|
||||
namespace omath::primitives
|
||||
{
|
||||
[[nodiscard]]
|
||||
std::array<Vector3<float>, 8> CreateBox(const Vector3<float>& top, const Vector3<float>& bottom,
|
||||
const Vector3<float>& dirForward, const Vector3<float>& dirRight);
|
||||
}
|
||||
1
source/3d_primitives/CMakeLists.txt
Normal file
1
source/3d_primitives/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
target_sources(omath PRIVATE box.cpp)
|
||||
32
source/3d_primitives/box.cpp
Normal file
32
source/3d_primitives/box.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by Vlad on 4/18/2025.
|
||||
//
|
||||
#include "omath/3d_primitives/box.hpp"
|
||||
|
||||
namespace omath::primitives
|
||||
{
|
||||
|
||||
std::array<Vector3<float>, 8> CreateBox(const Vector3<float>& top, const Vector3<float>& bottom,
|
||||
const Vector3<float>& dirForward,
|
||||
const Vector3<float>& dirRight)
|
||||
{
|
||||
const auto height = top.DistTo(bottom);
|
||||
const auto sideSize = height / 6.f;
|
||||
|
||||
std::array<Vector3<float>, 8> points;
|
||||
|
||||
points[0] = bottom + (dirForward + dirRight) * sideSize;
|
||||
points[1] = bottom + (dirForward - dirRight) * sideSize;
|
||||
|
||||
points[2] = bottom + (-dirForward + dirRight) * sideSize;
|
||||
points[3] = bottom + (-dirForward - dirRight) * sideSize;
|
||||
|
||||
points[4] = top + (dirForward + dirRight) * sideSize;
|
||||
points[5] = top + (dirForward - dirRight) * sideSize;
|
||||
|
||||
points[6] = top + (-dirForward + dirRight) * sideSize;
|
||||
points[7] = top + (-dirForward - dirRight) * sideSize;
|
||||
|
||||
return points;
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,5 @@ add_subdirectory(projectile_prediction)
|
||||
add_subdirectory(pathfinding)
|
||||
add_subdirectory(projection)
|
||||
add_subdirectory(collision)
|
||||
add_subdirectory(engines)
|
||||
add_subdirectory(engines)
|
||||
add_subdirectory(3d_primitives)
|
||||
@@ -18,6 +18,7 @@ add_executable(unit-tests
|
||||
general/unit_test_view_angles.cpp
|
||||
general/unit_test_angle.cpp
|
||||
general/unit_test_triangle.cpp
|
||||
general/unit_test_box_primitive.cpp
|
||||
|
||||
engines/unit_test_open_gl.cpp
|
||||
engines/unit_test_unity_engine.cpp
|
||||
|
||||
4
tests/general/unit_test_box_primitive.cpp
Normal file
4
tests/general/unit_test_box_primitive.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
//
|
||||
// Created by Vlad on 4/18/2025.
|
||||
//
|
||||
#include <omath/3d_primitives/box.hpp>
|
||||
Reference in New Issue
Block a user