Panda3D
|
00001 // Filename: cullBinStateSorted.I 00002 // Created by: drose (22Mar05) 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: CullBinStateSorted::Constructor 00018 // Access: Public 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE CullBinStateSorted:: 00022 CullBinStateSorted(const string &name, GraphicsStateGuardianBase *gsg, 00023 const PStatCollector &draw_region_pcollector) : 00024 CullBin(name, BT_state_sorted, gsg, draw_region_pcollector), 00025 _objects(get_class_type()) 00026 { 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: CullBinStateSorted::ObjectData::Constructor 00031 // Access: Public 00032 // Description: 00033 //////////////////////////////////////////////////////////////////// 00034 INLINE CullBinStateSorted::ObjectData:: 00035 ObjectData(CullableObject *object) : 00036 _object(object) 00037 { 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: CullBinStateSorted::ObjectData::operator < 00042 // Access: Public 00043 // Description: Specifies the correct sort ordering for these 00044 // objects. 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE bool CullBinStateSorted::ObjectData:: 00047 operator < (const ObjectData &other) const { 00048 // First group objects by transform, since transform changes are 00049 // supposed to be expensive. 00050 if (_object->_modelview_transform != other._object->_modelview_transform) { 00051 return _object->_modelview_transform < other._object->_modelview_transform; 00052 } 00053 00054 // Then group by other state changes, in approximate order from 00055 // heaviest change to lightest change. 00056 const RenderState *sa = _object->_state; 00057 const RenderState *sb = other._object->_state; 00058 return sa->compare_sort(*sb) < 0; 00059 } 00060