Browse Source

Fixed precision loss in compare_impl

Josh Yelon 17 years ago
parent
commit
9b27b21358
1 changed files with 4 additions and 6 deletions
  1. 4 6
      panda/src/pgraph/lightRampAttrib.cxx

+ 4 - 6
panda/src/pgraph/lightRampAttrib.cxx

@@ -240,15 +240,13 @@ compare_to_impl(const RenderAttrib *other) const {
     return compare_result;
     return compare_result;
   }
   }
   for (int i=0; i<2; i++) {
   for (int i=0; i<2; i++) {
-    compare_result = _level[i] - ta->_level[i];
-    if (compare_result!=0) {
-      return compare_result;
+    if (_level[i] != ta->_level[i]) {
+      return (_level[i] < ta->_level[i]) ? -1 : 1;
     }
     }
   }
   }
   for (int i=0; i<2; i++) {
   for (int i=0; i<2; i++) {
-    compare_result = _threshold[i] - ta->_threshold[i];
-    if (compare_result!=0) {
-      return compare_result;
+    if (_threshold[i] != ta->_threshold[i]) {
+      return (_threshold[i] < ta->_threshold[i]) ? -1 : 1;
     }
     }
   }
   }
   return 0;
   return 0;