本文整理汇总了C#中BEPUphysics.BroadPhaseEntries.BroadPhaseEntry.UpdateBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C# BroadPhaseEntry.UpdateBoundingBox方法的具体用法?C# BroadPhaseEntry.UpdateBoundingBox怎么用?C# BroadPhaseEntry.UpdateBoundingBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BEPUphysics.BroadPhaseEntries.BroadPhaseEntry
的用法示例。
在下文中一共展示了BroadPhaseEntry.UpdateBoundingBox方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
/// <summary>
/// Adds an entry to the broad phase.
/// </summary>
/// <param name="entry">Entry to add.</param>
public override void Add(BroadPhaseEntry entry)
{
base.Add(entry);
//Entities do not set up their own bounding box before getting stuck in here. If they're all zeroed out, the tree will be horrible.
Vector3 offset;
Vector3.Subtract(ref entry.boundingBox.Max, ref entry.boundingBox.Min, out offset);
if (offset.X * offset.Y * offset.Z == 0)
entry.UpdateBoundingBox();
//binary search for the approximately correct location. This helps prevent large first-frame sort times.
int minIndex = 0; //inclusive
int maxIndex = entries.Count; //exclusive
int index = 0;
while (maxIndex - minIndex > 0)
{
index = (maxIndex + minIndex) / 2;
if (entries.Elements[index].boundingBox.Min.X > entry.boundingBox.Min.X)
maxIndex = index;
else if (entries.Elements[index].boundingBox.Min.X < entry.boundingBox.Min.X)
minIndex = ++index;
else
break; //Found an equal value!
}
entries.Insert(index, entry);
}
示例2: Add
/// <summary>
/// Adds an entry to the broad phase.
/// </summary>
/// <param name="entry">Entry to add.</param>
public override void Add(BroadPhaseEntry entry)
{
base.Add(entry);
//Entities do not set up their own bounding box before getting stuck in here. If they're all zeroed out, the tree will be horrible.
System.Numerics.Vector3 offset;
Vector3Ex.Subtract(ref entry.boundingBox.Max, ref entry.boundingBox.Min, out offset);
if (offset.X * offset.Y * offset.Z == 0)
entry.UpdateBoundingBox();
var newEntry = entryPool.Take();
newEntry.Initialize(entry);
entries.Add(newEntry);
//Add the object to the grid.
for (int i = newEntry.previousMin.Y; i <= newEntry.previousMax.Y; i++)
{
for (int j = newEntry.previousMin.Z; j <= newEntry.previousMax.Z; j++)
{
var index = new Int2 {Y = i, Z = j};
cellSet.Add(ref index, newEntry);
}
}
}