本文整理汇总了C++中PODVector::Erase方法的典型用法代码示例。如果您正苦于以下问题:C++ PODVector::Erase方法的具体用法?C++ PODVector::Erase怎么用?C++ PODVector::Erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PODVector
的用法示例。
在下文中一共展示了PODVector::Erase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
PODVector<OffMeshConnection*> DynamicNavigationMesh::CollectOffMeshConnections(const BoundingBox& bounds)
{
PODVector<OffMeshConnection*> connections;
node_->GetComponents<OffMeshConnection>(connections, true);
for (unsigned i = 0; i < connections.Size(); ++i)
{
OffMeshConnection* connection = connections[i];
if (!(connection->IsEnabledEffective() && connection->GetEndPoint()))
{
// discard this connection
connections.Erase(i);
--i;
}
}
return connections;
}
示例2: GetScene
PODVector<CrowdAgent*> CrowdManager::GetAgents(Node* node, bool inCrowdFilter) const
{
if (!node)
node = GetScene();
PODVector<CrowdAgent*> agents;
node->GetComponents<CrowdAgent>(agents, true);
if (inCrowdFilter)
{
PODVector<CrowdAgent*>::Iterator i = agents.Begin();
while (i != agents.End())
{
if ((*i)->IsInCrowd())
++i;
else
i = agents.Erase(i);
}
}
return agents;
}
示例3: GetRigidBodies
void PhysicsWorld::GetRigidBodies(PODVector<RigidBody*>& result, const RigidBody* body)
{
ATOMIC_PROFILE(PhysicsBodyQuery);
result.Clear();
if (!body || !body->GetBody())
return;
PhysicsQueryCallback callback(result, body->GetCollisionMask());
world_->contactTest(body->GetBody(), callback);
// Remove the body itself from the returned list
for (unsigned i = 0; i < result.Size(); i++)
{
if (result[i] == body)
{
result.Erase(i);
break;
}
}
}
示例4: OptimizeIndices
void OptimizeIndices(ModelSubGeometryLodLevel* subGeom, ModelVertexBuffer* vb, ModelIndexBuffer* ib)
{
PODVector<Triangle> oldTriangles;
PODVector<Triangle> newTriangles;
if (subGeom->indexCount_ % 3)
{
PrintLine("Index count is not divisible by 3, skipping index optimization");
return;
}
for (unsigned i = 0; i < vb->vertices_.Size(); ++i)
{
vb->vertices_[i].useCount_ = 0;
vb->vertices_[i].cachePosition_ = -1;
}
for (unsigned i = subGeom->indexStart_; i < subGeom->indexStart_ + subGeom->indexCount_; i += 3)
{
Triangle triangle;
triangle.v0_ = ib->indices_[i];
triangle.v1_ = ib->indices_[i + 1];
triangle.v2_ = ib->indices_[i + 2];
vb->vertices_[triangle.v0_].useCount_++;
vb->vertices_[triangle.v1_].useCount_++;
vb->vertices_[triangle.v2_].useCount_++;
oldTriangles.Push(triangle);
}
for (unsigned i = 0; i < vb->vertices_.Size(); ++i)
CalculateScore(vb->vertices_[i]);
PODVector<unsigned> vertexCache;
while (oldTriangles.Size())
{
unsigned bestTriangle = M_MAX_UNSIGNED;
float bestTriangleScore = -1.0f;
// Find the best triangle at this point
for (unsigned i = 0; i < oldTriangles.Size(); ++i)
{
Triangle& triangle = oldTriangles[i];
float triangleScore =
vb->vertices_[triangle.v0_].score_ +
vb->vertices_[triangle.v1_].score_ +
vb->vertices_[triangle.v2_].score_;
if (triangleScore > bestTriangleScore)
{
bestTriangle = i;
bestTriangleScore = triangleScore;
}
}
if (bestTriangle == M_MAX_UNSIGNED)
{
PrintLine("Could not find next triangle, aborting index optimization");
return;
}
// Add the best triangle
Triangle triangleCopy = oldTriangles[bestTriangle];
newTriangles.Push(triangleCopy);
oldTriangles.Erase(oldTriangles.Begin() + bestTriangle);
// Reduce the use count
vb->vertices_[triangleCopy.v0_].useCount_--;
vb->vertices_[triangleCopy.v1_].useCount_--;
vb->vertices_[triangleCopy.v2_].useCount_--;
// Model the LRU cache behaviour
// Erase the triangle vertices from the middle of the cache, if they were there
for (unsigned i = 0; i < vertexCache.Size(); ++i)
{
if ((vertexCache[i] == triangleCopy.v0_) ||
(vertexCache[i] == triangleCopy.v1_) ||
(vertexCache[i] == triangleCopy.v2_))
{
vertexCache.Erase(vertexCache.Begin() + i);
--i;
}
}
// Then push them to the front
vertexCache.Insert(vertexCache.Begin(), triangleCopy.v0_);
vertexCache.Insert(vertexCache.Begin(), triangleCopy.v1_);
vertexCache.Insert(vertexCache.Begin(), triangleCopy.v2_);
// Update positions & scores of all vertices in the cache
// Give position -1 if vertex is going to be erased
for (unsigned i = 0; i < vertexCache.Size(); ++i)
{
ModelVertex& vertex = vb->vertices_[vertexCache[i]];
if (i >= VERTEX_CACHE_SIZE)
vertex.cachePosition_ = -1;
else
vertex.cachePosition_ = i;
CalculateScore(vertex);
}
//.........这里部分代码省略.........