Browse Source

Rework reverse order cycles (#2962)

1vanK 3 years ago
parent
commit
f5f2eae9e3

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

@@ -118,7 +118,7 @@ void Pack(const Vector<String>& arguments)
         ErrorExit("No files found");
         ErrorExit("No files found");
 
 
     // Check for extensions to ignore
     // Check for extensions to ignore
-    for (unsigned i = fileNames.Size() - 1; i < fileNames.Size(); --i)
+    for (i32 i = fileNames.Size() - 1; i >= 0; --i)
     {
     {
         String extension = GetExtension(fileNames[i]);
         String extension = GetExtension(fileNames[i]);
         for (unsigned j = 0; ignoreExtensions_[j].Length(); ++j)
         for (unsigned j = 0; ignoreExtensions_[j].Length(); ++j)

+ 1 - 5
Source/Urho3D/Audio/Audio.cpp

@@ -17,10 +17,6 @@
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
 
 
-#ifdef _MSC_VER
-#pragma warning(disable:6293)
-#endif
-
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
@@ -324,7 +320,7 @@ void Audio::UpdateInternal(float timeStep)
     URHO3D_PROFILE(UpdateAudio);
     URHO3D_PROFILE(UpdateAudio);
 
 
     // Update in reverse order, because sound sources might remove themselves
     // Update in reverse order, because sound sources might remove themselves
-    for (u32 i = soundSources_.Size() - 1; i < soundSources_.Size(); --i)
+    for (i32 i = soundSources_.Size() - 1; i >= 0; --i)
     {
     {
         SoundSource* source = soundSources_[i];
         SoundSource* source = soundSources_[i];
 
 

+ 0 - 4
Source/Urho3D/Container/Str.cpp

@@ -9,10 +9,6 @@
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
 
 
-#ifdef _MSC_VER
-#pragma warning(disable:6293)
-#endif
-
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 

+ 0 - 9
Source/Urho3D/Container/Vector.h

@@ -13,11 +13,6 @@
 #include <type_traits>
 #include <type_traits>
 #include <utility>
 #include <utility>
 
 
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:6293)
-#endif
-
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
@@ -964,7 +959,3 @@ template <class T> typename Urho3D::Vector<T>::Iterator begin(Urho3D::Vector<T>&
 template <class T> typename Urho3D::Vector<T>::Iterator end(Urho3D::Vector<T>& v) { return v.End(); }
 template <class T> typename Urho3D::Vector<T>::Iterator end(Urho3D::Vector<T>& v) { return v.End(); }
 
 
 }
 }
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif

+ 1 - 1
Source/Urho3D/Core/Context.cpp

@@ -48,7 +48,7 @@ void EventReceiverGroup::EndSendEvent()
     if (inSend_ == 0 && dirty_)
     if (inSend_ == 0 && dirty_)
     {
     {
         /// \todo Could be optimized by erase-swap, but this keeps the receiver order
         /// \todo Could be optimized by erase-swap, but this keeps the receiver order
-        for (unsigned i = receivers_.Size() - 1; i < receivers_.Size(); --i)
+        for (i32 i = receivers_.Size() - 1; i >= 0; --i)
         {
         {
             if (!receivers_[i])
             if (!receivers_[i])
                 receivers_.Erase(i);
                 receivers_.Erase(i);

+ 1 - 5
Source/Urho3D/Graphics/DecalSet.cpp

@@ -23,10 +23,6 @@
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
 
 
-#ifdef _MSC_VER
-#pragma warning(disable:6293)
-#endif
-
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
@@ -822,7 +818,7 @@ void DecalSet::GetFace(Vector<PODVector<DecalVertex>>& faces, Drawable* target,
         return;
         return;
 
 
     // Check if face is culled completely by any of the planes
     // Check if face is culled completely by any of the planes
-    for (unsigned i = PLANE_FAR; i < NUM_FRUSTUM_PLANES; --i)
+    for (i32 i = PLANE_FAR; i >= 0; --i)
     {
     {
         const Plane& plane = frustum.planes_[i];
         const Plane& plane = frustum.planes_[i];
         if (plane.Distance(v0) < 0.0f && plane.Distance(v1) < 0.0f && plane.Distance(v2) < 0.0f)
         if (plane.Distance(v0) < 0.0f && plane.Distance(v1) < 0.0f && plane.Distance(v2) < 0.0f)

+ 1 - 5
Source/Urho3D/Graphics/Drawable.cpp

@@ -18,10 +18,6 @@
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
 
 
-#ifdef _MSC_VER
-#pragma warning(disable:6293)
-#endif
-
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
@@ -319,7 +315,7 @@ void Drawable::LimitVertexLights(bool removeConvertedLights)
 {
 {
     if (removeConvertedLights)
     if (removeConvertedLights)
     {
     {
-        for (unsigned i = vertexLights_.Size() - 1; i < vertexLights_.Size(); --i)
+        for (i32 i = vertexLights_.Size() - 1; i >= 0; --i)
         {
         {
             if (!vertexLights_[i]->GetPerVertex())
             if (!vertexLights_[i]->GetPerVertex())
                 vertexLights_.Erase(i);
                 vertexLights_.Erase(i);

+ 2 - 6
Source/Urho3D/Graphics/RenderPath.cpp

@@ -11,10 +11,6 @@
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
 
 
-#ifdef _MSC_VER
-#pragma warning(disable:6293)
-#endif
-
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
@@ -437,7 +433,7 @@ void RenderPath::RemoveRenderTarget(const String& name)
 
 
 void RenderPath::RemoveRenderTargets(const String& tag)
 void RenderPath::RemoveRenderTargets(const String& tag)
 {
 {
-    for (unsigned i = renderTargets_.Size() - 1; i < renderTargets_.Size(); --i)
+    for (i32 i = renderTargets_.Size() - 1; i >= 0; --i)
     {
     {
         if (!renderTargets_[i].tag_.Compare(tag, false))
         if (!renderTargets_[i].tag_.Compare(tag, false))
             renderTargets_.Erase(i);
             renderTargets_.Erase(i);
@@ -469,7 +465,7 @@ void RenderPath::RemoveCommand(unsigned index)
 
 
 void RenderPath::RemoveCommands(const String& tag)
 void RenderPath::RemoveCommands(const String& tag)
 {
 {
-    for (unsigned i = commands_.Size() - 1; i < commands_.Size(); --i)
+    for (i32 i = commands_.Size() - 1; i >= 0; --i)
     {
     {
         if (!commands_[i].tag_.Compare(tag, false))
         if (!commands_[i].tag_.Compare(tag, false))
             commands_.Erase(i);
             commands_.Erase(i);

+ 4 - 8
Source/Urho3D/Graphics/Renderer.cpp

@@ -31,10 +31,6 @@
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
 
 
-#ifdef _MSC_VER
-#pragma warning(disable:6293)
-#endif
-
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
@@ -651,7 +647,7 @@ void Renderer::Update(float timeStep)
 
 
     // Queue update of the main viewports. Use reverse order, as rendering order is also reverse
     // Queue update of the main viewports. Use reverse order, as rendering order is also reverse
     // to render auxiliary views before dependent main views
     // to render auxiliary views before dependent main views
-    for (unsigned i = viewports_.Size() - 1; i < viewports_.Size(); --i)
+    for (i32 i = viewports_.Size() - 1; i >= 0; --i)
         QueueViewport(nullptr, viewports_[i]);
         QueueViewport(nullptr, viewports_[i]);
 
 
     // Update main viewports. This may queue further views
     // Update main viewports. This may queue further views
@@ -706,7 +702,7 @@ void Renderer::Render()
     }
     }
 
 
     // Render views from last to first. Each main (backbuffer) view is rendered after the auxiliary views it depends on
     // Render views from last to first. Each main (backbuffer) view is rendered after the auxiliary views it depends on
-    for (unsigned i = views_.Size() - 1; i < views_.Size(); --i)
+    for (i32 i = views_.Size() - 1; i >= 0; --i)
     {
     {
         if (!views_[i])
         if (!views_[i])
             continue;
             continue;
@@ -1516,7 +1512,7 @@ void Renderer::PrepareViewRender()
 
 
 void Renderer::RemoveUnusedBuffers()
 void Renderer::RemoveUnusedBuffers()
 {
 {
-    for (unsigned i = occlusionBuffers_.Size() - 1; i < occlusionBuffers_.Size(); --i)
+    for (i32 i = occlusionBuffers_.Size() - 1; i >= 0; --i)
     {
     {
         if (occlusionBuffers_[i]->GetUseTimer() > MAX_BUFFER_AGE)
         if (occlusionBuffers_[i]->GetUseTimer() > MAX_BUFFER_AGE)
         {
         {
@@ -1529,7 +1525,7 @@ void Renderer::RemoveUnusedBuffers()
     {
     {
         HashMap<unsigned long long, Vector<SharedPtr<Texture>>>::Iterator current = i++;
         HashMap<unsigned long long, Vector<SharedPtr<Texture>>>::Iterator current = i++;
         Vector<SharedPtr<Texture>>& buffers = current->second_;
         Vector<SharedPtr<Texture>>& buffers = current->second_;
-        for (unsigned j = buffers.Size() - 1; j < buffers.Size(); --j)
+        for (i32 j = buffers.Size() - 1; j >= 0; --j)
         {
         {
             Texture* buffer = buffers[j];
             Texture* buffer = buffers[j];
             if (buffer->GetUseTimer() > MAX_BUFFER_AGE)
             if (buffer->GetUseTimer() > MAX_BUFFER_AGE)

+ 1 - 1
Source/Urho3D/GraphicsAPI/OpenGL/OGLGraphics.cpp

@@ -3093,7 +3093,7 @@ void Graphics::PrepareDraw_OGL()
         // Use reverse order so that elements from higher index buffers will override lower index buffers
         // Use reverse order so that elements from higher index buffers will override lower index buffers
         unsigned assignedLocations = 0;
         unsigned assignedLocations = 0;
 
 
-        for (unsigned i = MAX_VERTEX_STREAMS - 1; i < MAX_VERTEX_STREAMS; --i)
+        for (i32 i = MAX_VERTEX_STREAMS - 1; i >= 0; --i)
         {
         {
             VertexBuffer* buffer = vertexBuffers_[i];
             VertexBuffer* buffer = vertexBuffers_[i];
             // Beware buffers with missing OpenGL objects, as binding a zero buffer object means accessing CPU memory for vertex data,
             // Beware buffers with missing OpenGL objects, as binding a zero buffer object means accessing CPU memory for vertex data,

+ 1 - 1
Source/Urho3D/GraphicsAPI/OpenGL/OGLShaderProgram.cpp

@@ -147,7 +147,7 @@ bool ShaderProgram_OGL::Link()
         unsigned char semanticIndex = 0;
         unsigned char semanticIndex = 0;
 
 
         // Go in reverse order so that "binormal" is detected before "normal"
         // Go in reverse order so that "binormal" is detected before "normal"
-        for (unsigned j = MAX_VERTEX_ELEMENT_SEMANTICS - 1; j < MAX_VERTEX_ELEMENT_SEMANTICS; --j)
+        for (i32 j = MAX_VERTEX_ELEMENT_SEMANTICS - 1; j >= 0; --j)
         {
         {
             if (name.Contains(ShaderVariation::elementSemanticNames_OGL[j], false))
             if (name.Contains(ShaderVariation::elementSemanticNames_OGL[j], false))
             {
             {

+ 3 - 7
Source/Urho3D/Math/Polyhedron.cpp

@@ -8,10 +8,6 @@
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
 
 
-#ifdef _MSC_VER
-#pragma warning(disable:6293)
-#endif
-
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
@@ -135,16 +131,16 @@ void Polyhedron::Clip(const Plane& plane)
     }
     }
 
 
     // Remove empty faces
     // Remove empty faces
-    for (unsigned i = faces_.Size() - 1; i < faces_.Size(); --i)
+    for (i32 i = faces_.Size() - 1; i >= 0; --i)
     {
     {
         if (faces_[i].Empty())
         if (faces_[i].Empty())
             faces_.Erase(i);
             faces_.Erase(i);
     }
     }
 
 
     // Create a new face from the clipped vertices. First remove duplicates
     // Create a new face from the clipped vertices. First remove duplicates
-    for (unsigned i = 0; i < clippedVertices_.Size(); ++i)
+    for (i32 i = 0; i < clippedVertices_.Size(); ++i)
     {
     {
-        for (unsigned j = clippedVertices_.Size() - 1; j > i; --j)
+        for (i32 j = clippedVertices_.Size() - 1; j > i; --j)
         {
         {
             if (clippedVertices_[j].Equals(clippedVertices_[i]))
             if (clippedVertices_[j].Equals(clippedVertices_[i]))
                 clippedVertices_.Erase(j);
                 clippedVertices_.Erase(j);

+ 1 - 5
Source/Urho3D/Scene/Component.cpp

@@ -18,10 +18,6 @@
 
 
 #include "../DebugNew.h"
 #include "../DebugNew.h"
 
 
-#ifdef _MSC_VER
-#pragma warning(disable:6293)
-#endif
-
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
@@ -196,7 +192,7 @@ void Component::CleanupConnection(Connection* connection)
 {
 {
     if (networkState_)
     if (networkState_)
     {
     {
-        for (unsigned i = networkState_->replicationStates_.Size() - 1; i < networkState_->replicationStates_.Size(); --i)
+        for (i32 i = networkState_->replicationStates_.Size() - 1; i >= 0; --i)
         {
         {
             if (networkState_->replicationStates_[i]->connection_ == connection)
             if (networkState_->replicationStates_[i]->connection_ == connection)
                 networkState_->replicationStates_.Erase(i);
                 networkState_->replicationStates_.Erase(i);

+ 4 - 8
Source/Urho3D/Scene/Node.cpp

@@ -21,10 +21,6 @@
 
 
 using namespace std;
 using namespace std;
 
 
-#ifdef _MSC_VER
-#pragma warning(disable:6293)
-#endif
-
 namespace Urho3D
 namespace Urho3D
 {
 {
 
 
@@ -872,7 +868,7 @@ void Node::RemoveChildren(bool removeReplicated, bool removeLocal, bool recursiv
 {
 {
     unsigned numRemoved = 0;
     unsigned numRemoved = 0;
 
 
-    for (unsigned i = children_.Size() - 1; i < children_.Size(); --i)
+    for (i32 i = children_.Size() - 1; i >= 0; --i)
     {
     {
         bool remove = false;
         bool remove = false;
         Node* childNode = children_[i];
         Node* childNode = children_[i];
@@ -1020,7 +1016,7 @@ void Node::RemoveComponents(bool removeReplicated, bool removeLocal)
 {
 {
     unsigned numRemoved = 0;
     unsigned numRemoved = 0;
 
 
-    for (unsigned i = components_.Size() - 1; i < components_.Size(); --i)
+    for (i32 i = components_.Size() - 1; i >= 0; --i)
     {
     {
         bool remove = false;
         bool remove = false;
         Component* component = components_[i];
         Component* component = components_[i];
@@ -1046,7 +1042,7 @@ void Node::RemoveComponents(StringHash type)
 {
 {
     unsigned numRemoved = 0;
     unsigned numRemoved = 0;
 
 
-    for (unsigned i = components_.Size() - 1; i < components_.Size(); --i)
+    for (i32 i = components_.Size() - 1; i >= 0; --i)
     {
     {
         if (components_[i]->GetType() == type)
         if (components_[i]->GetType() == type)
         {
         {
@@ -1762,7 +1758,7 @@ void Node::CleanupConnection(Connection* connection)
 
 
     if (networkState_)
     if (networkState_)
     {
     {
-        for (unsigned i = networkState_->replicationStates_.Size() - 1; i < networkState_->replicationStates_.Size(); --i)
+        for (i32 i = networkState_->replicationStates_.Size() - 1; i >= 0; --i)
         {
         {
             if (networkState_->replicationStates_[i]->connection_ == connection)
             if (networkState_->replicationStates_[i]->connection_ == connection)
                 networkState_->replicationStates_.Erase(i);
                 networkState_->replicationStates_.Erase(i);