30 AccumulatedAttribs() {
31 _transform = TransformState::make_identity();
33 _color_scale_override = 0;
34 _tex_matrix_override = 0;
35 _texture_override = 0;
36 _clip_plane_override = 0;
37 _cull_face_override = 0;
38 _other = RenderState::make_empty();
46 _transform(copy._transform),
48 _color_override(copy._color_override),
49 _color_scale(copy._color_scale),
50 _color_scale_override(copy._color_scale_override),
51 _tex_matrix(copy._tex_matrix),
52 _tex_matrix_override(copy._tex_matrix_override),
53 _texture(copy._texture),
54 _texture_override(copy._texture_override),
55 _clip_plane(copy._clip_plane),
56 _clip_plane_override(copy._clip_plane_override),
57 _cull_face(copy._cull_face),
58 _cull_face_override(copy._cull_face_override),
66 void AccumulatedAttribs::
68 _transform = copy._transform;
70 _color_override = copy._color_override;
71 _color_scale = copy._color_scale;
72 _color_scale_override = copy._color_scale_override;
73 _tex_matrix = copy._tex_matrix;
74 _tex_matrix_override = copy._tex_matrix_override;
75 _texture = copy._texture;
76 _texture_override = copy._texture_override;
77 _clip_plane = copy._clip_plane;
78 _clip_plane_override = copy._clip_plane_override;
79 _cull_face = copy._cull_face;
80 _cull_face_override = copy._cull_face_override;
87 void AccumulatedAttribs::
88 write(std::ostream &out,
int attrib_types,
int indent_level)
const {
89 if ((attrib_types & SceneGraphReducer::TT_transform) != 0) {
90 _transform->write(out, indent_level);
92 if ((attrib_types & SceneGraphReducer::TT_color) != 0) {
93 if (_color ==
nullptr) {
94 indent(out, indent_level) <<
"no color\n";
96 _color->write(out, indent_level);
99 if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) {
100 if (_color_scale ==
nullptr) {
101 indent(out, indent_level) <<
"no color scale\n";
103 _color_scale->write(out, indent_level);
106 if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) {
107 if (_tex_matrix ==
nullptr) {
108 indent(out, indent_level) <<
"no tex matrix\n";
110 _tex_matrix->write(out, indent_level);
113 if ((attrib_types & SceneGraphReducer::TT_clip_plane) != 0) {
114 if (_clip_plane ==
nullptr) {
115 indent(out, indent_level) <<
"no clip plane\n";
117 _clip_plane->write(out, indent_level);
120 if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) {
121 if (_cull_face ==
nullptr) {
122 indent(out, indent_level) <<
"no cull face\n";
124 _cull_face->write(out, indent_level);
127 if ((attrib_types & SceneGraphReducer::TT_other) != 0) {
128 _other->write(out, indent_level);
138 if ((attrib_types & SceneGraphReducer::TT_transform) != 0) {
140 nassertv(_transform !=
nullptr);
141 _transform = _transform->compose(node->get_transform());
158 if ((attrib_types & SceneGraphReducer::TT_color) != 0) {
160 new_state->get_attrib(ColorAttrib::get_class_slot());
161 if (node_attrib !=
nullptr) {
162 int color_override = new_state->get_override(ColorAttrib::get_class_slot());
163 if (color_override >= _color_override ||
166 if (_color ==
nullptr) {
167 _color = node_attrib;
169 _color = _color->compose(node_attrib);
171 _color_override = color_override;
173 new_state = new_state->remove_attrib(ColorAttrib::get_class_slot());
177 if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) {
179 new_state->get_attrib(ColorScaleAttrib::get_class_slot());
180 if (node_attrib !=
nullptr) {
181 int color_scale_override = new_state->get_override(ColorScaleAttrib::get_class_slot());
182 if (color_scale_override >= _color_scale_override ||
183 _color_scale ==
nullptr) {
184 if (_color_scale ==
nullptr) {
185 _color_scale = node_attrib;
187 _color_scale = _color_scale->compose(node_attrib);
189 _color_scale_override = color_scale_override;
191 new_state = new_state->remove_attrib(ColorScaleAttrib::get_class_slot());
195 if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) {
197 new_state->get_attrib(TexMatrixAttrib::get_class_slot());
198 if (node_attrib !=
nullptr) {
199 int tex_matrix_override = new_state->get_override(TexMatrixAttrib::get_class_slot());
200 if (tex_matrix_override >= _tex_matrix_override ||
201 _tex_matrix ==
nullptr) {
202 if (_tex_matrix ==
nullptr) {
203 _tex_matrix = node_attrib;
205 _tex_matrix = _tex_matrix->compose(node_attrib);
207 _tex_matrix_override = tex_matrix_override;
209 new_state = new_state->remove_attrib(TexMatrixAttrib::get_class_slot());
215 new_state->get_attrib(TextureAttrib::get_class_slot());
216 if (tex_attrib !=
nullptr) {
217 int texture_override = new_state->get_override(TextureAttrib::get_class_slot());
218 if (texture_override >= _texture_override ||
219 _texture ==
nullptr) {
220 if (_texture ==
nullptr) {
221 _texture = tex_attrib;
223 _texture = _texture->compose(tex_attrib);
225 _texture_override = texture_override;
234 if ((attrib_types & SceneGraphReducer::TT_clip_plane) != 0) {
236 new_state->get_attrib(ClipPlaneAttrib::get_class_slot());
237 if (node_attrib !=
nullptr) {
238 int clip_plane_override = new_state->get_override(ClipPlaneAttrib::get_class_slot());
239 if (clip_plane_override >= _clip_plane_override ||
240 _clip_plane ==
nullptr) {
241 if (_clip_plane ==
nullptr) {
242 _clip_plane = node_attrib;
244 _clip_plane = _clip_plane->compose(node_attrib);
246 _clip_plane_override = clip_plane_override;
248 new_state = new_state->remove_attrib(ClipPlaneAttrib::get_class_slot());
252 if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) {
254 new_state->get_attrib(CullFaceAttrib::get_class_slot());
255 if (node_attrib !=
nullptr) {
256 int cull_face_override = new_state->get_override(CullFaceAttrib::get_class_slot());
257 if (cull_face_override >= _cull_face_override ||
258 _cull_face ==
nullptr) {
259 if (_cull_face ==
nullptr) {
260 _cull_face = node_attrib;
262 _cull_face = _cull_face->compose(node_attrib);
264 _cull_face_override = cull_face_override;
266 new_state = new_state->remove_attrib(CullFaceAttrib::get_class_slot());
270 if ((attrib_types & SceneGraphReducer::TT_other) != 0) {
272 nassertr(_other !=
nullptr, new_state);
273 _other = _other->compose(new_state);
274 new_state = RenderState::make_empty();
287 if ((attrib_types & SceneGraphReducer::TT_transform) != 0) {
288 node->
set_transform(_transform->compose(node->get_transform())->get_unique());
290 _transform = TransformState::make_identity();
293 if ((attrib_types & SceneGraphReducer::TT_color) != 0) {
294 if (_color !=
nullptr) {
296 node->get_attrib(ColorAttrib::get_class_slot());
297 if (node_attrib !=
nullptr) {
298 node->
set_attrib(_color->compose(node_attrib)->get_unique());
306 if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) {
307 if (_color_scale !=
nullptr) {
309 node->get_attrib(ColorScaleAttrib::get_class_slot());
310 if (node_attrib !=
nullptr) {
311 node->
set_attrib(_color_scale->compose(node_attrib)->get_unique());
315 _color_scale =
nullptr;
319 if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) {
320 if (_tex_matrix !=
nullptr) {
322 node->get_attrib(TexMatrixAttrib::get_class_slot());
323 if (node_attrib !=
nullptr) {
324 node->
set_attrib(_tex_matrix->compose(node_attrib)->get_unique());
328 _tex_matrix =
nullptr;
332 if ((attrib_types & SceneGraphReducer::TT_clip_plane) != 0) {
333 if (_clip_plane !=
nullptr) {
335 node->get_attrib(ClipPlaneAttrib::get_class_slot());
336 if (node_attrib !=
nullptr) {
337 node->
set_attrib(_clip_plane->compose(node_attrib)->get_unique());
341 _clip_plane =
nullptr;
345 if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) {
346 if (_cull_face !=
nullptr) {
348 node->get_attrib(CullFaceAttrib::get_class_slot());
349 if (node_attrib !=
nullptr) {
350 node->
set_attrib(_cull_face->compose(node_attrib)->get_unique());
354 _cull_face =
nullptr;
358 if ((attrib_types & SceneGraphReducer::TT_other) != 0) {
359 node->
set_state(_other->compose(node->get_state())->get_unique());
360 _other = RenderState::make_empty();
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the base class for a number of render attributes (other than transform) that may be set on sc...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
set_state
Sets the complete RenderState that will be applied to all nodes at this level and below.
void collect(PandaNode *node, int attrib_types)
Collects the state and transform from the indicated node and adds it to the accumulator,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
set_transform
Sets the transform that will be applied to this node and below.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void reset_prev_transform(Thread *current_thread=Thread::get_current_thread())
Resets the transform that represents this node's "previous" position to the same as the current trans...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class is used by the SceneGraphReducer to maintain and accumulate the set of attributes we have ...
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_attrib(const RenderAttrib *attrib, int override=0)
Adds the indicated render attribute to the scene graph on this node.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CPT(RenderState) AccumulatedAttribs
Collects the state and transform from the indicated node and adds it to the accumulator,...
void set_prev_transform(const TransformState *transform, Thread *current_thread=Thread::get_current_thread())
Sets the transform that represents this node's "previous" position, one frame ago,...
void apply_to_node(PandaNode *node, int attrib_types)
Stores the indicated attributes in the node's transform and state information; does not attempt to ap...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.