本文整理汇总了C++中common::List::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ List::remove方法的具体用法?C++ List::remove怎么用?C++ List::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::List
的用法示例。
在下文中一共展示了List::remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: walkTo
void Actor::walkTo(const Math::Vector3d &p) {
if (p == _pos)
_walking = false;
else {
_walking = true;
_destPos = p;
_path.clear();
if (_constrain) {
g_grim->getCurrSet()->findClosestSector(p, NULL, &_destPos);
Common::List<PathNode *> openList;
Common::List<PathNode *> closedList;
PathNode *start = new PathNode;
start->parent = NULL;
start->pos = _pos;
start->dist = 0.f;
start->cost = 0.f;
openList.push_back(start);
g_grim->getCurrSet()->findClosestSector(_pos, &start->sect, NULL);
Common::List<Sector *> sectors;
for (int i = 0; i < g_grim->getCurrSet()->getSectorCount(); ++i) {
Sector *s = g_grim->getCurrSet()->getSectorBase(i);
int type = s->getType();
if ((type == Sector::WalkType || type == Sector::HotType || type == Sector::FunnelType) && s->isVisible()) {
sectors.push_back(s);
}
}
Sector *endSec = NULL;
g_grim->getCurrSet()->findClosestSector(_destPos, &endSec, NULL);
do {
PathNode *node = NULL;
float cost = -1.f;
for (Common::List<PathNode *>::iterator j = openList.begin(); j != openList.end(); ++j) {
PathNode *n = *j;
float c = n->dist + n->cost;
if (cost < 0.f || c < cost) {
cost = c;
node = n;
}
}
closedList.push_back(node);
openList.remove(node);
Sector *sector = node->sect;
if (sector == endSec) {
PathNode *n = closedList.back();
// Don't put the start position in the list, or else
// the first angle calculated in updateWalk() will be
// meaningless. The only node without parent is the start
// one.
while (n->parent) {
_path.push_back(n->pos);
n = n->parent;
}
break;
}
for (Common::List<Sector *>::iterator i = sectors.begin(); i != sectors.end(); ++i) {
Sector *s = *i;
bool inClosed = false;
for (Common::List<PathNode *>::iterator j = closedList.begin(); j != closedList.end(); ++j) {
if ((*j)->sect == s) {
inClosed = true;
break;
}
}
if (inClosed)
continue;
Common::List<Math::Line3d> bridges = sector->getBridgesTo(s);
if (bridges.empty())
continue; // The sectors are not adjacent.
Math::Vector3d closestPoint = s->getClosestPoint(_destPos);
Math::Vector3d best;
float bestDist = 1e6f;
Math::Line3d l(node->pos, closestPoint);
while (!bridges.empty()) {
Math::Line3d bridge = bridges.back();
Math::Vector3d pos;
const bool useXZ = (g_grim->getGameType() == GType_MONKEY4);
if (!bridge.intersectLine2d(l, &pos, useXZ)) {
pos = bridge.middle();
}
float dist = (pos - closestPoint).getMagnitude();
if (dist < bestDist) {
bestDist = dist;
best = pos;
}
bridges.pop_back();
}
best = handleCollisionTo(node->pos, best);
PathNode *n = NULL;
//.........这里部分代码省略.........