Panda3D
 All Classes Functions Variables Enumerations
cullBinUnsorted.cxx
00001 // Filename: cullBinUnsorted.cxx
00002 // Created by:  drose (28Feb02)
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 #include "cullBinUnsorted.h"
00016 #include "cullHandler.h"
00017 #include "graphicsStateGuardianBase.h"
00018 #include "pStatTimer.h"
00019 
00020 
00021 TypeHandle CullBinUnsorted::_type_handle;
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: CullBinUnsorted::Destructor
00025 //       Access: Public, Virtual
00026 //  Description: 
00027 ////////////////////////////////////////////////////////////////////
00028 CullBinUnsorted::
00029 ~CullBinUnsorted() {
00030   Objects::iterator oi;
00031   for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
00032     CullableObject *object = (*oi);
00033     delete object;
00034   }
00035 }
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: CullBinUnsorted::make_bin
00039 //       Access: Public, Static
00040 //  Description: Factory constructor for passing to the CullBinManager.
00041 ////////////////////////////////////////////////////////////////////
00042 CullBin *CullBinUnsorted::
00043 make_bin(const string &name, GraphicsStateGuardianBase *gsg,
00044          const PStatCollector &draw_region_pcollector) {
00045   return new CullBinUnsorted(name, gsg, draw_region_pcollector);
00046 }
00047 
00048 ////////////////////////////////////////////////////////////////////
00049 //     Function: CullBinUnsorted::add_object
00050 //       Access: Public, Virtual
00051 //  Description: Adds a geom, along with its associated state, to
00052 //               the bin for rendering.
00053 ////////////////////////////////////////////////////////////////////
00054 void CullBinUnsorted::
00055 add_object(CullableObject *object, Thread *current_thread) {
00056   _objects.push_back(object);
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: CullBinUnsorted::draw
00061 //       Access: Public, Virtual
00062 //  Description: Draws all the objects in the bin, in the appropriate
00063 //               order.
00064 ////////////////////////////////////////////////////////////////////
00065 void CullBinUnsorted::
00066 draw(bool force, Thread *current_thread) {
00067   PStatTimer timer(_draw_this_pcollector, current_thread);
00068   Objects::iterator oi;
00069   for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
00070     CullableObject *object = (*oi);
00071     CullHandler::draw(object, _gsg, force, current_thread);
00072   }
00073 }
00074 
00075 ////////////////////////////////////////////////////////////////////
00076 //     Function: CullBinUnsorted::fill_result_graph
00077 //       Access: Protected, Virtual
00078 //  Description: Called by CullBin::make_result_graph() to add all the
00079 //               geoms to the special cull result scene graph.
00080 ////////////////////////////////////////////////////////////////////
00081 void CullBinUnsorted::
00082 fill_result_graph(CullBin::ResultGraphBuilder &builder) {
00083   Objects::const_iterator oi;
00084   for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
00085     CullableObject *object = (*oi);
00086     builder.add_object(object);
00087   }
00088 }
 All Classes Functions Variables Enumerations