Panda3D
|
00001 // Filename: stateMunger.cxx 00002 // Created by: drose (04May05) 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 #include "stateMunger.h" 00016 00017 TypeHandle StateMunger::_type_handle; 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: StateMunger::Destructor 00021 // Access: Public, Virtual 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 StateMunger:: 00025 ~StateMunger() { 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: StateMunger::munge_state 00030 // Access: Public 00031 // Description: Given an input state, returns the munged state. 00032 //////////////////////////////////////////////////////////////////// 00033 CPT(RenderState) StateMunger:: 00034 munge_state(const RenderState *state) { 00035 WCPT(RenderState) pt_state = state; 00036 00037 StateMap::iterator mi = _state_map.find(pt_state); 00038 if (mi != _state_map.end()) { 00039 if (!(*mi).first.was_deleted() && 00040 !(*mi).second.was_deleted()) { 00041 return (*mi).second.p(); 00042 } 00043 } 00044 00045 CPT(RenderState) result = munge_state_impl(state); 00046 _state_map[pt_state] = result; 00047 00048 return result; 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: StateMunger::munge_state_impl 00053 // Access: Protected, Virtual 00054 // Description: Given an input state, returns the munged state. 00055 //////////////////////////////////////////////////////////////////// 00056 CPT(RenderState) StateMunger:: 00057 munge_state_impl(const RenderState *state) { 00058 return state; 00059 }