Skip to content

Commit

Permalink
Add line of sight to C API
Browse files Browse the repository at this point in the history
  • Loading branch information
Gtker committed Jul 6, 2023
1 parent f326314 commit 65fc766
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pathfind/pathfind_c_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,26 @@ PathfindResultType pathfind_find_height(pathfind::Map* const map, float start_x,
return static_cast<PathfindResultType>(Result::UNKNOWN_EXCEPTION);
}
}

PathfindResultType pathfind_line_of_sight(pathfind::Map* map,
float start_x, float start_y, float start_z,
float stop_x, float stop_y, float stop_z,
uint8_t* const line_of_sight) {
try
{
if (map->LineOfSight({start_x, start_y, start_z}, {stop_x, stop_y, stop_z})) {
*line_of_sight = 1;
} else {
*line_of_sight = 0;
}
}
catch (utility::exception& e)
{
return static_cast<PathfindResultType>(e.ResultCode());
}
catch (...)
{
return static_cast<PathfindResultType>(Result::UNKNOWN_EXCEPTION);
}
}
} // extern "C"
5 changes: 5 additions & 0 deletions pathfind/pathfind_c_bindings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ PathfindResultType pathfind_find_height(pathfind::Map* const map, float start_x,
float start_y, float start_z,
float stop_x, float stop_y,
float* const stop_z);

PathfindResultType pathfind_line_of_sight(pathfind::Map* map,
float start_x, float start_y, float start_z,
float stop_x, float stop_y, float stop_z,
uint8_t* const line_of_sight);
} // extern "C"

0 comments on commit 65fc766

Please sign in to comment.