Panda3D
|
00001 // Filename: texMatrixAttrib.I 00002 // Created by: drose (14Mar02) 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: TexMatrixAttrib::Constructor 00018 // Access: Protected 00019 // Description: Use TexMatrixAttrib::make() to construct a new 00020 // TexMatrixAttrib object. 00021 //////////////////////////////////////////////////////////////////// 00022 INLINE TexMatrixAttrib:: 00023 TexMatrixAttrib() { 00024 } 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Function: TexMatrixAttrib::Copy Constructor 00028 // Access: Protected 00029 // Description: Use TexMatrixAttrib::make() to construct a new 00030 // TexMatrixAttrib object. 00031 //////////////////////////////////////////////////////////////////// 00032 INLINE TexMatrixAttrib:: 00033 TexMatrixAttrib(const TexMatrixAttrib ©) : 00034 _stages(copy._stages) 00035 { 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: TexMatrixAttrib::get_override 00040 // Access: Published 00041 // Description: Returns the override value associated with the 00042 // indicated stage. 00043 //////////////////////////////////////////////////////////////////// 00044 INLINE int TexMatrixAttrib:: 00045 get_override(TextureStage *stage) const { 00046 Stages::const_iterator si; 00047 si = _stages.find(StageNode(stage)); 00048 if (si != _stages.end()) { 00049 return (*si)._override; 00050 } 00051 nassert_raise("Specified TextureStage not included in attrib"); 00052 return 0; 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: TexMatrixAttrib::get_geom_rendering 00057 // Access: Published 00058 // Description: Returns the union of the Geom::GeomRendering bits 00059 // that will be required once this TexMatrixAttrib is 00060 // applied to a geom which includes the indicated 00061 // geom_rendering bits. 00062 //////////////////////////////////////////////////////////////////// 00063 INLINE int TexMatrixAttrib:: 00064 get_geom_rendering(int geom_rendering) const { 00065 if ((geom_rendering & Geom::GR_point_sprite) != 0) { 00066 if (!is_empty()) { 00067 geom_rendering |= Geom::GR_point_sprite_tex_matrix; 00068 } 00069 } 00070 00071 return geom_rendering; 00072 } 00073 00074 //////////////////////////////////////////////////////////////////// 00075 // Function: TexMatrixAttrib::StageNode::Constructor 00076 // Access: Public 00077 // Description: 00078 //////////////////////////////////////////////////////////////////// 00079 INLINE TexMatrixAttrib::StageNode:: 00080 StageNode(const TextureStage *stage) : 00081 // Yeah, we cast away the constness here. Just too much trouble to 00082 // deal with it properly. 00083 _stage((TextureStage *)stage), 00084 _override(0) 00085 { 00086 } 00087 00088 //////////////////////////////////////////////////////////////////// 00089 // Function: TexMatrixAttrib::StageNode::operator < 00090 // Access: Public 00091 // Description: Compares the full attributes of StageNodes (as 00092 // opposed to just the pointer compared by 00093 // CompareTextureStagePointer, below). 00094 //////////////////////////////////////////////////////////////////// 00095 INLINE bool TexMatrixAttrib::StageNode:: 00096 operator < (const TexMatrixAttrib::StageNode &other) const { 00097 if (_stage != other._stage) { 00098 return _stage < other._stage; 00099 } 00100 if (_transform != other._transform) { 00101 return _transform < other._transform; 00102 } 00103 return _override < other._override; 00104 } 00105 00106 //////////////////////////////////////////////////////////////////// 00107 // Function: TexMatrixAttrib::CompareTextureStagePointer::operator () 00108 // Access: Public 00109 // Description: This STL function object is used to sort a list of 00110 // texture stages in order by pointer. 00111 //////////////////////////////////////////////////////////////////// 00112 INLINE bool TexMatrixAttrib::CompareTextureStagePointer:: 00113 operator () (const TexMatrixAttrib::StageNode &a, 00114 const TexMatrixAttrib::StageNode &b) const { 00115 return a._stage < b._stage; 00116 }