本文整理汇总了C++中Partition::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ Partition::Init方法的具体用法?C++ Partition::Init怎么用?C++ Partition::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Partition
的用法示例。
在下文中一共展示了Partition::Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
// 3D spatial partition
bool SpatialPartitionManager::Init(Vector3 minWorldDimension, Vector3 maxWorldDimension, Vector3 worldDivision, bool numPartitionBased, Mesh* mesh)
{
worldDimension = maxWorldDimension - minWorldDimension;
// ensure the data are not 0
if (worldDimension.IsZero() || worldDivision.IsZero())
{
return false;
}
else
{
// divide the world base on the number of partitons given
if (numPartitionBased)
{
numPartition = worldDivision;
partitionDimension.Set(worldDimension.x / worldDivision.x, worldDimension.y / worldDivision.y, worldDimension.z / worldDivision.z);
}
else
{
partitionDimension = worldDivision;
numPartition.Set(worldDimension.x / partitionDimension.x, worldDimension.y / partitionDimension.y, worldDimension.z / partitionDimension.z);
}
}
type = PARTITION_3D;
this->minWorldDimension = minWorldDimension;
this->maxWorldDimension = maxWorldDimension;
int id = 0;
for (int k = 0; k < numPartition.z; ++k)
{
for (int j = 0; j < numPartition.y; ++j)
{
for (int i = 0; i < numPartition.x; ++i)
{
id = i + j * (int)numPartition.x + k * (int)numPartition.x * (int)numPartition.y;
Partition* partition = new Partition();
partition->Init(partitionDimension,
Vector3(minWorldDimension.x + i * partitionDimension.x,
minWorldDimension.y + j * partitionDimension.y,
minWorldDimension.z + k * partitionDimension.z),
Vector3(minWorldDimension.x + (i + 1) * partitionDimension.x,
minWorldDimension.y + (j + 1) * partitionDimension.y,
minWorldDimension.z + (k + 1) * partitionDimension.z),
id,
mesh);
partitions.push_back(partition);
}
}
}
return true;
}