Panda3D
Loading...
Searching...
No Matches
cullableObject.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file cullableObject.h
10 * @author drose
11 * @date 2002-03-04
12 */
13
14#ifndef CULLABLEOBJECT_H
15#define CULLABLEOBJECT_H
16
17#include "pandabase.h"
18
19#include "geom.h"
20#include "geomVertexData.h"
21#include "renderState.h"
22#include "transformState.h"
23#include "pointerTo.h"
24#include "geomNode.h"
25#include "cullTraverserData.h"
26#include "pStatCollector.h"
27#include "deletedChain.h"
29#include "sceneSetup.h"
30#include "lightMutex.h"
31#include "callbackObject.h"
33
34class CullTraverser;
35class GeomMunger;
36
37/**
38 * The smallest atom of cull. This is normally just a Geom and its associated
39 * state, but it also contain a draw callback.
40 */
41class EXPCL_PANDA_PGRAPH CullableObject {
42public:
43 INLINE CullableObject();
44 INLINE CullableObject(CPT(Geom) geom, CPT(RenderState) state,
45 CPT(TransformState) internal_transform);
46
47 INLINE CullableObject(const CullableObject &copy);
48 INLINE void operator = (const CullableObject &copy);
49
50 bool munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger,
51 const CullTraverser *traverser, bool force);
52 INLINE void draw(GraphicsStateGuardianBase *gsg,
53 bool force, Thread *current_thread);
54
55 INLINE bool request_resident() const;
56 INLINE static void flush_level();
57
58 INLINE void set_draw_callback(CallbackObject *draw_callback);
59
60 INLINE void draw_inline(GraphicsStateGuardianBase *gsg,
61 bool force, Thread *current_thread);
62 INLINE void draw_callback(GraphicsStateGuardianBase *gsg,
63 bool force, Thread *current_thread);
64
65public:
66 ALLOC_DELETED_CHAIN(CullableObject);
67
68 void output(std::ostream &out) const;
69
70public:
71 CPT(Geom) _geom;
72 CPT(GeomVertexData) _munged_data;
73 CPT(RenderState) _state;
74 CPT(TransformState) _internal_transform;
75 PT(CallbackObject) _draw_callback;
76
77private:
78 bool munge_points_to_quads(const CullTraverser *traverser, bool force);
79
80 static CPT(RenderState) get_flash_cpu_state();
81 static CPT(RenderState) get_flash_hardware_state();
82
83private:
84 // This class is used internally by munge_points_to_quads().
85 class PointData {
86 public:
87 PN_stdfloat _dist;
88 };
89 class SortPoints {
90 public:
91 INLINE SortPoints(const PointData *array);
92 INLINE bool operator ()(unsigned short a, unsigned short b) const;
93
94 const PointData *_array;
95 };
96
97 // This is a cache of converted vertex formats.
98 class SourceFormat {
99 public:
100 SourceFormat(const GeomVertexFormat *format, bool sprite_texcoord);
101 INLINE bool operator < (const SourceFormat &other) const;
102
103 CPT(GeomVertexFormat) _format;
104 bool _sprite_texcoord;
105 bool _retransform_sprites;
106 };
107 typedef pmap<SourceFormat, CPT(GeomVertexFormat) > FormatMap;
108 static FormatMap _format_map;
109 static LightMutex _format_lock;
110
111 static PStatCollector _munge_pcollector;
112 static PStatCollector _munge_geom_pcollector;
113 static PStatCollector _munge_sprites_pcollector;
114 static PStatCollector _munge_sprites_verts_pcollector;
115 static PStatCollector _munge_sprites_prims_pcollector;
116 static PStatCollector _sw_sprites_pcollector;
117
118public:
119 static TypeHandle get_class_type() {
120 return _type_handle;
121 }
122 static void init_type() {
123 register_type(_type_handle, "CullableObject");
124 }
125
126private:
127 static TypeHandle _type_handle;
128};
129
130INLINE std::ostream &operator << (std::ostream &out, const CullableObject &object) {
131 object.output(out);
132 return out;
133}
134
135#include "cullableObject.I"
136
137#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a generic object that can be assigned to a callback at various points in the rendering proces...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
The smallest atom of cull.
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
Definition geomMunger.h:50
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This class defines the physical layout of the vertex data stored within a Geom.
A container for geometry primitives.
Definition geom.h:54
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition lightMutex.h:41
A lightweight class that represents a single element that may be timed and/or counted via stats.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
A thread; that is, a lightweight process.
Definition thread.h:46
Indicates a coordinate-system transform on vertices.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.