mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 16:29:55 +00:00
Sprinkle some const-ref to avoid unnecessary copies
This commit is contained in:
parent
d95cd985a4
commit
d45184a730
2 changed files with 11 additions and 11 deletions
|
@ -448,7 +448,7 @@ namespace MWWorld
|
|||
void CellPreloader::abortTerrainPreloadExcept(const CellPreloader::PositionCellGrid *exceptPos)
|
||||
{
|
||||
const float resetThreshold = ESM::Land::REAL_SIZE;
|
||||
for (auto pos : mTerrainPreloadPositions)
|
||||
for (const auto& pos : mTerrainPreloadPositions)
|
||||
if (exceptPos && (pos.first-exceptPos->first).length2() < resetThreshold*resetThreshold && pos.second == exceptPos->second)
|
||||
return;
|
||||
if (mTerrainPreloadItem && !mTerrainPreloadItem->isDone())
|
||||
|
@ -461,10 +461,10 @@ namespace MWWorld
|
|||
|
||||
bool contains(const std::vector<CellPreloader::PositionCellGrid>& container, const std::vector<CellPreloader::PositionCellGrid>& contained)
|
||||
{
|
||||
for (auto pos : contained)
|
||||
for (const auto& pos : contained)
|
||||
{
|
||||
bool found = false;
|
||||
for (auto pos2 : container)
|
||||
for (const auto& pos2 : container)
|
||||
{
|
||||
if ((pos.first-pos2.first).length2() < 1 && pos.second == pos2.second)
|
||||
{
|
||||
|
|
|
@ -1361,7 +1361,7 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv)
|
|||
if (settings->getMultipleShadowMapHint() == ShadowSettings::CASCADED)
|
||||
{
|
||||
cropShadowCameraToMainFrustum(frustum, camera, cascaseNear, cascadeFar, extraPlanes);
|
||||
for (auto plane : extraPlanes)
|
||||
for (const auto& plane : extraPlanes)
|
||||
local_polytope.getPlaneList().push_back(plane);
|
||||
local_polytope.setupMask();
|
||||
}
|
||||
|
@ -1998,19 +1998,19 @@ struct ConvexHull
|
|||
Vertices findInternalEdges(osg::Vec3d mainVertex, Vertices connectedVertices)
|
||||
{
|
||||
Vertices internalEdgeVertices;
|
||||
for (auto vertex : connectedVertices)
|
||||
for (const auto& vertex : connectedVertices)
|
||||
{
|
||||
osg::Matrixd matrix;
|
||||
osg::Vec3d dir = vertex - mainVertex;
|
||||
matrix.makeLookAt(mainVertex, vertex, dir.z() == 0 ? osg::Vec3d(0, 0, 1) : osg::Vec3d(1, 0, 0));
|
||||
Vertices testVertices;
|
||||
for (auto testVertex : connectedVertices)
|
||||
for (const auto& testVertex : connectedVertices)
|
||||
{
|
||||
if (vertex != testVertex)
|
||||
testVertices.push_back(testVertex);
|
||||
}
|
||||
std::vector<double> bearings;
|
||||
for (auto testVertex : testVertices)
|
||||
for (const auto& testVertex : testVertices)
|
||||
{
|
||||
osg::Vec3d transformedVertex = testVertex * matrix;
|
||||
bearings.push_back(atan2(transformedVertex.y(), transformedVertex.x()));
|
||||
|
@ -2039,7 +2039,7 @@ struct ConvexHull
|
|||
|
||||
// Collect the set of vertices
|
||||
VertexSet vertices;
|
||||
for (Edge edge : _edges)
|
||||
for (const Edge& edge : _edges)
|
||||
{
|
||||
vertices.insert(edge.first);
|
||||
vertices.insert(edge.second);
|
||||
|
@ -2069,7 +2069,7 @@ struct ConvexHull
|
|||
for (auto vertex : extremeVertices)
|
||||
{
|
||||
Vertices connectedVertices;
|
||||
for (Edge edge : _edges)
|
||||
for (const Edge& edge : _edges)
|
||||
{
|
||||
if (edge.first == vertex)
|
||||
connectedVertices.push_back(edge.second);
|
||||
|
@ -2107,7 +2107,7 @@ struct ConvexHull
|
|||
osg::Vec3d vertex = *unprocessedConnectedVertices.begin();
|
||||
unprocessedConnectedVertices.erase(unprocessedConnectedVertices.begin());
|
||||
connectedVertices.insert(vertex);
|
||||
for (Edge edge : _edges)
|
||||
for (const Edge& edge : _edges)
|
||||
{
|
||||
osg::Vec3d otherEnd;
|
||||
if (edge.first == vertex)
|
||||
|
@ -2124,7 +2124,7 @@ struct ConvexHull
|
|||
}
|
||||
}
|
||||
|
||||
for (Edge edge : _edges)
|
||||
for (const Edge& edge : _edges)
|
||||
{
|
||||
if (connectedVertices.count(edge.first) || connectedVertices.count(edge.second))
|
||||
finalEdges.push_back(edge);
|
||||
|
|
Loading…
Reference in a new issue