Panda3D
Loading...
Searching...
No Matches
multitexReducer.I
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 multitexReducer.I
10 * @author drose
11 * @date 2004-11-30
12 */
13
14/**
15 * Starts scanning the hierarchy beginning at the indicated node. Any
16 * GeomNodes discovered in the hierarchy with multitexture will be added to
17 * internal structures in the MultitexReducer so that a future call to
18 * flatten() will operate on all of these at once.
19 *
20 * This version of this method does not accumulate state from the parents of
21 * the indicated node; thus, only multitexture effects that have been applied
22 * at node and below will be considered.
23 */
25scan(const NodePath &node) {
26 scan(node.node(), RenderState::make_empty(), TransformState::make_identity());
27}
28
29/**
30 * Starts scanning the hierarchy beginning at the indicated node. Any
31 * GeomNodes discovered in the hierarchy with multitexture will be added to
32 * internal structures in the MultitexReducer so that a future call to
33 * flatten() will operate on all of these at once.
34 *
35 * The second parameter represents the NodePath from which to accumulate the
36 * state that is considered for the multitexture. Pass an empty NodePath to
37 * accumulate all the state from the root of the graph, or you may specify
38 * some other node here in order to not consider nodes above that as
39 * contributing to the state to be flattened. This is particularly useful if
40 * you have some texture stage which is applied globally to a scene (for
41 * instance, a caustics effect), which you don't want to be considered for
42 * flattening by the MultitexReducer.
43 */
45scan(const NodePath &node, const NodePath &state_from) {
46 scan(node.node(), node.get_parent().get_state(state_from),
47 node.get_parent().get_transform(state_from));
48}
49
50/**
51 *
52 */
53INLINE bool MultitexReducer::StageInfo::
54operator < (const MultitexReducer::StageInfo &other) const {
55 if (_stage != other._stage) {
56 return _stage < other._stage;
57 }
58 if (_tex != other._tex) {
59 return _tex < other._tex;
60 }
61 if (_tex_mat != other._tex_mat) {
62 return _tex_mat->compare_to(*other._tex_mat, true) < 0;
63 }
64
65 return false;
66}
67
68/**
69 *
70 */
71INLINE MultitexReducer::GeomInfo::
72GeomInfo(const RenderState *state, const RenderState *geom_net_state,
73 GeomNode *geom_node, int index) :
74 _state(state),
75 _geom_net_state(geom_net_state),
76 _geom_node(geom_node),
77 _index(index)
78{
79}
80
81/**
82 *
83 */
84INLINE MultitexReducer::GeomNodeInfo::
85GeomNodeInfo(const RenderState *state, GeomNode *geom_node) :
86 _state(state),
87 _geom_node(geom_node)
88{
89}
A node that holds Geom objects, renderable pieces of geometry.
Definition geomNode.h:34
void scan(const NodePath &node)
Starts scanning the hierarchy beginning at the indicated node.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
PandaNode * node() const
Returns the referenced node of the path.
Definition nodePath.I:227
get_parent
Returns the NodePath to the parent of the referenced node: that is, this NodePath,...
Definition nodePath.h:242
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47