Panda3D
cullBinUnsorted.cxx
1 // Filename: cullBinUnsorted.cxx
2 // Created by: drose (28Feb02)
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 #include "cullBinUnsorted.h"
16 #include "cullHandler.h"
17 #include "graphicsStateGuardianBase.h"
18 #include "pStatTimer.h"
19 
20 
21 TypeHandle CullBinUnsorted::_type_handle;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Function: CullBinUnsorted::Destructor
25 // Access: Public, Virtual
26 // Description:
27 ////////////////////////////////////////////////////////////////////
28 CullBinUnsorted::
29 ~CullBinUnsorted() {
30  Objects::iterator oi;
31  for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
32  CullableObject *object = (*oi);
33  delete object;
34  }
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: CullBinUnsorted::make_bin
39 // Access: Public, Static
40 // Description: Factory constructor for passing to the CullBinManager.
41 ////////////////////////////////////////////////////////////////////
43 make_bin(const string &name, GraphicsStateGuardianBase *gsg,
44  const PStatCollector &draw_region_pcollector) {
45  return new CullBinUnsorted(name, gsg, draw_region_pcollector);
46 }
47 
48 ////////////////////////////////////////////////////////////////////
49 // Function: CullBinUnsorted::add_object
50 // Access: Public, Virtual
51 // Description: Adds a geom, along with its associated state, to
52 // the bin for rendering.
53 ////////////////////////////////////////////////////////////////////
55 add_object(CullableObject *object, Thread *current_thread) {
56  _objects.push_back(object);
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: CullBinUnsorted::draw
61 // Access: Public, Virtual
62 // Description: Draws all the objects in the bin, in the appropriate
63 // order.
64 ////////////////////////////////////////////////////////////////////
66 draw(bool force, Thread *current_thread) {
67  PStatTimer timer(_draw_this_pcollector, current_thread);
68  Objects::iterator oi;
69  for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
70  CullableObject *object = (*oi);
71  CullHandler::draw(object, _gsg, force, current_thread);
72  }
73 }
74 
75 ////////////////////////////////////////////////////////////////////
76 // Function: CullBinUnsorted::fill_result_graph
77 // Access: Protected, Virtual
78 // Description: Called by CullBin::make_result_graph() to add all the
79 // geoms to the special cull result scene graph.
80 ////////////////////////////////////////////////////////////////////
81 void CullBinUnsorted::
82 fill_result_graph(CullBin::ResultGraphBuilder &builder) {
83  Objects::const_iterator oi;
84  for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
85  CullableObject *object = (*oi);
86  builder.add_object(object);
87  }
88 }
A collection of Geoms and their associated state, for a particular scene.
Definition: cullBin.h:44
A specific kind of CullBin that does not reorder the geometry; it simply passes it through to the GSG...
static CullBin * make_bin(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector)
Factory constructor for passing to the CullBinManager.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
Definition: pStatTimer.h:34
A lightweight class that represents a single element that may be timed and/or counted via stats...
static void draw(CullableObject *object, GraphicsStateGuardianBase *gsg, bool force, Thread *current_thread)
Draws the indicated CullableObject, with full support for decals if they are attached to the object...
Definition: cullHandler.I:24
The smallest atom of cull.
virtual void draw(bool force, Thread *current_thread)
Draws all the objects in the bin, in the appropriate order.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A thread; that is, a lightweight process.
Definition: thread.h:51
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
virtual void add_object(CullableObject *object, Thread *current_thread)
Adds a geom, along with its associated state, to the bin for rendering.