00001 // Filename: cullableObject.h 00002 // Created by: drose (04Mar02) 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 CULLABLEOBJECT_H 00020 #define CULLABLEOBJECT_H 00021 00022 #include "pandabase.h" 00023 00024 #include "geom.h" 00025 #include "renderState.h" 00026 #include "transformState.h" 00027 #include "pointerTo.h" 00028 #include "referenceCount.h" 00029 #include "geomNode.h" 00030 #include "cullTraverserData.h" 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Class : CullableObject 00034 // Description : The smallest atom of cull. This is normally just a 00035 // Geom and its associated state, but it also represent 00036 // a number of Geoms to be drawn together, with a number 00037 // of Geoms decalled onto them. 00038 //////////////////////////////////////////////////////////////////// 00039 class EXPCL_PANDA CullableObject { 00040 public: 00041 INLINE CullableObject(CullableObject *next = NULL); 00042 INLINE CullableObject(const CullTraverserData &data, 00043 GeomNode *geom_node, int i, 00044 CullableObject *next = NULL); 00045 INLINE CullableObject(Geom *geom, const RenderState *state, 00046 const TransformState *transform, 00047 CullableObject *next = NULL); 00048 00049 INLINE CullableObject(const CullableObject ©); 00050 INLINE void operator = (const CullableObject ©); 00051 00052 INLINE bool has_decals() const; 00053 00054 public: 00055 ~CullableObject(); 00056 00057 // We will allocate and destroy hundreds or thousands of these a 00058 // frame during the normal course of rendering. As an optimization, 00059 // then, we implement operator new and delete here to minimize this 00060 // overhead. 00061 INLINE void *operator new(size_t size); 00062 INLINE void operator delete(void *ptr); 00063 void output(ostream &out) const; 00064 00065 PUBLISHED: 00066 INLINE static int get_num_ever_allocated(); 00067 00068 public: 00069 PT(Geom) _geom; 00070 CPT(RenderState) _state; 00071 CPT(TransformState) _transform; 00072 CullableObject *_next; 00073 00074 private: 00075 static CullableObject *_deleted_chain; 00076 static int _num_ever_allocated; 00077 00078 public: 00079 static TypeHandle get_class_type() { 00080 return _type_handle; 00081 } 00082 static void init_type() { 00083 register_type(_type_handle, "CullableObject"); 00084 } 00085 00086 private: 00087 static TypeHandle _type_handle; 00088 }; 00089 00090 INLINE ostream &operator << (ostream &out, const CullableObject &object) { 00091 object.output(out); 00092 return out; 00093 } 00094 00095 #include "cullableObject.I" 00096 00097 #endif