Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/gobj/boundedObject.h

Go to the documentation of this file.
00001 // Filename: boundedObject.h
00002 // Created by:  drose (02Oct99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef BOUNDEDOBJECT_H
00020 #define BOUNDEDOBJECT_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "boundingVolume.h"
00025 #include "cycleData.h"
00026 #include "cycleDataReader.h"
00027 #include "cycleDataWriter.h"
00028 #include "pipelineCycler.h"
00029 #include "typedObject.h"
00030 #include "pointerTo.h"
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //       Class : BoundedObject
00034 // Description : This is any object (particularly in a scene graph)
00035 //               that may have a bounding volume established for it.
00036 //               The user may set a fixed bounding volume, or s/he may
00037 //               specify that the volume should be recomputed
00038 //               dynamically.
00039 ////////////////////////////////////////////////////////////////////
00040 class EXPCL_PANDA BoundedObject {
00041 public:
00042   INLINE BoundedObject();
00043   INLINE BoundedObject(const BoundedObject &copy);
00044   INLINE void operator = (const BoundedObject &copy);
00045   virtual ~BoundedObject();
00046 
00047 PUBLISHED:
00048   enum BoundingVolumeType {
00049     BVT_static,
00050     BVT_dynamic_sphere,
00051   };
00052 
00053   INLINE void set_bound(BoundingVolumeType type);
00054   INLINE void set_bound(const BoundingVolume &volume);
00055   const BoundingVolume &get_bound() const;
00056 
00057   INLINE bool mark_bound_stale();
00058   INLINE void force_bound_stale();
00059   INLINE bool is_bound_stale() const;
00060 
00061   INLINE void set_final(bool flag);
00062   INLINE bool is_final() const;
00063 
00064 protected:
00065   virtual void propagate_stale_bound();
00066   virtual BoundingVolume *recompute_bound();
00067 
00068   INLINE const BoundingVolume *get_bound_ptr() const;
00069   INLINE BoundingVolume *set_bound_ptr(BoundingVolume *bound);
00070 
00071 private:
00072   enum Flags {
00073     F_bound_stale  = 0x0001,
00074     F_final        = 0x0002,
00075   };
00076 
00077   // This is the data that must be cycled between pipeline stages.
00078   class EXPCL_PANDA CData : public CycleData {
00079   public:
00080     INLINE CData();
00081     INLINE CData(const CData &copy);
00082     INLINE void operator = (const CData &copy);
00083 
00084     virtual CycleData *make_copy() const;
00085 
00086     int _flags;
00087     BoundingVolumeType _bound_type;
00088     PT(BoundingVolume) _bound;
00089   };
00090 
00091   PipelineCycler<CData> _cycler;
00092   typedef CycleDataReader<CData> CDReader;
00093   typedef CycleDataWriter<CData> CDWriter;
00094 
00095 public:
00096   static TypeHandle get_class_type() {
00097     return _type_handle;
00098   }
00099   static void init_type() {
00100     register_type(_type_handle, "BoundedObject");
00101   }
00102 
00103 private:
00104   static TypeHandle _type_handle;
00105 
00106   friend class PandaNode;
00107   friend class CData;  // MSVC6 seems to require this.
00108 };
00109 
00110 #include "boundedObject.I"
00111 
00112 #endif
00113 

Generated on Fri May 2 00:39:15 2003 for Panda by doxygen1.3