Added path showing
This commit is contained in:
1 parent
4eaefd25d4
commit
dc76986cd3
7 files changed
+75
-9
No files matched your search
@@ -300,6 +300,10 @@ namespace ZL
|
||||
|
||||
navigation.build(obstacles, "resources/config2/navigation.json", CONST_ZIP_FILE);
|
||||
|
||||
#ifdef SHOW_PATH
|
||||
buildDebugNavMeshes();
|
||||
#endif
|
||||
|
||||
auto planner = [this](const Eigen::Vector3f& start, const Eigen::Vector3f& end) {
|
||||
return navigation.findPath(start, end);
|
||||
};
|
||||
@@ -315,6 +319,35 @@ namespace ZL
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SHOW_PATH
|
||||
void Game::buildDebugNavMeshes()
|
||||
{
|
||||
debugNavMeshes.clear();
|
||||
const auto& areas = navigation.getAreas();
|
||||
float y = navigation.getFloorY() + 0.02f;
|
||||
Eigen::Vector3f red(1.0f, 0.0f, 0.0f);
|
||||
|
||||
for (const auto& area : areas) {
|
||||
if (area.polygon.size() < 3) continue;
|
||||
VertexRenderStruct mesh;
|
||||
mesh.data = CreatePolygonFloor(area.polygon, y, red);
|
||||
mesh.RefreshVBO();
|
||||
debugNavMeshes.push_back(std::move(mesh));
|
||||
}
|
||||
}
|
||||
|
||||
void Game::drawDebugNavigation()
|
||||
{
|
||||
renderer.shaderManager.PushShader("defaultColor");
|
||||
renderer.SetMatrix();
|
||||
for (const auto& mesh : debugNavMeshes) {
|
||||
renderer.DrawVertexRenderStruct(mesh);
|
||||
}
|
||||
renderer.shaderManager.PopShader();
|
||||
renderer.SetMatrix();
|
||||
}
|
||||
#endif
|
||||
|
||||
InteractiveObject* Game::raycastInteractiveObjects(const Eigen::Vector3f& rayOrigin, const Eigen::Vector3f& rayDir) {
|
||||
if (interactiveObjects.empty()) {
|
||||
std::cout << "[RAYCAST] No interactive objects to check" << std::endl;
|
||||
@@ -465,6 +498,9 @@ namespace ZL
|
||||
if (player) player->draw(renderer);
|
||||
for (auto& npc : npcs) npc->draw(renderer);
|
||||
|
||||
#ifdef SHOW_PATH
|
||||
drawDebugNavigation();
|
||||
#endif
|
||||
|
||||
renderer.PopMatrix();
|
||||
|
||||
|
||||
Reference in new issue
Block a user