Panda3D

cullBinFrontToBack.h

00001 // Filename: cullBinFrontToBack.h
00002 // Created by:  drose (29May02)
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 CULLBINFRONTTOBACK_H
00016 #define CULLBINFRONTTOBACK_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "cullBin.h"
00021 #include "geom.h"
00022 #include "transformState.h"
00023 #include "renderState.h"
00024 #include "pointerTo.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : CullBinFrontToBack
00028 // Description : A specific kind of CullBin that sorts geometry in
00029 //               order from nearest to furthest based on the center of
00030 //               its bounding volume.
00031 //
00032 //               This is useful for rendering opaque geometry, taking
00033 //               optimal advantage of a hierarchical Z-buffer.
00034 ////////////////////////////////////////////////////////////////////
00035 class EXPCL_PANDA_CULL CullBinFrontToBack : public CullBin {
00036 public:
00037   INLINE CullBinFrontToBack(const string &name, 
00038                             GraphicsStateGuardianBase *gsg,
00039                             const PStatCollector &draw_region_pcollector);
00040   virtual ~CullBinFrontToBack();
00041 
00042   static CullBin *make_bin(const string &name, 
00043                            GraphicsStateGuardianBase *gsg,
00044                            const PStatCollector &draw_region_pcollector);
00045 
00046   virtual void add_object(CullableObject *object, Thread *current_thread);
00047   virtual void finish_cull(SceneSetup *scene_setup, Thread *current_thread);
00048   virtual void draw(bool force, Thread *current_thread);
00049 
00050 protected:
00051   virtual void fill_result_graph(ResultGraphBuilder &builder);
00052 
00053 private:
00054   class ObjectData {
00055   public:
00056     INLINE ObjectData(CullableObject *object, PN_stdfloat dist);
00057     INLINE bool operator < (const ObjectData &other) const;
00058     
00059     CullableObject *_object;
00060     PN_stdfloat _dist;
00061   };
00062 
00063   typedef pvector<ObjectData> Objects;
00064   Objects _objects;
00065 
00066 public:
00067   static TypeHandle get_class_type() {
00068     return _type_handle;
00069   }
00070   static void init_type() {
00071     CullBin::init_type();
00072     register_type(_type_handle, "CullBinFrontToBack",
00073                   CullBin::get_class_type());
00074   }
00075   virtual TypeHandle get_type() const {
00076     return get_class_type();
00077   }
00078   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00079 
00080 private:
00081   static TypeHandle _type_handle;
00082 };
00083 
00084 #include "cullBinFrontToBack.I"
00085 
00086 #endif
00087 
00088 
00089   
 All Classes Functions Variables Enumerations