当前位置: 首页>>代码示例>>C++>>正文


C++ BaseObject::findNear方法代码示例

本文整理汇总了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);
//.........这里部分代码省略.........
开发者ID:DeadMaX,项目名称:Qubi,代码行数:101,代码来源:BaseObject.cpp


注:本文中的BaseObject::findNear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。