Panda3D
Loading...
Searching...
No Matches
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
16TypeHandle StateMunger::_type_handle;
17
18/**
19 *
20 */
21StateMunger::
22~StateMunger() {
23}
24
25/**
26 * Given an input state, returns the munged state.
27 */
28CPT(RenderState) StateMunger::
29munge_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 */
51CPT(RenderState) StateMunger::
52munge_state_impl(const RenderState *state) {
53 return state;
54}
GraphicsStateGuardianBase * get_gsg() const
Returns a pointer to the GSG that created this munger.
Definition geomMunger.I:18
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition renderState.h:47
int store(const Key &key, const Value &data)
Records the indicated key/data pair in the map.
const Value & get_data(size_t n) const
Returns the data in the nth entry of the table.
int find(const Key &key) const
Searches for the indicated key in the table.
void remove_element(size_t n)
Removes the nth entry from the table.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.