00001 // Filename: subdivSegment.I 00002 // Created by: drose (14Oct03) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: SubdivSegment::Constructor 00018 // Access: Public 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE SubdivSegment:: 00022 SubdivSegment(const double *cint, int f, int t) : 00023 _cint(cint), 00024 _f(f), 00025 _t(t) 00026 { 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: SubdivSegment::get_score 00031 // Access: Public 00032 // Description: Returns the net score of the segment. 00033 //////////////////////////////////////////////////////////////////// 00034 INLINE double SubdivSegment:: 00035 get_score() const { 00036 return _cint[_t] - _cint[_f]; 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function: SubdivSegment::get_need 00041 // Access: Public 00042 // Description: Returns a score that indicates how badly the segment 00043 // needs to be further subdivided. The greater the 00044 // number, the greater the need. 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE double SubdivSegment:: 00047 get_need() const { 00048 return get_score() / (double)(_num_cuts+1); 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: SubdivSegment::operator < 00053 // Access: Public 00054 // Description: Sorts the segments in descending order of need. 00055 //////////////////////////////////////////////////////////////////// 00056 INLINE bool SubdivSegment:: 00057 operator < (const SubdivSegment &other) const { 00058 return get_need() > other.get_need(); 00059 }