本文整理汇总了C#中AABB.isValid方法的典型用法代码示例。如果您正苦于以下问题:C# AABB.isValid方法的具体用法?C# AABB.isValid怎么用?C# AABB.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABB
的用法示例。
在下文中一共展示了AABB.isValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: moveProxy
public bool moveProxy(int proxyId, AABB aabb, Vec2 displacement)
{
Debug.Assert(aabb.isValid());
Debug.Assert(0 <= proxyId && proxyId < m_nodeCapacity);
DynamicTreeNode node = m_nodes[proxyId];
Debug.Assert(node.child1 == null);
AABB nodeAABB = node.aabb;
// if (nodeAABB.contains(aabb)) {
if (nodeAABB.lowerBound.x <= aabb.lowerBound.x && nodeAABB.lowerBound.y <= aabb.lowerBound.y
&& aabb.upperBound.x <= nodeAABB.upperBound.x && aabb.upperBound.y <= nodeAABB.upperBound.y)
{
return false;
}
removeLeaf(node);
// Extend AABB
Vec2 lowerBound = nodeAABB.lowerBound;
Vec2 upperBound = nodeAABB.upperBound;
lowerBound.x = aabb.lowerBound.x - Settings.aabbExtension;
lowerBound.y = aabb.lowerBound.y - Settings.aabbExtension;
upperBound.x = aabb.upperBound.x + Settings.aabbExtension;
upperBound.y = aabb.upperBound.y + Settings.aabbExtension;
// Predict AABB displacement.
float dx = displacement.x*Settings.aabbMultiplier;
float dy = displacement.y*Settings.aabbMultiplier;
if (dx < 0.0f)
{
lowerBound.x += dx;
}
else
{
upperBound.x += dx;
}
if (dy < 0.0f)
{
lowerBound.y += dy;
}
else
{
upperBound.y += dy;
}
insertLeaf(proxyId);
return true;
}
示例2: query
public void query(TreeCallback callback, AABB aabb)
{
Debug.Assert(aabb.isValid());
nodeStackIndex = 0;
nodeStack[nodeStackIndex++] = m_root;
while (nodeStackIndex > 0)
{
DynamicTreeNode node = nodeStack[--nodeStackIndex];
if (node == null)
{
continue;
}
if (AABB.testOverlap(node.aabb, aabb))
{
if (node.child1 == null)
{
bool proceed = callback.treeCallback(node.id);
if (!proceed)
{
return;
}
}
else
{
if (nodeStack.Length - nodeStackIndex - 2 <= 0)
{
DynamicTreeNode[] newBuffer = new DynamicTreeNode[nodeStack.Length*2];
Array.Copy(nodeStack, 0, newBuffer, 0, nodeStack.Length);
nodeStack = newBuffer;
}
nodeStack[nodeStackIndex++] = node.child1;
nodeStack[nodeStackIndex++] = node.child2;
}
}
}
}
示例3: createProxy
public int createProxy(AABB aabb, object userData)
{
Debug.Assert(aabb.isValid());
DynamicTreeNode node = allocateNode();
int proxyId = node.id;
// Fatten the aabb
AABB nodeAABB = node.aabb;
nodeAABB.lowerBound.x = aabb.lowerBound.x - Settings.aabbExtension;
nodeAABB.lowerBound.y = aabb.lowerBound.y - Settings.aabbExtension;
nodeAABB.upperBound.x = aabb.upperBound.x + Settings.aabbExtension;
nodeAABB.upperBound.y = aabb.upperBound.y + Settings.aabbExtension;
node.userData = userData;
insertLeaf(proxyId);
return proxyId;
}