Panda3D
|
00001 // Filename: cullBin.h 00002 // Created by: drose (27Feb02) 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 CULLBIN_H 00016 #define CULLBIN_H 00017 00018 #include "pandabase.h" 00019 #include "cullBinEnums.h" 00020 #include "typedReferenceCount.h" 00021 #include "pStatCollector.h" 00022 #include "pointerTo.h" 00023 #include "luse.h" 00024 00025 class CullableObject; 00026 class GraphicsStateGuardianBase; 00027 class SceneSetup; 00028 class TransformState; 00029 class RenderState; 00030 class PandaNode; 00031 class GeomNode; 00032 00033 //////////////////////////////////////////////////////////////////// 00034 // Class : CullBin 00035 // Description : A collection of Geoms and their associated state, for 00036 // a particular scene. The cull traversal (and the 00037 // BinCullHandler) assigns Geoms to bins as it comes 00038 // across them. 00039 // 00040 // This is an abstract base class; derived classes like 00041 // CullBinStateSorted and CullBinBackToFront provide the 00042 // actual implementation. 00043 //////////////////////////////////////////////////////////////////// 00044 class EXPCL_PANDA_PGRAPH CullBin : public TypedReferenceCount, public CullBinEnums { 00045 protected: 00046 INLINE CullBin(const CullBin ©); 00047 public: 00048 INLINE CullBin(const string &name, BinType bin_type, 00049 GraphicsStateGuardianBase *gsg, 00050 const PStatCollector &draw_region_pcollector); 00051 virtual ~CullBin(); 00052 00053 INLINE const string &get_name() const; 00054 INLINE BinType get_bin_type() const; 00055 00056 virtual PT(CullBin) make_next() const; 00057 00058 virtual void add_object(CullableObject *object, Thread *current_thread)=0; 00059 virtual void finish_cull(SceneSetup *scene_setup, Thread *current_thread); 00060 00061 virtual void draw(bool force, Thread *current_thread)=0; 00062 00063 PT(PandaNode) make_result_graph(); 00064 00065 INLINE bool has_flash_color() const; 00066 INLINE const LColor &get_flash_color() const; 00067 00068 protected: 00069 class ResultGraphBuilder; 00070 virtual void fill_result_graph(ResultGraphBuilder &builder)=0; 00071 00072 private: 00073 void check_flash_color(); 00074 00075 protected: 00076 string _name; 00077 BinType _bin_type; 00078 GraphicsStateGuardianBase *_gsg; 00079 00080 bool _has_flash_color; 00081 LColor _flash_color; 00082 00083 // Used in make_result_graph() and fill_result_graph(). 00084 class ResultGraphBuilder { 00085 public: 00086 ResultGraphBuilder(PandaNode *root_node); 00087 void add_object(CullableObject *object); 00088 00089 private: 00090 void record_one_object(GeomNode *node, CullableObject *object); 00091 00092 private: 00093 int _object_index; 00094 CPT(TransformState) _current_transform; 00095 CPT(RenderState) _current_state; 00096 PT(PandaNode) _root_node; 00097 PT(GeomNode) _current_node; 00098 }; 00099 00100 static PStatCollector _cull_bin_pcollector; 00101 PStatCollector _cull_this_pcollector; 00102 PStatCollector _draw_this_pcollector; 00103 00104 public: 00105 static TypeHandle get_class_type() { 00106 return _type_handle; 00107 } 00108 static void init_type() { 00109 TypedReferenceCount::init_type(); 00110 register_type(_type_handle, "CullBin", 00111 TypedReferenceCount::get_class_type()); 00112 } 00113 virtual TypeHandle get_type() const { 00114 return get_class_type(); 00115 } 00116 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00117 00118 private: 00119 static TypeHandle _type_handle; 00120 }; 00121 00122 #include "cullBin.I" 00123 00124 #endif 00125 00126 00127