boundedObject.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Filename: boundedObject.h
  2. // Created by: drose (02Oct99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef BOUNDEDOBJECT_H
  19. #define BOUNDEDOBJECT_H
  20. #include <pandabase.h>
  21. #include "boundingVolume.h"
  22. #include <typedObject.h>
  23. #include <pointerTo.h>
  24. ////////////////////////////////////////////////////////////////////
  25. // Class : BoundedObject
  26. // Description : This is any object (particularly in a scene graph)
  27. // that may have a bounding volume established for it.
  28. // The user may set a fixed bounding volume, or s/he may
  29. // specify that the volume should be recomputed
  30. // dynamically.
  31. ////////////////////////////////////////////////////////////////////
  32. class EXPCL_PANDA BoundedObject {
  33. public:
  34. INLINE_GRAPH BoundedObject();
  35. virtual ~BoundedObject();
  36. PUBLISHED:
  37. enum BoundingVolumeType {
  38. BVT_static,
  39. BVT_dynamic_sphere,
  40. };
  41. INLINE_GRAPH void set_bound(BoundingVolumeType type);
  42. INLINE_GRAPH void set_bound(const BoundingVolume &volume);
  43. INLINE_GRAPH const BoundingVolume &get_bound() const;
  44. INLINE_GRAPH bool mark_bound_stale();
  45. INLINE_GRAPH void force_bound_stale();
  46. INLINE_GRAPH bool is_bound_stale() const;
  47. INLINE_GRAPH void set_final(bool flag);
  48. INLINE_GRAPH bool is_final() const;
  49. protected:
  50. virtual void propagate_stale_bound();
  51. virtual void recompute_bound();
  52. private:
  53. enum Flags {
  54. F_bound_stale = 0x0001,
  55. F_final = 0x0002,
  56. };
  57. int _flags;
  58. BoundingVolumeType _bound_type;
  59. protected:
  60. PT(BoundingVolume) _bound;
  61. public:
  62. static TypeHandle get_class_type() {
  63. return _type_handle;
  64. }
  65. static void init_type() {
  66. register_type(_type_handle, "BoundedObject");
  67. }
  68. private:
  69. static TypeHandle _type_handle;
  70. };
  71. #ifndef DONT_INLINE_GRAPH
  72. #include "boundedObject.I"
  73. #endif
  74. #endif