动态阻挡增加Flag
kangzr opened this issue · 1 comments
kangzr commented
添加动态阻挡时想要带上Flag,业务层可根据其Flag做不同业务逻辑
fananchong commented
看了下源代码,动态障碍物的实现原理,是把动态障碍物区域镂空。镂空后,这块区域是 DT_TILECACHE_NULL_AREA 。寻路上,就是遇到 Wall 。即动态障碍物区域是没有 ploy 的,更无法谈及对 ploy 设置 flag
具体相关代码如下:
dtStatus dtTileCache::buildNavMeshTile(const dtCompressedTileRef ref, dtNavMesh* navmesh)
{
// 略
// Rasterize obstacles.
for (int i = 0; i < m_params.maxObstacles; ++i)
{
const dtTileCacheObstacle* ob = &m_obstacles[i];
if (ob->state == DT_OBSTACLE_EMPTY || ob->state == DT_OBSTACLE_REMOVING)
continue;
if (contains(ob->touched, ob->ntouched, ref))
{
if (ob->type == DT_OBSTACLE_CYLINDER)
{
dtMarkCylinderArea(*bc.layer, tile->header->bmin, m_params.cs, m_params.ch,
ob->cylinder.pos, ob->cylinder.radius, ob->cylinder.height, 0);
}
else if (ob->type == DT_OBSTACLE_BOX)
{
dtMarkBoxArea(*bc.layer, tile->header->bmin, m_params.cs, m_params.ch,
ob->box.bmin, ob->box.bmax, 0);
}
else if (ob->type == DT_OBSTACLE_ORIENTED_BOX)
{
dtMarkBoxArea(*bc.layer, tile->header->bmin, m_params.cs, m_params.ch,
ob->orientedBox.center, ob->orientedBox.halfExtents, ob->orientedBox.rotAux, 0);
}
}
}
// Build navmesh
status = dtBuildTileCacheRegions(m_talloc, *bc.layer, walkableClimbVx);
if (dtStatusFailed(status))
return status;
// 略
}
dtMarkCylinderArea 、 dtMarkBoxArea 的最后一个参数 0 ,即为 DT_TILECACHE_NULL_AREA