本文整理汇总了C++中aabb::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ aabb::getSize方法的具体用法?C++ aabb::getSize怎么用?C++ aabb::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aabb
的用法示例。
在下文中一共展示了aabb::getSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void ireon::kd_tree::KdTree<T>::subdivide( KdTreeNode<T>* node, const aabb& box, int depth, int a_Prims )
{
// recycle used split list nodes
//add sPool_ at end sList_
if (sList_)
{
SplitList* list = sList_;
while (list->next)
list = list->next;
list->next = sPool_;
sPool_ = sList_, sList_ = 0;
}
// determine split axis
Vector3 s = box.getSize();
if ((s.x >= s.y) && (s.x >= s.z))
node->setAxis( 0 );
else if ((s.y >= s.x) && (s.y >= s.z))
node->setAxis( 1 );
int axis = node->getAxis();
// make a list of the split position candidates
ObjectList<T>* l = node->getList();
real p1, p2;
real pos1 = box.getPos().val[axis];
real pos2 = box.getPos().val[axis] + box.getSize().val[axis];
bool* pright = new bool[a_Prims];
float* eleft = new float[a_Prims], *eright = new float[a_Prims];
T** parray = new T*[a_Prims];
real etleft, etright;
int aidx = 0;
while (l)
{
T* p = parray[aidx] = l->getPrimitive();
pright[aidx] = true;
etleft = eleft[aidx];
etright = eright[aidx];
p->calculateRange( etleft, etright, axis );
eleft[aidx] = (float)etleft;
eright[aidx] = (float)etright;
aidx++;
for ( int i = 0; i < 3; i++ )
{
p1 = (float)p->vertice( i )->cell[axis];
if ((p1 >= pos1) && (p1 <= pos2))
insertSplitPos( p1 );
}
l = l->getNext();
}
// determine n1count / n2count for each split position
aabb b1, b2, b3 = box, b4 = box;
SplitList* splist = sList_;
float b3p1 = b3.getPos().val[axis];
float b4p2 = b4.getPos().val[axis] + b4.getSize().val[axis];
Vector3 foo;
while (splist)
{
foo = b4.getPos();
foo.val[axis] = splist->splitpos;
b4.setPos(foo);
foo = b4.getSize();
foo.val[axis] = pos2 - splist->splitpos;
b4.setSize(foo);
foo = b3.getSize();
foo.val[axis] = splist->splitpos - pos1;
b3.setSize(foo);
float b3p2 = b3.getPos().val[axis] + b3.getSize().val[axis];
float b4p1 = b4.getPos().val[axis];
for ( int i = 0; i < a_Prims; i++ ) if (pright[i])
{
T* p = parray[i];
if ((eleft[i] <= b3p2) && (eright[i] >= b3p1))
if (p->intersectBox( b3 )) splist->n1count++;
if ((eleft[i] <= b4p2) && (eright[i] >= b4p1))
if (p->intersectBox( b4 )) splist->n2count++; else pright[i] = false;
}
else splist->n1count++;
splist = splist->next;
}
delete[] pright;
// calculate surface area for current node
real SAV = 0.5f / (box.w() * box.d() + box.w() * box.h() + box.d() * box.h());
// calculate cost for not splitting
real Cleaf = a_Prims * 1.0f;
// determine optimal split plane position
splist = sList_;
real lowcost = 10000;
real bestpos = 0;
while (splist)
{
// calculate child node extends
foo = b4.getPos();
foo.val[axis] = splist->splitpos;
b4.setPos(foo);
foo = b4.getSize();
//.........这里部分代码省略.........