本文整理汇总了C++中Layer::GetGrids方法的典型用法代码示例。如果您正苦于以下问题:C++ Layer::GetGrids方法的具体用法?C++ Layer::GetGrids怎么用?C++ Layer::GetGrids使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layer
的用法示例。
在下文中一共展示了Layer::GetGrids方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: searchDestinationGrid
Grid* World::searchDestinationGrid(Object * object, bool isInternal)
{
Layer* belongLayer = nullptr;
int nextIndex = 0;
int belongIndex = 0;
auto aabb = object->GetAABB();
auto center = aabb.GetPosition() + aabb.GetSize() / 2;
auto size = aabb.GetSize();
for (int currentResolution = 0; currentResolution <= resolution; ++currentResolution)
{
auto range = layers[currentResolution]->GetGrids()[nextIndex]->GetGridRange();
//グリッドの縦横がそれぞれ円の直径を上回っていないか調べる。
if (range.GetIsContainingPoint(center) && range.Height >= size.Y && range.Width >= size.X)
{
belongLayer = layers[currentResolution];
belongIndex = nextIndex;
}
else
{
break;
}
if (currentResolution >= layers.size() - 1)
{
continue;
}
//次に遷移するレイヤーにおけるグリッドの添字を調べる。
auto children = Grid::GetChildrenIndices(belongIndex, currentResolution);
auto nextLayer = layers[currentResolution + 1];
nextIndex = -1;
for (auto gridIndex : children)
{
RectF gridRange = nextLayer->GetGrids()[gridIndex]->GetGridRange();
if (gridRange.GetIsContainingPoint(center))
{
nextIndex = gridIndex;
break;
}
}
if (nextIndex == -1)
{
break;
}
}
{
upperLeft_.X = Min(upperLeft_.X, aabb.X);
upperLeft_.Y = Min(upperLeft_.Y, aabb.Y);
lowerRight_.X = Max(lowerRight_.X, aabb.X + aabb.Width);
lowerRight_.Y = Max(lowerRight_.Y, aabb.Y + aabb.Height);
minRadius_ = Min(minRadius_, Min(aabb.Width, aabb.Height));
}
if (belongLayer == nullptr)
{
if (object->GetIsInWorld())
{
++outOfRangeObjectsCount;
}
object->SetIsInWorld(false);
return layers[0]->GetGrids()[0];
}
else
{
if (!object->GetIsInWorld())
{
--outOfRangeObjectsCount;
}
object->SetIsInWorld(true);
return belongLayer->GetGrids()[belongIndex];
}
}