Skip to content

Commit

Permalink
Merge pull request #71 from gtker/update-c-api
Browse files Browse the repository at this point in the history
pathfind: Add new Python API functions to C API and update dependencies
  • Loading branch information
namreeb authored Jul 24, 2024
2 parents f03d9f1 + 56b4b4e commit 7a1b98d
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
44 changes: 44 additions & 0 deletions pathfind/pathfind_c_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ PathfindResultType pathfind_is_adt_loaded(pathfind::Map* const map, int x, int y
return static_cast<PathfindResultType>(Result::SUCCESS);
}

PathfindResultType pathfind_has_adts(pathfind::Map* const map, bool* has_adts) {
try {
*has_adts = map->HasADTs();
return static_cast<PathfindResultType>(Result::SUCCESS);
}
catch (utility::exception& e) {
return static_cast<PathfindResultType>(e.ResultCode());
}
catch (...) {
return static_cast<PathfindResultType>(Result::UNKNOWN_EXCEPTION);
}
}

PathfindResultType pathfind_get_zone_and_area(pathfind::Map* const map,
float x,
float y,
Expand Down Expand Up @@ -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<PathfindResultType>(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<PathfindResultType>(Result::SUCCESS);
}
catch (utility::exception& e) {
return static_cast<PathfindResultType>(e.ResultCode());
}
catch (...) {
return static_cast<PathfindResultType>(Result::UNKNOWN_EXCEPTION);
}
}

PathfindResultType pathfind_find_path(pathfind::Map* const map,
float start_x,
float start_y,
Expand Down
19 changes: 19 additions & 0 deletions pathfind/pathfind_c_bindings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion pybind11
Submodule pybind11 updated 163 files
2 changes: 1 addition & 1 deletion recastnavigation
Submodule recastnavigation updated 44 files
+49 −3 CHANGELOG.md
+3 −3 CMakeLists.txt
+1 −1 CODE_OF_CONDUCT.md
+37 −128 CONTRIBUTING.md
+1 −1 Detour/Include/DetourAssert.h
+1 −1 Detour/Include/DetourNavMesh.h
+3 −3 Detour/Include/DetourNavMeshBuilder.h
+4 −4 Detour/Include/DetourNavMeshQuery.h
+1 −1 Detour/Source/DetourAssert.cpp
+4 −4 Detour/Source/DetourNavMeshBuilder.cpp
+13 −13 Detour/Source/DetourNavMeshQuery.cpp
+2 −2 DetourCrowd/Include/DetourCrowd.h
+1 −1 DetourCrowd/Source/DetourObstacleAvoidance.cpp
+5 −5 DetourCrowd/Source/DetourPathCorridor.cpp
+2 −2 DetourTileCache/Include/DetourTileCacheBuilder.h
+4 −4 Docs/Extern/Recast_api.txt
+ Docs/Images/logo.png
+34 −0 Docs/Readme.md
+0 −59 Docs/Readme.txt
+85 −0 Docs/_1_Introducation.md
+83 −0 Docs/_2_BuildingAndIntegrating.md
+42 −0 Docs/_3_FAQ.md
+16 −16 Docs/_99_Roadmap.md
+258 −95 Doxyfile
+47 −67 README.md
+13 −10 Recast/Include/Recast.h
+1 −1 Recast/Include/RecastAlloc.h
+1 −1 Recast/Include/RecastAssert.h
+1 −1 Recast/Source/RecastAssert.cpp
+3 −3 Recast/Source/RecastContour.cpp
+78 −61 Recast/Source/RecastFilter.cpp
+8 −7 Recast/Source/RecastMesh.cpp
+40 −28 Recast/Source/RecastMeshDetail.cpp
+40 −41 Recast/Source/RecastRasterization.cpp
+9 −4 Recast/Source/RecastRegion.cpp
+1 −1 RecastDemo/Source/NavMeshPruneTool.cpp
+3 −3 RecastDemo/Source/Sample_SoloMesh.cpp
+3 −2 RecastDemo/premake5.lua
+10 −5 Tests/CMakeLists.txt
+119 −0 Tests/DetourCrowd/Tests_DetourPathCorridor.cpp
+168 −0 Tests/Recast/Bench_rcVector.cpp
+260 −0 Tests/Recast/Tests_Alloc.cpp
+28 −440 Tests/Recast/Tests_Recast.cpp
+339 −0 Tests/Recast/Tests_RecastFilter.cpp
2 changes: 1 addition & 1 deletion stormlib
Submodule stormlib updated 60 files
+26 −0 .vscode/c_cpp_properties.json
+34 −0 .vscode/launch.json
+7 −0 .vscode/settings.json
+28 −0 .vscode/tasks.json
+18 −11 CMakeLists.txt
+0 −25 Publish.bat
+1 −1 README.md
+0 −3 StormLib.kdev4
+3 −3 StormLib.sln
+3 −196 StormLib.vcxproj
+221 −0 StormLib.vcxproj.filters
+8 −201 StormLib_dll.vcxproj
+229 −0 StormLib_dll.vcxproj.filters
+3 −196 StormLib_test.vcxproj
+230 −0 StormLib_test.vcxproj.filters
+12 −824 StormLib_vs08.vcproj
+16 −828 StormLib_vs08_dll.vcproj
+12 −824 StormLib_vs08_test.vcproj
+0 −830 StormLib_vs19.vcxproj.filters
+0 −838 StormLib_vs19_dll.vcxproj.filters
+0 −839 StormLib_vs19_test.vcxproj.filters
+25 −19 make-msvc.bat
+8 −8 src/DllMain.rc
+8 −8 src/FileStream.cpp
+85 −0 src/LibTomCrypt.c
+125 −0 src/LibTomMath.c
+4 −0 src/LibTomMathDesc.c
+84 −80 src/SBaseCommon.cpp
+248 −173 src/SBaseFileTable.cpp
+96 −30 src/SBaseSubTypes.cpp
+66 −45 src/SCompression.cpp
+21 −5 src/SFileAddFile.cpp
+4 −1 src/SFileAttributes.cpp
+1 −1 src/SFileCompactArchive.cpp
+11 −1 src/SFileCreateArchive.cpp
+5 −2 src/SFileFindFile.cpp
+42 −24 src/SFileGetFileInfo.cpp
+48 −1 src/SFileListFile.cpp
+53 −22 src/SFileOpenArchive.cpp
+19 −14 src/SFileOpenFileEx.cpp
+6 −6 src/SFilePatchArchives.cpp
+23 −14 src/SFileReadFile.cpp
+19 −14 src/SFileVerify.cpp
+11 −1 src/StormCommon.h
+30 −19 src/StormLib.h
+2 −1 src/StormPort.h
+1 −1 src/adpcm/adpcm.h
+66 −43 src/huffman/huff.cpp
+3 −3 src/huffman/huff.h
+340 −0 src/libtomcrypt/src/hashes/sha256.c
+18 −18 src/libtomcrypt/src/headers/tomcrypt_custom.h
+4 −2 src/pklib/pklib.h
+5 −0 src/sparse/sparse.cpp
+0 −1 src/wdk/sources-wdk-tommath.c
+0 −43 storm_dll/storm_vs19.sln
+0 −90 test/Readme.txt
+1,616 −1,916 test/StormTest.cpp
+448 −343 test/TLogHelper.cpp
+164 −0 test/stormlib-test-001.txt
+0 −2,351 test/stormlib-test.txt

0 comments on commit 7a1b98d

Please sign in to comment.