This commit is contained in:
aozhiwei 2020-08-18 17:03:26 +08:00
parent e5028fdc79
commit fe61fb7d12
3 changed files with 10 additions and 7 deletions

View File

@ -66,8 +66,10 @@ void MapInstance::Init()
NavMeshHelper::OutputObjFile(this); NavMeshHelper::OutputObjFile(this);
#endif #endif
#ifdef FIND_PATH_TEST #ifdef FIND_PATH_TEST
if (map_meta_->i->map_id() == 4001) {
NavMeshBuilder::Instance()->Build(this); NavMeshBuilder::Instance()->Build(this);
map_service_->SetNavMesh(navmesh_); map_service_->SetNavMesh(navmesh_);
}
#endif #endif
} }

View File

@ -460,19 +460,19 @@ void MapService::UpdateNavmesh(FindPathStatus* find_status)
float spos[3]; float spos[3];
spos[0] = find_status->start_pos.x; spos[0] = find_status->start_pos.x;
spos[1] = find_status->start_pos.y; spos[1] = 0;
spos[2] = 0; spos[2] = find_status->start_pos.y;
float epos[3]; float epos[3];
epos[0] = find_status->end_pos.x; epos[0] = find_status->end_pos.x;
epos[1] = find_status->end_pos.x; epos[1] = 0;
epos[2] = 0; epos[2] = find_status->end_pos.y;
dtQueryFilter filter; dtQueryFilter filter;
filter.setIncludeFlags(0xffff); filter.setIncludeFlags(0xffff);
filter.setExcludeFlags(0); filter.setExcludeFlags(0);
const float extents[3] = {2.f, 4.f, 2.f}; const float extents[3] = {20.f, 0.f, 20.f};
dtPolyRef start_ref = INVALID_NAVMESH_POLYREF; dtPolyRef start_ref = INVALID_NAVMESH_POLYREF;
dtPolyRef end_ref = INVALID_NAVMESH_POLYREF; dtPolyRef end_ref = INVALID_NAVMESH_POLYREF;

View File

@ -37,6 +37,7 @@ void NavMeshBuilder::Build(MapInstance* map_instance)
CreateNavMesh(builder_params); CreateNavMesh(builder_params);
BuildTiles(builder_params); BuildTiles(builder_params);
BuildMapObstalce(builder_params); BuildMapObstalce(builder_params);
map_instance->navmesh_ = builder_params.navmesh;
} }
void NavMeshBuilder::InitBuilderParams(BuilderParams& builder_params) void NavMeshBuilder::InitBuilderParams(BuilderParams& builder_params)