00001 // Filename: multitexReducer.I 00002 // Created by: drose (30Nov04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: MultitexReducer::scan 00018 // Access: Published 00019 // Description: Starts scanning the hierarchy beginning at the 00020 // indicated node. Any GeomNodes discovered in the 00021 // hierarchy with multitexture will be added to internal 00022 // structures in the MultitexReducer so that a future 00023 // call to flatten() will operate on all of these at 00024 // once. 00025 // 00026 // This version of this method does not accumulate state 00027 // from the parents of the indicated node; thus, only 00028 // multitexture effects that have been applied at node 00029 // and below will be considered. 00030 //////////////////////////////////////////////////////////////////// 00031 INLINE void MultitexReducer:: 00032 scan(const NodePath &node) { 00033 scan(node.node(), RenderState::make_empty(), TransformState::make_identity()); 00034 } 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Function: MultitexReducer::scan 00038 // Access: Published 00039 // Description: Starts scanning the hierarchy beginning at the 00040 // indicated node. Any GeomNodes discovered in the 00041 // hierarchy with multitexture will be added to internal 00042 // structures in the MultitexReducer so that a future 00043 // call to flatten() will operate on all of these at 00044 // once. 00045 // 00046 // The second parameter represents the NodePath from 00047 // which to accumulate the state that is considered for 00048 // the multitexture. Pass an empty NodePath to 00049 // accumulate all the state from the root of the graph, 00050 // or you may specify some other node here in order to 00051 // not consider nodes above that as contributing to the 00052 // state to be flattened. This is particularly useful 00053 // if you have some texture stage which is applied 00054 // globally to a scene (for instance, a caustics 00055 // effect), which you don't want to be considered for 00056 // flattening by the MultitexReducer. 00057 //////////////////////////////////////////////////////////////////// 00058 INLINE void MultitexReducer:: 00059 scan(const NodePath &node, const NodePath &state_from) { 00060 scan(node.node(), node.get_parent().get_state(state_from), 00061 node.get_parent().get_transform(state_from)); 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: MultitexReducer::StageInfo::operator < 00066 // Access: Public 00067 // Description: 00068 //////////////////////////////////////////////////////////////////// 00069 INLINE bool MultitexReducer::StageInfo:: 00070 operator < (const MultitexReducer::StageInfo &other) const { 00071 if (_stage != other._stage) { 00072 return _stage < other._stage; 00073 } 00074 if (_tex != other._tex) { 00075 return _tex < other._tex; 00076 } 00077 if (_tex_mat != other._tex_mat) { 00078 return _tex_mat->compare_to(*other._tex_mat, true) < 0; 00079 } 00080 00081 return false; 00082 } 00083 00084 //////////////////////////////////////////////////////////////////// 00085 // Function: MultitexReducer::GeomInfo::Constructor 00086 // Access: Public 00087 // Description: 00088 //////////////////////////////////////////////////////////////////// 00089 INLINE MultitexReducer::GeomInfo:: 00090 GeomInfo(const RenderState *state, const RenderState *geom_net_state, 00091 GeomNode *geom_node, int index) : 00092 _state(state), 00093 _geom_net_state(geom_net_state), 00094 _geom_node(geom_node), 00095 _index(index) 00096 { 00097 } 00098 00099 //////////////////////////////////////////////////////////////////// 00100 // Function: MultitexReducer::GeomNodeInfo::Constructor 00101 // Access: Public 00102 // Description: 00103 //////////////////////////////////////////////////////////////////// 00104 INLINE MultitexReducer::GeomNodeInfo:: 00105 GeomNodeInfo(const RenderState *state, GeomNode *geom_node) : 00106 _state(state), 00107 _geom_node(geom_node) 00108 { 00109 }