Improve c++11 for-loop performance with Universal References (#760)

This commit is contained in:
aismann 2022-07-21 13:19:08 +02:00 committed by GitHub
parent 07906b96e1
commit 2a2e8a1e95
157 changed files with 518 additions and 518 deletions

View File

@ -2495,7 +2495,7 @@ bool Animate::initWithAnimation(Animation* animation)
auto& frames = animation->getFrames();
for (auto& frame : frames)
for (auto&& frame : frames)
{
float value = (accumUnitsOfTime * newUnitOfTimeValue) / singleDuration;
accumUnitsOfTime += frame->getDelayUnits();

View File

@ -121,7 +121,7 @@ bool Animation::initWithSpriteFrames(const Vector<SpriteFrame*>& frames,
_delayPerUnit = delay;
_loops = loops;
for (auto& spriteFrame : frames)
for (auto&& spriteFrame : frames)
{
auto animFrame = AnimationFrame::create(spriteFrame, 1, ValueMap());
_frames.pushBack(animFrame);
@ -140,7 +140,7 @@ bool Animation::initWithAnimationFrames(const Vector<AnimationFrame*>& arrayOfAn
setFrames(arrayOfAnimationFrames);
for (auto& animFrame : _frames)
for (auto&& animFrame : _frames)
{
_totalDelayUnits += animFrame->getDelayUnits();
}

View File

@ -104,7 +104,7 @@ void AnimationCache::parseVersion1(const ValueMap& animations)
ssize_t frameNameSize = frameNames.size();
Vector<AnimationFrame*> frames(frameNameSize);
for (auto& frameName : frameNames)
for (auto&& frameName : frameNames)
{
SpriteFrame* spriteFrame = frameCache->getSpriteFrameByName(frameName.asString());
@ -170,7 +170,7 @@ void AnimationCache::parseVersion2(const ValueMap& animations)
// Array of AnimationFrames
Vector<AnimationFrame*> array(static_cast<int>(frameArray.size()));
for (auto& obj : frameArray)
for (auto&& obj : frameArray)
{
ValueMap& entry = obj.asValueMap();
std::string spriteFrameName = entry["spriteframe"].asString();

View File

@ -628,7 +628,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
}
}
}
for (auto j : p2points)
for (auto&& j : p2points)
{
delete j;
};

View File

@ -254,7 +254,7 @@ void CameraBackgroundColorBrush::drawBackground(Camera* camera)
void CameraBackgroundColorBrush::setColor(const Color4F& color)
{
for (auto& vert : _vertices)
for (auto&& vert : _vertices)
{
vert.colors = Color4B(color);
}

View File

@ -329,7 +329,7 @@ void ClippingNode::setProgramStateRecursively(Node* node, backend::ProgramState*
void ClippingNode::restoreAllProgramStates()
{
for (auto item : _originalStencilProgramState)
for (auto&& item : _originalStencilProgramState)
{
auto node = item.first;
auto programState = item.second;

View File

@ -100,7 +100,7 @@ void ComponentContainer::removeAll()
{
if (!_componentMap.empty())
{
for (auto& iter : _componentMap)
for (auto&& iter : _componentMap)
{
iter.second->onRemove();
iter.second->setOwner(nullptr);
@ -117,7 +117,7 @@ void ComponentContainer::visit(float delta)
if (!_componentMap.empty())
{
AX_SAFE_RETAIN(_owner);
for (auto& iter : _componentMap)
for (auto&& iter : _componentMap)
{
iter.second->update(delta);
}
@ -127,7 +127,7 @@ void ComponentContainer::visit(float delta)
void ComponentContainer::onEnter()
{
for (auto& iter : _componentMap)
for (auto&& iter : _componentMap)
{
iter.second->onEnter();
}
@ -135,7 +135,7 @@ void ComponentContainer::onEnter()
void ComponentContainer::onExit()
{
for (auto& iter : _componentMap)
for (auto&& iter : _componentMap)
{
iter.second->onExit();
}

View File

@ -121,7 +121,7 @@ FastTMXLayer::~FastTMXLayer()
AX_SAFE_RELEASE(_vertexBuffer);
AX_SAFE_RELEASE(_indexBuffer);
for (auto& e : _customCommands)
for (auto&& e : _customCommands)
{
AX_SAFE_RELEASE(e.second->getPipelineDescriptor().programState);
delete e.second;
@ -633,7 +633,7 @@ void FastTMXLayer::updateTotalQuads()
}
int offset = 0;
for (auto& vertexZOffset : _indicesVertexZOffsets)
for (auto&& vertexZOffset : _indicesVertexZOffsets)
{
std::swap(offset, vertexZOffset.second);
offset += vertexZOffset.second;
@ -976,7 +976,7 @@ TMXTileAnimManager::TMXTileAnimManager(FastTMXLayer* layer)
_layer = layer;
for (const auto& p : *_layer->getAnimTileCoord())
{
for (auto tilePos : p.second)
for (auto&& tilePos : p.second)
{
_tasks.pushBack(TMXTileAnimTask::create(_layer, _layer->getTileSet()->_animationInfo.at(p.first), tilePos));
}
@ -995,7 +995,7 @@ void TMXTileAnimManager::startAll()
if (_started || _tasks.empty())
return;
_started = true;
for (auto& task : _tasks)
for (auto&& task : _tasks)
{
task->start();
}
@ -1006,7 +1006,7 @@ void TMXTileAnimManager::stopAll()
if (!_started)
return;
_started = false;
for (auto& task : _tasks)
for (auto&& task : _tasks)
{
task->stop();
}

View File

@ -198,7 +198,7 @@ FastTMXLayer* FastTMXTiledMap::getLayer(std::string_view layerName) const
{
AXASSERT(!layerName.empty(), "Invalid layer name!");
for (auto& child : _children)
for (auto&& child : _children)
{
FastTMXLayer* layer = dynamic_cast<FastTMXLayer*>(child);
if (layer)
@ -258,7 +258,7 @@ std::string FastTMXTiledMap::getDescription() const
void FastTMXTiledMap::setTileAnimEnabled(bool enabled)
{
for (auto& child : _children)
for (auto&& child : _children)
{
FastTMXLayer* layer = dynamic_cast<FastTMXLayer*>(child);
if (layer)

View File

@ -139,7 +139,7 @@ void FontAtlas::reset()
void FontAtlas::releaseTextures()
{
for (auto& item : _atlasTextures)
for (auto&& item : _atlasTextures)
{
item.second->release();
}
@ -203,7 +203,7 @@ void FontAtlas::findNewCharacters(const std::u32string& u32Text, std::unordered_
}
else
{
for (auto charCode : u32Text)
for (auto&& charCode : u32Text)
if (_letterDefinitions.find(charCode) == _letterDefinitions.end())
charset.insert(charCode);
}
@ -239,7 +239,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
int startY = (int)_currentPageOrigY;
for (auto charCode : charCodeSet)
for (auto&& charCode : charCodeSet)
{
auto bitmap = _fontFreeType->getGlyphBitmap(charCode, bitmapWidth, bitmapHeight, tempRect, tempDef.xAdvance);
if (bitmap && bitmapWidth > 0 && bitmapHeight > 0)

View File

@ -244,7 +244,7 @@ bool FontAtlasCache::releaseFontAtlas(FontAtlas* atlas)
{
if (atlas->getReferenceCount() == 1)
{
for (auto& item : _atlasMap)
for (auto&& item : _atlasMap)
{
if (item.second == atlas)
{

View File

@ -699,7 +699,7 @@ bool Label::setProgramState(backend::ProgramState* programState, bool needsRetai
if (Node::setProgramState(programState, needsRetain))
{
updateUniformLocations();
for (auto& batch : _batchCommands)
for (auto&& batch : _batchCommands)
{
updateBatchCommand(batch);
}
@ -768,7 +768,7 @@ void Label::updateShaderProgram()
updateUniformLocations();
for (auto& batch : _batchCommands)
for (auto&& batch : _batchCommands)
{
updateBatchCommand(batch);
}
@ -1983,7 +1983,7 @@ void Label::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
continue;
auto& batch = _batchCommands[i++];
for (auto command : batch.getCommandArray())
for (auto&& command : batch.getCommandArray())
{
auto* programState = command->getPipelineDescriptor().programState;
Vec4 textColor(_textColorF.r, _textColorF.g, _textColorF.b, _textColorF.a);
@ -2003,9 +2003,9 @@ void Label::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
void Label::updateBlendState()
{
setOpacityModifyRGB(_blendFunc != BlendFunc::ALPHA_NON_PREMULTIPLIED);
for (auto& batch : _batchCommands)
for (auto&& batch : _batchCommands)
{
for (auto command : batch.getCommandArray())
for (auto&& command : batch.getCommandArray())
{
auto& blendDescriptor = command->getPipelineDescriptor().blendDescriptor;
updateBlend(blendDescriptor, _blendFunc);

View File

@ -42,13 +42,13 @@ void Label::computeAlignmentOffset()
_linesOffsetX.assign(_numberOfLines, 0);
break;
case axis::TextHAlignment::CENTER:
for (auto lineWidth : _linesWidth)
for (auto&& lineWidth : _linesWidth)
{
_linesOffsetX.push_back((_contentSize.width - lineWidth) / 2.f);
}
break;
case axis::TextHAlignment::RIGHT:
for (auto lineWidth : _linesWidth)
for (auto&& lineWidth : _linesWidth)
{
_linesOffsetX.push_back(_contentSize.width - lineWidth);
}

View File

@ -128,7 +128,7 @@ bool Menu::initWithArray(const Vector<MenuItem*>& arrayOfItems)
int z = 0;
for (auto& item : arrayOfItems)
for (auto&& item : arrayOfItems)
{
this->addChild(item, z);
z++;

View File

@ -171,7 +171,7 @@ Node::~Node()
// `AX_SAFE_RELEASE_NULL(_actionManager)`.
AX_SAFE_RELEASE_NULL(_userObject);
for (auto& child : _children)
for (auto&& child : _children)
{
child->_parent = nullptr;
}

View File

@ -1366,7 +1366,7 @@ void ParticleSystem::resetAnimationDescriptors()
void ParticleSystem::setMultiAnimationRandom()
{
_randomAnimations.clear();
for (auto& a : _animations)
for (auto&& a : _animations)
_randomAnimations.push_back(a.first);
}

View File

@ -196,7 +196,7 @@ void PlistSpriteSheetLoader::addSpriteFramesWithDictionary(ValueMap& dictionary,
auto textureFileName = Director::getInstance()->getTextureCache()->getTextureFilePath(texture);
Image* image = nullptr;
NinePatchImageParser parser;
for (auto& iter : framesDict)
for (auto&& iter : framesDict)
{
auto& frameDict = iter.second.asValueMap();
auto spriteFrameName = iter.first;
@ -394,7 +394,7 @@ void PlistSpriteSheetLoader::reloadSpriteFramesWithDictionary(ValueMap& dict,
spriteSheet->format = getFormat();
spriteSheet->path = plist;
for (auto& iter : framesDict)
for (auto&& iter : framesDict)
{
const ValueMap& frameDict = iter.second.asValueMap();
std::string_view spriteFrameName = iter.first;

View File

@ -120,7 +120,7 @@ Node* ProtectedNode::getProtectedChildByTag(int tag)
{
AXASSERT(tag != Node::INVALID_TAG, "Invalid tag");
for (auto& child : _protectedChildren)
for (auto&& child : _protectedChildren)
{
if (child && child->getTag() == tag)
return child;
@ -182,7 +182,7 @@ void ProtectedNode::removeAllProtectedChildren()
void ProtectedNode::removeAllProtectedChildrenWithCleanup(bool cleanup)
{
// not using detachChild improves speed here
for (auto& child : _protectedChildren)
for (auto&& child : _protectedChildren)
{
// IMPORTANT:
// -1st do onExit
@ -361,13 +361,13 @@ void ProtectedNode::updateDisplayedOpacity(uint8_t parentOpacity)
if (_cascadeOpacityEnabled)
{
for (auto child : _children)
for (auto&& child : _children)
{
child->updateDisplayedOpacity(_displayedOpacity);
}
}
for (auto child : _protectedChildren)
for (auto&& child : _protectedChildren)
{
child->updateDisplayedOpacity(_displayedOpacity);
}
@ -395,11 +395,11 @@ void ProtectedNode::updateDisplayedColor(const Color3B& parentColor)
void ProtectedNode::disableCascadeColor()
{
for (auto child : _children)
for (auto&& child : _children)
{
child->updateDisplayedColor(Color3B::WHITE);
}
for (auto child : _protectedChildren)
for (auto&& child : _protectedChildren)
{
child->updateDisplayedColor(Color3B::WHITE);
}
@ -409,12 +409,12 @@ void ProtectedNode::disableCascadeOpacity()
{
_displayedOpacity = _realOpacity;
for (auto child : _children)
for (auto&& child : _children)
{
child->updateDisplayedOpacity(255);
}
for (auto child : _protectedChildren)
for (auto&& child : _protectedChildren)
{
child->updateDisplayedOpacity(255);
}
@ -425,7 +425,7 @@ void ProtectedNode::setCameraMask(unsigned short mask, bool applyChildren)
Node::setCameraMask(mask, applyChildren);
if (applyChildren)
{
for (auto& iter : _protectedChildren)
for (auto&& iter : _protectedChildren)
{
iter->setCameraMask(mask);
}
@ -435,7 +435,7 @@ void ProtectedNode::setCameraMask(unsigned short mask, bool applyChildren)
void ProtectedNode::setGlobalZOrder(float globalZOrder)
{
Node::setGlobalZOrder(globalZOrder);
for (auto& child : _protectedChildren)
for (auto&& child : _protectedChildren)
child->setGlobalZOrder(globalZOrder);
}

View File

@ -151,7 +151,7 @@ void SpriteFrameCache::removeUnusedSpriteFrames()
std::vector<std::string> toRemoveFrames;
const auto& frames = getSpriteFrames();
for (auto& iter : frames)
for (auto&& iter : frames)
{
auto* spriteFrame = iter.second;
if (spriteFrame->getReferenceCount() == 1)
@ -228,7 +228,7 @@ void SpriteFrameCache::removeSpriteFramesFromTexture(Texture2D* texture)
{
std::vector<std::string> keysToRemove;
for (auto& iter : getSpriteFrames())
for (auto&& iter : getSpriteFrames())
{
auto key = iter.first;
auto* frame = findFrame(key);

View File

@ -411,7 +411,7 @@ void Animate3D::update(float t)
}
}
std::sort(eventInfos.begin(), eventInfos.end(), _playReverse ? cmpEventInfoDes : cmpEventInfoAsc);
for (auto eventInfo : eventInfos)
for (auto&& eventInfo : eventInfos)
{
Director::getInstance()->getEventDispatcher()->dispatchEvent(_keyFrameEvent[eventInfo->frame]);
}
@ -507,7 +507,7 @@ Animate3D::~Animate3D()
{
removeFromMap();
for (auto& it : _keyFrameEvent)
for (auto&& it : _keyFrameEvent)
{
delete it.second;
}

View File

@ -220,7 +220,7 @@ void Animation3DCache::addAnimation(std::string_view key, Animation3D* animation
void Animation3DCache::removeAllAnimations()
{
for (auto itor : _animations)
for (auto&& itor : _animations)
{
AX_SAFE_RELEASE(itor.second);
}

View File

@ -230,7 +230,7 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas,
auto last = fullPath.rfind('/');
if (last != std::string::npos)
dir = fullPath.substr(0, last + 1);
for (auto& material : materials)
for (auto&& material : materials)
{
NMaterialData materialdata;
@ -249,7 +249,7 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas,
// convert mesh
i = 0;
for (auto& shape : shapes)
for (auto&& shape : shapes)
{
auto mesh = shape.mesh;
MeshData* meshdata = new MeshData();
@ -310,7 +310,7 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas,
auto node = new NodeData();
node->id = shape.name;
for (auto& submesh : subMeshMap)
for (auto&& submesh : subMeshMap)
{
auto& storedIndices = meshdata->subMeshIndices.emplace_back(std::move(submesh.second));
meshdata->subMeshAABB.push_back(
@ -490,7 +490,7 @@ bool Bundle3D::loadMeshDatasBinary(MeshDatas& meshdatas)
FAILED:
{
AX_SAFE_DELETE(meshData);
for (auto& meshdata : meshdatas.meshDatas)
for (auto&& meshdata : meshdatas.meshDatas)
{
delete meshdata;
}
@ -2297,7 +2297,7 @@ std::vector<Vec3> Bundle3D::getTrianglesList(std::string_view path)
}
Bundle3D::destroyBundle(bundle);
for (auto iter : meshs.meshDatas)
for (auto&& iter : meshs.meshDatas)
{
int preVertexSize = iter->getPerVertexSize() / sizeof(float);
for (const auto& indices : iter->subMeshIndices)

View File

@ -272,13 +272,13 @@ struct NodeData
{
id.clear();
transform.setIdentity();
for (auto& it : children)
for (auto&& it : children)
{
delete it;
}
children.clear();
for (auto& modeldata : modelNodeDatas)
for (auto&& modeldata : modelNodeDatas)
{
delete modeldata;
}
@ -299,12 +299,12 @@ struct NodeDatas
void resetData()
{
for (auto& it : skeleton)
for (auto&& it : skeleton)
{
delete it;
}
skeleton.clear();
for (auto& it : nodes)
for (auto&& it : nodes)
{
delete it;
}
@ -369,7 +369,7 @@ struct MeshDatas
void resetData()
{
for (auto& it : meshDatas)
for (auto&& it : meshDatas)
{
delete it;
}

View File

@ -122,7 +122,7 @@ Mesh::Mesh()
{}
Mesh::~Mesh()
{
for (auto& tex : _textures)
for (auto&& tex : _textures)
{
AX_SAFE_RELEASE(tex.second);
}
@ -288,7 +288,7 @@ void Mesh::setTexture(Texture2D* tex, NTextureData::Usage usage, bool cacheFileN
if (_material)
{
auto technique = _material->_currentTechnique;
for (auto& pass : technique->_passes)
for (auto&& pass : technique->_passes)
{
pass->setUniformTexture(0, tex->getBackendTexture());
}
@ -303,7 +303,7 @@ void Mesh::setTexture(Texture2D* tex, NTextureData::Usage usage, bool cacheFileN
if (_material)
{
auto technique = _material->_currentTechnique;
for (auto& pass : technique->_passes)
for (auto&& pass : technique->_passes)
{
pass->setUniformNormTexture(1, tex->getBackendTexture());
}
@ -339,7 +339,7 @@ void Mesh::setMaterial(Material* material)
if (_material)
{
for (auto technique : _material->getTechniques())
for (auto&& technique : _material->getTechniques())
{
// allocate MeshCommand vector for technique
// allocate MeshCommand for each pass
@ -347,7 +347,7 @@ void Mesh::setMaterial(Material* material)
auto& list = _meshCommands[technique->getName()];
int i = 0;
for (auto pass : technique->getPasses())
for (auto&& pass : technique->getPasses())
{
#ifdef AXIS_DEBUG
// make it crashed when missing attribute data
@ -370,7 +370,7 @@ void Mesh::setMaterial(Material* material)
_meshIndexData->setPrimitiveType(material->getPrimitiveType());
}
// Was the texture set before the GLProgramState ? Set it
for (auto& tex : _textures)
for (auto&& tex : _textures)
setTexture(tex.second, tex.first);
if (_blendDirty)
@ -436,7 +436,7 @@ void Mesh::draw(Renderer* renderer,
}
auto& commands = _meshCommands[technique->getName()];
for (auto& command : commands)
for (auto&& command : commands)
{
command.init(globalZ, transform);
command.setSkipBatching(isTransparent);

View File

@ -183,7 +183,7 @@ void MeshMaterial::releaseBuiltInMaterial()
void MeshMaterial::releaseCachedMaterial()
{
for (auto& it : _materials)
for (auto&& it : _materials)
{
if (it.second)
it.second->release();
@ -307,7 +307,7 @@ MeshMaterial* MeshMaterial::createWithProgramState(backend::ProgramState* progra
void MeshMaterial::setTexture(Texture2D* tex, NTextureData::Usage usage)
{
const auto& passes = getTechnique()->getPasses();
for (auto& pass : passes)
for (auto&& pass : passes)
{
pass->setUniformTexture(0, tex->getBackendTexture());
}
@ -364,7 +364,7 @@ Texture2D* MeshMaterialCache::getMeshMaterial(std::string_view key)
void MeshMaterialCache::removeAllMeshMaterial()
{
for (auto& itr : _materials)
for (auto&& itr : _materials)
{
AX_SAFE_RELEASE_NULL(itr.second);
}

View File

@ -185,7 +185,7 @@ void MeshRenderer::afterAsyncLoad(void* param)
AABB MeshRenderer::getAABBRecursivelyImp(Node* node)
{
AABB aabb;
for (auto iter : node->getChildren())
for (auto&& iter : node->getChildren())
{
aabb.merge(getAABBRecursivelyImp(iter));
}
@ -202,7 +202,7 @@ bool MeshRenderer::loadFromCache(std::string_view path)
auto meshdata = MeshRendererCache::getInstance()->getMeshRenderData(path);
if (meshdata)
{
for (auto it : meshdata->meshVertexDatas)
for (auto&& it : meshdata->meshVertexDatas)
{
_meshVertexDatas.pushBack(it);
}
@ -502,14 +502,14 @@ void MeshRenderer::genMaterial(bool useLight)
_shaderUsingLight = useLight;
std::unordered_map<const MeshVertexData*, MeshMaterial*> materials;
for (auto meshVertexData : _meshVertexDatas)
for (auto&& meshVertexData : _meshVertexDatas)
{
auto material = getMeshRendererMaterialForAttribs(meshVertexData, useLight);
AXASSERT(material, "material should cannot be null.");
materials[meshVertexData] = material;
}
for (auto& mesh : _meshes)
for (auto&& mesh : _meshes)
{
auto material = materials[mesh->getMeshIndexData()->getMeshVertexData()];
// keep original state block if exist
@ -656,7 +656,7 @@ void MeshRenderer::createNode(NodeData* nodedata, Node* root, const MaterialData
MeshIndexData* MeshRenderer::getMeshIndexData(std::string_view indexId) const
{
for (auto it : _meshVertexDatas)
for (auto&& it : _meshVertexDatas)
{
auto index = it->getMeshIndexDataById(indexId);
if (index)
@ -680,7 +680,7 @@ void MeshRenderer::setTexture(std::string_view texFile)
void MeshRenderer::setTexture(Texture2D* texture)
{
for (auto mesh : _meshes)
for (auto&& mesh : _meshes)
{
mesh->setTexture(texture);
}
@ -718,7 +718,7 @@ void MeshRenderer::removeAttachNode(std::string_view boneName)
void MeshRenderer::removeAllAttachNode()
{
for (auto& it : _attachments)
for (auto&& it : _attachments)
{
removeChild(it.second);
}
@ -808,7 +808,7 @@ void MeshRenderer::draw(Renderer* renderer, const Mat4& transform, uint32_t flag
}
}
for (auto mesh : _meshes)
for (auto&& mesh : _meshes)
{
mesh->draw(renderer, _globalZOrder, transform, flags, _lightMask, Vec4(color.r, color.g, color.b, color.a),
_forceDepthWrite);
@ -819,7 +819,7 @@ bool MeshRenderer::setProgramState(backend::ProgramState* programState, bool nee
{
if (Node::setProgramState(programState, needsRetain))
{
for (auto state : _meshes)
for (auto&& state : _meshes)
{
state->setProgramState(programState);
}
@ -833,7 +833,7 @@ void MeshRenderer::setBlendFunc(const BlendFunc& blendFunc)
if (_blend.src != blendFunc.src || _blend.dst != blendFunc.dst)
{
_blend = blendFunc;
for (auto mesh : _meshes)
for (auto&& mesh : _meshes)
{
mesh->setBlendFunc(blendFunc);
}
@ -895,7 +895,7 @@ Rect MeshRenderer::getBoundingBox() const
void MeshRenderer::setCullFace(CullFaceSide side)
{
for (auto& it : _meshes)
for (auto&& it : _meshes)
{
it->getMaterial()->getStateBlock().setCullFaceSide(side);
}
@ -903,7 +903,7 @@ void MeshRenderer::setCullFace(CullFaceSide side)
void MeshRenderer::setCullFaceEnabled(bool enable)
{
for (auto& it : _meshes)
for (auto&& it : _meshes)
{
it->getMaterial()->getStateBlock().setCullFace(enable);
}
@ -1002,7 +1002,7 @@ void MeshRendererCache::removeMeshRenderData(std::string_view key)
void MeshRendererCache::removeAllMeshRenderData()
{
for (auto& it : _meshDatas)
for (auto&& it : _meshDatas)
{
delete it.second;
}

View File

@ -103,7 +103,7 @@ Vec4* MeshSkin::getMatrixPalette()
_matrixPalette.resize(_skinBones.size() * PALETTE_ROWS);
int i = 0, paletteIndex = 0;
static Mat4 t;
for (auto it : _skinBones)
for (auto&& it : _skinBones)
{
Mat4::multiply(it->getWorldMat(), _invBindPoses[i++], &t);
_matrixPalette[paletteIndex++].set(t.m[0], t.m[4], t.m[8], t.m[12]);

View File

@ -162,7 +162,7 @@ MeshVertexData* MeshVertexData::create(const MeshData& meshdata, CustomCommand::
MeshIndexData* MeshVertexData::getMeshIndexDataById(std::string_view id) const
{
for (auto it : _indices)
for (auto&& it : _indices)
{
if (it->getId() == id)
return it;

View File

@ -51,7 +51,7 @@ void Bone3D::resetPose()
{
_local = _oriPose;
for (auto it : _children)
for (auto&& it : _children)
{
it->resetPose();
}
@ -60,7 +60,7 @@ void Bone3D::resetPose()
void Bone3D::setWorldMatDirty(bool dirty)
{
_worldDirty = dirty;
for (auto it : _children)
for (auto&& it : _children)
{
it->setWorldMatDirty(dirty);
}
@ -70,7 +70,7 @@ void Bone3D::setWorldMatDirty(bool dirty)
void Bone3D::updateWorldMat()
{
getWorldMat();
for (auto itor : _children)
for (auto&& itor : _children)
{
itor->updateWorldMat();
}
@ -96,7 +96,7 @@ const Mat4& Bone3D::getWorldMat()
void Bone3D::setAnimationValue(float* trans, float* rot, float* scale, void* tag, float weight)
{
for (auto& it : _blendStates)
for (auto&& it : _blendStates)
{
if (it.tag == tag)
{
@ -127,7 +127,7 @@ void Bone3D::setAnimationValue(float* trans, float* rot, float* scale, void* tag
void Bone3D::clearBoneBlendState()
{
_blendStates.clear();
for (auto it : _children)
for (auto&& it : _children)
{
it->clearBoneBlendState();
}
@ -282,7 +282,7 @@ Bone3D* Skeleton3D::getBoneByIndex(unsigned int index) const
Bone3D* Skeleton3D::getBoneByName(std::string_view id) const
{
// search from bones
for (auto it : _bones)
for (auto&& it : _bones)
{
if (it->getName() == id)
return it;

View File

@ -438,7 +438,7 @@ void Terrain::calculateNormal()
_vertices[Index2]._normal += Normal;
}
for (auto& vertex : _vertices)
for (auto&& vertex : _vertices)
{
vertex._normal.normalize();
}
@ -1565,7 +1565,7 @@ Terrain::QuadTree::QuadTree(int x, int y, int w, int h, Terrain* terrain)
_localAABB = _chunk->_aabb;
_chunk->_parent = this;
for (auto& triangle : _chunk->_trianglesList)
for (auto&& triangle : _chunk->_trianglesList)
{
triangle.transform(_terrain->getNodeToWorldTransform());
}

View File

@ -835,7 +835,7 @@ void AudioEngineImpl::_updatePlayers(bool forStop)
{
if (!_finishCallbacks.empty())
{
for (auto& finishCallback : _finishCallbacks)
for (auto&& finishCallback : _finishCallbacks)
finishCallback();
_finishCallbacks.clear();
}
@ -864,7 +864,7 @@ void AudioEngineImpl::uncache(std::string_view filePath)
void AudioEngineImpl::uncacheAll()
{
// prevent player hold invalid AudioCache* pointer, since all audio caches purged
for (auto& player : _audioPlayers)
for (auto&& player : _audioPlayers)
player.second->setCache(nullptr);
_audioCaches.clear();

View File

@ -483,7 +483,7 @@ Console::~Console()
{
stop();
for (auto& e : _commands)
for (auto&& e : _commands)
delete e.second;
}
@ -812,7 +812,7 @@ void Console::loop()
{
for (const auto& str : _DebugStrings)
{
for (auto fd : _fds)
for (auto&& fd : _fds)
{
Console::Utility::sendToConsole(fd, str.c_str(), str.length());
}
@ -959,7 +959,7 @@ bool Console::parseCommand(socket_native_type fd)
auto commands = Console::Utility::split(cmdLine, _commandSeparator);
try
{
for (auto command : commands)
for (auto&& command : commands)
{
performCommand(fd, Console::Utility::trim(command));
}
@ -1623,7 +1623,7 @@ void Console::printFileUtils(socket_native_type fd)
void Console::sendHelp(socket_native_type fd, const hlookup::string_map<Command*>& commands, const char* msg)
{
Console::Utility::sendToConsole(fd, msg, strlen(msg));
for (auto& it : commands)
for (auto&& it : commands)
{
auto command = it.second;
if (command->getHelp().empty())

View File

@ -4182,7 +4182,7 @@ public:
{
// If there are any controllers connected that were not deleted at the end of execution, delete them.
// This wil prevent any memory leaks showing up in valgrind
for (auto& controller : Controller::s_allController)
for (auto&& controller : Controller::s_allController)
{
delete controller;
}
@ -4422,7 +4422,7 @@ void Controller::stopDiscoveryController()
glfwSetJoystickCallback(nullptr);
// Also remove all the connected controllers:
for (auto& controller : Controller::s_allController)
for (auto&& controller : Controller::s_allController)
{
delete controller;
}

View File

@ -40,7 +40,7 @@ std::vector<Controller*> Controller::s_allController;
Controller* Controller::getControllerByTag(int tag)
{
for (auto controller : Controller::s_allController)
for (auto&& controller : Controller::s_allController)
{
if (controller->_controllerTag == tag)
{
@ -52,7 +52,7 @@ Controller* Controller::getControllerByTag(int tag)
Controller* Controller::getControllerByDeviceId(int deviceId)
{
for (auto controller : Controller::s_allController)
for (auto&& controller : Controller::s_allController)
{
if (controller->_deviceId == deviceId)
{

View File

@ -285,13 +285,13 @@ void EventDispatcher::pauseEventListenersForTarget(Node* target, bool recursive
if (listenerIter != _nodeListenersMap.end())
{
auto listeners = listenerIter->second;
for (auto& l : *listeners)
for (auto&& l : *listeners)
{
l->setPaused(true);
}
}
for (auto& listener : _toAddedListeners)
for (auto&& listener : _toAddedListeners)
{
if (listener->getAssociatedNode() == target)
{
@ -315,13 +315,13 @@ void EventDispatcher::resumeEventListenersForTarget(Node* target, bool recursive
if (listenerIter != _nodeListenersMap.end())
{
auto listeners = listenerIter->second;
for (auto& l : *listeners)
for (auto&& l : *listeners)
{
l->setPaused(false);
}
}
for (auto& listener : _toAddedListeners)
for (auto&& listener : _toAddedListeners)
{
if (listener->getAssociatedNode() == target)
{
@ -353,7 +353,7 @@ void EventDispatcher::removeEventListenersForTarget(Node* target, bool recursive
{
auto listeners = listenerIter->second;
auto listenersCopy = *listeners;
for (auto& l : listenersCopy)
for (auto&& l : listenersCopy)
{
removeEventListener(l);
}
@ -704,7 +704,7 @@ void EventDispatcher::setPriority(EventListener* listener, int fixedPriority)
if (listener == nullptr)
return;
for (auto& iter : _listenerMap)
for (auto&& iter : _listenerMap)
{
auto fixedPriorityListeners = iter.second->getFixedPriorityListeners();
if (fixedPriorityListeners)
@ -759,7 +759,7 @@ void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners,
if (!shouldStopPropagation)
{
// priority == 0, scene graph priority
for (auto& l : *sceneGraphPriorityListeners)
for (auto&& l : *sceneGraphPriorityListeners)
{
if (l->isEnabled() && !l->isPaused() && l->isRegistered() && onEvent(l))
{
@ -827,7 +827,7 @@ void EventDispatcher::dispatchTouchEventToListeners(EventListenerVector* listene
// first, get all enabled, unPaused and registered listeners
std::vector<EventListener*> sceneListeners;
for (auto& l : *sceneGraphPriorityListeners)
for (auto&& l : *sceneGraphPriorityListeners)
{
if (l->isEnabled() && !l->isPaused() && l->isRegistered())
{
@ -848,7 +848,7 @@ void EventDispatcher::dispatchTouchEventToListeners(EventListenerVector* listene
Camera::_visitingCamera = camera;
auto cameraFlag = (unsigned short)camera->getCameraFlag();
for (auto& l : sceneListeners)
for (auto&& l : sceneListeners)
{
if (nullptr == l->getAssociatedNode() ||
0 == (l->getAssociatedNode()->getCameraMask() & cameraFlag))
@ -968,7 +968,7 @@ void EventDispatcher::dispatchTouchEvent(EventTouch* event)
{
auto mutableTouchesIter = mutableTouches.begin();
for (auto& touches : originalTouches)
for (auto&& touches : originalTouches)
{
bool isSwallowed = false;
@ -1235,7 +1235,7 @@ void EventDispatcher::updateListeners(Event* event)
if (!_toAddedListeners.empty())
{
for (auto& listener : _toAddedListeners)
for (auto&& listener : _toAddedListeners)
{
forceAddEventListener(listener);
}
@ -1252,12 +1252,12 @@ void EventDispatcher::updateDirtyFlagForSceneGraph()
{
if (!_dirtyNodes.empty())
{
for (auto& node : _dirtyNodes)
for (auto&& node : _dirtyNodes)
{
auto iter = _nodeListenersMap.find(node);
if (iter != _nodeListenersMap.end())
{
for (auto& l : *iter->second)
for (auto&& l : *iter->second)
{
setDirty(l->getListenerID(), DirtyFlag::SCENE_GRAPH_PRIORITY);
}
@ -1328,7 +1328,7 @@ void EventDispatcher::sortEventListenersOfSceneGraphPriority(std::string_view li
#if DUMP_LISTENER_ITEM_PRIORITY_INFO
log("-----------------------------------");
for (auto& l : *sceneGraphListeners)
for (auto&& l : *sceneGraphListeners)
{
log("listener priority: node ([%s]%p), priority (%d)", typeid(*l->_node).name(), l->_node,
_nodePriorityMap[l->_node]);
@ -1355,7 +1355,7 @@ void EventDispatcher::sortEventListenersOfFixedPriority(std::string_view listene
// FIXME: Should use binary search
int index = 0;
for (auto& listener : *fixedListeners)
for (auto&& listener : *fixedListeners)
{
if (listener->getFixedPriority() >= 0)
break;
@ -1366,7 +1366,7 @@ void EventDispatcher::sortEventListenersOfFixedPriority(std::string_view listene
#if DUMP_LISTENER_ITEM_PRIORITY_INFO
log("-----------------------------------");
for (auto& l : *fixedListeners)
for (auto&& l : *fixedListeners)
{
log("listener priority: node (%p), fixed (%d)", l->_node, l->_fixedPriority);
}
@ -1554,7 +1554,7 @@ void EventDispatcher::setDirty(std::string_view listenerID, DirtyFlag flag)
void EventDispatcher::cleanToRemovedListeners()
{
for (auto& l : _toRemovedListeners)
for (auto&& l : _toRemovedListeners)
{
auto listenersIter = _listenerMap.find(l->getListenerID());
if (listenersIter == _listenerMap.end())

View File

@ -430,7 +430,7 @@ protected:
/** Retains all the objects in the map */
void addRefForAllObjects()
{
for (auto& iter : _data)
for (auto&& iter : _data)
{
iter.second->retain();
}

View File

@ -78,7 +78,7 @@ Profiler::~Profiler() {}
void Profiler::displayTimers()
{
for (auto& iter : _activeTimers)
for (auto&& iter : _activeTimers)
{
ProfilingTimer* timer = iter.second;
log("%s", timer->getDescription().c_str());

View File

@ -833,7 +833,7 @@ bool Properties::setString(const char* name, const char* value)
{
if (name)
{
for (auto& itr : _properties)
for (auto&& itr : _properties)
{
if (itr.name == name)
{

View File

@ -908,7 +908,7 @@ void Scheduler::update(float dt)
}
// delete all updates that are removed in update
for (auto& e : _updateDeleteVector)
for (auto&& e : _updateDeleteVector)
delete e;
_updateDeleteVector.clear();

View File

@ -445,7 +445,7 @@ void UserDefault::lazyInit()
pugi::xml_parse_result ret = doc.load_buffer_inplace(data.getBytes(), data.getSize());
if (ret)
{
for (auto& elem : doc.document_element())
for (auto&& elem : doc.document_element())
updateValueForKey(elem.name(), elem.text().as_string());
}
else
@ -466,7 +466,7 @@ void UserDefault::flush()
{
yasio::obstream obs;
obs.write<int>(static_cast<int>(this->_values.size()));
for (auto& item : this->_values)
for (auto&& item : this->_values)
{
if (_encryptEnabled)
{
@ -506,7 +506,7 @@ void UserDefault::flush()
doc.load_string(R"(<?xml version="1.0" ?>
<r />)");
auto r = doc.document_element();
for (auto& kv : _values)
for (auto&& kv : _values)
r.append_child(kv.first.c_str()).append_child(pugi::xml_node_type::node_pcdata).set_value(kv.second.c_str());
std::stringstream ss;

View File

@ -857,7 +857,7 @@ static std::string visitMap(const T& v, int depth)
ret << getTabs(depth) << "{\n";
for (auto& iter : v)
for (auto&& iter : v)
{
ret << getTabs(depth + 1) << iter.first << ": ";
ret << visit(iter.second, depth + 1);

View File

@ -127,7 +127,7 @@ public:
/** Constructor with initializer list. */
Vector<T>(std::initializer_list<T> list)
{
for (auto& element : list)
for (auto&& element : list)
{
pushBack(element);
}
@ -424,7 +424,7 @@ public:
*/
void clear()
{
for (auto& it : _data)
for (auto&& it : _data)
{
it->release();
}

View File

@ -768,7 +768,7 @@ std::vector<std::string> ZipFile::listFiles(std::string_view pathname) const
// ensure pathname ends with `/` as a directory
std::string ensureDir;
std::string_view dirname = pathname[pathname.length() - 1] == '/' ? pathname : (ensureDir.append(pathname) += '/');
for (auto& item : _data->fileList)
for (auto&& item : _data->fileList)
{
std::string_view filename = item.first;
if (cxx20::starts_with(filename, cxx17::string_view{dirname}))

View File

@ -90,7 +90,7 @@ public:
_task_queue_cv.notify_all();
_task_queue_mtx.unlock();
for (auto& t : _threads)
for (auto&& t : _threads)
{
if (t.joinable())
t.join();

View File

@ -255,7 +255,7 @@ Rect getCascadeBoundingBox(Node* node)
// check all children bounding box, get maximize box
Node* child = nullptr;
bool merge = false;
for (auto object : node->getChildren())
for (auto&& object : node->getChildren())
{
child = dynamic_cast<Node*>(object);
if (!child->isVisible())
@ -359,7 +359,7 @@ Node* findChild(Node* levelRoot, std::string_view name)
return target;
// Find recursively
for (auto& child : levelRoot->getChildren())
for (auto&& child : levelRoot->getChildren())
{
target = findChild(child, name);
if (target != nullptr)
@ -379,7 +379,7 @@ Node* findChild(Node* levelRoot, int tag)
return target;
// Find recursively
for (auto& child : levelRoot->getChildren())
for (auto&& child : levelRoot->getChildren())
{
target = findChild(child, tag);
if (target != nullptr)

View File

@ -125,13 +125,13 @@ NavMesh::~NavMesh()
AX_SAFE_DELETE(_meshProcess);
AX_SAFE_DELETE(_geomData);
for (auto iter : _agentList)
for (auto&& iter : _agentList)
{
AX_SAFE_RELEASE(iter);
}
_agentList.clear();
for (auto iter : _obstacleList)
for (auto&& iter : _obstacleList)
{
AX_SAFE_RELEASE(iter);
}
@ -320,7 +320,7 @@ void axis::NavMesh::drawOffMeshConnections()
void axis::NavMesh::drawObstacles()
{
// Draw obstacles
for (auto iter : _obstacleList)
for (auto&& iter : _obstacleList)
{
if (iter)
{
@ -347,7 +347,7 @@ void axis::NavMesh::drawObstacles()
void axis::NavMesh::drawAgents()
{
for (auto iter : _agentList)
for (auto&& iter : _agentList)
{
if (iter)
{
@ -375,7 +375,7 @@ void axis::NavMesh::drawAgents()
}
// Velocity stuff.
for (auto iter : _agentList)
for (auto&& iter : _agentList)
{
if (iter)
{
@ -478,13 +478,13 @@ void NavMesh::debugDraw(Renderer* renderer)
void NavMesh::update(float dt)
{
for (auto iter : _agentList)
for (auto&& iter : _agentList)
{
if (iter)
iter->preUpdate(dt);
}
for (auto iter : _obstacleList)
for (auto&& iter : _obstacleList)
{
if (iter)
iter->preUpdate(dt);
@ -496,13 +496,13 @@ void NavMesh::update(float dt)
if (_tileCache)
_tileCache->update(dt, _navMesh);
for (auto iter : _agentList)
for (auto&& iter : _agentList)
{
if (iter)
iter->postUpdate(dt);
}
for (auto iter : _obstacleList)
for (auto&& iter : _obstacleList)
{
if (iter)
iter->postUpdate(dt);

View File

@ -94,7 +94,7 @@ void NavMeshDebugDraw::vertex(const float* pos, unsigned int color)
NavMeshDebugDraw::~NavMeshDebugDraw()
{
for (auto iter : _primitiveList)
for (auto&& iter : _primitiveList)
{
delete iter;
}
@ -191,7 +191,7 @@ void NavMeshDebugDraw::draw(Renderer* renderer)
{
_commands.resize(_primitiveList.size());
}
for (auto& iter : _primitiveList)
for (auto&& iter : _primitiveList)
{
if (iter->type == backend::PrimitiveType::POINT)
continue;
@ -255,7 +255,7 @@ void NavMeshDebugDraw::onBeforeEachCommand(bool enableDepthWrite)
void NavMeshDebugDraw::clear()
{
_vertices.clear();
for (auto iter : _primitiveList)
for (auto&& iter : _primitiveList)
{
delete iter;
}

View File

@ -414,7 +414,7 @@ public:
if (!_processSet.empty())
{
std::lock_guard<std::mutex> lock(_processMutex);
for (auto& task : _processSet)
for (auto&& task : _processSet)
task->cancel();
_processSet.clear();
}
@ -434,7 +434,7 @@ public:
{
std::lock_guard<std::mutex> lock(_processMutex);
outList.reserve(_processSet.size());
for (auto& task : _processSet)
for (auto&& task : _processSet)
{
if (!task->background)
outList.push_back(task);
@ -984,7 +984,7 @@ void DownloaderCURL::_onUpdate(float)
// update processing tasks
_impl->getProcessTasks(tasks);
for (auto& task : tasks)
for (auto&& task : tasks)
{
DownloadTaskCURL& coTask = static_cast<DownloadTaskCURL&>(*task->_coTask);
std::lock_guard<std::recursive_mutex> lock(coTask._mutex);
@ -1007,7 +1007,7 @@ void DownloaderCURL::_onUpdate(float)
_scheduler->pauseTarget(this);
}
for (auto& task : tasks)
for (auto&& task : tasks)
{
_onDownloadFinished(*task);
}

View File

@ -320,7 +320,7 @@ void HttpClient::handleNetworkEvent(yasio::io_event* event)
if (!headers.empty())
{
using namespace cxx17; // for string_view literal
for (auto& header : headers)
for (auto&& header : headers)
{
obs.write_bytes(header);
obs.write_bytes("\r\n");

View File

@ -103,7 +103,7 @@ const std::vector<CookieInfo>* HttpCookie::getCookies() const
const CookieInfo* HttpCookie::getMatchCookie(const Uri& uri) const
{
for (auto& cookie : _cookies)
for (auto&& cookie : _cookies)
{
if (cxx20::ends_with(uri.getHost(), cookie.domain) && cxx20::starts_with(uri.getPath(), cookie.path))
return &cookie;
@ -114,7 +114,7 @@ const CookieInfo* HttpCookie::getMatchCookie(const Uri& uri) const
void HttpCookie::updateOrAddCookie(CookieInfo* cookie)
{
for (auto& _cookie : _cookies)
for (auto&& _cookie : _cookies)
{
if (cookie->isSame(_cookie))
{
@ -264,7 +264,7 @@ void HttpCookie::writeFile()
std::string line;
char expires[32] = {0}; // LONGLONG_STRING_SIZE=20
for (auto& cookie : _cookies)
for (auto&& cookie : _cookies)
{
line.clear();
line.append(cookie.domain);

View File

@ -58,7 +58,7 @@ std::string submatch(const std::smatch& m, int idx)
template <class String>
void toLower(String& s)
{
for (auto& c : s)
for (auto&& c : s)
{
c = char(tolower(c));
}

View File

@ -115,7 +115,7 @@ PhysicsBody::PhysicsBody()
PhysicsBody::~PhysicsBody()
{
for (auto& joint : _joints)
for (auto&& joint : _joints)
{
PhysicsBody* other = joint->getBodyA() == this ? joint->getBodyB() : joint->getBodyA();
other->removeJoint(joint);
@ -367,7 +367,7 @@ void PhysicsBody::setRotation(float rotation)
void PhysicsBody::setScale(float scaleX, float scaleY)
{
for (auto& shape : _shapes)
for (auto&& shape : _shapes)
{
_area -= shape->getArea();
if (!_massSetByUser)
@ -674,7 +674,7 @@ void PhysicsBody::setMoment(float moment)
PhysicsShape* PhysicsBody::getShape(int tag) const
{
for (auto& shape : _shapes)
for (auto&& shape : _shapes)
{
if (shape->getTag() == tag)
{
@ -687,7 +687,7 @@ PhysicsShape* PhysicsBody::getShape(int tag) const
void PhysicsBody::removeShape(int tag, bool reduceMassAndMoment /* = true*/)
{
for (auto& shape : _shapes)
for (auto&& shape : _shapes)
{
if (shape->getTag() == tag)
{
@ -725,7 +725,7 @@ void PhysicsBody::removeShape(PhysicsShape* shape, bool reduceMassAndMoment /* =
void PhysicsBody::removeAllShapes(bool reduceMassAndMoment /* = true*/)
{
for (auto& child : _shapes)
for (auto&& child : _shapes)
{
PhysicsShape* shape = dynamic_cast<PhysicsShape*>(child);
@ -806,7 +806,7 @@ void PhysicsBody::update(float delta)
void PhysicsBody::setCategoryBitmask(int bitmask)
{
for (auto& shape : _shapes)
for (auto&& shape : _shapes)
{
shape->setCategoryBitmask(bitmask);
}
@ -826,7 +826,7 @@ int PhysicsBody::getCategoryBitmask() const
void PhysicsBody::setContactTestBitmask(int bitmask)
{
for (auto& shape : _shapes)
for (auto&& shape : _shapes)
{
shape->setContactTestBitmask(bitmask);
}
@ -846,7 +846,7 @@ int PhysicsBody::getContactTestBitmask() const
void PhysicsBody::setCollisionBitmask(int bitmask)
{
for (auto& shape : _shapes)
for (auto&& shape : _shapes)
{
shape->setCollisionBitmask(bitmask);
}
@ -866,7 +866,7 @@ int PhysicsBody::getCollisionBitmask() const
void PhysicsBody::setGroup(int group)
{
for (auto& shape : _shapes)
for (auto&& shape : _shapes)
{
shape->setGroup(group);
}

View File

@ -171,7 +171,7 @@ bool PhysicsJoint::initJoint()
ret = createConstraints();
AX_BREAK_IF(!ret);
for (auto subjoint : _cpConstraints)
for (auto&& subjoint : _cpConstraints)
{
cpConstraintSetMaxForce(subjoint, _maxForce);
cpConstraintSetErrorBias(subjoint, cpfpow(1.0f - 0.15f, 60.0f));
@ -235,7 +235,7 @@ void PhysicsJoint::setMaxForce(float force)
{
delay([this, force]() {
_maxForce = force;
for (auto joint : _cpConstraints)
for (auto&& joint : _cpConstraints)
{
cpConstraintSetMaxForce(joint, force);
}
@ -244,7 +244,7 @@ void PhysicsJoint::setMaxForce(float force)
else
{
_maxForce = force;
for (auto joint : _cpConstraints)
for (auto&& joint : _cpConstraints)
{
cpConstraintSetMaxForce(joint, force);
}

View File

@ -66,7 +66,7 @@ PhysicsShape::PhysicsShape()
PhysicsShape::~PhysicsShape()
{
for (auto shape : _cpShapes)
for (auto&& shape : _cpShapes)
{
cpShapeFree(shape);
}
@ -269,7 +269,7 @@ void PhysicsShape::setBody(PhysicsBody* body)
_body->removeShape(this);
}
for (auto shape : _cpShapes)
for (auto&& shape : _cpShapes)
{
cpShapeSetBody(shape, body == nullptr ? s_sharedBody : body->_cpBody);
}
@ -794,7 +794,7 @@ Vec2 PhysicsShapeEdgePolygon::getCenter()
int count = (int)_cpShapes.size();
cpVect* points = new cpVect[count];
int i = 0;
for (auto shape : _cpShapes)
for (auto&& shape : _cpShapes)
{
points[i++] = cpSegmentShapeGetA(shape);
}
@ -808,7 +808,7 @@ Vec2 PhysicsShapeEdgePolygon::getCenter()
void PhysicsShapeEdgePolygon::getPoints(axis::Vec2* outPoints) const
{
int i = 0;
for (auto shape : _cpShapes)
for (auto&& shape : _cpShapes)
{
outPoints[i++] = PhysicsHelper::cpv2vec2(cpSegmentShapeGetA(shape));
}
@ -841,7 +841,7 @@ void PhysicsShapeEdgePolygon::updateScale()
cpFloat factorX = _newScaleX / _scaleX;
cpFloat factorY = _newScaleY / _scaleY;
for (auto shape : _cpShapes)
for (auto&& shape : _cpShapes)
{
cpVect a = cpSegmentShapeGetA(shape);
a.x *= factorX;
@ -899,7 +899,7 @@ Vec2 PhysicsShapeEdgeChain::getCenter()
int count = (int)_cpShapes.size() + 1;
cpVect* points = new cpVect[count];
int i = 0;
for (auto shape : _cpShapes)
for (auto&& shape : _cpShapes)
{
points[i++] = cpSegmentShapeGetA(shape);
}
@ -915,7 +915,7 @@ Vec2 PhysicsShapeEdgeChain::getCenter()
void PhysicsShapeEdgeChain::getPoints(Vec2* outPoints) const
{
int i = 0;
for (auto shape : _cpShapes)
for (auto&& shape : _cpShapes)
{
outPoints[i++] = PhysicsHelper::cpv2vec2(cpSegmentShapeGetA(shape));
}
@ -933,7 +933,7 @@ void PhysicsShapeEdgeChain::updateScale()
cpFloat factorX = _newScaleX / _scaleX;
cpFloat factorY = _newScaleY / _scaleY;
for (auto shape : _cpShapes)
for (auto&& shape : _cpShapes)
{
cpVect a = cpSegmentShapeGetA(shape);
a.x *= factorX;
@ -951,7 +951,7 @@ void PhysicsShape::setGroup(int group)
{
if (group < 0)
{
for (auto shape : _cpShapes)
for (auto&& shape : _cpShapes)
{
cpShapeSetFilter(shape, cpShapeFilterNew(group, CP_ALL_CATEGORIES, CP_ALL_CATEGORIES));
}
@ -962,7 +962,7 @@ void PhysicsShape::setGroup(int group)
bool PhysicsShape::containsPoint(const Vec2& point) const
{
for (auto shape : _cpShapes)
for (auto&& shape : _cpShapes)
{
if (cpShapePointQuery(shape, PhysicsHelper::vec22cpv(point), nullptr) < 0)
{

View File

@ -571,7 +571,7 @@ void PhysicsWorld::doAddBody(PhysicsBody* body)
}
// add shapes to space
for (auto& shape : body->getShapes())
for (auto&& shape : body->getShapes())
{
addShape(dynamic_cast<PhysicsShape*>(shape));
}
@ -604,14 +604,14 @@ void PhysicsWorld::updateBodies()
// make a copy.
auto addCopy = _delayAddBodies;
_delayAddBodies.clear();
for (auto& body : addCopy)
for (auto&& body : addCopy)
{
doAddBody(body);
}
auto removeCopy = _delayRemoveBodies;
_delayRemoveBodies.clear();
for (auto& body : removeCopy)
for (auto&& body : removeCopy)
{
doRemoveBody(body);
}
@ -619,7 +619,7 @@ void PhysicsWorld::updateBodies()
void PhysicsWorld::removeBody(int tag)
{
for (auto& body : _bodies)
for (auto&& body : _bodies)
{
if (body->getTag() == tag)
{
@ -639,7 +639,7 @@ void PhysicsWorld::removeBody(PhysicsBody* body)
// destroy the body's joints
auto removeCopy = body->_joints;
for (auto joint : removeCopy)
for (auto&& joint : removeCopy)
{
removeJoint(joint, true);
}
@ -716,7 +716,7 @@ void PhysicsWorld::updateJoints()
return;
}
for (auto joint : _delayAddJoints)
for (auto&& joint : _delayAddJoints)
{
joint->_world = this;
if (joint->initJoint())
@ -730,13 +730,13 @@ void PhysicsWorld::updateJoints()
}
_delayAddJoints.clear();
for (auto joint : _delayRemoveJoints)
for (auto&& joint : _delayRemoveJoints)
{
doRemoveJoint(joint);
}
_delayRemoveJoints.clear();
for (auto joint : _joints)
for (auto&& joint : _joints)
{
joint->flushDelayTasks();
}
@ -746,7 +746,7 @@ void PhysicsWorld::removeShape(PhysicsShape* shape)
{
if (shape)
{
for (auto cps : shape->_cpShapes)
for (auto&& cps : shape->_cpShapes)
{
if (cpSpaceContainsShape(_cpSpace, cps))
{
@ -780,7 +780,7 @@ void PhysicsWorld::addJoint(PhysicsJoint* joint)
void PhysicsWorld::removeAllJoints(bool destroy)
{
auto removeCopy = _joints;
for (auto joint : removeCopy)
for (auto&& joint : removeCopy)
{
removeJoint(joint, destroy);
}
@ -790,7 +790,7 @@ void PhysicsWorld::addShape(PhysicsShape* physicsShape)
{
if (physicsShape)
{
for (auto shape : physicsShape->_cpShapes)
for (auto&& shape : physicsShape->_cpShapes)
{
cpSpaceAddShape(_cpSpace, shape);
}
@ -802,7 +802,7 @@ void PhysicsWorld::doRemoveBody(PhysicsBody* body)
AXASSERT(body != nullptr, "the body can not be nullptr");
// remove shapes
for (auto& shape : body->getShapes())
for (auto&& shape : body->getShapes())
{
removeShape(shape);
}
@ -816,7 +816,7 @@ void PhysicsWorld::doRemoveBody(PhysicsBody* body)
void PhysicsWorld::doRemoveJoint(PhysicsJoint* joint)
{
for (auto constraint : joint->_cpConstraints)
for (auto&& constraint : joint->_cpConstraints)
{
cpSpaceRemoveConstraint(_cpSpace, constraint);
}
@ -841,7 +841,7 @@ void PhysicsWorld::doRemoveJoint(PhysicsJoint* joint)
void PhysicsWorld::removeAllBodies()
{
for (auto& child : _bodies)
for (auto&& child : _bodies)
{
removeBodyOrDelay(child);
child->_world = nullptr;
@ -868,7 +868,7 @@ const Vector<PhysicsBody*>& PhysicsWorld::getAllBodies() const
PhysicsBody* PhysicsWorld::getBody(int tag) const
{
for (auto& body : _bodies)
for (auto&& body : _bodies)
{
if (body->getTag() == tag)
{
@ -974,7 +974,7 @@ void PhysicsWorld::update(float delta, bool userCall /* = false*/)
# else
cpHastySpaceStep(_cpSpace, dt);
# endif
for (auto& body : _bodies)
for (auto&& body : _bodies)
{
body->update(dt);
}
@ -1062,7 +1062,7 @@ void PhysicsWorld::beforeSimulation(Node* node,
physicsBody->beforeSimulation(parentToWorldTransform, nodeToWorldTransform, scaleX, scaleY, rotation);
}
for (auto child : node->getChildren())
for (auto&& child : node->getChildren())
beforeSimulation(child, nodeToWorldTransform, scaleX, scaleY, rotation);
}
@ -1077,7 +1077,7 @@ void PhysicsWorld::afterSimulation(Node* node, const Mat4& parentToWorldTransfor
physicsBody->afterSimulation(parentToWorldTransform, parentRotation);
}
for (auto child : node->getChildren())
for (auto&& child : node->getChildren())
afterSimulation(child, nodeToWorldTransform, nodeRotation);
}

View File

@ -41,7 +41,7 @@ Physics3DRigidBody::~Physics3DRigidBody()
{
if (_physicsWorld)
{
for (auto constraint : _constraintList)
for (auto&& constraint : _constraintList)
{
_physicsWorld->removePhysics3DConstraint(constraint);
}
@ -412,7 +412,7 @@ public:
Physics3DObject* getPhysicsObject(const btCollisionObject* btObj)
{
for (auto it : _collider->getPhysicsWorld()->getPhysicsObjects())
for (auto&& it : _collider->getPhysicsWorld()->getPhysicsObjects())
{
if (it->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY)
{

View File

@ -49,7 +49,7 @@ Physics3DShape::~Physics3DShape()
# if (AX_ENABLE_BULLET_INTEGRATION)
AX_SAFE_DELETE(_btShape);
AX_SAFE_DELETE_ARRAY(_heightfieldData);
for (auto iter : _compoundChildShapes)
for (auto&& iter : _compoundChildShapes)
{
AX_SAFE_RELEASE(iter);
}
@ -206,7 +206,7 @@ bool Physics3DShape::initCompoundShape(const std::vector<std::pair<Physics3DShap
{
_shapeType = ShapeType::COMPOUND;
auto compound = new btCompoundShape;
for (auto iter : shapes)
for (auto&& iter : shapes)
{
compound->addChildShape(convertMat4TobtTransform(iter.second), iter.first->getbtShape());
AX_SAFE_RETAIN(iter.first);

View File

@ -56,7 +56,7 @@ Physics3DWorld::~Physics3DWorld()
AX_SAFE_DELETE(_solver);
AX_SAFE_DELETE(_btPhyiscsWorld);
AX_SAFE_DELETE(_debugDrawer);
for (auto it : _physicsComponents)
for (auto&& it : _physicsComponents)
it->setPhysics3DObject(nullptr);
_physicsComponents.clear();
}
@ -166,7 +166,7 @@ void Physics3DWorld::removePhysics3DObject(Physics3DObject* physicsObj)
void Physics3DWorld::removeAllPhysics3DObjects()
{
for (auto it : _objects)
for (auto&& it : _objects)
{
if (it->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY)
{
@ -219,13 +219,13 @@ void Physics3DWorld::removePhysics3DConstraint(Physics3DConstraint* constraint)
void Physics3DWorld::removeAllPhysics3DConstraints()
{
for (auto it : _objects)
for (auto&& it : _objects)
{
auto type = it->getObjType();
if (type == Physics3DObject::PhysicsObjType::RIGID_BODY)
{
auto& constraints = static_cast<Physics3DRigidBody*>(it)->_constraintList;
for (auto constraint : constraints)
for (auto&& constraint : constraints)
{
_btPhyiscsWorld->removeConstraint(constraint->getbtContraint());
constraint->release();
@ -234,7 +234,7 @@ void Physics3DWorld::removeAllPhysics3DConstraints()
}
}
for (auto constraint : _constraints)
for (auto&& constraint : _constraints)
{
removePhysics3DConstraintFromBullet(constraint);
constraint->release();
@ -260,13 +260,13 @@ void Physics3DWorld::stepSimulate(float dt)
{
setGhostPairCallback();
// should sync kinematic node before simulation
for (auto it : _physicsComponents)
for (auto&& it : _physicsComponents)
{
it->preSimulate();
}
_btPhyiscsWorld->stepSimulation(dt, 3);
// sync dynamic node after simulation
for (auto it : _physicsComponents)
for (auto&& it : _physicsComponents)
{
it->postSimulate();
}
@ -328,7 +328,7 @@ bool Physics3DWorld::sweepShape(Physics3DShape* shape,
Physics3DObject* Physics3DWorld::getPhysicsObject(const btCollisionObject* btObj)
{
for (auto it : _objects)
for (auto&& it : _objects)
{
if (it->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY)
{
@ -390,7 +390,7 @@ bool Physics3DWorld::needCollisionChecking()
if (_collisionCheckingFlag)
{
_needCollisionChecking = false;
for (auto it : _objects)
for (auto&& it : _objects)
{
if (it->getCollisionCallback() != nullptr)
{
@ -408,7 +408,7 @@ void Physics3DWorld::setGhostPairCallback()
if (_needGhostPairCallbackChecking)
{
bool needCallback = false;
for (auto it : _objects)
for (auto&& it : _objects)
{
if (it->getObjType() == Physics3DObject::PhysicsObjType::COLLIDER)
{

View File

@ -452,7 +452,7 @@ void GLView::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode,
auto dispatcher = Director::getInstance()->getEventDispatcher();
dispatcher->dispatchEvent(&touchEvent);
for (auto& touch : touchEvent._touches)
for (auto&& touch : touchEvent._touches)
{
// release the touch object.
touch->release();

View File

@ -297,7 +297,7 @@ GLViewImpl::GLViewImpl(bool initglfw)
{
_viewName = "AX_10";
g_keyCodeMap.clear();
for (auto& item : g_keyCodeStructArray)
for (auto&& item : g_keyCodeStructArray)
{
g_keyCodeMap[item.glfwKeyCode] = item.keyCode;
}
@ -634,7 +634,7 @@ void GLViewImpl::setIcon(const std::vector<std::string_view>& filelist) const
glfwSetWindowIcon(window, iconsCount, images);
AX_SAFE_DELETE_ARRAY(images);
for (auto& icon : icons)
for (auto&& icon : icons)
{
AX_SAFE_DELETE(icon);
}

View File

@ -53,7 +53,7 @@ std::string replaceDefines(std::string_view compileTimeDefines)
auto defineParts = Console::Utility::split(compileTimeDefines, ';');
std::stringstream ss;
for (auto& p : defineParts)
for (auto&& p : defineParts)
{
if (p.find("#define ") == std::string::npos)
{

View File

@ -41,7 +41,7 @@ QuadCommand::QuadCommand() : _indexSize(-1), _ownedIndices() {}
QuadCommand::~QuadCommand()
{
for (auto& indices : _ownedIndices)
for (auto&& indices : _ownedIndices)
{
AX_SAFE_DELETE_ARRAY(indices);
}

View File

@ -45,7 +45,7 @@ public:
// AXLOG("All RenderCommand should not be used when Pool is released!");
// }
_freePool.clear();
for (auto& allocatedPoolBlock : _allocatedPoolBlocks)
for (auto&& allocatedPoolBlock : _allocatedPoolBlocks)
{
delete[] allocatedPoolBlock;
allocatedPoolBlock = nullptr;

View File

@ -179,7 +179,7 @@ Renderer::~Renderer()
_renderGroups.clear();
_groupCommandManager->release();
for (auto clearCommand : _callbackCommandsPool)
for (auto&& clearCommand : _callbackCommandsPool)
delete clearCommand;
_callbackCommandsPool.clear();
@ -389,7 +389,7 @@ void Renderer::render()
{
// Process render commands
// 1. Sort render commands based on ID
for (auto& renderqueue : _renderGroups)
for (auto&& renderqueue : _renderGroups)
{
renderqueue.sort();
}
@ -932,10 +932,10 @@ void Renderer::setScissorRect(float x, float y, float width, float height)
// TriangleCommandBufferManager
Renderer::TriangleCommandBufferManager::~TriangleCommandBufferManager()
{
for (auto& vertexBuffer : _vertexBufferPool)
for (auto&& vertexBuffer : _vertexBufferPool)
vertexBuffer->release();
for (auto& indexBuffer : _indexBufferPool)
for (auto&& indexBuffer : _indexBufferPool)
indexBuffer->release();
}

View File

@ -69,7 +69,7 @@ TextureCache::~TextureCache()
{
AXLOGINFO("deallocing TextureCache: %p", this);
for (auto& texture : _textures)
for (auto&& texture : _textures)
texture.second->release();
AX_SAFE_DELETE(_loadingThread);
@ -231,7 +231,7 @@ void TextureCache::unbindImageAsync(std::string_view callbackKey)
return;
}
for (auto& asyncStruct : _asyncStructQueue)
for (auto&& asyncStruct : _asyncStructQueue)
{
if (asyncStruct->callbackKey == callbackKey)
{
@ -246,7 +246,7 @@ void TextureCache::unbindAllImageAsync()
{
return;
}
for (auto& asyncStruct : _asyncStructQueue)
for (auto&& asyncStruct : _asyncStructQueue)
{
asyncStruct->callback = nullptr;
}
@ -551,7 +551,7 @@ bool TextureCache::reloadTexture(std::string_view fileName)
void TextureCache::removeAllTextures()
{
for (auto& texture : _textures)
for (auto&& texture : _textures)
{
texture.second->release();
}
@ -631,7 +631,7 @@ Texture2D* TextureCache::getTextureForKey(std::string_view textureKeyName) const
std::string TextureCache::getTextureFilePath(axis::Texture2D* texture) const
{
for (auto& item : _textures)
for (auto&& item : _textures)
{
if (item.second == texture)
{
@ -661,7 +661,7 @@ std::string TextureCache::getCachedTextureInfo() const
unsigned int count = 0;
unsigned int totalBytes = 0;
for (auto& texture : _textures)
for (auto&& texture : _textures)
{
memset(buftmp, 0, sizeof(buftmp));
@ -816,7 +816,7 @@ void VolatileTextureMgr::addStringTexture(Texture2D* tt, const char* text, const
void VolatileTextureMgr::removeTexture(Texture2D* t)
{
for (auto& item : _textures)
for (auto&& item : _textures)
{
VolatileTexture* vt = item;
if (vt->_texture == t)
@ -833,7 +833,7 @@ void VolatileTextureMgr::reloadAllTextures()
_isReloading = true;
AXLOG("reload all texture");
for (auto& texture : _textures)
for (auto&& texture : _textures)
{
VolatileTexture* vt = texture;

View File

@ -254,7 +254,7 @@ bool TextureCube::init(std::string_view positive_x,
free(pData);
}
for (auto img : images)
for (auto&& img : images)
{
AX_SAFE_RELEASE(img);
}

View File

@ -71,7 +71,7 @@ void ProgramCache::destroyInstance()
ProgramCache::~ProgramCache()
{
for (auto& program : _cachedPrograms)
for (auto&& program : _cachedPrograms)
{
AX_SAFE_RELEASE(program.second);
}
@ -255,7 +255,7 @@ void ProgramCache::removeUnusedProgram()
void ProgramCache::removeAllPrograms()
{
ProgramStateRegistry::getInstance()->clearPrograms();
for (auto& program : _cachedPrograms)
for (auto&& program : _cachedPrograms)
{
program.second->release();
}

View File

@ -124,13 +124,13 @@ TextureInfo::~TextureInfo()
void TextureInfo::retainTextures()
{
for (auto& texture : textures)
for (auto&& texture : textures)
AX_SAFE_RETAIN(texture);
}
void TextureInfo::releaseTextures()
{
for (auto& texture : textures)
for (auto&& texture : textures)
AX_SAFE_RELEASE(texture);
textures.clear();
}

View File

@ -50,7 +50,7 @@ void ShaderCache::destroyInstance()
ShaderCache::~ShaderCache()
{
for (auto& shaderModule : _cachedShaders)
for (auto&& shaderModule : _cachedShaders)
{
AX_SAFE_RELEASE(shaderModule.second);
}

View File

@ -292,7 +292,7 @@ void CommandBufferGL::setUniforms(ProgramGL* program) const
if (_programState)
{
auto& callbacks = _programState->getCallbackUniforms();
for (auto& cb : callbacks)
for (auto&& cb : callbacks)
cb.second(_programState, cb.first);
auto& uniformInfos = _programState->getProgram()->getAllActiveUniformInfo(ShaderStage::VERTEX);
@ -301,7 +301,7 @@ void CommandBufferGL::setUniforms(ProgramGL* program) const
_programState->getVertexUniformBuffer(&buffer, bufferSize);
int i = 0;
for (auto& iter : uniformInfos)
for (auto&& iter : uniformInfos)
{
auto& uniformInfo = iter.second;
if (uniformInfo.size <= 0)

View File

@ -122,7 +122,7 @@ GLuint TextureInfoGL::ensure(int index, GLenum target)
void TextureInfoGL::recreateAll(GLenum target)
{
int idx = 0;
for (auto& texID : textures)
for (auto&& texID : textures)
{
if (texID)
{

View File

@ -324,7 +324,7 @@ void LayoutHelper::setNodeGroupBottom(const std::vector<Node*>& nodes, float bot
void LayoutHelper::moveNodeGroupHorizontally(const std::vector<Node*>& nodes, float delta)
{
for (auto node : nodes)
for (auto&& node : nodes)
{
node->setPositionX(node->getPositionX() + delta);
}
@ -332,7 +332,7 @@ void LayoutHelper::moveNodeGroupHorizontally(const std::vector<Node*>& nodes, fl
void LayoutHelper::moveNodeGroupVertically(const std::vector<Node*>& nodes, float delta)
{
for (auto node : nodes)
for (auto&& node : nodes)
{
node->setPositionY(node->getPositionY() - delta);
}

View File

@ -74,7 +74,7 @@ Widget* Helper::seekWidgetByName(Widget* root, std::string_view name)
return root;
}
const auto& arrayRootChildren = root->getChildren();
for (auto& subWidget : arrayRootChildren)
for (auto&& subWidget : arrayRootChildren)
{
Widget* child = dynamic_cast<Widget*>(subWidget);
if (child)
@ -101,7 +101,7 @@ Widget* Helper::seekActionWidgetByActionTag(Widget* root, int tag)
return root;
}
const auto& arrayRootChildren = root->getChildren();
for (auto& subWidget : arrayRootChildren)
for (auto&& subWidget : arrayRootChildren)
{
Widget* child = dynamic_cast<Widget*>(subWidget);
if (child)
@ -151,7 +151,7 @@ void Helper::doLayout(axis::Node* rootNode)
return;
}
for (auto& node : rootNode->getChildren())
for (auto&& node : rootNode->getChildren())
{
auto com = node->getComponent(__LAYOUT_COMPONENT_NAME);
Node* parent = node->getParent();

View File

@ -116,7 +116,7 @@ void Layout::setGlobalZOrder(float globalZOrder)
if (_clippingStencil)
_clippingStencil->setGlobalZOrder(globalZOrder);
for (auto& child : _children)
for (auto&& child : _children)
child->setGlobalZOrder(globalZOrder);
}
@ -886,7 +886,7 @@ void Layout::setLayoutType(Type type)
{
_layoutType = type;
for (auto& child : _children)
for (auto&& child : _children)
{
Widget* widgetChild = dynamic_cast<Widget*>(child);
if (widgetChild)

View File

@ -649,7 +649,7 @@ void LayoutComponent::refreshLayout()
page->forceDoLayout();
Vector<Widget*> _widgetVector = page->getItems();
for (auto& item : _widgetVector)
for (auto&& item : _widgetVector)
{
ui::Helper::doLayout(item);
}

View File

@ -43,7 +43,7 @@ void LinearHorizontalLayoutManager::doLayout(LayoutProtocol* layout)
Vec2 layoutSize = layout->getLayoutContentSize();
Vector<Node*> container = layout->getLayoutElements();
float leftBoundary = 0.0f;
for (auto& subWidget : container)
for (auto&& subWidget : container)
{
Widget* child = dynamic_cast<Widget*>(subWidget);
if (child)
@ -94,7 +94,7 @@ void LinearVerticalLayoutManager::doLayout(LayoutProtocol* layout)
Vector<Node*> container = layout->getLayoutElements();
float topBoundary = layoutSize.height;
for (auto& subWidget : container)
for (auto&& subWidget : container)
{
LayoutParameterProtocol* child = dynamic_cast<LayoutParameterProtocol*>(subWidget);
if (child)
@ -217,7 +217,7 @@ Vector<Widget*> RelativeLayoutManager::getAllWidgets(axis::ui::LayoutProtocol* l
{
Vector<Node*> container = layout->getLayoutElements();
Vector<Widget*> widgetChildren;
for (auto& subWidget : container)
for (auto&& subWidget : container)
{
Widget* child = dynamic_cast<Widget*>(subWidget);
if (child)
@ -240,7 +240,7 @@ Widget* RelativeLayoutManager::getRelativeWidget(Widget* widget)
if (!relativeName.empty())
{
for (auto& sWidget : _widgetChildren)
for (auto&& sWidget : _widgetChildren)
{
if (sWidget)
{
@ -584,7 +584,7 @@ void RelativeLayoutManager::doLayout(LayoutProtocol* layout)
while (_unlayoutChildCount > 0)
{
for (auto& subWidget : _widgetChildren)
for (auto&& subWidget : _widgetChildren)
{
_widget = static_cast<Widget*>(subWidget);

View File

@ -116,7 +116,7 @@ void ListView::updateInnerContainerSize()
{
size_t length = _items.size();
float totalHeight = (length == 0) ? 0.0f : (length - 1) * _itemsMargin + (_topPadding + _bottomPadding);
for (auto& item : _items)
for (auto&& item : _items)
{
totalHeight += item->getContentSize().height * item->getScaleY();
}
@ -129,7 +129,7 @@ void ListView::updateInnerContainerSize()
{
size_t length = _items.size();
float totalWidth = (length == 0) ? 0.0f : (length - 1) * _itemsMargin + (_leftPadding + _rightPadding);
for (auto& item : _items)
for (auto&& item : _items)
{
totalWidth += item->getContentSize().width * item->getScaleX();
}
@ -914,7 +914,7 @@ Widget* ListView::createCloneInstance()
void ListView::copyClonedWidgetChildren(Widget* model)
{
auto& arrayItems = static_cast<ListView*>(model)->getItems();
for (auto& item : arrayItems)
for (auto&& item : arrayItems)
{
pushBackCustomItem(item->clone());
}

View File

@ -135,7 +135,7 @@ void PageViewIndicator::rearrange()
float totalSizeValue = sizeValue * numberOfItems + _spaceBetweenIndexNodes * (numberOfItems - 1);
float posValue = -(totalSizeValue / 2) + (sizeValue / 2);
for (auto& indexNode : _indexNodes)
for (auto&& indexNode : _indexNodes)
{
Vec2 position;
if (horizontal)
@ -165,7 +165,7 @@ void PageViewIndicator::setIndexNodesColor(const Color3B& indexNodesColor)
{
_indexNodesColor = indexNodesColor;
for (auto& indexNode : _indexNodes)
for (auto&& indexNode : _indexNodes)
{
indexNode->setColor(indexNodesColor);
}
@ -174,7 +174,7 @@ void PageViewIndicator::setIndexNodesColor(const Color3B& indexNodesColor)
void PageViewIndicator::setIndexNodesOpacity(uint8_t opacity)
{
_indexNodesOpacity = opacity;
for (auto& indexNode : _indexNodes)
for (auto&& indexNode : _indexNodes)
indexNode->setOpacity(opacity);
}
@ -187,7 +187,7 @@ void PageViewIndicator::setIndexNodesScale(float indexNodesScale)
_indexNodesScale = indexNodesScale;
_currentIndexNode->setScale(indexNodesScale);
for (auto& indexNode : _indexNodes)
for (auto&& indexNode : _indexNodes)
{
indexNode->setScale(_indexNodesScale);
}
@ -205,14 +205,14 @@ void PageViewIndicator::setIndexNodesTexture(std::string_view texName, Widget::T
{
case Widget::TextureResType::LOCAL:
_currentIndexNode->setTexture(texName);
for (auto& indexNode : _indexNodes)
for (auto&& indexNode : _indexNodes)
{
indexNode->setTexture(texName);
}
break;
case Widget::TextureResType::PLIST:
_currentIndexNode->setSpriteFrame(texName);
for (auto& indexNode : _indexNodes)
for (auto&& indexNode : _indexNodes)
{
indexNode->setSpriteFrame(texName);
}
@ -281,7 +281,7 @@ void PageViewIndicator::clear()
_currentOverlappingIndexNode->setVisible(true);
_currentOverlappingIndexNode = nullptr;
}
for (auto& indexNode : _indexNodes)
for (auto&& indexNode : _indexNodes)
{
removeProtectedChild(indexNode);
}

View File

@ -1949,11 +1949,11 @@ void RichText::formatRenderers()
float nextPosY = 0.0f;
std::vector<std::pair<Vector<Node*>*, float>> rowWidthPairs;
rowWidthPairs.reserve(_elementRenders.size());
for (auto& element : _elementRenders)
for (auto&& element : _elementRenders)
{
float nextPosX = 0.0f;
float maxY = 0.0f;
for (auto& iter : element)
for (auto&& iter : element)
{
iter->setAnchorPoint(Vec2::ZERO);
iter->setPosition(nextPosX, nextPosY);
@ -1967,7 +1967,7 @@ void RichText::formatRenderers()
rowWidthPairs.emplace_back(&element, nextPosX);
}
this->setContentSize(Vec2(newContentSizeWidth, -nextPosY));
for (auto& row : rowWidthPairs)
for (auto&& row : rowWidthPairs)
doHorizontalAlignment(*row.first, row.second);
}
else
@ -1980,7 +1980,7 @@ void RichText::formatRenderers()
{
Vector<Node*>& row = _elementRenders[i];
float maxHeight = 0.0f;
for (auto& iter : row)
for (auto&& iter : row)
{
maxHeight = std::max(iter->getContentSize().height, maxHeight);
}
@ -2004,7 +2004,7 @@ void RichText::formatRenderers()
Vector<Node*>& row = _elementRenders[i];
float nextPosX = 0.0f;
nextPosY -= (i != 0 ? maxHeights[i] + verticalSpace : maxHeights[i]);
for (auto& iter : row)
for (auto&& iter : row)
{
iter->setAnchorPoint(Vec2::ZERO);
iter->setPosition(nextPosX, nextPosY);
@ -2057,7 +2057,7 @@ void RichText::doHorizontalAlignment(const Vector<axis::Node*>& row, float rowWi
const auto leftOver = getContentSize().width - (rowWidth + diff);
const float leftPadding = getPaddingAmount(alignment, leftOver);
const Vec2 offset(leftPadding, 0.f);
for (auto& node : row)
for (auto&& node : row)
{
node->setPosition(node->getPosition() + offset);
}

View File

@ -363,7 +363,7 @@ void ScrollView::updateScrollBar(const Vec2& outOfBoundary)
Vec2 ScrollView::calculateTouchMoveVelocity() const
{
float totalTime = 0;
for (auto& timeDelta : _touchMoveTimeDeltas)
for (auto&& timeDelta : _touchMoveTimeDeltas)
{
totalTime += timeDelta;
}
@ -373,7 +373,7 @@ Vec2 ScrollView::calculateTouchMoveVelocity() const
}
Vec2 totalMovement;
for (auto& displacement : _touchMoveDisplacements)
for (auto&& displacement : _touchMoveDisplacements)
{
totalMovement += displacement;
}

View File

@ -50,7 +50,7 @@ TabControl::TabControl()
TabControl::~TabControl()
{
for (auto& item : _tabItems)
for (auto&& item : _tabItems)
{
if (item)
AX_SAFE_DELETE(item);
@ -179,7 +179,7 @@ void TabControl::setHeaderDockPlace(TabControl::Dock dockPlace)
initContainers();
auto anpoint = getHeaderAnchorWithDock();
for (auto& item : _tabItems)
for (auto&& item : _tabItems)
{
item->header->setAnchorPoint(anpoint);
}
@ -280,7 +280,7 @@ void TabControl::initContainers()
break;
}
for (auto& tabItem : _tabItems)
for (auto&& tabItem : _tabItems)
{
Layout* container = tabItem->container;
container->setPosition(_containerPosition);
@ -440,7 +440,7 @@ void TabControl::ignoreHeadersTextureSize(bool ignore)
return;
_ignoreHeaderTextureSize = ignore;
for (auto& item : _tabItems)
for (auto&& item : _tabItems)
{
item->header->ignoreContentAdaptWithSize(!ignore);
if (ignore)

View File

@ -517,7 +517,7 @@ void Widget::onSizeChanged()
{
if (!_usingLayoutComponent)
{
for (auto& child : getChildren())
for (auto&& child : getChildren())
{
Widget* widgetChild = dynamic_cast<Widget*>(child);
if (widgetChild)
@ -1136,7 +1136,7 @@ void Widget::copyClonedWidgetChildren(Widget* model)
{
auto& modelChildren = model->getChildren();
for (auto& subWidget : modelChildren)
for (auto&& subWidget : modelChildren)
{
Widget* child = dynamic_cast<Widget*>(subWidget);
if (child)
@ -1188,7 +1188,7 @@ void Widget::copyProperties(Widget* widget)
copySpecialProperties(widget);
Map<int, LayoutParameter*>& layoutParameterDic = widget->_layoutParameterDictionary;
for (auto& iter : layoutParameterDic)
for (auto&& iter : layoutParameterDic)
{
setLayoutParameter(iter.second->clone());
}

View File

@ -226,7 +226,7 @@ void Control::setOpacityModifyRGB(bool bOpacityModifyRGB)
{
_isOpacityModifyRGB = bOpacityModifyRGB;
for (auto child : _children)
for (auto&& child : _children)
{
child->setOpacityModifyRGB(bOpacityModifyRGB);
}

View File

@ -117,7 +117,7 @@ void Particle3DQuadRender::render(Renderer* renderer, const Mat4& transform, Par
Vec3 position; // particle position
int vertexindex = 0;
int index = 0;
for (auto iter : activeParticleList)
for (auto&& iter : activeParticleList)
{
auto particle = iter;
Vec3 halfwidth = particle->width * 0.5f * right;
@ -283,7 +283,7 @@ void Particle3DQuadRender::reset()
Particle3DModelRender::Particle3DModelRender() : _meshSize(Vec3::ONE) {}
Particle3DModelRender::~Particle3DModelRender()
{
for (auto iter : _meshList)
for (auto&& iter : _meshList)
{
iter->release();
}
@ -333,7 +333,7 @@ void Particle3DModelRender::render(Renderer* renderer, const Mat4& transform, Pa
Quaternion q;
transform.decompose(nullptr, &q, nullptr);
unsigned int index = 0;
for (auto iter : activeParticleList)
for (auto&& iter : activeParticleList)
{
auto particle = iter;
Mat4::createRotation(q * particle->orientation, &rotMat);
@ -350,7 +350,7 @@ void Particle3DModelRender::render(Renderer* renderer, const Mat4& transform, Pa
void Particle3DModelRender::reset()
{
for (auto iter : _meshList)
for (auto&& iter : _meshList)
{
iter->release();
}

View File

@ -133,7 +133,7 @@ void ParticleSystem3D::removeAffector(int index)
void ParticleSystem3D::removeAllAffector()
{
// release all affectors
for (auto it : _affectors)
for (auto&& it : _affectors)
{
it->release();
}
@ -159,7 +159,7 @@ void ParticleSystem3D::update(float delta)
_emitter->updateEmitter(particle, delta);
}
for (auto& it : _affectors)
for (auto&& it : _affectors)
{
it->updateAffector(particle, delta);
}

View File

@ -142,7 +142,7 @@ public:
void removeAllDatas()
{
lockAllDatas();
for (auto iter : _locked)
for (auto&& iter : _locked)
{
delete iter;
}

View File

@ -64,7 +64,7 @@ void PUBeamRender::render(Renderer* renderer, const Mat4& transform, ParticleSys
return;
Vec3 basePosition = static_cast<PUParticleSystem3D*>(_particleSystem)->getDerivedPosition();
for (auto iter : particlePool.getActiveDataList())
for (auto&& iter : particlePool.getActiveDataList())
{
auto particle = static_cast<PUParticle3D*>(iter);
auto visualData = static_cast<PUParticle3DBeamVisualData*>(particle->visualData);

View File

@ -188,7 +188,7 @@ bool PUBoxCollider::isSmallestValue(float value, const Vec3& particlePosition)
void PUBoxCollider::updatePUAffector(PUParticle3D* particle, float /*deltaTime*/)
{
// for (auto iter : _particleSystem->getParticles())
// for (auto&& iter : _particleSystem->getParticles())
{
// PUParticle3D *particle = iter;
_predictedPosition = particle->position + _velocityScale * particle->direction;

View File

@ -48,7 +48,7 @@ void PUCollisionAvoidanceAffector::setRadius(float radius)
void PUCollisionAvoidanceAffector::updatePUAffector(PUParticle3D* /*particle*/, float /*deltaTime*/)
{
AXASSERT(0, "nonsupport yet");
// for (auto iter : _particleSystem->getParticles())
// for (auto&& iter : _particleSystem->getParticles())
//{
// PUParticle3D *particle = iter;
// // Activate spatial hashing

View File

@ -86,7 +86,7 @@ void PUColorAffector::updatePUAffector(PUParticle3D* particle, float /*deltaTime
if (_colorMap.empty())
return;
// for (auto iter : _particleSystem->getParticles())
// for (auto&& iter : _particleSystem->getParticles())
{
// PUParticle3D *particle = iter;
// Linear interpolation of the colour

View File

@ -46,7 +46,7 @@ void PUDoAffectorEventHandler::handle(PUParticleSystem3D* particleSystem, PUPart
// Search all techniques in this ParticleSystem for an affector with the correct name
PUParticleSystem3D* system = particleSystem->getParentParticleSystem();
auto children = system->getChildren();
for (auto iter : children)
for (auto&& iter : children)
{
technique = dynamic_cast<PUParticleSystem3D*>(iter);
if (technique)

View File

@ -54,7 +54,7 @@ void PUDoEnableComponentEventHandler::handle(PUParticleSystem3D* particleSystem,
if (system)
{
auto children = system->getChildren();
for (auto iter : children)
for (auto&& iter : children)
{
PUParticleSystem3D* child = dynamic_cast<PUParticleSystem3D*>(iter);
if (child)
@ -85,7 +85,7 @@ void PUDoEnableComponentEventHandler::handle(PUParticleSystem3D* particleSystem,
if (system)
{
auto children = system->getChildren();
for (auto iter : children)
for (auto&& iter : children)
{
PUParticleSystem3D* child = dynamic_cast<PUParticleSystem3D*>(iter);
if (child)
@ -116,7 +116,7 @@ void PUDoEnableComponentEventHandler::handle(PUParticleSystem3D* particleSystem,
if (system)
{
auto children = system->getChildren();
for (auto iter : children)
for (auto&& iter : children)
{
PUParticleSystem3D* child = dynamic_cast<PUParticleSystem3D*>(iter);
if (child)
@ -144,7 +144,7 @@ void PUDoEnableComponentEventHandler::handle(PUParticleSystem3D* particleSystem,
if (system)
{
auto children = system->getChildren();
for (auto iter : children)
for (auto&& iter : children)
{
PUParticleSystem3D* child = dynamic_cast<PUParticleSystem3D*>(iter);
if (child && child->getName() == _componentName)

View File

@ -81,7 +81,7 @@ void PUDoPlacementParticleEventHandler::handle(PUParticleSystem3D* particleSyste
if (parentSystem)
{
auto children = parentSystem->getChildren();
for (auto iter : children)
for (auto&& iter : children)
{
PUParticleSystem3D* child = dynamic_cast<PUParticleSystem3D*>(iter);
if (child)

View File

@ -378,7 +378,7 @@ void PUEmitter::prepare()
if (system)
{
auto children = system->getChildren();
for (auto it : children)
for (auto&& it : children)
{
if (it->getName() == _emitsName)
{

View File

@ -35,7 +35,7 @@ PUFlockCenteringAffector::~PUFlockCenteringAffector() {}
void PUFlockCenteringAffector::updatePUAffector(PUParticle3D* particle, float deltaTime)
{
// for (auto iter : _particleSystem->getParticles())
// for (auto&& iter : _particleSystem->getParticles())
{
// PUParticle3D *particle = iter;
_sum += particle->position;

View File

@ -242,7 +242,7 @@ void PUForceFieldAffector::suppressGeneration(bool suppress)
void PUForceFieldAffector::updatePUAffector(PUParticle3D* particle, float deltaTime)
{
// for (auto iter : _particleSystem->getParticles())
// for (auto&& iter : _particleSystem->getParticles())
{
// PUParticle3D *particle = iter;
_forceField.determineForce(particle->position, _force, _delta);

View File

@ -104,7 +104,7 @@ void PUGeometryRotator::initParticleForEmission(PUParticle3D* particle)
//// Only continue if the particle is a visual particle
// if (particle->particleType != Particle::PT_VISUAL)
// return;
// for (auto iter : _particleSystem->getParticlePool().getActiveParticleList())
// for (auto&& iter : _particleSystem->getParticlePool().getActiveParticleList())
{
// PUParticle3D *particle = static_cast<PUParticle3D*>(iter);
if (!_rotationAxisSet)
@ -132,7 +132,7 @@ void PUGeometryRotator::initParticleForEmission(PUParticle3D* particle)
void PUGeometryRotator::updatePUAffector(PUParticle3D* particle, float deltaTime)
{
// for (auto iter : _particleSystem->getParticles())
// for (auto&& iter : _particleSystem->getParticles())
{
// PUParticle3D *particle = iter;
// Rotate the geometry

View File

@ -49,7 +49,7 @@ void PUGravityAffector::setGravity(float gravity)
void PUGravityAffector::updatePUAffector(PUParticle3D* particle, float deltaTime)
{
// for (auto iter : _particleSystem->getParticles())
// for (auto&& iter : _particleSystem->getParticles())
{
// PUParticle3D *particle = iter;
// Applied scaling in V1.3.1

View File

@ -131,7 +131,7 @@ bool PUParticle3DInterParticleCollider::validateAndExecuteSphereCollision(PUPart
void PUParticle3DInterParticleCollider::updatePUAffector(PUParticle3D* /*particle*/, float /*deltaTime*/)
{
// AXASSERT(0, "nonsupport yet");
// for (auto iter : _particleSystem->getParticles())
// for (auto&& iter : _particleSystem->getParticles())
//{
// PUParticle3D *particle = iter;
// Fast rejection: only visible, moving particles are able to collide, unless they are colliding already

View File

@ -58,7 +58,7 @@ void PUJetAffector::setDynAcceleration(PUDynamicAttribute* dynAcceleration)
void PUJetAffector::updatePUAffector(PUParticle3D* particle, float deltaTime)
{
// for (auto iter : _particleSystem->getParticles())
// for (auto&& iter : _particleSystem->getParticles())
{
// PUParticle3D *particle = iter;
_scaled = deltaTime * (_dynAcceleration->getValue(particle->timeFraction));

Some files were not shown because too many files have changed in this diff Show More