本文整理汇总了C++中BoxVolume::extendBy方法的典型用法代码示例。如果您正苦于以下问题:C++ BoxVolume::extendBy方法的具体用法?C++ BoxVolume::extendBy怎么用?C++ BoxVolume::extendBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoxVolume
的用法示例。
在下文中一共展示了BoxVolume::extendBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doBuild
UInt32 ParticleBSPTree::doBuild(std::vector<Int32>::iterator begin,
std::vector<Int32>::iterator end,
UInt32 nodeindex,
GeoVectorProperty *pos)
{
// reached a leaf?
if(begin + 1 == end)
{
_tree[nodeindex].setValue(*begin);
return nodeindex + 1;
}
// find the bounding volume of the group
BoxVolume b;
Pnt3f p;
b.setEmpty();
for(std::vector<Int32>::iterator i = begin; i != end; ++i)
{
pos->getValue(p,*i);
b.extendBy(p);
}
// find the axis with the longest extension
Vec3f d = b.getMax() - b.getMin();
UInt8 axis = ParticleBSPNode::X;
Real32 maxval = d[0];
if(d[1] > maxval)
{
axis = ParticleBSPNode::Y;
maxval = d[1];
}
if(d[2] > maxval)
{
axis = ParticleBSPNode::Z;
maxval = d[2];
}
// sort in that axis
ParticleCompare comp(pos, axis);
std::sort(begin,end,comp);
// find median value
std::vector<Int32>::iterator mid = begin + (end - begin) / 2;
Pnt3f p2;
pos->getValue(p ,*mid);
pos->getValue(p2,(*mid)-1);
_tree[nodeindex].setSplit(axis, (p[axis] + p2[axis]) / 2.f);
return osgMax( doBuild(begin, mid, nodeindex * 2 , pos),
doBuild( mid, end, nodeindex * 2 + 1, pos) );
}
示例2: updateVolume
void Node::updateVolume(void)
{
// still valid or static, nothing to do
if(_sfVolume.getValue().isValid () == true ||
_sfVolume.getValue().isStatic() == true ||
getTravMask() == 0x0000 )
{
return;
}
// be careful to not change the real volume. If two threads
// are updating the same aspect this will lead to chaos
BoxVolume vol = _sfVolume.getValue();
MFUnrecChildNodePtr::const_iterator cIt =
this->getMFChildren()->begin();
MFUnrecChildNodePtr::const_iterator cEnd =
this->getMFChildren()->end();
vol.setEmpty();
for(; cIt != cEnd; ++cIt)
{
if(*cIt != NULL && (*cIt)->getTravMask())
{
(*cIt)->updateVolume();
vol.extendBy((*cIt)->getVolume());
}
}
// test for null core. Shouldn't happen, but just in case...
if(getCore() != NULL)
{
getCore()->adjustVolume(vol);
}
// don't propagate the static flag from children
vol.setStatic(false);
editSField(VolumeFieldMask);
_sfVolume.setValue(vol);
}
示例3: splitDrawables
void SortLastWindow::splitDrawables(DrawableListT &src,
UInt32 groups,
bool cut)
{
BoxVolume vol;
// Real32 srcLoad=0;
Real32 dst1Load = 0;
Real32 dst2Load = 0;
DrawableListT::iterator dI;
UInt32 dIFront = 0;
UInt32 dIBack = 0;
UInt32 axis = 0;
Vec3f size;
DrawableListT dst1;
DrawableListT dst2;
UInt32 groups1 = 0;
UInt32 groups2 = 0;
// no group
if(groups == 0)
return;
// only one group
if(groups == 1)
{
editMFGroupLengths()->push_back(UInt32(src.size()));
for(dI = src.begin() ; dI != src.end() ; ++dI)
{
pushToGroupNodes(dI->node);
// srcLoad+=dI->load;
}
// printf("load:%f\n",srcLoad);
return;
}
groups1 = groups / 2;
groups2 = groups - groups1;
// collect all load and get summed volume
for(dI = src.begin() ; dI != src.end() ; ++dI)
{
vol.extendBy(dI->bMin);
vol.extendBy(dI->bMax);
}
// get longes axis
vol.getSize(size);
if(size[0] > size[1])
{
if(size[0] > size[2])
axis=0;
else
axis=2;
}
else
{
if(size[1] > size[2])
axis=1;
else
axis=2;
}
// sort by volume
if(axis == 0)
{
std::sort(src.begin(),src.end(), DrawableInfo::MaxXOrder());
}
else
{
if(axis == 1)
std::sort(src.begin(),src.end(), DrawableInfo::MaxYOrder());
else
std::sort(src.begin(),src.end(), DrawableInfo::MaxZOrder());
}
// split group
if(src.size())
{
dIFront = 0;
dIBack = UInt32(src.size()) - 1;
do
{
// printf("f %d b %d\n",dIFront,dIBack);
if(dst2Load < dst1Load)
{
dst2.push_back(src[dIBack]);
dst2Load += src[dIBack].load*groups/Real32(groups2);
dIBack--;
}
else
{
dst1.push_back(src[dIFront]);
dst1Load += src[dIFront].load*groups/Real32(groups1);
dIFront++;
//.........这里部分代码省略.........