Browse Source

Clang-Tidy - modernize-return-braced-init-list.

Yao Wei Tjong 姚伟忠 8 years ago
parent
commit
d8a438b169

+ 1 - 1
Source/Tools/AssetImporter/AssetImporter.cpp

@@ -2563,7 +2563,7 @@ aiMatrix4x4 GetDerivedTransform(aiMatrix4x4 transform, aiNode* node, aiNode* roo
 aiMatrix4x4 GetMeshBakingTransform(aiNode* meshNode, aiNode* modelRootNode)
 {
     if (meshNode == modelRootNode)
-        return aiMatrix4x4();
+        return {};
     else
         return GetDerivedTransform(meshNode, modelRootNode);
 }

+ 10 - 10
Source/Urho3D/Graphics/View.cpp

@@ -2509,8 +2509,8 @@ bool View::IsShadowCasterVisible(Drawable* drawable, BoundingBox lightViewBox, C
 
 IntRect View::GetShadowMapViewport(Light* light, unsigned splitIndex, Texture2D* shadowMap)
 {
-    auto width = (unsigned)shadowMap->GetWidth();
-    auto height = (unsigned)shadowMap->GetHeight();
+    int width = shadowMap->GetWidth();
+    int height = shadowMap->GetHeight();
 
     switch (light->GetLightType())
     {
@@ -2518,23 +2518,23 @@ IntRect View::GetShadowMapViewport(Light* light, unsigned splitIndex, Texture2D*
         {
             int numSplits = light->GetNumShadowSplits();
             if (numSplits == 1)
-                return IntRect(0, 0, width, height);
+                return {0, 0, width, height};
             else if (numSplits == 2)
-                return IntRect(splitIndex * width / 2, 0, (splitIndex + 1) * width / 2, height);
+                return {static_cast<int>(splitIndex * width / 2), 0, static_cast<int>((splitIndex + 1) * width / 2), height};
             else
-                return IntRect((splitIndex & 1) * width / 2, (splitIndex / 2) * height / 2, ((splitIndex & 1) + 1) * width / 2,
-                    (splitIndex / 2 + 1) * height / 2);
+                return {static_cast<int>((splitIndex & 1) * width / 2), static_cast<int>((splitIndex / 2) * height / 2),
+                    static_cast<int>(((splitIndex & 1) + 1) * width / 2), static_cast<int>((splitIndex / 2 + 1) * height / 2)};
         }
 
     case LIGHT_SPOT:
-        return IntRect(0, 0, width, height);
+        return {0, 0, width, height};
 
     case LIGHT_POINT:
-        return IntRect((splitIndex & 1) * width / 2, (splitIndex / 2) * height / 3, ((splitIndex & 1) + 1) * width / 2,
-            (splitIndex / 2 + 1) * height / 3);
+        return {static_cast<int>((splitIndex & 1) * width / 2), static_cast<int>((splitIndex / 2) * height / 3),
+            static_cast<int>(((splitIndex & 1) + 1) * width / 2), static_cast<int>((splitIndex / 2 + 1) * height / 3)};
     }
 
-    return IntRect();
+    return {};
 }
 
 void View::SetupShadowCameras(LightQueryResult& query)

+ 1 - 1
Source/Urho3D/IO/Deserializer.cpp

@@ -141,7 +141,7 @@ IntRect Deserializer::ReadIntRect()
 {
     int data[4];
     Read(data, sizeof data);
-    return IntRect(data);
+    return {data};
 }
 
 IntVector2 Deserializer::ReadIntVector2()

+ 1 - 1
Source/Urho3D/Resource/PListFile.cpp

@@ -216,7 +216,7 @@ IntRect PListValue::GetIntRect() const
 
     int x, y, w, h;
     sscanf(string_->CString(), "{{%d,%d},{%d,%d}}", &x, &y, &w, &h);
-    return IntRect(x, y, x + w, y + h);
+    return {x, y, x + w, y + h};
 }
 
 IntVector2 PListValue::GetIntVector2() const

+ 2 - 2
Source/Urho3D/Urho2D/PhysicsUtils2D.h

@@ -38,7 +38,7 @@ inline Color ToColor(const b2Color& color)
 
 inline b2Vec2 ToB2Vec2(const Vector2& vector)
 {
-    return b2Vec2(vector.x_, vector.y_);
+    return {vector.x_, vector.y_};
 }
 
 inline Vector2 ToVector2(const b2Vec2& vec2)
@@ -48,7 +48,7 @@ inline Vector2 ToVector2(const b2Vec2& vec2)
 
 inline b2Vec2 ToB2Vec2(const Vector3& vector)
 {
-    return b2Vec2(vector.x_, vector.y_);
+    return {vector.x_, vector.y_};
 }
 
 inline Vector3 ToVector3(const b2Vec2& vec2)

+ 1 - 1
Source/Urho3D/Urho2D/SpriterData2D.cpp

@@ -573,7 +573,7 @@ SpatialInfo SpatialInfo::UnmapFromParent(const SpatialInfo& parentInfo) const
         unmappedY = parentInfo.y_;
     }
 
-    return SpatialInfo(unmappedX, unmappedY, unmappedAngle, unmappedScaleX, unmappedScaleY, unmappedAlpha, spin);
+    return {unmappedX, unmappedY, unmappedAngle, unmappedScaleX, unmappedScaleY, unmappedAlpha, spin};
 }
 
 void SpatialInfo::Interpolate(const SpatialInfo& other, float t)