Compare commits

..

4 Commits

Author SHA1 Message Date
va_alpatov
28e86fc355 tests hotfix 2026-04-11 20:23:08 +03:00
va_alpatov
93e7a9457a fixed pathfinding bug 2026-04-11 20:06:39 +03:00
8f65183882 fixed tests 2026-04-08 15:34:10 +03:00
327db8d441 updated contributing 2026-04-03 20:59:34 +03:00
4 changed files with 40 additions and 34 deletions

View File

@@ -1,32 +1,36 @@
## 🤝 Contributing to OMath or other Orange's Projects # Contributing
### ❕ Prerequisites ## Prerequisites
- A working up-to-date OMath installation - C++ compiler with C++23 support (Clang 18+, GCC 14+, MSVC 19.38+)
- C++ knowledge - CMake 3.25+
- Git knowledge - Git
- Ability to ask for help (Feel free to create empty pull-request or PM a maintainer - Familiarity with the codebase (see `INSTALL.md` for setup)
in [Telegram](https://t.me/orange_cpp))
### ⏬ Setting up OMath For questions, create a draft PR or reach out via [Telegram](https://t.me/orange_cpp).
Please read INSTALL.md file in repository ## Workflow
### 🔀 Pull requests and Branches 1. [Fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) the repository.
2. Create a feature branch from `main`.
3. Make your changes, ensuring tests pass.
4. Open a [pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) against `main`.
In order to send code back to the official OMath repository, you must first create a copy of OMath on your github ## Code Style
account ([fork](https://help.github.com/articles/creating-a-pull-request-from-a-fork/)) and
then [create a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) back to OMath.
OMath development is performed on multiple branches. Changes are then pull requested into master. By default, changes Follow the project `.clang-format`. Run `clang-format` before committing.
merged into master will not roll out to stable build users unless the `stable` tag is updated.
### 📜 Code-Style ## Building
The orange code-style can be found in `.clang-format`. Use one of the CMake presets defined in `CMakePresets.json`:
### 📦 Building ```bash
cmake --preset <preset-name> -DOMATH_BUILD_TESTS=ON
cmake --build --preset <preset-name>
```
OMath has already created the `cmake-build` and `out` directories where cmake/bin files are located. By default, you Run `cmake --list-presets` to see available configurations.
can build OMath by running `cmake --build cmake-build/build/windows-release --target omath -j 6` in the source
directory. ## Tests
All new functionality must include unit tests. Run the test binary after building to verify nothing is broken.

View File

@@ -71,18 +71,18 @@ void drawChar(char c, float x, float y, float scale, const Color& color, std::ve
lines.push_back(x + x1 * w); lines.push_back(x + x1 * w);
lines.push_back(y + y1 * h); lines.push_back(y + y1 * h);
lines.push_back(0.0f); lines.push_back(0.0f);
lines.push_back(color.x); lines.push_back(color.value().x);
lines.push_back(color.y); lines.push_back(color.value().y);
lines.push_back(color.z); lines.push_back(color.value().z);
lines.push_back(1.0f); // size lines.push_back(1.0f); // size
lines.push_back(1.0f); // isLine lines.push_back(1.0f); // isLine
lines.push_back(x + x2 * w); lines.push_back(x + x2 * w);
lines.push_back(y + y2 * h); lines.push_back(y + y2 * h);
lines.push_back(0.0f); lines.push_back(0.0f);
lines.push_back(color.x); lines.push_back(color.value().x);
lines.push_back(color.y); lines.push_back(color.value().y);
lines.push_back(color.z); lines.push_back(color.value().z);
lines.push_back(1.0f); // size lines.push_back(1.0f); // size
lines.push_back(1.0f); // isLine lines.push_back(1.0f); // isLine
}; };

View File

@@ -87,11 +87,11 @@ namespace omath::pathfinding
const auto current_node = current_node_it->second; const auto current_node = current_node_it->second;
closed_list.emplace(current, current_node);
if (current == end_vertex) if (current == end_vertex)
return reconstruct_final_path(closed_list, current); return reconstruct_final_path(closed_list, current);
closed_list.emplace(current, current_node);
for (const auto& neighbor: nav_mesh.get_neighbors(current)) for (const auto& neighbor: nav_mesh.get_neighbors(current))
{ {
if (closed_list.contains(neighbor)) if (closed_list.contains(neighbor))

View File

@@ -40,8 +40,9 @@ TEST(AStarExtra, TrivialNeighbor)
nav.m_vertex_map[v2] = {v1}; nav.m_vertex_map[v2] = {v1};
const auto path = Astar::find_path(v1, v2, nav); const auto path = Astar::find_path(v1, v2, nav);
ASSERT_EQ(path.size(), 1u); ASSERT_EQ(path.size(), 2u);
EXPECT_EQ(path.front(), v2); EXPECT_EQ(path.front(), v1);
EXPECT_EQ(path.back(), v2);
} }
TEST(AStarExtra, StartEqualsGoal) TEST(AStarExtra, StartEqualsGoal)
@@ -101,7 +102,7 @@ TEST(AStarExtra, LongerPathAvoidsBlock)
constexpr Vector3<float> goal = idx(2, 1); constexpr Vector3<float> goal = idx(2, 1);
const auto path = Astar::find_path(start, goal, nav); const auto path = Astar::find_path(start, goal, nav);
ASSERT_FALSE(path.empty()); ASSERT_FALSE(path.empty());
EXPECT_EQ(path.front(), goal); EXPECT_EQ(path.back(), goal);
} }
TEST(AstarTests, TrivialDirectNeighborPath) TEST(AstarTests, TrivialDirectNeighborPath)
@@ -114,8 +115,9 @@ TEST(AstarTests, TrivialDirectNeighborPath)
nav.m_vertex_map.emplace(v2, std::vector<Vector3<float>>{v1}); nav.m_vertex_map.emplace(v2, std::vector<Vector3<float>>{v1});
const auto path = Astar::find_path(v1, v2, nav); const auto path = Astar::find_path(v1, v2, nav);
ASSERT_EQ(path.size(), 1u); ASSERT_EQ(path.size(), 2u);
EXPECT_EQ(path.front(), v2); EXPECT_EQ(path.front(), v1);
EXPECT_EQ(path.back(), v2);
} }
TEST(AstarTests, NoPathWhenDisconnected) TEST(AstarTests, NoPathWhenDisconnected)