Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/omath/3d_primitives/box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//

#pragma once
#include "omath/linear_algebra/triangle.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include "omath/triangle.hpp"
#include <array>

namespace omath::primitives
Expand Down
2 changes: 1 addition & 1 deletion include/omath/3d_primitives/plane.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//

#pragma once
#include "omath/linear_algebra/triangle.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include "omath/triangle.hpp"
#include <array>

namespace omath::primitives
Expand Down
2 changes: 1 addition & 1 deletion include/omath/collision/line_tracer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//
#pragma once

#include "omath/linear_algebra/triangle.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include "omath/triangle.hpp"

namespace omath::collision
{
Expand Down
4 changes: 2 additions & 2 deletions include/omath/engines/iw_engine/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#pragma once
#include "omath/linear_algebra/mat.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include <omath/angle.hpp>
#include <omath/view_angles.hpp>
#include <omath/trigonometry/angle.hpp>
#include <omath/trigonometry/view_angles.hpp>

namespace omath::iw_engine
{
Expand Down
4 changes: 2 additions & 2 deletions include/omath/engines/opengl_engine/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "omath/linear_algebra/mat.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include <omath/angle.hpp>
#include <omath/view_angles.hpp>
#include <omath/trigonometry/angle.hpp>
#include <omath/trigonometry/view_angles.hpp>

namespace omath::opengl_engine
{
Expand Down
4 changes: 2 additions & 2 deletions include/omath/engines/source_engine/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "omath/linear_algebra/mat.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include <omath/angle.hpp>
#include <omath/view_angles.hpp>
#include <omath/trigonometry/angle.hpp>
#include <omath/trigonometry/view_angles.hpp>

namespace omath::source_engine
{
Expand Down
4 changes: 2 additions & 2 deletions include/omath/engines/unity_engine/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include "omath/linear_algebra/mat.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include <omath/angle.hpp>
#include <omath/view_angles.hpp>
#include <omath/trigonometry/angle.hpp>
#include <omath/trigonometry/view_angles.hpp>

namespace omath::unity_engine
{
Expand Down
4 changes: 2 additions & 2 deletions include/omath/engines/unreal_engine/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include "omath/linear_algebra/mat.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include <omath/angle.hpp>
#include <omath/view_angles.hpp>
#include <omath/trigonometry/angle.hpp>
#include <omath/trigonometry/view_angles.hpp>

namespace omath::unreal_engine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Created by Orange on 11/13/2024.
//
#pragma once
#include "linear_algebra/vector3.hpp"
#include "vector3.hpp"

namespace omath
{
Expand Down
2 changes: 1 addition & 1 deletion include/omath/linear_algebra/vector3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "omath/angle.hpp"
#include "omath/trigonometry/angle.hpp"
#include "omath/linear_algebra/vector2.hpp"
#include <cstdint>
#include <expected>
Expand Down
14 changes: 9 additions & 5 deletions include/omath/omath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#pragma once

// Basic math utilities
#include "omath/angles.hpp"
#include "omath/angle.hpp"
#include "omath/trigonometry/angles.hpp"
#include "omath/trigonometry/angle.hpp"

// Vector classes (in dependency order)
#include "omath/linear_algebra/vector2.hpp"
Expand All @@ -18,11 +18,11 @@
#include "omath/linear_algebra/mat.hpp"

// Color functionality
#include "omath/color.hpp"
#include "omath/utility/color.hpp"

// Geometric primitives
#include "omath/triangle.hpp"
#include "omath/view_angles.hpp"
#include "omath/linear_algebra/triangle.hpp"
#include "omath/trigonometry/view_angles.hpp"

// 3D primitives
#include "omath/3d_primitives/box.hpp"
Expand Down Expand Up @@ -82,3 +82,7 @@
#include "omath/engines/unreal_engine/camera.hpp"
#include "omath/engines/unreal_engine/traits/camera_trait.hpp"
#include "omath/engines/unreal_engine/traits/pred_engine_trait.hpp"

// Reverse Engineering
#include "omath/rev_eng/external_rev_object.hpp"
#include "omath/rev_eng/internal_rev_object.hpp"
2 changes: 1 addition & 1 deletion include/omath/projection/camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "omath/linear_algebra/mat.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include "omath/projection/error_codes.hpp"
#include <omath/trigonometry/angle.hpp>
#include <expected>
#include <omath/angle.hpp>
#include <type_traits>

#ifdef OMATH_BUILD_TESTS
Expand Down
35 changes: 35 additions & 0 deletions include/omath/rev_eng/external_rev_object.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Created by Vlad on 10/4/2025.
//

#pragma once
#include <cstddef>
#include <cstdint>

namespace omath::rev_eng
{
template<class ExternalMemoryManagementTrait>
class ExternalReverseEngineeredObject
{
public:
explicit ExternalReverseEngineeredObject(const std::uintptr_t addr): m_object_address(addr)
{
}
private:
std::uintptr_t m_object_address{};

protected:
template<class Type>
[[nodiscard]]
Type get_by_offset(const std::ptrdiff_t offset) const
{
return ExternalMemoryManagementTrait::read_memory(m_object_address+offset);
}

template<class Type>
void set_by_offset(const std::ptrdiff_t offset, const Type& value) const
{
return ExternalMemoryManagementTrait::write_memory(m_object_address+offset, value);
}
};
} // namespace omath::rev_eng
33 changes: 33 additions & 0 deletions include/omath/rev_eng/internal_rev_object.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Created by Vlad on 8/8/2025.
//

#pragma once
#include <cstddef>
#include <cstdint>

namespace omath::rev_eng
{
class InternalReverseEngineeredObject
{
protected:
template<class Type>
[[nodiscard]] Type& get_by_offset(const std::ptrdiff_t offset)
{
return *reinterpret_cast<Type*>(reinterpret_cast<std::uintptr_t>(this) + offset);
}

template<class Type>
[[nodiscard]] const Type& get_by_offset(const std::ptrdiff_t offset) const
{
return *reinterpret_cast<Type*>(reinterpret_cast<std::uintptr_t>(this) + offset);
}

template<std::size_t id, class ReturnType>
ReturnType call_virtual_method(auto... arg_list)
{
using VirtualMethodType = ReturnType(__thiscall*)(void*, decltype(arg_list)...);
return (*reinterpret_cast<VirtualMethodType**>(this))[id](this, arg_list...);
}
};
} // namespace omath::rev_eng
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

#pragma once
#include "omath/angles.hpp"
#include "omath/trigonometry/angles.hpp"
#include <algorithm>
#include <format>
#include <utility>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#pragma once

#include "linear_algebra/vector4.hpp"
#include "omath/linear_algebra/vector4.hpp"
#include <cstdint>

namespace omath
Expand Down
2 changes: 1 addition & 1 deletion tests/general/unit_test_angle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Created by Orange on 11/30/2024.
//

#include <omath/trigonometry/angle.hpp>
#include <cmath>
#include <gtest/gtest.h>
#include <numbers>
#include <omath/angle.hpp>

using namespace omath;

Expand Down
2 changes: 1 addition & 1 deletion tests/general/unit_test_angles.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//
// Created by Orange on 11/30/2024.
//
#include <omath/trigonometry/angles.hpp>
#include <gtest/gtest.h>
#include <omath/angles.hpp>

TEST(unit_test_angles, radians_to_deg)
{
Expand Down
3 changes: 1 addition & 2 deletions tests/general/unit_test_color.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//
// Created by Vlad on 01.09.2024.
//
#include <omath/utility/color.hpp>
#include <gtest/gtest.h>
#include <omath/color.hpp>


using namespace omath;

Expand Down
4 changes: 2 additions & 2 deletions tests/general/unit_test_line_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Revised unit‑test suite for LineTracer (segment‑based Möller–Trumbore)
// Pure ASCII: avoids non‑standard characters that MSVC rejects.
//
#include "omath/linear_algebra/vector3.hpp"
#include "omath/linear_algebra/triangle.hpp"
#include "omath/collision/line_tracer.hpp"
#include "omath/triangle.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include "gtest/gtest.h"
#include <cmath>

Expand Down
50 changes: 50 additions & 0 deletions tests/general/unit_test_reverse_enineering.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// Created by Vlad on 10/4/2025.
//
#include "omath/linear_algebra/vector3.hpp"
#include <gtest/gtest.h>
#include <omath/rev_eng/internal_rev_object.hpp>

class Player final
{
public:
virtual int foo() {return 1;}
virtual int bar() {return 2;}
omath::Vector3<float> m_origin{1.f, 2.f, 3.f};
int m_health{123};
};

class RevPlayer : omath::rev_eng::InternalReverseEngineeredObject
{
public:
omath::Vector3<float> get_origin()
{
return get_by_offset<omath::Vector3<float>>(sizeof(std::uintptr_t));
}
int get_health()
{
return get_by_offset<int>(sizeof(std::uintptr_t)+sizeof(omath::Vector3<float>));
}

int rev_foo()
{
return call_virtual_method<0, int>();
}
int rev_bar()
{
return call_virtual_method<1, int>();
}
};


TEST(unit_test_reverse_enineering, read_test)
{
Player player_original;
const auto player_reversed = reinterpret_cast<RevPlayer*>(&player_original);

EXPECT_EQ(player_original.m_origin, player_reversed->get_origin());
EXPECT_EQ(player_original.m_health, player_reversed->get_health());

EXPECT_EQ(player_original.bar(), player_reversed->rev_bar());
EXPECT_EQ(player_original.foo(), player_reversed->rev_foo());
}
2 changes: 1 addition & 1 deletion tests/general/unit_test_triangle.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Created by Orange on 1/6/2025.
//
#include "omath/triangle.hpp"
#include "omath/linear_algebra/triangle.hpp"
#include "omath/linear_algebra/vector3.hpp"
#include <cmath> // For std::sqrt, std::isinf, std::isnan
#include <gtest/gtest.h>
Expand Down
2 changes: 1 addition & 1 deletion tests/general/unit_test_view_angles.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
// Created by Orange on 11/30/2024.
//
#include <omath/view_angles.hpp>
#include <omath/trigonometry/view_angles.hpp>