From 6a0e88e74baa9738f63d75bfe98ef56db644a3b9 Mon Sep 17 00:00:00 2001 From: Gtker Date: Wed, 24 Jul 2024 15:20:07 +0200 Subject: [PATCH 1/4] pathfind: Add new Python API functions to C API Adds Python API functions from https://github.com/namreeb/namigator/commit/e1525f86f47afbcd7268a44b90430c81f17e7888 for C API. --- Common.hpp | 2 ++ pathfind/pathfind_c_bindings.cpp | 44 ++++++++++++++++++++++++++++++++ pathfind/pathfind_c_bindings.hpp | 19 ++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/Common.hpp b/Common.hpp index bb1679b..10bd313 100644 --- a/Common.hpp +++ b/Common.hpp @@ -203,5 +203,7 @@ enum class Result { MAP_DOES_NOT_HAVE_ADT = 87, UNABLE_TO_FIND_RANDOM_POINT_IN_CIRCLE = 88, + FAILED_TO_FIND_POINT_BETWEEN_VECTORS = 89, + UNKNOWN_EXCEPTION = 0xFF, }; diff --git a/pathfind/pathfind_c_bindings.cpp b/pathfind/pathfind_c_bindings.cpp index 1d34fdd..d1c7ddd 100644 --- a/pathfind/pathfind_c_bindings.cpp +++ b/pathfind/pathfind_c_bindings.cpp @@ -123,6 +123,19 @@ PathfindResultType pathfind_is_adt_loaded(pathfind::Map* const map, int x, int y return static_cast(Result::SUCCESS); } +PathfindResultType pathfind_has_adts(pathfind::Map* const map, bool* has_adts) { + try { + *has_adts = map->HasADTs(); + return static_cast(Result::SUCCESS); + } + catch (utility::exception& e) { + return static_cast(e.ResultCode()); + } + catch (...) { + return static_cast(Result::UNKNOWN_EXCEPTION); + } +} + PathfindResultType pathfind_get_zone_and_area(pathfind::Map* const map, float x, float y, @@ -154,6 +167,37 @@ PathfindResultType pathfind_get_zone_and_area(pathfind::Map* const map, } } +PathfindResultType pathfind_find_point_in_between_vectors(pathfind::Map* const map, + float distance, + float x1, + float y1, + float z1, + float x2, + float y2, + float z2, + Vertex* out_vertex) { + try { + const math::Vertex start {x1, y1, z1}; + const math::Vertex end {x2, y2, z2}; + math::Vertex in_between_point {}; + if (!map->FindPointInBetweenVectors(start, end, distance, in_between_point)) { + return static_cast(Result::FAILED_TO_FIND_POINT_BETWEEN_VECTORS); + } + + out_vertex->x = in_between_point.X; + out_vertex->y = in_between_point.Y; + out_vertex->z = in_between_point.Z; + + return static_cast(Result::SUCCESS); + } + catch (utility::exception& e) { + return static_cast(e.ResultCode()); + } + catch (...) { + return static_cast(Result::UNKNOWN_EXCEPTION); + } +} + PathfindResultType pathfind_find_path(pathfind::Map* const map, float start_x, float start_y, diff --git a/pathfind/pathfind_c_bindings.hpp b/pathfind/pathfind_c_bindings.hpp index be36fad..a5ca5f8 100644 --- a/pathfind/pathfind_c_bindings.hpp +++ b/pathfind/pathfind_c_bindings.hpp @@ -59,6 +59,12 @@ PathfindResultType pathfind_unload_adt(pathfind::Map* const map, int x, int y); */ PathfindResultType pathfind_is_adt_loaded(pathfind::Map* const map, int x, int y, uint8_t* const loaded); + +/* + Returns `true` if the map has any ADTs. +*/ +PathfindResultType pathfind_has_adts(pathfind::Map* const map, bool* has_adts); + /* Returns the zone and area of a particular x, y, z. */ @@ -67,6 +73,19 @@ PathfindResultType pathfind_get_zone_and_area(pathfind::Map* const map, float x, unsigned int* const out_zone, unsigned int* const out_area); +/* + Finds a point between the two vectors with a given distance. +*/ +PathfindResultType pathfind_find_point_in_between_vectors(pathfind::Map* const map, + float distance, + float x1, + float y1, + float z1, + float x2, + float y2, + float z2, + Vertex* out_vertex); + /* Calculates a path from `start_x`, `start_y`, and `start_z` to `stop_x`, `stop_y`, and `stop_z`. From d161268af800970f37e08e85604a76145b39701d Mon Sep 17 00:00:00 2001 From: Gtker Date: Wed, 24 Jul 2024 15:23:23 +0200 Subject: [PATCH 2/4] Update pybind to 2.13.1 This brings along minor fixes and compatibility with newer Python versions (3.10+). --- pybind11 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pybind11 b/pybind11 index 8a099e4..941f45b 160000 --- a/pybind11 +++ b/pybind11 @@ -1 +1 @@ -Subproject commit 8a099e44b3d5f85b20f05828d919d2332a8de841 +Subproject commit 941f45bcb51457884fa1afd6e24a67377d70f75c From bfffcd3b8c73772ab80519ba7c8de5a712b892f7 Mon Sep 17 00:00:00 2001 From: Gtker Date: Wed, 24 Jul 2024 15:26:55 +0200 Subject: [PATCH 3/4] Update stormlib to newest master This brings various fixes for division by zero and CMake improvements. --- stormlib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stormlib b/stormlib index 3235d01..37000d1 160000 --- a/stormlib +++ b/stormlib @@ -1 +1 @@ -Subproject commit 3235d01eab95af50c589a615bd8d492f911369f7 +Subproject commit 37000d13927f52c96d7ead3f9bca4fe421894fcf From 56b4b4e5579da303aad052b34e8abddfe2b9c3fb Mon Sep 17 00:00:00 2001 From: Gtker Date: Wed, 24 Jul 2024 15:30:31 +0200 Subject: [PATCH 4/4] Update recastnavigation to current main This brings various fixes and CMake updates. --- recastnavigation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recastnavigation b/recastnavigation index ee39124..455a019 160000 --- a/recastnavigation +++ b/recastnavigation @@ -1 +1 @@ -Subproject commit ee39124e5f6cb23086b4aa9eebd18454c7342f4f +Subproject commit 455a019e7aef99354ac3020f04c1fe3541aa4d19