Panda3D
|
00001 // Filename: cullBinStateSorted.h 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 #ifndef CULLBINSTATESORTED_H 00016 #define CULLBINSTATESORTED_H 00017 00018 #include "pandabase.h" 00019 00020 #include "cullBin.h" 00021 #include "cullableObject.h" 00022 #include "geom.h" 00023 #include "transformState.h" 00024 #include "renderState.h" 00025 #include "pointerTo.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : CullBinStateSorted 00029 // Description : A specific kind of CullBin that sorts geometry to 00030 // collect items of the same state together, so that 00031 // minimal state changes are required on the GSG to 00032 // render them. 00033 // 00034 // This also sorts objects front-to-back within a 00035 // particular state, to take advantage of hierarchical 00036 // Z-buffer algorithms which can early-out when an 00037 // object appears behind another one. 00038 //////////////////////////////////////////////////////////////////// 00039 class EXPCL_PANDA_CULL CullBinStateSorted : public CullBin { 00040 public: 00041 INLINE CullBinStateSorted(const string &name, 00042 GraphicsStateGuardianBase *gsg, 00043 const PStatCollector &draw_region_pcollector); 00044 virtual ~CullBinStateSorted(); 00045 00046 static CullBin *make_bin(const string &name, 00047 GraphicsStateGuardianBase *gsg, 00048 const PStatCollector &draw_region_pcollector); 00049 00050 virtual void add_object(CullableObject *object, Thread *current_thread); 00051 virtual void finish_cull(SceneSetup *scene_setup, Thread *current_thread); 00052 virtual void draw(bool force, Thread *current_thread); 00053 00054 protected: 00055 virtual void fill_result_graph(ResultGraphBuilder &builder); 00056 00057 private: 00058 class ObjectData { 00059 public: 00060 INLINE ObjectData(CullableObject *object); 00061 INLINE bool operator < (const ObjectData &other) const; 00062 00063 CullableObject *_object; 00064 }; 00065 00066 typedef pvector<ObjectData> Objects; 00067 Objects _objects; 00068 00069 public: 00070 static TypeHandle get_class_type() { 00071 return _type_handle; 00072 } 00073 static void init_type() { 00074 CullBin::init_type(); 00075 register_type(_type_handle, "CullBinStateSorted", 00076 CullBin::get_class_type()); 00077 } 00078 virtual TypeHandle get_type() const { 00079 return get_class_type(); 00080 } 00081 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00082 00083 private: 00084 static TypeHandle _type_handle; 00085 }; 00086 00087 #include "cullBinStateSorted.I" 00088 00089 #endif 00090 00091 00092