From 9b27b213580d2eed59135d93ae3f46a06bacea30 Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Tue, 6 May 2008 22:02:26 +0000 Subject: [PATCH] Fixed precision loss in compare_impl --- panda/src/pgraph/lightRampAttrib.cxx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/panda/src/pgraph/lightRampAttrib.cxx b/panda/src/pgraph/lightRampAttrib.cxx index 3e87ff999b..7b3c3e640a 100644 --- a/panda/src/pgraph/lightRampAttrib.cxx +++ b/panda/src/pgraph/lightRampAttrib.cxx @@ -240,15 +240,13 @@ compare_to_impl(const RenderAttrib *other) const { return compare_result; } 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++) { - 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;