本文整理汇总了C++中Box3f::Extent方法的典型用法代码示例。如果您正苦于以下问题:C++ Box3f::Extent方法的具体用法?C++ Box3f::Extent怎么用?C++ Box3f::Extent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box3f
的用法示例。
在下文中一共展示了Box3f::Extent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddReference
void CQuadTree::AddReference( Box3f box, CEntity * pEntity, CQuadNode * node ) {
assert( m_iLevels > 1 );
int iNumInside = 0;
Box3f boxTemp = box;
Box3f boxEnt = *pEntity->GetBoundingBox();
// move box to the entity's height
boxTemp.Center().Y() = boxEnt.Center().Y();
boxTemp.Extent(1) = 100.0f; //extend this box infinitely
bool bEntInQuad = false;
Vector3f vBoxVerts[8];
bool abValid[8] = { 1,1,1,1,1,1,1,1 };//{ 0,0,0,0,0,0,0,0 };
bool bEntBoxInNode = false;
bool bNodeInEntBox = false;
//switch(TestIntersection( boxTemp, boxEnt ) )
switch(TestIntersection( boxEnt, boxTemp ) )
{
case true: // box intersects
node->m_EntMap[pEntity->GetId()] = pEntity;
bEntInQuad = true; // find if the children intersect too
break;
case false: // ent box is INSIDE or OUTSIDE the node
// get vertices for the bounding box
boxEnt.ComputeVertices(vBoxVerts);
// if entities box is contained in node box
for (int j=0; j<8; j++ ) {
if (InBox( vBoxVerts[j], boxTemp)) {
bEntBoxInNode = true;
}
}
if (bEntBoxInNode == true) {
//if (ContOrientedBox (8, vBoxVerts, abValid, node->m_BBox)) {
node->m_EntMap[pEntity->GetId()] = pEntity; //entity is in this node
bEntInQuad = true; // find out what child quads also contain this
iNumInside++;
}
else { // OUTSIDE or entities box contains the bounding box!
boxTemp.ComputeVertices(vBoxVerts);
// if node box is contained in entities box
for (int j=0; j<8; j++ ) {
if (InBox( vBoxVerts[j], boxEnt)) {
bNodeInEntBox = true;
}
}
if (bNodeInEntBox == true) {
//if (ContOrientedBox (8, vBoxVerts, abValid, boxTemp)) {
node->m_EntMap[pEntity->GetId()] = pEntity; //entity is in this node
bEntInQuad = true; // find out what child quads also contain this
}
else {
// entity is outside, so don't add
bEntInQuad = false;
return;
}
}
break;
}
// now this box will also intersect/be contained in the children as well
if (bEntInQuad == true ) {
//check if we need to subdivide even further
if (iNumInside >= MAX_ENTS_PER_NODE) {
m_iLevels++; //increase the number of levels
SubDivide(node, m_iLevels-1);
}
if (node->m_pChildNode[NE] != NULL) {
AddReference( node->m_pChildNode[NE]->m_BBox, pEntity, node->m_pChildNode[NE]);
//node->m_pChildNode[NE]->m_EntMap[pEntity->GetId()] = pEntity;
}
if (node->m_pChildNode[NW] != NULL) {
AddReference( node->m_pChildNode[NW]->m_BBox, pEntity, node->m_pChildNode[NW]);
//node->m_pChildNode[NW]->m_EntMap[pEntity->GetId()] = pEntity;
}
if (node->m_pChildNode[SE] != NULL) {
AddReference( node->m_pChildNode[SE]->m_BBox, pEntity, node->m_pChildNode[SE]);
//node->m_pChildNode[SE]->m_EntMap[pEntity->GetId()] = pEntity;
}
if (node->m_pChildNode[SW] != NULL) {
AddReference( node->m_pChildNode[SW]->m_BBox, pEntity, node->m_pChildNode[SW]);
//node->m_pChildNode[SW]->m_EntMap[pEntity->GetId()] = pEntity;
}
}
return;
}