本文整理汇总了C++中NodeVector::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeVector::resize方法的具体用法?C++ NodeVector::resize怎么用?C++ NodeVector::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeVector
的用法示例。
在下文中一共展示了NodeVector::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddFieldNode
void AddFieldNode(CPLXMLNode* node, int iOrderPos)
{
if (iOrderPos >= (int)oFields.size())
oFields.resize(iOrderPos+1);
//CPLDebug( "OGR_ILI", "Register field with OrderPos %d to Class %s", iOrderPos, GetName());
oFields[iOrderPos] = node;
}
示例2: ConvertFromLonLatToCartesian
void ConvertFromLonLatToCartesian(
const LonLatNodeVector & vecLonLatNodes,
NodeVector & vecNodes
) {
vecNodes.resize(vecLonLatNodes.size());
// Loop over all nodes
int i;
for (i = 0; i < vecLonLatNodes.size(); i++) {
vecNodes[i].x =
sin(vecLonLatNodes[i].lon) * cos(vecLonLatNodes[i].lat);
vecNodes[i].y =
cos(vecLonLatNodes[i].lon) * cos(vecLonLatNodes[i].lat);
vecNodes[i].z =
sin(vecLonLatNodes[i].lat);
}
}
示例3: generatePathfindingNodes
void EntityEngine::generatePathfindingNodes(NodeVector & nodes) {
// lay a grid over the static entities
Timing tm;
const int resolutionFactor = 1;
const float collisionMarginFactor = 2.5f;
const float gridSize = 1.0f / float(resolutionFactor); // 0.5f;
//const float neighbourDistance = sqrt(gridSize * gridSize * 2.0f) * 1.1f;
float floatHighestY = 0;
float floatLowestY = 100000000000.0f;
for (Entity const* ent : getStaticEntities()) {
floatHighestY = std::max(floatHighestY, ent->getPosition().y());
floatLowestY = std::min(floatLowestY, ent->getPosition().y());
}
dropNavigationNodes(nodes);
// protect against no entities
if (getStaticEntities().size() == 0)
return;
assert(floatHighestY > floatLowestY);
logging::Info() << "Generating navigation grid for lowY: " << floatLowestY << " highY: " << floatHighestY;
const int highestY = int(std::ceil(floatHighestY));
const int lowestY = int(std::floor(floatLowestY));
const int spanY = highestY - lowestY;
const float spanX = 15.0f;
const int nodeCount = (spanX * resolutionFactor) * (spanY * resolutionFactor);
nodes.resize(nodeCount);
// with a resolution of 2 times the tile size
const int sizeX = spanX * resolutionFactor;
const int sizeY = (spanY * resolutionFactor);
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
Vector2 pos(float(x) * gridSize, float(y) * gridSize + float(lowestY));
// do only add if there is no collision object near by
if (!checkForCollisionObject(pos, gridSize * collisionMarginFactor)) {
const int thisNodeLocation = sizeX * y + x;
NodePtr n = &nodes[thisNodeLocation];
n->Location = pos;
// connect to left
if (x > 0) {
// left same line
n->Neighbours.push_back(&nodes[thisNodeLocation - 1]);
// left lower
if (y > 0) {
n->Neighbours.push_back(&nodes[thisNodeLocation - 1 - sizeX]);
}
// left upper
if (y < (sizeY - 1)) {
n->Neighbours.push_back(&nodes[thisNodeLocation - 1 + sizeX]);
}
}
if (x < (sizeX - 1)) {
// right same line
n->Neighbours.push_back(&nodes[thisNodeLocation + 1]);
// right lower
if (y > 0) {
n->Neighbours.push_back(&nodes[thisNodeLocation + 1 - sizeX]);
}
// right upper
if (y < (sizeY - 1)) {
n->Neighbours.push_back(&nodes[thisNodeLocation + 1 + sizeX]);
}
}
if (y > 0) {
// lower one
n->Neighbours.push_back(&nodes[thisNodeLocation - sizeX]);
}
if (y < (sizeY - 1)) {
// upper one
n->Neighbours.push_back(&nodes[thisNodeLocation + sizeX]);
}
}
}
}
float dt = tm.end();
logging::Info() << "Building the Pathfinding grid took " << dt << " seconds";
}