Panda3D
 All Classes Functions Variables Enumerations
multitexReducer.I
1 // Filename: multitexReducer.I
2 // Created by: drose (30Nov04)
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: MultitexReducer::scan
18 // Access: Published
19 // Description: Starts scanning the hierarchy beginning at the
20 // indicated node. Any GeomNodes discovered in the
21 // hierarchy with multitexture will be added to internal
22 // structures in the MultitexReducer so that a future
23 // call to flatten() will operate on all of these at
24 // once.
25 //
26 // This version of this method does not accumulate state
27 // from the parents of the indicated node; thus, only
28 // multitexture effects that have been applied at node
29 // and below will be considered.
30 ////////////////////////////////////////////////////////////////////
31 INLINE void MultitexReducer::
32 scan(const NodePath &node) {
33  scan(node.node(), RenderState::make_empty(), TransformState::make_identity());
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: MultitexReducer::scan
38 // Access: Published
39 // Description: Starts scanning the hierarchy beginning at the
40 // indicated node. Any GeomNodes discovered in the
41 // hierarchy with multitexture will be added to internal
42 // structures in the MultitexReducer so that a future
43 // call to flatten() will operate on all of these at
44 // once.
45 //
46 // The second parameter represents the NodePath from
47 // which to accumulate the state that is considered for
48 // the multitexture. Pass an empty NodePath to
49 // accumulate all the state from the root of the graph,
50 // or you may specify some other node here in order to
51 // not consider nodes above that as contributing to the
52 // state to be flattened. This is particularly useful
53 // if you have some texture stage which is applied
54 // globally to a scene (for instance, a caustics
55 // effect), which you don't want to be considered for
56 // flattening by the MultitexReducer.
57 ////////////////////////////////////////////////////////////////////
58 INLINE void MultitexReducer::
59 scan(const NodePath &node, const NodePath &state_from) {
60  scan(node.node(), node.get_parent().get_state(state_from),
61  node.get_parent().get_transform(state_from));
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function: MultitexReducer::StageInfo::operator <
66 // Access: Public
67 // Description:
68 ////////////////////////////////////////////////////////////////////
69 INLINE bool MultitexReducer::StageInfo::
70 operator < (const MultitexReducer::StageInfo &other) const {
71  if (_stage != other._stage) {
72  return _stage < other._stage;
73  }
74  if (_tex != other._tex) {
75  return _tex < other._tex;
76  }
77  if (_tex_mat != other._tex_mat) {
78  return _tex_mat->compare_to(*other._tex_mat, true) < 0;
79  }
80 
81  return false;
82 }
83 
84 ////////////////////////////////////////////////////////////////////
85 // Function: MultitexReducer::GeomInfo::Constructor
86 // Access: Public
87 // Description:
88 ////////////////////////////////////////////////////////////////////
89 INLINE MultitexReducer::GeomInfo::
90 GeomInfo(const RenderState *state, const RenderState *geom_net_state,
91  GeomNode *geom_node, int index) :
92  _state(state),
93  _geom_net_state(geom_net_state),
94  _geom_node(geom_node),
95  _index(index)
96 {
97 }
98 
99 ////////////////////////////////////////////////////////////////////
100 // Function: MultitexReducer::GeomNodeInfo::Constructor
101 // Access: Public
102 // Description:
103 ////////////////////////////////////////////////////////////////////
104 INLINE MultitexReducer::GeomNodeInfo::
105 GeomNodeInfo(const RenderState *state, GeomNode *geom_node) :
106  _state(state),
107  _geom_node(geom_node)
108 {
109 }
const RenderState * get_state(Thread *current_thread=Thread::get_current_thread()) const
Returns the complete state object set on this node.
Definition: nodePath.cxx:848
NodePath get_parent(Thread *current_thread=Thread::get_current_thread()) const
Returns the NodePath to the parent of the referenced node: that is, this NodePath, shortened by one node.
Definition: nodePath.I:460
void scan(const NodePath &node)
Starts scanning the hierarchy beginning at the indicated node.
const TransformState * get_transform(Thread *current_thread=Thread::get_current_thread()) const
Returns the complete transform object set on this node.
Definition: nodePath.cxx:925
PandaNode * node() const
Returns the referenced node of the path.
Definition: nodePath.I:284
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37