本文整理汇总了C++中LLBBox::addPointLocal方法的典型用法代码示例。如果您正苦于以下问题:C++ LLBBox::addPointLocal方法的具体用法?C++ LLBBox::addPointLocal怎么用?C++ LLBBox::addPointLocal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLBBox
的用法示例。
在下文中一共展示了LLBBox::addPointLocal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: align
void QToolAlign::align()
{
// no linkset parts, please
LLSelectMgr::getInstance()->promoteSelectionToRoot();
std::vector<LLPointer<LLViewerObject> > objects;
std::map<LLPointer<LLViewerObject>, LLBBox > original_bboxes;
// cycle over the nodes in selection and collect them into an array
for (LLObjectSelection::root_iterator selection_iter = LLSelectMgr::getInstance()->getSelection()->root_begin();
selection_iter != LLSelectMgr::getInstance()->getSelection()->root_end();
++selection_iter)
{
LLSelectNode *select_node = *selection_iter;
if (select_node)
{
LLViewerObject* object = select_node->getObject();
if (object)
{
LLVector3 position = object->getPositionAgent();
LLBBox bbox = LLBBox(position, LLQuaternion(), LLVector3(), LLVector3());
bbox.addPointLocal(LLVector3());
// add the parent's bbox
bbox.addBBoxAgent(object->getBoundingBoxAgent());
LLViewerObject::const_child_list_t& children = object->getChildren();
for (LLViewerObject::const_child_list_t::const_iterator i = children.begin();
i != children.end(); i++)
{
// add the child's bbox
LLViewerObject* child = *i;
bbox.addBBoxAgent(child->getBoundingBoxAgent());
}
objects.push_back(object);
original_bboxes[object] = bbox;
}
}
}
S32 axis = mHighlightedAxis;
F32 direction = mHighlightedDirection;
// sort them into positional order for proper packing
BBoxCompare compare(axis, direction, original_bboxes);
sort(objects.begin(), objects.end(), compare);
// storage for their new position after alignment - start with original position first
std::map<LLPointer<LLViewerObject>, LLBBox > new_bboxes = original_bboxes;
// find new positions
for (U32 i = 0; i < objects.size(); i++)
{
LLBBox target_bbox = mBBox;
LLVector3 target_corner = target_bbox.getCenterAgent() -
direction * target_bbox.getExtentLocal() / 2.0;
LLViewerObject* object = objects[i];
LLBBox this_bbox = original_bboxes[object];
LLVector3 this_corner = this_bbox.getCenterAgent() -
direction * this_bbox.getExtentLocal() / 2.0;
// for packing, we cycle over several possible positions, taking the smallest that does not overlap
F32 smallest = direction * 9999999; // 999999 guarenteed not to be the smallest
for (U32 j = 0; j <= i; j++)
{
// how far must it move?
LLVector3 delta = target_corner - this_corner;
// new position moves only on one axis, please
LLVector3 delta_one_axis = LLVector3(0,0,0);
delta_one_axis.mV[axis] = delta.mV[axis];
LLVector3 new_position = this_bbox.getCenterAgent() + delta_one_axis;
// construct the new bbox
LLBBox new_bbox = LLBBox(new_position, LLQuaternion(), LLVector3(), LLVector3());
new_bbox.addPointLocal(this_bbox.getExtentLocal() / 2.0);
new_bbox.addPointLocal(-1.0 * this_bbox.getExtentLocal() / 2.0);
// check to see if it overlaps the previously placed objects
BOOL overlap = FALSE;
llwarns << "i=" << i << " j=" << j << llendl;
if (!mForce) // well, don't check if in force mode
{
for (U32 k = 0; k < i; k++)
{
LLViewerObject* other_object = objects[k];
LLBBox other_bbox = new_bboxes[other_object];
BOOL overlaps_this = bbox_overlap(other_bbox, new_bbox);
if (overlaps_this)
{
llwarns << "overlap" << new_bbox.getCenterAgent() << other_bbox.getCenterAgent() << llendl;
//.........这里部分代码省略.........