RenderState
from panda3d.core import RenderState
- class RenderState
Bases:
NodeCachedReferenceCount
This represents a unique collection of RenderAttrib objects that correspond to a particular renderable state.
You should not attempt to create or modify a RenderState object directly. Instead, call one of the make() functions to create one for you. And instead of modifying a RenderState object, create a new one.
Inheritance diagram
- __init__(*args, **kwargs)
- addAttrib()
C++ Interface: add_attrib(RenderState self, const RenderAttrib attrib, int override)
- /**
Returns a new RenderState object that represents the same as the source
state, with the new RenderAttrib added. If there is already a RenderAttrib
with the same type, it is replaced (unless the override is lower).
*/
- add_attrib()
C++ Interface: add_attrib(RenderState self, const RenderAttrib attrib, int override)
- /**
Returns a new RenderState object that represents the same as the source
state, with the new RenderAttrib added. If there is already a RenderAttrib
with the same type, it is replaced (unless the override is lower).
*/
- adjustAllPriorities()
C++ Interface: adjust_all_priorities(RenderState self, int adjustment)
- /**
Returns a new RenderState object that represents the same as the source
state, with all attributes’ override values incremented (or decremented, if
negative) by the indicated amount. If the override would drop below zero,
it is set to zero.
*/
- adjust_all_priorities()
C++ Interface: adjust_all_priorities(RenderState self, int adjustment)
- /**
Returns a new RenderState object that represents the same as the source
state, with all attributes’ override values incremented (or decremented, if
negative) by the indicated amount. If the override would drop below zero,
it is set to zero.
*/
- attribs
- cacheRef()
C++ Interface: cache_ref(RenderState self)
- /**
Overrides this method to update PStats appropriately.
*/
- cacheUnref()
C++ Interface: cache_unref(RenderState self)
- /**
Overrides this method to update PStats appropriately.
*/
- cache_ref()
C++ Interface: cache_ref(RenderState self)
- /**
Overrides this method to update PStats appropriately.
*/
- cache_unref()
C++ Interface: cache_unref(RenderState self)
- /**
Overrides this method to update PStats appropriately.
*/
- clearCache()
C++ Interface: clear_cache()
- /**
Empties the cache of composed RenderStates. This makes every RenderState
forget what results when it is composed with other RenderStates.
This will eliminate any RenderState objects that have been allocated but
have no references outside of the internal RenderState map. It will not
eliminate RenderState objects that are still in use.
Nowadays, this method should not be necessary, as reference-count cycles in
the composition cache should be automatically detected and broken.
The return value is the number of RenderStates freed by this operation.
*/
- clearMungerCache()
C++ Interface: clear_munger_cache()
- /**
Completely empties the cache of state + gsg -> munger, for all states and
all gsg’s. Normally there is no need to empty this cache.
*/
- clear_cache()
C++ Interface: clear_cache()
- /**
Empties the cache of composed RenderStates. This makes every RenderState
forget what results when it is composed with other RenderStates.
This will eliminate any RenderState objects that have been allocated but
have no references outside of the internal RenderState map. It will not
eliminate RenderState objects that are still in use.
Nowadays, this method should not be necessary, as reference-count cycles in
the composition cache should be automatically detected and broken.
The return value is the number of RenderStates freed by this operation.
*/
- clear_munger_cache()
C++ Interface: clear_munger_cache()
- /**
Completely empties the cache of state + gsg -> munger, for all states and
all gsg’s. Normally there is no need to empty this cache.
*/
- compareMask()
C++ Interface: compare_mask(RenderState self, const RenderState other, BitMask compare_mask)
- /**
This version of compare_to takes a slot mask that indicates which
attributes to include in the comparison. Unlike compare_to, this method
compares the attributes by pointer.
*/
- compareSort()
C++ Interface: compare_sort(RenderState self, const RenderState other)
- /**
Returns -1, 0, or 1 according to the relative sorting of these two
RenderStates, with regards to rendering performance, so that “heavier”
RenderAttribs (as defined by RenderAttribRegistry::get_slot_sort()) are
more likely to be grouped together. This is not related to the sorting
order defined by compare_to.
*/
- compareTo()
C++ Interface: compare_to(RenderState self, const RenderState other)
- /**
Provides an arbitrary ordering among all unique RenderStates, so we can
store the essentially different ones in a big set and throw away the rest.
This method is not needed outside of the RenderState class because all
equivalent RenderState objects are guaranteed to share the same pointer;
thus, a pointer comparison is always sufficient.
*/
- compare_mask()
C++ Interface: compare_mask(RenderState self, const RenderState other, BitMask compare_mask)
- /**
This version of compare_to takes a slot mask that indicates which
attributes to include in the comparison. Unlike compare_to, this method
compares the attributes by pointer.
*/
- compare_sort()
C++ Interface: compare_sort(RenderState self, const RenderState other)
- /**
Returns -1, 0, or 1 according to the relative sorting of these two
RenderStates, with regards to rendering performance, so that “heavier”
RenderAttribs (as defined by RenderAttribRegistry::get_slot_sort()) are
more likely to be grouped together. This is not related to the sorting
order defined by compare_to.
*/
- compare_to()
C++ Interface: compare_to(RenderState self, const RenderState other)
- /**
Provides an arbitrary ordering among all unique RenderStates, so we can
store the essentially different ones in a big set and throw away the rest.
This method is not needed outside of the RenderState class because all
equivalent RenderState objects are guaranteed to share the same pointer;
thus, a pointer comparison is always sufficient.
*/
- compose()
C++ Interface: compose(RenderState self, const RenderState other)
- /**
Returns a new RenderState object that represents the composition of this
state with the other state.
The result of this operation is cached, and will be retained as long as
both this RenderState object and the other RenderState object continue to
exist. Should one of them destruct, the cached entry will be removed, and
its pointer will be allowed to destruct as well.
*/
- cullCallback()
C++ Interface: cull_callback(RenderState self, CullTraverser trav, const CullTraverserData data)
- /**
Calls cull_callback() on each attrib. If any attrib returns false,
interrupts the list and returns false immediately; otherwise, completes the
list and returns true.
*/
- cull_callback()
C++ Interface: cull_callback(RenderState self, CullTraverser trav, const CullTraverserData data)
- /**
Calls cull_callback() on each attrib. If any attrib returns false,
interrupts the list and returns false immediately; otherwise, completes the
list and returns true.
*/
- garbageCollect()
C++ Interface: garbage_collect()
- /**
Performs a garbage-collection cycle. This must be called periodically if
garbage-collect-states is true to ensure that RenderStates get cleaned up
appropriately. It does no harm to call it even if this variable is not
true, but there is probably no advantage in that case.
This automatically calls RenderAttrib::garbage_collect() as well.
*/
- garbage_collect()
C++ Interface: garbage_collect()
- /**
Performs a garbage-collection cycle. This must be called periodically if
garbage-collect-states is true to ensure that RenderStates get cleaned up
appropriately. It does no harm to call it even if this variable is not
true, but there is probably no advantage in that case.
This automatically calls RenderAttrib::garbage_collect() as well.
*/
- getAttrib()
C++ Interface: get_attrib(RenderState self, TypeHandle type) get_attrib(RenderState self, int slot)
- getAttribDef()
C++ Interface: get_attrib_def(RenderState self, int slot)
- /**
Returns the RenderAttrib with the indicated slot index, or the default
attrib for that slot if there is no such RenderAttrib in the state.
*/
- getBinIndex()
C++ Interface: get_bin_index(RenderState self)
- /**
Returns the bin index indicated by the CullBinAttrib, if any, associated by
this state (or the default bin index if there is no CullBinAttrib). This
function is provided as an optimization for determining this at render
time.
*/
- getClassType()
C++ Interface: get_class_type()
- getCompositionCache()
C++ Interface: get_composition_cache(RenderState self)
- getCompositionCacheNumEntries()
C++ Interface: get_composition_cache_num_entries(RenderState self)
- /**
Returns the number of entries in the composition cache for this
RenderState. This is the number of other RenderStates whose composition
with this one has been cached. This number is not useful for any practical
reason other than performance analysis.
*/
- getCompositionCacheResult()
C++ Interface: get_composition_cache_result(RenderState self, int n)
- /**
Returns the result RenderState of the nth element in the composition cache.
Returns NULL if there doesn’t happen to be an entry in the nth element.
In general, a->compose(a->get_composition_cache_source(n)) ==
a->get_composition_cache_result(n).
This has no practical value other than for examining the cache for
performance analysis.
*/
- getCompositionCacheSize()
C++ Interface: get_composition_cache_size(RenderState self)
- /**
Returns the number of slots in the composition cache for this RenderState.
You may use this as an upper bound when walking through all of the
composition cache results via get_composition_cache_source() or result().
This has no practical value other than for examining the cache for
performance analysis.
*/
- getCompositionCacheSource()
C++ Interface: get_composition_cache_source(RenderState self, int n)
- /**
Returns the source RenderState of the nth element in the composition cache.
Returns NULL if there doesn’t happen to be an entry in the nth element.
See get_composition_cache_result().
This has no practical value other than for examining the cache for
performance analysis.
*/
- getDrawOrder()
C++ Interface: get_draw_order(RenderState self)
// These methods are intended for use by low-level code, but they’re also // handy enough to expose to high-level users.
- /**
Returns the draw order indicated by the CullBinAttrib, if any, associated
by this state (or 0 if there is no CullBinAttrib). See get_bin_index().
*/
- getGeomRendering()
C++ Interface: get_geom_rendering(RenderState self, int geom_rendering)
- /**
Returns the union of the Geom::GeomRendering bits that will be required
once this RenderState is applied to a geom which includes the indicated
geom_rendering bits.
*/
- getHash()
C++ Interface: get_hash(RenderState self)
- /**
Returns a suitable hash value for phash_map.
*/
- getInvertCompositionCache()
C++ Interface: get_invert_composition_cache(RenderState self)
- getInvertCompositionCacheNumEntries()
C++ Interface: get_invert_composition_cache_num_entries(RenderState self)
- /**
Returns the number of entries in the invert_composition cache for this
RenderState. This is similar to the composition cache, but it records
cache entries for the invert_compose() operation. See
get_composition_cache_num_entries().
*/
- getInvertCompositionCacheResult()
C++ Interface: get_invert_composition_cache_result(RenderState self, int n)
- /**
Returns the result RenderState of the nth element in the invert composition
cache. Returns NULL if there doesn’t happen to be an entry in the nth
element.
In general, a->invert_compose(a->get_invert_composition_cache_source(n)) ==
a->get_invert_composition_cache_result(n).
This has no practical value other than for examining the cache for
performance analysis.
*/
- getInvertCompositionCacheSize()
C++ Interface: get_invert_composition_cache_size(RenderState self)
- /**
Returns the number of slots in the composition cache for this RenderState.
You may use this as an upper bound when walking through all of the
composition cache results via get_invert_composition_cache_source() or
result().
This has no practical value other than for examining the cache for
performance analysis.
*/
- getInvertCompositionCacheSource()
C++ Interface: get_invert_composition_cache_source(RenderState self, int n)
- /**
Returns the source RenderState of the nth element in the invert composition
cache. Returns NULL if there doesn’t happen to be an entry in the nth
element. See get_invert_composition_cache_result().
This has no practical value other than for examining the cache for
performance analysis.
*/
- getMaxPriority()
C++ Interface: get_max_priority()
- /**
Returns the maximum priority number (sometimes called override) that may be
set on any node. This may or may not be enforced, but the scene graph code
assumes that no priority numbers will be larger than this, and some effects
may not work properly if you use a larger number.
*/
- getNumStates()
C++ Interface: get_num_states()
- /**
Returns the total number of unique RenderState objects allocated in the
world. This will go up and down during normal operations.
*/
- getNumUnusedStates()
C++ Interface: get_num_unused_states()
- /**
Returns the total number of RenderState objects that have been allocated
but have no references outside of the internal RenderState cache.
A nonzero return value is not necessarily indicative of leaked references;
it is normal for two RenderState objects, both of which have references
held outside the cache, to have to result of their composition stored
within the cache. This result will be retained within the cache until one
of the base RenderStates is released.
Use list_cycles() to get an idea of the number of actual “leaked”
RenderState objects.
*/
- getOverride()
C++ Interface: get_override(RenderState self, TypeHandle type) get_override(RenderState self, int slot)
- getStates()
C++ Interface: get_states()
- getUnique()
C++ Interface: get_unique(RenderState self)
- /**
Returns the pointer to the unique RenderState in the cache that is
equivalent to this one. This may be the same pointer as this object, or it
may be a different pointer; but it will be an equivalent object, and it
will be a shared pointer. This may be called from time to time to improve
cache benefits.
*/
- getUnusedStates()
C++ Interface: get_unused_states()
- get_attrib()
C++ Interface: get_attrib(RenderState self, TypeHandle type) get_attrib(RenderState self, int slot)
- get_attrib_def()
C++ Interface: get_attrib_def(RenderState self, int slot)
- /**
Returns the RenderAttrib with the indicated slot index, or the default
attrib for that slot if there is no such RenderAttrib in the state.
*/
- get_bin_index()
C++ Interface: get_bin_index(RenderState self)
- /**
Returns the bin index indicated by the CullBinAttrib, if any, associated by
this state (or the default bin index if there is no CullBinAttrib). This
function is provided as an optimization for determining this at render
time.
*/
- get_class_type()
C++ Interface: get_class_type()
- get_composition_cache()
C++ Interface: get_composition_cache(RenderState self)
- get_composition_cache_num_entries()
C++ Interface: get_composition_cache_num_entries(RenderState self)
- /**
Returns the number of entries in the composition cache for this
RenderState. This is the number of other RenderStates whose composition
with this one has been cached. This number is not useful for any practical
reason other than performance analysis.
*/
- get_composition_cache_result()
C++ Interface: get_composition_cache_result(RenderState self, int n)
- /**
Returns the result RenderState of the nth element in the composition cache.
Returns NULL if there doesn’t happen to be an entry in the nth element.
In general, a->compose(a->get_composition_cache_source(n)) ==
a->get_composition_cache_result(n).
This has no practical value other than for examining the cache for
performance analysis.
*/
- get_composition_cache_size()
C++ Interface: get_composition_cache_size(RenderState self)
- /**
Returns the number of slots in the composition cache for this RenderState.
You may use this as an upper bound when walking through all of the
composition cache results via get_composition_cache_source() or result().
This has no practical value other than for examining the cache for
performance analysis.
*/
- get_composition_cache_source()
C++ Interface: get_composition_cache_source(RenderState self, int n)
- /**
Returns the source RenderState of the nth element in the composition cache.
Returns NULL if there doesn’t happen to be an entry in the nth element.
See get_composition_cache_result().
This has no practical value other than for examining the cache for
performance analysis.
*/
- get_draw_order()
C++ Interface: get_draw_order(RenderState self)
// These methods are intended for use by low-level code, but they’re also // handy enough to expose to high-level users.
- /**
Returns the draw order indicated by the CullBinAttrib, if any, associated
by this state (or 0 if there is no CullBinAttrib). See get_bin_index().
*/
- get_geom_rendering()
C++ Interface: get_geom_rendering(RenderState self, int geom_rendering)
- /**
Returns the union of the Geom::GeomRendering bits that will be required
once this RenderState is applied to a geom which includes the indicated
geom_rendering bits.
*/
- get_hash()
C++ Interface: get_hash(RenderState self)
- /**
Returns a suitable hash value for phash_map.
*/
- get_invert_composition_cache()
C++ Interface: get_invert_composition_cache(RenderState self)
- get_invert_composition_cache_num_entries()
C++ Interface: get_invert_composition_cache_num_entries(RenderState self)
- /**
Returns the number of entries in the invert_composition cache for this
RenderState. This is similar to the composition cache, but it records
cache entries for the invert_compose() operation. See
get_composition_cache_num_entries().
*/
- get_invert_composition_cache_result()
C++ Interface: get_invert_composition_cache_result(RenderState self, int n)
- /**
Returns the result RenderState of the nth element in the invert composition
cache. Returns NULL if there doesn’t happen to be an entry in the nth
element.
In general, a->invert_compose(a->get_invert_composition_cache_source(n)) ==
a->get_invert_composition_cache_result(n).
This has no practical value other than for examining the cache for
performance analysis.
*/
- get_invert_composition_cache_size()
C++ Interface: get_invert_composition_cache_size(RenderState self)
- /**
Returns the number of slots in the composition cache for this RenderState.
You may use this as an upper bound when walking through all of the
composition cache results via get_invert_composition_cache_source() or
result().
This has no practical value other than for examining the cache for
performance analysis.
*/
- get_invert_composition_cache_source()
C++ Interface: get_invert_composition_cache_source(RenderState self, int n)
- /**
Returns the source RenderState of the nth element in the invert composition
cache. Returns NULL if there doesn’t happen to be an entry in the nth
element. See get_invert_composition_cache_result().
This has no practical value other than for examining the cache for
performance analysis.
*/
- get_max_priority()
C++ Interface: get_max_priority()
- /**
Returns the maximum priority number (sometimes called override) that may be
set on any node. This may or may not be enforced, but the scene graph code
assumes that no priority numbers will be larger than this, and some effects
may not work properly if you use a larger number.
*/
- get_num_states()
C++ Interface: get_num_states()
- /**
Returns the total number of unique RenderState objects allocated in the
world. This will go up and down during normal operations.
*/
- get_num_unused_states()
C++ Interface: get_num_unused_states()
- /**
Returns the total number of RenderState objects that have been allocated
but have no references outside of the internal RenderState cache.
A nonzero return value is not necessarily indicative of leaked references;
it is normal for two RenderState objects, both of which have references
held outside the cache, to have to result of their composition stored
within the cache. This result will be retained within the cache until one
of the base RenderStates is released.
Use list_cycles() to get an idea of the number of actual “leaked”
RenderState objects.
*/
- get_override()
C++ Interface: get_override(RenderState self, TypeHandle type) get_override(RenderState self, int slot)
- get_states()
C++ Interface: get_states()
- get_unique()
C++ Interface: get_unique(RenderState self)
- /**
Returns the pointer to the unique RenderState in the cache that is
equivalent to this one. This may be the same pointer as this object, or it
may be a different pointer; but it will be an equivalent object, and it
will be a shared pointer. This may be called from time to time to improve
cache benefits.
*/
- get_unused_states()
C++ Interface: get_unused_states()
- hasAttrib()
C++ Interface: has_attrib(RenderState self, TypeHandle type) has_attrib(RenderState self, int slot)
- hasCullCallback()
C++ Interface: has_cull_callback(RenderState self)
- /**
Returns true if any of the RenderAttribs in this state request a
cull_callback(), false if none of them do.
*/
- has_attrib()
C++ Interface: has_attrib(RenderState self, TypeHandle type) has_attrib(RenderState self, int slot)
- has_cull_callback()
C++ Interface: has_cull_callback(RenderState self)
- /**
Returns true if any of the RenderAttribs in this state request a
cull_callback(), false if none of them do.
*/
- invertCompose()
C++ Interface: invert_compose(RenderState self, const RenderState other)
- /**
Returns a new RenderState object that represents the composition of this
state’s inverse with the other state.
This is similar to compose(), but is particularly useful for computing the
relative state of a node as viewed from some other node.
*/
- invert_compose()
C++ Interface: invert_compose(RenderState self, const RenderState other)
- /**
Returns a new RenderState object that represents the composition of this
state’s inverse with the other state.
This is similar to compose(), but is particularly useful for computing the
relative state of a node as viewed from some other node.
*/
- isEmpty()
C++ Interface: is_empty(RenderState self)
- /**
Returns true if the state is empty, false otherwise.
*/
- is_empty()
C++ Interface: is_empty(RenderState self)
- /**
Returns true if the state is empty, false otherwise.
*/
- listCycles()
C++ Interface: list_cycles(ostream out)
- /**
Detects all of the reference-count cycles in the cache and reports them to
standard output.
These cycles may be inadvertently created when state compositions cycle
back to a starting point. Nowadays, these cycles should be automatically
detected and broken, so this method should never list any cycles unless
there is a bug in that detection logic.
The cycles listed here are not leaks in the strictest sense of the word,
since they can be reclaimed by a call to clear_cache(); but they will not
be reclaimed automatically.
*/
- listStates()
C++ Interface: list_states(ostream out)
- /**
Lists all of the RenderStates in the cache to the output stream, one per
line. This can be quite a lot of output if the cache is large, so be
prepared.
*/
- list_cycles()
C++ Interface: list_cycles(ostream out)
- /**
Detects all of the reference-count cycles in the cache and reports them to
standard output.
These cycles may be inadvertently created when state compositions cycle
back to a starting point. Nowadays, these cycles should be automatically
detected and broken, so this method should never list any cycles unless
there is a bug in that detection logic.
The cycles listed here are not leaks in the strictest sense of the word,
since they can be reclaimed by a call to clear_cache(); but they will not
be reclaimed automatically.
*/
- list_states()
C++ Interface: list_states(ostream out)
- /**
Lists all of the RenderStates in the cache to the output stream, one per
line. This can be quite a lot of output if the cache is large, so be
prepared.
*/
- make()
Returns a RenderState with one attribute set.
Returns a RenderState with two attributes set.
Returns a RenderState with three attributes set.
Returns a RenderState with four attributes set.
Returns a RenderState with five attributes set.
Returns a RenderState with n attributes set.
- nodeRef()
C++ Interface: node_ref(RenderState self)
- /**
Overrides this method to update PStats appropriately.
*/
- nodeUnref()
C++ Interface: node_unref(RenderState self)
- /**
Overrides this method to update PStats appropriately.
*/
- node_ref()
C++ Interface: node_ref(RenderState self)
- /**
Overrides this method to update PStats appropriately.
*/
- node_unref()
C++ Interface: node_unref(RenderState self)
- /**
Overrides this method to update PStats appropriately.
*/
- removeAttrib()
C++ Interface: remove_attrib(RenderState self, TypeHandle type) remove_attrib(RenderState self, int slot)
- remove_attrib()
C++ Interface: remove_attrib(RenderState self, TypeHandle type) remove_attrib(RenderState self, int slot)
- setAttrib()
C++ Interface: set_attrib(RenderState self, const RenderAttrib attrib) set_attrib(RenderState self, const RenderAttrib attrib, int override)
- /**
Returns a new RenderState object that represents the same as the source
state, with the new RenderAttrib added. If there is already a RenderAttrib
with the same type, it is replaced unconditionally. The override is not
changed.
*/
- /**
Returns a new RenderState object that represents the same as the source
state, with the new RenderAttrib added. If there is already a RenderAttrib
with the same type, it is replaced unconditionally. The override is also
replaced unconditionally.
*/
- set_attrib()
C++ Interface: set_attrib(RenderState self, const RenderAttrib attrib) set_attrib(RenderState self, const RenderAttrib attrib, int override)
- /**
Returns a new RenderState object that represents the same as the source
state, with the new RenderAttrib added. If there is already a RenderAttrib
with the same type, it is replaced unconditionally. The override is not
changed.
*/
- /**
Returns a new RenderState object that represents the same as the source
state, with the new RenderAttrib added. If there is already a RenderAttrib
with the same type, it is replaced unconditionally. The override is also
replaced unconditionally.
*/
- validateStates()
C++ Interface: validate_states()
- /**
Ensures that the cache is still stored in sorted order, and that none of
the cache elements have been inadvertently deleted. Returns true if so,
false if there is a problem (which implies someone has modified one of the
supposedly-const RenderState objects).
*/
- validate_states()
C++ Interface: validate_states()
- /**
Ensures that the cache is still stored in sorted order, and that none of
the cache elements have been inadvertently deleted. Returns true if so,
false if there is a problem (which implies someone has modified one of the
supposedly-const RenderState objects).
*/