Panda3D
stateMunger.cxx
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 stateMunger.cxx
10  * @author drose
11  * @date 2005-05-04
12  */
13 
14 #include "stateMunger.h"
15 
16 TypeHandle StateMunger::_type_handle;
17 
18 /**
19  *
20  */
21 StateMunger::
22 ~StateMunger() {
23 }
24 
25 /**
26  * Given an input state, returns the munged state.
27  */
28 CPT(RenderState) StateMunger::
29 munge_state(const RenderState *state) {
30  RenderState::MungedStates &munged_states = state->_munged_states;
31 
32  int id = get_gsg()->_id;
33  int mi = munged_states.find(id);
34  if (mi != -1) {
35  if (auto munged_state = munged_states.get_data(mi).lock()) {
36  return munged_state;
37  } else {
38  munged_states.remove_element(mi);
39  }
40  }
41 
42  CPT(RenderState) result = munge_state_impl(state);
43  munged_states.store(id, result);
44 
45  return result;
46 }
47 
48 /**
49  * Given an input state, returns the munged state.
50  */
51 CPT(RenderState) StateMunger::
52 munge_state_impl(const RenderState *state) {
53  return state;
54 }
CPT(RenderState) StateMunger
Given an input state, returns the munged state.
Definition: stateMunger.cxx:28
const Value & get_data(size_t n) const
Returns the data in the nth entry of the table.
int store(const Key &key, const Value &data)
Records the indicated key/data pair in the map.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void remove_element(size_t n)
Removes the nth entry from the table.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
GraphicsStateGuardianBase * get_gsg() const
Returns a pointer to the GSG that created this munger.
Definition: geomMunger.I:18
int find(const Key &key) const
Searches for the indicated key in the table.