cullableObject.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Filename: cullableObject.h
  2. // Created by: drose (04Mar02)
  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 CULLABLEOBJECT_H
  19. #define CULLABLEOBJECT_H
  20. #include "pandabase.h"
  21. #include "geom.h"
  22. #include "renderState.h"
  23. #include "transformState.h"
  24. #include "pointerTo.h"
  25. #include "referenceCount.h"
  26. #include "geomNode.h"
  27. #include "cullTraverserData.h"
  28. ////////////////////////////////////////////////////////////////////
  29. // Class : CullableObject
  30. // Description : The smallest atom of cull. This is normally just a
  31. // Geom and its associated state, but it also represent
  32. // a number of Geoms to be drawn together, with a number
  33. // of Geoms decalled onto them.
  34. ////////////////////////////////////////////////////////////////////
  35. class EXPCL_PANDA CullableObject {
  36. public:
  37. INLINE CullableObject(CullableObject *next = NULL);
  38. INLINE CullableObject(const CullTraverserData &data,
  39. GeomNode *geom_node, int i,
  40. CullableObject *next = NULL);
  41. INLINE CullableObject(Geom *geom, const RenderState *state,
  42. const TransformState *transform,
  43. CullableObject *next = NULL);
  44. INLINE CullableObject(const CullableObject &copy);
  45. INLINE void operator = (const CullableObject &copy);
  46. INLINE bool has_decals() const;
  47. public:
  48. ~CullableObject();
  49. // We will allocate and destroy hundreds or thousands of these a
  50. // frame during the normal course of rendering. As an optimization,
  51. // then, we implement operator new and delete here to minimize this
  52. // overhead.
  53. INLINE void *operator new(size_t size);
  54. INLINE void operator delete(void *ptr);
  55. void output(ostream &out) const;
  56. PUBLISHED:
  57. INLINE static int get_num_ever_allocated();
  58. public:
  59. PT(Geom) _geom;
  60. CPT(RenderState) _state;
  61. CPT(TransformState) _transform;
  62. CullableObject *_next;
  63. private:
  64. static CullableObject *_deleted_chain;
  65. static int _num_ever_allocated;
  66. public:
  67. static TypeHandle get_class_type() {
  68. return _type_handle;
  69. }
  70. static void init_type() {
  71. register_type(_type_handle, "CullableObject");
  72. }
  73. private:
  74. static TypeHandle _type_handle;
  75. };
  76. INLINE ostream &operator << (ostream &out, const CullableObject &object) {
  77. object.output(out);
  78. return out;
  79. }
  80. #include "cullableObject.I"
  81. #endif