本文整理汇总了C#中OctreeNode.ClearObjects方法的典型用法代码示例。如果您正苦于以下问题:C# OctreeNode.ClearObjects方法的具体用法?C# OctreeNode.ClearObjects怎么用?C# OctreeNode.ClearObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OctreeNode
的用法示例。
在下文中一共展示了OctreeNode.ClearObjects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BreakDownNode
///
/// <summary>
/// Subdivide a leaf node into 8 equal volumes and distribute the objects within that node across the 8 new children
/// </summary>
///
/// <param name="node">
/// The node to break down
/// </param>
///
private void BreakDownNode(OctreeNode node)
{
// We shouldn't ever call this on a node that has already been broken down but if for some reason
// we do we should fail in a noticable manner so we can debug the problem rather than tracking
// down the silent error based on some unpredicted side effect.
if (node.Children != null)
{
throw new ArgumentException("Called Octree.BreakDownNode on a node which has already been broken down");
}
node.Children = new OctreeNode[8];
BoundingBox nodeBoundingBox = _masterBoundingBoxList[node.BoundingBoxIndex];
nodeBoundingBox.Max += node.BoundingBoxPosition;
nodeBoundingBox.Min += node.BoundingBoxPosition;
Vector3[] nodeCorners = nodeBoundingBox.GetCorners();
Vector3 nodeCenter = (nodeBoundingBox.Max + nodeBoundingBox.Min) / 2.0f;
// shrink our bounding box by a factor of 2. We will use the same bounding box for all 8 children
Vector3[] points = new Vector3[2];
points[0] = _masterBoundingBoxList[node.BoundingBoxIndex].Max / 2.0f;
points[1] = _masterBoundingBoxList[node.BoundingBoxIndex].Min / 2.0f;
BoundingBox newBoundingBox = BoundingBox.CreateFromPoints(points);
int boundingBoxIndex;
if (_masterBoundingBoxList.Contains(newBoundingBox))
{
boundingBoxIndex = _masterBoundingBoxList.FindIndex(x => x == newBoundingBox);
}
else
{
_masterBoundingBoxList.Add(newBoundingBox);
boundingBoxIndex =_masterBoundingBoxList.Count - 1;
}
for (int i = 0; i < node.Children.Length; ++i)
{
Vector3 subRegionCenter = (nodeCorners[i] + nodeCenter) / 2.0f;
node.Children[i] = new OctreeNode(boundingBoxIndex, subRegionCenter);
}
AddItems(node.InternalObjectPositions.ToArray(), node.InternalObjectBoundingBoxes.ToArray(), node);
node.ClearObjects();
}