From 6a157e1c0811e61f2a0f74ffa0578410ada6edd8 Mon Sep 17 00:00:00 2001 From: gallaert Date: Wed, 22 Apr 2020 10:43:36 +0100 Subject: [PATCH] Replace boost::tuple by std::tuple --- simgear/scene/material/Effect.cxx | 3 +- simgear/scene/material/Effect.hxx | 5 +- simgear/scene/material/TextureBuilder.cxx | 66 +++++++++++------------ simgear/scene/material/mipmap.cxx | 24 ++++----- simgear/scene/material/mipmap.hxx | 4 +- simgear/scene/tgdb/pt_lights.cxx | 3 +- 6 files changed, 50 insertions(+), 55 deletions(-) diff --git a/simgear/scene/material/Effect.cxx b/simgear/scene/material/Effect.cxx index 6432dda2..b7eb0b7a 100644 --- a/simgear/scene/material/Effect.cxx +++ b/simgear/scene/material/Effect.cxx @@ -36,7 +36,6 @@ #include #include -#include #include #include @@ -137,7 +136,7 @@ ref_ptr UniformFactoryImpl::getUniform( Effect * effect, } } - UniformCacheKey key = boost::make_tuple(name, uniformType, val, effect->getName()); + UniformCacheKey key = std::make_tuple(name, uniformType, val, effect->getName()); ref_ptr uniform = uniformCache[key]; if (uniform.valid()) { diff --git a/simgear/scene/material/Effect.hxx b/simgear/scene/material/Effect.hxx index 02a83285..c6afd738 100644 --- a/simgear/scene/material/Effect.hxx +++ b/simgear/scene/material/Effect.hxx @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -191,8 +190,8 @@ private: std::mutex _mutex; - typedef boost::tuple UniformCacheKey; - typedef boost::tuple, SGPropertyChangeListener*> UniformCacheValue; + typedef std::tuple UniformCacheKey; + typedef std::tuple, SGPropertyChangeListener*> UniformCacheValue; std::map > uniformCache; typedef std::queue DeferredListenerList; diff --git a/simgear/scene/material/TextureBuilder.cxx b/simgear/scene/material/TextureBuilder.cxx index 2a1e96b3..25fab866 100644 --- a/simgear/scene/material/TextureBuilder.cxx +++ b/simgear/scene/material/TextureBuilder.cxx @@ -39,8 +39,6 @@ #include #include -#include - #include #include #include @@ -73,9 +71,9 @@ osg::Texture* TextureBuilder::buildFromType(Effect* effect, Pass* pass, const st return EffectBuilder::buildFromType(effect, pass, type, props, options); } -typedef boost::tuple TexTuple; +typedef std::tuple TexTuple; EffectNameValue texEnvModesInit[] = { @@ -263,7 +261,7 @@ TexTuple makeTexTuple(Effect* effect, const SGPropertyNode* props, bool setAttrs(const TexTuple& attrs, Texture* tex, const SGReaderWriterOptions* options) { - const string& imageName = attrs.get<0>(); + const string& imageName = std::get<0>(attrs); if (imageName.empty()) return false; @@ -271,7 +269,7 @@ bool setAttrs(const TexTuple& attrs, Texture* tex, // load texture for effect SGReaderWriterOptions::LoadOriginHint origLOH = options->getLoadOriginHint(); - if(attrs.get<8>() == ImageInternalFormat::Normalized) + if (std::get<8>(attrs) == ImageInternalFormat::Normalized) options->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_EFFECTS_NORMALIZED); else options->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_EFFECTS); @@ -286,7 +284,7 @@ bool setAttrs(const TexTuple& attrs, Texture* tex, image = result.getImage(); if (image.valid()) { - image = computeMipmap( image.get(), attrs.get<7>() ); + image = computeMipmap( image.get(), std::get<7>(attrs) ); tex->setImage(GL_FRONT_AND_BACK, image.get()); int s = image->s(); int t = image->t(); @@ -302,11 +300,11 @@ bool setAttrs(const TexTuple& attrs, Texture* tex, } // texture->setDataVariance(osg::Object::STATIC); - tex->setFilter(Texture::MIN_FILTER, attrs.get<1>()); - tex->setFilter(Texture::MAG_FILTER, attrs.get<2>()); - tex->setWrap(Texture::WRAP_S, attrs.get<3>()); - tex->setWrap(Texture::WRAP_T, attrs.get<4>()); - tex->setWrap(Texture::WRAP_R, attrs.get<5>()); + tex->setFilter(Texture::MIN_FILTER, std::get<1>(attrs)); + tex->setFilter(Texture::MAG_FILTER, std::get<2>(attrs)); + tex->setWrap(Texture::WRAP_S, std::get<3>(attrs)); + tex->setWrap(Texture::WRAP_T, std::get<4>(attrs)); + tex->setWrap(Texture::WRAP_R, std::get<5>(attrs)); return true; } @@ -521,7 +519,7 @@ TextureBuilder::Registrar installLightSprite("light-sprite", new LightSpriteBuil } // Image names for all sides -typedef boost::tuple CubeMapTuple; +typedef std::tuple CubeMapTuple; CubeMapTuple makeCubeMapTuple(Effect* effect, const SGPropertyNode* props) { @@ -610,54 +608,54 @@ Texture* CubeMapBuilder::build(Effect* effect, Pass* pass, const SGPropertyNode* SGReaderWriterOptions::LoadOriginHint origLOH = wOpts->getLoadOriginHint(); wOpts->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_EFFECTS); #if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(_tuple.get<0>(), options); + result = osgDB::readImageFile(std::get<0>(_tuple), options); #else - result = osgDB::readRefImageFile(_tuple.get<0>(), options); + result = osgDB::readRefImageFile(std::get<0>(_tuple), options); #endif if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::POSITIVE_X, image); } #if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(_tuple.get<1>(), options); + result = osgDB::readImageFile(std::get<1>(_tuple), options); #else - result = osgDB::readRefImageFile(_tuple.get<1>(), options); + result = osgDB::readRefImageFile(std::get<1>(_tuple), options); #endif if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::NEGATIVE_X, image); } #if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(_tuple.get<2>(), options); + result = osgDB::readImageFile(std::get<2>(_tuple), options); #else - result = osgDB::readRefImageFile(_tuple.get<2>(), options); + result = osgDB::readRefImageFile(std::get<2>(_tuple), options); #endif if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::POSITIVE_Y, image); } #if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(_tuple.get<3>(), options); + result = osgDB::readImageFile(std::get<3>(_tuple), options); #else - result = osgDB::readRefImageFile(_tuple.get<3>(), options); + result = osgDB::readRefImageFile(std::get<3>(_tuple), options); #endif if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::NEGATIVE_Y, image); } #if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(_tuple.get<4>(), options); + result = osgDB::readImageFile(std::get<4>(_tuple), options); #else - result = osgDB::readRefImageFile(_tuple.get<4>(), options); + result = osgDB::readRefImageFile(std::get<4>(_tuple), options); #endif if(result.success()) { osg::Image* image = result.getImage(); cubeTexture->setImage(TextureCubeMap::POSITIVE_Z, image); } #if OSG_VERSION_LESS_THAN(3,4,1) - result = osgDB::readImageFile(_tuple.get<5>(), options); + result = osgDB::readImageFile(std::get<5>(_tuple), options); #else - result = osgDB::readRefImageFile(_tuple.get<5>(), options); + result = osgDB::readRefImageFile(std::get<5>(_tuple), options); #endif if(result.success()) { osg::Image* image = result.getImage(); @@ -802,7 +800,7 @@ Texture* Texture3DBuilder::build(Effect* effect, Pass* pass, tex = new Texture3D; - const string& imageName = attrs.get<0>(); + const string& imageName = std::get<0>(attrs); if (imageName.empty()) return NULL; @@ -810,7 +808,7 @@ Texture* Texture3DBuilder::build(Effect* effect, Pass* pass, // load texture for effect SGReaderWriterOptions::LoadOriginHint origLOH = options->getLoadOriginHint(); - if(attrs.get<8>() == ImageInternalFormat::Normalized) + if (std::get<8>(attrs) == ImageInternalFormat::Normalized) options->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_EFFECTS_NORMALIZED); else options->setLoadOriginHint(SGReaderWriterOptions::LoadOriginHint::ORIGIN_EFFECTS); @@ -840,18 +838,18 @@ Texture* Texture3DBuilder::build(Effect* effect, Pass* pass, } image3d->setInternalTextureFormat(image->getInternalTextureFormat()); - image3d = computeMipmap(image3d.get(), attrs.get<7>()); + image3d = computeMipmap(image3d.get(), std::get<7>(attrs)); tex->setImage(image3d.get()); } else { SG_LOG(SG_INPUT, SG_ALERT, "failed to load effect texture file " << imageName); return NULL; } - tex->setFilter(Texture::MIN_FILTER, attrs.get<1>()); - tex->setFilter(Texture::MAG_FILTER, attrs.get<2>()); - tex->setWrap(Texture::WRAP_S, attrs.get<3>()); - tex->setWrap(Texture::WRAP_T, attrs.get<4>()); - tex->setWrap(Texture::WRAP_R, attrs.get<5>()); + tex->setFilter(Texture::MIN_FILTER, std::get<1>(attrs)); + tex->setFilter(Texture::MAG_FILTER, std::get<2>(attrs)); + tex->setWrap(Texture::WRAP_S, std::get<3>(attrs)); + tex->setWrap(Texture::WRAP_T, std::get<4>(attrs)); + tex->setWrap(Texture::WRAP_R, std::get<5>(attrs)); if (itr == texMap.end()) texMap.insert(make_pair(attrs, tex)); diff --git a/simgear/scene/material/mipmap.cxx b/simgear/scene/material/mipmap.cxx index ba8ef3c8..62e80629 100644 --- a/simgear/scene/material/mipmap.cxx +++ b/simgear/scene/material/mipmap.cxx @@ -215,13 +215,13 @@ osg::Vec4 computeColor( osg::Vec4 colors[2][2][2], bool colorValid[2][2][2], Mip { osg::Vec4 result; unsigned int nbComponents = osg::Image::computeNumComponents( pixelFormat ); - result[0] = computeComponent( 0, colors, colorValid, attrs.get<0>() ); + result[0] = computeComponent( 0, colors, colorValid, std::get<0>(attrs) ); if ( nbComponents >= 2 ) - result[1] = computeComponent( 1, colors, colorValid, attrs.get<1>() ); + result[1] = computeComponent( 1, colors, colorValid, std::get<1>(attrs) ); if ( nbComponents >= 3 ) - result[2] = computeComponent( 2, colors, colorValid, attrs.get<2>() ); + result[2] = computeComponent( 2, colors, colorValid, std::get<2>(attrs) ); if ( nbComponents == 4 ) - result[3] = computeComponent( 3, colors, colorValid, attrs.get<3>() ); + result[3] = computeComponent( 3, colors, colorValid, std::get<3>(attrs) ); return result; } @@ -265,17 +265,17 @@ osg::Image* computeMipmap( osg::Image* image, MipMapTuple attrs ) { bool computeMipmap = false; unsigned int nbComponents = osg::Image::computeNumComponents( image->getPixelFormat() ); - if ( attrs.get<0>() != AUTOMATIC && - ( attrs.get<1>() != AUTOMATIC || nbComponents < 2 ) && - ( attrs.get<2>() != AUTOMATIC || nbComponents < 3 ) && - ( attrs.get<3>() != AUTOMATIC || nbComponents < 4 ) ) + if ( std::get<0>(attrs) != AUTOMATIC && + ( std::get<1>(attrs) != AUTOMATIC || nbComponents < 2 ) && + ( std::get<2>(attrs) != AUTOMATIC || nbComponents < 3 ) && + ( std::get<3>(attrs) != AUTOMATIC || nbComponents < 4 ) ) { computeMipmap = true; } - else if ( attrs.get<0>() != AUTOMATIC || - ( attrs.get<1>() != AUTOMATIC && nbComponents >= 2 ) || - ( attrs.get<2>() != AUTOMATIC && nbComponents >= 3 ) || - ( attrs.get<3>() != AUTOMATIC && nbComponents == 4 ) ) + else if ( std::get<0>(attrs) != AUTOMATIC || + ( std::get<1>(attrs) != AUTOMATIC && nbComponents >= 2 ) || + ( std::get<2>(attrs) != AUTOMATIC && nbComponents >= 3 ) || + ( std::get<3>(attrs) != AUTOMATIC && nbComponents == 4 ) ) { throw BuilderException("invalid mipmap control function combination"); } diff --git a/simgear/scene/material/mipmap.hxx b/simgear/scene/material/mipmap.hxx index 75b29231..51cd0608 100644 --- a/simgear/scene/material/mipmap.hxx +++ b/simgear/scene/material/mipmap.hxx @@ -17,7 +17,7 @@ #ifndef SIMGEAR_MIPMAP_HXX #define SIMGEAR_MIPMAP_HXX 1 -#include +#include class SGPropertyNode; @@ -44,7 +44,7 @@ namespace effect { Normalized, }; -typedef boost::tuple MipMapTuple; +typedef std::tuple MipMapTuple; MipMapTuple makeMipMapTuple(Effect* effect, const SGPropertyNode* props, const SGReaderWriterOptions* options); diff --git a/simgear/scene/tgdb/pt_lights.cxx b/simgear/scene/tgdb/pt_lights.cxx index cad28567..c1bb3d61 100644 --- a/simgear/scene/tgdb/pt_lights.cxx +++ b/simgear/scene/tgdb/pt_lights.cxx @@ -27,7 +27,6 @@ #include "pt_lights.hxx" #include -#include #include #include @@ -78,7 +77,7 @@ static Mutex lightMutex; namespace { -typedef boost::tuple PointParams; +typedef std::tuple PointParams; typedef std::map > EffectMap; EffectMap effectMap;