From fdfe327f9a35f19540bb47671fcf8358ac877cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 21 Jun 2026 20:29:36 +0200 Subject: [PATCH] Put single-statement branch contents on the following line. --- doc/generated/atlas.cpp | 3 +- doc/generated/easings.cpp | 3 +- doc/snippets/Animation.cpp | 3 +- doc/snippets/DebugTools.cpp | 3 +- doc/snippets/Magnum.cpp | 6 +- doc/snippets/Math.cpp | 3 +- doc/snippets/SceneTools.cpp | 3 +- doc/snippets/ShaderTools.cpp | 6 +- doc/snippets/Text.cpp | 6 +- doc/snippets/Trade.cpp | 9 +- doc/snippets/Vk.cpp | 3 +- doc/snippets/plugins.cpp | 3 +- src/Magnum/AbstractResourceLoader.h | 9 +- src/Magnum/Animation/Easing.h | 44 ++-- src/Magnum/Animation/Interpolation.h | 21 +- src/Magnum/Animation/Player.h | 6 +- src/Magnum/Animation/Player.hpp | 27 +- src/Magnum/Animation/Test/PlayerTest.cpp | 3 +- src/Magnum/Array.h | 6 +- src/Magnum/Audio/Buffer.h | 5 +- src/Magnum/Audio/Context.cpp | 18 +- src/Magnum/Audio/Listener.cpp | 6 +- src/Magnum/Audio/Source.cpp | 3 +- src/Magnum/Audio/Source.h | 5 +- .../GlobalStateAcrossLibrariesLibrary.cpp | 3 +- src/Magnum/Audio/al-info.cpp | 3 +- src/Magnum/DebugTools/BufferData.h | 3 +- src/Magnum/DebugTools/CompareImage.cpp | 18 +- src/Magnum/DebugTools/CompareMaterial.cpp | 6 +- src/Magnum/DebugTools/ForceRenderer.cpp | 6 +- src/Magnum/DebugTools/FrameProfiler.cpp | 39 ++- src/Magnum/DebugTools/ObjectRenderer.cpp | 6 +- src/Magnum/DebugTools/Profiler.cpp | 15 +- .../DebugTools/Test/FrameProfilerGLTest.cpp | 3 +- src/Magnum/GL/AbstractShaderProgram.cpp | 21 +- src/Magnum/GL/AbstractTexture.cpp | 18 +- src/Magnum/GL/Attribute.cpp | 6 +- src/Magnum/GL/Buffer.cpp | 12 +- src/Magnum/GL/Context.cpp | 18 +- src/Magnum/GL/DebugOutput.h | 5 +- src/Magnum/GL/DefaultFramebuffer.cpp | 4 +- src/Magnum/GL/Framebuffer.cpp | 7 +- src/Magnum/GL/Implementation/BufferState.cpp | 3 +- src/Magnum/GL/Implementation/MeshState.cpp | 6 +- src/Magnum/GL/Implementation/State.cpp | 3 +- src/Magnum/GL/Mesh.cpp | 21 +- src/Magnum/GL/MeshView.cpp | 3 +- src/Magnum/GL/PrimitiveQuery.cpp | 3 +- src/Magnum/GL/Renderbuffer.cpp | 3 +- src/Magnum/GL/Shader.cpp | 12 +- src/Magnum/GL/Test/CubeMapTextureGLTest.cpp | 18 +- src/Magnum/GL/Test/MeshGLTest.cpp | 3 +- src/Magnum/GL/TransformFeedback.cpp | 3 +- src/Magnum/Image.cpp | 3 +- src/Magnum/ImageView.cpp | 6 +- src/Magnum/ImageView.h | 3 +- src/Magnum/MaterialTools/Filter.cpp | 6 +- .../PhongToPbrMetallicRoughness.cpp | 6 +- src/Magnum/Math/Algorithms/KahanSum.h | 3 +- src/Magnum/Math/Algorithms/Svd.h | 6 +- src/Magnum/Math/Bezier.h | 3 +- src/Magnum/Math/BitVector.h | 9 +- src/Magnum/Math/Color.h | 3 +- src/Magnum/Math/Complex.h | 3 +- src/Magnum/Math/ConfigurationValue.h | 9 +- src/Magnum/Math/Frustum.h | 9 +- src/Magnum/Math/Functions.cpp | 6 +- src/Magnum/Math/Functions.h | 21 +- src/Magnum/Math/FunctionsBatch.h | 31 ++- src/Magnum/Math/Intersection.h | 6 +- src/Magnum/Math/Matrix.h | 3 +- src/Magnum/Math/Quaternion.h | 6 +- src/Magnum/Math/Range.h | 9 +- src/Magnum/Math/RectangularMatrix.h | 9 +- .../Math/Test/IntersectionBenchmark.cpp | 3 +- src/Magnum/Math/TypeTraits.h | 6 +- src/Magnum/Math/Vector.h | 10 +- src/Magnum/Mesh.cpp | 6 +- src/Magnum/MeshTools/BoundingVolume.cpp | 3 +- src/Magnum/MeshTools/Compile.cpp | 9 +- src/Magnum/MeshTools/Concatenate.cpp | 9 +- src/Magnum/MeshTools/Duplicate.cpp | 3 +- src/Magnum/MeshTools/GenerateNormals.cpp | 15 +- src/Magnum/MeshTools/Interleave.cpp | 15 +- src/Magnum/MeshTools/RemoveDuplicates.cpp | 12 +- src/Magnum/MeshTools/Test/CompileGLTest.cpp | 3 +- src/Magnum/MeshTools/Test/InterleaveTest.cpp | 6 +- src/Magnum/MeshTools/Tipsify.cpp | 12 +- src/Magnum/MeshTools/Transform.h | 24 +- src/Magnum/PixelFormat.cpp | 6 +- src/Magnum/Platform/AbstractXApplication.cpp | 15 +- src/Magnum/Platform/AndroidApplication.cpp | 3 +- src/Magnum/Platform/EmscriptenApplication.cpp | 27 +- src/Magnum/Platform/GlfwApplication.cpp | 45 ++-- src/Magnum/Platform/ScreenedApplication.hpp | 48 ++-- src/Magnum/Platform/Sdl2Application.cpp | 54 ++-- .../Test/EmscriptenApplicationTest.cpp | 3 +- .../Platform/Test/GlfwApplicationTest.cpp | 3 +- .../Platform/Test/Sdl2ApplicationTest.cpp | 6 +- .../Platform/WindowlessCglApplication.cpp | 9 +- .../Platform/WindowlessEglApplication.cpp | 9 +- .../Platform/WindowlessGlxApplication.cpp | 12 +- .../Platform/WindowlessWglApplication.cpp | 12 +- src/Magnum/Platform/gl-info.cpp | 6 +- src/Magnum/Primitives/Cone.cpp | 3 +- src/Magnum/Primitives/Cylinder.cpp | 6 +- src/Magnum/Primitives/Grid.cpp | 6 +- src/Magnum/Primitives/Plane.cpp | 3 +- src/Magnum/Resource.h | 18 +- src/Magnum/ResourceManager.h | 9 +- .../SceneGraph/AbstractGroupedFeature.h | 6 +- src/Magnum/SceneGraph/AbstractObject.h | 3 +- src/Magnum/SceneGraph/Animable.hpp | 6 +- src/Magnum/SceneGraph/FeatureGroup.h | 3 +- src/Magnum/SceneGraph/Object.hpp | 54 ++-- src/Magnum/SceneGraph/Test/ObjectTest.cpp | 6 +- .../SceneTools/FlattenMeshHierarchy.cpp | 6 +- .../SceneTools/Implementation/combine.h | 12 +- .../convertToSingleFunctionObjects.h | 22 +- .../Implementation/sceneConverterUtilities.h | 66 +++-- .../Test/SceneConverterImplementationTest.cpp | 56 ++-- src/Magnum/SceneTools/sceneconverter.cpp | 33 ++- src/Magnum/ShaderTools/AbstractConverter.cpp | 24 +- src/Magnum/ShaderTools/Implementation/spirv.h | 6 +- .../Test/AbstractConverterTest.cpp | 12 +- src/Magnum/ShaderTools/shaderconverter.cpp | 39 ++- src/Magnum/Shaders/DistanceFieldVectorGL.cpp | 3 +- src/Magnum/Shaders/FlatGL.cpp | 21 +- src/Magnum/Shaders/LineGL.cpp | 3 +- src/Magnum/Shaders/MeshVisualizerGL.cpp | 39 ++- src/Magnum/Shaders/MeshVisualizerGL.h | 6 +- src/Magnum/Shaders/PhongGL.cpp | 78 ++++-- .../Test/DistanceFieldVectorGLTest.cpp | 6 +- src/Magnum/Shaders/Test/FlatGLTest.cpp | 6 +- src/Magnum/Shaders/Test/LineGLTest.cpp | 60 +++-- src/Magnum/Shaders/Test/VectorGLTest.cpp | 6 +- src/Magnum/Shaders/VectorGL.cpp | 3 +- src/Magnum/Shaders/VertexColorGL.cpp | 6 +- src/Magnum/Shaders/glShaderWrapper.cpp | 3 +- src/Magnum/Test/PixelFormatTest.cpp | 3 +- src/Magnum/Test/ResourceManagerTest.cpp | 3 +- src/Magnum/Test/VertexFormatTest.cpp | 6 +- src/Magnum/Text/AbstractFontConverter.cpp | 3 +- src/Magnum/Text/AbstractGlyphCache.cpp | 3 +- src/Magnum/Text/Implementation/printFourCC.h | 3 +- src/Magnum/Text/Test/AbstractFontTest.cpp | 3 +- src/Magnum/Text/Test/RendererTest.cpp | 3 +- src/Magnum/Text/fontconverter.cpp | 6 +- src/Magnum/TextureTools/Atlas.cpp | 3 +- .../TextureTools/Test/AtlasBenchmark.cpp | 3 +- .../TextureTools/distancefieldconverter.cpp | 6 +- src/Magnum/Timeline.cpp | 9 +- src/Magnum/Trade/AbstractImageConverter.cpp | 42 ++- src/Magnum/Trade/AbstractImporter.cpp | 12 +- src/Magnum/Trade/AbstractSceneConverter.cpp | 39 ++- src/Magnum/Trade/AnimationData.cpp | 3 +- src/Magnum/Trade/ImageData.cpp | 3 +- .../Trade/Implementation/arrayUtilities.h | 3 +- .../Trade/Implementation/converterUtilities.h | 33 ++- src/Magnum/Trade/MaterialData.cpp | 21 +- src/Magnum/Trade/MaterialData.h | 12 +- src/Magnum/Trade/MeshData.cpp | 18 +- src/Magnum/Trade/MeshData.h | 48 ++-- src/Magnum/Trade/PhongMaterialData.cpp | 3 +- src/Magnum/Trade/SceneData.cpp | 132 ++++++---- src/Magnum/Trade/SceneData.h | 60 +++-- .../Trade/Test/AbstractImporterTest.cpp | 240 ++++++++++++------ .../Trade/Test/AbstractSceneConverterTest.cpp | 96 ++++--- src/Magnum/Trade/imageconverter.cpp | 48 ++-- src/Magnum/VertexFormat.cpp | 3 +- src/Magnum/Vk/Buffer.cpp | 3 +- src/Magnum/Vk/DescriptorPool.cpp | 6 +- src/Magnum/Vk/DescriptorSetLayout.cpp | 9 +- src/Magnum/Vk/Device.cpp | 33 ++- src/Magnum/Vk/DeviceProperties.cpp | 46 ++-- src/Magnum/Vk/ExtensionProperties.cpp | 3 +- src/Magnum/Vk/Image.cpp | 6 +- .../Vk/Implementation/DriverWorkaround.cpp | 6 +- src/Magnum/Vk/Implementation/spirvPatching.h | 9 +- .../Vk/Implementation/structureHelpers.h | 3 +- src/Magnum/Vk/Instance.cpp | 45 ++-- src/Magnum/Vk/LayerProperties.cpp | 3 +- src/Magnum/Vk/Memory.h | 3 +- src/Magnum/Vk/Mesh.cpp | 12 +- src/Magnum/Vk/MeshLayout.cpp | 12 +- src/Magnum/Vk/Queue.cpp | 3 +- src/Magnum/Vk/RenderPass.cpp | 24 +- src/Magnum/Vk/Shader.cpp | 3 +- src/Magnum/Vk/ShaderSet.cpp | 12 +- src/Magnum/Vk/Test/DevicePropertiesVkTest.cpp | 6 +- src/Magnum/Vk/Test/DeviceVkTest.cpp | 6 +- .../Vk/Test/ExtensionPropertiesVkTest.cpp | 3 +- src/Magnum/Vk/Test/LayerPropertiesVkTest.cpp | 3 +- src/Magnum/Vk/Version.cpp | 3 +- src/Magnum/Vk/vk-info.cpp | 12 +- .../AnyAudioImporter/AnyImporter.cpp | 3 +- .../AnyImageImporter/AnyImageImporter.cpp | 33 ++- .../AnySceneConverter/AnySceneConverter.cpp | 3 +- .../AnySceneImporter/AnySceneImporter.cpp | 6 +- .../AnyShaderConverter/AnyConverter.cpp | 12 +- src/MagnumPlugins/MagnumFont/MagnumFont.cpp | 3 +- .../TgaImageConverter/TgaImageConverter.cpp | 6 +- 202 files changed, 1911 insertions(+), 967 deletions(-) diff --git a/doc/generated/atlas.cpp b/doc/generated/atlas.cpp index 0e8feccf1..95f29734c 100644 --- a/doc/generated/atlas.cpp +++ b/doc/generated/atlas.cpp @@ -88,7 +88,8 @@ int main() { data[i].size = Vector2i{1 << currentSize}; - if(i) size.x() += padding; + if(i) + size.x() += padding; size.x() += data[i].size.x(); size.y() = Math::max(size.y(), data[i].size.y()); } diff --git a/doc/generated/easings.cpp b/doc/generated/easings.cpp index 8d8f8814c..2d0f55642 100644 --- a/doc/generated/easings.cpp +++ b/doc/generated/easings.cpp @@ -160,7 +160,8 @@ void generate(Containers::StringView file, Float(*function)(Float), std::initial )"); }; - for(auto fn: related) print(0x747474_srgbf, 1.0f, fn); + for(auto fn: related) + print(0x747474_srgbf, 1.0f, fn); /* Bezier representation, if any */ if(!bezier[3].isZero()) { diff --git a/doc/snippets/Animation.cpp b/doc/snippets/Animation.cpp index 53380230a..a9c816b7c 100644 --- a/doc/snippets/Animation.cpp +++ b/doc/snippets/Animation.cpp @@ -275,7 +275,8 @@ player.addRawCallback(track, std::size_t& hint, void* destination, void(*callback)(), void* userData) { Int value = static_cast&>(track) .atStrict(key, hint); - if(value == *static_cast(destination)) return; + if(value == *static_cast(destination)) + return; *static_cast(destination) = value; reinterpret_cast&, Int)>(callback) (*static_cast*>(userData), value); diff --git a/doc/snippets/DebugTools.cpp b/doc/snippets/DebugTools.cpp index 0f608c195..eed82640d 100644 --- a/doc/snippets/DebugTools.cpp +++ b/doc/snippets/DebugTools.cpp @@ -136,7 +136,8 @@ void MyApp::drawEventAgain() { _profiler.printStatistics(10); swapBuffers(); - if(_profiler.isEnabled()) redraw(); + if(_profiler.isEnabled()) + redraw(); } /* [FrameProfiler-usage-console] */ diff --git a/doc/snippets/Magnum.cpp b/doc/snippets/Magnum.cpp index bdd367f47..251c38a50 100644 --- a/doc/snippets/Magnum.cpp +++ b/doc/snippets/Magnum.cpp @@ -123,9 +123,9 @@ std::nullptr_t data = nullptr; Image2D image{PixelFormat::RGB8Unorm, {128, 128}, data}; Containers::StridedArrayView2D pixels = image.pixels(); -for(auto row: pixels.sliceSize({48, 48}, {32, 32})) { - for(Color3ub& pixel: row) pixel *= 1.1f; -} +for(auto row: pixels.sliceSize({48, 48}, {32, 32})) + for(Color3ub& pixel: row) + pixel *= 1.1f; /* [Image-pixels] */ } diff --git a/doc/snippets/Math.cpp b/doc/snippets/Math.cpp index 25334d6f5..18a821b96 100644 --- a/doc/snippets/Math.cpp +++ b/doc/snippets/Math.cpp @@ -1106,7 +1106,8 @@ Math::Dual integral{floatingPoint}; // {1, 2} Frustum frustum; /* [Frustum-range] */ for(Vector4 plane: frustum) - if(Math::Distance::pointPlaneScaled(point, plane) < 0.0f) return false; + if(Math::Distance::pointPlaneScaled(point, plane) < 0.0f) + return false; return true; /* [Frustum-range] */ }({}); diff --git a/doc/snippets/SceneTools.cpp b/doc/snippets/SceneTools.cpp index 0cba2d894..8c308aa6b 100644 --- a/doc/snippets/SceneTools.cpp +++ b/doc/snippets/SceneTools.cpp @@ -118,7 +118,8 @@ Containers::BitArray objectsToKeep{ValueInit, std::size_t(scene.mappingBound())} /* Look for the object in the list */ for(const Containers::Pair& i: childrenRanges) { - if(i.first() != objectToLookFor) continue; + if(i.first() != objectToLookFor) + continue; /* Right after the object appearing in the list is all its (nested) children, mark them in the bit array */ diff --git a/doc/snippets/ShaderTools.cpp b/doc/snippets/ShaderTools.cpp index 7dbd012d4..819bfcd96 100644 --- a/doc/snippets/ShaderTools.cpp +++ b/doc/snippets/ShaderTools.cpp @@ -146,7 +146,8 @@ converter->setInputFileCallback([](const std::string& filename, /* Discard the loaded file, if not needed anymore */ if(policy == InputFileCallbackPolicy::Close) { - if(found != data.files.end()) data.files.erase(found); + if(found != data.files.end()) + data.files.erase(found); return {}; } @@ -156,7 +157,8 @@ converter->setInputFileCallback([](const std::string& filename, if(found == data.files.end()) found = data.files.emplace( filename, extract("shaders.zip", filename)).first; - if(!found->second) return {}; + if(!found->second) + return {}; return Containers::ArrayView{*found->second}; }, data); diff --git a/doc/snippets/Text.cpp b/doc/snippets/Text.cpp index b0c4f06d6..73cef9052 100644 --- a/doc/snippets/Text.cpp +++ b/doc/snippets/Text.cpp @@ -169,7 +169,8 @@ font->setFileCallback([](const std::string& filename, /* Discard the memory mapping, if not needed anymore */ if(policy == InputFileCallbackPolicy::Close) { - if(found != data.files.end()) data.files.erase(found); + if(found != data.files.end()) + data.files.erase(found); return {}; } @@ -178,7 +179,8 @@ font->setFileCallback([](const std::string& filename, if(found == data.files.end()) found = data.files.emplace( filename, Utility::Path::mapRead(filename)).first; - if(!found->second) return {}; + if(!found->second) + return {}; return Containers::arrayView(*found->second); }, data); diff --git a/doc/snippets/Trade.cpp b/doc/snippets/Trade.cpp index a2be8071d..c596545e1 100644 --- a/doc/snippets/Trade.cpp +++ b/doc/snippets/Trade.cpp @@ -187,7 +187,8 @@ if(!importer || !importer->openFile("image.png")) Fatal{} << "Can't open image.png with AnyImageImporter"; Containers::Optional image = importer->image2D(0); -if(!image) Fatal{} << "Importing the image failed"; +if(!image) + Fatal{} << "Importing the image failed"; // use the image ... /* [AbstractImporter-usage] */ @@ -230,7 +231,8 @@ importer->setFileCallback([](const std::string& filename, /* Discard the memory mapping, if not needed anymore */ if(policy == InputFileCallbackPolicy::Close) { - if(found != data.files.end()) data.files.erase(found); + if(found != data.files.end()) + data.files.erase(found); return {}; } @@ -239,7 +241,8 @@ importer->setFileCallback([](const std::string& filename, if(found == data.files.end()) found = data.files.emplace( filename, Utility::Path::mapRead(filename)).first; - if(!found->second) return {}; + if(!found->second) + return {}; return Containers::arrayView(*found->second); }, data); diff --git a/doc/snippets/Vk.cpp b/doc/snippets/Vk.cpp index e386622d2..4c19681b6 100644 --- a/doc/snippets/Vk.cpp +++ b/doc/snippets/Vk.cpp @@ -354,7 +354,8 @@ Vk::DescriptorPool pool{NoCreate}, overflowPool{NoCreate}; Containers::Optional set = pool.tryAllocate(layout); /* Oops, the pool is full (or fragmented). Hope the plan B doesn't fail too. */ -if(!set) set = overflowPool.allocate(layout); +if(!set) + set = overflowPool.allocate(layout); /* [DescriptorSet-allocation-try] */ } diff --git a/doc/snippets/plugins.cpp b/doc/snippets/plugins.cpp index 24f179265..482727538 100644 --- a/doc/snippets/plugins.cpp +++ b/doc/snippets/plugins.cpp @@ -56,7 +56,8 @@ void mainPlugins() { PluginManager::Manager manager; Containers::Pointer importer = manager.loadAndInstantiate("TgaImporter"); - if(!importer) Fatal{} << "Cannot load the TgaImporter plugin"; + if(!importer) + Fatal{} << "Cannot load the TgaImporter plugin"; // Use the plugin... diff --git a/src/Magnum/AbstractResourceLoader.h b/src/Magnum/AbstractResourceLoader.h index 4d5e9d532..4204f871a 100644 --- a/src/Magnum/AbstractResourceLoader.h +++ b/src/Magnum/AbstractResourceLoader.h @@ -264,7 +264,8 @@ template class CORRADE_DEPRECATED("the ResourceManager class is obsolet CORRADE_IGNORE_DEPRECATED_PUSH template AbstractResourceLoader::~AbstractResourceLoader() { - if(manager) manager->_loader = nullptr; + if(manager) + manager->_loader = nullptr; } template std::string AbstractResourceLoader::doName(ResourceKey) const { return {}; } @@ -277,8 +278,10 @@ template void AbstractResourceLoader::load(ResourceKey key) { } template void AbstractResourceLoader::set(ResourceKey key, T* data, ResourceDataState state, ResourcePolicy policy) { - if(data) ++_loadedCount; - if(!data && state == ResourceDataState::NotFound) ++_notFoundCount; + if(data) + ++_loadedCount; + if(!data && state == ResourceDataState::NotFound) + ++_notFoundCount; manager->set(key, data, state, policy); } CORRADE_IGNORE_DEPRECATED_POP diff --git a/src/Magnum/Animation/Easing.h b/src/Magnum/Animation/Easing.h index 86a15ce0b..f9cd9ddad 100644 --- a/src/Magnum/Animation/Easing.h +++ b/src/Magnum/Animation/Easing.h @@ -366,8 +366,10 @@ template struct BasicEasing { static T smoothstep(T t) { /* Deliberately *not* using Math::clamp() because that would drag in unneeded vector headers */ - if(t <= T(0.0)) return T(0.0); - if(t >= T(1.0)) return T(1.0); + if(t <= T(0.0)) + return T(0.0); + if(t >= T(1.0)) + return T(1.0); return (T(3.0) - T(2.0)*t)*t*t; } @@ -391,8 +393,10 @@ template struct BasicEasing { static T smootherstep(T t) { /* Deliberately *not* using Math::clamp() because that would drag in unneeded vector headers */ - if(t <= T(0.0)) return T(0.0); - if(t >= T(1.0)) return T(1.0); + if(t <= T(0.0)) + return T(0.0); + if(t >= T(1.0)) + return T(1.0); return t*t*t*(t*(t*T(6.0) - T(15.0)) + T(10.0)); } @@ -451,8 +455,8 @@ template struct BasicEasing { * @see @ref cubicInOut(), @ref quarticInOut(), @ref quinticInOut() */ static T quadraticInOut(T t) { - if(t < T(0.5)) return T(2.0)*t*t; - + if(t < T(0.5)) + return T(2.0)*t*t; const T inv = T(1.0) - t; return T(1.0) - T(2.0)*inv*inv; } @@ -515,8 +519,8 @@ template struct BasicEasing { * @see @ref quadraticInOut(), @ref quarticInOut(), @ref quinticInOut() */ static T cubicInOut(T t) { - if(t < T(0.5)) return T(4.0)*t*t*t; - + if(t < T(0.5)) + return T(4.0)*t*t*t; const T inv = T(1.0) - t; return T(1.0) - T(4.0)*inv*inv*inv; } @@ -748,7 +752,8 @@ template struct BasicEasing { * @see @ref sineInOut() */ static T circularInOut(T t) { - if(t < T(0.5)) return T(0.5)*(T(1.0) - std::sqrt(T(1.0) - T(4.0)*t*t)); + if(t < T(0.5)) + return T(0.5)*(T(1.0) - std::sqrt(T(1.0) - T(4.0)*t*t)); return T(0.5)*(T(1.0) + std::sqrt(T(-4.0)*t*t + T(8.0)*t - T(3.0))); } @@ -818,9 +823,12 @@ template struct BasicEasing { * @f] */ static T exponentialInOut(T t) { - if(t <= T(0.0)) return T(0.0); - if(t < T(0.5)) return T(0.5)*std::pow(T(2.0), T(20.0)*t - T(10.0)); - if(t < T(1.0)) return T(1.0) - T(0.5)*std::pow(T(2.0), T(10.0) -T(20.0)*t); + if(t <= T(0.0)) + return T(0.0); + if(t < T(0.5)) + return T(0.5)*std::pow(T(2.0), T(20.0)*t - T(10.0)); + if(t < T(1.0)) + return T(1.0) - T(0.5)*std::pow(T(2.0), T(10.0) -T(20.0)*t); return T(1.0); } @@ -943,9 +951,12 @@ template struct BasicEasing { * @htmlinclude easings-bounceout.svg */ static T bounceOut(T t) { - if(t < T(4.0)/T(11.0)) return (T(121.0)*t*t)/T(16.0); - if(t < T(8.0)/T(11.0)) return T(363.0)/T(40.0)*t*t - T(99.0)/T(10.0)*t + T(17.0)/T(5.0); - if(t < T(9.0)/T(10.0)) return T(4356.0)/T(361.0)*t*t - T(35442.0)/T(1805.0)*t + T(16061.0)/T(1805.0); + if(t < T(4.0)/T(11.0)) + return (T(121.0)*t*t)/T(16.0); + if(t < T(8.0)/T(11.0)) + return T(363.0)/T(40.0)*t*t - T(99.0)/T(10.0)*t + T(17.0)/T(5.0); + if(t < T(9.0)/T(10.0)) + return T(4356.0)/T(361.0)*t*t - T(35442.0)/T(1805.0)*t + T(16061.0)/T(1805.0); return T(54.0)/T(5.0)*t*t - T(513.0)/T(25.0)*t + T(268.0)/T(25.0); } @@ -957,7 +968,8 @@ template struct BasicEasing { * @htmlinclude easings-bounceinout.svg */ static T bounceInOut(T t) { - if(t < T(0.5)) return T(0.5)*bounceIn(T(2.0)*t); + if(t < T(0.5)) + return T(0.5)*bounceIn(T(2.0)*t); return T(0.5)*bounceOut(T(2.0)*t - T(1.0)) + T(0.5); } }; diff --git a/src/Magnum/Animation/Interpolation.h b/src/Magnum/Animation/Interpolation.h index 9028ff289..418b62f2f 100644 --- a/src/Magnum/Animation/Interpolation.h +++ b/src/Magnum/Animation/Interpolation.h @@ -420,7 +420,8 @@ template R interpolate(const Containers::StridedArray CORRADE_ASSERT(keys.size() == values.size(), "Animation::interpolate(): keys and values don't have the same size", {}); /* No data, return default-constructed value */ - if(!keys.size()) return {}; + if(!keys.size()) + return {}; /* Only one frame, return it verbatim (or default-constructed, if desired) */ if(keys.size() == 1) { @@ -432,7 +433,8 @@ template R interpolate(const Containers::StridedArray } /* Rewind from the beginning if hint is too late */ - if(hint >= keys.size() || frame < keys[hint]) hint = 0; + if(hint >= keys.size() || frame < keys[hint]) + hint = 0; /* Go through the keys until we find a pair that is around given time */ while(hint + 2 < keys.size() && frame >= keys[hint + 1]) @@ -441,11 +443,15 @@ template R interpolate(const Containers::StridedArray /* Special extrapolation outside of range. Usual extrapolation is handled below. */ if(frame < keys[hint]) { - if(before == Extrapolation::DefaultConstructed) return {}; - if(before == Extrapolation::Constant) frame = keys[hint]; + if(before == Extrapolation::DefaultConstructed) + return {}; + if(before == Extrapolation::Constant) + frame = keys[hint]; } else if(frame >= keys[hint + 1]) { - if(after == Extrapolation::DefaultConstructed) return {}; - if(after == Extrapolation::Constant) frame = keys[hint + 1]; + if(after == Extrapolation::DefaultConstructed) + return {}; + if(after == Extrapolation::Constant) + frame = keys[hint + 1]; } return interpolator(values[hint], values[hint + 1], @@ -457,7 +463,8 @@ template R interpolateStrict(const Containers::Stride CORRADE_ASSERT(keys.size() == values.size(), "Animation::interpolateStrict(): keys and values don't have the same size", {}); /* Rewind from the beginning if hint is too late */ - if(hint >= keys.size() || frame < keys[hint]) hint = 0; + if(hint >= keys.size() || frame < keys[hint]) + hint = 0; /* Go through the keys until we find a pair that is around given time */ while(hint + 2 < keys.size() && frame >= keys[hint + 1]) diff --git a/src/Magnum/Animation/Player.h b/src/Magnum/Animation/Player.h index 86a39658f..867a1c00a 100644 --- a/src/Magnum/Animation/Player.h +++ b/src/Magnum/Animation/Player.h @@ -850,7 +850,8 @@ template template Player& track, K key, std::size_t& hint, void* destination, void(*callback)(), void* userData) { /** @todo try to use atStrict() if possible */ R result = static_cast&>(track).at(key, hint); - if(result == *static_cast(destination)) return; + if(result == *static_cast(destination)) + return; reinterpret_cast(callback)(key, result, userData); *static_cast(destination) = result; }, &destination, reinterpret_cast(callbackPtr), userData); @@ -862,7 +863,8 @@ template template P [](const TrackViewStorage& track, K key, std::size_t& hint, void* destination, void(*callback)(), void* userData) { /** @todo try to use atStrict() if possible */ R result = static_cast&>(track).at(key, hint); - if(result == *static_cast(destination)) return; + if(result == *static_cast(destination)) + return; reinterpret_cast(callback)(key, result, *static_cast(userData)); *static_cast(destination) = result; }, &destination, reinterpret_cast(callbackPtr), &userData); diff --git a/src/Magnum/Animation/Player.hpp b/src/Magnum/Animation/Player.hpp index e4e286baf..03be7d9fe 100644 --- a/src/Magnum/Animation/Player.hpp +++ b/src/Magnum/Animation/Player.hpp @@ -74,7 +74,8 @@ template struct Player::Track { #endif template void Player::advance(const T time, const std::initializer_list>> players) { - for(Player& p: players) p.advance(time); + for(Player& p: players) + p.advance(time); } template Player::Player(Player&&) noexcept = default; @@ -126,13 +127,15 @@ template Player& Player::play(T startTime) { } template Player& Player::resume(T startTime) { - if(_state == State::Playing) return *this; + if(_state == State::Playing) + return *this; return play(startTime); } template Player& Player::pause(T pauseTime) { /* Avoid breaking the pause state when not playing */ - if(_state != State::Playing) return *this; + if(_state != State::Playing) + return *this; _state = State::Paused; _stopPauseTime = pauseTime; @@ -141,7 +144,8 @@ template Player& Player::pause(T pauseTime) { template Player& Player::seekBy(T timeDelta) { /* Animation is stopped, nothing to do */ - if(_state == State::Stopped) return *this; + if(_state == State::Stopped) + return *this; /* If the animation is paused and parked already, trigger a "park" again in order to have the values updated on the next call to advance(). The @@ -160,7 +164,8 @@ template Player& Player::seekBy(T timeDelta) { template Player& Player::seekTo(T seekTime, T animationTime) { /* Animation is stopped, nothing to do */ - if(_state == State::Stopped) return *this; + if(_state == State::Stopped) + return *this; /* If the animation is paused and parked already, trigger a "park" again in order to have the values updated on the next call to advance(). The @@ -233,7 +238,8 @@ template Containers::Optional> playe key = K{}; playIteration = 0; if(playCount != 0) { - if(state != State::Paused) state = State::Stopped; + if(state != State::Paused) + state = State::Stopped; startTime = {}; } @@ -245,7 +251,8 @@ template Containers::Optional> playe playIteration = scaled.first; key = scaled.second; if(playCount && playIteration >= playCount) { - if(state != State::Paused) state = State::Stopped; + if(state != State::Paused) + state = State::Stopped; /* Don't reset the startTime to disambiguate between explicitly stopped and "time run out" animation */ playIteration = playCount - 1; @@ -268,7 +275,8 @@ template std::pair Player::elapsed(const T pauseTime = _stopPauseTime; State state = _state; const Containers::Optional> elapsed = Implementation::playerElapsed(duration, _playCount, _scaler, time, startTime, pauseTime, state); - if(elapsed) return *elapsed; + if(elapsed) + return *elapsed; } /* If not advancing, the animation can be paused -- calculate the iteration @@ -300,7 +308,8 @@ template Player& Player::advance(const T time) { /* Get the elapsed time. If we shouldn't advance anything (player already stopped / not yet playing, quit */ Containers::Optional> elapsed = Implementation::playerElapsed(_duration.size(), _playCount, _scaler, time, _startTime, _stopPauseTime, _state); - if(!elapsed) return *this; + if(!elapsed) + return *this; /* Advance all tracks. Properly handle durations that don't start at 0. */ for(Track& t: _tracks) diff --git a/src/Magnum/Animation/Test/PlayerTest.cpp b/src/Magnum/Animation/Test/PlayerTest.cpp index 82a2a73ae..e3546ef74 100644 --- a/src/Magnum/Animation/Test/PlayerTest.cpp +++ b/src/Magnum/Animation/Test/PlayerTest.cpp @@ -1312,7 +1312,8 @@ template void PlayerTest::addRawCallback() { [](const Animation::TrackViewStorage& track, Float key, std::size_t& hint, void* destination, void(*callback)(), void* userData) { Int value = static_cast&>(track).at(key, hint); - if(value == *static_cast(destination)) return; + if(value == *static_cast(destination)) + return; *static_cast(destination) = value; reinterpret_cast&, Int)>(callback)(*static_cast*>(userData), value); }, &result, reinterpret_cast(callback), &data) diff --git a/src/Magnum/Array.h b/src/Magnum/Array.h index 8187308f8..2ac86d679 100644 --- a/src/Magnum/Array.h +++ b/src/Magnum/Array.h @@ -110,7 +110,8 @@ template class CORRADE_DEPRECATED("use Math::Ve /** @brief Equality */ bool operator==(const Array& other) const { for(UnsignedInt i = 0; i != dimensions; ++i) - if(_data[i] != other._data[i]) return false; + if(_data[i] != other._data[i]) + return false; return true; } @@ -257,7 +258,8 @@ template class CORRADE_DEPRECATED("use Math::Vector3 or Containers::Arr template Debug& operator<<(Debug& debug, const Array& value) { debug << "Array(" << Debug::nospace; for(UnsignedInt i = 0; i != dimensions; ++i) { - if(i != 0) debug << Debug::nospace << ","; + if(i != 0) + debug << Debug::nospace << ","; debug << value[i]; } return debug << Debug::nospace << ")"; diff --git a/src/Magnum/Audio/Buffer.h b/src/Magnum/Audio/Buffer.h index 234d83634..7f75e62f9 100644 --- a/src/Magnum/Audio/Buffer.h +++ b/src/Magnum/Audio/Buffer.h @@ -66,7 +66,10 @@ class MAGNUM_AUDIO_EXPORT Buffer { * Deletes OpenAL buffer object. * @see @fn_al_keyword{DeleteBuffers} */ - ~Buffer() { if(_id) alDeleteBuffers(1, &_id); } + ~Buffer() { + if(_id) + alDeleteBuffers(1, &_id); + } /** @brief Copying is not allowed */ Buffer(const Buffer&) = delete; diff --git a/src/Magnum/Audio/Context.cpp b/src/Magnum/Audio/Context.cpp index 4439aa4a2..41c1ba775 100644 --- a/src/Magnum/Audio/Context.cpp +++ b/src/Magnum/Audio/Context.cpp @@ -202,7 +202,8 @@ Context::Context(NoCreateT, const Int argc, const char* const* const argv) noexc } void Context::create(const Configuration& configuration) { - if(!tryCreate(configuration)) std::exit(1); + if(!tryCreate(configuration)) + std::exit(1); } bool Context::tryCreate(const Configuration& configuration) { @@ -301,7 +302,8 @@ bool Context::tryCreate(const Configuration& configuration) { anything. If it is, set its status as unsupported but flip the corresponding bit in the disabled bitmap so we know it is supported and only got disabled */ - if(!_extensionStatus[found->index()]) continue; + if(!_extensionStatus[found->index()]) + continue; _extensionStatus.set(found->index(), false); _disabledExtensions.set(found->index(), true); @@ -319,13 +321,17 @@ bool Context::tryCreate(const Configuration& configuration) { Context::Context(Context&& other) noexcept: _device{other._device}, _context{other._context}, _extensionStatus{Utility::move(other._extensionStatus)}, _supportedExtensions{Utility::move(other._supportedExtensions)} { other._device = nullptr; other._context = nullptr; - if(currentContext == &other) currentContext = this; + if(currentContext == &other) + currentContext = this; } Context::~Context() { - if(_context) alcDestroyContext(_context); - if(_device) alcCloseDevice(_device); - if(currentContext == this) currentContext = nullptr; + if(_context) + alcDestroyContext(_context); + if(_device) + alcCloseDevice(_device); + if(currentContext == this) + currentContext = nullptr; } std::vector Context::extensionStrings() const { diff --git a/src/Magnum/Audio/Listener.cpp b/src/Magnum/Audio/Listener.cpp index 6b385d2b3..cea748745 100644 --- a/src/Magnum/Audio/Listener.cpp +++ b/src/Magnum/Audio/Listener.cpp @@ -59,7 +59,8 @@ template Listener::~Listener() = default; template void Listener::clean(const MatrixTypeFor& absoluteTransformationMatrix) { /* Only clean if this Listener is active */ - if(!isActive()) return; + if(!isActive()) + return; Renderer::setListenerPosition(_soundTransformation.transformVector(Vector3::pad(absoluteTransformationMatrix.translation()))); @@ -102,7 +103,8 @@ template void Listener::update(std::initiali template Listener& Listener::setGain(const Float gain) { _gain = gain; - if(isActive()) Renderer::setListenerGain(_gain); + if(isActive()) + Renderer::setListenerGain(_gain); return *this; } diff --git a/src/Magnum/Audio/Source.cpp b/src/Magnum/Audio/Source.cpp index 6bfc2a86e..f0100dc00 100644 --- a/src/Magnum/Audio/Source.cpp +++ b/src/Magnum/Audio/Source.cpp @@ -54,7 +54,8 @@ std::size_t Source::unqueueBuffers(Containers::ArrayView unqueuedIds(processedBuffers); alSourceUnqueueBuffers(_id, unqueuedIds.size(), unqueuedIds.data()); diff --git a/src/Magnum/Audio/Source.h b/src/Magnum/Audio/Source.h index fd540cd76..f5f861ebb 100644 --- a/src/Magnum/Audio/Source.h +++ b/src/Magnum/Audio/Source.h @@ -72,7 +72,10 @@ class MAGNUM_AUDIO_EXPORT Source { * Deletes OpenAL source object. * @see @fn_al_keyword{DeleteSources} */ - ~Source() { if(_id) alDeleteSources(1, &_id); } + ~Source() { + if(_id) + alDeleteSources(1, &_id); + } /** @brief Copying is not allowed */ Source(const Source&) = delete; diff --git a/src/Magnum/Audio/Test/GlobalStateAcrossLibrariesLibrary.cpp b/src/Magnum/Audio/Test/GlobalStateAcrossLibrariesLibrary.cpp index 5320b8926..fa05521c5 100644 --- a/src/Magnum/Audio/Test/GlobalStateAcrossLibrariesLibrary.cpp +++ b/src/Magnum/Audio/Test/GlobalStateAcrossLibrariesLibrary.cpp @@ -31,7 +31,8 @@ namespace Magnum { namespace Audio { namespace Test { Audio::Context* currentContextInALibrary() { - if(!Audio::Context::hasCurrent()) return nullptr; + if(!Audio::Context::hasCurrent()) + return nullptr; return &Audio::Context::current(); } diff --git a/src/Magnum/Audio/al-info.cpp b/src/Magnum/Audio/al-info.cpp index 19244f56d..7d8ee386c 100644 --- a/src/Magnum/Audio/al-info.cpp +++ b/src/Magnum/Audio/al-info.cpp @@ -174,7 +174,8 @@ int main(const int argc, const char* const* const argv) { return 0; } - if(args.isSet("short")) return 0; + if(args.isSet("short")) + return 0; Debug() << "Vendor extension support:"; for(const auto& extension: Audio::Extension::extensions()) { diff --git a/src/Magnum/DebugTools/BufferData.h b/src/Magnum/DebugTools/BufferData.h index f5a8522d1..d4052b2c6 100644 --- a/src/Magnum/DebugTools/BufferData.h +++ b/src/Magnum/DebugTools/BufferData.h @@ -109,7 +109,8 @@ template CORRADE_DEPRECATED("use non-templated bufferSubData() and Cont /* Yes, this should have NoInit, but let's preserve the deprecated API in its original form */ Containers::Array data{std::size_t(size)}; - if(size) Implementation::bufferSubData(buffer, offset, size*sizeof(T), data); + if(size) + Implementation::bufferSubData(buffer, offset, size*sizeof(T), data); return data; } #endif diff --git a/src/Magnum/DebugTools/CompareImage.cpp b/src/Magnum/DebugTools/CompareImage.cpp index 2828956ce..1a087f7e1 100644 --- a/src/Magnum/DebugTools/CompareImage.cpp +++ b/src/Magnum/DebugTools/CompareImage.cpp @@ -252,7 +252,8 @@ void printDeltaImage(Debug& out, Containers::ArrayView deltas, cons const Vector2i blockCount = (size + pixelsPerBlock - Vector2i{1})/pixelsPerBlock; for(std::int_fast32_t y = 0; y != blockCount.y(); ++y) { - if(y) out << Debug::newline; + if(y) + out << Debug::newline; out << " |"; for(std::int_fast32_t x = 0; x != blockCount.x(); ++x) { @@ -388,11 +389,13 @@ void printPixelDeltas(Debug& out, Containers::ArrayView delta, Pixe sorted map. Need to reverse the condition in order to catch NaNs. */ std::multimap large; for(std::size_t i = 0; i != delta.size(); ++i) - if(!(delta[i] <= meanThreshold)) large.emplace(delta[i], i); + if(!(delta[i] <= meanThreshold)) + large.emplace(delta[i], i); /* If there's no outliers, don't print anything. This can happen only when --verbose is used. */ - if(large.empty()) return; + if(large.empty()) + return; /* If there are outliers, adding a newline to separate itself from the delta image -- calling code wouldn't know if we produce output or not, @@ -408,7 +411,8 @@ void printPixelDeltas(Debug& out, Containers::ArrayView delta, Pixe inner loop but that doesn't matter as we always print just ~10 values. */ std::size_t count = 0; for(auto it = large.crbegin(); it != large.crend(); ++it) { - if(++count > maxCount) break; + if(++count > maxCount) + break; const Containers::Pair div = Math::div(Int(it->second), Int(expectedPixels.size()[1])); const Vector2i pos{div.second(), div.first()}; @@ -457,11 +461,13 @@ class ImageComparatorBase::State { the --save-failed option. Treat both the same lazy way to keep the code straightforward. */ PluginManager::Manager& importerManager() { - if(!_importerManager) _importerManager = &_privateImporterManager.emplace(); + if(!_importerManager) + _importerManager = &_privateImporterManager.emplace(); return *_importerManager; } PluginManager::Manager& converterManager() { - if(!_converterManager) _converterManager = &_privateConverterManager.emplace(); + if(!_converterManager) + _converterManager = &_privateConverterManager.emplace(); return *_converterManager; } diff --git a/src/Magnum/DebugTools/CompareMaterial.cpp b/src/Magnum/DebugTools/CompareMaterial.cpp index b3f687263..38917ca1a 100644 --- a/src/Magnum/DebugTools/CompareMaterial.cpp +++ b/src/Magnum/DebugTools/CompareMaterial.cpp @@ -297,9 +297,11 @@ void Comparator::printMessage(const TestSuite::Comp } if(_state->actual->types() && _state->actual->types() != _state->expected->types()) { out << Debug::newline << " " << Debug::color(Debug::Color::Green) << "+" << Debug::nospace; - if(_state->expected->types()) out << Debug::resetColor; + if(_state->expected->types()) + out << Debug::resetColor; out << "Types:"; - if(_state->expected->types()) out << Debug::color(Debug::Color::Green); + if(_state->expected->types()) + out << Debug::color(Debug::Color::Green); out << Debug::packed << _state->actual->types() << Debug::resetColor; } diff --git a/src/Magnum/DebugTools/ForceRenderer.cpp b/src/Magnum/DebugTools/ForceRenderer.cpp index 68997cd20..6f077d918 100644 --- a/src/Magnum/DebugTools/ForceRenderer.cpp +++ b/src/Magnum/DebugTools/ForceRenderer.cpp @@ -74,11 +74,13 @@ constexpr UnsignedByte indices[]{ template ForceRenderer::ForceRenderer(ResourceManager& manager, SceneGraph::AbstractObject& object, const VectorTypeFor& forcePosition, const VectorTypeFor& force, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable(object, drawables), _forcePosition(forcePosition), _force(force), _options(manager.get(options)) { /* Shader */ _shader = manager.get>(shaderKey()); - if(!_shader) manager.set(_shader.key(), new Shaders::FlatGL); + if(!_shader) + manager.set(_shader.key(), new Shaders::FlatGL); /* Mesh and vertex buffer */ _mesh = manager.get("force"); - if(_mesh) return; + if(_mesh) + return; /* Create the mesh */ GL::Buffer vertexBuffer{GL::Buffer::TargetHint::Array}; diff --git a/src/Magnum/DebugTools/FrameProfiler.cpp b/src/Magnum/DebugTools/FrameProfiler.cpp index 92080d886..a719bb2d5 100644 --- a/src/Magnum/DebugTools/FrameProfiler.cpp +++ b/src/Magnum/DebugTools/FrameProfiler.cpp @@ -79,7 +79,8 @@ FrameProfiler::FrameProfiler(FrameProfiler&& other) noexcept: /* For all state pointers that point to &other patch them to point to this instead, to account for 90% of use cases of derived classes */ for(Measurement& measurement: _measurements) - if(measurement._state == &other) measurement._state = this; + if(measurement._state == &other) + measurement._state = this; } FrameProfiler& FrameProfiler::operator=(FrameProfiler&& other) noexcept { @@ -96,12 +97,14 @@ FrameProfiler& FrameProfiler::operator=(FrameProfiler&& other) noexcept { /* For all state pointers that point to &other patch them to point to this instead, to account for 90% of use cases of derived classes */ for(Measurement& measurement: _measurements) - if(measurement._state == &other) measurement._state = this; + if(measurement._state == &other) + measurement._state = this; /* And the same the other way to avoid the other instance accidentally affecting our measurements */ for(Measurement& measurement: other._measurements) - if(measurement._state == this) measurement._state = &other; + if(measurement._state == this) + measurement._state = &other; return *this; } @@ -360,7 +363,8 @@ void FrameProfiler::printStatisticsInternal(Debug& out) const { out << Debug::color(Debug::Color::Blue) << "-.--" << Debug::resetColor; - if(units[0] != '\0') out << units; + if(units[0] != '\0') + out << units; /* Otherwise format the value */ } else { @@ -406,7 +410,8 @@ Containers::String FrameProfiler::statistics() const { void FrameProfiler::printStatistics(const UnsignedInt frequency) const { Debug::Flags flags; - if(!Debug::isTty()) flags |= Debug::Flag::DisableColors; + if(!Debug::isTty()) + flags |= Debug::Flag::DisableColors; printStatistics(Debug{flags}, frequency); } @@ -559,7 +564,8 @@ void FrameProfilerGL::setup(const Values values, const UnsignedInt maxFrameCount [](void* state, UnsignedInt previous, UnsignedInt) { /* Avoid division by zero if a frame doesn't have any draws */ const auto submitted = static_cast(state)->verticesSubmittedQueries[previous].result(); - if(!submitted) return UnsignedLong{}; + if(!submitted) + return UnsignedLong{}; return static_cast(state)->vertexShaderInvocationsQueries[previous].result()*1000/submitted; }, _state.get()); @@ -584,14 +590,16 @@ void FrameProfilerGL::setup(const Values values, const UnsignedInt maxFrameCount [](void* state, UnsignedInt previous, UnsignedInt) { /* Avoid division by zero if a frame doesn't have any draws */ const auto input = static_cast(state)->clippingInputPrimitivesQueries[previous].result(); - if(!input) return UnsignedLong{}; + if(!input) + return UnsignedLong{}; /* If we have more output primitives than input, it's because a triangle got split into multiple. To avoid an underflow, return zero as well. A corresponding test case is in FrameProfilerGLTest::primitiveClipRatioNegative(). */ const auto output = static_cast(state)->clippingOutputPrimitivesQueries[previous].result(); - if(input < output) return UnsignedLong{}; + if(input < output) + return UnsignedLong{}; return 100000 - static_cast(state)->clippingOutputPrimitivesQueries[previous].result()*100000/input; }, _state.get()); @@ -603,12 +611,17 @@ void FrameProfilerGL::setup(const Values values, const UnsignedInt maxFrameCount auto FrameProfilerGL::values() const -> Values { Values values; - if(_state->frameTimeIndex != 0xffff) values |= Value::FrameTime; - if(_state->cpuDurationIndex != 0xffff) values |= Value::CpuDuration; - if(_state->gpuDurationIndex != 0xffff) values |= Value::GpuDuration; + if(_state->frameTimeIndex != 0xffff) + values |= Value::FrameTime; + if(_state->cpuDurationIndex != 0xffff) + values |= Value::CpuDuration; + if(_state->gpuDurationIndex != 0xffff) + values |= Value::GpuDuration; #ifndef MAGNUM_TARGET_GLES - if(_state->vertexFetchRatioIndex != 0xffff) values |= Value::VertexFetchRatio; - if(_state->primitiveClipRatioIndex != 0xffff) values |= Value::PrimitiveClipRatio; + if(_state->vertexFetchRatioIndex != 0xffff) + values |= Value::VertexFetchRatio; + if(_state->primitiveClipRatioIndex != 0xffff) + values |= Value::PrimitiveClipRatio; #endif return values; } diff --git a/src/Magnum/DebugTools/ObjectRenderer.cpp b/src/Magnum/DebugTools/ObjectRenderer.cpp index ca25ace62..a2ff9eac9 100644 --- a/src/Magnum/DebugTools/ObjectRenderer.cpp +++ b/src/Magnum/DebugTools/ObjectRenderer.cpp @@ -72,11 +72,13 @@ template<> struct Renderer<3> { template ObjectRenderer::ObjectRenderer(ResourceManager& manager, SceneGraph::AbstractObject& object, ResourceKey options, SceneGraph::DrawableGroup* drawables): SceneGraph::Drawable{object, drawables}, _options{manager.get(options)} { /* Shader */ _shader = manager.get>(Renderer::shader()); - if(!_shader) manager.set(_shader.key(), new Shaders::VertexColorGL); + if(!_shader) + manager.set(_shader.key(), new Shaders::VertexColorGL); /* Mesh */ _mesh = manager.get(Renderer::mesh()); - if(!_mesh) manager.set(_mesh.key(), MeshTools::compile(Renderer::meshData())); + if(!_mesh) + manager.set(_mesh.key(), MeshTools::compile(Renderer::meshData())); } /* To avoid deleting pointers to incomplete type on destruction of Resource members */ diff --git a/src/Magnum/DebugTools/Profiler.cpp b/src/Magnum/DebugTools/Profiler.cpp index 2c79e7094..ee0e3fa23 100644 --- a/src/Magnum/DebugTools/Profiler.cpp +++ b/src/Magnum/DebugTools/Profiler.cpp @@ -68,7 +68,8 @@ void Profiler::disable() { /* MSVC complains about deprecated Section here */ CORRADE_IGNORE_DEPRECATED_PUSH void Profiler::start(Section section) { - if(!_enabled) return; + if(!_enabled) + return; CORRADE_ASSERT(section < _sections.size(), "Profiler: unknown section passed to start()", ); save(); @@ -78,7 +79,8 @@ void Profiler::start(Section section) { CORRADE_IGNORE_DEPRECATED_POP void Profiler::stop() { - if(!_enabled) return; + if(!_enabled) + return; save(); @@ -97,7 +99,8 @@ void Profiler::save() { } void Profiler::nextFrame() { - if(!_enabled) return; + if(!_enabled) + return; /* Next frame index */ std::size_t nextFrame = (_currentFrame+1) % _measureDuration; @@ -115,11 +118,13 @@ void Profiler::nextFrame() { /* Advance to next frame */ _currentFrame = nextFrame; - if(_frameCount < _measureDuration) ++_frameCount; + if(_frameCount < _measureDuration) + ++_frameCount; } void Profiler::printStatistics() { - if(!_enabled) return; + if(!_enabled) + return; std::vector totalSorted(_sections.size()); std::iota(totalSorted.begin(), totalSorted.end(), 0); diff --git a/src/Magnum/DebugTools/Test/FrameProfilerGLTest.cpp b/src/Magnum/DebugTools/Test/FrameProfilerGLTest.cpp index 2e6547d47..bdee06fb8 100644 --- a/src/Magnum/DebugTools/Test/FrameProfilerGLTest.cpp +++ b/src/Magnum/DebugTools/Test/FrameProfilerGLTest.cpp @@ -134,7 +134,8 @@ void FrameProfilerGLTest::test() { FrameProfilerGL::Value::PrimitiveClipRatio #endif }) { - if(!(data.values & value)) continue; + if(!(data.values & value)) + continue; CORRADE_VERIFY(!profiler.isMeasurementAvailable(value)); /* The names should not be allocated */ diff --git a/src/Magnum/GL/AbstractShaderProgram.cpp b/src/Magnum/GL/AbstractShaderProgram.cpp index 967b71cab..d76721e0c 100644 --- a/src/Magnum/GL/AbstractShaderProgram.cpp +++ b/src/Magnum/GL/AbstractShaderProgram.cpp @@ -312,7 +312,8 @@ AbstractShaderProgram::~AbstractShaderProgram() { /* Remove current usage from the state */ GLuint& current = Context::current().state().shaderProgram.current; - if(current == _id) current = 0; + if(current == _id) + current = 0; glDeleteProgram(_id); } @@ -587,7 +588,8 @@ AbstractShaderProgram& AbstractShaderProgram::dispatchComputeIndirect(Buffer& in void AbstractShaderProgram::use(const GLuint id) { /* Use only if the program isn't already in use */ GLuint& current = Context::current().state().shaderProgram.current; - if(current != id) glUseProgram(current = id); + if(current != id) + glUseProgram(current = id); } void AbstractShaderProgram::use() { use(_id); } @@ -597,7 +599,8 @@ void AbstractShaderProgram::attachShader(Shader& shader) { } void AbstractShaderProgram::attachShaders(const Containers::Iterable& shaders) { - for(Shader& s: shaders) attachShader(s); + for(Shader& s: shaders) + attachShader(s); } void AbstractShaderProgram::bindAttributeLocation(const UnsignedInt location, const Containers::StringView name) { @@ -728,9 +731,11 @@ bool AbstractShaderProgram::checkLink(const Containers::Iterable& shader #ifdef MAGNUM_BUILD_DEPRECATED bool AbstractShaderProgram::link(std::initializer_list> shaders) { - for(AbstractShaderProgram& shader: shaders) shader.submitLink(); + for(AbstractShaderProgram& shader: shaders) + shader.submitLink(); bool allSuccess = true; - for(AbstractShaderProgram& shader: shaders) allSuccess = allSuccess && shader.checkLink({}); + for(AbstractShaderProgram& shader: shaders) + allSuccess = allSuccess && shader.checkLink({}); return allSuccess; } #endif @@ -745,13 +750,15 @@ void AbstractShaderProgram::cleanLogImplementationNoOp(Containers::String&) {} #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES) void AbstractShaderProgram::cleanLogImplementationIntelWindows(Containers::String& message) { - if(message == "No errors.\n") message = {}; + if(message == "No errors.\n") + message = {}; } #endif #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL) void AbstractShaderProgram::cleanLogImplementationAngle(Containers::String& message) { - if(message == "\n") message = {}; + if(message == "\n") + message = {}; } #endif diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index 860a1b746..a86bcd6af 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -184,7 +184,8 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, cons const GLuint id = textures && textures[i] ? textures[i]->_id : 0; if(textures) { - if(textures[i]) textures[i]->createIfNotAlready(); + if(textures[i]) + textures[i]->createIfNotAlready(); ids[i] = id; } @@ -195,7 +196,8 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, cons } /* Avoid doing the binding if there is nothing different */ - if(different) glBindTextures(firstTextureUnit, textures.size(), ids); + if(different) + glBindTextures(firstTextureUnit, textures.size(), ids); } #endif @@ -240,14 +242,16 @@ AbstractTexture::~AbstractTexture() { /* Remove all bindings */ for(auto& binding: Context::current().state().texture.bindings) { /* MSVC 2015 needs the parentheses around */ - if(binding.second() == _id) binding = {}; + if(binding.second() == _id) + binding = {}; } #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /* Remove all image bindings */ for(auto& binding: Context::current().state().texture.imageBindings) { /* MSVC 2015 needs the parentheses around */ - if(binding.id == _id) binding = {}; + if(binding.id == _id) + binding = {}; } #endif @@ -334,7 +338,8 @@ void AbstractTexture::bindImages(const Int firstImageUnit, const Containers::Arr } /* Avoid doing the binding if there is nothing different */ - if(different) glBindImageTextures(firstImageUnit, textures.size(), ids); + if(different) + glBindImageTextures(firstImageUnit, textures.size(), ids); } void AbstractTexture::bindImages(const Int firstImageUnit, const std::initializer_list textures) { @@ -401,7 +406,8 @@ void AbstractTexture::bindImplementationDSA(AbstractTexture& self, const GLint t #ifdef CORRADE_TARGET_WINDOWS void AbstractTexture::bindImplementationDSAIntelWindows(AbstractTexture& self, const GLint textureUnit) { /* See the "intel-windows-half-baked-dsa-texture-bind" workaround */ - if(self._target == GL_TEXTURE_CUBE_MAP) bindImplementationDefault(self, textureUnit); + if(self._target == GL_TEXTURE_CUBE_MAP) + bindImplementationDefault(self, textureUnit); else bindImplementationDSA(self, textureUnit); } #endif diff --git a/src/Magnum/GL/Attribute.cpp b/src/Magnum/GL/Attribute.cpp index 6931163d9..58c8712d0 100644 --- a/src/Magnum/GL/Attribute.cpp +++ b/src/Magnum/GL/Attribute.cpp @@ -227,7 +227,8 @@ UnsignedInt Attribute>::size(GLint components, DataType d UnsignedInt Attribute>::size(GLint components, DataType dataType) { #ifndef MAGNUM_TARGET_GLES - if(components == GL_BGRA) components = 4; + if(components == GL_BGRA) + components = 4; #endif switch(dataType) { @@ -586,7 +587,8 @@ namespace { UnsignedInt attributeSize(DynamicAttribute::Components components, DynamicAttribute::DataType dataType) { Int componentCount = GLint(components); #ifndef MAGNUM_TARGET_GLES - if(components == DynamicAttribute::Components::BGRA) componentCount = 4; + if(components == DynamicAttribute::Components::BGRA) + componentCount = 4; #endif switch(dataType) { diff --git a/src/Magnum/GL/Buffer.cpp b/src/Magnum/GL/Buffer.cpp index 0f2641c0e..a3e9c6053 100644 --- a/src/Magnum/GL/Buffer.cpp +++ b/src/Magnum/GL/Buffer.cpp @@ -209,7 +209,8 @@ Buffer::~Buffer() { /* Remove all current bindings from the state */ for(std::size_t i = 1; i != Implementation::BufferState::TargetCount; ++i) - if(bindings[i] == _id) bindings[i] = 0; + if(bindings[i] == _id) + bindings[i] = 0; glDeleteBuffers(1, &_id); } @@ -287,7 +288,8 @@ void Buffer::bindInternal(const TargetHint target, Buffer* const buffer) { /* Bind the buffer otherwise, which will also finally create it */ bound = id; - if(buffer) buffer->_flags |= ObjectFlag::Created; + if(buffer) + buffer->_flags |= ObjectFlag::Created; glBindBuffer(GLenum(target), id); } @@ -438,7 +440,8 @@ bool Buffer::unmap() { return Context::current().state().buffer.unmapImplementat #if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) && __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20017) Containers::Array Buffer::subData(const GLintptr offset, const GLsizeiptr size) { Containers::Array data{NoInit, std::size_t(size)}; - if(size) Context::current().state().buffer.getSubDataImplementation(*this, offset, size, data); + if(size) + Context::current().state().buffer.getSubDataImplementation(*this, offset, size, data); return data; } #endif @@ -446,7 +449,8 @@ Containers::Array Buffer::subData(const GLintptr offset, const GLsizeiptr #ifndef MAGNUM_TARGET_GLES2 void Buffer::bindImplementationFallback(const Target target, const GLuint firstIndex, Containers::ArrayView buffers) { for(std::size_t i = 0; i != buffers.size(); ++i) { - if(buffers && buffers[i]) buffers[i]->bind(target, firstIndex + i); + if(buffers && buffers[i]) + buffers[i]->bind(target, firstIndex + i); else unbind(target, firstIndex + i); } } diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index 00356aa78..4c1eeb78f 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -843,16 +843,19 @@ Context::Context(Context&& other) noexcept: _configurationFlags{other._configurationFlags} { Utility::copy(other._extensionRequiredVersion, _extensionRequiredVersion); - if(currentContext == &other) currentContext = this; + if(currentContext == &other) + currentContext = this; } Context::~Context() { - if(currentContext == this) currentContext = nullptr; + if(currentContext == this) + currentContext = nullptr; } void Context::create(const Configuration& configuration) { /* Hard exit if the context cannot be created */ - if(!tryCreate(configuration)) std::exit(1); + if(!tryCreate(configuration)) + std::exit(1); } bool Context::tryCreate(const Configuration& configuration) { @@ -892,7 +895,8 @@ bool Context::tryCreate(const Configuration& configuration) { /* Load GL function pointers. Pass this instance to it so it can use it for potential driver-specific workarounds. */ - if(_functionLoader) _functionLoader(*this); + if(_functionLoader) + _functionLoader(*this); /* Initialize to something predictable to avoid crashes on improperly created contexts */ @@ -1024,7 +1028,8 @@ bool Context::tryCreate(const Configuration& configuration) { } /* Reset minimal required version to Version::None for whole array */ - for(auto& i: _extensionRequiredVersion) i = Version::None; + for(auto& i: _extensionRequiredVersion) + i = Version::None; /* Initialize required versions from extension info */ for(const auto& version: KnownExtensionsForVersion) @@ -1072,7 +1077,8 @@ bool Context::tryCreate(const Configuration& configuration) { if(!_driverWorkarounds.isEmpty()) { Debug{output} << "Using driver workarounds:"; for(const auto& workaround: _driverWorkarounds) - if(!workaround.second()) Debug(output) << " " << workaround.first(); + if(!workaround.second()) + Debug(output) << " " << workaround.first(); } /* Fetch default framebuffer size and set up default clear color. If we are diff --git a/src/Magnum/GL/DebugOutput.h b/src/Magnum/GL/DebugOutput.h index 82afdc7d8..30a05f4a2 100644 --- a/src/Magnum/GL/DebugOutput.h +++ b/src/Magnum/GL/DebugOutput.h @@ -749,7 +749,10 @@ class MAGNUM_GL_EXPORT DebugGroup { * * If the group is active, calls @ref pop(). */ - ~DebugGroup() { if(_active) pop(); } + ~DebugGroup() { + if(_active) + pop(); + } /** * @brief Push debug group onto the stack diff --git a/src/Magnum/GL/DefaultFramebuffer.cpp b/src/Magnum/GL/DefaultFramebuffer.cpp index 6f1fdaff1..4ca97c60b 100644 --- a/src/Magnum/GL/DefaultFramebuffer.cpp +++ b/src/Magnum/GL/DefaultFramebuffer.cpp @@ -64,8 +64,8 @@ DefaultFramebuffer& DefaultFramebuffer::clearColor(const Vector4ui& color) { DefaultFramebuffer& DefaultFramebuffer::mapForDraw(const Containers::ArrayView> attachments) { /* Max attachment location */ std::size_t max = 0; - for(const auto& attachment: attachments) - if(attachment.first() > max) max = attachment.first(); + for(const auto& attachment: attachments) if(attachment.first() > max) + max = attachment.first(); /* Create linear array from associative */ /** @todo C++14: use VLA to avoid heap allocation */ diff --git a/src/Magnum/GL/Framebuffer.cpp b/src/Magnum/GL/Framebuffer.cpp index 71b774272..7b0ad4716 100644 --- a/src/Magnum/GL/Framebuffer.cpp +++ b/src/Magnum/GL/Framebuffer.cpp @@ -131,7 +131,8 @@ Framebuffer::~Framebuffer() { /* If bound, remove itself from state */ Context& context = Context::current(); Implementation::FramebufferState& state = context.state().framebuffer; - if(state.readBinding == _id) state.readBinding = 0; + if(state.readBinding == _id) + state.readBinding = 0; /* For draw binding reset also viewport. Don't do that for windowless contexts to avoid potential race conditions with default framebuffer on @@ -188,8 +189,8 @@ Framebuffer& Framebuffer::clearColor(const Int attachment, const Vector4ui& colo Framebuffer& Framebuffer::mapForDraw(const Containers::ArrayView> attachments) { /* Max attachment location */ std::size_t max = 0; - for(const auto& attachment: attachments) - if(attachment.first() > max) max = attachment.first(); + for(const auto& attachment: attachments) if(attachment.first() > max) + max = attachment.first(); /* Create linear array from associative */ /** @todo C++14: use VLA to avoid heap allocation */ diff --git a/src/Magnum/GL/Implementation/BufferState.cpp b/src/Magnum/GL/Implementation/BufferState.cpp index 23608c63e..5115eccaa 100644 --- a/src/Magnum/GL/Implementation/BufferState.cpp +++ b/src/Magnum/GL/Implementation/BufferState.cpp @@ -240,7 +240,8 @@ BufferState::BufferState(Context& context, Containers::StaticArrayView> State::al Debug{out} << "Using optional features:"; for(const char* extension: extensions) - if(extension) Debug(out) << " " << extension; + if(extension) + Debug(out) << " " << extension; return {Utility::move(data), state}; } diff --git a/src/Magnum/GL/Mesh.cpp b/src/Magnum/GL/Mesh.cpp index 44634383e..0a3eee688 100644 --- a/src/Magnum/GL/Mesh.cpp +++ b/src/Magnum/GL/Mesh.cpp @@ -347,7 +347,8 @@ Mesh::~Mesh() { /* Remove current vao from the state */ GLuint& current = Context::current().state().mesh.currentVAO; - if(current == _id) current = 0; + if(current == _id) + current = 0; Context::current().state().mesh.destroyImplementation(*this); } @@ -1103,7 +1104,8 @@ void Mesh::drawInternal(TransformFeedback& xfb, const UnsignedInt stream, const /* Default stream */ if(stream == 0) { /* Non-instanced mesh */ - if(instanceCount == 1) glDrawTransformFeedback(GLenum(_primitive), xfb.id()); + if(instanceCount == 1) + glDrawTransformFeedback(GLenum(_primitive), xfb.id()); /* Instanced mesh */ else glDrawTransformFeedbackInstanced(GLenum(_primitive), xfb.id(), instanceCount); @@ -1111,7 +1113,8 @@ void Mesh::drawInternal(TransformFeedback& xfb, const UnsignedInt stream, const /* Specific stream */ } else { /* Non-instanced mesh */ - if(instanceCount == 1) glDrawTransformFeedbackStream(GLenum(_primitive), xfb.id(), stream); + if(instanceCount == 1) + glDrawTransformFeedbackStream(GLenum(_primitive), xfb.id(), stream); /* Instanced mesh */ else glDrawTransformFeedbackStreamInstanced(GLenum(_primitive), xfb.id(), stream, instanceCount); @@ -1289,11 +1292,13 @@ void Mesh::attributePointerImplementationVAODSAIntelWindows(Mesh& self, Attribut /* See the "angle-instanced-attributes-always-draw-instanced" workaround for these two */ void Mesh::attributePointerImplementationDefaultAngleAlwaysInstanced(Mesh& self, AttributeLayout&& attribute) { - if(attribute.divisor) self._instanced = true; + if(attribute.divisor) + self._instanced = true; return attributePointerImplementationDefault(self, Utility::move(attribute)); } void Mesh::attributePointerImplementationVAOAngleAlwaysInstanced(Mesh& self, AttributeLayout&& attribute) { - if(attribute.divisor) self._instanced = true; + if(attribute.divisor) + self._instanced = true; return attributePointerImplementationVAO(self, Utility::move(attribute)); } #endif @@ -1404,7 +1409,8 @@ void Mesh::bindImplementationDefault(Mesh& self) { self.vertexAttribPointer(attribute); /* Bind index buffer, if the mesh is indexed */ - if(self._indexBuffer.id()) self._indexBuffer.bindInternal(Buffer::TargetHint::ElementArray); + if(self._indexBuffer.id()) + self._indexBuffer.bindInternal(Buffer::TargetHint::ElementArray); } void Mesh::bindImplementationVAO(Mesh& self) { @@ -1492,7 +1498,8 @@ void Mesh::multiDrawElementsBaseVertexImplementationANGLE(const GLenum mode, con {NoInit, std::size_t(drawCount), instanceCount}, {ValueInit, std::size_t(drawCount), baseInstance}, }; - for(GLsizei& i: instanceCount) i = 1; + for(GLsizei& i: instanceCount) + i = 1; glMultiDrawElementsInstancedBaseVertexBaseInstanceANGLE(mode, count, type, indices, instanceCount, baseVertex, baseInstance, drawCount); } diff --git a/src/Magnum/GL/MeshView.cpp b/src/Magnum/GL/MeshView.cpp index 0faa9d4e7..a4ab46ed9 100644 --- a/src/Magnum/GL/MeshView.cpp +++ b/src/Magnum/GL/MeshView.cpp @@ -120,7 +120,8 @@ void MeshView::multiDrawImplementationDefault(const Containers::Iterable> shaders) { /* Invoke (possibly parallel) compilation on all shaders */ - for(Shader& shader: shaders) shader.submitCompile(); + for(Shader& shader: shaders) + shader.submitCompile(); bool allSuccess = true; - for(Shader& shader: shaders) allSuccess = allSuccess && shader.checkCompile(); + for(Shader& shader: shaders) + allSuccess = allSuccess && shader.checkCompile(); return allSuccess; } #endif @@ -959,7 +962,8 @@ void Shader::cleanLogImplementationNoOp(Containers::String&) {} #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES) void Shader::cleanLogImplementationIntelWindows(Containers::String& message) { - if(message == "No errors.\n") message = {}; + if(message == "No errors.\n") + message = {}; } #endif diff --git a/src/Magnum/GL/Test/CubeMapTextureGLTest.cpp b/src/Magnum/GL/Test/CubeMapTextureGLTest.cpp index 6db6c3ff5..506ffcd34 100644 --- a/src/Magnum/GL/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/GL/Test/CubeMapTextureGLTest.cpp @@ -1858,7 +1858,8 @@ void CubeMapTextureGLTest::compressedImage3D() { "ARB_DSA compressed cubemap APIs are broken on AMD drivers."); MAGNUM_VERIFY_NO_GL_ERROR(); - if(fails) CORRADE_SKIP("Skipping the rest of the test"); + if(fails) + CORRADE_SKIP("Skipping the rest of the test"); } CompressedImage3D image = texture.compressedImage(0, {data.storage}); @@ -1872,7 +1873,8 @@ void CubeMapTextureGLTest::compressedImage3D() { MAGNUM_VERIFY_NO_GL_ERROR(); #ifdef CORRADE_TARGET_WINDOWS - if(fails) CORRADE_SKIP("Skipping the rest of the test"); + if(fails) + CORRADE_SKIP("Skipping the rest of the test"); #endif } @@ -1911,7 +1913,8 @@ void CubeMapTextureGLTest::compressedImage3DBuffer() { "ARB_DSA compressed cubemap APIs are broken on AMD drivers."); MAGNUM_VERIFY_NO_GL_ERROR(); - if(fails) CORRADE_SKIP("Skipping the rest of the test"); + if(fails) + CORRADE_SKIP("Skipping the rest of the test"); } CompressedBufferImage3D image = texture.compressedImage(0, {data.storage}, BufferUsage::StaticRead); @@ -1925,7 +1928,8 @@ void CubeMapTextureGLTest::compressedImage3DBuffer() { MAGNUM_VERIFY_NO_GL_ERROR(); #ifdef CORRADE_TARGET_WINDOWS - if(fails) CORRADE_SKIP("Skipping the rest of the test"); + if(fails) + CORRADE_SKIP("Skipping the rest of the test"); #endif } @@ -1963,7 +1967,8 @@ void CubeMapTextureGLTest::compressedImage3DQueryView() { "ARB_DSA compressed cubemap APIs are broken on AMD drivers."); MAGNUM_VERIFY_NO_GL_ERROR(); - if(fails) CORRADE_SKIP("Skipping the rest of the test"); + if(fails) + CORRADE_SKIP("Skipping the rest of the test"); } Containers::Array imageData{data.offset + 16*6}; @@ -1979,7 +1984,8 @@ void CubeMapTextureGLTest::compressedImage3DQueryView() { MAGNUM_VERIFY_NO_GL_ERROR(); #ifdef CORRADE_TARGET_WINDOWS - if(fails) CORRADE_SKIP("Skipping the rest of the test"); + if(fails) + CORRADE_SKIP("Skipping the rest of the test"); #endif } diff --git a/src/Magnum/GL/Test/MeshGLTest.cpp b/src/Magnum/GL/Test/MeshGLTest.cpp index 53a0734b1..cbabcb905 100644 --- a/src/Magnum/GL/Test/MeshGLTest.cpp +++ b/src/Magnum/GL/Test/MeshGLTest.cpp @@ -1444,7 +1444,8 @@ Checker::Checker(AbstractShaderProgram&& shader, RenderbufferFormat format, Mesh #endif ; - if(view.mesh().isIndexed()) view.setIndexOffset(1); + if(view.mesh().isIndexed()) + view.setIndexOffset(1); shader.draw(view); } diff --git a/src/Magnum/GL/TransformFeedback.cpp b/src/Magnum/GL/TransformFeedback.cpp index 5833b25a9..00efc25f8 100644 --- a/src/Magnum/GL/TransformFeedback.cpp +++ b/src/Magnum/GL/TransformFeedback.cpp @@ -137,7 +137,8 @@ TransformFeedback::~TransformFeedback() { /* If bound, remove itself from state */ GLuint& binding = Context::current().state().transformFeedback.binding; - if(binding == _id) binding = 0; + if(binding == _id) + binding = 0; glDeleteTransformFeedbacks(1, &_id); } diff --git a/src/Magnum/Image.cpp b/src/Magnum/Image.cpp index 25e3240b3..1edd96e0d 100644 --- a/src/Magnum/Image.cpp +++ b/src/Magnum/Image.cpp @@ -115,7 +115,8 @@ template CompressedImage::CompressedImage(co size check below could then die on division by zero. Exit early in that case. */ /** @todo any better idea to handle this? ugh */ - if(!passed) return; + if(!passed) + return; #else static_cast(passed); #endif diff --git a/src/Magnum/ImageView.cpp b/src/Magnum/ImageView.cpp index cbf662733..ee951c643 100644 --- a/src/Magnum/ImageView.cpp +++ b/src/Magnum/ImageView.cpp @@ -64,7 +64,8 @@ template void ImageView::setData } template auto ImageView::pixels() const -> Containers::StridedArrayView { - if(!_data && !_data.size()) return {}; + if(!_data && !_data.size()) + return {}; return Implementation::imagePixelView(*this, data()); } @@ -87,7 +88,8 @@ template CompressedImageView::Co size check below could then die on division by zero. Exit early in that case. */ /** @todo any better idea to handle this? ugh */ - if(!passed) return; + if(!passed) + return; #else static_cast(passed); #endif diff --git a/src/Magnum/ImageView.h b/src/Magnum/ImageView.h index 1678b162a..3ad646f5e 100644 --- a/src/Magnum/ImageView.h +++ b/src/Magnum/ImageView.h @@ -532,7 +532,8 @@ template class ImageView { * as well. See also @ref Image-pixel-access for more information. */ template Containers::StridedArrayView::value, typename std::add_const::type, U>::type> pixels() const { - if(!_data && !_data.size()) return {}; + if(!_data && !_data.size()) + return {}; /* Deliberately not adding a StridedArrayView include, it should work without since this is a templated function and we declare arrayCast() above to satisfy two-phase lookup. */ diff --git a/src/Magnum/MaterialTools/Filter.cpp b/src/Magnum/MaterialTools/Filter.cpp index 181c65b0f..7494a4b02 100644 --- a/src/Magnum/MaterialTools/Filter.cpp +++ b/src/Magnum/MaterialTools/Filter.cpp @@ -80,7 +80,8 @@ Trade::MaterialData filterAttributesLayersImplementation(const Trade::MaterialDa std::size_t layerCount; if(inputLayersToKeep.data()) { layerCount = inputLayersToKeep.count(); - if(!inputLayersToKeep[0]) ++layerCount; + if(!inputLayersToKeep[0]) + ++layerCount; } else layerCount = material.layerCount(); /* Fill in the layer offsets based on count of attributes in each, skipping @@ -91,7 +92,8 @@ Trade::MaterialData filterAttributesLayersImplementation(const Trade::MaterialDa for(UnsignedInt i = 0; i != material.layerCount(); ++i) { if(inputLayersToKeep.data() && !inputLayersToKeep[i]) { /* The base layer stays, just gets empty */ - if(i == 0) layers[layerOffset++] = 0; + if(i == 0) + layers[layerOffset++] = 0; continue; } layers[layerOffset++] = patchedInputAttributesToKeep.prefix(material.attributeDataOffset(i + 1)).count(); diff --git a/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.cpp b/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.cpp index b5bbc0b51..0d7a09b3c 100644 --- a/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.cpp +++ b/src/Magnum/MaterialTools/PhongToPbrMetallicRoughness.cpp @@ -62,7 +62,8 @@ Containers::Optional phongToPbrMetallicRoughness(const Trad Trade::MaterialAttribute::Shininess }) { const Containers::Optional id = material.findAttributeId(attribute); - if(!id) continue; + if(!id) + continue; if(flags >= PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes) { Error{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertible" << attribute << "attribute"; @@ -78,7 +79,8 @@ Containers::Optional phongToPbrMetallicRoughness(const Trad Trade::MaterialAttribute::SpecularTexture }) { const Containers::Optional id = material.findAttributeId(attribute); - if(!id) continue; + if(!id) + continue; if(flags >= PhongToPbrMetallicRoughnessFlag::FailOnUnconvertibleAttributes) { Error{} << "MaterialTools::phongToPbrMetallicRoughness(): unconvertible" << attribute << "attribute"; diff --git a/src/Magnum/Math/Algorithms/KahanSum.h b/src/Magnum/Math/Algorithms/KahanSum.h index 20484fad7..cdcb38a0d 100644 --- a/src/Magnum/Math/Algorithms/KahanSum.h +++ b/src/Magnum/Math/Algorithms/KahanSum.h @@ -71,7 +71,8 @@ template Containers::Optional epsilonX) epsilonX = y; + if(y > epsilonX) + epsilonX = y; } /* Accumulation of right hand transformations */ @@ -229,7 +230,8 @@ template Containers::Optional class Bezier { */ bool operator==(const Bezier& other) const { for(std::size_t i = 0; i != order + 1; ++i) - if(_data[i] != other._data[i]) return false; + if(_data[i] != other._data[i]) + return false; return true; } diff --git a/src/Magnum/Math/BitVector.h b/src/Magnum/Math/BitVector.h index fcc697981..4172b3c1b 100644 --- a/src/Magnum/Math/BitVector.h +++ b/src/Magnum/Math/BitVector.h @@ -387,7 +387,8 @@ template Debug& operator<<(Debug& debug, const BitVector template inline bool BitVector::operator==(const BitVector& other) const { for(std::size_t i = 0; i != size/8; ++i) - if(_data[i] != other._data[i]) return false; + if(_data[i] != other._data[i]) + return false; /* Check last segment */ if(size%8 && (_data[DataSize-1] & LastSegmentMask) != (other._data[DataSize-1] & LastSegmentMask)) @@ -399,7 +400,8 @@ template inline bool BitVector::operator==(const BitVect template inline bool BitVector::all() const { /* Check all full segments */ for(std::size_t i = 0; i != size/8; ++i) - if(_data[i] != FullSegmentMask) return false; + if(_data[i] != FullSegmentMask) + return false; /* Check last segment */ if(size%8 && (_data[DataSize-1] & LastSegmentMask) != LastSegmentMask) @@ -411,7 +413,8 @@ template inline bool BitVector::all() const { template inline bool BitVector::none() const { /* Check all full segments */ for(std::size_t i = 0; i != size/8; ++i) - if(_data[i]) return false; + if(_data[i]) + return false; /* Check last segment */ if(size%8 && (_data[DataSize-1] & LastSegmentMask)) diff --git a/src/Magnum/Math/Color.h b/src/Magnum/Math/Color.h index a544e35a8..085e1205f 100644 --- a/src/Magnum/Math/Color.h +++ b/src/Magnum/Math/Color.h @@ -51,7 +51,8 @@ namespace Implementation { template::value, int>::type = 0> Color3 fromHsv(ColorHsv hsv) { /* Remove repeats */ hsv.hue -= floor(T(hsv.hue)/T(360))*Deg(360); - if(hsv.hue < Deg(0)) hsv.hue += Deg(360); + if(hsv.hue < Deg(0)) + hsv.hue += Deg(360); int h = int(T(hsv.hue)/T(60)) % 6; T f = T(hsv.hue)/T(60) - h; diff --git a/src/Magnum/Math/Complex.h b/src/Magnum/Math/Complex.h index 08f63485b..1962a83e8 100644 --- a/src/Magnum/Math/Complex.h +++ b/src/Magnum/Math/Complex.h @@ -648,7 +648,8 @@ template inline Complex slerp(const Complex& normalizedA, const C const T cosAngle = dot(normalizedA, normalizedB); /* Avoid division by zero */ - if(std::abs(cosAngle) >= T(1)) return Complex{normalizedA}; + if(std::abs(cosAngle) >= T(1)) + return Complex{normalizedA}; /** @todo couldn't this be done somewhat simpler? */ const T a = std::acos(cosAngle); diff --git a/src/Magnum/Math/ConfigurationValue.h b/src/Magnum/Math/ConfigurationValue.h index 7bfdce753..5297040bf 100644 --- a/src/Magnum/Math/ConfigurationValue.h +++ b/src/Magnum/Math/ConfigurationValue.h @@ -92,7 +92,8 @@ template struct ConfigurationValue::toString(value[i], flags); } @@ -164,7 +165,8 @@ template struct ConfigurationValue< for(std::size_t row = 0; row != rows; ++row) { for(std::size_t col = 0; col != cols; ++col) { - if(!output.empty()) output += ' '; + if(!output.empty()) + output += ' '; output += ConfigurationValue::toString(value[col][row], flags); } } @@ -349,7 +351,8 @@ template str for(std::size_t o = 0; o != order + 1; ++o) { for(std::size_t i = 0; i != dimensions; ++i) { - if(!output.empty()) output += ' '; + if(!output.empty()) + output += ' '; output += ConfigurationValue::toString(value[o][i], flags); } } diff --git a/src/Magnum/Math/Frustum.h b/src/Magnum/Math/Frustum.h index 25c95e3df..81af1bd67 100644 --- a/src/Magnum/Math/Frustum.h +++ b/src/Magnum/Math/Frustum.h @@ -135,7 +135,8 @@ template class Frustum { */ bool operator==(const Frustum& other) const { for(std::size_t i = 0; i != 6; ++i) - if(_data[i] != other._data[i]) return false; + if(_data[i] != other._data[i]) + return false; return true; } @@ -292,9 +293,11 @@ template class Frustum { template Debug& operator<<(Debug& debug, const Frustum& value) { debug << "Frustum({" << Debug::nospace; for(std::size_t i = 0; i != 6; ++i) { - if(i != 0) debug << Debug::nospace << "},\n {" << Debug::nospace; + if(i != 0) + debug << Debug::nospace << "},\n {" << Debug::nospace; for(std::size_t j = 0; j != 4; ++j) { - if(j != 0) debug << Debug::nospace << ","; + if(j != 0) + debug << Debug::nospace << ","; debug << value[i][j]; } } diff --git a/src/Magnum/Math/Functions.cpp b/src/Magnum/Math/Functions.cpp index f5667a504..b407f5d5c 100644 --- a/src/Magnum/Math/Functions.cpp +++ b/src/Magnum/Math/Functions.cpp @@ -75,9 +75,11 @@ UnsignedLong binomialCoefficient(const UnsignedInt n, UnsignedInt k) { /* k and n - k gives the same value, optimize the calculation to do fewer steps */ - if(k*2 > n) k = n - k; + if(k*2 > n) + k = n - k; - if(k == 0) return 1; + if(k == 0) + return 1; UnsignedLong result = n; for(UnsignedInt i = 2; i <= k; ++i) { diff --git a/src/Magnum/Math/Functions.h b/src/Magnum/Math/Functions.h index 5c35f3c6f..7dfa69178 100644 --- a/src/Magnum/Math/Functions.h +++ b/src/Magnum/Math/Functions.h @@ -266,8 +266,8 @@ template inline BitVector isInf(const Vector& value) { BitVector out; - for(std::size_t i = 0; i != size; ++i) - if(Math::isInf(value[i])) out.set(i); + for(std::size_t i = 0; i != size; ++i) if(Math::isInf(value[i])) + out.set(i); return out; } @@ -292,8 +292,8 @@ template inline BitVector isNan(const Vector& value) { BitVector out; - for(std::size_t i = 0; i != size; ++i) - if(Math::isNan(value[i])) out.set(i); + for(std::size_t i = 0; i != size; ++i) if(Math::isNan(value[i])) + out.set(i); return out; } @@ -379,8 +379,8 @@ template inline Containers::Pair, Vector> minmax(const Vector& a, const Vector& b) { using Utility::swap; Containers::Pair, Vector> out{a, b}; - for(std::size_t i = 0; i != size; ++i) - if(out.first()[i] > out.second()[i]) swap(out.first()[i], out.second()[i]); + for(std::size_t i = 0; i != size; ++i) if(out.first()[i] > out.second()[i]) + swap(out.first()[i], out.second()[i]); return out; } @@ -428,8 +428,10 @@ template::value, int>::type = 0 #endif > inline UnderlyingTypeOf sign(T scalar) { - if(scalar > T(0)) return UnderlyingTypeOf(1); - if(scalar < T(0)) return UnderlyingTypeOf(-1); + if(scalar > T(0)) + return UnderlyingTypeOf(1); + if(scalar < T(0)) + return UnderlyingTypeOf(-1); return UnderlyingTypeOf(0); } @@ -914,7 +916,8 @@ template inline Vector refract(const Vector< "Math::refract(): vectors" << vector << "and" << normal << "are not normalized", {}); const T dot = Math::dot(vector, normal); const T k = T(1.0) - eta*eta*(T(1.0) - dot*dot); - if(k < T(0.0)) return {}; + if(k < T(0.0)) + return {}; return eta*vector - (eta*dot + std::sqrt(k))*normal; } diff --git a/src/Magnum/Math/FunctionsBatch.h b/src/Magnum/Math/FunctionsBatch.h index d50d4ef97..e3a6ec1b7 100644 --- a/src/Magnum/Math/FunctionsBatch.h +++ b/src/Magnum/Math/FunctionsBatch.h @@ -72,14 +72,16 @@ empty, returns @cpp false @ce or a @ref BitVector with no bits set. @see @ref isInf(T), @ref Constants::inf() */ template auto isInf(const Containers::StridedArrayView1D& range) -> decltype(isInf(std::declval())) { - if(range.isEmpty()) return {}; + if(range.isEmpty()) + return {}; /* For scalars, this loop exits once any value is infinity. For vectors the loop accumulates the bits and exits as soon as all bits are set or the input is exhausted */ auto out = isInf(range[0]); /* bool or BitVector */ for(std::size_t i = 1; i != range.size(); ++i) { - if(out) break; + if(out) + break; out = out || isInf(range[i]); } @@ -124,14 +126,16 @@ returns @cpp false @ce or a @ref BitVector with no bits set. @see @ref isNan(T), @ref Constants::nan() */ template inline auto isNan(const Containers::StridedArrayView1D& range) -> decltype(isNan(std::declval())) { - if(range.isEmpty()) return {}; + if(range.isEmpty()) + return {}; /* For scalars, this loop exits once any value is infinity. For vectors the loop accumulates the bits and exits as soon as all bits are set or the input is exhausted */ auto out = isNan(range[0]); /* bool or BitVector */ for(std::size_t i = 1; i != range.size(); ++i) { - if(out) break; + if(out) + break; out = out || isNan(range[i]); } @@ -177,8 +181,8 @@ namespace Implementation { /* Find the first non-NaN value to compare against. If all are NaN, return the last value so the following loop in min/max/minmax() doesn't even execute. */ - for(std::size_t i = 0; i != range.size(); ++i) - if(!isNan(range[i])) return {i, range[i]}; + for(std::size_t i = 0; i != range.size(); ++i) if(!isNan(range[i])) + return {i, range[i]}; return {range.size() - 1, range.back()}; } /* Floating-point vectors. Try to gather non-NaN values for each component @@ -193,8 +197,10 @@ namespace Implementation { std::size_t firstValid = 0; for(std::size_t i = 1; i != range.size(); ++i) { BitVector nans = isNan(out); - if(nans.none()) break; - if(nans.all() && firstValid + 1 == i) ++firstValid; + if(nans.none()) + break; + if(nans.all() && firstValid + 1 == i) + ++firstValid; out = Math::lerp(out, range[i], isNan(out)); } return {firstValid, out}; @@ -209,7 +215,8 @@ ignored, unless the range is all NaNs. @see @ref min(T, T), @ref isNan(const Containers::StridedArrayView1D&) */ template inline T min(const Containers::StridedArrayView1D& range) { - if(range.isEmpty()) return {}; + if(range.isEmpty()) + return {}; Containers::Pair iOut = Implementation::firstNonNan(range, IsFloatingPoint{}, IsVector{}); for(++iOut.first(); iOut.first() != range.size(); ++iOut.first()) @@ -254,7 +261,8 @@ ignored, unless the range is all NaNs. @see @ref max(T, T), @ref isNan(const Containers::StridedArrayView1D&) */ template inline T max(const Containers::StridedArrayView1D& range) { - if(range.isEmpty()) return {}; + if(range.isEmpty()) + return {}; Containers::Pair iOut = Implementation::firstNonNan(range, IsFloatingPoint{}, IsVector{}); for(++iOut.first(); iOut.first() != range.size(); ++iOut.first()) @@ -314,7 +322,8 @@ ignored, unless the range is all NaNs. @ref isNan(const Containers::StridedArrayView1D&) */ template inline Containers::Pair minmax(const Containers::StridedArrayView1D& range) { - if(range.isEmpty()) return {}; + if(range.isEmpty()) + return {}; Containers::Pair iOut = Implementation::firstNonNan(range, IsFloatingPoint{}, IsVector{}); T min{iOut.second()}, max{iOut.second()}; diff --git a/src/Magnum/Math/Intersection.h b/src/Magnum/Math/Intersection.h index 825c98110..0a3fd0166 100644 --- a/src/Magnum/Math/Intersection.h +++ b/src/Magnum/Math/Intersection.h @@ -505,7 +505,8 @@ template bool rangeFrustum(const Range3D& range, const Frustum& f const Float d = Math::dot(center, plane.xyz()); const Float r = Math::dot(extent, absPlaneNormal); - if(d + r < -T(2)*plane.w()) return false; + if(d + r < -T(2)*plane.w()) + return false; } return true; @@ -525,7 +526,8 @@ template bool aabbFrustum(const Vector3& aabbCenter, const Vector3 bool Matrix::isOrthogonal() const { /* Normality */ for(std::size_t i = 0; i != size; ++i) - if(!RectangularMatrix::_data[i].isNormalized()) return false; + if(!RectangularMatrix::_data[i].isNormalized()) + return false; /* Orthogonality */ for(std::size_t i = 0; i != size-1; ++i) diff --git a/src/Magnum/Math/Quaternion.h b/src/Magnum/Math/Quaternion.h index 77668ea80..d94b5c1f3 100644 --- a/src/Magnum/Math/Quaternion.h +++ b/src/Magnum/Math/Quaternion.h @@ -888,8 +888,10 @@ template Quaternion quaternionFromMatrix(const Matrix3x3& m) { /* Diagonal is negative */ std::size_t i = 0; - if(diagonal[1] > diagonal[0]) i = 1; - if(diagonal[2] > diagonal[i]) i = 2; + if(diagonal[1] > diagonal[0]) + i = 1; + if(diagonal[2] > diagonal[i]) + i = 2; const std::size_t j = (i + 1) % 3; const std::size_t k = (i + 2) % 3; diff --git a/src/Magnum/Math/Range.h b/src/Magnum/Math/Range.h index ef7490057..d4ea942eb 100644 --- a/src/Magnum/Math/Range.h +++ b/src/Magnum/Math/Range.h @@ -803,8 +803,10 @@ size. @see @ref join(const Range&, const Vector&) */ template inline Range join(const Range& a, const Range& b) { - if(a.min() == a.max()) return b; - if(b.min() == b.max()) return a; + if(a.min() == a.max()) + return b; + if(b.min() == b.max()) + return a; return {min(a.min(), b.min()), max(a.max(), b.max())}; } @@ -841,7 +843,8 @@ undefined if any range has a negative size. @see @ref intersects() */ template inline Range intersect(const Range& a, const Range& b) { - if(!intersects(a, b)) return {}; + if(!intersects(a, b)) + return {}; return {max(a.min(), b.min()), min(a.max(), b.max())}; } diff --git a/src/Magnum/Math/RectangularMatrix.h b/src/Magnum/Math/RectangularMatrix.h index d109ed1ea..2d407812d 100644 --- a/src/Magnum/Math/RectangularMatrix.h +++ b/src/Magnum/Math/RectangularMatrix.h @@ -316,7 +316,8 @@ template class RectangularMatrix { */ bool operator==(const RectangularMatrix& other) const { for(std::size_t i = 0; i != cols; ++i) - if(_data[i] != other._data[i]) return false; + if(_data[i] != other._data[i]) + return false; return true; } @@ -775,9 +776,11 @@ template Debug& operator<<(Debug& d const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; debug << (packed ? "{" : "Matrix(") << Debug::nospace; for(std::size_t row = 0; row != rows; ++row) { - if(row != 0) debug << Debug::nospace << (packed ? ",\n" : ",\n "); + if(row != 0) + debug << Debug::nospace << (packed ? ",\n" : ",\n "); for(std::size_t col = 0; col != cols; ++col) { - if(col != 0) debug << Debug::nospace << ","; + if(col != 0) + debug << Debug::nospace << ","; debug << value[col][row]; } } diff --git a/src/Magnum/Math/Test/IntersectionBenchmark.cpp b/src/Magnum/Math/Test/IntersectionBenchmark.cpp index a0f9fcf03..c214ec788 100644 --- a/src/Magnum/Math/Test/IntersectionBenchmark.cpp +++ b/src/Magnum/Math/Test/IntersectionBenchmark.cpp @@ -47,7 +47,8 @@ template bool rangeFrustumNaive(const Math::Range3D& box, const Math } /* All corners are outside this plane */ - if(!cornerHit) return false; + if(!cornerHit) + return false; } return true; diff --git a/src/Magnum/Math/TypeTraits.h b/src/Magnum/Math/TypeTraits.h index 7f9910331..5218de98f 100644 --- a/src/Magnum/Math/TypeTraits.h +++ b/src/Magnum/Math/TypeTraits.h @@ -529,7 +529,8 @@ template struct TypeTraitsFloatingPoint: TypeTraitsName { template bool TypeTraitsFloatingPoint::equals(const T a, const T b) { /* Shortcut for binary equality (also infinites) */ - if(a == b) return true; + if(a == b) + return true; const T absA = std::abs(a); const T absB = std::abs(b); @@ -546,7 +547,8 @@ template bool TypeTraitsFloatingPoint::equals(const T a, const T b) template bool TypeTraitsFloatingPoint::equalsZero(const T a, const T magnitude) { /* Shortcut for binary equality */ - if(a == T(0.0)) return true; + if(a == T(0.0)) + return true; const T absA = std::abs(a); diff --git a/src/Magnum/Math/Vector.h b/src/Magnum/Math/Vector.h index e7a7cdda0..3c3917198 100644 --- a/src/Magnum/Math/Vector.h +++ b/src/Magnum/Math/Vector.h @@ -300,7 +300,8 @@ template class Vector { */ bool operator==(const Vector& other) const { for(std::size_t i = 0; i != size; ++i) - if(!TypeTraits::equals(_data[i], other._data[i])) return false; + if(!TypeTraits::equals(_data[i], other._data[i])) + return false; return true; } @@ -1301,7 +1302,8 @@ template Debug& operator<<(Debug& debug, const Vector const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; debug << (packed ? "{" : "Vector(") << Debug::nospace; for(std::size_t i = 0; i != size; ++i) { - if(i != 0) debug << Debug::nospace << ","; + if(i != 0) + debug << Debug::nospace << ","; debug << value[i]; } debug << Debug::nospace << (packed ? "}" : ")"); @@ -1599,8 +1601,8 @@ namespace Implementation { /* Find the first non-NaN value to compare against. If all are NaN, return the last value so the following loop in min/max/minmax() doesn't even execute. */ - for(std::size_t i = 0; i != size; ++i) - if(!isNan(data[i])) return i; + for(std::size_t i = 0; i != size; ++i) if(!isNan(data[i])) + return i; return size - 1; } } diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index 9ace15b2f..abef8d7ed 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -113,7 +113,8 @@ Containers::String ConfigurationValue::toString(Magnum::M Magnum::MeshPrimitive ConfigurationValue::fromString(Containers::StringView stringValue, ConfigurationValueFlags) { for(std::size_t i = 0; i != Containers::arraySize(Magnum::MeshPrimitiveNames); ++i) - if(stringValue == Magnum::MeshPrimitiveNames[i]) return Magnum::MeshPrimitive(i + 1); + if(stringValue == Magnum::MeshPrimitiveNames[i]) + return Magnum::MeshPrimitive(i + 1); return {}; } @@ -127,7 +128,8 @@ Containers::String ConfigurationValue::toString(Magnum::M Magnum::MeshIndexType ConfigurationValue::fromString(Containers::StringView stringValue, ConfigurationValueFlags) { for(std::size_t i = 0; i != Containers::arraySize(Magnum::MeshIndexTypeNames); ++i) - if(stringValue == Magnum::MeshIndexTypeNames[i]) return Magnum::MeshIndexType(i + 1); + if(stringValue == Magnum::MeshIndexTypeNames[i]) + return Magnum::MeshIndexType(i + 1); return {}; } diff --git a/src/Magnum/MeshTools/BoundingVolume.cpp b/src/Magnum/MeshTools/BoundingVolume.cpp index fdf0f103c..2f7551abe 100644 --- a/src/Magnum/MeshTools/BoundingVolume.cpp +++ b/src/Magnum/MeshTools/BoundingVolume.cpp @@ -42,7 +42,8 @@ Range3D boundingRange(const Containers::StridedArrayView1D& point Containers::Pair boundingSphereBouncingBubble(const Containers::StridedArrayView1D& points) { /* See comment about radius below, this is done for consistency */ - if(points.isEmpty()) return {{}, Math::TypeTraits::epsilon()}; + if(points.isEmpty()) + return {{}, Math::TypeTraits::epsilon()}; /** @todo Skip NaNs here? To match behaviour of boundingBoxAxisAligned() which uses minmax(). */ diff --git a/src/Magnum/MeshTools/Compile.cpp b/src/Magnum/MeshTools/Compile.cpp index 863811d24..33f8839f6 100644 --- a/src/Magnum/MeshTools/Compile.cpp +++ b/src/Magnum/MeshTools/Compile.cpp @@ -495,9 +495,12 @@ GL::Mesh compile(const Trade::MeshData3D& meshData, CompileFlags flags) { } else { positions = meshData.positions(0); - if(meshData.hasNormals()) normals = meshData.normals(0); - if(meshData.hasTextureCoords2D()) textureCoords2D = meshData.textureCoords2D(0); - if(meshData.hasColors()) colors = meshData.colors(0); + if(meshData.hasNormals()) + normals = meshData.normals(0); + if(meshData.hasTextureCoords2D()) + textureCoords2D = meshData.textureCoords2D(0); + if(meshData.hasColors()) + colors = meshData.colors(0); useIndices = meshData.isIndexed(); } diff --git a/src/Magnum/MeshTools/Concatenate.cpp b/src/Magnum/MeshTools/Concatenate.cpp index 0799a1690..2f4cb2f3e 100644 --- a/src/Magnum/MeshTools/Concatenate.cpp +++ b/src/Magnum/MeshTools/Concatenate.cpp @@ -44,12 +44,14 @@ Containers::Pair concatenateIndexVertexCount(const Con indexed mesh, all previous meshes will have a trivial index buffer generated for all their vertices */ if(mesh.isIndexed()) { - if(!indexCount) indexCount = vertexCount; + if(!indexCount) + indexCount = vertexCount; indexCount += mesh.indexCount(); /* Otherwise, if some earlier mesh was indexed, this mesh will have a trivial index buffer generated for all its vertices */ - } else if(indexCount) indexCount += mesh.vertexCount(); + } else if(indexCount) + indexCount += mesh.vertexCount(); vertexCount += mesh.vertexCount(); } @@ -111,7 +113,8 @@ Trade::MeshData concatenate(Containers::Array&& indexData, const UnsignedI indexOffset += mesh.indexCount(); /* Adjust indices for current vertex offset */ - for(UnsignedInt& index: dst) index += vertexOffset; + for(UnsignedInt& index: dst) + index += vertexOffset; /* Otherwise, if we need an index buffer (meaning at least one of the meshes is indexed), generate a trivial index buffer */ diff --git a/src/Magnum/MeshTools/Duplicate.cpp b/src/Magnum/MeshTools/Duplicate.cpp index e961bd0c6..cfe632e66 100644 --- a/src/Magnum/MeshTools/Duplicate.cpp +++ b/src/Magnum/MeshTools/Duplicate.cpp @@ -112,7 +112,8 @@ Trade::MeshData duplicate(const Trade::MeshData& mesh, const Containers::ArrayVi UnsignedInt attributeIndex = mesh.attributeCount(); for(UnsignedInt i = 0; i != extra.size(); ++i) { /* Padding, ignore */ - if(extra[i].format() == VertexFormat{}) continue; + if(extra[i].format() == VertexFormat{}) + continue; /* Asserting here even though data() has another assert since that one would be too confusing in this context */ diff --git a/src/Magnum/MeshTools/GenerateNormals.cpp b/src/Magnum/MeshTools/GenerateNormals.cpp index 2a32d49ff..837a3b986 100644 --- a/src/Magnum/MeshTools/GenerateNormals.cpp +++ b/src/Magnum/MeshTools/GenerateNormals.cpp @@ -69,14 +69,16 @@ template inline void generateSmoothNormalsIntoImplementation(const Cont CORRADE_ASSERT(normals.size() == positions.size(), "MeshTools::generateSmoothNormalsInto(): bad output size, expected" << positions.size() << "but got" << normals.size(), ); - if(indices.isEmpty()) return; + if(indices.isEmpty()) + return; /* Gather count of triangles for every vertex. This abuses the output storage to avoid extra allocations, zero-initialize it first to avoid random memory getting used. */ Containers::StridedArrayView1D triangleCount = Containers::arrayCast(normals); - for(UnsignedInt& i: triangleCount) i = 0; + for(UnsignedInt& i: triangleCount) + i = 0; for(const T index: indices) { CORRADE_ASSERT(index < positions.size(), "MeshTools::generateSmoothNormalsInto(): index" << index << "out of range for" << positions.size() << "elements", ); ++triangleCount[index]; @@ -168,9 +170,12 @@ template inline void generateSmoothNormalsIntoImplementation(const Cont /* Angle between two sides of the triangle that share vertex `v`. The shared vertex can be one of the three. */ Rad angle; - if(v == v0i) angle = crossAngle.second()[0]; - else if(v == v1i) angle = crossAngle.second()[1]; - else if(v == v2i) angle = crossAngle.second()[2]; + if(v == v0i) + angle = crossAngle.second()[0]; + else if(v == v1i) + angle = crossAngle.second()[1]; + else if(v == v2i) + angle = crossAngle.second()[2]; else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ /* The normal is cross.normalized(), we need to multiply it it by diff --git a/src/Magnum/MeshTools/Interleave.cpp b/src/Magnum/MeshTools/Interleave.cpp index 11bd07871..c8dd96f49 100644 --- a/src/Magnum/MeshTools/Interleave.cpp +++ b/src/Magnum/MeshTools/Interleave.cpp @@ -62,7 +62,8 @@ Containers::Optional> interleavedData std::size_t maxOffset = 0; bool hasImplementationSpecificVertexFormat = false; for(UnsignedInt i = 0; i != mesh.attributeCount(); ++i) { - if(mesh.attributeStride(i) != stride) return Containers::NullOpt; + if(mesh.attributeStride(i) != stride) + return Containers::NullOpt; const std::size_t offset = mesh.attributeOffset(i); minOffset = Math::min(minOffset, offset); @@ -139,7 +140,8 @@ namespace Implementation { Containers::Array interleavedLayout(Trade::MeshData&& mesh, const Containers::ArrayView extra, const InterleaveFlags flags) { /* Nothing to do here, bye! */ - if(!mesh.attributeCount() && extra.isEmpty()) return {}; + if(!mesh.attributeCount() && extra.isEmpty()) + return {}; /* If we're not told to preserve the layout, treat the mesh as noninterleaved always, forcing a repack. Otherwise check if it's already @@ -204,14 +206,16 @@ Containers::Array interleavedLayout(Trade::MeshData&& preserve relative attribute offsets, otherwise pack tightly. */ std::size_t offset = 0; for(UnsignedInt i = 0; i != originalAttributeCount; ++i) { - if(interleaved) offset = attributeData[i].offset(mesh.vertexData()) - minOffset; + if(interleaved) + offset = attributeData[i].offset(mesh.vertexData()) - minOffset; attributeData[i] = Trade::MeshAttributeData{ attributeData[i].name(), attributeData[i].format(), offset, 0, std::ptrdiff_t(stride), attributeData[i].arraySize(), attributeData[i].morphTargetId()}; - if(!interleaved) offset += attributeSize(attributeData[i]); + if(!interleaved) + offset += attributeSize(attributeData[i]); } /* In case the original is already interleaved, set the offset for extra @@ -361,7 +365,8 @@ Trade::MeshData interleave(Trade::MeshData&& mesh, const Containers::ArrayView std::size_t removeDuplicatesIndexedInPlaceImplementati inverted (having the *Indexed() variant as the main implementation) because the remapping there has to be done once for every dimension. */ const Containers::Pair, std::size_t> result = removeDuplicatesInPlace(data); - for(auto& i: indices) i = result.first()[i]; + for(auto& i: indices) + i = result.first()[i]; return result.second(); } @@ -269,7 +270,8 @@ template std::size_t removeDuplicatesFuzzyIndexedInPla /* In iteration `0` we're not moving in any dimension, in iteration `vectorSize` we're moving in `vectorSize - 1` dimension */ - if(vi + 1 == moving) c += moveAmount; + if(vi + 1 == moving) + c += moveAmount; discretizedEntry[vi] = (c - offsets[vi])/epsilon; } @@ -292,7 +294,8 @@ template std::size_t removeDuplicatesFuzzyIndexedInPla } /* Remap the resulting index array */ - for(auto& i: indices) i = remapping[i]; + for(auto& i: indices) + i = remapping[i]; /* Move vertex coordinates by epsilon/2 in the next dimension (which is moving + 1 in the next loop iteration) */ @@ -344,7 +347,8 @@ template std::size_t removeDuplicatesFuzzyInPlaceIntoImplementation(con but on MSVC 2015 debug build it excepts StridedArrayIterator to have a member named iterator_category. Fuck that, using a loop instead. */ UnsignedInt i = 0; - for(UnsignedInt& index: indices) index = i++; + for(UnsignedInt& index: indices) + index = i++; const std::size_t size = removeDuplicatesFuzzyIndexedInPlaceImplementation(Containers::stridedArrayView(indices), data, epsilon); return size; diff --git a/src/Magnum/MeshTools/Test/CompileGLTest.cpp b/src/Magnum/MeshTools/Test/CompileGLTest.cpp index 911cd3de5..4215208c5 100644 --- a/src/Magnum/MeshTools/Test/CompileGLTest.cpp +++ b/src/Magnum/MeshTools/Test/CompileGLTest.cpp @@ -1767,7 +1767,8 @@ void CompileGLTest::externalBuffers() { }}; /* Duplicate everything if data is non-indexed */ - if(!data.indexed) meshData = duplicate(meshData); + if(!data.indexed) + meshData = duplicate(meshData); GL::Buffer indices{NoCreate}; if(meshData.isIndexed()) { diff --git a/src/Magnum/MeshTools/Test/InterleaveTest.cpp b/src/Magnum/MeshTools/Test/InterleaveTest.cpp index d1852e2f2..08fb0f27e 100644 --- a/src/Magnum/MeshTools/Test/InterleaveTest.cpp +++ b/src/Magnum/MeshTools/Test/InterleaveTest.cpp @@ -1304,7 +1304,8 @@ void InterleaveTest::interleaveMeshDataIndexed() { /* Testing also offset */ UnsignedShort indexData[50 + 3]; Containers::StridedArrayView1D indices = Containers::arrayView(indexData).exceptPrefix(50); - if(data.flip) indices = indices.flipped<0>(); + if(data.flip) + indices = indices.flipped<0>(); Utility::copy({0, 2, 1}, indices); Vector2 positions[]{{1.3f, 0.3f}, {0.87f, 1.1f}, {1.0f, -0.5f}}; @@ -1551,7 +1552,8 @@ void InterleaveTest::interleaveMeshDataAlreadyInterleavedMoveIndices() { /* Testing also offset */ Containers::Array indexData{(50 + 3)*sizeof(UnsignedShort)}; Containers::StridedArrayView1D indices = Containers::arrayCast(indexData).exceptPrefix(50); - if(data.flip) indices = indices.flipped<0>(); + if(data.flip) + indices = indices.flipped<0>(); Utility::copy({0, 2, 1}, indices); Containers::Array vertexData{3*8}; diff --git a/src/Magnum/MeshTools/Tipsify.cpp b/src/Magnum/MeshTools/Tipsify.cpp index 3d070ce1f..58e222fcd 100644 --- a/src/Magnum/MeshTools/Tipsify.cpp +++ b/src/Magnum/MeshTools/Tipsify.cpp @@ -69,7 +69,8 @@ template void tipsifyInPlaceImplementation(const Containers::StridedArr const UnsignedInt t = neighbors[ti]; /* Continue if already emitted */ - if(emitted[t]) continue; + if(emitted[t]) + continue; emitted[t] = true; /* Write all vertices of the triangle to output buffer */ @@ -99,7 +100,8 @@ template void tipsifyInPlaceImplementation(const Containers::StridedArr Int candidatePriority = -1; for(UnsignedInt v: candidates) { /* Skip if it doesn't have any live triangles */ - if(!liveTriangleCount[v]) continue; + if(!liveTriangleCount[v]) + continue; /* Get most fresh candidate which will still be in cache even after fanning. Every fanned triangle will generate at most @@ -120,7 +122,8 @@ template void tipsifyInPlaceImplementation(const Containers::StridedArr UnsignedInt d = deadEndStack.back(); arrayRemoveSuffix(deadEndStack); - if(!liveTriangleCount[d]) continue; + if(!liveTriangleCount[d]) + continue; fanningVertex = d; break; } @@ -128,7 +131,8 @@ template void tipsifyInPlaceImplementation(const Containers::StridedArr /* If not found, find next artbitrary vertex with live triangles */ while(++i < vertexCount) { - if(!liveTriangleCount[i]) continue; + if(!liveTriangleCount[i]) + continue; fanningVertex = i; break; diff --git a/src/Magnum/MeshTools/Transform.h b/src/Magnum/MeshTools/Transform.h index 4bd5d0a8c..d7653513e 100644 --- a/src/Magnum/MeshTools/Transform.h +++ b/src/Magnum/MeshTools/Transform.h @@ -61,22 +61,26 @@ Example usage: @todo GPU transform feedback implementation (otherwise this is only bad joke) */ template void transformVectorsInPlace(const Math::Matrix4& matrix, U&& vectors) { - for(auto& vector: vectors) vector = matrix.transformVector(vector); + for(auto& vector: vectors) + vector = matrix.transformVector(vector); } /** @overload */ template void transformVectorsInPlace(const Math::Matrix3& matrix, U&& vectors) { - for(auto& vector: vectors) vector = matrix.transformVector(vector); + for(auto& vector: vectors) + vector = matrix.transformVector(vector); } /** @overload */ template void transformVectorsInPlace(const Math::Complex& complex, U&& vectors) { - for(auto& vector: vectors) vector = complex.transformVector(vector); + for(auto& vector: vectors) + vector = complex.transformVector(vector); } /** @overload */ template void transformVectorsInPlace(const Math::Quaternion& normalizedQuaternion, U&& vectors) { - for(auto& vector: vectors) vector = normalizedQuaternion.transformVectorNormalized(vector); + for(auto& vector: vectors) + vector = normalizedQuaternion.transformVectorNormalized(vector); } /** @@ -114,22 +118,26 @@ Example usage: @ref DualQuaternion::transformPointNormalized() */ template void transformPointsInPlace(const Math::Matrix4& matrix, U&& points) { - for(auto& point: points) point = matrix.transformPoint(point); + for(auto& point: points) + point = matrix.transformPoint(point); } /** @overload */ template void transformPointsInPlace(const Math::Matrix3& matrix, U&& points) { - for(auto& point: points) point = matrix.transformPoint(point); + for(auto& point: points) + point = matrix.transformPoint(point); } /** @overload */ template void transformPointsInPlace(const Math::DualComplex& dualComplex, U&& points) { - for(auto& point: points) point = dualComplex.transformPoint(point); + for(auto& point: points) + point = dualComplex.transformPoint(point); } /** @overload */ template void transformPointsInPlace(const Math::DualQuaternion& normalizedDualQuaternion, U&& points) { - for(auto& point: points) point = normalizedDualQuaternion.transformPointNormalized(point); + for(auto& point: points) + point = normalizedDualQuaternion.transformPointNormalized(point); } /** diff --git a/src/Magnum/PixelFormat.cpp b/src/Magnum/PixelFormat.cpp index 1385c6f39..a822ec1b9 100644 --- a/src/Magnum/PixelFormat.cpp +++ b/src/Magnum/PixelFormat.cpp @@ -1226,7 +1226,8 @@ Magnum::PixelFormat ConfigurationValue::fromString(Containe /** @todo This is extremely slow with >100 values. Do a binary search on a sorted index list instead (extracted into a common utility) */ for(std::size_t i = 0; i != Containers::arraySize(Magnum::PixelFormatNames); ++i) - if(stringValue == Magnum::PixelFormatNames[i]) return Magnum::PixelFormat(i + 1); + if(stringValue == Magnum::PixelFormatNames[i]) + return Magnum::PixelFormat(i + 1); return {}; } @@ -1242,7 +1243,8 @@ Magnum::CompressedPixelFormat ConfigurationValue: /** @todo This is extremely slow with >100 values. Do a binary search on a sorted index list instead (extracted into a common utility) */ for(std::size_t i = 0; i != Containers::arraySize(Magnum::CompressedPixelFormatNames); ++i) - if(stringValue == Magnum::CompressedPixelFormatNames[i]) return Magnum::CompressedPixelFormat(i + 1); + if(stringValue == Magnum::CompressedPixelFormatNames[i]) + return Magnum::CompressedPixelFormat(i + 1); return {}; } diff --git a/src/Magnum/Platform/AbstractXApplication.cpp b/src/Magnum/Platform/AbstractXApplication.cpp index 2e80bfdc9..d21dded8f 100644 --- a/src/Magnum/Platform/AbstractXApplication.cpp +++ b/src/Magnum/Platform/AbstractXApplication.cpp @@ -53,7 +53,8 @@ void AbstractXApplication::create(const Configuration& configuration) { } void AbstractXApplication::create(const Configuration& configuration, const GLConfiguration& glConfiguration) { - if(!tryCreate(configuration, glConfiguration)) std::exit(1); + if(!tryCreate(configuration, glConfiguration)) + std::exit(1); } bool AbstractXApplication::tryCreate(const Configuration& configuration) { @@ -119,8 +120,10 @@ AbstractXApplication::~AbstractXApplication() { _contextHandler.reset(); /* Shut down X */ - if(_window) XDestroyWindow(_display, _window); - if(_display) XCloseDisplay(_display); + if(_window) + XDestroyWindow(_display, _window); + if(_display) + XCloseDisplay(_display); } void AbstractXApplication::swapBuffers() { @@ -130,7 +133,8 @@ void AbstractXApplication::swapBuffers() { int AbstractXApplication::exec() { /* If exit was requested directly in the constructor, exit immediately without calling anything else */ - if(_flags & Flag::Exit) return _exitCode; + if(_flags & Flag::Exit) + return _exitCode; /* Show window */ XMapWindow(_display, _window); @@ -171,7 +175,8 @@ AbstractXApplication::Pointers buttonsToPointers(const unsigned int state) { bool AbstractXApplication::mainLoopIteration() { /* If exit was requested directly in the constructor, exit immediately without calling anything else */ - if(_flags & Flag::Exit) return false; + if(_flags & Flag::Exit) + return false; XEvent event; diff --git a/src/Magnum/Platform/AndroidApplication.cpp b/src/Magnum/Platform/AndroidApplication.cpp index 71861f284..905de283b 100644 --- a/src/Magnum/Platform/AndroidApplication.cpp +++ b/src/Magnum/Platform/AndroidApplication.cpp @@ -103,7 +103,8 @@ void AndroidApplication::create(const Configuration& configuration) { } void AndroidApplication::create(const Configuration& configuration, const GLConfiguration& glConfiguration) { - if(!tryCreate(configuration, glConfiguration)) std::exit(32); + if(!tryCreate(configuration, glConfiguration)) + std::exit(32); } bool AndroidApplication::tryCreate(const Configuration& configuration) { diff --git a/src/Magnum/Platform/EmscriptenApplication.cpp b/src/Magnum/Platform/EmscriptenApplication.cpp index 830356c50..db04bfb4d 100644 --- a/src/Magnum/Platform/EmscriptenApplication.cpp +++ b/src/Magnum/Platform/EmscriptenApplication.cpp @@ -142,14 +142,17 @@ namespace { or 'Minus'. Note that the Y key on some layouts may result in 'KeyZ'. */ Key toKey(const EM_UTF8* const key, const EM_UTF8* const code) { const Containers::StringView keyView = key; - if(keyView.isEmpty()) return Key::Unknown; + if(keyView.isEmpty()) + return Key::Unknown; /* We use key for a-z as it gives us a keyboard layout respecting representation of the key, i.e. we get `z` for z depending on layout where code may give us `y` independent of the layout. */ if(keyView.size() == 1) { - if(key[0] >= 'a' && key[0] <= 'z') return Key(key[0]); - else if(key[0] >= 'A' && key[0] <= 'Z') return Key(key[0] - 'A' + 'a'); + if(key[0] >= 'a' && key[0] <= 'z') + return Key(key[0]); + else if(key[0] >= 'A' && key[0] <= 'Z') + return Key(key[0] - 'A' + 'a'); } /* We use code for 0-9 as it allows us to differentiate towards Numpad @@ -174,7 +177,8 @@ namespace { /* Numpad0 - Numpad9 */ const Int num = numKey[0] - '0'; - if(num >= 0 && num <= 9) return Key(num + Int(Key::NumZero)); + if(num >= 0 && num <= 9) + return Key(num + Int(Key::NumZero)); return Key::Unknown; } @@ -235,7 +239,8 @@ EmscriptenApplication::EmscriptenApplication(const Arguments& arguments, NoCreat #endif /* Save command-line arguments */ - if(args.value("log") == "verbose") _verboseLog = true; + if(args.value("log") == "verbose") + _verboseLog = true; const Containers::StringView dpiScaling = args.value("dpi-scaling"); /* Use physical DPI scaling */ @@ -273,12 +278,14 @@ void EmscriptenApplication::create() { } void EmscriptenApplication::create(const Configuration& configuration) { - if(!tryCreate(configuration)) exit(1); + if(!tryCreate(configuration)) + exit(1); } #ifdef MAGNUM_TARGET_GL void EmscriptenApplication::create(const Configuration& configuration, const GLConfiguration& glConfiguration) { - if(!tryCreate(configuration, glConfiguration)) exit(32); + if(!tryCreate(configuration, glConfiguration)) + exit(32); } #endif @@ -1196,7 +1203,8 @@ EmscriptenApplication::GLConfiguration::GLConfiguration(): int EmscriptenApplication::exec() { /* If exit was requested directly in the constructor, exit immediately without calling anything else */ - if(_flags & Flag::ExitRequested) return 0; + if(_flags & Flag::ExitRequested) + return 0; redraw(); return 0; @@ -1208,7 +1216,8 @@ void EmscriptenApplication::redraw() { /* Loop already running, no need to start, Note that should javascript runtimes ever be multithreaded, we will have a reentrancy issue here. */ - if(_flags & Flag::LoopActive) return; + if(_flags & Flag::LoopActive) + return; /* Start requestAnimationFrame loop */ _flags |= Flag::LoopActive; diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index d934a76b7..4148afdd1 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -139,7 +139,8 @@ GlfwApplication::GlfwApplication(const Arguments& arguments, NoCreateT): #endif /* Save command-line arguments */ - if(args.value("log") == "verbose") _verboseLog = true; + if(args.value("log") == "verbose") + _verboseLog = true; const Containers::StringView dpiScaling = args.value("dpi-scaling"); if(dpiScaling == "default"_s) _commandLineDpiScalingPolicy = Implementation::GlfwDpiScalingPolicy::Default; @@ -163,12 +164,14 @@ void GlfwApplication::create() { } void GlfwApplication::create(const Configuration& configuration) { - if(!tryCreate(configuration)) std::exit(1); + if(!tryCreate(configuration)) + std::exit(1); } #ifdef MAGNUM_TARGET_GL void GlfwApplication::create(const Configuration& configuration, const GLConfiguration& glConfiguration) { - if(!tryCreate(configuration, glConfiguration)) std::exit(1); + if(!tryCreate(configuration, glConfiguration)) + std::exit(1); } #endif @@ -676,7 +679,8 @@ void GlfwApplication::setupCallbacks() { glfwSetWindowCloseCallback(_window, [](GLFWwindow* const window){ ExitEvent e; static_cast(glfwGetWindowUserPointer(window))->exitEvent(e); - if(!e.isAccepted()) glfwSetWindowShouldClose(window, false); + if(!e.isAccepted()) + glfwSetWindowShouldClose(window, false); }); glfwSetWindowRefreshCallback(_window, [](GLFWwindow* const window){ /* Properly redraw after the window is restored from minimized state */ @@ -758,7 +762,8 @@ void GlfwApplication::setupCallbacks() { glfwSetCharCallback(_window, [](GLFWwindow* window, unsigned int codepoint) { auto& app = *static_cast(glfwGetWindowUserPointer(window)); - if(!(app._flags & Flag::TextInputActive)) return; + if(!(app._flags & Flag::TextInputActive)) + return; /* One extra byte to ensure it gets always null-terminated */ char utf8[4 + 1]{}; @@ -846,7 +851,8 @@ void GlfwApplication::setSwapInterval(const Int interval) { minimal loop period or not. Unlike SDL2 where it's possible to check whether the VSync was actually set, here it's purely hope-based. Sorry. */ - if(interval) _flags |= Flag::VSyncEnabled; + if(interval) + _flags |= Flag::VSyncEnabled; else _flags &= ~Flag::VSyncEnabled; } @@ -867,7 +873,8 @@ int GlfwApplication::exec() { bool GlfwApplication::mainLoopIteration() { /* If exit was requested directly in the constructor, exit immediately without calling anything else */ - if(_flags & Flag::Exit || glfwWindowShouldClose(_window)) return false; + if(_flags & Flag::Exit || glfwWindowShouldClose(_window)) + return false; CORRADE_ASSERT(_window, "Platform::GlfwApplication::mainLoopIteration(): no window opened", {}); @@ -891,14 +898,16 @@ bool GlfwApplication::mainLoopIteration() { which point the vtable pointers for the derived class are not set up yet). */ - if(glfwGetWindowUserPointer(_window) != this) setupCallbacks(); + if(glfwGetWindowUserPointer(_window) != this) + setupCallbacks(); const Nanoseconds timeBefore = _minimalLoopPeriodNanoseconds ? glfwGetTime()*1.0_sec : Nanoseconds{}; glfwPollEvents(); /* Tick event */ - if(!(_flags & Flag::NoTickEvent)) tickEvent(); + if(!(_flags & Flag::NoTickEvent)) + tickEvent(); /* Draw event */ if(_flags & Flag::Redraw) { @@ -924,7 +933,8 @@ bool GlfwApplication::mainLoopIteration() { /* Then, if the tick event doesn't need to be called periodically, wait indefinitely for next input event */ - if(_flags & Flag::NoTickEvent) glfwWaitEvents(); + if(_flags & Flag::NoTickEvent) + glfwWaitEvents(); return !(_flags & Flag::Exit || glfwWindowShouldClose(_window)); } @@ -934,7 +944,8 @@ void GlfwApplication::exit(int exitCode) { /* If the window is already created, tell GLFW that it should close. If not, this is done in tryCreate() once the window is created */ - if(_window) glfwSetWindowShouldClose(_window, true); + if(_window) + glfwSetWindowShouldClose(_window, true); } bool GlfwApplication::isKeyPressed(const Key key) { @@ -1195,7 +1206,8 @@ GlfwApplication::Pointers GlfwApplication::PointerMoveEvent::pointers() { } GlfwApplication::Modifiers GlfwApplication::PointerMoveEvent::modifiers() { - if(!_modifiers) _modifiers = currentGlfwModifiers(_window); + if(!_modifiers) + _modifiers = currentGlfwModifiers(_window); return *_modifiers; } @@ -1216,14 +1228,16 @@ auto GlfwApplication::MouseMoveEvent::buttons() -> Buttons { } GlfwApplication::Modifiers GlfwApplication::MouseMoveEvent::modifiers() { - if(!_modifiers) _modifiers = currentGlfwModifiers(_window); + if(!_modifiers) + _modifiers = currentGlfwModifiers(_window); return *_modifiers; } CORRADE_IGNORE_DEPRECATED_POP #endif GlfwApplication::Modifiers GlfwApplication::ScrollEvent::modifiers() { - if(!_modifiers) _modifiers = currentGlfwModifiers(_window); + if(!_modifiers) + _modifiers = currentGlfwModifiers(_window); return *_modifiers; } Vector2 GlfwApplication::ScrollEvent::position() { @@ -1248,7 +1262,8 @@ Vector2i GlfwApplication::MouseScrollEvent::position() { } GlfwApplication::Modifiers GlfwApplication::MouseScrollEvent::modifiers() { - if(!_modifiers) _modifiers = currentGlfwModifiers(_window); + if(!_modifiers) + _modifiers = currentGlfwModifiers(_window); return *_modifiers; } CORRADE_IGNORE_DEPRECATED_POP diff --git a/src/Magnum/Platform/ScreenedApplication.hpp b/src/Magnum/Platform/ScreenedApplication.hpp index 9d4b5d73f..a45209308 100644 --- a/src/Magnum/Platform/ScreenedApplication.hpp +++ b/src/Magnum/Platform/ScreenedApplication.hpp @@ -43,7 +43,8 @@ template void ApplicationKeyEventMixin::ca for(BasicScreen* s = screens.first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->keyPressEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } } @@ -54,7 +55,8 @@ template void ApplicationKeyEventMixin::ca for(BasicScreen* s = screens.first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->keyReleaseEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } } @@ -65,7 +67,8 @@ template void ApplicationScrollEventMixin: for(BasicScreen* s = screens.first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->scrollEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } @@ -89,7 +92,8 @@ template void ApplicationMouseScrollEventMixin* s = screens.first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->mouseScrollEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } } @@ -102,7 +106,8 @@ template void ApplicationTextInputEventMixin* s = screens.first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->textInputEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } } @@ -114,7 +119,8 @@ true>::callTextEditingEvent(typename Application::TextEditingEvent& event, Conta for(BasicScreen* s = screens.first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->textEditingEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } } @@ -199,7 +205,8 @@ template BasicScreenedApplication& BasicScreened BasicScreen(BasicScreenedApplication&, PropagatedEvents) as well. Keep in sync. */ Containers::LinkedList>::insert(&screen); - if(screens().first() == &screen) screen.focusEvent(); + if(screens().first() == &screen) + screen.focusEvent(); Application::redraw(); return *this; } @@ -219,7 +226,8 @@ template BasicScreenedApplication& BasicScreened "Platform::ScreenedApplication::focusScreen(): screen not owned by this application", *this); /* Already focused, nothing to do */ - if(screens().first() == &screen) return *this; + if(screens().first() == &screen) + return *this; screens().first()->blurEvent(); Containers::LinkedList>::move(&screen, screens().first()); @@ -234,7 +242,8 @@ template void BasicScreenedApplication::viewport /* Call global event before all other (to resize framebuffer first) */ globalViewportEvent(event); - for(BasicScreen& s: *this) s.viewportEvent(event); + for(BasicScreen& s: *this) + s.viewportEvent(event); } template void BasicScreenedApplication::globalBeforeDrawEvent() {} @@ -245,7 +254,8 @@ template void BasicScreenedApplication::drawEven /* Back-to-front rendering */ for(BasicScreen* s = screens().last(); s; s = s->nextNearerScreen()) - if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Draw) s->drawEvent(); + if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Draw) + s->drawEvent(); /* Call global event after all other (to swap buffers last) */ globalDrawEvent(); @@ -264,7 +274,8 @@ template void BasicScreenedApplication::pointerP for(BasicScreen* s = screens().first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->pointerPressEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } @@ -283,7 +294,8 @@ template void BasicScreenedApplication::pointerR for(BasicScreen* s = screens().first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->pointerReleaseEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } @@ -302,7 +314,8 @@ template void BasicScreenedApplication::pointerM for(BasicScreen* s = screens().first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->pointerMoveEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } @@ -323,7 +336,8 @@ template void BasicScreenedApplication::mousePre for(BasicScreen* s = screens().first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->mousePressEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } } @@ -333,7 +347,8 @@ template void BasicScreenedApplication::mouseRel for(BasicScreen* s = screens().first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->mouseReleaseEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } } @@ -343,7 +358,8 @@ template void BasicScreenedApplication::mouseMov for(BasicScreen* s = screens().first(); s; s = s->nextFartherScreen()) { if(s->propagatedEvents() & Implementation::PropagatedScreenEvent::Input) { s->mouseMoveEvent(event); - if(event.isAccepted()) break; + if(event.isAccepted()) + break; } } } diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index c2d7d46f5..fd864d48e 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -248,7 +248,8 @@ Sdl2Application::Sdl2Application(const Arguments& arguments, NoCreateT): } /* Save command-line arguments */ - if(args.value("log") == "verbose") _verboseLog = true; + if(args.value("log") == "verbose") + _verboseLog = true; const Containers::StringView dpiScaling = args.value("dpi-scaling"); if(dpiScaling == "default"_s) _commandLineDpiScalingPolicy = Implementation::Sdl2DpiScalingPolicy::Default; @@ -275,12 +276,14 @@ void Sdl2Application::create() { } void Sdl2Application::create(const Configuration& configuration) { - if(!tryCreate(configuration)) std::exit(1); + if(!tryCreate(configuration)) + std::exit(1); } #ifdef MAGNUM_TARGET_GL void Sdl2Application::create(const Configuration& configuration, const GLConfiguration& glConfiguration) { - if(!tryCreate(configuration, glConfiguration)) std::exit(1); + if(!tryCreate(configuration, glConfiguration)) + std::exit(1); } #endif @@ -897,7 +900,8 @@ bool Sdl2Application::setSwapInterval(const Int interval) { return false; } - if(interval) _flags |= Flag::VSyncEnabled; + if(interval) + _flags |= Flag::VSyncEnabled; else _flags &= ~Flag::VSyncEnabled; return true; } @@ -930,9 +934,11 @@ Sdl2Application::~Sdl2Application() { _context = Containers::NullOpt; #ifndef CORRADE_TARGET_EMSCRIPTEN - if(_glContext) SDL_GL_DeleteContext(_glContext); + if(_glContext) + SDL_GL_DeleteContext(_glContext); #else - if(_surface) SDL_FreeSurface(_surface); + if(_surface) + SDL_FreeSurface(_surface); #endif #endif @@ -942,7 +948,8 @@ Sdl2Application::~Sdl2Application() { #endif #ifndef CORRADE_TARGET_EMSCRIPTEN - if(_window) SDL_DestroyWindow(_window); + if(_window) + SDL_DestroyWindow(_window); #endif SDL_Quit(); } @@ -1007,7 +1014,8 @@ Sdl2Application::Pointers buttonsToPointers(const Uint32 buttons) { bool Sdl2Application::mainLoopIteration() { /* If exit was requested directly in the constructor, exit immediately without calling anything else */ - if(_flags & Flag::Exit) return false; + if(_flags & Flag::Exit) + return false; #ifndef CORRADE_TARGET_EMSCRIPTEN CORRADE_ASSERT(_window, "Platform::Sdl2Application::mainLoopIteration(): no window opened", {}); @@ -1084,10 +1092,12 @@ bool Sdl2Application::mainLoopIteration() { things not present in the Application APIs */ case SDL_WINDOWEVENT_EXPOSED: _flags |= Flag::Redraw; - if(!(_flags & Flag::NoAnyEvent)) anyEvent(event); + if(!(_flags & Flag::NoAnyEvent)) + anyEvent(event); break; default: - if(!(_flags & Flag::NoAnyEvent)) anyEvent(event); + if(!(_flags & Flag::NoAnyEvent)) + anyEvent(event); } break; case SDL_KEYDOWN: @@ -1282,12 +1292,14 @@ bool Sdl2Application::mainLoopIteration() { /* Direct everything else to anyEvent(), so users can implement event handling for things not present in the Application APIs */ - default: if(!(_flags & Flag::NoAnyEvent)) anyEvent(event); + default: if(!(_flags & Flag::NoAnyEvent)) + anyEvent(event); } } /* Tick event */ - if(!(_flags & Flag::NoTickEvent)) tickEvent(); + if(!(_flags & Flag::NoTickEvent)) + tickEvent(); /* Draw event */ if(_flags & Flag::Redraw) { @@ -1316,7 +1328,8 @@ bool Sdl2Application::mainLoopIteration() { /* Then, if the tick event doesn't need to be called periodically, wait indefinitely for next input event */ - if(_flags & Flag::NoTickEvent) SDL_WaitEvent(nullptr); + if(_flags & Flag::NoTickEvent) + SDL_WaitEvent(nullptr); #endif return !(_flags & Flag::Exit); } @@ -1416,7 +1429,8 @@ Sdl2Application::Cursor Sdl2Application::cursor() { SDL_Cursor* cursor = SDL_GetCursor(); if(cursor) for(UnsignedInt i = 0; i < sizeof(_cursors); i++) - if(_cursors[i] == cursor) return Cursor(i); + if(_cursors[i] == cursor) + return Cursor(i); return Cursor::Arrow; #else @@ -1713,7 +1727,8 @@ Sdl2Application::Modifiers Sdl2Application::PointerEvent::modifiers() { #ifdef MAGNUM_BUILD_DEPRECATED CORRADE_IGNORE_DEPRECATED_PUSH Sdl2Application::Modifiers Sdl2Application::MouseEvent::modifiers() { - if(_modifiers) return *_modifiers; + if(_modifiers) + return *_modifiers; return *(_modifiers = fixedModifiers(Uint16(SDL_GetModState()))); } CORRADE_IGNORE_DEPRECATED_POP @@ -1728,7 +1743,8 @@ Sdl2Application::Modifiers Sdl2Application::PointerMoveEvent::modifiers() { #ifdef MAGNUM_BUILD_DEPRECATED CORRADE_IGNORE_DEPRECATED_PUSH Sdl2Application::Modifiers Sdl2Application::MouseMoveEvent::modifiers() { - if(_modifiers) return *_modifiers; + if(_modifiers) + return *_modifiers; return *(_modifiers = fixedModifiers(Uint16(SDL_GetModState()))); } CORRADE_IGNORE_DEPRECATED_POP @@ -1755,14 +1771,16 @@ Sdl2Application::Modifiers Sdl2Application::ScrollEvent::modifiers() { #ifdef MAGNUM_BUILD_DEPRECATED CORRADE_IGNORE_DEPRECATED_PUSH Vector2i Sdl2Application::MouseScrollEvent::position() { - if(_position) return *_position; + if(_position) + return *_position; _position = Vector2i{}; SDL_GetMouseState(&_position->x(), &_position->y()); return *_position; } Sdl2Application::Modifiers Sdl2Application::MouseScrollEvent::modifiers() { - if(_modifiers) return *_modifiers; + if(_modifiers) + return *_modifiers; return *(_modifiers = fixedModifiers(Uint16(SDL_GetModState()))); } CORRADE_IGNORE_DEPRECATED_POP diff --git a/src/Magnum/Platform/Test/EmscriptenApplicationTest.cpp b/src/Magnum/Platform/Test/EmscriptenApplicationTest.cpp index 02842dd85..da1cf7a1d 100644 --- a/src/Magnum/Platform/Test/EmscriptenApplicationTest.cpp +++ b/src/Magnum/Platform/Test/EmscriptenApplicationTest.cpp @@ -386,7 +386,8 @@ struct EmscriptenApplicationTest: Platform::Application { } else if(event.key() == Key::F2) { _redraw = !_redraw; Debug{} << "redrawing" << (_redraw ? "enabled" : "disabled"); - if(_redraw) redraw(); + if(_redraw) + redraw(); } else if(event.key() == Key::Esc) { Debug{} << "stopping text input"; stopTextInput(); diff --git a/src/Magnum/Platform/Test/GlfwApplicationTest.cpp b/src/Magnum/Platform/Test/GlfwApplicationTest.cpp index 7a198c686..a24430660 100644 --- a/src/Magnum/Platform/Test/GlfwApplicationTest.cpp +++ b/src/Magnum/Platform/Test/GlfwApplicationTest.cpp @@ -322,7 +322,8 @@ struct GlfwApplicationTest: Platform::Application { } else if(event.key() == Key::F2) { _redraw = !_redraw; Debug{} << "redrawing" << (_redraw ? "enabled" : "disabled"); - if(_redraw) redraw(); + if(_redraw) + redraw(); } else if(event.key() == Key::V && !event.modifiers()) { _vsync = !_vsync; Debug{} << "vsync" << (_vsync? "on" : "off"); diff --git a/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp b/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp index 9372215fe..1f15e7867 100644 --- a/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp +++ b/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp @@ -405,7 +405,8 @@ struct Sdl2ApplicationTest: Platform::Application { } else if(event.key() == Key::F2) { _redraw = !_redraw; Debug{} << "redrawing" << (_redraw ? "enabled" : "disabled"); - if(_redraw) redraw(); + if(_redraw) + redraw(); } #ifndef CORRADE_TARGET_EMSCRIPTEN else if(event.key() == Key::V && !(event.modifiers() & ~(Modifier::CapsLock|Modifier::NumLock))) { @@ -500,7 +501,8 @@ struct Sdl2ApplicationTest: Platform::Application { void anyEvent(SDL_Event& event) override { Debug d; d << "any event:" << event.type; - if(event.type == SDL_WINDOWEVENT) d << event.window.event; + if(event.type == SDL_WINDOWEVENT) + d << event.window.event; } /* Uncomment to test the tick event. It should run at given minimal loop diff --git a/src/Magnum/Platform/WindowlessCglApplication.cpp b/src/Magnum/Platform/WindowlessCglApplication.cpp index a5eba49e3..e35ca4f9a 100644 --- a/src/Magnum/Platform/WindowlessCglApplication.cpp +++ b/src/Magnum/Platform/WindowlessCglApplication.cpp @@ -79,8 +79,10 @@ WindowlessCglContext::WindowlessCglContext(WindowlessCglContext&& other) noexcep } WindowlessCglContext::~WindowlessCglContext() { - if(_context) CGLDestroyContext(_context); - if(_pixelFormat) CGLDestroyPixelFormat(_pixelFormat); + if(_context) + CGLDestroyContext(_context); + if(_pixelFormat) + CGLDestroyPixelFormat(_pixelFormat); } WindowlessCglContext& WindowlessCglContext::operator=(WindowlessCglContext&& other) noexcept { @@ -121,7 +123,8 @@ WindowlessCglApplication::~WindowlessCglApplication() = default; void WindowlessCglApplication::createContext() { createContext({}); } void WindowlessCglApplication::createContext(const Configuration& configuration) { - if(!tryCreateContext(configuration)) std::exit(1); + if(!tryCreateContext(configuration)) + std::exit(1); } bool WindowlessCglApplication::tryCreateContext(const Configuration& configuration) { diff --git a/src/Magnum/Platform/WindowlessEglApplication.cpp b/src/Magnum/Platform/WindowlessEglApplication.cpp index 9283baaef..448e31b7e 100644 --- a/src/Magnum/Platform/WindowlessEglApplication.cpp +++ b/src/Magnum/Platform/WindowlessEglApplication.cpp @@ -615,7 +615,8 @@ WindowlessEglContext::~WindowlessEglContext() { eglDestroyContext(_display, _context); } #if defined(CORRADE_TARGET_WINDOWS) || (defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)) - if(_surface) eglDestroySurface(_display, _surface); + if(_surface) + eglDestroySurface(_display, _surface); #endif /* Don't terminate EGL if we're a shared context as it would kill all @@ -629,7 +630,8 @@ WindowlessEglContext::~WindowlessEglContext() { _display) eglTerminate(_display); #ifdef CORRADE_TARGET_WINDOWS - if(_window) DestroyWindow(_window); + if(_window) + DestroyWindow(_window); #endif } @@ -713,7 +715,8 @@ WindowlessEglApplication::WindowlessEglApplication(const Arguments& arguments, N void WindowlessEglApplication::createContext() { createContext({}); } void WindowlessEglApplication::createContext(const Configuration& configuration) { - if(!tryCreateContext(configuration)) std::exit(1); + if(!tryCreateContext(configuration)) + std::exit(1); } bool WindowlessEglApplication::tryCreateContext(const Configuration& configuration) { diff --git a/src/Magnum/Platform/WindowlessGlxApplication.cpp b/src/Magnum/Platform/WindowlessGlxApplication.cpp index 0cc776647..5b4855178 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.cpp +++ b/src/Magnum/Platform/WindowlessGlxApplication.cpp @@ -286,9 +286,12 @@ WindowlessGlxContext::WindowlessGlxContext(WindowlessGlxContext&& other) noexcep } WindowlessGlxContext::~WindowlessGlxContext() { - if(_context) glXDestroyContext(_display, _context); - if(_pbuffer) glXDestroyPbuffer(_display, _pbuffer); - if(_display) XCloseDisplay(_display); + if(_context) + glXDestroyContext(_display, _context); + if(_pbuffer) + glXDestroyPbuffer(_display, _pbuffer); + if(_display) + XCloseDisplay(_display); } WindowlessGlxContext& WindowlessGlxContext::operator=(WindowlessGlxContext&& other) noexcept { @@ -331,7 +334,8 @@ WindowlessGlxApplication::WindowlessGlxApplication(const Arguments& arguments, N void WindowlessGlxApplication::createContext() { createContext({}); } void WindowlessGlxApplication::createContext(const Configuration& configuration) { - if(!tryCreateContext(configuration)) std::exit(1); + if(!tryCreateContext(configuration)) + std::exit(1); } bool WindowlessGlxApplication::tryCreateContext(const Configuration& configuration) { diff --git a/src/Magnum/Platform/WindowlessWglApplication.cpp b/src/Magnum/Platform/WindowlessWglApplication.cpp index 8e51b679f..3d8a7a8b5 100644 --- a/src/Magnum/Platform/WindowlessWglApplication.cpp +++ b/src/Magnum/Platform/WindowlessWglApplication.cpp @@ -83,7 +83,8 @@ WindowlessWglContext::WindowlessWglContext(const Configuration& configuration, G the Windows API is horrible. HORRIBLE. */ HDC currentDeviceContext = wglGetCurrentDC(); _deviceContext = GetDC(_window); - if(!currentDeviceContext) currentDeviceContext = _deviceContext; + if(!currentDeviceContext) + currentDeviceContext = _deviceContext; /* Use first provided pixel format */ constexpr static const PIXELFORMATDESCRIPTOR pfd = { @@ -294,8 +295,10 @@ WindowlessWglContext::WindowlessWglContext(WindowlessWglContext&& other) noexcep } WindowlessWglContext::~WindowlessWglContext() { - if(_context) wglDeleteContext(_context); - if(_window) DestroyWindow(_window); + if(_context) + wglDeleteContext(_context); + if(_window) + DestroyWindow(_window); } WindowlessWglContext& WindowlessWglContext::operator=(WindowlessWglContext&& other) noexcept { @@ -338,7 +341,8 @@ WindowlessWglApplication::WindowlessWglApplication(const Arguments& arguments, N void WindowlessWglApplication::createContext() { createContext({}); } void WindowlessWglApplication::createContext(const Configuration& configuration) { - if(!tryCreateContext(configuration)) std::exit(1); + if(!tryCreateContext(configuration)) + std::exit(1); } bool WindowlessWglApplication::tryCreateContext(const Configuration& configuration) { diff --git a/src/Magnum/Platform/gl-info.cpp b/src/Magnum/Platform/gl-info.cpp index 8083594aa..35b4dd45a 100644 --- a/src/Magnum/Platform/gl-info.cpp +++ b/src/Magnum/Platform/gl-info.cpp @@ -394,7 +394,8 @@ GLInfo::GLInfo(const Arguments& arguments): Platform::WindowlessApplication{argu return; } - if(args.isSet("short")) return; + if(args.isSet("short")) + return; Debug{} << ""; @@ -455,7 +456,8 @@ GLInfo::GLInfo(const Arguments& arguments): Platform::WindowlessApplication{argu Debug{} << ""; } - if(!args.isSet("limits")) return; + if(!args.isSet("limits")) + return; /* Limits and implementation-defined values */ #define _h(val) Debug{} << "\n " << GL::Extensions::val::string() << Debug::nospace << ":"; diff --git a/src/Magnum/Primitives/Cone.cpp b/src/Magnum/Primitives/Cone.cpp index c8050ae69..7e4201945 100644 --- a/src/Magnum/Primitives/Cone.cpp +++ b/src/Magnum/Primitives/Cone.cpp @@ -54,7 +54,8 @@ Trade::MeshData coneSolid(const UnsignedInt rings, const UnsignedInt segments, c cone.cylinderVertexRings(rings+1, -halfLength, {-1.0f/rings, length/rings}, textureCoordsV, length/(rings*(flags & ConeFlag::CapEnd ? length + 1.0f : length))); /* Faces. Account for the extra vertices for caps and texture coords. */ - if(flags & ConeFlag::CapEnd) cone.bottomFaceRing(); + if(flags & ConeFlag::CapEnd) + cone.bottomFaceRing(); if(flags & ConeFlag::CapEnd && flags & (ConeFlag::Tangents|ConeFlag::TextureCoordinates)) cone.faceRings(rings, 2 + segments); else if(flags & ConeFlag::CapEnd) diff --git a/src/Magnum/Primitives/Cylinder.cpp b/src/Magnum/Primitives/Cylinder.cpp index 3aff9ebe4..7c6529b46 100644 --- a/src/Magnum/Primitives/Cylinder.cpp +++ b/src/Magnum/Primitives/Cylinder.cpp @@ -60,14 +60,16 @@ Trade::MeshData cylinderSolid(const UnsignedInt rings, const UnsignedInt segment } /* Faces. Account for the extra vertices for caps and texture coords. */ - if(flags & CylinderFlag::CapEnds) cylinder.bottomFaceRing(); + if(flags & CylinderFlag::CapEnds) + cylinder.bottomFaceRing(); if(flags & CylinderFlag::CapEnds && flags & (CylinderFlag::TextureCoordinates|CylinderFlag::Tangents)) cylinder.faceRings(rings, 2 + segments); else if(flags & CylinderFlag::CapEnds) cylinder.faceRings(rings, 1 + segments); else cylinder.faceRings(rings, 0); - if(flags & CylinderFlag::CapEnds) cylinder.topFaceRing(); + if(flags & CylinderFlag::CapEnds) + cylinder.topFaceRing(); return cylinder.finalize(); } diff --git a/src/Magnum/Primitives/Grid.cpp b/src/Magnum/Primitives/Grid.cpp index 6036147d0..b3720c070 100644 --- a/src/Magnum/Primitives/Grid.cpp +++ b/src/Magnum/Primitives/Grid.cpp @@ -99,7 +99,8 @@ Trade::MeshData grid3DSolid(const Vector2i& subdivisions, const GridFlags flags) attributes[attributeIndex++] = Trade::MeshAttributeData{Trade::MeshAttribute::Normal, normals}; attributeOffset += sizeof(Vector3); - for(auto&& i: normals) i = Vector3::zAxis(1.0f); + for(auto&& i: normals) + i = Vector3::zAxis(1.0f); } if(flags & GridFlag::Tangents) { Containers::StridedArrayView1D tangents{vertexData, @@ -108,7 +109,8 @@ Trade::MeshData grid3DSolid(const Vector2i& subdivisions, const GridFlags flags) attributes[attributeIndex++] = Trade::MeshAttributeData{Trade::MeshAttribute::Tangent, tangents}; attributeOffset += sizeof(Vector4); - for(auto&& i: tangents) i = {1.0f, 0.0f, 0.0f, 1.0f}; + for(auto&& i: tangents) + i = {1.0f, 0.0f, 0.0f, 1.0f}; } if(flags & GridFlag::TextureCoordinates) { diff --git a/src/Magnum/Primitives/Plane.cpp b/src/Magnum/Primitives/Plane.cpp index 44e61d9ca..196a00b18 100644 --- a/src/Magnum/Primitives/Plane.cpp +++ b/src/Magnum/Primitives/Plane.cpp @@ -66,7 +66,8 @@ Trade::MeshData planeSolid() { Trade::MeshData planeSolid(const PlaneFlags flags) { /* Return the compile-time data if nothing extra is requested */ - if(!flags) return planeSolid(); + if(!flags) + return planeSolid(); /* Calculate attribute count and vertex size */ std::size_t stride = sizeof(Vector3) + sizeof(Vector3); diff --git a/src/Magnum/Resource.h b/src/Magnum/Resource.h index 71bfdac3d..c30474b6c 100644 --- a/src/Magnum/Resource.h +++ b/src/Magnum/Resource.h @@ -189,7 +189,8 @@ class /** @brief Copy constructor */ CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */ Resource(const Resource& other): _manager{other._manager}, _key{other._key}, _lastCheck{other._lastCheck}, _state{other._state}, _data{other._data} { - if(_manager) _manager->incrementReferenceCount(_key); + if(_manager) + _manager->incrementReferenceCount(_key); } CORRADE_IGNORE_DEPRECATED_POP @@ -200,7 +201,8 @@ class /** @brief Destructor */ ~Resource() { - if(_manager) _manager->decrementReferenceCount(_key); + if(_manager) + _manager->decrementReferenceCount(_key); } /** @brief Copy assignment */ @@ -329,7 +331,8 @@ class CORRADE_IGNORE_DEPRECATED_PUSH template Resource& Resource::operator=(const Resource& other) { - if(_manager) _manager->decrementReferenceCount(_key); + if(_manager) + _manager->decrementReferenceCount(_key); _manager = other._manager; _key = other._key; @@ -337,7 +340,8 @@ template Resource& Resource::operator=(const Resou _state = other._state; _data = other._data; - if(_manager) _manager->incrementReferenceCount(_key); + if(_manager) + _manager->incrementReferenceCount(_key); return *this; } @@ -361,10 +365,12 @@ template Resource& Resource::operator=(Resource void Resource::acquire() { /* The data are already final, nothing to do */ - if(_state == ResourceState::Final) return; + if(_state == ResourceState::Final) + return; /* Nothing changed since last check */ - if(_manager->lastChange() <= _lastCheck) return; + if(_manager->lastChange() <= _lastCheck) + return; /* Acquire new data and save last check time */ const typename Implementation::ResourceManagerData::Data& d = _manager->data(_key); diff --git a/src/Magnum/ResourceManager.h b/src/Magnum/ResourceManager.h index 6eca0afd2..3b509017a 100644 --- a/src/Magnum/ResourceManager.h +++ b/src/Magnum/ResourceManager.h @@ -536,7 +536,8 @@ template ResourceManagerData::~ResourceManagerData() { template std::size_t ResourceManagerData::referenceCount(const ResourceKey key) const { auto it = _data.find(key); - if(it == _data.end()) return 0; + if(it == _data.end()) + return 0; return it->second.referenceCount; } @@ -617,11 +618,13 @@ template void ResourceManagerData::setLoader(AbstractResourceLoader< delete _loader; /* Add new loader */ - if((_loader = loader)) _loader->manager = this; + if((_loader = loader)) + _loader->manager = this; } template void ResourceManagerData::freeLoader() { - if(!_loader) return; + if(!_loader) + return; _loader->manager = nullptr; delete _loader; diff --git a/src/Magnum/SceneGraph/AbstractGroupedFeature.h b/src/Magnum/SceneGraph/AbstractGroupedFeature.h index 18be30334..3ebb13f8d 100644 --- a/src/Magnum/SceneGraph/AbstractGroupedFeature.h +++ b/src/Magnum/SceneGraph/AbstractGroupedFeature.h @@ -76,7 +76,8 @@ template class AbstractGroupedFe * @see @ref FeatureGroup::add() */ explicit AbstractGroupedFeature(AbstractObject& object, FeatureGroup* group = nullptr): AbstractFeature(object), _group(nullptr) { - if(group) group->add(static_cast(*this)); + if(group) + group->add(static_cast(*this)); } /** @@ -86,7 +87,8 @@ template class AbstractGroupedFe * any. */ ~AbstractGroupedFeature() { - if(_group) _group->remove(static_cast(*this)); + if(_group) + _group->remove(static_cast(*this)); } /** @brief Group this feature belongs to */ diff --git a/src/Magnum/SceneGraph/AbstractObject.h b/src/Magnum/SceneGraph/AbstractObject.h index 34c6c16b7..81a3cbcdc 100644 --- a/src/Magnum/SceneGraph/AbstractObject.h +++ b/src/Magnum/SceneGraph/AbstractObject.h @@ -207,7 +207,8 @@ template class AbstractObject * possible. */ static void setClean(const std::vector>>& objects) { - if(objects.empty()) return; + if(objects.empty()) + return; objects.front().get().doSetClean(objects); } diff --git a/src/Magnum/SceneGraph/Animable.hpp b/src/Magnum/SceneGraph/Animable.hpp index 89a391afb..c46025298 100644 --- a/src/Magnum/SceneGraph/Animable.hpp +++ b/src/Magnum/SceneGraph/Animable.hpp @@ -47,7 +47,8 @@ template Animable::~Animable() { } template Animable& Animable::setState(AnimationState state) { - if(_currentState == state) return *this; + if(_currentState == state) + return *this; /* Not allowed (for sanity) */ if(_previousState == AnimationState::Stopped && state == AnimationState::Paused) @@ -68,7 +69,8 @@ template const AnimableGroup* An } template void AnimableGroup::step(const Float time, const Float delta) { - if(!_runningCount && !wakeUp) return; + if(!_runningCount && !wakeUp) + return; wakeUp = false; for(std::size_t i = 0; i != AnimableGroup::size(); ++i) { diff --git a/src/Magnum/SceneGraph/FeatureGroup.h b/src/Magnum/SceneGraph/FeatureGroup.h index 4c94111e0..b82f209f5 100644 --- a/src/Magnum/SceneGraph/FeatureGroup.h +++ b/src/Magnum/SceneGraph/FeatureGroup.h @@ -175,7 +175,8 @@ template using FeatureGroup3D = BasicFeatureGroup3D FeatureGroup::~FeatureGroup() { - for(auto i: AbstractFeatureGroup::_features) static_cast(i.get())._group = nullptr; + for(auto i: AbstractFeatureGroup::_features) + static_cast(i.get())._group = nullptr; } template FeatureGroup& FeatureGroup::add(Feature& feature) { diff --git a/src/Magnum/SceneGraph/Object.hpp b/src/Magnum/SceneGraph/Object.hpp index f4b941684..e0d89b4df 100644 --- a/src/Magnum/SceneGraph/Object.hpp +++ b/src/Magnum/SceneGraph/Object.hpp @@ -52,13 +52,15 @@ template Object::~Object() = default; template Scene* Object::scene() { Object* p(this); - while(p && !p->isScene()) p = p->parent(); + while(p && !p->isScene()) + p = p->parent(); return static_cast*>(p); } template const Scene* Object::scene() const { const Object* p(this); - while(p && !p->isScene()) p = p->parent(); + while(p && !p->isScene()) + p = p->parent(); return static_cast*>(p); } @@ -81,21 +83,25 @@ template const Object* Object Object& Object::setParent(Object* parent) { /* Skip if parent is already parent or this is scene (which cannot have parent) */ /** @todo Assert for setting parent to scene */ - if(this->parent() == parent || isScene()) return *this; + if(this->parent() == parent || isScene()) + return *this; /* Object cannot be parented to its child */ Object* p = parent; while(p) { /** @todo Assert for this */ - if(p == this) return *this; + if(p == this) + return *this; p = p->parent(); } /* Remove the object from old parent children list */ - if(this->parent()) this->parent()->Containers::template LinkedList>::cut(this); + if(this->parent()) + this->parent()->Containers::template LinkedList>::cut(this); /* Add the object to list of new parent */ - if(parent) parent->Containers::LinkedList>::insert(this); + if(parent) + parent->Containers::LinkedList>::insert(this); setDirty(); return *this; @@ -113,14 +119,16 @@ template Object& Object::s } template typename Transformation::DataType Object::absoluteTransformation() const { - if(!parent()) return Transformation::transformation(); + if(!parent()) + return Transformation::transformation(); return Implementation::Transformation::compose(parent()->absoluteTransformation(), Transformation::transformation()); } template void Object::setDirty() { /* The transformation of this object (and all children) is already dirty, nothing to do */ - if(flags & Flag::Dirty) return; + if(flags & Flag::Dirty) + return; /* Make all features dirty */ for(AbstractFeature& feature: this->features()) @@ -136,7 +144,8 @@ template void Object::setDirty() { template void Object::setClean() { /* The object (and all its parents) are already clean, nothing to do */ - if(!(flags & Flag::Dirty)) return; + if(!(flags & Flag::Dirty)) + return; /* Collect all parents, compute base transformation */ std::stack*> objects; @@ -148,7 +157,8 @@ template void Object::setClean() { p = p->parent(); /* On root object, base transformation is identity */ - if(!p) break; + if(!p) + break; /* Parent object is clean, base transformation is its absolute transformation */ @@ -175,7 +185,8 @@ template auto Object::doTransformationMatr std::vector>> castObjects; castObjects.reserve(objects.size()); /** @todo Ensure this doesn't crash, somehow */ - for(auto o: objects) castObjects.push_back(static_cast&>(o.get())); + for(auto o: objects) + castObjects.push_back(static_cast&>(o.get())); return transformationMatrices(std::move(castObjects), finalTransformationMatrix); } @@ -214,7 +225,8 @@ template std::vector Ob for(std::size_t i = 0; i != objects.size(); ++i) { /* Multiple occurrences of one object in the array, don't overwrite it with different counter */ - if(objects[i].get().counter != ~UnsignedInt{}) continue; + if(objects[i].get().counter != ~UnsignedInt{}) + continue; objects[i].get().counter = UnsignedInt(i); objects[i].get().flags |= Flag::Joint; @@ -267,7 +279,8 @@ template std::vector Ob } else *it = *parent; /* Cycle if reached end */ - if(it == objects.end()) it = objects.begin(); + if(it == objects.end()) + it = objects.begin(); } /* Array of absolute transformations in joints */ @@ -303,7 +316,8 @@ template typename Transformation::DataType Object void Object::doSetClean(const std std::vector>> castObjects; castObjects.reserve(objects.size()); /** @todo Ensure this doesn't crash, somehow */ - for(auto o: objects) castObjects.push_back(static_cast&>(o.get())); + for(auto o: objects) + castObjects.push_back(static_cast&>(o.get())); setClean(std::move(castObjects)); } @@ -350,7 +365,8 @@ template void Object::setClean(std::vector objects.erase(firstClean, objects.end()); /* No dirty objects left, done */ - if(objects.empty()) return; + if(objects.empty()) + return; /* Add non-clean parents to the list. Mark each added object as visited, so they aren't added more than once */ @@ -366,7 +382,8 @@ template void Object::setClean(std::vector } /* Cleanup all marks */ - for(auto o: objects) o.get().flags &= ~Flag::Visited; + for(auto o: objects) + o.get().flags &= ~Flag::Visited; /* Compute absolute transformations */ Scene* scene = objects[0].get().scene(); @@ -376,7 +393,8 @@ template void Object::setClean(std::vector /* Go through all objects and clean them */ for(std::size_t i = 0; i != objects.size(); ++i) { /* The object might be duplicated in the list, don't clean it more than once */ - if(!objects[i].get().isDirty()) continue; + if(!objects[i].get().isDirty()) + continue; objects[i].get().setCleanInternal(transformations[i]); CORRADE_ASSERT(!objects[i].get().isDirty(), "SceneGraph::Object::setClean(): original implementation was not called", ); diff --git a/src/Magnum/SceneGraph/Test/ObjectTest.cpp b/src/Magnum/SceneGraph/Test/ObjectTest.cpp index caae92c7a..82989561e 100644 --- a/src/Magnum/SceneGraph/Test/ObjectTest.cpp +++ b/src/Magnum/SceneGraph/Test/ObjectTest.cpp @@ -612,7 +612,8 @@ template void ObjectTest::rangeBasedForChildren() { Object3D c{&scene}; std::vector*> objects; - for(auto&& i: scene.children()) objects.push_back(&i); + for(auto&& i: scene.children()) + objects.push_back(&i); CORRADE_COMPARE(objects, (std::vector*>{&a, &b, &c})); } @@ -629,7 +630,8 @@ template void ObjectTest::rangeBasedForFeatures() { Feature c{object}; std::vector*> features; - for(auto&& i: object.features()) features.push_back(&i); + for(auto&& i: object.features()) + features.push_back(&i); CORRADE_COMPARE(features, (std::vector*>{&a, &b, &c})); } diff --git a/src/Magnum/SceneTools/FlattenMeshHierarchy.cpp b/src/Magnum/SceneTools/FlattenMeshHierarchy.cpp index 68ab9cdf4..a0355f0d6 100644 --- a/src/Magnum/SceneTools/FlattenMeshHierarchy.cpp +++ b/src/Magnum/SceneTools/FlattenMeshHierarchy.cpp @@ -64,7 +64,8 @@ template void flattenMeshHierarchyIntoImplementation(con const Containers::Optional meshFieldId = scene.findFieldId(Trade::SceneField::Mesh); /* If there's no mesh field in the file, nothing to do. This is how the original API behaved, it's an assertion in the new one. */ - if(!meshFieldId) return; + if(!meshFieldId) + return; DimensionTraits::flattenInto(scene, *meshFieldId, outputTransformations, globalTransformation); } @@ -73,7 +74,8 @@ template Containers::Array meshFieldId = scene.findFieldId(Trade::SceneField::Mesh); /* If there's no mesh field in the file, nothing to do. This is how the original API behaved, it's an assertion in the new one. */ - if(!meshFieldId) return {}; + if(!meshFieldId) + return {}; /* Get the transformations. This will be a no-op if the mesh field isn't present, but will go through other assertions that may still be rather diff --git a/src/Magnum/SceneTools/Implementation/combine.h b/src/Magnum/SceneTools/Implementation/combine.h index 0f590ead1..a0fa2fba7 100644 --- a/src/Magnum/SceneTools/Implementation/combine.h +++ b/src/Magnum/SceneTools/Implementation/combine.h @@ -65,12 +65,14 @@ template void combineCopyMappings(const Containers::ArrayView(src, sceneFieldTypeSize(fieldType)*(field.fieldArraySize() ? field.fieldArraySize() : 1)), itemViews[itemViewMappings[i].second()].types); diff --git a/src/Magnum/SceneTools/Implementation/convertToSingleFunctionObjects.h b/src/Magnum/SceneTools/Implementation/convertToSingleFunctionObjects.h index 34d8f0b0f..a006d4e22 100644 --- a/src/Magnum/SceneTools/Implementation/convertToSingleFunctionObjects.h +++ b/src/Magnum/SceneTools/Implementation/convertToSingleFunctionObjects.h @@ -42,7 +42,8 @@ namespace Magnum { namespace SceneTools { namespace Implementation { inline Containers::Optional findField(Containers::ArrayView fields, Trade::SceneField field) { for(std::size_t i = 0; i != fields.size(); ++i) - if(fields[i] == field) return i; + if(fields[i] == field) + return i; return {}; } @@ -71,7 +72,8 @@ inline Trade::SceneData convertToSingleFunctionObjects(const Trade::SceneData& s /* Skip fields that are not present -- is it's not present, then it definitely won't be responsible for multi-function objects */ const Containers::Optional fieldId = scene.findFieldId(field); - if(!fieldId) continue; + if(!fieldId) + continue; /** @todo use a statically-allocated array & Into() in a loop instead once this is more than a private backwards-compatibility utility @@ -92,7 +94,8 @@ inline Trade::SceneData convertToSingleFunctionObjects(const Trade::SceneData& s /* Skip fields that are not present */ const Containers::Optional fieldId = scene.findFieldId(field); - if(!fieldId) continue; + if(!fieldId) + continue; /** @todo use a statically-allocated array & Into() in a loop instead once this is more than a private backwards-compatibility utility @@ -105,8 +108,8 @@ inline Trade::SceneData convertToSingleFunctionObjects(const Trade::SceneData& s } UnsignedInt objectsToAdd = 0; - for(const UnsignedInt count: objectAttachmentCount) - if(count > 1) objectsToAdd += count - 1; + for(const UnsignedInt count: objectAttachmentCount) if(count > 1) + objectsToAdd += count - 1; /* Ensure we don't overflow the 32-bit object count with the objects to add. This should also cover the case when the parent field would not be @@ -171,7 +174,8 @@ inline Trade::SceneData convertToSingleFunctionObjects(const Trade::SceneData& s const Trade::SceneField field = fieldsToCopy[i]; const Containers::Optional fieldId = scene.findFieldId(field); - if(!fieldId) continue; + if(!fieldId) + continue; const Containers::StridedArrayView1D outMapping = out.mutableMapping(*fieldId); const Containers::StridedArrayView2D outField = out.mutableField(*fieldId); @@ -201,7 +205,8 @@ inline Trade::SceneData convertToSingleFunctionObjects(const Trade::SceneData& s std::size_t newParentIndex = 0; for(const Trade::SceneField field: fieldsToConvert) { const Containers::Optional fieldId = scene.findFieldId(field); - if(!fieldId) continue; + if(!fieldId) + continue; for(UnsignedInt& fieldObject: out.mutableMapping(*fieldId)) { /* If the object is not new (could happen when an object @@ -215,7 +220,8 @@ inline Trade::SceneData convertToSingleFunctionObjects(const Trade::SceneData& s was assigned to the original object */ for(std::size_t i = 0; i != fieldsToCopy.size(); ++i) { const Containers::Optional fieldToCopyId = scene.findFieldId(fieldsToCopy[i]); - if(!fieldToCopyId) continue; + if(!fieldToCopyId) + continue; /* View to copy the data from */ const Containers::StridedArrayView2D fieldToCopyDataSrc = scene.field(*fieldToCopyId); diff --git a/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h b/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h index 5944d4867..e3097ece1 100644 --- a/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h +++ b/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h @@ -273,7 +273,8 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility } if(objectInfos) for(const UnsignedInt object: scene->mappingAsArray(j)) { - if(object >= objectInfos.size()) continue; + if(object >= objectInfos.size()) + continue; objectInfos[object].object = object; objectInfos[object].scenes |= 1 << i; @@ -616,7 +617,8 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility const auto printObjectFieldInfo = [&sceneFieldNames](Debug& d, const ObjectInfo& info) { for(std::size_t i = 0; i != info.fields.size(); ++i) { - if(i) d << Debug::nospace << ","; + if(i) + d << Debug::nospace << ","; const Containers::Pair nameCount = info.fields[i]; d << Debug::color(Debug::Color::Cyan); if(Trade::isSceneFieldCustom(nameCount.first())) { @@ -638,7 +640,8 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility for(const SceneInfo& info: sceneInfos) { Debug d{useColor}; d << Debug::boldColor(Debug::Color::Default) << "Scene" << info.scene << Debug::nospace << ":" << Debug::resetColor; - if(info.name) d << Debug::boldColor(Debug::Color::Yellow) << info.name << Debug::resetColor; + if(info.name) + d << Debug::boldColor(Debug::Color::Yellow) << info.name << Debug::resetColor; d << Debug::newline; d << " Bound:" << info.mappingBound << "objects" << Debug::color(Debug::Color::Blue) << "@" << Debug::packed @@ -719,21 +722,25 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility if(!args.isSet("object-hierarchy")) for(const ObjectInfo& info: objectInfos) { /* Objects without a name and not referenced by any scenes are useless, ignore */ - if(!info.name && !info.scenes) continue; + if(!info.name && !info.scenes) + continue; Debug d{useColor}; d << Debug::boldColor(Debug::Color::Default) << "Object" << info.object << Debug::resetColor; if(sceneInfos) { const UnsignedInt count = Math::popcount(info.scenes); - if(!count) d << Debug::color(Debug::Color::Red); + if(!count) + d << Debug::color(Debug::Color::Red); d << "(referenced by" << count << "scenes)"; - if(!count) d << Debug::resetColor; + if(!count) + d << Debug::resetColor; } d << Debug::boldColor(Debug::Color::Default) << Debug::nospace << ":" << Debug::resetColor; - if(info.name) d << Debug::boldColor(Debug::Color::Yellow) + if(info.name) + d << Debug::boldColor(Debug::Color::Yellow) << info.name << Debug::resetColor; if(info.scenes) { d << Debug::newline << " Fields:"; @@ -745,7 +752,8 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility for(const AnimationInfo& info: animationInfos) { Debug d{useColor}; d << Debug::boldColor(Debug::Color::Default) << "Animation" << info.animation << Debug::nospace << ":" << Debug::resetColor; - if(info.name) d << Debug::boldColor(Debug::Color::Yellow) << info.name << Debug::resetColor; + if(info.name) + d << Debug::boldColor(Debug::Color::Yellow) << info.name << Debug::resetColor; d << Debug::newline << " Duration: {" << Debug::nospace /** @todo have a nice packed printing for Range instead */ @@ -813,9 +821,11 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility (!info.twoDimensions && skin3DReferenceCount)) { const UnsignedInt count = info.twoDimensions ? skin2DReferenceCount[info.skin] : skin3DReferenceCount[info.skin]; - if(!count) d << Debug::color(Debug::Color::Red); + if(!count) + d << Debug::color(Debug::Color::Red); d << "(referenced by" << count << "objects)"; - if(!count) d << Debug::resetColor; + if(!count) + d << Debug::resetColor; } d << Debug::boldColor(Debug::Color::Default) << Debug::nospace << ":" @@ -834,9 +844,11 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility were parsed, otherwise this information is useless */ if(lightReferenceCount) { const UnsignedInt count = lightReferenceCount[info.light]; - if(!count) d << Debug::color(Debug::Color::Red); + if(!count) + d << Debug::color(Debug::Color::Red); d << "(referenced by" << count << "objects)"; - if(!count) d << Debug::resetColor; + if(!count) + d << Debug::resetColor; } d << Debug::boldColor(Debug::Color::Default) << Debug::nospace << ":" @@ -875,9 +887,11 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility were parsed, otherwise this information is useless */ if(cameraReferenceCount) { const UnsignedInt count = cameraReferenceCount[info.camera]; - if(!count) d << Debug::color(Debug::Color::Red); + if(!count) + d << Debug::color(Debug::Color::Red); d << "(referenced by" << count << "objects)"; - if(!count) d << Debug::resetColor; + if(!count) + d << Debug::resetColor; } d << Debug::boldColor(Debug::Color::Default) << Debug::nospace << ":" @@ -910,14 +924,17 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility were parsed, otherwise this information is useless */ if(materialReferenceCount) { const UnsignedInt count = materialReferenceCount[info.material]; - if(!count) d << Debug::color(Debug::Color::Red); + if(!count) + d << Debug::color(Debug::Color::Red); d << "(referenced by" << count << "objects)"; - if(!count) d << Debug::resetColor; + if(!count) + d << Debug::resetColor; } d << Debug::boldColor(Debug::Color::Default) << Debug::nospace << ":" << Debug::resetColor; - if(info.name) d << Debug::boldColor(Debug::Color::Yellow) << info.name << Debug::resetColor; + if(info.name) + d << Debug::boldColor(Debug::Color::Yellow) << info.name << Debug::resetColor; d << Debug::newline << " Type:" << Debug::packed << Debug::color(Debug::Color::Cyan) << info.data.types() << Debug::resetColor; @@ -1028,14 +1045,17 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility were parsed, otherwise this information is useless */ if(meshReferenceCount) { const UnsignedInt count = meshReferenceCount[info.mesh]; - if(!count) d << Debug::color(Debug::Color::Red); + if(!count) + d << Debug::color(Debug::Color::Red); d << "(referenced by" << count << "objects)"; - if(!count) d << Debug::resetColor; + if(!count) + d << Debug::resetColor; } d << Debug::boldColor(Debug::Color::Default) << Debug::nospace << ":" << Debug::resetColor; - if(info.name) d << Debug::boldColor(Debug::Color::Yellow) << info.name << Debug::resetColor; + if(info.name) + d << Debug::boldColor(Debug::Color::Yellow) << info.name << Debug::resetColor; d << Debug::newline; } d << " Level" << info.level << Debug::nospace << ":" @@ -1100,9 +1120,11 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility were parsed, otherwise this information is useless */ if(textureReferenceCount) { const UnsignedInt count = textureReferenceCount[info.texture]; - if(!count) d << Debug::color(Debug::Color::Red); + if(!count) + d << Debug::color(Debug::Color::Red); d << "(referenced by" << count << "material attributes)"; - if(!count) d << Debug::resetColor; + if(!count) + d << Debug::resetColor; } d << Debug::boldColor(Debug::Color::Default) << Debug::nospace << ":" diff --git a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp index 3d66fdc42..ddea96279 100644 --- a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp +++ b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp @@ -257,15 +257,21 @@ void SceneConverterImplementationTest::infoScenesObjects() { return id == 0 ? "A simple scene" : ""; } Containers::String doObjectName(UnsignedLong id) override { - if(id == 0) return "Parent-less mesh"; - if(id == 2) return "Two meshes, shared among two scenes"; - if(id == 4) return "Two custom arrays"; - if(id == 6) return "Only in the second scene, but no fields, thus same as unreferenced"; - if(id == 8) return "Not in any scene"; + if(id == 0) + return "Parent-less mesh"; + if(id == 2) + return "Two meshes, shared among two scenes"; + if(id == 4) + return "Two custom arrays"; + if(id == 6) + return "Only in the second scene, but no fields, thus same as unreferenced"; + if(id == 8) + return "Not in any scene"; return ""; } Containers::String doSceneFieldName(Trade::SceneField name) override { - if(name == Trade::sceneFieldCustom(1337)) return "directionVector"; + if(name == Trade::sceneFieldCustom(1337)) + return "directionVector"; return ""; } Containers::Optional doScene(UnsignedInt id) override { @@ -434,12 +440,13 @@ void SceneConverterImplementationTest::infoSkins() { } Containers::Optional doSkin2D(UnsignedInt id) override { /* First a regular skin, second externally owned */ - if(id == 0) return Trade::SkinData2D{ - {3, 6, 7, 12, 22}, - {{}, {}, {}, {}, {}} - }; + if(id == 0) + return Trade::SkinData2D{ + {3, 6, 7, 12, 22}, + {{}, {}, {}, {}, {}}}; - if(id == 1) return Trade::SkinData2D{Trade::DataFlag::ExternallyOwned, skin2JointData, Trade::DataFlag::ExternallyOwned, skin2MatrixData}; + if(id == 1) + return Trade::SkinData2D{Trade::DataFlag::ExternallyOwned, skin2JointData, Trade::DataFlag::ExternallyOwned, skin2MatrixData}; CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } @@ -451,7 +458,8 @@ void SceneConverterImplementationTest::infoSkins() { Containers::Optional doSkin3D(UnsignedInt id) override { /* Reverse order in 3D, plus one more to ensure the count isn't mismatched between 2D and 3D */ - if(id == 0) return Trade::SkinData3D{Trade::DataFlag::ExternallyOwned, skin3JointData, Trade::DataFlag::ExternallyOwned, skin3MatrixData}; + if(id == 0) + return Trade::SkinData3D{Trade::DataFlag::ExternallyOwned, skin3JointData, Trade::DataFlag::ExternallyOwned, skin3MatrixData}; if(id == 1) return Trade::SkinData3D{ {3, 22}, @@ -691,10 +699,13 @@ void SceneConverterImplementationTest::infoMeshes() { return id == 1 ? "LODs? No, meshlets." : ""; } Containers::String doMeshAttributeName(Trade::MeshAttribute name) override { - if(name == Trade::meshAttributeCustom(25)) return "vertices"; - if(name == Trade::meshAttributeCustom(26)) return "triangles"; + if(name == Trade::meshAttributeCustom(25)) + return "vertices"; + if(name == Trade::meshAttributeCustom(26)) + return "triangles"; /* 37 (triangleCount) deliberately not named */ - if(name == Trade::meshAttributeCustom(116)) return "vertexCount"; + if(name == Trade::meshAttributeCustom(116)) + return "vertexCount"; return ""; } @@ -742,7 +753,8 @@ void SceneConverterImplementationTest::infoMeshes() { } /* Third is an empty instance mesh */ - if(id == 2 && level == 0) return Trade::MeshData{MeshPrimitive::Instances, 15}; + if(id == 2 && level == 0) + return Trade::MeshData{MeshPrimitive::Instances, 15}; CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } @@ -1102,7 +1114,8 @@ void SceneConverterImplementationTest::infoReferenceCount() { {Trade::MaterialAttribute::NormalTexture, 17u}, {Trade::MaterialAttribute::EmissiveTexture, 4u}, }}; - if(id == 2) return Trade::MaterialData{{}, {}}; + if(id == 2) + return Trade::MaterialData{{}, {}}; CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } @@ -1111,9 +1124,12 @@ void SceneConverterImplementationTest::infoReferenceCount() { return id == 1 ? "Not referenced" : ""; } Containers::Optional doMesh(UnsignedInt id, UnsignedInt) override { - if(id == 0) return Trade::MeshData{MeshPrimitive::Points, 5}; - if(id == 1) return Trade::MeshData{MeshPrimitive::Lines, 4}; - if(id == 2) return Trade::MeshData{MeshPrimitive::TriangleFan, 4}; + if(id == 0) + return Trade::MeshData{MeshPrimitive::Points, 5}; + if(id == 1) + return Trade::MeshData{MeshPrimitive::Lines, 4}; + if(id == 2) + return Trade::MeshData{MeshPrimitive::TriangleFan, 4}; CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } diff --git a/src/Magnum/SceneTools/sceneconverter.cpp b/src/Magnum/SceneTools/sceneconverter.cpp index d1ca7795d..24ea0b4ba 100644 --- a/src/Magnum/SceneTools/sceneconverter.cpp +++ b/src/Magnum/SceneTools/sceneconverter.cpp @@ -375,7 +375,8 @@ template bool runImageConverters(PluginManager::Manager< /* Set options, if passed. The AnyImageConverter check makes no sense here, is just there because the helper wants it */ - if(args.isSet("verbose")) imageConverter->addFlags(Trade::ImageConverterFlag::Verbose); + if(args.isSet("verbose")) + imageConverter->addFlags(Trade::ImageConverterFlag::Verbose); if(j < args.arrayValueCount("image-converter-options")) Implementation::setOptions(*imageConverter, "AnyImageConverter", args.arrayValue("image-converter-options", j)); @@ -708,7 +709,8 @@ well, the IDs reference attributes of the first mesh.)") } /* Set options, if passed */ - if(args.isSet("verbose")) importer->addFlags(Trade::ImporterFlag::Verbose); + if(args.isSet("verbose")) + importer->addFlags(Trade::ImporterFlag::Verbose); Implementation::setOptions(*importer, "AnySceneImporter", args.value("importer-options")); Trade::Implementation::printImporterInfo(useColor, *importer); return 0; @@ -721,7 +723,8 @@ well, the IDs reference attributes of the first mesh.)") } /* Set options, if passed */ - if(args.isSet("verbose")) converter->addFlags(Trade::SceneConverterFlag::Verbose); + if(args.isSet("verbose")) + converter->addFlags(Trade::SceneConverterFlag::Verbose); if(args.arrayValueCount("converter-options")) Implementation::setOptions(*converter, "AnySceneConverter", args.arrayValue("converter-options", 0)); SceneTools::Implementation::printSceneConverterInfo(useColor, *converter); @@ -735,7 +738,8 @@ well, the IDs reference attributes of the first mesh.)") } /* Set options, if passed */ - if(args.isSet("verbose")) converter->addFlags(Trade::ImageConverterFlag::Verbose); + if(args.isSet("verbose")) + converter->addFlags(Trade::ImageConverterFlag::Verbose); if(args.arrayValueCount("image-converter-options")) Implementation::setOptions(*converter, "AnyImageConverter", args.arrayValue("image-converter-options", 0)); Trade::Implementation::printImageConverterInfo(useColor, *converter); @@ -749,7 +753,8 @@ well, the IDs reference attributes of the first mesh.)") } /* Set options, if passed */ - if(args.isSet("verbose")) importer->addFlags(Trade::ImporterFlag::Verbose); + if(args.isSet("verbose")) + importer->addFlags(Trade::ImporterFlag::Verbose); Implementation::setOptions(*importer, "AnySceneImporter", args.value("importer-options")); /* Wow, C++, you suck. This implicitly initializes to random shit?! @@ -904,7 +909,8 @@ well, the IDs reference attributes of the first mesh.)") it's possible to filter attributes by name */ if(Containers::StringView onlyAttributes = args.value("only-mesh-attributes")) { const Containers::Optional> only = Utility::String::parseNumberSequence(onlyAttributes, 0, mesh->attributeCount()); - if(!only) return 2; + if(!only) + return 2; /** @todo use MeshTools::filterOnlyAttributes() once it has a rvalue overload that transfers ownership */ @@ -929,7 +935,8 @@ well, the IDs reference attributes of the first mesh.)") explicit SingleMeshImporter(Trade::MeshData&& mesh_, Containers::String&& name, Trade::AbstractImporter& original): mesh{Utility::move(mesh_)}, name{Utility::move(name)} { for(UnsignedInt i = 0; i != mesh.attributeCount(); ++i) { const Trade::MeshAttribute attributeName = mesh.attributeName(i); - if(!isMeshAttributeCustom(attributeName)) continue; + if(!isMeshAttributeCustom(attributeName)) + continue; /* Appending even empty ones so we don't have to special-case "not found" in doMeshAttributeName() */ arrayAppend(attributeNames, InPlaceInit, attributeName, original.meshAttributeName(attributeName)); @@ -946,7 +953,8 @@ well, the IDs reference attributes of the first mesh.)") } Containers::String doMeshAttributeName(Trade::MeshAttribute name) override { for(const Containers::Pair& i: attributeNames) - if(i.first() == name) return i.second(); + if(i.first() == name) + return i.second(); /* All custom attributes, including the unnamed, are in the attributeNames array and both our attribute name propagation here and addSupportedImporterContents() call @@ -1102,7 +1110,8 @@ well, the IDs reference attributes of the first mesh.)") /* Set options, if passed. The AnySceneConverter check makes no sense here, is just there because the helper wants it */ - if(args.isSet("verbose")) meshConverter->addFlags(Trade::SceneConverterFlag::Verbose); + if(args.isSet("verbose")) + meshConverter->addFlags(Trade::SceneConverterFlag::Verbose); if(j < args.arrayValueCount("mesh-converter-options")) Implementation::setOptions(*meshConverter, "AnySceneConverter", args.arrayValue("mesh-converter-options", j)); @@ -1206,7 +1215,8 @@ well, the IDs reference attributes of the first mesh.)") } /* Set options, if passed */ - if(args.isSet("verbose")) converter->addFlags(Trade::SceneConverterFlag::Verbose); + if(args.isSet("verbose")) + converter->addFlags(Trade::SceneConverterFlag::Verbose); if(i < args.arrayValueCount("converter-options")) Implementation::setOptions(*converter, "AnySceneConverter", args.arrayValue("converter-options", i)); @@ -1331,7 +1341,8 @@ well, the IDs reference attributes of the first mesh.)") /** @todo have some kind of a map to not have to query the same custom attribute again for each mesh */ const Trade::MeshAttribute name = mesh.attributeName(k); - if(!isMeshAttributeCustom(name)) continue; + if(!isMeshAttributeCustom(name)) + continue; /* The expectation here is that the meshes are coming from the importer instance. If --mesh or --concatenate-meshes was used, the original importer is replaced a new one diff --git a/src/Magnum/ShaderTools/AbstractConverter.cpp b/src/Magnum/ShaderTools/AbstractConverter.cpp index 3e7010b68..1057c1d50 100644 --- a/src/Magnum/ShaderTools/AbstractConverter.cpp +++ b/src/Magnum/ShaderTools/AbstractConverter.cpp @@ -387,7 +387,8 @@ bool AbstractConverter::convertDataToFile(const Stage stage, const Containers::A /* Cast to a non-void type for more convenience */ const Containers::Optional> out = doConvertDataToData(stage, Containers::arrayCast(data)); - if(!out) return false; + if(!out) + return false; if(!Utility::Path::write(filename, *out)) { Error{} << "ShaderTools::AbstractConverter::convertDataToFile(): cannot write to file" << filename; @@ -434,7 +435,8 @@ bool AbstractConverter::convertFileToFile(const Stage stage, const Containers::S in the base doConvertFileToFile() implementation, because this branch is never taken in that case) */ const Containers::Optional> out = convertDataToDataUsingInputFileCallbacks("ShaderTools::AbstractConverter::convertFileToFile():", stage, from); - if(!out) return false; + if(!out) + return false; if(!Utility::Path::write(to, *out)) { Error{} << "ShaderTools::AbstractConverter::convertFileToFile(): cannot write to file" << to; @@ -469,7 +471,8 @@ bool AbstractConverter::doConvertFileToFile(const Stage stage, const Containers: out = doConvertDataToData(stage, *data); } - if(!out) return false; + if(!out) + return false; if(!Utility::Path::write(to, *out)) { Error{} << "ShaderTools::AbstractConverter::convertFileToFile(): cannot write to file" << to; @@ -592,7 +595,8 @@ bool AbstractConverter::linkDataToFile(const Containers::ArrayView> out = doLinkDataToData(Containers::arrayCast>>(data)); - if(!out) return false; + if(!out) + return false; if(!Utility::Path::write(filename, *out)) { Error{} << "ShaderTools::AbstractConverter::linkDataToFile(): cannot write to file" << filename; @@ -614,7 +618,8 @@ Containers::Optional> AbstractConverter::linkDataToDataU std::size_t i; for(i = 0; i != filenames.size(); ++i) { const Containers::Optional> contents = _inputFileCallback(filenames[i].second(), InputFileCallbackPolicy::LoadTemporary, _inputFileCallbackUserData); - if(!contents) break; + if(!contents) + break; data[i].first() = filenames[i].first(); data[i].second() = *contents; @@ -622,7 +627,8 @@ Containers::Optional> AbstractConverter::linkDataToDataU /* If all input files loaded successfully, process */ Containers::Optional> out; - if(i == filenames.size()) out = doLinkDataToData(data); + if(i == filenames.size()) + out = doLinkDataToData(data); /* Close again all input files that loaded successfully */ for(std::size_t ii = 0; ii != i; ++ii) @@ -671,7 +677,8 @@ bool AbstractConverter::linkFilesToFile(const Containers::ArrayView> out = linkDataToDataUsingInputFileCallbacks("ShaderTools::AbstractConverter::linkFilesToFile():", from); - if(!out) return false; + if(!out) + return false; if(!Utility::Path::write(to, *out)) { Error{} << "ShaderTools::AbstractConverter::linkFilesToFile(): cannot write to file" << to; @@ -723,7 +730,8 @@ bool AbstractConverter::doLinkFilesToFile(const Containers::ArrayView spirvNextEntrypoint(Containers::ArrayView< /* Expecting at least op, execution model, ID, name. If less, it's an invalid SPIR-V. */ /** @todo print a message here? */ - if(entryPoint.size() < 4) return {}; + if(entryPoint.size() < 4) + return {}; /* Find where the name ends and interface IDs start. According to the spec, a string literal is null-terminated and all bytes after are @@ -169,7 +170,8 @@ void spirvEntrypointInterface(Containers::ArrayView data, con /* Expecting at least op, result, ID, SpvStorageClass. If less, it's an invalid SPIR-V. */ /** @todo print a message here? */ - if(variable.size() < 4) return; + if(variable.size() < 4) + return; for(std::size_t i = 0; i != entrypoint.interfaces.size(); ++i) { if(variable[2] == entrypoint.interfaces[i]) { diff --git a/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp b/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp index 438b72033..1555db17c 100644 --- a/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp +++ b/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp @@ -3306,7 +3306,8 @@ void AbstractConverterTest::setInputFileCallbackLinkFilesToFileThroughBaseImplem if(filename == "another.dat") return Containers::arrayView(state.data); /* This deliberately fails */ - if(filename == "file.dat") return {}; + if(filename == "file.dat") + return {}; } if(policy == InputFileCallbackPolicy::Close) { @@ -3421,7 +3422,8 @@ void AbstractConverterTest::setInputFileCallbackLinkFilesToFileAsDataFailed() { if(filename == "another.dat") return Containers::arrayView(state.data); /* This deliberately fails */ - if(filename == "file.dat") return {}; + if(filename == "file.dat") + return {}; } if(policy == InputFileCallbackPolicy::Close) { @@ -3632,7 +3634,8 @@ void AbstractConverterTest::setInputFileCallbackLinkFilesToDataThroughBaseImplem if(filename == "another.dat") return Containers::arrayView(state.data); /* This deliberately fails */ - if(filename == "file.dat") return {}; + if(filename == "file.dat") + return {}; } if(policy == InputFileCallbackPolicy::Close) { @@ -3745,7 +3748,8 @@ void AbstractConverterTest::setInputFileCallbackLinkFilesToDataAsDataFailed() { if(filename == "another.dat") return Containers::arrayView(state.data); /* This deliberately fails */ - if(filename == "file.dat") return {}; + if(filename == "file.dat") + return {}; } if(policy == InputFileCallbackPolicy::Close) { diff --git a/src/Magnum/ShaderTools/shaderconverter.cpp b/src/Magnum/ShaderTools/shaderconverter.cpp index e35038151..23e30ba17 100644 --- a/src/Magnum/ShaderTools/shaderconverter.cpp +++ b/src/Magnum/ShaderTools/shaderconverter.cpp @@ -222,14 +222,16 @@ void printSpirvInfo(Containers::ArrayView data) { ShaderTools::Implementation::spirvEntrypointInterface(data, *entrypoint, interface); for(const ShaderTools::Implementation::SpirvEntrypointInterface& i: interface) { d << " "; - if(!i.storageClass) d << "(unknown)"; + if(!i.storageClass) + d << "(unknown)"; else if(*i.storageClass == SpvStorageClassInput) d << "in"; else if(*i.storageClass == SpvStorageClassOutput) d << "out"; else d << "SpvStorageClass(" << Debug::nospace << *i.storageClass << Debug::nospace << ")"; - if(i.location) d << "(location=" << Debug::nospace << *i.location << Debug::nospace << ")"; + if(i.location) + d << "(location=" << Debug::nospace << *i.location << Debug::nospace << ")"; d << Debug::newline; } @@ -396,12 +398,18 @@ see documentation of a particular converter for more information.)") if(args.isSet("info")) outputFormat = ShaderTools::Format::Spirv; auto parseFormat = [](Containers::StringView format) -> Containers::Optional { - if(format == ""_s) return ShaderTools::Format::Unspecified; - if(format == "glsl"_s) return ShaderTools::Format::Glsl; - if(format == "spv"_s) return ShaderTools::Format::Spirv; - if(format == "spvasm"_s) return ShaderTools::Format::SpirvAssembly; - if(format == "hlsl"_s) return ShaderTools::Format::Hlsl; - if(format == "metal"_s) return ShaderTools::Format::Msl; + if(format == ""_s) + return ShaderTools::Format::Unspecified; + if(format == "glsl"_s) + return ShaderTools::Format::Glsl; + if(format == "spv"_s) + return ShaderTools::Format::Spirv; + if(format == "spvasm"_s) + return ShaderTools::Format::SpirvAssembly; + if(format == "hlsl"_s) + return ShaderTools::Format::Hlsl; + if(format == "metal"_s) + return ShaderTools::Format::Msl; /** @todo wgsl and dxil once i figure out the extensions */ Error{} << "Unrecognized format" << format << Debug::nospace << ", expected glsl, spv, spvasm, hlsl or metal"; @@ -433,9 +441,12 @@ see documentation of a particular converter for more information.)") ShaderTools::ConverterFlags flags; /* Global flags, applied for all converters */ - if(args.isSet("quiet")) flags |= ShaderTools::ConverterFlag::Quiet; - if(args.isSet("verbose")) flags |= ShaderTools::ConverterFlag::Verbose; - if(args.isSet("warning-as-error")) flags |= ShaderTools::ConverterFlag::WarningAsError; + if(args.isSet("quiet")) + flags |= ShaderTools::ConverterFlag::Quiet; + if(args.isSet("verbose")) + flags |= ShaderTools::ConverterFlag::Verbose; + if(args.isSet("warning-as-error")) + flags |= ShaderTools::ConverterFlag::WarningAsError; /* Options and flags applied just for the first converter; setting up file list for linking */ @@ -538,11 +549,13 @@ see documentation of a particular converter for more information.)") if(!out.first()) { if(args.isSet("verbose")) Error{} << "Validation failed:"; - if(!out.second().isEmpty()) Error{} << out.second(); + if(!out.second().isEmpty()) + Error{} << out.second(); } else if(!out.second().isEmpty()) { if(args.isSet("verbose")) Warning{} << "Validation succeeded with warnings:"; - if(!out.second().isEmpty()) Warning{} << out.second(); + if(!out.second().isEmpty()) + Warning{} << out.second(); } else if(args.isSet("verbose")) Debug{} << "Validation passed"; return out.first() ? 0 : 14; diff --git a/src/Magnum/Shaders/DistanceFieldVectorGL.cpp b/src/Magnum/Shaders/DistanceFieldVectorGL.cpp index fd768844d..080435a7d 100644 --- a/src/Magnum/Shaders/DistanceFieldVectorGL.cpp +++ b/src/Magnum/Shaders/DistanceFieldVectorGL.cpp @@ -244,7 +244,8 @@ template DistanceFieldVectorGL::DistanceFiel #ifdef CORRADE_GRACEFUL_ASSERT /* When graceful assertions fire from within compile(), we get a NoCreate'd CompileState. Exiting makes it possible to test the assert. */ - if(!id()) return; + if(!id()) + return; #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); diff --git a/src/Magnum/Shaders/FlatGL.cpp b/src/Magnum/Shaders/FlatGL.cpp index bd4d31024..f94e7b8ee 100644 --- a/src/Magnum/Shaders/FlatGL.cpp +++ b/src/Magnum/Shaders/FlatGL.cpp @@ -406,7 +406,8 @@ template FlatGL::FlatGL(CompileState&& state #ifdef CORRADE_GRACEFUL_ASSERT /* When graceful assertions fire from within compile(), we get a NoCreate'd CompileState. Exiting makes it possible to test the assert. */ - if(!id()) return; + if(!id()) + return; #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); @@ -438,9 +439,11 @@ template FlatGL::FlatGL(CompileState&& state _textureLayerUniform = uniformLocation("textureLayer"_s); #endif _colorUniform = uniformLocation("color"_s); - if(_flags & Flag::AlphaMask) _alphaMaskUniform = uniformLocation("alphaMask"_s); + if(_flags & Flag::AlphaMask) + _alphaMaskUniform = uniformLocation("alphaMask"_s); #ifndef MAGNUM_TARGET_GLES2 - if(_flags & Flag::ObjectId) _objectIdUniform = uniformLocation("objectId"_s); + if(_flags & Flag::ObjectId) + _objectIdUniform = uniformLocation("objectId"_s); #endif #ifndef MAGNUM_TARGET_GLES2 if(_jointCount) { @@ -457,9 +460,11 @@ template FlatGL::FlatGL(CompileState&& state if(state._version < GL::Version::GLES310) #endif { - if(_flags & Flag::Textured) setUniform(uniformLocation("textureData"_s), TextureUnit); + if(_flags & Flag::Textured) + setUniform(uniformLocation("textureData"_s), TextureUnit); #ifndef MAGNUM_TARGET_GLES2 - if(_flags >= Flag::ObjectIdTexture) setUniform(uniformLocation("objectIdTextureData"_s), ObjectIdTextureUnit); + if(_flags >= Flag::ObjectIdTexture) + setUniform(uniformLocation("objectIdTextureData"_s), ObjectIdTextureUnit); /* SSBOs have bindings defined in the source always */ if(_flags >= Flag::UniformBuffers #ifndef MAGNUM_TARGET_WEBGL @@ -494,7 +499,8 @@ template FlatGL::FlatGL(CompileState&& state setTextureMatrix(Matrix3{Math::IdentityInit}); /* Texture layer is zero by default */ setColor(Magnum::Color4{1.0f}); - if(_flags & Flag::AlphaMask) setAlphaMask(0.5f); + if(_flags & Flag::AlphaMask) + setAlphaMask(0.5f); /* Object ID is zero by default */ #ifndef MAGNUM_TARGET_GLES2 if(_jointCount) { @@ -601,7 +607,8 @@ template FlatGL& FlatGL::setJoin "Shaders::FlatGL::setJointMatrices(): the shader was created with uniform buffers enabled", *this); CORRADE_ASSERT(matrices.size() <= _jointCount, "Shaders::FlatGL::setJointMatrices(): expected at most" << _jointCount << "items but got" << matrices.size(), *this); - if(_jointCount) setUniform(_jointMatricesUniform, matrices); + if(_jointCount) + setUniform(_jointMatricesUniform, matrices); return *this; } diff --git a/src/Magnum/Shaders/LineGL.cpp b/src/Magnum/Shaders/LineGL.cpp index d2b621a7d..59c12f129 100644 --- a/src/Magnum/Shaders/LineGL.cpp +++ b/src/Magnum/Shaders/LineGL.cpp @@ -258,7 +258,8 @@ template LineGL::LineGL(CompileState&& state #ifdef CORRADE_GRACEFUL_ASSERT /* When graceful assertions fire from within compile(), we get a NoCreate'd CompileState. Exiting makes it possible to test the assert. */ - if(!id()) return; + if(!id()) + return; #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); diff --git a/src/Magnum/Shaders/MeshVisualizerGL.cpp b/src/Magnum/Shaders/MeshVisualizerGL.cpp index 05991e2b5..7463157fc 100644 --- a/src/Magnum/Shaders/MeshVisualizerGL.cpp +++ b/src/Magnum/Shaders/MeshVisualizerGL.cpp @@ -92,9 +92,12 @@ void MeshVisualizerGLBase::assertExtensions(const FlagsBase flags) { #ifndef MAGNUM_TARGET_GLES2 #ifndef CORRADE_NO_ASSERT Int countMutuallyExclusive = 0; - if(flags & FlagBase::ObjectId) ++countMutuallyExclusive; - if(flags & FlagBase::VertexId) ++countMutuallyExclusive; - if(flags & FlagBase::PrimitiveIdFromVertexId) ++countMutuallyExclusive; + if(flags & FlagBase::ObjectId) + ++countMutuallyExclusive; + if(flags & FlagBase::VertexId) + ++countMutuallyExclusive; + if(flags & FlagBase::PrimitiveIdFromVertexId) + ++countMutuallyExclusive; #endif CORRADE_ASSERT(countMutuallyExclusive <= 1, "Shaders::MeshVisualizerGL: Flag::ObjectId, Flag::VertexId and Flag::PrimitiveId are mutually exclusive", ); @@ -706,7 +709,8 @@ MeshVisualizerGL2D::CompileState MeshVisualizerGL2D::compile(const Configuration #endif out.attachShaders({vert, frag}); - if(geom) out.attachShader(*geom); + if(geom) + out.attachShader(*geom); /* ES3 has this done in the shader directly */ #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) @@ -784,7 +788,8 @@ MeshVisualizerGL2D::MeshVisualizerGL2D(CompileState&& state): MeshVisualizerGL2D #ifdef CORRADE_GRACEFUL_ASSERT /* When graceful assertions fire from within compile(), we get a NoCreate'd CompileState. Exiting makes it possible to test the assert. */ - if(!id()) return; + if(!id()) + return; #endif #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) @@ -990,7 +995,8 @@ MeshVisualizerGL2D& MeshVisualizerGL2D::setJointMatrices(const Containers::Array "Shaders::MeshVisualizerGL2D::setJointMatrices(): the shader was created with uniform buffers enabled", *this); CORRADE_ASSERT(matrices.size() <= _jointCount, "Shaders::MeshVisualizerGL2D::setJointMatrices(): expected at most" << _jointCount << "items but got" << matrices.size(), *this); - if(_jointCount) setUniform(_jointMatricesUniform, matrices); + if(_jointCount) + setUniform(_jointMatricesUniform, matrices); return *this; } @@ -1197,11 +1203,14 @@ MeshVisualizerGL3D::CompileState MeshVisualizerGL3D::compile(const Configuration #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if(configuration.flags() & (Flag::Wireframe|Flag::TangentDirection|Flag::BitangentFromTangentDirection|Flag::BitangentDirection|Flag::NormalDirection) && !(configuration.flags() & Flag::NoGeometryShader)) { Int maxVertices = 0; - if(configuration.flags() & Flag::Wireframe) maxVertices += 3; - if(configuration.flags() & Flag::TangentDirection) maxVertices += 3*6; + if(configuration.flags() & Flag::Wireframe) + maxVertices += 3; + if(configuration.flags() & Flag::TangentDirection) + maxVertices += 3*6; if(configuration.flags() & (Flag::BitangentDirection|Flag::BitangentFromTangentDirection)) maxVertices += 3*6; - if(configuration.flags() & Flag::NormalDirection) maxVertices += 3*6; + if(configuration.flags() & Flag::NormalDirection) + maxVertices += 3*6; geom = GL::Shader{version, GL::Shader::Type::Geometry}; (*geom) @@ -1249,10 +1258,12 @@ MeshVisualizerGL3D::CompileState MeshVisualizerGL3D::compile(const Configuration vert.submitCompile(); frag.submitCompile(); - if(geom) geom->submitCompile(); + if(geom) + geom->submitCompile(); out.attachShaders({vert, frag}); - if(geom) out.attachShader(*geom); + if(geom) + out.attachShader(*geom); /* ES3 has this done in the shader directly */ #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) @@ -1345,7 +1356,8 @@ MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D #ifdef CORRADE_GRACEFUL_ASSERT /* When graceful assertions fire from within compile(), we get a NoCreate'd CompileState. Exiting makes it possible to test the assert. */ - if(!id()) return; + if(!id()) + return; #endif #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) @@ -1642,7 +1654,8 @@ MeshVisualizerGL3D& MeshVisualizerGL3D::setJointMatrices(const Containers::Array "Shaders::MeshVisualizerGL3D::setJointMatrices(): the shader was created with uniform buffers enabled", *this); CORRADE_ASSERT(matrices.size() <= _jointCount, "Shaders::MeshVisualizerGL3D::setJointMatrices(): expected at most" << _jointCount << "items but got" << matrices.size(), *this); - if(_jointCount) setUniform(_jointMatricesUniform, matrices); + if(_jointCount) + setUniform(_jointMatricesUniform, matrices); return *this; } diff --git a/src/Magnum/Shaders/MeshVisualizerGL.h b/src/Magnum/Shaders/MeshVisualizerGL.h index f2256ea74..898916246 100644 --- a/src/Magnum/Shaders/MeshVisualizerGL.h +++ b/src/Magnum/Shaders/MeshVisualizerGL.h @@ -1385,7 +1385,8 @@ class MeshVisualizerGL2D::CompileState: public MeshVisualizerGL2D { #endif { #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) - if(geom) _geom = Implementation::GLShaderWrapper{Utility::move(*geom)}; + if(geom) + _geom = Implementation::GLShaderWrapper{Utility::move(*geom)}; #endif } @@ -3404,7 +3405,8 @@ class MeshVisualizerGL3D::CompileState: public MeshVisualizerGL3D { #endif { #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) - if(geom) _geom = Implementation::GLShaderWrapper{Utility::move(*geom)}; + if(geom) + _geom = Implementation::GLShaderWrapper{Utility::move(*geom)}; #endif } diff --git a/src/Magnum/Shaders/PhongGL.cpp b/src/Magnum/Shaders/PhongGL.cpp index 33563e373..d6b0f55a9 100644 --- a/src/Magnum/Shaders/PhongGL.cpp +++ b/src/Magnum/Shaders/PhongGL.cpp @@ -508,7 +508,8 @@ PhongGL::PhongGL(CompileState&& state): PhongGL{static_cast(Utility:: #ifdef CORRADE_GRACEFUL_ASSERT /* When graceful assertions fire from within compile(), we get a NoCreate'd CompileState. Exiting makes it possible to test the assert. */ - if(!id()) return; + if(!id()) + return; #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); @@ -556,9 +557,11 @@ PhongGL::PhongGL(CompileState&& state): PhongGL{static_cast(Utility:: _lightSpecularColorsUniform = uniformLocation("lightSpecularColors"_s); _lightRangesUniform = uniformLocation("lightRanges"_s); } - if(_flags & Flag::AlphaMask) _alphaMaskUniform = uniformLocation("alphaMask"_s); + if(_flags & Flag::AlphaMask) + _alphaMaskUniform = uniformLocation("alphaMask"_s); #ifndef MAGNUM_TARGET_GLES2 - if(_flags & Flag::ObjectId) _objectIdUniform = uniformLocation("objectId"_s); + if(_flags & Flag::ObjectId) + _objectIdUniform = uniformLocation("objectId"_s); #endif #ifndef MAGNUM_TARGET_GLES2 if(_jointCount) { @@ -575,14 +578,19 @@ PhongGL::PhongGL(CompileState&& state): PhongGL{static_cast(Utility:: if(state._version < GL::Version::GLES310) #endif { - if(_flags & Flag::AmbientTexture) setUniform(uniformLocation("ambientTexture"_s), AmbientTextureUnit); + if(_flags & Flag::AmbientTexture) + setUniform(uniformLocation("ambientTexture"_s), AmbientTextureUnit); if(_perDrawLightCount) { - if(_flags & Flag::DiffuseTexture) setUniform(uniformLocation("diffuseTexture"_s), DiffuseTextureUnit); - if(_flags & Flag::SpecularTexture) setUniform(uniformLocation("specularTexture"_s), SpecularTextureUnit); - if(_flags & Flag::NormalTexture) setUniform(uniformLocation("normalTexture"_s), NormalTextureUnit); + if(_flags & Flag::DiffuseTexture) + setUniform(uniformLocation("diffuseTexture"_s), DiffuseTextureUnit); + if(_flags & Flag::SpecularTexture) + setUniform(uniformLocation("specularTexture"_s), SpecularTextureUnit); + if(_flags & Flag::NormalTexture) + setUniform(uniformLocation("normalTexture"_s), NormalTextureUnit); } #ifndef MAGNUM_TARGET_GLES2 - if(_flags >= Flag::ObjectIdTexture) setUniform(uniformLocation("objectIdTextureData"_s), ObjectIdTextureUnit); + if(_flags >= Flag::ObjectIdTexture) + setUniform(uniformLocation("objectIdTextureData"_s), ObjectIdTextureUnit); /* SSBOs have bindings defined in the source always */ if(_flags >= Flag::UniformBuffers #ifndef MAGNUM_TARGET_WEBGL @@ -616,7 +624,8 @@ PhongGL::PhongGL(CompileState&& state): PhongGL{static_cast(Utility:: #endif { /* Default to fully opaque white so we can see the textures */ - if(_flags & Flag::AmbientTexture) setAmbientColor(Magnum::Color4{1.0f}); + if(_flags & Flag::AmbientTexture) + setAmbientColor(Magnum::Color4{1.0f}); else setAmbientColor(Magnum::Color4{0.0f}); setTransformationMatrix(Matrix4{Math::IdentityInit}); setProjectionMatrix(Matrix4{Math::IdentityInit}); @@ -640,7 +649,8 @@ PhongGL::PhongGL(CompileState&& state): PhongGL{static_cast(Utility:: if(_flags & Flag::TextureTransformation) setTextureMatrix(Matrix3{Math::IdentityInit}); /* Texture layer is zero by default */ - if(_flags & Flag::AlphaMask) setAlphaMask(0.5f); + if(_flags & Flag::AlphaMask) + setAlphaMask(0.5f); /* Object ID is zero by default */ #ifndef MAGNUM_TARGET_GLES2 if(_jointCount) { @@ -697,7 +707,8 @@ PhongGL& PhongGL::setDiffuseColor(const Magnum::Color4& color) { CORRADE_ASSERT(!(_flags >= Flag::UniformBuffers), "Shaders::PhongGL::setDiffuseColor(): the shader was created with uniform buffers enabled", *this); #endif - if(_perDrawLightCount) setUniform(_diffuseColorUniform, color); + if(_perDrawLightCount) + setUniform(_diffuseColorUniform, color); return *this; } @@ -708,7 +719,8 @@ PhongGL& PhongGL::setSpecularColor(const Magnum::Color4& color) { #endif CORRADE_ASSERT(!(_flags >= Flag::NoSpecular), "Shaders::PhongGL::setSpecularColor(): the shader was created with specular disabled", *this); - if(_perDrawLightCount) setUniform(_specularColorUniform, color); + if(_perDrawLightCount) + setUniform(_specularColorUniform, color); return *this; } @@ -719,7 +731,8 @@ PhongGL& PhongGL::setShininess(Float shininess) { #endif CORRADE_ASSERT(!(_flags >= Flag::NoSpecular), "Shaders::PhongGL::setShininess(): the shader was created with specular disabled", *this); - if(_perDrawLightCount) setUniform(_shininessUniform, shininess); + if(_perDrawLightCount) + setUniform(_shininessUniform, shininess); return *this; } @@ -730,7 +743,8 @@ PhongGL& PhongGL::setNormalTextureScale(const Float scale) { #endif CORRADE_ASSERT(_flags & Flag::NormalTexture, "Shaders::PhongGL::setNormalTextureScale(): the shader was not created with normal texture enabled", *this); - if(_perDrawLightCount) setUniform(_normalTextureScaleUniform, scale); + if(_perDrawLightCount) + setUniform(_normalTextureScaleUniform, scale); return *this; } @@ -770,7 +784,8 @@ PhongGL& PhongGL::setNormalMatrix(const Matrix3x3& matrix) { CORRADE_ASSERT(!(_flags >= Flag::UniformBuffers), "Shaders::PhongGL::setNormalMatrix(): the shader was created with uniform buffers enabled", *this); #endif - if(_perDrawLightCount) setUniform(_normalMatrixUniform, matrix); + if(_perDrawLightCount) + setUniform(_normalMatrixUniform, matrix); return *this; } @@ -812,7 +827,8 @@ PhongGL& PhongGL::setLightPositions(const Containers::ArrayView p #endif CORRADE_ASSERT(_lightCount == positions.size(), "Shaders::PhongGL::setLightPositions(): expected" << _lightCount << "items but got" << positions.size(), *this); - if(_lightCount) setUniform(_lightPositionsUniform, positions); + if(_lightCount) + setUniform(_lightPositionsUniform, positions); return *this; } @@ -867,7 +883,8 @@ PhongGL& PhongGL::setLightColors(const Containers::ArrayView= Flag::NoSpecular), "Shaders::PhongGL::setLightSpecularColors(): the shader was created with specular disabled", *this); - if(_lightCount) setUniform(_lightSpecularColorsUniform, colors); + if(_lightCount) + setUniform(_lightSpecularColorsUniform, colors); return *this; } @@ -950,7 +968,8 @@ PhongGL& PhongGL::setLightRanges(const Containers::ArrayView ranges #endif CORRADE_ASSERT(_lightCount == ranges.size(), "Shaders::PhongGL::setLightRanges(): expected" << _lightCount << "items but got" << ranges.size(), *this); - if(_lightCount) setUniform(_lightRangesUniform, ranges); + if(_lightCount) + setUniform(_lightRangesUniform, ranges); return *this; } @@ -975,7 +994,8 @@ PhongGL& PhongGL::setJointMatrices(const Containers::ArrayView ma "Shaders::PhongGL::setJointMatrices(): the shader was created with uniform buffers enabled", *this); CORRADE_ASSERT(matrices.size() <= _jointCount, "Shaders::PhongGL::setJointMatrices(): expected at most" << _jointCount << "items but got" << matrices.size(), *this); - if(_jointCount) setUniform(_jointMatricesUniform, matrices); + if(_jointCount) + setUniform(_jointMatricesUniform, matrices); return *this; } @@ -1207,7 +1227,8 @@ PhongGL& PhongGL::bindDiffuseTexture(GL::Texture2D& texture) { CORRADE_ASSERT(!(_flags & Flag::TextureArrays), "Shaders::PhongGL::bindDiffuseTexture(): the shader was created with texture arrays enabled, use a Texture2DArray instead", *this); #endif - if(_perDrawLightCount) texture.bind(DiffuseTextureUnit); + if(_perDrawLightCount) + texture.bind(DiffuseTextureUnit); return *this; } @@ -1217,7 +1238,8 @@ PhongGL& PhongGL::bindDiffuseTexture(GL::Texture2DArray& texture) { "Shaders::PhongGL::bindDiffuseTexture(): the shader was not created with diffuse texture enabled", *this); CORRADE_ASSERT(_flags & Flag::TextureArrays, "Shaders::PhongGL::bindDiffuseTexture(): the shader was not created with texture arrays enabled, use a Texture2D instead", *this); - if(_perDrawLightCount) texture.bind(DiffuseTextureUnit); + if(_perDrawLightCount) + texture.bind(DiffuseTextureUnit); return *this; } #endif @@ -1229,7 +1251,8 @@ PhongGL& PhongGL::bindSpecularTexture(GL::Texture2D& texture) { CORRADE_ASSERT(!(_flags & Flag::TextureArrays), "Shaders::PhongGL::bindSpecularTexture(): the shader was created with texture arrays enabled, use a Texture2DArray instead", *this); #endif - if(_perDrawLightCount) texture.bind(SpecularTextureUnit); + if(_perDrawLightCount) + texture.bind(SpecularTextureUnit); return *this; } @@ -1239,7 +1262,8 @@ PhongGL& PhongGL::bindSpecularTexture(GL::Texture2DArray& texture) { "Shaders::PhongGL::bindSpecularTexture(): the shader was not created with specular texture enabled", *this); CORRADE_ASSERT(_flags & Flag::TextureArrays, "Shaders::PhongGL::bindSpecularTexture(): the shader was not created with texture arrays enabled, use a Texture2D instead", *this); - if(_perDrawLightCount) texture.bind(SpecularTextureUnit); + if(_perDrawLightCount) + texture.bind(SpecularTextureUnit); return *this; } #endif @@ -1251,7 +1275,8 @@ PhongGL& PhongGL::bindNormalTexture(GL::Texture2D& texture) { CORRADE_ASSERT(!(_flags & Flag::TextureArrays), "Shaders::PhongGL::bindNormalTexture(): the shader was created with texture arrays enabled, use a Texture2DArray instead", *this); #endif - if(_perDrawLightCount) texture.bind(NormalTextureUnit); + if(_perDrawLightCount) + texture.bind(NormalTextureUnit); return *this; } @@ -1261,7 +1286,8 @@ PhongGL& PhongGL::bindNormalTexture(GL::Texture2DArray& texture) { "Shaders::PhongGL::bindNormalTexture(): the shader was not created with normal texture enabled", *this); CORRADE_ASSERT(_flags & Flag::TextureArrays, "Shaders::PhongGL::bindNormalTexture(): the shader was not created with texture arrays enabled, use a Texture2D instead", *this); - if(_perDrawLightCount) texture.bind(NormalTextureUnit); + if(_perDrawLightCount) + texture.bind(NormalTextureUnit); return *this; } #endif diff --git a/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp b/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp index 21da1b2fd..cda2f3d03 100644 --- a/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp +++ b/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp @@ -1323,7 +1323,8 @@ template void DistanceFieldVectorGLTest::ren /* Dropping the alpha channel, as it's always 1.0 */ Containers::StridedArrayView2D pixels = rendered.pixels().slice(&Color4ub::rgb); - if(data.flip) pixels = pixels.flipped<0>().flipped<1>(); + if(data.flip) + pixels = pixels.flipped<0>().flipped<1>(); #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) /* SwiftShader has off-by-one differences when smoothing, Apple A8 a bit @@ -1514,7 +1515,8 @@ template void DistanceFieldVectorGLTest::ren /* Dropping the alpha channel, as it's always 1.0 */ Containers::StridedArrayView2D pixels = rendered.pixels().slice(&Color4ub::rgb); - if(data.flip) pixels = pixels.flipped<0>().flipped<1>(); + if(data.flip) + pixels = pixels.flipped<0>().flipped<1>(); #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) /* SwiftShader has off-by-one differences when smoothing plus a bunch of diff --git a/src/Magnum/Shaders/Test/FlatGLTest.cpp b/src/Magnum/Shaders/Test/FlatGLTest.cpp index 8ebb12e2e..7cead7544 100644 --- a/src/Magnum/Shaders/Test/FlatGLTest.cpp +++ b/src/Magnum/Shaders/Test/FlatGLTest.cpp @@ -2583,7 +2583,8 @@ template void FlatGLTest::renderTextured2D() { /* Dropping the alpha channel, as it's always 1.0 */ Containers::StridedArrayView2D pixels = rendered.pixels().slice(&Color4ub::rgb); - if(data.flip) pixels = pixels.flipped<0>().flipped<1>(); + if(data.flip) + pixels = pixels.flipped<0>().flipped<1>(); #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) /* SwiftShader has minor rounding errors, Apple A8 & llvmpipe a bit more */ @@ -2742,7 +2743,8 @@ template void FlatGLTest::renderTextured3D() { /* Dropping the alpha channel, as it's always 1.0 */ Containers::StridedArrayView2D pixels = rendered.pixels().slice(&Color4ub::rgb); - if(data.flip) pixels = pixels.flipped<0>().flipped<1>(); + if(data.flip) + pixels = pixels.flipped<0>().flipped<1>(); #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) /* SwiftShader has 5 different pixels on the edges */ diff --git a/src/Magnum/Shaders/Test/LineGLTest.cpp b/src/Magnum/Shaders/Test/LineGLTest.cpp index 58c7ad5e8..2cae1670d 100644 --- a/src/Magnum/Shaders/Test/LineGLTest.cpp +++ b/src/Magnum/Shaders/Test/LineGLTest.cpp @@ -570,12 +570,16 @@ template void LineGLTest::construct() { typename LineGL::Configuration configuration; configuration.setFlags(data.flags); - if(data.capStyle) configuration.setCapStyle(*data.capStyle); - if(data.joinStyle) configuration.setJoinStyle(*data.joinStyle); + if(data.capStyle) + configuration.setCapStyle(*data.capStyle); + if(data.joinStyle) + configuration.setJoinStyle(*data.joinStyle); LineGL shader{configuration}; CORRADE_COMPARE(shader.flags(), data.flags); - if(data.capStyle) CORRADE_COMPARE(shader.capStyle(), data.capStyle); - if(data.joinStyle) CORRADE_COMPARE(shader.joinStyle(), data.joinStyle); + if(data.capStyle) + CORRADE_COMPARE(shader.capStyle(), data.capStyle); + if(data.joinStyle) + CORRADE_COMPARE(shader.joinStyle(), data.joinStyle); CORRADE_VERIFY(shader.id()); { #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) @@ -664,12 +668,16 @@ template void LineGLTest::constructUniformBuffers() { .setFlags(data.flags) .setMaterialCount(data.materialCount) .setDrawCount(data.drawCount); - if(data.capStyle) configuration.setCapStyle(*data.capStyle); - if(data.joinStyle) configuration.setJoinStyle(*data.joinStyle); + if(data.capStyle) + configuration.setCapStyle(*data.capStyle); + if(data.joinStyle) + configuration.setJoinStyle(*data.joinStyle); LineGL shader{configuration}; CORRADE_COMPARE(shader.flags(), data.flags); - if(data.capStyle) CORRADE_COMPARE(shader.capStyle(), data.capStyle); - if(data.joinStyle) CORRADE_COMPARE(shader.joinStyle(), data.joinStyle); + if(data.capStyle) + CORRADE_COMPARE(shader.capStyle(), data.capStyle); + if(data.joinStyle) + CORRADE_COMPARE(shader.joinStyle(), data.joinStyle); CORRADE_COMPARE(shader.materialCount(), data.materialCount); CORRADE_COMPARE(shader.drawCount(), data.drawCount); CORRADE_VERIFY(shader.id()); @@ -1452,8 +1460,10 @@ template void LineGLTest::renderLineCapsJoins2D() { LineGL2D::Configuration configuration; configuration.setFlags(flag); - if(data.capStyle) configuration.setCapStyle(*data.capStyle); - if(data.joinStyle) configuration.setJoinStyle(*data.joinStyle); + if(data.capStyle) + configuration.setCapStyle(*data.capStyle); + if(data.joinStyle) + configuration.setJoinStyle(*data.joinStyle); LineGL2D shader{configuration}; shader.setViewportSize(Vector2{RenderSizeLarge}); @@ -1551,16 +1561,20 @@ void LineGLTest::renderLineCapsJoins2DReversed() { GL::Renderer::BlendFunction::OneMinusSourceAlpha); LineGL2D::Configuration configuration; - if(data.capStyle) configuration.setCapStyle(*data.capStyle); - if(data.joinStyle) configuration.setJoinStyle(*data.joinStyle); + if(data.capStyle) + configuration.setCapStyle(*data.capStyle); + if(data.joinStyle) + configuration.setJoinStyle(*data.joinStyle); LineGL2D shader{configuration}; shader .setViewportSize(Vector2{RenderSizeLarge}) .setWidth(data.width) .setSmoothness(data.smoothness) .setColor(0x80808080_rgbaf); - if(data.miterLengthLimit) shader.setMiterLengthLimit(*data.miterLengthLimit); - if(data.miterAngleLimit) shader.setMiterAngleLimit(*data.miterAngleLimit); + if(data.miterLengthLimit) + shader.setMiterLengthLimit(*data.miterLengthLimit); + if(data.miterAngleLimit) + shader.setMiterAngleLimit(*data.miterAngleLimit); /* Enabling blending and a half-transparent color -- there should be no overlaps */ @@ -1609,8 +1623,10 @@ void LineGLTest::renderLineCapsJoins2DTransformed() { GL::Mesh lines = generateLineMesh<2>(transformedLineSegments); LineGL2D::Configuration configuration; - if(data.capStyle) configuration.setCapStyle(*data.capStyle); - if(data.joinStyle) configuration.setJoinStyle(*data.joinStyle); + if(data.capStyle) + configuration.setCapStyle(*data.capStyle); + if(data.joinStyle) + configuration.setJoinStyle(*data.joinStyle); LineGL2D shader{configuration}; shader .setViewportSize(Vector2{RenderSizeLarge}) @@ -1619,8 +1635,10 @@ void LineGLTest::renderLineCapsJoins2DTransformed() { .setTransformationProjectionMatrix(transformation.inverted()) .setColor(0x80808080_rgbaf); - if(data.miterLengthLimit) shader.setMiterLengthLimit(*data.miterLengthLimit); - if(data.miterAngleLimit) shader.setMiterAngleLimit(*data.miterAngleLimit); + if(data.miterLengthLimit) + shader.setMiterLengthLimit(*data.miterLengthLimit); + if(data.miterAngleLimit) + shader.setMiterAngleLimit(*data.miterAngleLimit); /* Enabling blending and a half-transparent color -- there should be no overlaps */ @@ -1777,8 +1795,10 @@ template void LineGLTest::renderCube3D() { LineGL3D::Configuration configuration; configuration.setFlags(flag); - if(data.capStyle) configuration.setCapStyle(*data.capStyle); - if(data.joinStyle) configuration.setJoinStyle(*data.joinStyle); + if(data.capStyle) + configuration.setCapStyle(*data.capStyle); + if(data.joinStyle) + configuration.setJoinStyle(*data.joinStyle); LineGL3D shader{configuration}; shader.setViewportSize(Vector2{RenderSizeLarge}); diff --git a/src/Magnum/Shaders/Test/VectorGLTest.cpp b/src/Magnum/Shaders/Test/VectorGLTest.cpp index 299ea57ea..c16c613ee 100644 --- a/src/Magnum/Shaders/Test/VectorGLTest.cpp +++ b/src/Magnum/Shaders/Test/VectorGLTest.cpp @@ -1292,7 +1292,8 @@ template void VectorGLTest::render2D() { /* Dropping the alpha channel, as it's always 1.0 */ Containers::StridedArrayView2D pixels = rendered.pixels().slice(&Color4ub::rgb); - if(data.flip) pixels = pixels.flipped<0>().flipped<1>(); + if(data.flip) + pixels = pixels.flipped<0>().flipped<1>(); #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) /* SwiftShader has differently rasterized edges on four pixels */ @@ -1478,7 +1479,8 @@ template void VectorGLTest::render3D() { /* Dropping the alpha channel, as it's always 1.0 */ Containers::StridedArrayView2D pixels = rendered.pixels().slice(&Color4ub::rgb); - if(data.flip) pixels = pixels.flipped<0>().flipped<1>(); + if(data.flip) + pixels = pixels.flipped<0>().flipped<1>(); #if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)) /* SwiftShader has differently rasterized edges on four pixels */ diff --git a/src/Magnum/Shaders/VectorGL.cpp b/src/Magnum/Shaders/VectorGL.cpp index 7818adfbc..ef1a430d3 100644 --- a/src/Magnum/Shaders/VectorGL.cpp +++ b/src/Magnum/Shaders/VectorGL.cpp @@ -245,7 +245,8 @@ template VectorGL::VectorGL(CompileState&& s #ifdef CORRADE_GRACEFUL_ASSERT /* When graceful assertions fire from within compile(), we get a NoCreate'd CompileState. Exiting makes it possible to test the assert. */ - if(!id()) return; + if(!id()) + return; #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); diff --git a/src/Magnum/Shaders/VertexColorGL.cpp b/src/Magnum/Shaders/VertexColorGL.cpp index f1fdc8e28..aa2339c9f 100644 --- a/src/Magnum/Shaders/VertexColorGL.cpp +++ b/src/Magnum/Shaders/VertexColorGL.cpp @@ -200,7 +200,8 @@ template VertexColorGL::VertexColorGL(Compil #ifdef CORRADE_GRACEFUL_ASSERT /* When graceful assertions fire from within compile(), we get a NoCreate'd CompileState. Exiting makes it possible to test the assert. */ - if(!id()) return; + if(!id()) + return; #endif CORRADE_INTERNAL_ASSERT_OUTPUT(checkLink({GL::Shader(state._vert), GL::Shader(state._frag)})); @@ -290,7 +291,8 @@ template VertexColorGL& VertexColorGL 1) setUniform(_drawOffsetUniform, offset); + if(_drawCount > 1) + setUniform(_drawOffsetUniform, offset); return *this; } diff --git a/src/Magnum/Shaders/glShaderWrapper.cpp b/src/Magnum/Shaders/glShaderWrapper.cpp index d76c740e6..2048a87a2 100644 --- a/src/Magnum/Shaders/glShaderWrapper.cpp +++ b/src/Magnum/Shaders/glShaderWrapper.cpp @@ -46,7 +46,8 @@ GLShaderWrapper& GLShaderWrapper::operator=(GLShaderWrapper&& other) noexcept { GLShaderWrapper::~GLShaderWrapper() { /* Convert itself to a temporary GL::Shader, triggering deletion in its destructor. Cast to void to avoid warnings about an unused result. */ - if(id) static_cast(GL::Shader{Utility::move(*this)}); + if(id) + static_cast(GL::Shader{Utility::move(*this)}); } GLShaderWrapper::operator GL::Shader() & noexcept { diff --git a/src/Magnum/Test/PixelFormatTest.cpp b/src/Magnum/Test/PixelFormatTest.cpp index ce778ab89..f1a3517ed 100644 --- a/src/Magnum/Test/PixelFormatTest.cpp +++ b/src/Magnum/Test/PixelFormatTest.cpp @@ -526,7 +526,8 @@ void PixelFormatTest::assembleRoundtrip() { { Debug d{&out, Debug::Flag::NoNewlineAtTheEnd}; d << data.channelType; - if(data.srgb) d << Debug::nospace << ", srgb"; + if(data.srgb) + d << Debug::nospace << ", srgb"; } setTestCaseDescription(out); diff --git a/src/Magnum/Test/ResourceManagerTest.cpp b/src/Magnum/Test/ResourceManagerTest.cpp index c695c6146..ea3cf0700 100644 --- a/src/Magnum/Test/ResourceManagerTest.cpp +++ b/src/Magnum/Test/ResourceManagerTest.cpp @@ -445,7 +445,8 @@ void ResourceManagerTest::loader() { void doLoad(ResourceKey) override {} std::string doName(ResourceKey key) const override { - if(key == ResourceKey("hello")) return "hello"; + if(key == ResourceKey("hello")) + return "hello"; return ""; } diff --git a/src/Magnum/Test/VertexFormatTest.cpp b/src/Magnum/Test/VertexFormatTest.cpp index ce019993f..6fbef56b2 100644 --- a/src/Magnum/Test/VertexFormatTest.cpp +++ b/src/Magnum/Test/VertexFormatTest.cpp @@ -509,7 +509,8 @@ void VertexFormatTest::assembleRoundtrip() { { Debug d{&out, Debug::Flag::NoNewlineAtTheEnd}; d << data.componentType; - if(data.normalized) d << Debug::nospace << ", normalized"; + if(data.normalized) + d << Debug::nospace << ", normalized"; } setTestCaseDescription(out); @@ -581,7 +582,8 @@ void VertexFormatTest::assembleMatrixRoundtrip() { { Debug d{&out, Debug::Flag::NoNewlineAtTheEnd}; d << data.componentType << Debug::nospace << "," << data.componentCount; - if(data.aligned) d << Debug::nospace << ", aligned"; + if(data.aligned) + d << Debug::nospace << ", aligned"; } setTestCaseDescription(out); diff --git a/src/Magnum/Text/AbstractFontConverter.cpp b/src/Magnum/Text/AbstractFontConverter.cpp index b566b9f57..509681bfb 100644 --- a/src/Magnum/Text/AbstractFontConverter.cpp +++ b/src/Magnum/Text/AbstractFontConverter.cpp @@ -154,7 +154,8 @@ std::vector>> AbstractFontConvert std::vector>> out; Containers::Array result = doExportFontToSingleData(font, cache, characters); - if(result) out.emplace_back(filename, Utility::move(result)); + if(result) + out.emplace_back(filename, Utility::move(result)); return out; } diff --git a/src/Magnum/Text/AbstractGlyphCache.cpp b/src/Magnum/Text/AbstractGlyphCache.cpp index 0d64f2656..d272cd7fd 100644 --- a/src/Magnum/Text/AbstractGlyphCache.cpp +++ b/src/Magnum/Text/AbstractGlyphCache.cpp @@ -231,7 +231,8 @@ const AbstractFont* AbstractGlyphCache::fontPointer(const UnsignedInt fontId) co Containers::Optional AbstractGlyphCache::findFont(const AbstractFont& font) const { const State& state = *_state; for(UnsignedInt i = 0; i != state.fonts.size() - 1; ++i) - if(state.fonts[i].pointer == &font) return i; + if(state.fonts[i].pointer == &font) + return i; return {}; } diff --git a/src/Magnum/Text/Implementation/printFourCC.h b/src/Magnum/Text/Implementation/printFourCC.h index 86fe2aac4..0208501b8 100644 --- a/src/Magnum/Text/Implementation/printFourCC.h +++ b/src/Magnum/Text/Implementation/printFourCC.h @@ -37,7 +37,8 @@ inline Debug& printFourCC(Debug& debug, UnsignedInt value) { debug << "(" << Debug::nospace; for(std::size_t i = 0; i != 4; ++i) { - if(i) debug << Debug::nospace << ","; + if(i) + debug << Debug::nospace << ","; const int c = value & 255u; if(std::isprint(c)) { diff --git a/src/Magnum/Text/Test/AbstractFontTest.cpp b/src/Magnum/Text/Test/AbstractFontTest.cpp index b571b4eb7..243660b73 100644 --- a/src/Magnum/Text/Test/AbstractFontTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontTest.cpp @@ -4167,7 +4167,8 @@ void AbstractFontTest::layoutGlyphOutOfRange() { void doGlyphIdsInto(const Containers::StridedArrayView1D& ids) const override { /* Clear the IDs as otherwise it'd result in OOB calls into the glyph cache */ - for(UnsignedInt& i: ids) i = 0; + for(UnsignedInt& i: ids) + i = 0; } void doGlyphOffsetsAdvancesInto(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&) const override {} void doGlyphClustersInto(const Containers::StridedArrayView1D&) const override {} diff --git a/src/Magnum/Text/Test/RendererTest.cpp b/src/Magnum/Text/Test/RendererTest.cpp index 3c15d9366..ae25e49bc 100644 --- a/src/Magnum/Text/Test/RendererTest.cpp +++ b/src/Magnum/Text/Test/RendererTest.cpp @@ -2511,7 +2511,8 @@ void RendererTest::glyphRangeForBytes() { 13 /* 9 0 */ }; Containers::StridedArrayView1D clusters = clusterData; - if(!data.ascending) clusters = clusters.flipped<0>(); + if(!data.ascending) + clusters = clusters.flipped<0>(); /* With empty clusters it means there are no glyphs, so returning 0 means both before and after the glyph run */ diff --git a/src/Magnum/Text/fontconverter.cpp b/src/Magnum/Text/fontconverter.cpp index a4541bb5b..f13d1dba5 100644 --- a/src/Magnum/Text/fontconverter.cpp +++ b/src/Magnum/Text/fontconverter.cpp @@ -174,7 +174,8 @@ int FontConverter::exec() { #endif }; Containers::Pointer font = fontManager.loadAndInstantiate(args.value("font")); - if(!font) return 1; + if(!font) + return 1; /* Register the image converter manager for potential dependencies (MagnumFontConverter needs TgaImageConverter, for example) */ @@ -188,7 +189,8 @@ int FontConverter::exec() { /* Load font converter */ Containers::Pointer converter = converterManager.loadAndInstantiate(args.value("converter")); - if(!converter) return 2; + if(!converter) + return 2; /* Open font */ if(!font->openFile(args.value("input"), args.value("font-size"))) { diff --git a/src/Magnum/TextureTools/Atlas.cpp b/src/Magnum/TextureTools/Atlas.cpp index b5ab9c086..038e31358 100644 --- a/src/Magnum/TextureTools/Atlas.cpp +++ b/src/Magnum/TextureTools/Atlas.cpp @@ -395,7 +395,8 @@ Containers::Optional AtlasLandfill::add(const std::initializer_list atlas(const Vector2i& atlasSize, const std::vector& sizes, const Vector2i& padding) { - if(sizes.empty()) return {}; + if(sizes.empty()) + return {}; /* Size of largest texture */ Vector2i maxSize; diff --git a/src/Magnum/TextureTools/Test/AtlasBenchmark.cpp b/src/Magnum/TextureTools/Test/AtlasBenchmark.cpp index ff8e28e0e..cfbcc5f48 100644 --- a/src/Magnum/TextureTools/Test/AtlasBenchmark.cpp +++ b/src/Magnum/TextureTools/Test/AtlasBenchmark.cpp @@ -345,7 +345,8 @@ void AtlasBenchmark::benchmarkBegin() { std::uint64_t AtlasBenchmark::benchmarkEnd() { /* If the test failed, exit early as continuing would cause a division by zero. */ - if(!_filledArea) return {}; + if(!_filledArea) + return {}; UnsignedInt total = 0; for(const Vector2i& i: _sizes) diff --git a/src/Magnum/TextureTools/distancefieldconverter.cpp b/src/Magnum/TextureTools/distancefieldconverter.cpp index ed7472a64..01a620d5e 100644 --- a/src/Magnum/TextureTools/distancefieldconverter.cpp +++ b/src/Magnum/TextureTools/distancefieldconverter.cpp @@ -166,7 +166,8 @@ int DistanceFieldConverter::exec() { #endif }; Containers::Pointer importer = importerManager.loadAndInstantiate(args.value("importer")); - if(!importer) return 1; + if(!importer) + return 1; /* Load converter plugin */ PluginManager::Manager converterManager{ @@ -176,7 +177,8 @@ int DistanceFieldConverter::exec() { #endif }; Containers::Pointer converter = converterManager.loadAndInstantiate(args.value("converter")); - if(!converter) return 2; + if(!converter) + return 2; /* Open input file */ Containers::Optional image; diff --git a/src/Magnum/Timeline.cpp b/src/Magnum/Timeline.cpp index 79d936e04..267d457fe 100644 --- a/src/Magnum/Timeline.cpp +++ b/src/Magnum/Timeline.cpp @@ -51,7 +51,8 @@ void Timeline::stop() { } void Timeline::nextFrame() { - if(!_running) return; + if(!_running) + return; auto now = high_resolution_clock::now(); auto duration = UnsignedInt(duration_cast(now-_previousFrameTime).count()); @@ -64,7 +65,8 @@ Float Timeline::previousFrameTime() const { } Float Timeline::currentFrameDuration() const { - if(!_running) return 0; + if(!_running) + return 0; auto now = high_resolution_clock::now(); auto duration = UnsignedInt(duration_cast(now-_previousFrameTime).count()); @@ -72,7 +74,8 @@ Float Timeline::currentFrameDuration() const { } Float Timeline::currentFrameTime() const { - if(!_running) return 0; + if(!_running) + return 0; auto now = high_resolution_clock::now(); return duration_cast(now-_startTime).count()/1e6f; diff --git a/src/Magnum/Trade/AbstractImageConverter.cpp b/src/Magnum/Trade/AbstractImageConverter.cpp index dcc81e6c7..efc236352 100644 --- a/src/Magnum/Trade/AbstractImageConverter.cpp +++ b/src/Magnum/Trade/AbstractImageConverter.cpp @@ -299,7 +299,8 @@ Containers::Optional AbstractImageConverter::doConvert(const ImageV #ifdef MAGNUM_BUILD_DEPRECATED Containers::Optional AbstractImageConverter::exportToImage(const ImageView2D& image) { Containers::Optional out = convert(image); - if(!out) return {}; + if(!out) + return {}; if(out->isCompressed()) { Error{} << "Trade::AbstractImageConverter::exportToImage(): implementation returned a compressed image"; return {}; @@ -315,7 +316,8 @@ Containers::Optional AbstractImageConverter::exportToImage(const ImageV Containers::Optional AbstractImageConverter::exportToCompressedImage(const ImageView2D& image) { Containers::Optional out = convert(image); - if(!out) return {}; + if(!out) + return {}; if(!out->isCompressed()) { Error{} << "Trade::AbstractImageConverter::exportToCompressedImage(): implementation returned an uncompressed image"; return {}; @@ -999,7 +1001,8 @@ bool AbstractImageConverter::doConvertToFile(const ImageView1D& image, const Con const Containers::Optional> data = doConvertToData(image); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; @@ -1033,7 +1036,8 @@ bool AbstractImageConverter::doConvertToFile(const ImageView2D& image, const Con const Containers::Optional> data = doConvertToData(image); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; @@ -1073,7 +1077,8 @@ bool AbstractImageConverter::doConvertToFile(const ImageView3D& image, const Con const Containers::Optional> data = doConvertToData(image); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; @@ -1107,7 +1112,8 @@ bool AbstractImageConverter::doConvertToFile(const CompressedImageView1D& image, const Containers::Optional> data = doConvertToData(image); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; @@ -1141,7 +1147,8 @@ bool AbstractImageConverter::doConvertToFile(const CompressedImageView2D& image, const Containers::Optional> data = doConvertToData(image); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; @@ -1181,7 +1188,8 @@ bool AbstractImageConverter::doConvertToFile(const CompressedImageView3D& image, const Containers::Optional> data = doConvertToData(image); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; @@ -1231,7 +1239,8 @@ bool AbstractImageConverter::doConvertToFile(const Containers::ArrayView> data = doConvertToData(imageLevels); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; @@ -1263,7 +1272,8 @@ bool AbstractImageConverter::doConvertToFile(const Containers::ArrayView> data = doConvertToData(imageLevels); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; @@ -1295,7 +1305,8 @@ bool AbstractImageConverter::doConvertToFile(const Containers::ArrayView> data = doConvertToData(imageLevels); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; @@ -1327,7 +1338,8 @@ bool AbstractImageConverter::doConvertToFile(const Containers::ArrayView> data = doConvertToData(imageLevels); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; @@ -1359,7 +1371,8 @@ bool AbstractImageConverter::doConvertToFile(const Containers::ArrayView> data = doConvertToData(imageLevels); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; @@ -1391,7 +1404,8 @@ bool AbstractImageConverter::doConvertToFile(const Containers::ArrayView> data = doConvertToData(imageLevels); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error() << "Trade::AbstractImageConverter::convertToFile(): cannot write to file" << filename; diff --git a/src/Magnum/Trade/AbstractImporter.cpp b/src/Magnum/Trade/AbstractImporter.cpp index 6a5c988d4..e8add28d7 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -624,7 +624,8 @@ struct AbstractImporter::CachedScenes { }; void AbstractImporter::populateCachedScenes() { - if(_cachedScenes) return; + if(_cachedScenes) + return; _cachedScenes.emplace(); _cachedScenes->scenes = Containers::Array>{sceneCount()}; @@ -721,7 +722,8 @@ std::string AbstractImporter::doObject2DName(const UnsignedInt id) { /* Alias to the new interface if the ID is known to the new interface, return an empty string for objects that got newly added in order to make them single-functioning */ - if(id < doObjectCount()) return doObjectName(id); + if(id < doObjectCount()) + return doObjectName(id); populateCachedScenes(); for(UnsignedInt i = 0; i != _cachedScenes->scenes.size(); ++i) { @@ -899,7 +901,8 @@ std::string AbstractImporter::doObject3DName(const UnsignedInt id) { /* Alias to the new interface if the ID is known to the new interface, return an empty string for objects that got newly added in order to make them single-functioning */ - if(id < doObjectCount()) return doObjectName(id); + if(id < doObjectCount()) + return doObjectName(id); populateCachedScenes(); for(UnsignedInt i = 0; i != _cachedScenes->scenes.size(); ++i) { @@ -1317,7 +1320,8 @@ Containers::Optional AbstractImporter::mesh3D(const UnsignedInt id) Containers::Optional AbstractImporter::doMesh3D(const UnsignedInt id) { Containers::Optional out = doMesh(id, 0); - if(out) return MeshData3D{*out}; + if(out) + return MeshData3D{*out}; return Containers::NullOpt; } CORRADE_IGNORE_DEPRECATED_POP diff --git a/src/Magnum/Trade/AbstractSceneConverter.cpp b/src/Magnum/Trade/AbstractSceneConverter.cpp index 0fd8884dd..78c7b94f4 100644 --- a/src/Magnum/Trade/AbstractSceneConverter.cpp +++ b/src/Magnum/Trade/AbstractSceneConverter.cpp @@ -462,7 +462,8 @@ AbstractSceneConverter::convertToData(const MeshData& mesh) { } else if(features() >= (SceneConverterFeature::ConvertMultipleToData|SceneConverterFeature::AddMeshes)) { beginData(); - if(add(mesh)) return endData(); + if(add(mesh)) + return endData(); /* Finish the conversion even if add() fails -- this API shouldn't leave it in an in-progress state */ @@ -485,7 +486,8 @@ bool AbstractSceneConverter::convertToFile(const MeshData& mesh, const Container } else if(features() & (SceneConverterFeature::ConvertMultipleToFile|SceneConverterFeature::AddMeshes)) { beginFile(filename); - if(add(mesh)) return endFile(); + if(add(mesh)) + return endFile(); /* Finish the conversion even if add() fails -- this API shouldn't leave it in an in-progress state */ @@ -506,7 +508,8 @@ bool AbstractSceneConverter::doConvertToFile(const MeshData& mesh, const Contain const Containers::Optional> out = doConvertToData(mesh); /* No deleter checks as it doesn't matter here */ - if(!out) return false; + if(!out) + return false; if(!Utility::Path::write(filename, *out)) { Error() << "Trade::AbstractSceneConverter::convertToFile(): cannot write to file" << filename; @@ -521,7 +524,8 @@ bool AbstractSceneConverter::isConverting() const { } void AbstractSceneConverter::abort() { - if(!_state) return; + if(!_state) + return; doAbort(); _state = {}; @@ -725,7 +729,8 @@ bool AbstractSceneConverter::doEndFile(const Containers::StringView filename) { const Containers::Optional> data = doEndData(); /* No deleter checks as it doesn't matter here */ - if(!data) return false; + if(!data) + return false; if(!Utility::Path::write(filename, *data)) { Error{} << "Trade::AbstractSceneConverter::endFile(): cannot write to file" << filename; @@ -939,7 +944,8 @@ Containers::Optional AbstractSceneConverter::add(const MeshData& me "Trade::AbstractSceneConverter::add(): no conversion in progress", {}); if(features() >= SceneConverterFeature::AddMeshes) { - if(!doAdd(_state->meshCount, mesh, name)) return {}; + if(!doAdd(_state->meshCount, mesh, name)) + return {}; } else if(features() & (SceneConverterFeature::ConvertMesh| SceneConverterFeature::ConvertMeshToData| @@ -1478,7 +1484,8 @@ bool AbstractSceneConverter::addImporterContentsInternal(AbstractImporter& impor Debug{} << "Trade::AbstractSceneConverter::addImporterContents(): importing mesh" << i << "level" << j << "out of" << levelCount; Containers::Optional mesh = importer.mesh(i, j); - if(!mesh) return false; + if(!mesh) + return false; /* Propagate custom attribute names, skip ones that are empty. Compared to data names this is done always to avoid @@ -1487,7 +1494,8 @@ bool AbstractSceneConverter::addImporterContentsInternal(AbstractImporter& impor /** @todo have some kind of a map to not have to query the same custom attribute again for each mesh */ const Trade::MeshAttribute name = mesh->attributeName(k); - if(!isMeshAttributeCustom(name)) continue; + if(!isMeshAttributeCustom(name)) + continue; if(const Containers::String nameString = importer.meshAttributeName(name)) { setMeshAttributeName(name, nameString); } @@ -1534,7 +1542,8 @@ bool AbstractSceneConverter::addImporterContentsInternal(AbstractImporter& impor Debug{} << "Trade::AbstractSceneConverter::addImporterContents(): importing 1D image" << i << "level" << j << "out of" << levelCount; Containers::Optional image = importer.image1D(i, j); - if(!image) return false; + if(!image) + return false; if(image->isCompressed() && !(features() & SceneConverterFeature::AddCompressedImages1D)) { Error{} << "Trade::AbstractSceneConverter::addImporterContents(): 1D image" << i << "level" << j << "is compressed but the converter doesn't support" << SceneConverterFeature::AddCompressedImages1D; @@ -1587,7 +1596,8 @@ bool AbstractSceneConverter::addImporterContentsInternal(AbstractImporter& impor Debug{} << "Trade::AbstractSceneConverter::addImporterContents(): importing 2D image" << i << "level" << j << "out of" << levelCount; Containers::Optional image = importer.image2D(i, j); - if(!image) return false; + if(!image) + return false; if(image->isCompressed() && !(features() & SceneConverterFeature::AddCompressedImages2D)) { Error{} << "Trade::AbstractSceneConverter::addImporterContents(): 2D image" << i << "level" << j << "is compressed but the converter doesn't support" << SceneConverterFeature::AddCompressedImages2D; @@ -1640,7 +1650,8 @@ bool AbstractSceneConverter::addImporterContentsInternal(AbstractImporter& impor Debug{} << "Trade::AbstractSceneConverter::addImporterContents(): importing 3D image" << i << "level" << j << "out of" << levelCount; Containers::Optional image = importer.image3D(i, j); - if(!image) return false; + if(!image) + return false; if(image->isCompressed() && !(features() & SceneConverterFeature::AddCompressedImages3D)) { Error{} << "Trade::AbstractSceneConverter::addImporterContents(): 3D image" << i << "level" << j << "is compressed but the converter doesn't support" << SceneConverterFeature::AddCompressedImages3D; @@ -1722,7 +1733,8 @@ bool AbstractSceneConverter::addImporterContentsInternal(AbstractImporter& impor Debug{} << "Trade::AbstractSceneConverter::addImporterContents(): adding scene" << i << "out of" << iMax; Containers::Optional scene = importer.scene(i); - if(!scene) return false; + if(!scene) + return false; /* Propagate custom field names, skip ones that are empty. Compared to data names this is done always to avoid information loss. */ @@ -1730,7 +1742,8 @@ bool AbstractSceneConverter::addImporterContentsInternal(AbstractImporter& impor /** @todo have some kind of a map to not have to query the same field again for each scene */ const Trade::SceneField name = scene->fieldName(j); - if(!isSceneFieldCustom(name)) continue; + if(!isSceneFieldCustom(name)) + continue; if(const Containers::String nameString = importer.sceneFieldName(name)) { setSceneFieldName(name, nameString); } diff --git a/src/Magnum/Trade/AnimationData.cpp b/src/Magnum/Trade/AnimationData.cpp index 425893a4e..f3acf25eb 100644 --- a/src/Magnum/Trade/AnimationData.cpp +++ b/src/Magnum/Trade/AnimationData.cpp @@ -288,7 +288,8 @@ AnimationData::AnimationData(const DataFlags dataFlags, const Containers::ArrayV AnimationData::AnimationData(Containers::Array&& data, Containers::Array&& tracks, const void* importerState) noexcept: _dataFlags{DataFlag::Owned|DataFlag::Mutable}, _data{Utility::move(data)}, _tracks{Utility::move(tracks)}, _importerState{importerState} { if(!_tracks.isEmpty()) { const auto duration = [](const AnimationTrackData& track) { - if(!track._size) return Range1D{}; + if(!track._size) + return Range1D{}; /* We're sure the view is correct, circumventing the assert */ Containers::StridedArrayView1D keys{{nullptr, ~std::size_t{}}, static_cast(track._keysData), track._size, track._keysStride}; diff --git a/src/Magnum/Trade/ImageData.cpp b/src/Magnum/Trade/ImageData.cpp index cf4389ffa..2572f4eb4 100644 --- a/src/Magnum/Trade/ImageData.cpp +++ b/src/Magnum/Trade/ImageData.cpp @@ -97,7 +97,8 @@ template ImageData::ImageData(const Compress size check below could then die on division by zero. Exit early in that case. */ /** @todo any better idea to handle this? ugh */ - if(!passed) return; + if(!passed) + return; #else static_cast(passed); #endif diff --git a/src/Magnum/Trade/Implementation/arrayUtilities.h b/src/Magnum/Trade/Implementation/arrayUtilities.h index 10733c6d0..724412e6e 100644 --- a/src/Magnum/Trade/Implementation/arrayUtilities.h +++ b/src/Magnum/Trade/Implementation/arrayUtilities.h @@ -41,7 +41,8 @@ template Containers::Array initializerListToArrayWithDefaultDeleter( Containers::Array out{list.size()}; /* FFS why initializer list doesn't have an operator[] */ std::size_t i = 0; - for(auto&& item: list) out[i++] = item; + for(auto&& item: list) + out[i++] = item; return out; } diff --git a/src/Magnum/Trade/Implementation/converterUtilities.h b/src/Magnum/Trade/Implementation/converterUtilities.h index d5dee0c7a..3142c9df5 100644 --- a/src/Magnum/Trade/Implementation/converterUtilities.h +++ b/src/Magnum/Trade/Implementation/converterUtilities.h @@ -101,7 +101,8 @@ void printPluginConfigurationInfo(Debug& d, const Utility::ConfigurationGroup& c /* Print leading space only if there's actually something */ d << Debug::newline; - if(i.second()) d << " " << Debug::boldColor(Debug::Color::Black) << i.second() << Debug::resetColor; + if(i.second()) + d << " " << Debug::boldColor(Debug::Color::Black) << i.second() << Debug::resetColor; } } @@ -116,7 +117,8 @@ void printPluginConfigurationInfo(Debug& d, const Utility::ConfigurationGroup& c void printPluginConfigurationInfo(const Debug::Flags useColor, const PluginManager::AbstractPlugin& plugin) { const Utility::ConfigurationGroup& configuration = plugin.configuration(); - if(configuration.isEmpty()) return; + if(configuration.isEmpty()) + return; Debug d{useColor}; d << Debug::boldColor(Debug::Color::Default) << "Configuration:" << Debug::resetColor; @@ -276,8 +278,10 @@ void printImageInfo(const Debug::Flags useColor, const Containers::ArrayView(info.size.x()); @@ -322,7 +332,8 @@ void printImageInfo(const Debug::Flags useColor, const Containers::ArrayView 1) for(std::size_t j = begin + 1; j != end; ++j) { - if(_data[j - 1].name() < _data[j].name()) continue; + if(_data[j - 1].name() < _data[j].name()) + continue; std::sort(_data + begin, _data + end, [ #ifndef CORRADE_NO_ASSERT @@ -606,8 +607,10 @@ UnsignedInt MaterialData::layerFactorTextureLayer(const MaterialLayer layer) con UnsignedInt MaterialData::attributeCount(const UnsignedInt layer) const { CORRADE_ASSERT(layer < layerCount(), "Trade::MaterialData::attributeCount(): index" << layer << "out of range for" << layerCount() << "layers", {}); - if(!_layerOffsets) return _data.size(); - if(!layer) return _layerOffsets[0]; + if(!_layerOffsets) + return _data.size(); + if(!layer) + return _layerOffsets[0]; return _layerOffsets[layer] - _layerOffsets[layer - 1]; } @@ -632,7 +635,8 @@ UnsignedInt MaterialData::findAttributeIdInternal(const UnsignedInt layer, const const MaterialAttributeData* const found = std::lower_bound(begin, end, name, [](const MaterialAttributeData& a, const Containers::StringView& b) { return a.name() < b; }); - if(found == end || found->name() != name) return ~UnsignedInt{}; + if(found == end || found->name() != name) + return ~UnsignedInt{}; return found - begin; } @@ -1074,7 +1078,8 @@ const void* MaterialData::findAttribute(const UnsignedInt layer, const Container CORRADE_ASSERT(layer < layerCount(), "Trade::MaterialData::findAttribute(): index" << layer << "out of range for" << layerCount() << "layers", {}); const UnsignedInt id = findAttributeIdInternal(layer, name); - if(id == ~UnsignedInt{}) return nullptr; + if(id == ~UnsignedInt{}) + return nullptr; return _data[layerOffset(layer) + id].value(); } @@ -1089,7 +1094,8 @@ const void* MaterialData::findAttribute(const Containers::StringView layer, cons CORRADE_ASSERT(layerId != ~UnsignedInt{}, "Trade::MaterialData::findAttribute(): layer" << layer << "not found", {}); const UnsignedInt id = findAttributeIdInternal(layerId, name); - if(id == ~UnsignedInt{}) return nullptr; + if(id == ~UnsignedInt{}) + return nullptr; return _data[layerOffset(layerId) + id].value(); } @@ -1163,7 +1169,8 @@ Debug& operator<<(Debug& debug, const MaterialAttribute value) { /* LayerName is prefixed with a single space, drop that */ Containers::StringView string = AttributeMap[UnsignedInt(value) - 1].name; - if(string[0] == ' ') string = string.exceptPrefix(1); + if(string[0] == ' ') + string = string.exceptPrefix(1); return debug << "::" << Debug::nospace << string; } diff --git a/src/Magnum/Trade/MaterialData.h b/src/Magnum/Trade/MaterialData.h index 944c13fb2..3fe41fdcd 100644 --- a/src/Magnum/Trade/MaterialData.h +++ b/src/Magnum/Trade/MaterialData.h @@ -3601,7 +3601,8 @@ template<> Containers::ArrayView MaterialAttributeData::value T MaterialData::attribute(const UnsignedInt layer, const UnsignedInt id) const { const void* const value = attribute(layer, id); #ifdef CORRADE_GRACEFUL_ASSERT - if(!value) return {}; + if(!value) + return {}; #endif #ifndef CORRADE_NO_ASSERT const Trade::MaterialAttributeData& data = _data[layerOffset(layer) + id]; @@ -3614,7 +3615,8 @@ template T MaterialData::attribute(const UnsignedInt layer, const Unsig template typename std::conditional::value || std::is_same>::value, T, T&>::type MaterialData::mutableAttribute(const UnsignedInt layer, const UnsignedInt id) { void* const value = mutableAttribute(layer, id); #ifdef CORRADE_GRACEFUL_ASSERT - if(!value) return *reinterpret_cast(this); + if(!value) + return *reinterpret_cast(this); #endif #ifndef CORRADE_NO_ASSERT const Trade::MaterialAttributeData& data = _data[layerOffset(layer) + id]; @@ -3751,7 +3753,8 @@ template Containers::Optional MaterialData::findAttribute(const Unsi CORRADE_ASSERT(layer < layerCount(), "Trade::MaterialData::findAttribute(): index" << layer << "out of range for" << layerCount() << "layers", {}); const UnsignedInt id = findAttributeIdInternal(layer, name); - if(id == ~UnsignedInt{}) return {}; + if(id == ~UnsignedInt{}) + return {}; return attribute(layer, id); } @@ -3790,7 +3793,8 @@ template T MaterialData::attributeOr(const UnsignedInt layer, const Con CORRADE_ASSERT(layer < layerCount(), "Trade::MaterialData::attributeOr(): index" << layer << "out of range for" << layerCount() << "layers", {}); const UnsignedInt id = findAttributeIdInternal(layer, name); - if(id == ~UnsignedInt{}) return defaultValue; + if(id == ~UnsignedInt{}) + return defaultValue; return attribute(layer, id); } diff --git a/src/Magnum/Trade/MeshData.cpp b/src/Magnum/Trade/MeshData.cpp index 216a88a32..9b8473a80 100644 --- a/src/Magnum/Trade/MeshData.cpp +++ b/src/Magnum/Trade/MeshData.cpp @@ -51,9 +51,12 @@ MeshIndexData::MeshIndexData(const Containers::StridedArrayView2D& d return; } - if(data.size()[1] == 4) _type = MeshIndexType::UnsignedInt; - else if(data.size()[1] == 2) _type = MeshIndexType::UnsignedShort; - else if(data.size()[1] == 1) _type = MeshIndexType::UnsignedByte; + if(data.size()[1] == 4) + _type = MeshIndexType::UnsignedInt; + else if(data.size()[1] == 2) + _type = MeshIndexType::UnsignedShort; + else if(data.size()[1] == 1) + _type = MeshIndexType::UnsignedByte; else CORRADE_ASSERT_UNREACHABLE("Trade::MeshIndexData: expected index type size 1, 2 or 4 but got" << data.size()[1], ); CORRADE_ASSERT(data.isContiguous<1>(), @@ -337,7 +340,8 @@ Short MeshData::indexStride() const { Containers::StridedArrayView2D MeshData::indices() const { /* For a non-indexed mesh returning zero size in both dimensions, indexed mesh with zero indices still has the second dimension non-zero */ - if(!isIndexed()) return {}; + if(!isIndexed()) + return {}; const std::size_t indexTypeSize = isMeshIndexTypeImplementationSpecific(_indexType) ? Math::abs(_indexStride) : meshIndexTypeSize(_indexType); @@ -351,7 +355,8 @@ Containers::StridedArrayView2D MeshData::mutableIndices() { "Trade::MeshData::mutableIndices(): index data not mutable", {}); /* For a non-indexed mesh returning zero size in both dimensions, indexed mesh with zero indices still has the second dimension non-zero */ - if(!isIndexed()) return {}; + if(!isIndexed()) + return {}; const std::size_t indexTypeSize = isMeshIndexTypeImplementationSpecific(_indexType) ? Math::abs(_indexStride) : meshIndexTypeSize(_indexType); @@ -457,7 +462,8 @@ UnsignedInt MeshData::findAttributeIdInternal(const MeshAttribute name, Unsigned if(_attributes[i]._name != name || _attributes[i]._morphTargetId != morphTargetId) continue; - if(id-- == 0) return i; + if(id-- == 0) + return i; } return ~UnsignedInt{}; } diff --git a/src/Magnum/Trade/MeshData.h b/src/Magnum/Trade/MeshData.h index f9fbff655..2182f1f5a 100644 --- a/src/Magnum/Trade/MeshData.h +++ b/src/Magnum/Trade/MeshData.h @@ -2730,7 +2730,8 @@ template Containers::StridedArrayView1D MeshData::indices() co "Trade::MeshData::indices(): the mesh is not indexed", {}); Containers::StridedArrayView2D data = indices(); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif CORRADE_ASSERT(!isMeshIndexTypeImplementationSpecific(_indexType), "Trade::MeshData::indices(): can't cast data from an implementation-specific index type" << Debug::hex << meshIndexTypeUnwrap(_indexType), {}); @@ -2744,7 +2745,8 @@ template Containers::StridedArrayView1D MeshData::mutableIndices() { "Trade::MeshData::mutableIndices(): the mesh is not indexed", {}); Containers::StridedArrayView2D data = mutableIndices(); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif CORRADE_ASSERT(!isMeshIndexTypeImplementationSpecific(_indexType), "Trade::MeshData::mutableIndices(): can't cast data from an implementation-specific index type" << Debug::hex << meshIndexTypeUnwrap(_indexType), {}); @@ -2773,10 +2775,12 @@ template bool MeshData::checkVertexFormatCompatibility(const MeshAttrib template::value, int>::type> Containers::StridedArrayView1D MeshData::attribute(const UnsignedInt id) const { Containers::StridedArrayView2D data = attribute(id); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkVertexFormatCompatibility(_attributes[id], "Trade::MeshData::attribute():")) return {}; + if(!checkVertexFormatCompatibility(_attributes[id], "Trade::MeshData::attribute():")) + return {}; #endif return Containers::arrayCast<1, const T>(data); } @@ -2784,10 +2788,12 @@ template::value, int>::type> template::value, int>::type> Containers::StridedArrayView2D::type> MeshData::attribute(const UnsignedInt id) const { Containers::StridedArrayView2D data = attribute(id); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkVertexFormatCompatibility(_attributes[id], "Trade::MeshData::attribute():")) return {}; + if(!checkVertexFormatCompatibility(_attributes[id], "Trade::MeshData::attribute():")) + return {}; #endif return Containers::arrayCast<2, const typename std::remove_extent::type>(data); } @@ -2795,10 +2801,12 @@ template::value, int>::type> C template::value, int>::type> Containers::StridedArrayView1D MeshData::mutableAttribute(const UnsignedInt id) { Containers::StridedArrayView2D data = mutableAttribute(id); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkVertexFormatCompatibility(_attributes[id], "Trade::MeshData::mutableAttribute():")) return {}; + if(!checkVertexFormatCompatibility(_attributes[id], "Trade::MeshData::mutableAttribute():")) + return {}; #endif return Containers::arrayCast<1, T>(data); } @@ -2806,10 +2814,12 @@ template::value, int>::type> template::value, int>::type> Containers::StridedArrayView2D::type> MeshData::mutableAttribute(const UnsignedInt id) { Containers::StridedArrayView2D data = mutableAttribute(id); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkVertexFormatCompatibility(_attributes[id], "Trade::MeshData::mutableAttribute():")) return {}; + if(!checkVertexFormatCompatibility(_attributes[id], "Trade::MeshData::mutableAttribute():")) + return {}; #endif return Containers::arrayCast<2, typename std::remove_extent::type>(data); } @@ -2826,7 +2836,8 @@ template::value, int>::type> /* Unlike mutableAttribute(), the above can't fail, so no early return with CORRADE_GRACEFUL_ASSERT */ #ifndef CORRADE_NO_ASSERT - if(!checkVertexFormatCompatibility(_attributes[attributeId], "Trade::MeshData::attribute():")) return {}; + if(!checkVertexFormatCompatibility(_attributes[attributeId], "Trade::MeshData::attribute():")) + return {}; #endif return Containers::arrayCast<1, const T>(data); } @@ -2843,7 +2854,8 @@ template::value, int>::type> C /* Unlike mutableAttribute(), the above can't fail, so no early return with CORRADE_GRACEFUL_ASSERT */ #ifndef CORRADE_NO_ASSERT - if(!checkVertexFormatCompatibility(_attributes[attributeId], "Trade::MeshData::attribute():")) return {}; + if(!checkVertexFormatCompatibility(_attributes[attributeId], "Trade::MeshData::attribute():")) + return {}; #endif return Containers::arrayCast<2, const typename std::remove_extent::type>(data); } @@ -2858,10 +2870,12 @@ template::value, int>::type> #endif Containers::StridedArrayView2D data = mutableAttribute(attributeId); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkVertexFormatCompatibility(_attributes[attributeId], "Trade::MeshData::mutableAttribute():")) return {}; + if(!checkVertexFormatCompatibility(_attributes[attributeId], "Trade::MeshData::mutableAttribute():")) + return {}; #endif return Containers::arrayCast<1, T>(data); } @@ -2876,10 +2890,12 @@ template::value, int>::type> C #endif Containers::StridedArrayView2D data = mutableAttribute(attributeId); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkVertexFormatCompatibility(_attributes[attributeId], "Trade::MeshData::mutableAttribute():")) return {}; + if(!checkVertexFormatCompatibility(_attributes[attributeId], "Trade::MeshData::mutableAttribute():")) + return {}; #endif return Containers::arrayCast<2, typename std::remove_extent::type>(data); } diff --git a/src/Magnum/Trade/PhongMaterialData.cpp b/src/Magnum/Trade/PhongMaterialData.cpp index 26836dbd0..b074c6dc3 100644 --- a/src/Magnum/Trade/PhongMaterialData.cpp +++ b/src/Magnum/Trade/PhongMaterialData.cpp @@ -396,7 +396,8 @@ Matrix3 PhongMaterialData::commonTextureMatrix() const { #ifdef MAGNUM_BUILD_DEPRECATED Matrix3 PhongMaterialData::textureMatrix() const { - if(hasCommonTextureTransformation()) return commonTextureMatrix(); + if(hasCommonTextureTransformation()) + return commonTextureMatrix(); return attributeOr(MaterialAttribute::TextureMatrix, Matrix3{}); } #endif diff --git a/src/Magnum/Trade/SceneData.cpp b/src/Magnum/Trade/SceneData.cpp index 9a4db85f3..1321ca373 100644 --- a/src/Magnum/Trade/SceneData.cpp +++ b/src/Magnum/Trade/SceneData.cpp @@ -567,7 +567,8 @@ SceneFieldData::SceneFieldData(const SceneField name, const Containers::StridedA #ifdef CORRADE_GRACEFUL_ASSERT /* This caused an assertion in the delegated-to constructor, bail instead of cascading the asserts further */ - if(fieldType == SceneFieldType::Bit) return; + if(fieldType == SceneFieldType::Bit) + return; #endif #ifndef CORRADE_NO_ASSERT @@ -1160,7 +1161,8 @@ UnsignedShort SceneData::fieldArraySize(const UnsignedInt id) const { UnsignedInt SceneData::findFieldIdInternal(const SceneField name) const { for(std::size_t i = 0; i != _fields.size(); ++i) - if(_fields[i]._name == name) return i; + if(_fields[i]._name == name) + return i; return ~UnsignedInt{}; } @@ -1202,13 +1204,15 @@ template std::size_t findObject(const SceneFieldFlags flags, const Cont std::lower_bound() is error prone beyond any reason. */ if(flags >= SceneFieldFlag::OrderedMapping) { const Containers::StridedIterator<1, const T> found = std::lower_bound(mappingT.begin(), mappingT.end(), T(object)); - if(found == mappingT.end() || *found != object) return max; + if(found == mappingT.end() || *found != object) + return max; return found - mappingT.begin(); } /* Generally unordered container, O(n)-complexity search. */ for(std::size_t i = 0; i != max; ++i) - if(mappingT[i] == object) return i; + if(mappingT[i] == object) + return i; return max; } @@ -1749,8 +1753,10 @@ std::size_t SceneData::parentsInto(const std::size_t offset, const Containers::S CORRADE_ASSERT(!mappingDestination != !fieldDestination|| mappingDestination.size() == fieldDestination.size(), "Trade::SceneData::parentsInto(): mapping and field destination views have different size," << mappingDestination.size() << "vs" << fieldDestination.size(), {}); const std::size_t size = Math::min(Math::max(mappingDestination.size(), fieldDestination.size()), fieldSize - offset); - if(mappingDestination) mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); - if(fieldDestination) parentsIntoInternal(fieldId, offset, fieldDestination.prefix(size)); + if(mappingDestination) + mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); + if(fieldDestination) + parentsIntoInternal(fieldId, offset, fieldDestination.prefix(size)); return size; } @@ -1965,8 +1971,10 @@ std::size_t SceneData::transformations2DInto(const std::size_t offset, const Con CORRADE_ASSERT(!mappingDestination != !fieldDestination|| mappingDestination.size() == fieldDestination.size(), "Trade::SceneData::transformations2DInto(): mapping and field destination views have different size," << mappingDestination.size() << "vs" << fieldDestination.size(), {}); const std::size_t size = Math::min(Math::max(mappingDestination.size(), fieldDestination.size()), fieldSize - offset); - if(mappingDestination) mappingIntoInternal(fieldWithObjectMapping, offset, mappingDestination.prefix(size)); - if(fieldDestination) transformations2DIntoInternal(transformationFieldId, translationFieldId, rotationFieldId, scalingFieldId, offset, fieldDestination.prefix(size)); + if(mappingDestination) + mappingIntoInternal(fieldWithObjectMapping, offset, mappingDestination.prefix(size)); + if(fieldDestination) + transformations2DIntoInternal(transformationFieldId, translationFieldId, rotationFieldId, scalingFieldId, offset, fieldDestination.prefix(size)); return size; } @@ -2085,7 +2093,8 @@ std::size_t SceneData::translationsRotationsScalings2DInto(const std::size_t off CORRADE_ASSERT(!rotationDestination != !scalingDestination || rotationDestination.size() == scalingDestination.size(), "Trade::SceneData::translationsRotationsScalings2DInto(): rotation and scaling destination views have different size," << rotationDestination.size() << "vs" << scalingDestination.size(), {}); const std::size_t size = Math::min(Math::max({mappingDestination.size(), translationDestination.size(), rotationDestination.size(), scalingDestination.size()}), fieldSize - offset); - if(mappingDestination) mappingIntoInternal(fieldWithObjectMapping, offset, mappingDestination.prefix(size)); + if(mappingDestination) + mappingIntoInternal(fieldWithObjectMapping, offset, mappingDestination.prefix(size)); translationsRotationsScalings2DIntoInternal(translationFieldId, rotationFieldId, scalingFieldId, offset, translationDestination ? translationDestination.prefix(size) : nullptr, rotationDestination ? rotationDestination.prefix(size) : nullptr, @@ -2211,8 +2220,10 @@ std::size_t SceneData::transformations3DInto(const std::size_t offset, const Con CORRADE_ASSERT(!mappingDestination != !fieldDestination|| mappingDestination.size() == fieldDestination.size(), "Trade::SceneData::transformations3DInto(): mapping and field destination views have different size," << mappingDestination.size() << "vs" << fieldDestination.size(), {}); const std::size_t size = Math::min(Math::max(mappingDestination.size(), fieldDestination.size()), fieldSize - offset); - if(mappingDestination) mappingIntoInternal(fieldWithObjectMapping, offset, mappingDestination.prefix(size)); - if(fieldDestination) transformations3DIntoInternal(transformationFieldId, translationFieldId, rotationFieldId, scalingFieldId, offset, fieldDestination.prefix(size)); + if(mappingDestination) + mappingIntoInternal(fieldWithObjectMapping, offset, mappingDestination.prefix(size)); + if(fieldDestination) + transformations3DIntoInternal(transformationFieldId, translationFieldId, rotationFieldId, scalingFieldId, offset, fieldDestination.prefix(size)); return size; } @@ -2331,7 +2342,8 @@ std::size_t SceneData::translationsRotationsScalings3DInto(const std::size_t off CORRADE_ASSERT(!rotationDestination != !scalingDestination || rotationDestination.size() == scalingDestination.size(), "Trade::SceneData::translationsRotationsScalings3DInto(): rotation and scaling destination views have different size," << rotationDestination.size() << "vs" << scalingDestination.size(), {}); const std::size_t size = Math::min(Math::max({mappingDestination.size(), translationDestination.size(), rotationDestination.size(), scalingDestination.size()}), fieldSize - offset); - if(mappingDestination) mappingIntoInternal(fieldWithObjectMapping, offset, mappingDestination.prefix(size)); + if(mappingDestination) + mappingIntoInternal(fieldWithObjectMapping, offset, mappingDestination.prefix(size)); translationsRotationsScalings3DIntoInternal(translationFieldId, rotationFieldId, scalingFieldId, offset, translationDestination ? translationDestination.prefix(size) : nullptr, rotationDestination ? rotationDestination.prefix(size) : nullptr, @@ -2446,7 +2458,8 @@ std::size_t SceneData::meshesMaterialsInto(const std::size_t offset, const Conta CORRADE_ASSERT(!meshDestination != !meshMaterialDestination || meshMaterialDestination.size() == meshDestination.size(), "Trade::SceneData::meshesMaterialsInto(): mesh and mesh material destination views have different size," << meshDestination.size() << "vs" << meshMaterialDestination.size(), {}); const std::size_t size = Math::min(Math::max({mappingDestination.size(), meshDestination.size(), meshMaterialDestination.size()}), fieldSize - offset); - if(mappingDestination) mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); + if(mappingDestination) + mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); meshesMaterialsIntoInternal(fieldId, offset, meshDestination ? meshDestination.prefix(size) : nullptr, meshMaterialDestination ? meshMaterialDestination.prefix(size) : nullptr); @@ -2491,8 +2504,10 @@ std::size_t SceneData::lightsInto(const std::size_t offset, const Containers::St CORRADE_ASSERT(!mappingDestination != !fieldDestination|| mappingDestination.size() == fieldDestination.size(), "Trade::SceneData::lightsInto(): mapping and field destination views have different size," << mappingDestination.size() << "vs" << fieldDestination.size(), {}); const std::size_t size = Math::min(Math::max(mappingDestination.size(), fieldDestination.size()), fieldSize - offset); - if(mappingDestination) mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); - if(fieldDestination) unsignedIndexFieldIntoInternal(fieldId, offset, fieldDestination.prefix(size)); + if(mappingDestination) + mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); + if(fieldDestination) + unsignedIndexFieldIntoInternal(fieldId, offset, fieldDestination.prefix(size)); return size; } @@ -2527,8 +2542,10 @@ std::size_t SceneData::camerasInto(const std::size_t offset, const Containers::S CORRADE_ASSERT(!mappingDestination != !fieldDestination|| mappingDestination.size() == fieldDestination.size(), "Trade::SceneData::camerasInto(): mapping and field destination views have different size," << mappingDestination.size() << "vs" << fieldDestination.size(), {}); const std::size_t size = Math::min(Math::max(mappingDestination.size(), fieldDestination.size()), fieldSize - offset); - if(mappingDestination) mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); - if(fieldDestination) unsignedIndexFieldIntoInternal(fieldId, offset, fieldDestination.prefix(size)); + if(mappingDestination) + mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); + if(fieldDestination) + unsignedIndexFieldIntoInternal(fieldId, offset, fieldDestination.prefix(size)); return size; } @@ -2563,8 +2580,10 @@ std::size_t SceneData::skinsInto(const std::size_t offset, const Containers::Str CORRADE_ASSERT(!mappingDestination != !fieldDestination|| mappingDestination.size() == fieldDestination.size(), "Trade::SceneData::skinsInto(): mapping and field destination views have different size," << mappingDestination.size() << "vs" << fieldDestination.size(), {}); const std::size_t size = Math::min(Math::max(mappingDestination.size(), fieldDestination.size()), fieldSize - offset); - if(mappingDestination) mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); - if(fieldDestination) unsignedIndexFieldIntoInternal(fieldId, offset, fieldDestination.prefix(size)); + if(mappingDestination) + mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); + if(fieldDestination) + unsignedIndexFieldIntoInternal(fieldId, offset, fieldDestination.prefix(size)); return size; } @@ -2609,8 +2628,10 @@ std::size_t SceneData::importerStateInto(const std::size_t offset, const Contain CORRADE_ASSERT(!mappingDestination != !fieldDestination|| mappingDestination.size() == fieldDestination.size(), "Trade::SceneData::importerStateInto(): mapping and field destination views have different size," << mappingDestination.size() << "vs" << fieldDestination.size(), {}); const std::size_t size = Math::min(Math::max(mappingDestination.size(), fieldDestination.size()), fieldSize - offset); - if(mappingDestination) mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); - if(fieldDestination) importerStateIntoInternal(fieldId, offset, fieldDestination.prefix(size)); + if(mappingDestination) + mappingIntoInternal(fieldId, offset, mappingDestination.prefix(size)); + if(fieldDestination) + importerStateIntoInternal(fieldId, offset, fieldDestination.prefix(size)); return size; } @@ -2640,11 +2661,13 @@ Containers::Optional SceneData::parentFor(const UnsignedLong object) const "Trade::SceneData::parentFor(): object" << object << "out of range for" << _mappingBound << "objects", {}); const UnsignedInt fieldId = findFieldIdInternal(SceneField::Parent); - if(fieldId == ~UnsignedInt{}) return {}; + if(fieldId == ~UnsignedInt{}) + return {}; const SceneFieldData& field = _fields[fieldId]; const std::size_t offset = findFieldObjectOffsetInternal(field, object, 0); - if(offset == field._size) return {}; + if(offset == field._size) + return {}; Int index[1]; parentsIntoInternal(fieldId, offset, index); @@ -2656,7 +2679,8 @@ Containers::Array SceneData::childrenFor(const Long object) const "Trade::SceneData::childrenFor(): object" << object << "out of range for" << _mappingBound << "objects", {}); const UnsignedInt parentFieldId = findFieldIdInternal(SceneField::Parent); - if(parentFieldId == ~UnsignedInt{}) return {}; + if(parentFieldId == ~UnsignedInt{}) + return {}; const SceneFieldData& parentField = _fields[parentFieldId]; @@ -2687,7 +2711,8 @@ Containers::Optional SceneData::transformation2DFor(const UnsignedLong UnsignedInt transformationFieldId, translationFieldId, rotationFieldId, scalingFieldId; const UnsignedInt fieldWithObjectMapping = findTransformationFields(transformationFieldId, translationFieldId, rotationFieldId, scalingFieldId); - if(fieldWithObjectMapping == ~UnsignedInt{}) return {}; + if(fieldWithObjectMapping == ~UnsignedInt{}) + return {}; /* If is2D() returned false as well, all *FieldId would be invalid, which is handled above. */ @@ -2695,7 +2720,8 @@ Containers::Optional SceneData::transformation2DFor(const UnsignedLong const SceneFieldData& field = _fields[fieldWithObjectMapping]; const std::size_t offset = findFieldObjectOffsetInternal(field, object, 0); - if(offset == field._size) return {}; + if(offset == field._size) + return {}; Matrix3 transformation[1]; transformations2DIntoInternal(transformationFieldId, translationFieldId, rotationFieldId, scalingFieldId, offset, transformation); @@ -2708,7 +2734,8 @@ Containers::Optional> SceneData::t UnsignedInt translationFieldId, rotationFieldId, scalingFieldId; const UnsignedInt fieldWithObjectMapping = findTranslationRotationScalingFields(translationFieldId, rotationFieldId, scalingFieldId); - if(fieldWithObjectMapping == ~UnsignedInt{}) return {}; + if(fieldWithObjectMapping == ~UnsignedInt{}) + return {}; /* If is2D() returned false as well, all *FieldId would be invalid, which is handled above. */ @@ -2716,7 +2743,8 @@ Containers::Optional> SceneData::t const SceneFieldData& field = _fields[fieldWithObjectMapping]; const std::size_t offset = findFieldObjectOffsetInternal(field, object, 0); - if(offset == field._size) return {}; + if(offset == field._size) + return {}; Vector2 translation[1]; Complex rotation[1]; @@ -2731,7 +2759,8 @@ Containers::Optional SceneData::transformation3DFor(const UnsignedLong UnsignedInt transformationFieldId, translationFieldId, rotationFieldId, scalingFieldId; const UnsignedInt fieldWithObjectMapping = findTransformationFields(transformationFieldId, translationFieldId, rotationFieldId, scalingFieldId); - if(fieldWithObjectMapping == ~UnsignedInt{}) return {}; + if(fieldWithObjectMapping == ~UnsignedInt{}) + return {}; /* If is3D() returned false as well, all *FieldId would be invalid, which is handled above. */ @@ -2739,7 +2768,8 @@ Containers::Optional SceneData::transformation3DFor(const UnsignedLong const SceneFieldData& field = _fields[fieldWithObjectMapping]; const std::size_t offset = findFieldObjectOffsetInternal(field, object, 0); - if(offset == field._size) return {}; + if(offset == field._size) + return {}; Matrix4 transformation[1]; transformations3DIntoInternal(transformationFieldId, translationFieldId, rotationFieldId, scalingFieldId, offset, transformation); @@ -2752,7 +2782,8 @@ Containers::Optional> SceneData UnsignedInt translationFieldId, rotationFieldId, scalingFieldId; const UnsignedInt fieldWithObjectMapping = findTranslationRotationScalingFields(translationFieldId, rotationFieldId, scalingFieldId); - if(fieldWithObjectMapping == ~UnsignedInt{}) return {}; + if(fieldWithObjectMapping == ~UnsignedInt{}) + return {}; /* If is3D() returned false as well, all *FieldId would be invalid, which is handled above. */ @@ -2760,7 +2791,8 @@ Containers::Optional> SceneData const SceneFieldData& field = _fields[fieldWithObjectMapping]; const std::size_t offset = findFieldObjectOffsetInternal(field, object, 0); - if(offset == field._size) return {}; + if(offset == field._size) + return {}; Vector3 translation[1]; Quaternion rotation[1]; @@ -2774,14 +2806,16 @@ Containers::Array> SceneData::meshesMaterials "Trade::SceneData::meshesMaterialsFor(): object" << object << "out of range for" << _mappingBound << "objects", {}); const UnsignedInt meshFieldId = findFieldIdInternal(SceneField::Mesh); - if(meshFieldId == ~UnsignedInt{}) return {}; + if(meshFieldId == ~UnsignedInt{}) + return {}; const SceneFieldData& field = _fields[meshFieldId]; Containers::Array> out; std::size_t offset = 0; for(;;) { offset = findFieldObjectOffsetInternal(field, object, offset); - if(offset == field._size) break; + if(offset == field._size) + break; UnsignedInt mesh[1]; Int material[1]; @@ -2798,14 +2832,16 @@ Containers::Array SceneData::lightsFor(const UnsignedLong object) c "Trade::SceneData::lightsFor(): object" << object << "out of range for" << _mappingBound << "objects", {}); const UnsignedInt fieldId = findFieldIdInternal(SceneField::Light); - if(fieldId == ~UnsignedInt{}) return {}; + if(fieldId == ~UnsignedInt{}) + return {}; const SceneFieldData& field = _fields[fieldId]; Containers::Array out; std::size_t offset = 0; for(;;) { offset = findFieldObjectOffsetInternal(field, object, offset); - if(offset == field._size) break; + if(offset == field._size) + break; UnsignedInt index[1]; unsignedIndexFieldIntoInternal(fieldId, offset, index); @@ -2821,14 +2857,16 @@ Containers::Array SceneData::camerasFor(const UnsignedLong object) "Trade::SceneData::camerasFor(): object" << object << "out of range for" << _mappingBound << "objects", {}); const UnsignedInt fieldId = findFieldIdInternal(SceneField::Camera); - if(fieldId == ~UnsignedInt{}) return {}; + if(fieldId == ~UnsignedInt{}) + return {}; const SceneFieldData& field = _fields[fieldId]; Containers::Array out; std::size_t offset = 0; for(;;) { offset = findFieldObjectOffsetInternal(field, object, offset); - if(offset == field._size) break; + if(offset == field._size) + break; UnsignedInt index[1]; unsignedIndexFieldIntoInternal(fieldId, offset, index); @@ -2844,14 +2882,16 @@ Containers::Array SceneData::skinsFor(const UnsignedLong object) co "Trade::SceneData::skinsFor(): object" << object << "out of range for" << _mappingBound << "objects", {}); const UnsignedInt fieldId = findFieldIdInternal(SceneField::Skin); - if(fieldId == ~UnsignedInt{}) return {}; + if(fieldId == ~UnsignedInt{}) + return {}; const SceneFieldData& field = _fields[fieldId]; Containers::Array out; std::size_t offset = 0; for(;;) { offset = findFieldObjectOffsetInternal(field, object, offset); - if(offset == field._size) break; + if(offset == field._size) + break; UnsignedInt index[1]; unsignedIndexFieldIntoInternal(fieldId, offset, index); @@ -2867,11 +2907,13 @@ Containers::Optional SceneData::importerStateFor(const UnsignedLong "Trade::SceneData::importerStateFor(): object" << object << "out of range for" << _mappingBound << "objects", {}); const UnsignedInt fieldId = findFieldIdInternal(SceneField::ImporterState); - if(fieldId == ~UnsignedInt{}) return {}; + if(fieldId == ~UnsignedInt{}) + return {}; const SceneFieldData& field = _fields[fieldId]; const std::size_t offset = findFieldObjectOffsetInternal(field, object, 0); - if(offset == field._size) return {}; + if(offset == field._size) + return {}; const void* importerState[1]; importerStateIntoInternal(fieldId, offset, importerState); @@ -2880,7 +2922,8 @@ Containers::Optional SceneData::importerStateFor(const UnsignedLong #ifdef MAGNUM_BUILD_DEPRECATED std::vector SceneData::children2D() const { - if(_dimensions != 2) return {}; + if(_dimensions != 2) + return {}; /* Even though (or exactly because?) this API is deprecated, it's better to warn than to spend several hours debugging what's wrong */ @@ -2892,7 +2935,8 @@ std::vector SceneData::children2D() const { } std::vector SceneData::children3D() const { - if(_dimensions != 3) return {}; + if(_dimensions != 3) + return {}; /* Even though (or exactly because?) this API is deprecated, it's better to warn than to spend several hours debugging what's wrong */ diff --git a/src/Magnum/Trade/SceneData.h b/src/Magnum/Trade/SceneData.h index cd3793814..e97e5d4e7 100644 --- a/src/Magnum/Trade/SceneData.h +++ b/src/Magnum/Trade/SceneData.h @@ -4246,7 +4246,8 @@ constexpr SceneFieldData::SceneFieldData(const SceneField name, const std::size_ template Containers::StridedArrayView1D SceneData::mapping(const UnsignedInt fieldId) const { Containers::StridedArrayView2D data = mapping(fieldId); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif CORRADE_ASSERT(Implementation::sceneMappingTypeFor() == _mappingType, "Trade::SceneData::mapping(): mapping is" << _mappingType << "but requested" << Implementation::sceneMappingTypeFor(), {}); @@ -4256,7 +4257,8 @@ template Containers::StridedArrayView1D SceneData::mapping(con template Containers::StridedArrayView1D SceneData::mutableMapping(const UnsignedInt fieldId) { Containers::StridedArrayView2D data = mutableMapping(fieldId); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif CORRADE_ASSERT(Implementation::sceneMappingTypeFor() == _mappingType, "Trade::SceneData::mutableMapping(): mapping is" << _mappingType << "but requested" << Implementation::sceneMappingTypeFor(), {}); @@ -4266,7 +4268,8 @@ template Containers::StridedArrayView1D SceneData::mutableMapping(co template Containers::StridedArrayView1D SceneData::mapping(const SceneField fieldName) const { Containers::StridedArrayView2D data = mapping(fieldName); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif CORRADE_ASSERT(Implementation::sceneMappingTypeFor() == _mappingType, "Trade::SceneData::mapping(): mapping is" << _mappingType << "but requested" << Implementation::sceneMappingTypeFor(), {}); @@ -4276,7 +4279,8 @@ template Containers::StridedArrayView1D SceneData::mapping(con template Containers::StridedArrayView1D SceneData::mutableMapping(const SceneField fieldName) { Containers::StridedArrayView2D data = mutableMapping(fieldName); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif CORRADE_ASSERT(Implementation::sceneMappingTypeFor() == _mappingType, "Trade::SceneData::mutableMapping(): mapping is" << _mappingType << "but requested" << Implementation::sceneMappingTypeFor(), {}); @@ -4301,10 +4305,12 @@ template bool SceneData::checkFieldTypeCompatibility(const SceneFieldDa template::value, int>::type> Containers::StridedArrayView1D SceneData::field(const UnsignedInt id) const { Containers::StridedArrayView2D data = field(id); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkFieldTypeCompatibility(_fields[id], "Trade::SceneData::field():")) return {}; + if(!checkFieldTypeCompatibility(_fields[id], "Trade::SceneData::field():")) + return {}; #endif return Containers::arrayCast<1, const T>(data); } @@ -4312,10 +4318,12 @@ template::value, int>::type> template::value, int>::type> Containers::StridedArrayView2D::type> SceneData::field(const UnsignedInt id) const { Containers::StridedArrayView2D data = field(id); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkFieldTypeCompatibility(_fields[id], "Trade::SceneData::field():")) return {}; + if(!checkFieldTypeCompatibility(_fields[id], "Trade::SceneData::field():")) + return {}; #endif return Containers::arrayCast<2, const typename std::remove_extent::type>(data); } @@ -4323,10 +4331,12 @@ template::value, int>::type> C template::value, int>::type> Containers::StridedArrayView1D SceneData::mutableField(const UnsignedInt id) { Containers::StridedArrayView2D data = mutableField(id); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkFieldTypeCompatibility(_fields[id], "Trade::SceneData::mutableField():")) return {}; + if(!checkFieldTypeCompatibility(_fields[id], "Trade::SceneData::mutableField():")) + return {}; #endif return Containers::arrayCast<1, T>(data); } @@ -4334,10 +4344,12 @@ template::value, int>::type> template::value, int>::type> Containers::StridedArrayView2D::type> SceneData::mutableField(const UnsignedInt id) { Containers::StridedArrayView2D data = mutableField(id); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkFieldTypeCompatibility(_fields[id], "Trade::SceneData::mutableField():")) return {}; + if(!checkFieldTypeCompatibility(_fields[id], "Trade::SceneData::mutableField():")) + return {}; #endif return Containers::arrayCast<2, typename std::remove_extent::type>(data); } @@ -4348,10 +4360,12 @@ template::value, int>::type> "Trade::SceneData::field(): field" << name << "not found", {}); Containers::StridedArrayView2D data = field(fieldId); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkFieldTypeCompatibility(_fields[fieldId], "Trade::SceneData::field():")) return {}; + if(!checkFieldTypeCompatibility(_fields[fieldId], "Trade::SceneData::field():")) + return {}; #endif return Containers::arrayCast<1, const T>(data); } @@ -4362,10 +4376,12 @@ template::value, int>::type> C "Trade::SceneData::field(): field" << name << "not found", {}); Containers::StridedArrayView2D data = field(fieldId); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkFieldTypeCompatibility(_fields[fieldId], "Trade::SceneData::field():")) return {}; + if(!checkFieldTypeCompatibility(_fields[fieldId], "Trade::SceneData::field():")) + return {}; #endif return Containers::arrayCast<2, const typename std::remove_extent::type>(data); } @@ -4376,10 +4392,12 @@ template::value, int>::type> "Trade::SceneData::mutableField(): field" << name << "not found", {}); Containers::StridedArrayView2D data = mutableField(fieldId); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkFieldTypeCompatibility(_fields[fieldId], "Trade::SceneData::mutableField():")) return {}; + if(!checkFieldTypeCompatibility(_fields[fieldId], "Trade::SceneData::mutableField():")) + return {}; #endif return Containers::arrayCast<1, T>(data); } @@ -4390,10 +4408,12 @@ template::value, int>::type> C "Trade::SceneData::mutableField(): field" << name << "not found", {}); Containers::StridedArrayView2D data = mutableField(fieldId); #ifdef CORRADE_GRACEFUL_ASSERT /* Sigh. Brittle. Better idea? */ - if(!data.stride()[1]) return {}; + if(!data.stride()[1]) + return {}; #endif #ifndef CORRADE_NO_ASSERT - if(!checkFieldTypeCompatibility(_fields[fieldId], "Trade::SceneData::mutableField():")) return {}; + if(!checkFieldTypeCompatibility(_fields[fieldId], "Trade::SceneData::mutableField():")) + return {}; #endif return Containers::arrayCast<2, typename std::remove_extent::type>(data); } diff --git a/src/Magnum/Trade/Test/AbstractImporterTest.cpp b/src/Magnum/Trade/Test/AbstractImporterTest.cpp index bc6522ae8..9b48efde5 100644 --- a/src/Magnum/Trade/Test/AbstractImporterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImporterTest.cpp @@ -1984,7 +1984,8 @@ void AbstractImporterTest::thingByNameNotFound() { Containers::String out; { Containers::Optional redirectError; - if(data.checkMessage) redirectError.emplace(&out); + if(data.checkMessage) + redirectError.emplace(&out); CORRADE_VERIFY(!importer.scene("foobar")); CORRADE_VERIFY(!importer.animation("foobar")); @@ -2196,11 +2197,13 @@ void AbstractImporterTest::scene() { UnsignedInt doSceneCount() const override { return 8; } Int doSceneForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doSceneName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doScene(UnsignedInt id) override { @@ -2256,11 +2259,13 @@ void AbstractImporterTest::object() { UnsignedLong doObjectCount() const override { return 8; } Long doObjectForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doObjectName(UnsignedLong id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } } importer; @@ -2409,11 +2414,13 @@ void AbstractImporterTest::sceneDeprecatedFallback2D() { UnsignedInt doSceneCount() const override { return 3; } UnsignedLong doObjectCount() const override { return 7; } Long doObjectForName(Containers::StringView name) override { - if(name == "sixth") return 5; + if(name == "sixth") + return 5; return -1; } Containers::String doObjectName(UnsignedLong id) override { - if(id == 5) return "sixth"; + if(id == 5) + return "sixth"; return {}; } Containers::Optional doScene(UnsignedInt id) override { @@ -2681,11 +2688,13 @@ void AbstractImporterTest::sceneDeprecatedFallback3D() { UnsignedInt doSceneCount() const override { return 3; } UnsignedLong doObjectCount() const override { return 7; } Long doObjectForName(Containers::StringView name) override { - if(name == "sixth") return 5; + if(name == "sixth") + return 5; return -1; } Containers::String doObjectName(UnsignedLong id) override { - if(id == 5) return "sixth"; + if(id == 5) + return "sixth"; return {}; } Containers::Optional doScene(UnsignedInt id) override { @@ -3302,11 +3311,16 @@ void AbstractImporterTest::sceneDeprecatedFallbackMultiFunctionObjects2D() { UnsignedInt doSceneCount() const override { return 4; } UnsignedLong doObjectCount() const override { return 63; } Containers::String doObjectName(UnsignedLong id) override { - if(id == 1) return "object 1"; - if(id == 15) return "object 15"; - if(id == 23) return "object 23"; - if(id == 30) return "object 30 from secondary scene"; - if(id == 62) return "last"; + if(id == 1) + return "object 1"; + if(id == 15) + return "object 15"; + if(id == 23) + return "object 23"; + if(id == 30) + return "object 30 from secondary scene"; + if(id == 62) + return "last"; CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } Containers::Optional doScene(UnsignedInt id) override { @@ -3584,11 +3598,16 @@ void AbstractImporterTest::sceneDeprecatedFallbackMultiFunctionObjects3D() { UnsignedInt doSceneCount() const override { return 4; } UnsignedLong doObjectCount() const override { return 63; } Containers::String doObjectName(UnsignedLong id) override { - if(id == 1) return "object 1"; - if(id == 15) return "object 15"; - if(id == 23) return "object 23"; - if(id == 30) return "object 30 from secondary scene"; - if(id == 62) return "last"; + if(id == 1) + return "object 1"; + if(id == 15) + return "object 15"; + if(id == 23) + return "object 23"; + if(id == 30) + return "object 30 from secondary scene"; + if(id == 62) + return "last"; CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } Containers::Optional doScene(UnsignedInt id) override { @@ -3825,11 +3844,13 @@ void AbstractImporterTest::sceneDeprecatedFallbackBoth2DAnd3DScene() { UnsignedInt doSceneCount() const override { return 2; } UnsignedLong doObjectCount() const override { return 7; } Long doObjectForName(Containers::StringView name) override { - if(name == "sixth") return 5; + if(name == "sixth") + return 5; return -1; } Containers::String doObjectName(UnsignedLong id) override { - if(id == 5) return "sixth"; + if(id == 5) + return "sixth"; return {}; } Containers::Optional doScene(UnsignedInt id) override { @@ -4096,12 +4117,14 @@ void AbstractImporterTest::sceneFieldName() { void doClose() override {} SceneField doSceneFieldForName(Containers::StringView name) override { - if(name == "octreeCell") return sceneFieldCustom(100037); + if(name == "octreeCell") + return sceneFieldCustom(100037); return SceneField{}; } Containers::String doSceneFieldName(SceneField id) override { - if(id == sceneFieldCustom(100037)) return "octreeCell"; + if(id == sceneFieldCustom(100037)) + return "octreeCell"; return ""; } } importer; @@ -4170,11 +4193,13 @@ void AbstractImporterTest::animation() { UnsignedInt doAnimationCount() const override { return 8; } Int doAnimationForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doAnimationName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doAnimation(UnsignedInt id) override { @@ -4427,12 +4452,14 @@ void AbstractImporterTest::animationTrackTargetName() { void doClose() override {} AnimationTrackTarget doAnimationTrackTargetForName(Containers::StringView name) override { - if(name == "visibility") return animationTrackTargetCustom(37); + if(name == "visibility") + return animationTrackTargetCustom(37); return AnimationTrackTarget{}; } Containers::String doAnimationTrackTargetName(AnimationTrackTarget id) override { - if(id == animationTrackTargetCustom(37)) return "visibility"; + if(id == animationTrackTargetCustom(37)) + return "visibility"; return ""; } } importer; @@ -4501,15 +4528,18 @@ void AbstractImporterTest::light() { UnsignedInt doLightCount() const override { return 8; } Int doLightForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doLightName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doLight(UnsignedInt id) override { - if(id == 7) return LightData{{}, {}, {}, &state}; + if(id == 7) + return LightData{{}, {}, {}, &state}; return {}; } } importer; @@ -4664,15 +4694,18 @@ void AbstractImporterTest::camera() { UnsignedInt doCameraCount() const override { return 8; } Int doCameraForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doCameraName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doCamera(UnsignedInt id) override { - if(id == 7) return CameraData{{}, Vector2{}, {}, {}, &state}; + if(id == 7) + return CameraData{{}, Vector2{}, {}, {}, &state}; return {}; } } importer; @@ -4828,16 +4861,19 @@ void AbstractImporterTest::object2D() { UnsignedInt doObject2DCount() const override { return 8; } Int doObject2DForName(const std::string& name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } std::string doObject2DName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } CORRADE_IGNORE_DEPRECATED_PUSH Containers::Pointer doObject2D(UnsignedInt id) override { - if(id == 7) return Containers::pointer(new ObjectData2D{{}, {}, &state}); + if(id == 7) + return Containers::pointer(new ObjectData2D{{}, {}, &state}); return {}; } CORRADE_IGNORE_DEPRECATED_POP @@ -4935,7 +4971,8 @@ void AbstractImporterTest::object2DByNameNotFound() { Containers::String out; { Containers::Optional redirectError; - if(data.checkMessage) redirectError.emplace(&out); + if(data.checkMessage) + redirectError.emplace(&out); CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_VERIFY(!importer.object2D("foobar")); @@ -5092,16 +5129,19 @@ void AbstractImporterTest::object3D() { UnsignedInt doObject3DCount() const override { return 8; } Int doObject3DForName(const std::string& name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } std::string doObject3DName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } CORRADE_IGNORE_DEPRECATED_PUSH Containers::Pointer doObject3D(UnsignedInt id) override { - if(id == 7) return Containers::pointer(new ObjectData3D{{}, {}, &state}); + if(id == 7) + return Containers::pointer(new ObjectData3D{{}, {}, &state}); return {}; } CORRADE_IGNORE_DEPRECATED_POP @@ -5199,7 +5239,8 @@ void AbstractImporterTest::object3DByNameNotFound() { Containers::String out; { Containers::Optional redirectError; - if(data.checkMessage) redirectError.emplace(&out); + if(data.checkMessage) + redirectError.emplace(&out); CORRADE_IGNORE_DEPRECATED_PUSH CORRADE_VERIFY(!importer.object3D("foobar")); @@ -5357,17 +5398,20 @@ void AbstractImporterTest::skin2D() { UnsignedInt doSkin2DCount() const override { return 8; } Int doSkin2DForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doSkin2DName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doSkin2D(UnsignedInt id) override { /* Verify that initializer list is converted to an array with the default deleter and not something disallowed */ - if(id == 7) return SkinData2D{{1}, {{}}, &state}; + if(id == 7) + return SkinData2D{{1}, {{}}, &state}; return {}; } } importer; @@ -5600,17 +5644,20 @@ void AbstractImporterTest::skin3D() { UnsignedInt doSkin3DCount() const override { return 8; } Int doSkin3DForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doSkin3DName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doSkin3D(UnsignedInt id) override { /* Verify that initializer list is converted to an array with the default deleter and not something disallowed */ - if(id == 7) return SkinData3D{{1}, {{}}, &state}; + if(id == 7) + return SkinData3D{{1}, {{}}, &state}; return {}; } } importer; @@ -5844,21 +5891,25 @@ void AbstractImporterTest::mesh() { UnsignedInt doMeshCount() const override { return 8; } UnsignedInt doMeshLevelCount(UnsignedInt id) override { - if(id == 7) return 3; + if(id == 7) + return 3; return {}; } Int doMeshForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doMeshName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doMesh(UnsignedInt id, UnsignedInt level) override { /* Verify that initializer list is converted to an array with the default deleter and not something disallowed */ - if(id == 7 && level == 2) return MeshData{MeshPrimitive::Points, nullptr, {MeshAttributeData{MeshAttribute::Position, VertexFormat::Vector3, nullptr}}, MeshData::ImplicitVertexCount, &state}; + if(id == 7 && level == 2) + return MeshData{MeshPrimitive::Points, nullptr, {MeshAttributeData{MeshAttribute::Position, VertexFormat::Vector3, nullptr}}, MeshData::ImplicitVertexCount, &state}; return {}; } } importer; @@ -5910,15 +5961,18 @@ void AbstractImporterTest::meshDeprecatedFallback() { UnsignedInt doMeshCount() const override { return 8; } Int doMeshForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doMeshName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doMesh(UnsignedInt id, UnsignedInt level) override { - if(id == 7 && level == 0) return MeshData{MeshPrimitive::Points, nullptr, {MeshAttributeData{MeshAttribute::Position, VertexFormat::Vector3, nullptr}}, MeshData::ImplicitVertexCount, &state}; + if(id == 7 && level == 0) + return MeshData{MeshPrimitive::Points, nullptr, {MeshAttributeData{MeshAttribute::Position, VertexFormat::Vector3, nullptr}}, MeshData::ImplicitVertexCount, &state}; return {}; } } importer; @@ -6260,12 +6314,14 @@ void AbstractImporterTest::meshAttributeName() { void doClose() override {} MeshAttribute doMeshAttributeForName(Containers::StringView name) override { - if(name == "SMOOTH_GROUP_ID") return meshAttributeCustom(37); + if(name == "SMOOTH_GROUP_ID") + return meshAttributeCustom(37); return MeshAttribute{}; } Containers::String doMeshAttributeName(MeshAttribute id) override { - if(id == meshAttributeCustom(37)) return "SMOOTH_GROUP_ID"; + if(id == meshAttributeCustom(37)) + return "SMOOTH_GROUP_ID"; return ""; } } importer; @@ -6335,16 +6391,19 @@ void AbstractImporterTest::mesh2D() { UnsignedInt doMesh2DCount() const override { return 8; } Int doMesh2DForName(const std::string& name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } std::string doMesh2DName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } CORRADE_IGNORE_DEPRECATED_PUSH Containers::Optional doMesh2D(UnsignedInt id) override { - if(id == 7) return MeshData2D{{}, {}, {{}}, {}, {}, &state}; + if(id == 7) + return MeshData2D{{}, {}, {{}}, {}, {}, &state}; return {}; } CORRADE_IGNORE_DEPRECATED_POP @@ -6539,16 +6598,19 @@ void AbstractImporterTest::mesh3D() { UnsignedInt doMesh3DCount() const override { return 8; } Int doMesh3DForName(const std::string& name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } std::string doMesh3DName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } CORRADE_IGNORE_DEPRECATED_PUSH Containers::Optional doMesh3D(UnsignedInt id) override { - if(id == 7) return MeshData3D{{}, {}, {{}}, {}, {}, {}, &state}; + if(id == 7) + return MeshData3D{{}, {}, {{}}, {}, {}, {}, &state}; return {}; } CORRADE_IGNORE_DEPRECATED_POP @@ -6746,15 +6808,18 @@ void AbstractImporterTest::material() { UnsignedInt doMaterialCount() const override { return 8; } Int doMaterialForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doMaterialName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doMaterial(UnsignedInt id) override { - if(id == 7) return Containers::optional(MaterialTypes{}, nullptr, &state); + if(id == 7) + return Containers::optional(MaterialTypes{}, nullptr, &state); return {}; } } importer; @@ -7030,15 +7095,18 @@ void AbstractImporterTest::texture() { UnsignedInt doTextureCount() const override { return 8; } Int doTextureForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doTextureName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doTexture(UnsignedInt id) override { - if(id == 7) return TextureData{{}, {}, {}, {}, {}, {}, &state}; + if(id == 7) + return TextureData{{}, {}, {}, {}, {}, {}, &state}; return {}; } } importer; @@ -7193,19 +7261,23 @@ void AbstractImporterTest::image1D() { UnsignedInt doImage1DCount() const override { return 8; } UnsignedInt doImage1DLevelCount(UnsignedInt id) override { - if(id == 7) return 3; + if(id == 7) + return 3; return {}; } Int doImage1DForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doImage1DName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doImage1D(UnsignedInt id, UnsignedInt level) override { - if(id == 7 && level == 2) return ImageData1D{PixelFormat::RGBA8Unorm, {}, {}, ImageFlags1D{}, &state}; + if(id == 7 && level == 2) + return ImageData1D{PixelFormat::RGBA8Unorm, {}, {}, ImageFlags1D{}, &state}; return {}; } } importer; @@ -7501,19 +7573,23 @@ void AbstractImporterTest::image2D() { UnsignedInt doImage2DCount() const override { return 8; } UnsignedInt doImage2DLevelCount(UnsignedInt id) override { - if(id == 7) return 3; + if(id == 7) + return 3; return {}; } Int doImage2DForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doImage2DName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doImage2D(UnsignedInt id, UnsignedInt level) override { - if(id == 7 && level == 2) return ImageData2D{PixelFormat::RGBA8Unorm, {}, {}, ImageFlags2D{}, &state}; + if(id == 7 && level == 2) + return ImageData2D{PixelFormat::RGBA8Unorm, {}, {}, ImageFlags2D{}, &state}; return {}; } } importer; @@ -7809,19 +7885,23 @@ void AbstractImporterTest::image3D() { UnsignedInt doImage3DCount() const override { return 8; } UnsignedInt doImage3DLevelCount(UnsignedInt id) override { - if(id == 7) return 3; + if(id == 7) + return 3; return {}; } Int doImage3DForName(Containers::StringView name) override { - if(name == "eighth") return 7; + if(name == "eighth") + return 7; return -1; } Containers::String doImage3DName(UnsignedInt id) override { - if(id == 7) return "eighth"; + if(id == 7) + return "eighth"; return {}; } Containers::Optional doImage3D(UnsignedInt id, UnsignedInt level) override { - if(id == 7 && level == 2) return ImageData3D{PixelFormat::RGBA8Unorm, {}, {}, ImageFlags3D{}, &state}; + if(id == 7 && level == 2) + return ImageData3D{PixelFormat::RGBA8Unorm, {}, {}, ImageFlags3D{}, &state}; return {}; } } importer; diff --git a/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp b/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp index 76a26f0be..e73ab7559 100644 --- a/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp @@ -6819,8 +6819,10 @@ void AbstractSceneConverterTest::addImporterContentsCustomSceneFields() { return SceneData{SceneMappingType::UnsignedInt, 0, nullptr, {}}; } Containers::String doSceneFieldName(SceneField name) override { - if(name == sceneFieldCustom(34977)) return "offsetSmall"; - if(name == sceneFieldCustom(5266)) return "valueData"; + if(name == sceneFieldCustom(34977)) + return "offsetSmall"; + if(name == sceneFieldCustom(5266)) + return "valueData"; CORRADE_FAIL("This should not be reached"); CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } @@ -6884,8 +6886,10 @@ void AbstractSceneConverterTest::addImporterContentsCustomMeshAttributes() { return MeshData{MeshPrimitive::Points, 0}; } Containers::String doMeshAttributeName(MeshAttribute name) override { - if(name == meshAttributeCustom(31977)) return "offsetSmall"; - if(name == meshAttributeCustom(5266)) return "valueData"; + if(name == meshAttributeCustom(31977)) + return "offsetSmall"; + if(name == meshAttributeCustom(5266)) + return "valueData"; CORRADE_FAIL("This should not be reached"); CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } @@ -6941,7 +6945,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { return contents & SceneContent::Scenes ? 4 : 0; } Containers::Optional doScene(UnsignedInt id) override { - if(id == 2) return {}; + if(id == 2) + return {}; return SceneData{SceneMappingType::UnsignedInt, 0, nullptr, {}}; } @@ -6949,7 +6954,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { return contents & SceneContent::Animations ? 4 : 0; } Containers::Optional doAnimation(UnsignedInt id) override { - if(id == 2) return {}; + if(id == 2) + return {}; return AnimationData{nullptr, {}}; } @@ -6957,7 +6963,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { return contents & SceneContent::Lights ? 4 : 0; } Containers::Optional doLight(UnsignedInt id) override { - if(id == 2) return {}; + if(id == 2) + return {}; return LightData{LightType::Point, {}, {}}; } @@ -6965,7 +6972,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { return contents & SceneContent::Cameras ? 4 : 0; } Containers::Optional doCamera(UnsignedInt id) override { - if(id == 2) return {}; + if(id == 2) + return {}; return CameraData{CameraType::Orthographic2D, {}, 0.0f, 0.0f}; } @@ -6973,7 +6981,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { return contents & SceneContent::Skins2D ? 4 : 0; } Containers::Optional doSkin2D(UnsignedInt id) override { - if(id == 2) return {}; + if(id == 2) + return {}; return SkinData2D{{}, {}}; } @@ -6981,7 +6990,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { return contents & SceneContent::Skins3D ? 4 : 0; } Containers::Optional doSkin3D(UnsignedInt id) override { - if(id == 2) return {}; + if(id == 2) + return {}; return SkinData3D{{}, {}}; } @@ -6994,7 +7004,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { Containers::Optional doMesh(UnsignedInt id, UnsignedInt level) override { if(id == 2) { if(contents & SceneContent::MeshLevels) { - if(level == 3) return {}; + if(level == 3) + return {}; } else return {}; } @@ -7005,7 +7016,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { return contents & SceneContent::Materials ? 4 : 0; } Containers::Optional doMaterial(UnsignedInt id) override { - if(id == 2) return {}; + if(id == 2) + return {}; return MaterialData{{}, {}}; } @@ -7013,7 +7025,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { return contents & SceneContent::Textures ? 4 : 0; } Containers::Optional doTexture(UnsignedInt id) override { - if(id == 2) return {}; + if(id == 2) + return {}; return TextureData{TextureType::Texture1D, SamplerFilter::Nearest, SamplerFilter::Nearest, SamplerMipmap::Nearest, SamplerWrapping::ClampToEdge, 0}; } @@ -7026,7 +7039,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { Containers::Optional doImage1D(UnsignedInt id, UnsignedInt level) override { if(id == 2) { if(contents & SceneContent::ImageLevels) { - if(level == 3) return {}; + if(level == 3) + return {}; } else return {}; } @@ -7042,7 +7056,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { Containers::Optional doImage2D(UnsignedInt id, UnsignedInt level) override { if(id == 2) { if(contents & SceneContent::ImageLevels) { - if(level == 3) return {}; + if(level == 3) + return {}; } else return {}; } @@ -7058,7 +7073,8 @@ void AbstractSceneConverterTest::addImporterContentsImportFail() { Containers::Optional doImage3D(UnsignedInt id, UnsignedInt level) override { if(id == 2) { if(contents & SceneContent::ImageLevels) { - if(level == 3) return {}; + if(level == 3) + return {}; } else return {}; } @@ -7302,102 +7318,118 @@ void AbstractSceneConverterTest::addImporterContentsConversionFail() { bool doBeginData() override { return true; } bool doAdd(UnsignedInt id, const SceneData&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding scene"; return true; } bool doAdd(UnsignedInt id, const AnimationData&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding animation"; return true; } bool doAdd(UnsignedInt id, const LightData&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding light"; return true; } bool doAdd(UnsignedInt id, const CameraData&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding camera"; return true; } bool doAdd(UnsignedInt id, const SkinData2D&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding 2D skin"; return true; } bool doAdd(UnsignedInt id, const SkinData3D&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding 3D skin"; return true; } bool doAdd(UnsignedInt id, const MeshData&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding mesh"; return true; } bool doAdd(UnsignedInt id, const Containers::Iterable&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding mesh levels"; return true; } bool doAdd(UnsignedInt id, const MaterialData&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding material"; return true; } bool doAdd(UnsignedInt id, const TextureData&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding texture"; return true; } bool doAdd(UnsignedInt id, const ImageData1D&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding 1D image"; return true; } bool doAdd(UnsignedInt id, const Containers::Iterable&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding 1D image levels"; return true; } bool doAdd(UnsignedInt id, const ImageData2D&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding 2D image"; return true; } bool doAdd(UnsignedInt id, const Containers::Iterable&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding 2D image levels"; return true; } bool doAdd(UnsignedInt id, const ImageData3D&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding 3D image"; return true; } bool doAdd(UnsignedInt id, const Containers::Iterable&, Containers::StringView) override { - if(id == 2) return false; + if(id == 2) + return false; Debug{} << "Adding 3D image levels"; return true; diff --git a/src/Magnum/Trade/imageconverter.cpp b/src/Magnum/Trade/imageconverter.cpp index f66489023..6c42c42ef 100644 --- a/src/Magnum/Trade/imageconverter.cpp +++ b/src/Magnum/Trade/imageconverter.cpp @@ -302,7 +302,8 @@ template bool checkCommonFormatFlags(const Utility::Argu const bool compressed = images.front().isCompressed(); PixelFormat format{}; CompressedPixelFormat compressedFormat{}; - if(!compressed) format = images.front().format(); + if(!compressed) + format = images.front().format(); else compressedFormat = images.front().compressedFormat(); ImageFlags flags = images.front().flags(); for(std::size_t i = 1; i != images.size(); ++i) { @@ -333,7 +334,8 @@ template bool checkCommonFormatFlags(const Utility::Argu } template bool checkCommonFormatAndSize(const Utility::Arguments& args, const Containers::Array>& images) { - if(!checkCommonFormatFlags(args, images)) return false; + if(!checkCommonFormatFlags(args, images)) + return false; CORRADE_INTERNAL_ASSERT(!images.isEmpty()); Math::Vector size = images.front().size(); @@ -373,7 +375,8 @@ template bool convertImages(Trade::AbstractImageConverte CORRADE_INTERNAL_ASSERT(!images.isEmpty()); for(Trade::ImageData& image: images) { Containers::Optional> output = converter.convert(image); - if(!output) return false; + if(!output) + return false; image = *Utility::move(output); } @@ -541,7 +544,8 @@ no -C / --converter is specified, AnyImageConverter is used.)") } /* Set options, if passed */ - if(args.isSet("verbose")) importer->addFlags(Trade::ImporterFlag::Verbose); + if(args.isSet("verbose")) + importer->addFlags(Trade::ImporterFlag::Verbose); Implementation::setOptions(*importer, "AnyImageImporter", args.value("importer-options")); Trade::Implementation::printImporterInfo(useColor, *importer); return 0; @@ -554,7 +558,8 @@ no -C / --converter is specified, AnyImageConverter is used.)") } /* Set options, if passed */ - if(args.isSet("verbose")) converter->addFlags(Trade::ImageConverterFlag::Verbose); + if(args.isSet("verbose")) + converter->addFlags(Trade::ImageConverterFlag::Verbose); if(args.arrayValueCount("converter-options")) Implementation::setOptions(*converter, "AnyImageConverter", args.arrayValue("converter-options", 0)); Trade::Implementation::printImageConverterInfo(useColor, *converter); @@ -565,7 +570,8 @@ no -C / --converter is specified, AnyImageConverter is used.)") /** @todo make them array options as well? */ const UnsignedInt image = args.value("image"); Containers::Optional level; - if(!args.value("level").empty()) level = args.value("level"); + if(!args.value("level").empty()) + level = args.value("level"); #if defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) Containers::Array> mapped; #endif @@ -656,7 +662,8 @@ no -C / --converter is specified, AnyImageConverter is used.)") } /* Set options, if passed */ - if(args.isSet("verbose")) importer->addFlags(Trade::ImporterFlag::Verbose); + if(args.isSet("verbose")) + importer->addFlags(Trade::ImporterFlag::Verbose); Implementation::setOptions(*importer, "AnyImageImporter", args.value("importer-options")); /* Open the file or map it if requested */ @@ -867,7 +874,8 @@ no -C / --converter is specified, AnyImageConverter is used.)") Trade::Implementation::Duration d{conversionTime}; if(dimensions == 1) { - if(!checkCommonFormatAndSize(args, images1D)) return 1; + if(!checkCommonFormatAndSize(args, images1D)) + return 1; outputDimensions = 2; if(!images1D.front().isCompressed()) { @@ -895,7 +903,8 @@ no -C / --converter is specified, AnyImageConverter is used.)") } } else if(dimensions == 2) { - if(!checkCommonFormatAndSize(args, images2D)) return 1; + if(!checkCommonFormatAndSize(args, images2D)) + return 1; outputDimensions = 3; if(!images2D.front().isCompressed()) { @@ -941,7 +950,8 @@ no -C / --converter is specified, AnyImageConverter is used.)") /* There can be multiple input levels, and a layer should get extracted from each level, forming a multi-level image again */ - if(!checkCommonFormatFlags(args, images2D)) return 1; + if(!checkCommonFormatFlags(args, images2D)) + return 1; if(!images2D.front().isCompressed()) { for(std::size_t i = 0; i != images2D.size(); ++i) { /* Diagnostic printed in the import loop above, as here we @@ -971,7 +981,8 @@ no -C / --converter is specified, AnyImageConverter is used.)") /* There can be multiple input levels, and a layer should get extracted from each level, forming a multi-level image again */ - if(!checkCommonFormatFlags(args, images3D)) return 1; + if(!checkCommonFormatFlags(args, images3D)) + return 1; if(!images3D.front().isCompressed()) { for(std::size_t i = 0; i != images3D.size(); ++i) { /* Diagnostic printed in the import loop above, as here we @@ -1003,15 +1014,18 @@ no -C / --converter is specified, AnyImageConverter is used.)") --levels is set or if the (single) input image is multi-level. */ } else { if(dimensions == 1) { - if(!checkCommonFormatFlags(args, images1D)) return 1; + if(!checkCommonFormatFlags(args, images1D)) + return 1; outputDimensions = 1; outputImages1D = Utility::move(images1D); } else if(dimensions == 2) { - if(!checkCommonFormatFlags(args, images2D)) return 1; + if(!checkCommonFormatFlags(args, images2D)) + return 1; outputDimensions = 2; outputImages2D = Utility::move(images2D); } else if(dimensions == 3) { - if(!checkCommonFormatFlags(args, images3D)) return 1; + if(!checkCommonFormatFlags(args, images3D)) + return 1; outputDimensions = 3; outputImages3D = Utility::move(images3D); } else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); @@ -1045,7 +1059,8 @@ no -C / --converter is specified, AnyImageConverter is used.)") } /* Set options, if passed */ - if(args.isSet("verbose")) converter->addFlags(Trade::ImageConverterFlag::Verbose); + if(args.isSet("verbose")) + converter->addFlags(Trade::ImageConverterFlag::Verbose); if(i < args.arrayValueCount("converter-options")) Implementation::setOptions(*converter, "AnyImageConverter", args.arrayValue("converter-options", i)); } @@ -1152,7 +1167,8 @@ no -C / --converter is specified, AnyImageConverter is used.)") { Trade::Implementation::Duration d{conversionTime}; - if(!Utility::Path::write(output, data)) return 1; + if(!Utility::Path::write(output, data)) + return 1; } /* Convert to a file */ diff --git a/src/Magnum/VertexFormat.cpp b/src/Magnum/VertexFormat.cpp index 586bb5f10..5a3920cbd 100644 --- a/src/Magnum/VertexFormat.cpp +++ b/src/Magnum/VertexFormat.cpp @@ -940,7 +940,8 @@ Containers::String ConfigurationValue::toString(Magnum::Ve Magnum::VertexFormat ConfigurationValue::fromString(Containers::StringView stringValue, ConfigurationValueFlags) { for(std::size_t i = 0; i != Containers::arraySize(Magnum::VertexFormatNames); ++i) - if(stringValue == Magnum::VertexFormatNames[i]) return Magnum::VertexFormat(i + 1); + if(stringValue == Magnum::VertexFormatNames[i]) + return Magnum::VertexFormat(i + 1); return {}; } diff --git a/src/Magnum/Vk/Buffer.cpp b/src/Magnum/Vk/Buffer.cpp index eba8c1b00..e3098118e 100644 --- a/src/Magnum/Vk/Buffer.cpp +++ b/src/Magnum/Vk/Buffer.cpp @@ -151,7 +151,8 @@ void Buffer::getMemoryRequirementsImplementation11(Device& device, const VkBuffe VkResult Buffer::bindMemoryImplementationDefault(Device& device, UnsignedInt count, const VkBindBufferMemoryInfo* const infos) { for(std::size_t i = 0; i != count; ++i) - if(VkResult result = device->BindBufferMemory(device, infos[i].buffer, infos[i].memory, infos[i].memoryOffset)) return result; + if(VkResult result = device->BindBufferMemory(device, infos[i].buffer, infos[i].memory, infos[i].memoryOffset)) + return result; return VK_SUCCESS; } diff --git a/src/Magnum/Vk/DescriptorPool.cpp b/src/Magnum/Vk/DescriptorPool.cpp index 20154e147..0848c0e78 100644 --- a/src/Magnum/Vk/DescriptorPool.cpp +++ b/src/Magnum/Vk/DescriptorPool.cpp @@ -170,7 +170,8 @@ DescriptorSet DescriptorPool::allocate(const VkDescriptorSetLayout layout) { Containers::Optional DescriptorPool::tryAllocate(const VkDescriptorSetLayout layout) { Containers::Pair out = allocateInternal(layout); - if(out.first() != Result::Success) return {}; + if(out.first() != Result::Success) + return {}; return Utility::move(out.second()); } @@ -207,7 +208,8 @@ DescriptorSet DescriptorPool::allocate(const VkDescriptorSetLayout layout, const Containers::Optional DescriptorPool::tryAllocate(const VkDescriptorSetLayout layout, const UnsignedInt variableDescriptorCount) { Containers::Pair out = allocateInternal(layout, variableDescriptorCount); - if(out.first() != Result::Success) return {}; + if(out.first() != Result::Success) + return {}; return Utility::move(out.second()); } diff --git a/src/Magnum/Vk/DescriptorSetLayout.cpp b/src/Magnum/Vk/DescriptorSetLayout.cpp index a5d1b792b..a5cafb7b8 100644 --- a/src/Magnum/Vk/DescriptorSetLayout.cpp +++ b/src/Magnum/Vk/DescriptorSetLayout.cpp @@ -100,8 +100,10 @@ DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo(const Containers::I std::size_t immutableSamplerCount = 0; bool hasBindingFlags = false; for(const DescriptorSetLayoutBinding& b: bindings) { - if(b->pImmutableSamplers) immutableSamplerCount += b->descriptorCount; - if(b.flags()) hasBindingFlags = true; + if(b->pImmutableSamplers) + immutableSamplerCount += b->descriptorCount; + if(b.flags()) + hasBindingFlags = true; } /* Allocate a single block of memory for everything. (I'm still amazed at @@ -132,7 +134,8 @@ DescriptorSetLayoutCreateInfo::DescriptorSetLayoutCreateInfo(const Containers::I bindingsCopy[i].pImmutableSamplers = immutableSamplersCopy + immutableSamplerOffset; immutableSamplerOffset += b->descriptorCount; } - if(hasBindingFlags) bindingFlagsCopy[i] = b.flags(); + if(hasBindingFlags) + bindingFlagsCopy[i] = b.flags(); } CORRADE_INTERNAL_ASSERT(immutableSamplerOffset == immutableSamplerCount); diff --git a/src/Magnum/Vk/Device.cpp b/src/Magnum/Vk/Device.cpp index 559f2f9b9..7d8a510f5 100644 --- a/src/Magnum/Vk/Device.cpp +++ b/src/Magnum/Vk/Device.cpp @@ -292,10 +292,12 @@ DeviceCreateInfo& DeviceCreateInfo::operator=(DeviceCreateInfo&& other) noexcept } DeviceCreateInfo& DeviceCreateInfo::addEnabledExtensions(const Containers::StringIterable& extensions) & { - if(extensions.isEmpty()) return *this; + if(extensions.isEmpty()) + return *this; /* This can happen in case we used the NoInit or VkDeviceCreateInfo constructor */ - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* Add null-terminated strings to the extension array */ arrayReserve(_state->extensions, _state->extensions.size() + extensions.size()); @@ -329,10 +331,12 @@ DeviceCreateInfo&& DeviceCreateInfo::addEnabledExtensions(const Containers::Stri } DeviceCreateInfo& DeviceCreateInfo::addEnabledExtensions(const Containers::ArrayView extensions) & { - if(extensions.isEmpty()) return *this; + if(extensions.isEmpty()) + return *this; /* This can happen in case we used the NoInit or VkDeviceCreateInfo constructor */ - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); arrayReserve(_state->extensions, _state->extensions.size() + extensions.size()); for(const Extension& extension: extensions) { @@ -366,7 +370,8 @@ namespace { template void structureConnectIfUsed(Containers::Reference& next, void*& firstFeatureStructure, T& structure, VkStructureType type) { if(structure.sType) { - if(!firstFeatureStructure) firstFeatureStructure = &structure; + if(!firstFeatureStructure) + firstFeatureStructure = &structure; Implementation::structureConnect(next, structure, type); } } @@ -446,7 +451,8 @@ DeviceCreateInfo& DeviceCreateInfo::setEnabledFeatures(const DeviceFeatures& fea _state->features = {}; /* If there's no features to enable, exit */ - if(!features) return *this; + if(!features) + return *this; /* Otherwise, first set enabled bits in each structure and remember which structures have bits set */ @@ -576,7 +582,8 @@ DeviceCreateInfo& DeviceCreateInfo::addQueues(const UnsignedInt family, const Co /* This can happen in case we used the NoInit or VkDeviceCreateInfo constructor */ - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); VkDeviceQueueCreateInfo info{}; info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; @@ -629,7 +636,8 @@ DeviceCreateInfo&& DeviceCreateInfo::addQueues(const QueueFlags flags, const std DeviceCreateInfo& DeviceCreateInfo::addQueues(const VkDeviceQueueCreateInfo& info) & { /* This can happen in case we used the NoInit or VkDeviceCreateInfo constructor */ - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* Copy the info to an internal storage and re-route the pointer to it. This handles a potential reallocation and also the case of replacing the @@ -688,11 +696,13 @@ Device::~Device() { } void Device::create(Instance& instance, const DeviceCreateInfo& info) { - if(tryCreate(instance, info) != Result::Success) std::exit(1); + if(tryCreate(instance, info) != Result::Success) + std::exit(1); } void Device::create(Instance& instance, DeviceCreateInfo&& info) { - if(tryCreate(instance, Utility::move(info)) != Result::Success) std::exit(1); + if(tryCreate(instance, Utility::move(info)) != Result::Success) + std::exit(1); } Result Device::tryCreate(Instance& instance, const DeviceCreateInfo& info) { @@ -795,7 +805,8 @@ Result Device::tryCreateInternal(Instance& instance, const DeviceCreateInfo& inf const Math::BitVector missingExtensions = ~_enabledExtensions & info._state->featuresRequiredExtensions; if(missingExtensions.any()) { for(std::size_t i = 0; i != Implementation::ExtensionCount; ++i) { - if(!missingExtensions[i]) continue; + if(!missingExtensions[i]) + continue; for(const Version extensionVersion: KnownVersionsForExtensions) { for(const Extension extension: Extension::extensions(extensionVersion)) { if(extension.index() != i) diff --git a/src/Magnum/Vk/DeviceProperties.cpp b/src/Magnum/Vk/DeviceProperties.cpp index 79270a3d3..c6e245e35 100644 --- a/src/Magnum/Vk/DeviceProperties.cpp +++ b/src/Magnum/Vk/DeviceProperties.cpp @@ -191,13 +191,15 @@ Containers::StringView DeviceProperties::driverInfo() { } const VkPhysicalDeviceProperties& DeviceProperties::properties1() { - if(!_state) _state.emplace(*_instance, _handle); + if(!_state) + _state.emplace(*_instance, _handle); return _state->properties.properties; } const VkPhysicalDeviceProperties2& DeviceProperties::properties() { - if(!_state) _state.emplace(*_instance, _handle); + if(!_state) + _state.emplace(*_instance, _handle); /* Properties not fetched yet, do that now */ if(!_state->properties.sType) { @@ -251,18 +253,22 @@ ExtensionProperties DeviceProperties::enumerateExtensionProperties() { } const ExtensionProperties& DeviceProperties::extensionPropertiesInternal() { - if(!_state) _state.emplace(*_instance, _handle); - if(!_state->extensions) _state->extensions = enumerateExtensionProperties(); + if(!_state) + _state.emplace(*_instance, _handle); + if(!_state->extensions) + _state->extensions = enumerateExtensionProperties(); return *_state->extensions; } template bool DeviceProperties::isOrVersionSupportedInternal() { - if(isVersionSupported(E::coreVersion())) return true; + if(isVersionSupported(E::coreVersion())) + return true; return extensionPropertiesInternal().isSupported(); } bool DeviceProperties::canUseFeatures2ForDeviceCreation() { - if(!_state) _state.emplace(*_instance, _handle); + if(!_state) + _state.emplace(*_instance, _handle); /* To avoid repeating the logic (and the 10-paragraph explanation) from State constructor here, we simply check what is used to query device @@ -277,7 +283,8 @@ bool DeviceProperties::canUseFeatures2ForDeviceCreation() { } const DeviceFeatures& DeviceProperties::features() { - if(!_state) _state.emplace(*_instance, _handle); + if(!_state) + _state.emplace(*_instance, _handle); /* If a device doesn't support *any* feature, this will be fetched always. That's rather rare though. */ @@ -374,7 +381,8 @@ const DeviceFeatures& DeviceProperties::features() { } Containers::ArrayView DeviceProperties::queueFamilyProperties() { - if(!_state) _state.emplace(*_instance, _handle); + if(!_state) + _state.emplace(*_instance, _handle); /* Fetch if not already */ if(_state->queueFamilyProperties.isEmpty()) { @@ -438,21 +446,24 @@ QueueFlags DeviceProperties::queueFamilyFlags(const UnsignedInt id) { UnsignedInt DeviceProperties::pickQueueFamily(const QueueFlags flags) { Containers::Optional id = tryPickQueueFamily(flags); - if(id) return *id; + if(id) + return *id; std::exit(1); /* LCOV_EXCL_LINE */ } Containers::Optional DeviceProperties::tryPickQueueFamily(const QueueFlags flags) { const Containers::ArrayView properties = queueFamilyProperties(); for(UnsignedInt i = 0; i != properties.size(); ++i) - if(QueueFlag(properties[i].queueFamilyProperties.queueFlags) >= flags) return i; + if(QueueFlag(properties[i].queueFamilyProperties.queueFlags) >= flags) + return i; Error{} << "Vk::DeviceProperties::tryPickQueueFamily(): no" << flags << "found among" << properties.size() << "queue families"; return {}; } const VkPhysicalDeviceMemoryProperties2& DeviceProperties::memoryProperties() { - if(!_state) _state.emplace(*_instance, _handle); + if(!_state) + _state.emplace(*_instance, _handle); if(!_state->memoryProperties.sType) { _state->memoryProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2; @@ -512,7 +523,8 @@ UnsignedInt DeviceProperties::memoryHeapIndex(const UnsignedInt memory) { UnsignedInt DeviceProperties::pickMemory(const MemoryFlags requiredFlags, const MemoryFlags preferredFlags, const UnsignedInt memories) { Containers::Optional id = tryPickMemory(requiredFlags, preferredFlags, memories); - if(id) return *id; + if(id) + return *id; std::exit(1); /* LCOV_EXCL_LINE */ } @@ -547,7 +559,8 @@ Containers::Optional DeviceProperties::tryPickMemory(const MemoryFl } } - if(maxPreferredBitCount >= 0) return maxPreferredBitCountMemory; + if(maxPreferredBitCount >= 0) + return maxPreferredBitCountMemory; Error{} << "Vk::DeviceProperties::tryPickMemory(): no" << requiredFlags << "found among" << Math::popcount(memories & ((1 << properties.memoryTypeCount) - 1)) << "considered memory types"; return {}; @@ -640,8 +653,8 @@ Containers::Optional tryPickDevice(Instance& instance) { return {}; } - for(DeviceProperties& device: devices) - if(device.type() == type) return Utility::move(device); + for(DeviceProperties& device: devices) if(device.type() == type) + return Utility::move(device); Error{} << "Vk::tryPickDevice(): no" << type << "found among" << devices.size() << "Vulkan devices"; return {}; @@ -649,7 +662,8 @@ Containers::Optional tryPickDevice(Instance& instance) { DeviceProperties pickDevice(Instance& instance) { Containers::Optional device = tryPickDevice(instance); - if(device) return *Utility::move(device); + if(device) + return *Utility::move(device); std::exit(1); /* LCOV_EXCL_LINE */ } diff --git a/src/Magnum/Vk/ExtensionProperties.cpp b/src/Magnum/Vk/ExtensionProperties.cpp index 5776043b8..0589daf21 100644 --- a/src/Magnum/Vk/ExtensionProperties.cpp +++ b/src/Magnum/Vk/ExtensionProperties.cpp @@ -153,7 +153,8 @@ UnsignedInt ExtensionProperties::revision(const Containers::StringView extension /* Thanks, C++, for forcing me to have a larger bug surface instead of providing a library helper to find the damn thing. */ auto found = std::lower_bound(_names.begin(), _names.end(), extension); - if(found == _names.end() || *found != extension) return 0; + if(found == _names.end() || *found != extension) + return 0; /* The view target is contents of the VkExtensionProperties structure, the revision is stored nearby */ diff --git a/src/Magnum/Vk/Image.cpp b/src/Magnum/Vk/Image.cpp index 4bd9ac69b..58728a1d1 100644 --- a/src/Magnum/Vk/Image.cpp +++ b/src/Magnum/Vk/Image.cpp @@ -225,7 +225,8 @@ void Image::getMemoryRequirementsImplementation11(Device& device, const VkImageM VkResult Image::bindMemoryImplementationDefault(Device& device, UnsignedInt count, const VkBindImageMemoryInfo* const infos) { for(std::size_t i = 0; i != count; ++i) - if(VkResult result = device->BindImageMemory(device, infos[i].image, infos[i].memory, infos[i].memoryOffset)) return result; + if(VkResult result = device->BindImageMemory(device, infos[i].image, infos[i].memory, infos[i].memoryOffset)) + return result; return VK_SUCCESS; } @@ -641,7 +642,8 @@ namespace { more info */ void fixupImageCopySwiftShader(VkImageSubresourceLayers& subresource, VkOffset3D& offset, VkExtent3D& extent) { /* Not a layered image, nothing to do */ - if(subresource.baseArrayLayer == 0 && subresource.layerCount == 1) return; + if(subresource.baseArrayLayer == 0 && subresource.layerCount == 1) + return; /* When copying 2D array to 3D, depth is already at the value we want it to be */ diff --git a/src/Magnum/Vk/Implementation/DriverWorkaround.cpp b/src/Magnum/Vk/Implementation/DriverWorkaround.cpp index a989337d7..905b32912 100644 --- a/src/Magnum/Vk/Implementation/DriverWorkaround.cpp +++ b/src/Magnum/Vk/Implementation/DriverWorkaround.cpp @@ -86,7 +86,8 @@ constexpr Containers::StringView KnownWorkarounds[]{ some binary search, which needs extra testing effort. */ Containers::StringView findWorkaround(const Containers::StringView workaround) { for(const Containers::StringView i: KnownWorkarounds) - if(workaround == i) return i; + if(workaround == i) + return i; return {}; } @@ -128,7 +129,8 @@ bool isDriverWorkaroundDisabled(Containers::Array inline void** structureFind(void*& next, const T& structure) { Containers::Reference nextRebindable = next; while(nextRebindable) { auto& found = *reinterpret_cast(*nextRebindable); - if(&found == static_cast(&structure)) return &*nextRebindable; + if(&found == static_cast(&structure)) + return &*nextRebindable; nextRebindable = reinterpret_cast(found.pNext); } diff --git a/src/Magnum/Vk/Instance.cpp b/src/Magnum/Vk/Instance.cpp index 6396a9f34..e8e1e0e2e 100644 --- a/src/Magnum/Vk/Instance.cpp +++ b/src/Magnum/Vk/Instance.cpp @@ -68,7 +68,8 @@ InstanceCreateInfo::InstanceCreateInfo(const Int argc, const char* const* const if(args.value("log") == "quiet") _state.emplace().quietLog = true; if(argc && argv) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); _state->argc = argc; _state->argv = argv; } @@ -84,7 +85,8 @@ InstanceCreateInfo::InstanceCreateInfo(const Int argc, const char* const* const instance version */ Containers::StringView version = args.value("vulkan-version"); if(!version.isEmpty()) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); if((_state->version = args.value("vulkan-version")) == Version::None) Warning{} << "Invalid --magnum-vulkan-version" << args.value("vulkan-version") << Debug::nospace << ", ignoring"; @@ -103,14 +105,16 @@ InstanceCreateInfo::InstanceCreateInfo(const Int argc, const char* const* const Containers::String disabledLayers = args.value("disable-layers"); Containers::String disabledExtensions = args.value("disable-extensions"); if(!disabledLayers.isEmpty()) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); _state->disabledLayersStorage = Utility::move(disabledLayers); _state->disabledLayers = Containers::StringView{_state->disabledLayersStorage}.splitOnWhitespaceWithoutEmptyParts(); std::sort(_state->disabledLayers.begin(), _state->disabledLayers.end()); } if(!disabledExtensions.isEmpty()) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); _state->disabledExtensionsStorage = Utility::move(disabledExtensions); _state->disabledExtensions = Containers::StringView{_state->disabledExtensionsStorage}.splitOnWhitespaceWithoutEmptyParts(); @@ -134,7 +138,8 @@ InstanceCreateInfo::InstanceCreateInfo(const Int argc, const char* const* const /* Enable implicit extensions unless that's forbidden */ /** @todo move this somewhere else as this will grow significantly? */ if(!(flags & Flag::NoImplicitExtensions)) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* Fetch searchable extension properties if not already */ Containers::Optional extensionPropertiesStorage; @@ -162,12 +167,14 @@ InstanceCreateInfo& InstanceCreateInfo::setApplicationInfo(const Containers::Str /* Keep an owned copy of the name if it's not global / null-terminated; Use nullptr if the view is empty */ if(!name.isEmpty()) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); _state->applicationName = Containers::String::nullTerminatedGlobalView(name); _applicationInfo.pApplicationName = _state->applicationName.data(); } else { - if(_state) _state->applicationName = nullptr; + if(_state) + _state->applicationName = nullptr; _applicationInfo.pApplicationName = nullptr; } @@ -176,8 +183,10 @@ InstanceCreateInfo& InstanceCreateInfo::setApplicationInfo(const Containers::Str } InstanceCreateInfo& InstanceCreateInfo::addEnabledLayers(const Containers::StringIterable& layers) { - if(layers.isEmpty()) return *this; - if(!_state) _state.emplace(); + if(layers.isEmpty()) + return *this; + if(!_state) + _state.emplace(); /* Add null-terminated strings to the layer array */ arrayReserve(_state->layers, _state->layers.size() + layers.size()); @@ -207,8 +216,10 @@ InstanceCreateInfo& InstanceCreateInfo::addEnabledLayers(const Containers::Strin } InstanceCreateInfo& InstanceCreateInfo::addEnabledExtensions(const Containers::StringIterable& extensions) { - if(extensions.isEmpty()) return *this; - if(!_state) _state.emplace(); + if(extensions.isEmpty()) + return *this; + if(!_state) + _state.emplace(); /* Add null-terminated strings to the extension array */ arrayReserve(_state->extensions, _state->extensions.size() + extensions.size()); @@ -238,8 +249,10 @@ InstanceCreateInfo& InstanceCreateInfo::addEnabledExtensions(const Containers::S } InstanceCreateInfo& InstanceCreateInfo::addEnabledExtensions(const Containers::ArrayView extensions) { - if(extensions.isEmpty()) return *this; - if(!_state) _state.emplace(); + if(extensions.isEmpty()) + return *this; + if(!_state) + _state.emplace(); arrayReserve(_state->extensions, _state->extensions.size() + extensions.size()); for(const InstanceExtension& extension: extensions) { @@ -288,11 +301,13 @@ Instance::~Instance() { } void Instance::create(const InstanceCreateInfo& info) { - if(tryCreate(info) != Result::Success) std::exit(1); + if(tryCreate(info) != Result::Success) + std::exit(1); } void Instance::create() { - if(tryCreate() != Result::Success) std::exit(1); + if(tryCreate() != Result::Success) + std::exit(1); } Result Instance::tryCreate(const InstanceCreateInfo& info) { diff --git a/src/Magnum/Vk/LayerProperties.cpp b/src/Magnum/Vk/LayerProperties.cpp index 9b58b22c5..dc57d3819 100644 --- a/src/Magnum/Vk/LayerProperties.cpp +++ b/src/Magnum/Vk/LayerProperties.cpp @@ -89,7 +89,8 @@ LayerProperties enumerateLayerProperties() { MAGNUM_VK_INTERNAL_ASSERT_SUCCESS(vkEnumerateInstanceLayerProperties(&count, nullptr)); /* No layers, nothing to do */ - if(!count) return out; + if(!count) + return out; /* Allocate extra for a list of string views that we'll use to sort & search the values; query the layers */ diff --git a/src/Magnum/Vk/Memory.h b/src/Magnum/Vk/Memory.h index 93aea329d..20f033fa7 100644 --- a/src/Magnum/Vk/Memory.h +++ b/src/Magnum/Vk/Memory.h @@ -324,7 +324,8 @@ class MAGNUM_VK_EXPORT MemoryMapDeleter { explicit MemoryMapDeleter(): _unmap{}, _device{}, _memory{} {} explicit MemoryMapDeleter(void(*unmap)(VkDevice, VkDeviceMemory), VkDevice device, VkDeviceMemory memory): _unmap{unmap}, _device{device}, _memory{memory} {} void operator()(const char*, std::size_t) { - if(_unmap) _unmap(_device, _memory); + if(_unmap) + _unmap(_device, _memory); } private: diff --git a/src/Magnum/Vk/Mesh.cpp b/src/Magnum/Vk/Mesh.cpp index ab21c6743..8532d076e 100644 --- a/src/Magnum/Vk/Mesh.cpp +++ b/src/Magnum/Vk/Mesh.cpp @@ -102,7 +102,8 @@ Mesh::Mesh(MeshLayout&& layout): _layout{Utility::move(layout)} { }; /** @tod use DirectInit once ArrayTuple can do that */ - for(Buffer& b: _state->ownedVertexBuffers) new(&b) Buffer{NoCreate}; + for(Buffer& b: _state->ownedVertexBuffers) + new(&b) Buffer{NoCreate}; } } @@ -143,7 +144,8 @@ Mesh& Mesh::addVertexBuffer(const UnsignedInt binding, const VkBuffer buffer, co Mesh& Mesh::addVertexBuffer(const UnsignedInt binding, Buffer&& buffer, const UnsignedLong offset) { const std::size_t index = addVertexBufferInternal(binding, buffer, offset); #ifdef CORRADE_GRACEFUL_ASSERT - if(index == ~std::size_t{}) return *this; + if(index == ~std::size_t{}) + return *this; #endif _state->ownedVertexBuffers[index] = Utility::move(buffer); return *this; @@ -152,7 +154,8 @@ Mesh& Mesh::addVertexBuffer(const UnsignedInt binding, Buffer&& buffer, const Un Mesh& Mesh::setIndexBuffer(const VkBuffer buffer, const UnsignedLong offset, const MeshIndexType indexType) { /* If the mesh has no vertex buffer bindings, the state isn't populated in the constructor. Do it here. */ - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); _state->indexBuffer = buffer; _state->indexBufferOffset = offset; @@ -207,7 +210,8 @@ CommandBuffer& CommandBuffer::draw(Mesh& mesh) { CORRADE_ASSERT(mesh.isCountSet(), "Vk::CommandBuffer::draw(): Mesh::setCount() was never called, probably a mistake?", *this); - if(!mesh.count() || !mesh.instanceCount()) return *this; + if(!mesh.count() || !mesh.instanceCount()) + return *this; if(_dynamicRasterizationStates & DynamicRasterizationState::MeshPrimitive) (**_device).CmdSetPrimitiveTopologyEXT(_handle, mesh.layout().vkPipelineInputAssemblyStateCreateInfo().topology); diff --git a/src/Magnum/Vk/MeshLayout.cpp b/src/Magnum/Vk/MeshLayout.cpp index 20dff060a..dad6714bc 100644 --- a/src/Magnum/Vk/MeshLayout.cpp +++ b/src/Magnum/Vk/MeshLayout.cpp @@ -161,7 +161,8 @@ bool MeshLayout::operator==(const MeshLayout& other) const { /* Then continue only if both have the state struct -- if only one has it, it can be still equal if the counts are zero for both (which is verified by the assert above) */ - if(!other._state || !_state) return true; + if(!other._state || !_state) + return true; return _c(_state->vertexDivisorInfo.vertexBindingDivisorCount) && /* These assume the bindings and locations are sorted (as the asserts @@ -175,7 +176,8 @@ bool MeshLayout::operator==(const MeshLayout& other) const { } MeshLayout& MeshLayout::addBinding(const UnsignedInt binding, const UnsignedInt stride) & { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* Ensure order for efficient comparisons */ CORRADE_ASSERT(_state->bindings.isEmpty() || _state->bindings.back().binding < binding, @@ -197,7 +199,8 @@ MeshLayout&& MeshLayout::addBinding(const UnsignedInt binding, const UnsignedInt } MeshLayout& MeshLayout::addInstancedBinding(const UnsignedInt binding, const UnsignedInt stride, const UnsignedInt divisor) & { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* Ensure order for efficient comparisons */ CORRADE_ASSERT(_state->bindings.isEmpty() || _state->bindings.back().binding < binding, @@ -232,7 +235,8 @@ MeshLayout&& MeshLayout::addInstancedBinding(const UnsignedInt binding, const Un } MeshLayout& MeshLayout::addAttribute(const UnsignedInt location, const UnsignedInt binding, const VertexFormat format, const UnsignedInt offset) & { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* Ensure order for efficient comparisons */ CORRADE_ASSERT(_state->attributes.isEmpty() || _state->attributes.back().location < location, diff --git a/src/Magnum/Vk/Queue.cpp b/src/Magnum/Vk/Queue.cpp index b6af59f67..c165888c3 100644 --- a/src/Magnum/Vk/Queue.cpp +++ b/src/Magnum/Vk/Queue.cpp @@ -139,7 +139,8 @@ SubmitInfo& SubmitInfo::operator=(SubmitInfo&& other) noexcept { } SubmitInfo& SubmitInfo::setCommandBuffers(const Containers::ArrayView buffers) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); _state->commandBuffers = Containers::Array{NoInit, buffers.size()}; Utility::copy(buffers, _state->commandBuffers); diff --git a/src/Magnum/Vk/RenderPass.cpp b/src/Magnum/Vk/RenderPass.cpp index 68d2c5267..6718b0503 100644 --- a/src/Magnum/Vk/RenderPass.cpp +++ b/src/Magnum/Vk/RenderPass.cpp @@ -238,7 +238,8 @@ SubpassDescription& SubpassDescription::operator=(SubpassDescription&& other) no } template void SubpassDescription::setInputAttachmentsInternal(Containers::ArrayView attachments) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* While not strictly needed right now, storing the original AttachmentReference instances as well to prepare for a future case where @@ -280,7 +281,8 @@ SubpassDescription&& SubpassDescription::setInputAttachments(std::initializer_li } template void SubpassDescription::setColorAttachmentsInternal(Containers::ArrayView attachments, Containers::ArrayView resolveAttachments) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); CORRADE_ASSERT(!resolveAttachments.size() || resolveAttachments.size() == attachments.size(), "Vk::SubpassDescription::setColorAttachments(): resolve attachments expected to be either empty or have a size of" << attachments.size() << "but got" << resolveAttachments.size(), ); @@ -346,7 +348,8 @@ SubpassDescription&& SubpassDescription::setColorAttachments(std::initializer_li } SubpassDescription& SubpassDescription::setDepthStencilAttachment(AttachmentReference attachment) & { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); _state->depthStencilAttachment = attachment; @@ -359,7 +362,8 @@ SubpassDescription&& SubpassDescription::setDepthStencilAttachment(AttachmentRef } SubpassDescription& SubpassDescription::setPreserveAttachments(Containers::Array&& attachments) & { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); _state->preserveAttachments = Utility::move(attachments); _description.preserveAttachmentCount = _state->preserveAttachments.size(); @@ -595,7 +599,8 @@ RenderPassCreateInfo& RenderPassCreateInfo::operator=(RenderPassCreateInfo&& oth } template void RenderPassCreateInfo::setAttachmentsInternal(Containers::ArrayView attachments) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* While not strictly needed right now, storing the original SubpassDependency instances as well to prepare for a future case where @@ -629,7 +634,8 @@ RenderPassCreateInfo& RenderPassCreateInfo::setAttachments(std::initializer_list } RenderPassCreateInfo& RenderPassCreateInfo::addSubpass(SubpassDescription&& subpass) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* Unfortunately here we can't use an ArrayTuple as it can't grow, and accepting an array view / initializer list would mean a deep copy, which @@ -647,7 +653,8 @@ RenderPassCreateInfo& RenderPassCreateInfo::addSubpass(SubpassDescription&& subp } template void RenderPassCreateInfo::setDependenciesInternal(Containers::ArrayView dependencies) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* Vulkan 1.2.166 doesn't allow anything in VkSubpassDependency2::pNext yet so there's no point in storing the original SubpassDependency wrapper */ @@ -888,7 +895,8 @@ RenderPassBeginInfo& RenderPassBeginInfo::clearDepthStencil(const UnsignedInt at } RenderPassBeginInfo& RenderPassBeginInfo::clearInternal(const UnsignedInt attachment, const VkClearValue& value) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); if(_state->clearValues.size() <= attachment) arrayResize(_state->clearValues, NoInit, attachment + 1); _state->clearValues[attachment] = value; diff --git a/src/Magnum/Vk/Shader.cpp b/src/Magnum/Vk/Shader.cpp index 663573cc0..49dffde7d 100644 --- a/src/Magnum/Vk/Shader.cpp +++ b/src/Magnum/Vk/Shader.cpp @@ -71,7 +71,8 @@ ShaderCreateInfo::ShaderCreateInfo(ShaderCreateInfo&& other) noexcept: } ShaderCreateInfo::~ShaderCreateInfo() { - if(_deleter) _deleter(_originalDeleter, _info.pCode, _info.codeSize); + if(_deleter) + _deleter(_originalDeleter, _info.pCode, _info.codeSize); } ShaderCreateInfo& ShaderCreateInfo::operator=(ShaderCreateInfo&& other) noexcept { diff --git a/src/Magnum/Vk/ShaderSet.cpp b/src/Magnum/Vk/ShaderSet.cpp index de6615ad9..172040193 100644 --- a/src/Magnum/Vk/ShaderSet.cpp +++ b/src/Magnum/Vk/ShaderSet.cpp @@ -102,7 +102,8 @@ ShaderSet& ShaderSet::addShader(const ShaderStage stage, const VkShaderModule sh if(entrypoint.flags() >= (Containers::StringViewFlag::Global|Containers::StringViewFlag::NullTerminated)) { _stages[_stageCount].pName = entrypoint.data(); } else { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* Ensure the data are never SSO'd and so when the array reallocates we don't need to rewire existing name pointers */ _stages[_stageCount].pName = arrayAppend(_state->entrypointNames, InPlaceInit, Containers::AllocatedInit, entrypoint).data(); @@ -111,7 +112,8 @@ ShaderSet& ShaderSet::addShader(const ShaderStage stage, const VkShaderModule sh /* Specialization, also only if there are any to avoid allocating the state struct when not necessary */ if(!specializations.isEmpty()) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); /* Remember the original base data pointers so we can reroute the structures after a potential reallocation */ @@ -126,7 +128,8 @@ ShaderSet& ShaderSet::addShader(const ShaderStage stage, const VkShaderModule sh /* Reroute the existing structures for possible reallocations */ for(std::size_t i = 0; i != _stageCount; ++i) { - if(!_specializations[i].dataSize) continue; + if(!_specializations[i].dataSize) + continue; CORRADE_INTERNAL_ASSERT(_specializations[i].pData >= previousBaseDataPointer && _specializations[i].pData < previousBaseDataPointer + _state->specializationData.size() - specializations.size()*4); _specializations[i].pData = _state->specializationData.data() + (static_cast(_specializations[i].pData) - previousBaseDataPointer); @@ -160,7 +163,8 @@ ShaderSet& ShaderSet::addShader(const ShaderStage stage, const VkShaderModule sh } ShaderSet& ShaderSet::addShader(const ShaderStage stage, Shader&& shader, const Containers::StringView entrypoint, const Containers::ArrayView specializations) { - if(!_state) _state.emplace(); + if(!_state) + _state.emplace(); return addShader(stage, arrayAppend(_state->ownedShaders, Utility::move(shader)), entrypoint, specializations); } diff --git a/src/Magnum/Vk/Test/DevicePropertiesVkTest.cpp b/src/Magnum/Vk/Test/DevicePropertiesVkTest.cpp index f737a3552..4042ae66b 100644 --- a/src/Magnum/Vk/Test/DevicePropertiesVkTest.cpp +++ b/src/Magnum/Vk/Test/DevicePropertiesVkTest.cpp @@ -371,7 +371,8 @@ void DevicePropertiesVkTest::extensionConstructMove() { ExtensionProperties a = devices[0].enumerateExtensionProperties(); const UnsignedInt count = a.count(); - if(!count) CORRADE_SKIP("No extensions reported, can't test"); + if(!count) + CORRADE_SKIP("No extensions reported, can't test"); ExtensionProperties b = Utility::move(a); CORRADE_COMPARE(b.count(), count); @@ -670,7 +671,8 @@ void DevicePropertiesVkTest::pickDeviceType() { Instance instance2{InstanceCreateInfo{Int(Containers::arraySize(argv)), argv}}; Containers::Optional device = tryPickDevice(instance2); - if(!device) CORRADE_SKIP("No CPU device found."); + if(!device) + CORRADE_SKIP("No CPU device found."); CORRADE_VERIFY(device->type() == DeviceType::Cpu); } diff --git a/src/Magnum/Vk/Test/DeviceVkTest.cpp b/src/Magnum/Vk/Test/DeviceVkTest.cpp index 3ae554d01..305d3dbfb 100644 --- a/src/Magnum/Vk/Test/DeviceVkTest.cpp +++ b/src/Magnum/Vk/Test/DeviceVkTest.cpp @@ -897,9 +897,11 @@ void DeviceVkTest::constructMultipleQueues() { DeviceProperties* deviceWithMultipleQueues = nullptr; UnsignedInt largeFamily = ~UnsignedInt{}; for(DeviceProperties& i: deviceProperties) { - if(i.queueFamilyCount() < 2) continue; + if(i.queueFamilyCount() < 2) + continue; for(UnsignedInt family = 0; family != i.queueFamilyCount(); ++family) { - if(i.queueFamilySize(family) < 4) continue; + if(i.queueFamilySize(family) < 4) + continue; largeFamily = family; break; } diff --git a/src/Magnum/Vk/Test/ExtensionPropertiesVkTest.cpp b/src/Magnum/Vk/Test/ExtensionPropertiesVkTest.cpp index 1bfbf3310..dcdc94401 100644 --- a/src/Magnum/Vk/Test/ExtensionPropertiesVkTest.cpp +++ b/src/Magnum/Vk/Test/ExtensionPropertiesVkTest.cpp @@ -72,7 +72,8 @@ using namespace Containers::Literals; void ExtensionPropertiesVkTest::constructMove() { InstanceExtensionProperties a = enumerateInstanceExtensionProperties(); const UnsignedInt count = a.count(); - if(!count) CORRADE_SKIP("No extensions reported, can't test"); + if(!count) + CORRADE_SKIP("No extensions reported, can't test"); InstanceExtensionProperties b = Utility::move(a); CORRADE_COMPARE(b.count(), count); diff --git a/src/Magnum/Vk/Test/LayerPropertiesVkTest.cpp b/src/Magnum/Vk/Test/LayerPropertiesVkTest.cpp index 4b79b85b5..4d9ac439b 100644 --- a/src/Magnum/Vk/Test/LayerPropertiesVkTest.cpp +++ b/src/Magnum/Vk/Test/LayerPropertiesVkTest.cpp @@ -57,7 +57,8 @@ using namespace Containers::Literals; void LayerPropertiesVkTest::constructMove() { LayerProperties a = enumerateLayerProperties(); const UnsignedInt count = a.count(); - if(!count) CORRADE_SKIP("No extensions reported, can't test"); + if(!count) + CORRADE_SKIP("No extensions reported, can't test"); LayerProperties b = Utility::move(a); CORRADE_COMPARE(b.count(), count); diff --git a/src/Magnum/Vk/Version.cpp b/src/Magnum/Vk/Version.cpp index afc9752a4..667cec226 100644 --- a/src/Magnum/Vk/Version.cpp +++ b/src/Magnum/Vk/Version.cpp @@ -45,7 +45,8 @@ Debug& operator<<(Debug& debug, const Version value) { } Version enumerateInstanceVersion() { - if(!vkEnumerateInstanceVersion) return Version::Vk10; + if(!vkEnumerateInstanceVersion) + return Version::Vk10; UnsignedInt version; MAGNUM_VK_INTERNAL_ASSERT_SUCCESS(vkEnumerateInstanceVersion(&version)); diff --git a/src/Magnum/Vk/vk-info.cpp b/src/Magnum/Vk/vk-info.cpp index 8d129d525..8d7b18ea3 100644 --- a/src/Magnum/Vk/vk-info.cpp +++ b/src/Magnum/Vk/vk-info.cpp @@ -295,7 +295,8 @@ int main(int argc, char** argv) { } else for(std::size_t i = instanceFuture; i != Containers::arraySize(versions); ++i) { Containers::ArrayView extensions = Vk::InstanceExtension::extensions(versions[i]); - if(extensions.isEmpty()) continue; + if(extensions.isEmpty()) + continue; if(versions[i] != Vk::Version::None) Debug{} << versions[i] << "instance extension support:"; @@ -328,7 +329,8 @@ int main(int argc, char** argv) { << Debug::packed << device.driverVersion(); } - if(devices.isEmpty()) return 0; + if(devices.isEmpty()) + return 0; } Debug{} << ""; @@ -374,7 +376,8 @@ int main(int argc, char** argv) { } else for(std::size_t i = deviceFuture; i != Containers::arraySize(versions); ++i) { Containers::ArrayView extensions = Vk::Extension::extensions(versions[i]); - if(extensions.isEmpty()) continue; + if(extensions.isEmpty()) + continue; if(versions[i] != Vk::Version::None) Debug{} << versions[i] << "extension support:"; @@ -394,7 +397,8 @@ int main(int argc, char** argv) { } /* If we wanted only extension strings, exit now */ - if(args.isSet("extension-strings")) return 0; + if(args.isSet("extension-strings")) + return 0; if(args.isSet("features")) { Debug{} << "Feature support:"; diff --git a/src/MagnumPlugins/AnyAudioImporter/AnyImporter.cpp b/src/MagnumPlugins/AnyAudioImporter/AnyImporter.cpp index 5bd2757e6..fe6603cff 100644 --- a/src/MagnumPlugins/AnyAudioImporter/AnyImporter.cpp +++ b/src/MagnumPlugins/AnyAudioImporter/AnyImporter.cpp @@ -93,7 +93,8 @@ void AnyImporter::doOpenFile(const std::string& filename) { /* Try to open the file (error output should be printed by the plugin itself) */ - if(!importer->openFile(filename)) return; + if(!importer->openFile(filename)) + return; /* Success, save the instance */ _in = Utility::move(importer); diff --git a/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp b/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp index c3180a73f..4b48794fb 100644 --- a/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp +++ b/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp @@ -181,14 +181,16 @@ void AnyImageImporter::doOpenFile(const Containers::StringView filename) { /* Instantiate the plugin, propagate flags and the file callback, if set */ Containers::Pointer importer = static_cast*>(manager())->instantiate(plugin); importer->setFlags(flags()); - if(fileCallback()) importer->setFileCallback(fileCallback(), fileCallbackUserData()); + if(fileCallback()) + importer->setFileCallback(fileCallback(), fileCallbackUserData()); /* Propagate configuration */ Magnum::Implementation::propagateConfiguration("Trade::AnyImageImporter::openFile():", {}, metadata->name(), configuration(), importer->configuration(), !(flags() & ImporterFlag::Quiet)); /* Try to open the file (error output should be printed by the plugin itself) */ - if(!importer->openFile(filename)) return; + if(!importer->openFile(filename)) + return; /* Success, save the instance */ _in = Utility::move(importer); @@ -276,20 +278,25 @@ void AnyImageImporter::doOpenData(Containers::Array&& data, DataFlags) { TGAs are a complete guesswork, so try after everything else fails. */ else if([dataView]() { /* TGA header is 18 bytes */ - if(dataView.size() < 18) return false; + if(dataView.size() < 18) + return false; /* Third byte (image type) must be one of these */ if(dataView[2] != 1 && dataView[2] != 2 && dataView[2] != 3 && - dataView[2] != 9 && dataView[2] != 10 && dataView[2] != 11) return false; + dataView[2] != 9 && dataView[2] != 10 && dataView[2] != 11) + return false; /* If image type is 1 or 9, second byte (colormap type) must be 1 */ - if((dataView[2] == 1 || dataView[2] == 9) && dataView[1] != 1) return false; + if((dataView[2] == 1 || dataView[2] == 9) && dataView[1] != 1) + return false; /* ... and 0 otherwise */ - if(dataView[2] != 1 && dataView[2] != 9 && dataView[1] != 0) return false; + if(dataView[2] != 1 && dataView[2] != 9 && dataView[1] != 0) + return false; /* Colormap index (unsigned short, byte 3+4) should be 0 */ - if(dataView[3] != 0 && dataView[4] != 0) return false; + if(dataView[3] != 0 && dataView[4] != 0) + return false; /* Probably TGA, heh. Or random memory. */ return true; @@ -301,9 +308,12 @@ void AnyImageImporter::doOpenData(Containers::Array&& data, DataFlags) { /* FFS so much casting to avoid implicit sign extension ruining everything */ UnsignedInt signature = UnsignedInt(UnsignedByte(data[0])) << 24; - if(data.size() > 1) signature |= UnsignedInt(UnsignedByte(data[1])) << 16; - if(data.size() > 2) signature |= UnsignedInt(UnsignedByte(data[2])) << 8; - if(data.size() > 3) signature |= UnsignedInt(UnsignedByte(data[3])); + if(data.size() > 1) + signature |= UnsignedInt(UnsignedByte(data[1])) << 16; + if(data.size() > 2) + signature |= UnsignedInt(UnsignedByte(data[2])) << 8; + if(data.size() > 3) + signature |= UnsignedInt(UnsignedByte(data[3])); /* If there's less than four bytes, cut the rest away */ Error{} << "Trade::AnyImageImporter::openData(): cannot determine the format from signature 0x" << Debug::nospace << Utility::format("{:.8x}", signature).prefix(Math::min(data.size(), std::size_t{4})*2); return; @@ -336,7 +346,8 @@ void AnyImageImporter::doOpenData(Containers::Array&& data, DataFlags) { /* Try to open the file (error output should be printed by the plugin itself) */ - if(!importer->openData(data)) return; + if(!importer->openData(data)) + return; /* Success, save the instance */ _in = Utility::move(importer); diff --git a/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp b/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp index 770694d86..b41a9046a 100644 --- a/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp +++ b/src/MagnumPlugins/AnySceneConverter/AnySceneConverter.cpp @@ -169,7 +169,8 @@ bool AnySceneConverter::doBeginFile(const Containers::StringView filename) { /* Try to begin the file (error output should be printed by the plugin itself) */ - if(!converter->beginFile(filename)) return false; + if(!converter->beginFile(filename)) + return false; /* Success, save the instance */ _converter = Utility::move(converter); diff --git a/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp b/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp index 97d12ce81..5dd0d3bd4 100644 --- a/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp +++ b/src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp @@ -203,14 +203,16 @@ void AnySceneImporter::doOpenFile(const Containers::StringView filename) { /* Instantiate the plugin, propagate flags and the file callback, if set */ Containers::Pointer importer = static_cast*>(manager())->instantiate(plugin); importer->setFlags(flags()); - if(fileCallback()) importer->setFileCallback(fileCallback(), fileCallbackUserData()); + if(fileCallback()) + importer->setFileCallback(fileCallback(), fileCallbackUserData()); /* Propagate configuration */ Magnum::Implementation::propagateConfiguration("Trade::AnySceneImporter::openFile():", {}, metadata->name(), configuration(), importer->configuration(), !(flags() & ImporterFlag::Quiet)); /* Try to open the file (error output should be printed by the plugin itself) */ - if(!importer->openFile(filename)) return; + if(!importer->openFile(filename)) + return; /* Success, save the instance */ _in = Utility::move(importer); diff --git a/src/MagnumPlugins/AnyShaderConverter/AnyConverter.cpp b/src/MagnumPlugins/AnyShaderConverter/AnyConverter.cpp index 65e8019cc..e6a4eb00a 100644 --- a/src/MagnumPlugins/AnyShaderConverter/AnyConverter.cpp +++ b/src/MagnumPlugins/AnyShaderConverter/AnyConverter.cpp @@ -184,7 +184,8 @@ Containers::Pair AnyConverter::doValidateFile(const St _state->inputFormat != Format::Unspecified ? _state->inputFormat : formatForExtension("ShaderTools::AnyConverter::validateFile():", filename) ); - if(format.isEmpty()) return {}; + if(format.isEmpty()) + return {}; /* Decide on a plugin name based on the format */ const Containers::String plugin = Utility::format("{}ShaderConverter", format); @@ -300,11 +301,13 @@ bool AnyConverter::doConvertFileToFile(const Stage stage, const Containers::Stri const Containers::StringView formatFrom = stringForFormat( _state->inputFormat != Format::Unspecified ? _state->inputFormat : formatForExtension("ShaderTools::AnyConverter::convertFileToFile():", from) ); - if(formatFrom.isEmpty()) return {}; + if(formatFrom.isEmpty()) + return {}; const Containers::StringView formatTo = stringForFormat( _state->outputFormat != Format::Unspecified ? _state->outputFormat : formatForExtension("ShaderTools::AnyConverter::convertFileToFile():", to) ); - if(formatTo.isEmpty()) return {}; + if(formatTo.isEmpty()) + return {}; /* Decide on a plugin name based on the format. This might result in invalid combinations such as SpirvToGlslShaderConverter which can't be @@ -384,7 +387,8 @@ Containers::Optional> AnyConverter::doConvertFileToData( const Containers::StringView formatFrom = stringForFormat( _state->inputFormat != Format::Unspecified ? _state->inputFormat : formatForExtension("ShaderTools::AnyConverter::convertFileToData():", filename) ); - if(formatFrom.isEmpty()) return {}; + if(formatFrom.isEmpty()) + return {}; if(_state->outputFormat == Format::Unspecified) { Error{} << "ShaderTools::AnyConverter::convertFileToData(): no output format specified"; return {}; diff --git a/src/MagnumPlugins/MagnumFont/MagnumFont.cpp b/src/MagnumPlugins/MagnumFont/MagnumFont.cpp index 7664f91ed..6ff95d876 100644 --- a/src/MagnumPlugins/MagnumFont/MagnumFont.cpp +++ b/src/MagnumPlugins/MagnumFont/MagnumFont.cpp @@ -86,7 +86,8 @@ void MagnumFont::doOpenData(Containers::Array&& data, DataFlags, Float, Un return; } - if(!_opened) _opened.emplace(); + if(!_opened) + _opened.emplace(); if(!_opened->filePath && !fileCallback()) { Error{} << "Text::MagnumFont::openData(): the font can be opened only from the filesystem or if a file callback is present"; diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp index 169906e52..a6861b53a 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp @@ -103,7 +103,8 @@ template void rleEncode(Containers::Array& data, const ImageView2 builds */ Containers::StridedArrayView1D currentRow; while(y < pixels.size()[0]) { - if(!currentRow) currentRow = pixels[y]; + if(!currentRow) + currentRow = pixels[y]; /* Current pixel, again pre-swizzled so we don't need to swizzle in each arrayAppend() call */ const T current = swizzle(currentRow[x]); @@ -305,7 +306,8 @@ Containers::Optional> TgaImageConverter::doConvertToData /* If we started with a RLE-encoded file, turn the array back into a non-growable to avoid a dangling deleter on plugin unload */ - if(rle) arrayShrink(data); + if(rle) + arrayShrink(data); /* GCC 4.8 needs extra help here */ return Containers::optional(Utility::move(data));