From b9e56303c1f7b83383e3f90e645761603820a31e Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Mon, 28 Jul 2014 23:41:01 +0200 Subject: [PATCH] Try to replace emplace_back() call. Only on some part of the code, need confirmation it works before propagating. --- src/graphics/stkmeshscenenode.cpp | 38 ++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index f09781067..fcd291063 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -189,6 +189,18 @@ void STKMeshSceneNode::OnRegisterSceneNode() CMeshSceneNode::OnRegisterSceneNode(); } +template +static void +pushVector(std::vector &vec, Args ...args) +{ + +#if __cplusplus >= 201103 || _MSC_VER >=1800 + vec.emplace_back(args...); +#else + vec.push_back(T(args...)); +#endif +} + void STKMeshSceneNode::render() { irr::video::IVideoDriver* driver = irr_driver->getVideoDriver(); @@ -246,29 +258,29 @@ void STKMeshSceneNode::render() GLMesh* mesh; for_in(mesh, MeshSolidMaterials[MAT_DEFAULT]) - ListMatDefault::Arguments.emplace_back(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()); + pushVector(ListMatDefault::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()); for_in(mesh, MeshSolidMaterials[MAT_ALPHA_REF]) - ListMatAlphaRef::Arguments.emplace_back(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()); + pushVector(ListMatAlphaRef::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()); for_in(mesh, MeshSolidMaterials[MAT_SPHEREMAP]) - ListMatSphereMap::Arguments.emplace_back(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()); + pushVector(ListMatSphereMap::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()); for_in(mesh, MeshSolidMaterials[MAT_DETAIL]) - ListMatDetails::Arguments.emplace_back(mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()); + pushVector(ListMatDetails::Arguments, mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix, irr_driver->getSceneManager()->getAmbientLight()); windDir = getWind(); for_in(mesh, MeshSolidMaterials[MAT_GRASS]) - ListMatGrass::Arguments.emplace_back(mesh, AbsoluteTransformation, invmodel, windDir, irr_driver->getSceneManager()->getAmbientLight()); + pushVector(ListMatGrass::Arguments, mesh, AbsoluteTransformation, invmodel, windDir, irr_driver->getSceneManager()->getAmbientLight()); for_in(mesh, MeshSolidMaterials[MAT_UNLIT]) - ListMatUnlit::Arguments.emplace_back(mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY); + pushVector(ListMatUnlit::Arguments, mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY); for_in(mesh, MeshSolidMaterials[MAT_SPLATTING]) - ListMatSplatting::Arguments.emplace_back(mesh, AbsoluteTransformation, invmodel, irr_driver->getSceneManager()->getAmbientLight()); + pushVector(ListMatSplatting::Arguments, mesh, AbsoluteTransformation, invmodel, irr_driver->getSceneManager()->getAmbientLight()); for_in(mesh, MeshSolidMaterials[MAT_NORMAL_MAP]) - ListMatNormalMap::Arguments.emplace_back(mesh, AbsoluteTransformation, invmodel, core::matrix4::EM4CONST_IDENTITY, irr_driver->getSceneManager()->getAmbientLight()); + pushVector( ListMatNormalMap::Arguments, mesh, AbsoluteTransformation, invmodel, core::matrix4::EM4CONST_IDENTITY, irr_driver->getSceneManager()->getAmbientLight()); return; } @@ -408,23 +420,23 @@ void STKMeshSceneNode::render() tmpcol.getBlue() / 255.0f); for_in(mesh, TransparentMesh[TM_DEFAULT]) - ListBlendTransparentFog::Arguments.emplace_back(mesh, AbsoluteTransformation, mesh->TextureMatrix, + pushVector(ListBlendTransparentFog::Arguments, mesh, AbsoluteTransformation, mesh->TextureMatrix, fogmax, startH, endH, start, end, col); for_in(mesh, TransparentMesh[TM_ADDITIVE]) - ListAdditiveTransparentFog::Arguments.emplace_back(mesh, AbsoluteTransformation, mesh->TextureMatrix, + pushVector(ListAdditiveTransparentFog::Arguments, mesh, AbsoluteTransformation, mesh->TextureMatrix, fogmax, startH, endH, start, end, col); } else { for_in(mesh, TransparentMesh[TM_DEFAULT]) - ListBlendTransparent::Arguments.emplace_back(mesh, AbsoluteTransformation, mesh->TextureMatrix); + pushVector(ListBlendTransparent::Arguments, mesh, AbsoluteTransformation, mesh->TextureMatrix); for_in(mesh, TransparentMesh[TM_ADDITIVE]) - ListAdditiveTransparent::Arguments.emplace_back(mesh, AbsoluteTransformation, mesh->TextureMatrix); + pushVector(ListAdditiveTransparent::Arguments, mesh, AbsoluteTransformation, mesh->TextureMatrix); } for_in(mesh, TransparentMesh[TM_DISPLACEMENT]) - ListDisplacement::Arguments.emplace_back(mesh, AbsoluteTransformation); + pushVector(ListDisplacement::Arguments, mesh, AbsoluteTransformation); if (!TransparentMesh[TM_BUBBLE].empty()) glUseProgram(MeshShader::BubbleShader::Program);