Fix #33405: preview render getting stuck in a particular .blend file, ObjectKey
[blender.git] / intern / cycles / blender / blender_util.h
index 4feb8b556d5ca7d01b08d08d2bbd8d3c866cb889..0a9f2dd06aa20005583b411f5fefb92d06c0934a 100644 (file)
@@ -367,12 +367,22 @@ struct ObjectKey {
 
        bool operator<(const ObjectKey& k) const
        {
-               return (parent < k.parent) ||
-                      (parent == k.parent && (memcmp(id, k.id, sizeof(id)) < 0)) ||
-                      (memcmp(id, k.id, sizeof(id)) == 0 && ob < k.ob);
+               if(ob < k.ob) {
+                       return true;
+               }
+               else if(ob == k.ob) {
+                       if(parent < k.parent)
+                               return true;
+                       else if(parent == k.parent)
+                               return memcmp(id, k.id, sizeof(id)) < 0;
+               }
+
+               return false;
        }
 };
 
+/* Particle System Key */
+
 struct ParticleSystemKey {
        void *ob;
        int id[OBJECT_PERSISTENT_ID_SIZE];
@@ -389,8 +399,12 @@ struct ParticleSystemKey {
        bool operator<(const ParticleSystemKey& k) const
        {
                /* first id is particle index, we don't compare that */
-               return (ob < k.ob) ||
-                      (ob == k.ob && (memcmp(id+1, k.id+1, sizeof(int)*(OBJECT_PERSISTENT_ID_SIZE-1)) < 0));
+               if(ob < k.ob)
+                       return true;
+               else if(ob == k.ob)
+                       return memcmp(id+1, k.id+1, sizeof(int)*(OBJECT_PERSISTENT_ID_SIZE-1)) < 0;
+
+               return false;
        }
 };