本文整理汇总了C++中BaseObject::findNear方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseObject::findNear方法的具体用法?C++ BaseObject::findNear怎么用?C++ BaseObject::findNear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseObject
的用法示例。
在下文中一共展示了BaseObject::findNear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_draw_list
void BaseObject::get_draw_list(BaseObject& world, std::vector < std::shared_ptr<BaseObject> > &list,
Camera& camera)
{
Vector cam = camera.getPos();
Vector look = camera.getLook();
GLdouble fov = cos (camera.getFov() * M_PI / 360.0); /* 180.0 * 2 */
shared_ptr<BaseObject> cur;
while (! (cur = world.findNear (cam)))
;
bool cur_op = ~world.cur_op[OP_DRAW];
world.cur_op.flip (OP_DRAW);
static const auto lambda = [&] (const shared_ptr<BaseObject> &lhs, const shared_ptr<BaseObject> &rhs) -> bool
{
return ((lhs->position - cam).normal2()) < ((rhs->position - cam).normal2());
};
queue<shared_ptr<BaseObject>> reminder;
static const auto lambda2 = [] (const shared_ptr<BaseObject> &lhs, const shared_ptr<BaseObject> &rhs) -> bool
{
return lhs.get() < rhs.get();
};
set < shared_ptr<BaseObject>, decltype (lambda2) > to_recalc (lambda2);
cur->cur_op[OP_DRAW] = cur_op;
to_recalc.insert (cur);
vector<shared_ptr<BaseObject>> to_add;
for (unsigned short i = 0; i < mini_draw_recursion; i++)
{
for (auto it = to_recalc.begin(); it != to_recalc.end(); it ++)
{
if (cur = (*it)->front)
{
cur->cur_op[OP_DRAW] = cur_op;
to_add.push_back (cur);
}
if (cur = (*it)->back)
{
cur->cur_op[OP_DRAW] = cur_op;
to_add.push_back (cur);
}
if (cur = (*it)->left)
{
cur->cur_op[OP_DRAW] = cur_op;
to_add.push_back (cur);
}
if (cur = (*it)->right)
{
cur->cur_op[OP_DRAW] = cur_op;
to_add.push_back (cur);
}
if (cur = (*it)->up)
{
cur->cur_op[OP_DRAW] = cur_op;
to_add.push_back (cur);
}
if (cur = (*it)->down)
{
cur->cur_op[OP_DRAW] = cur_op;
to_add.push_back (cur);
}
}
to_recalc.insert (to_add.begin(), to_add.end());
to_add.clear();
}
for (auto it = to_recalc.begin(); it != to_recalc.end(); it ++)
{
(*it)->cur_op[OP_DRAW] = cur_op;
reminder.push ( (*it));
}
do
{
cur = reminder.front();
reminder.pop();
list.push_back (cur);
shared_ptr<BaseObject> to_draw = cur->up;
if (to_draw && to_draw->cur_op[OP_DRAW] != cur_op)
{
to_draw->cur_op[OP_DRAW] = cur_op;
if (to_draw->isDrawable(fov, cam, look))
reminder.push (to_draw);
//.........这里部分代码省略.........