This commit is contained in:
azw 2021-09-15 22:03:35 +08:00
parent f136b4c91e
commit f0b02eafc6
2 changed files with 6 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#include "dummyentity.h" #include "dummyentity.h"
#include "mapblock.h" #include "mapblock.h"
#include "roommgr.h" #include "roommgr.h"
#include "navmeshbuilder.h"
const int MAX_POLYS = 256; const int MAX_POLYS = 256;
static const int INVALID_NAVMESH_POLYREF = 0; static const int INVALID_NAVMESH_POLYREF = 0;
@ -66,6 +67,8 @@ void MapInstance::Init()
if (current_uniid_ >= FIXED_OBJECT_MAXID) { if (current_uniid_ >= FIXED_OBJECT_MAXID) {
abort(); abort();
} }
NavMeshBuilder::Instance()->Build(this);
map_service_->SetNavMesh(navmesh_);
} }
void MapInstance::UnInit() void MapInstance::UnInit()

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
class dtNavMesh;
class Human; class Human;
class ColliderComponent; class ColliderComponent;
@ -73,11 +74,13 @@ class MapService
const a8::Vec2& pos, const a8::Vec2& pos,
ColliderComponent* collider, ColliderComponent* collider,
ColliderComponent** pickup_collider); ColliderComponent** pickup_collider);
void SetNavMesh(dtNavMesh* navmesh) { navmesh_ = navmesh; };
private: private:
int GetGridId(float world_x, float world_y); int GetGridId(float world_x, float world_y);
private: private:
dtNavMesh* navmesh_ = nullptr;
list_head* map_cells_ = nullptr; list_head* map_cells_ = nullptr;
int map_width_ = 0; int map_width_ = 0;
int map_height_ = 0; int map_height_ = 0;