Panda3D
 All Classes Functions Variables Enumerations
renderEffects.I
1 // Filename: renderEffects.I
2 // Created by: drose (14Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: RenderEffects::Effect::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE RenderEffects::Effect::
22 Effect(const RenderEffect *effect) :
23  _type(effect->get_type()),
24  _effect(effect)
25 {
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: RenderEffects::Effect::Constructor
30 // Access: Public
31 // Description: This constructor is only used when reading the
32 // RenderEffects from a bam file. At this point, the
33 // effect pointer is unknown.
34 ////////////////////////////////////////////////////////////////////
35 INLINE RenderEffects::Effect::
36 Effect() {
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function: RenderEffects::Effect::Constructor
41 // Access: Public
42 // Description: This constructor makes an invalid Effect with no
43 // RenderEffect pointer; its purpose is just to make an
44 // object we can use to look up a particular type in the
45 // Effect set.
46 ////////////////////////////////////////////////////////////////////
47 INLINE RenderEffects::Effect::
48 Effect(TypeHandle type) :
49  _type(type),
50  _effect(NULL)
51 {
52 }
53 
54 ////////////////////////////////////////////////////////////////////
55 // Function: RenderEffects::Effect::Copy Constructor
56 // Access: Public
57 // Description:
58 ////////////////////////////////////////////////////////////////////
59 INLINE RenderEffects::Effect::
60 Effect(const Effect &copy) :
61  _type(copy._type),
62  _effect(copy._effect)
63 {
64 }
65 
66 ////////////////////////////////////////////////////////////////////
67 // Function: RenderEffects::Effect::Copy Assignment Operator
68 // Access: Public
69 // Description:
70 ////////////////////////////////////////////////////////////////////
71 INLINE void RenderEffects::Effect::
72 operator = (const Effect &copy) {
73  _type = copy._type;
74  _effect = copy._effect;
75 }
76 
77 ////////////////////////////////////////////////////////////////////
78 // Function: RenderEffects::Effect::operator <
79 // Access: Public
80 // Description: This is used by the Effects set to uniquify
81 // RenderEffects by type. Only one RenderEffect of a
82 // given type is allowed in the set. This ordering must
83 // also match the ordering reported by compare_to().
84 ////////////////////////////////////////////////////////////////////
85 INLINE bool RenderEffects::Effect::
86 operator < (const Effect &other) const {
87  return _type < other._type;
88 }
89 
90 ////////////////////////////////////////////////////////////////////
91 // Function: RenderEffects::Effect::compare_to
92 // Access: Public
93 // Description: Provides an indication of whether a particular
94 // effect is equivalent to another one, for purposes
95 // of generating unique RenderEffects. This should
96 // compare all properties of the Effect, but it is
97 // important that the type is compared first, to be
98 // consistent with the ordering defined by operator <.
99 ////////////////////////////////////////////////////////////////////
100 INLINE int RenderEffects::Effect::
101 compare_to(const Effect &other) const {
102  if (_type != other._type) {
103  return _type.get_index() - other._type.get_index();
104  }
105  if (_effect != other._effect) {
106  return _effect < other._effect ? -1 : 1;
107  }
108  return 0;
109 }
110 
111 ////////////////////////////////////////////////////////////////////
112 // Function: RenderEffects::is_empty
113 // Access: Published
114 // Description: Returns true if the state is empty, false otherwise.
115 ////////////////////////////////////////////////////////////////////
116 INLINE bool RenderEffects::
117 is_empty() const {
118  return _effects.empty();
119 }
120 
121 ////////////////////////////////////////////////////////////////////
122 // Function: RenderEffects::get_num_effects
123 // Access: Published
124 // Description: Returns the number of separate effects indicated
125 // in the state.
126 ////////////////////////////////////////////////////////////////////
127 INLINE int RenderEffects::
129  return _effects.size();
130 }
131 
132 ////////////////////////////////////////////////////////////////////
133 // Function: RenderEffects::get_effect
134 // Access: Published
135 // Description: Returns the nth effect in the state.
136 ////////////////////////////////////////////////////////////////////
137 INLINE const RenderEffect *RenderEffects::
138 get_effect(int n) const {
139  nassertr(n >= 0 && n < (int)_effects.size(), NULL);
140  return _effects[n]._effect;
141 }
142 
143 ////////////////////////////////////////////////////////////////////
144 // Function: RenderEffects::has_decal
145 // Access: Public
146 // Description: This function is provided as an optimization, to
147 // speed up the render-time checking for the existance
148 // of a DecalEffect on this state. It returns true if a
149 // DecalEffect exists, false otherwise. Note that since
150 // there is no additional information stored on the
151 // DecalEffect, there's no point in returning it if it
152 // exists.
153 ////////////////////////////////////////////////////////////////////
154 INLINE bool RenderEffects::
155 has_decal() const {
156  if ((_flags & F_checked_decal) == 0) {
157  // We pretend this function is const, even though it transparently
158  // modifies the internal decal cache.
159  ((RenderEffects *)this)->determine_decal();
160  }
161  return ((_flags & F_has_decal) != 0);
162 }
163 
164 ////////////////////////////////////////////////////////////////////
165 // Function: RenderEffects::has_show_bounds
166 // Access: Public
167 // Description: This function is provided as an optimization, to
168 // speed up the render-time checking for the existance
169 // of a ShowBoundsEffect on this state. It returns true
170 // if a ShowBoundsEffect exists, false otherwise. Note
171 // that since there is no additional information stored
172 // on the ShowBoundsEffect, there's no point in
173 // returning it if it exists.
174 ////////////////////////////////////////////////////////////////////
175 INLINE bool RenderEffects::
177  if ((_flags & F_checked_show_bounds) == 0) {
178  // We pretend this function is const, even though it transparently
179  // modifies the internal show_bounds cache.
180  ((RenderEffects *)this)->determine_show_bounds();
181  }
182  return ((_flags & F_has_show_bounds) != 0);
183 }
184 
185 ////////////////////////////////////////////////////////////////////
186 // Function: RenderEffects::has_show_tight_bounds
187 // Access: Public
188 // Description: If has_show_bounds() returns true, this will return
189 // true if the ShowBoundsEffect in question requests
190 // showing a "tight" bound.
191 ////////////////////////////////////////////////////////////////////
192 INLINE bool RenderEffects::
194  if ((_flags & F_checked_show_bounds) == 0) {
195  // We pretend this function is const, even though it transparently
196  // modifies the internal show_bounds cache.
197  ((RenderEffects *)this)->determine_show_bounds();
198  }
199  return ((_flags & F_has_show_tight_bounds) != 0);
200 }
201 
202 ////////////////////////////////////////////////////////////////////
203 // Function: RenderEffects::has_cull_callback
204 // Access: Public
205 // Description: This function is provided as an optimization, to
206 // speed up the render-time checking for the existance
207 // of an effect with a cull_callback on this state.
208 ////////////////////////////////////////////////////////////////////
209 INLINE bool RenderEffects::
211  if ((_flags & F_checked_cull_callback) == 0) {
212  // We pretend this function is const, even though it transparently
213  // modifies the internal cull_callback cache.
214  ((RenderEffects *)this)->determine_cull_callback();
215  }
216  return ((_flags & F_has_cull_callback) != 0);
217 }
218 
219 ////////////////////////////////////////////////////////////////////
220 // Function: RenderEffects::has_adjust_transform
221 // Access: Public
222 // Description: This function is provided as an optimization, to
223 // speed up the render-time checking for the existance
224 // of an effect with a compute_adjust_transform on this
225 // state.
226 ////////////////////////////////////////////////////////////////////
227 INLINE bool RenderEffects::
229  if ((_flags & F_checked_adjust_transform) == 0) {
230  // We pretend this function is const, even though it transparently
231  // modifies the internal adjust_transform cache.
232  ((RenderEffects *)this)->determine_adjust_transform();
233  }
234  return ((_flags & F_has_adjust_transform) != 0);
235 }
bool has_cull_callback() const
This function is provided as an optimization, to speed up the render-time checking for the existance ...
bool empty() const
Returns true if the ordered vector is empty, false otherwise.
bool has_show_bounds() const
This function is provided as an optimization, to speed up the render-time checking for the existance ...
This is the base class for a number of special render effects that may be set on scene graph nodes to...
Definition: renderEffect.h:56
int get_num_effects() const
Returns the number of separate effects indicated in the state.
bool has_adjust_transform() const
This function is provided as an optimization, to speed up the render-time checking for the existance ...
const RenderEffect * get_effect(int n) const
Returns the nth effect in the state.
bool has_decal() const
This function is provided as an optimization, to speed up the render-time checking for the existance ...
bool is_empty() const
Returns true if the state is empty, false otherwise.
size_type_0 size() const
Returns the number of elements in the ordered vector.
bool has_show_tight_bounds() const
If has_show_bounds() returns true, this will return true if the ShowBoundsEffect in question requests...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This represents a unique collection of RenderEffect objects that correspond to a particular renderabl...
Definition: renderEffects.h:46