From 777322003a07f4790489cd1d8ff3625acc881c19 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 11 Jan 2010 19:43:54 +0000 Subject: [PATCH] morph threshold comparisons --- panda/src/egg/eggAttributes.I | 4 ++-- panda/src/egg/eggAttributes.cxx | 4 ++-- panda/src/egg/eggAttributes.h | 2 +- panda/src/egg/eggMorph.I | 4 ++-- panda/src/egg/eggMorph.h | 2 +- panda/src/egg/eggMorphList.I | 4 ++-- panda/src/egg/eggMorphList.h | 2 +- panda/src/egg/eggVertex.I | 2 +- panda/src/egg/eggVertex.cxx | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/panda/src/egg/eggAttributes.I b/panda/src/egg/eggAttributes.I index ec293ea07a..1956b1d474 100644 --- a/panda/src/egg/eggAttributes.I +++ b/panda/src/egg/eggAttributes.I @@ -70,7 +70,7 @@ matches_normal(const EggAttributes &other) const { return true; } return (get_normal() == other.get_normal() && - _dnormals.compare_to(other._dnormals) == 0); + _dnormals.compare_to(other._dnormals, egg_parameters->_normal_threshold) == 0); } //////////////////////////////////////////////////////////////////// @@ -151,7 +151,7 @@ matches_color(const EggAttributes &other) const { return true; } return (get_color() == other.get_color() && - _drgbas.compare_to(other._drgbas) == 0); + _drgbas.compare_to(other._drgbas, egg_parameters->_color_threshold) == 0); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/egg/eggAttributes.cxx b/panda/src/egg/eggAttributes.cxx index e0b27ee072..41784417d4 100644 --- a/panda/src/egg/eggAttributes.cxx +++ b/panda/src/egg/eggAttributes.cxx @@ -119,7 +119,7 @@ compare_to(const EggAttributes &other) const { if (compare != 0) { return compare; } - compare = _dnormals.compare_to(other._dnormals); + compare = _dnormals.compare_to(other._dnormals, egg_parameters->_normal_threshold); if (compare != 0) { return compare; } @@ -131,7 +131,7 @@ compare_to(const EggAttributes &other) const { if (compare != 0) { return compare; } - compare = _drgbas.compare_to(other._drgbas); + compare = _drgbas.compare_to(other._drgbas, egg_parameters->_color_threshold); if (compare != 0) { return compare; } diff --git a/panda/src/egg/eggAttributes.h b/panda/src/egg/eggAttributes.h index 3976446329..27ac628bf0 100644 --- a/panda/src/egg/eggAttributes.h +++ b/panda/src/egg/eggAttributes.h @@ -18,7 +18,7 @@ #include "pandabase.h" #include "eggMorphList.h" - +#include "eggParameters.h" #include "typedObject.h" #include "luse.h" #include "pnotify.h" diff --git a/panda/src/egg/eggMorph.I b/panda/src/egg/eggMorph.I index 36a10b85b7..a7e6c29583 100644 --- a/panda/src/egg/eggMorph.I +++ b/panda/src/egg/eggMorph.I @@ -93,12 +93,12 @@ operator != (const EggMorph &other) const { //////////////////////////////////////////////////////////////////// template INLINE int EggMorph:: -compare_to(const EggMorph &other) const { +compare_to(const EggMorph &other, double threshold) const { int compare = strcmp(get_name().c_str(), other.get_name().c_str()); if (compare != 0) { return compare; } - return _offset.compare_to(other._offset); + return _offset.compare_to(other._offset, threshold); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/egg/eggMorph.h b/panda/src/egg/eggMorph.h index 637dbc19a6..af0564ae64 100644 --- a/panda/src/egg/eggMorph.h +++ b/panda/src/egg/eggMorph.h @@ -40,7 +40,7 @@ public: INLINE bool operator == (const EggMorph &other) const; INLINE bool operator != (const EggMorph &other) const; - INLINE int compare_to(const EggMorph &other) const; + INLINE int compare_to(const EggMorph &other, double threshold) const; INLINE void output(ostream &out, const string &tag, int num_dimensions) const; diff --git a/panda/src/egg/eggMorphList.I b/panda/src/egg/eggMorphList.I index 382ce4cb17..2b922ff936 100644 --- a/panda/src/egg/eggMorphList.I +++ b/panda/src/egg/eggMorphList.I @@ -98,12 +98,12 @@ operator < (const EggMorphList &other) const { //////////////////////////////////////////////////////////////////// template int EggMorphList:: -compare_to(const EggMorphList &other) const { +compare_to(const EggMorphList &other, double threshold) const { if (_morphs.size() != other._morphs.size()) { return (int)_morphs.size() - (int)other._morphs.size(); } for (size_t i = 0; i < _morphs.size(); i++) { - int compare = _morphs[i].compare_to(other._morphs[i]); + int compare = _morphs[i].compare_to(other._morphs[i], threshold); if (compare < 0) { return compare; } diff --git a/panda/src/egg/eggMorphList.h b/panda/src/egg/eggMorphList.h index 6451e49354..e6fa8610ee 100644 --- a/panda/src/egg/eggMorphList.h +++ b/panda/src/egg/eggMorphList.h @@ -45,7 +45,7 @@ public: INLINE bool operator == (const EggMorphList &other) const; INLINE bool operator != (const EggMorphList &other) const; INLINE bool operator < (const EggMorphList &other) const; - int compare_to(const EggMorphList &other) const; + int compare_to(const EggMorphList &other, double threshold) const; INLINE iterator begin(); INLINE const_iterator begin() const; diff --git a/panda/src/egg/eggVertex.I b/panda/src/egg/eggVertex.I index 367b25d250..4dd6753d8d 100644 --- a/panda/src/egg/eggVertex.I +++ b/panda/src/egg/eggVertex.I @@ -327,7 +327,7 @@ get_external_index() const { //////////////////////////////////////////////////////////////////// INLINE bool EggVertex:: sorts_less_than(const EggVertex &other) const { - return compare_to(other) < 0; + return (compare_to(other) < 0); } diff --git a/panda/src/egg/eggVertex.cxx b/panda/src/egg/eggVertex.cxx index 0a83d9d738..3bf4fa413f 100644 --- a/panda/src/egg/eggVertex.cxx +++ b/panda/src/egg/eggVertex.cxx @@ -395,7 +395,7 @@ compare_to(const EggVertex &other) const { if (compare != 0) { return compare; } - compare = _dxyzs.compare_to(other._dxyzs); + compare = _dxyzs.compare_to(other._dxyzs, egg_parameters->_pos_threshold); if (compare != 0) { return compare; }