mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 00:06:44 -04:00
pgraph: Add RenderState::get_unused_states() by analogy with TransformState
This commit is contained in:
parent
1415ccca61
commit
bcbef3f6c8
@ -145,6 +145,7 @@ PUBLISHED:
|
|||||||
static void list_states(std::ostream &out);
|
static void list_states(std::ostream &out);
|
||||||
static bool validate_states();
|
static bool validate_states();
|
||||||
EXTENSION(static PyObject *get_states());
|
EXTENSION(static PyObject *get_states());
|
||||||
|
EXTENSION(static PyObject *get_unused_states());
|
||||||
|
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
// These methods are intended for use by low-level code, but they're also
|
// These methods are intended for use by low-level code, but they're also
|
||||||
|
@ -142,6 +142,32 @@ get_states() {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all of the "unused" RenderState objects in the state
|
||||||
|
* cache. See get_num_unused_states().
|
||||||
|
*/
|
||||||
|
PyObject *Extension<RenderState>::
|
||||||
|
get_unused_states() {
|
||||||
|
extern struct Dtool_PyTypedObject Dtool_RenderState;
|
||||||
|
if (RenderState::_states == nullptr) {
|
||||||
|
return PyList_New(0);
|
||||||
|
}
|
||||||
|
LightReMutexHolder holder(*RenderState::_states_lock);
|
||||||
|
|
||||||
|
PyObject *list = PyList_New(0);
|
||||||
|
size_t size = RenderState::_states->get_num_entries();
|
||||||
|
for (size_t si = 0; si < size; ++si) {
|
||||||
|
const RenderState *state = RenderState::_states->get_key(si);
|
||||||
|
if (state->get_cache_ref_count() == state->get_ref_count()) {
|
||||||
|
state->ref();
|
||||||
|
PyObject *a =
|
||||||
|
DTool_CreatePyInstanceTyped((void *)state, Dtool_RenderState,
|
||||||
|
true, true, state->get_type_index());
|
||||||
|
PyList_Append(list, a);
|
||||||
|
Py_DECREF(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // HAVE_PYTHON
|
#endif // HAVE_PYTHON
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
PyObject *get_composition_cache() const;
|
PyObject *get_composition_cache() const;
|
||||||
PyObject *get_invert_composition_cache() const;
|
PyObject *get_invert_composition_cache() const;
|
||||||
static PyObject *get_states();
|
static PyObject *get_states();
|
||||||
|
static PyObject *get_unused_states();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HAVE_PYTHON
|
#endif // HAVE_PYTHON
|
||||||
|
Loading…
x
Reference in New Issue
Block a user