Panda3D
 All Classes Functions Variables Enumerations
cullBinStateSorted.I
1 // Filename: cullBinStateSorted.I
2 // Created by: drose (22Mar05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: CullBinStateSorted::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE CullBinStateSorted::
22 CullBinStateSorted(const string &name, GraphicsStateGuardianBase *gsg,
23  const PStatCollector &draw_region_pcollector) :
24  CullBin(name, BT_state_sorted, gsg, draw_region_pcollector),
25  _objects(get_class_type())
26 {
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: CullBinStateSorted::ObjectData::Constructor
31 // Access: Public
32 // Description:
33 ////////////////////////////////////////////////////////////////////
34 INLINE CullBinStateSorted::ObjectData::
35 ObjectData(CullableObject *object) :
36  _object(object)
37 {
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: CullBinStateSorted::ObjectData::operator <
42 // Access: Public
43 // Description: Specifies the correct sort ordering for these
44 // objects.
45 ////////////////////////////////////////////////////////////////////
46 INLINE bool CullBinStateSorted::ObjectData::
47 operator < (const ObjectData &other) const {
48  // First group objects by transform, since transform changes are
49  // supposed to be expensive.
50  if (_object->_internal_transform != other._object->_internal_transform) {
51  return _object->_internal_transform < other._object->_internal_transform;
52  }
53 
54  // Then group by other state changes, in approximate order from
55  // heaviest change to lightest change.
56  const RenderState *sa = _object->_state;
57  const RenderState *sb = other._object->_state;
58  return sa->compare_sort(*sb) < 0;
59 }
60 
A collection of Geoms and their associated state, for a particular scene.
Definition: cullBin.h:44
int compare_sort(const RenderState &other) const
Returns -1, 0, or 1 according to the relative sorting of these two RenderStates, with regards to rend...
A lightweight class that represents a single element that may be timed and/or counted via stats...
The smallest atom of cull.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...