本文整理汇总了C#中AABB.Extend方法的典型用法代码示例。如果您正苦于以下问题:C# AABB.Extend方法的具体用法?C# AABB.Extend怎么用?C# AABB.Extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABB
的用法示例。
在下文中一共展示了AABB.Extend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateExploreCells
private int GenerateExploreCells(AABB cell_aabb)
{
// should not happen
//if (m_ExploreCells.Exists(x => x.AABB.Equals(cell_aabb)))
// return;
MovementFlag movement_flags = Navmesh.Navigator.MovementFlags;
//using (new Profiler("[Nav] Nav data generated [{t}]"))
using (Navmesh.AquireReadDataLock())
{
List<Cell> cells = new List<Cell>();
// find all cells inside cell_aabb
foreach (GridCell grid_cell in Navmesh.m_GridCells)
{
if (!cell_aabb.Overlaps2D(grid_cell.AABB))
continue;
cells.AddRange(grid_cell.Cells.FindAll(x => !x.Replacement && x.HasFlags(movement_flags) && cell_aabb.Overlaps2D(x.AABB)));
}
// add all replaced cells overlapped by explore cell
//cells.AddRange(Navmesh.GetReplacedCells().FindAll(x => x.HasFlags(movement_flags) && cell_aabb.Overlaps2D(x.AABB)));
//create ExploreCell for each interconnected group of cells
List<Cell> cells_copy = new List<Cell>(cells);
int last_explore_cells_count = m_ExploreCells.Count;
while (cells_copy.Count > 0)
{
List<Cell> visited = new List<Cell>();
Algorihms.Visit(cells_copy[0], ref visited, movement_flags, true, 1, -1, cells_copy);
List<AABB> intersections = new List<AABB>();
AABB intersections_aabb = new AABB();
foreach (Cell c in visited)
{
AABB intersection = cell_aabb.Intersect(c.AABB);
intersections.Add(intersection);
intersections_aabb.Extend(intersection);
}
Vec3 nearest_intersection_center = Vec3.Empty;
float nearest_intersection_dist = float.MaxValue;
foreach (AABB inter_aabb in intersections)
{
float dist = inter_aabb.Center.Distance2D(intersections_aabb.Center);
if (dist < nearest_intersection_dist)
{
nearest_intersection_center = inter_aabb.Center;
nearest_intersection_dist = dist;
}
}
ExploreCell ex_cell = new ExploreCell(cell_aabb, visited, nearest_intersection_center, m_LastExploreCellId++);
Add(ex_cell);
ex_cell.Small = (ex_cell.CellsArea() < MAX_AREA_TO_MARK_AS_SMALL);
cells_copy.RemoveAll(x => visited.Contains(x));
}
return m_ExploreCells.Count - last_explore_cells_count;
}
}