Panda3D
Public Types | Public Member Functions | Static Public Member Functions

RenderState Class Reference

This represents a unique collection of RenderAttrib objects that correspond to a particular renderable state. More...

Inheritance diagram for RenderState:
NodeCachedReferenceCount CachedTypedWritableReferenceCount TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

List of all members.

Public Types

enum  Referenced { RNode = 1, RCache = 2 }

Public Member Functions

RenderState const addAttrib (RenderAttrib const attrib, int override)
 Returns a new RenderState object that represents the same as the source state, with the new RenderAttrib added.
RenderState const addAttrib (RenderAttrib const attrib)
 Returns a new RenderState object that represents the same as the source state, with the new RenderAttrib added.
RenderState const adjustAllPriorities (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.
 cacheRef ()
 Overrides this method to update PStats appropriately.
bool cacheUnref ()
 Overrides this method to update PStats appropriately.
int compareSort (RenderState const 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.
RenderState const compose (RenderState const other)
 Returns a new RenderState object that represents the composition of this state with the other state.
bool cullCallback (CullTraverser trav, CullTraverserData const data)
 Calls cull_callback() on each attrib.
string encodeToBamStream ()
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string.
bool encodeToBamStream (basic_stringchar data, BamWriter writer)
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string.
bool encodeToBamStream (basic_stringchar data)
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string.
RenderAttrib const getAttrib (TypeHandle type)
 Looks for a RenderAttrib of the indicated type in the state, and returns it if it is found, or NULL if it is not.
RenderAttrib const getAttrib (int slot)
 Returns the RenderAttrib with the indicated slot index, or NULL if there is no such RenderAttrib in the state.
RenderAttrib const getAttribDef (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.
UpdateSeq getBamModified ()
 Returns the current bam_modified counter.
int getBinIndex ()
 Returns the bin index indicated by the CullBinAttrib, if any, associated by this state (or the default bin index if there is no CullBinAttrib).
int getCacheRefCount ()
 Returns the current reference count.
PyObject getCompositionCache ()
 Returns a list of 2-tuples that represents the composition cache.
int getCompositionCacheNumEntries ()
 Returns the number of entries in the composition cache for this RenderState.
RenderState const getCompositionCacheResult (int n)
 Returns the result RenderState of the nth element in the composition cache.
int getCompositionCacheSize ()
 Returns the number of slots in the composition cache for this RenderState.
RenderState const getCompositionCacheSource (int n)
 Returns the source RenderState of the nth element in the composition cache.
int getDrawOrder ()
 Returns the draw order indicated by the CullBinAttrib, if any, associated by this state (or 0 if there is no CullBinAttrib).
int getGeomRendering (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.
unsigned int getHash ()
 Returns a suitable hash value for phash_map.
PyObject getInvertCompositionCache ()
 Returns a list of 2-tuples that represents the invert_composition cache.
int getInvertCompositionCacheNumEntries ()
 Returns the number of entries in the invert_composition cache for this RenderState.
RenderState const getInvertCompositionCacheResult (int n)
 Returns the result RenderState of the nth element in the invert composition cache.
int getInvertCompositionCacheSize ()
 Returns the number of slots in the composition cache for this RenderState.
RenderState const getInvertCompositionCacheSource (int n)
 Returns the source RenderState of the nth element in the invert composition cache.
int getNodeRefCount ()
 Returns the current reference count.
int getOverride (TypeHandle type)
 Looks for a RenderAttrib of the indicated type in the state, and returns its override value if it is found, or 0 if it is not.
int getOverride (int slot)
 Looks for a RenderAttrib of the indicated type in the state, and returns its override value if it is found, or 0 if it is not.
int getRefCount ()
 Returns the current reference count.
int getReferencedBits ()
 Returns the union of the values defined in the Referenced enum that represents the various things that appear to be holding a pointer to this object.
TypeHandle getType ()
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.
RenderState const getUnique ()
 Returns the pointer to the unique RenderState in the cache that is equivalent to this one.
bool hasAttrib (int slot)
 Returns true if an attrib of the indicated type is present, false otherwise.
bool hasAttrib (TypeHandle type)
 Returns true if an attrib of the indicated type is present, false otherwise.
bool hasCullCallback ()
 Returns true if any of the RenderAttribs in this state request a cull_callback(), false if none of them do.
RenderState const invertCompose (RenderState const other)
 Returns a new RenderState object that represents the composition of this state's inverse with the other state.
bool isEmpty ()
 Returns true if the state is empty, false otherwise.
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly.
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type.
 markBamModified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams.
 nodeRef ()
 Overrides this method to update PStats appropriately.
bool nodeUnref ()
 Overrides this method to update PStats appropriately.
bool operator< (RenderState const 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.
 output (ostream out)
PyObject reduce (PyObject self)
 This special Python method is implement to provide support for the pickle module.
PyObject reducePersist (PyObject self, PyObject pickler)
 This special Python method is implement to provide support for the pickle module.
 ref ()
 Explicitly increments the reference count.
RenderState const removeAttrib (int slot)
 Returns a new RenderState object that represents the same as the source state, with the indicated RenderAttrib removed.
RenderState const removeAttrib (TypeHandle type)
 Returns a new RenderState object that represents the same as the source state, with the indicated RenderAttrib removed.
RenderState const setAttrib (RenderAttrib const attrib, int override)
 Returns a new RenderState object that represents the same as the source state, with the new RenderAttrib added.
RenderState const setAttrib (RenderAttrib const attrib)
 Returns a new RenderState object that represents the same as the source state, with the new RenderAttrib added.
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus.
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
bool unref ()
 Explicitly decrements the reference count.
 write (ostream out, int indent_level)

Static Public Member Functions

static int clearCache ()
 Empties the cache of composed RenderStates.
static clearMungerCache ()
 Completely empties the cache of state + gsg -> munger, for all states and all gsg's.
static TypedWritableReferenceCount decodeFromBamStream (string data, BamReader reader)
 Reads the string created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on that string.
static TypedWritableReferenceCount decodeFromBamStream (string data)
 Reads the string created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on that string.
static TypeHandle getClassType ()
static int getMaxPriority ()
 Returns the maximum priority number (sometimes called override) that may be set on any node.
static int getNumStates ()
 Returns the total number of unique RenderState objects allocated in the world.
static int getNumUnusedStates ()
 Returns the total number of RenderState objects that have been allocated but have no references outside of the internal RenderState cache.
static PyObject getStates ()
 Returns a list of all of the RenderState objects in the state cache.
static listCycles (ostream out)
 Detects all of the reference-count cycles in the cache and reports them to standard output.
static listStates (ostream out)
 Lists all of the RenderStates in the cache to the output stream, one per line.
static RenderState const make (RenderAttrib const attrib1, RenderAttrib const attrib2, RenderAttrib const attrib3, RenderAttrib const attrib4, int override)
 Returns a RenderState with four attributes set.
static RenderState const make (RenderAttrib const attrib1, RenderAttrib const attrib2, RenderAttrib const attrib3, RenderAttrib const attrib4)
 Returns a RenderState with four attributes set.
static RenderState const make (RenderAttrib const attrib)
 Returns a RenderState with one attribute set.
static RenderState const make (RenderAttrib const attrib1, RenderAttrib const attrib2, RenderAttrib const attrib3, int override)
 Returns a RenderState with three attributes set.
static RenderState const make (RenderAttrib const attrib, int override)
 Returns a RenderState with one attribute set.
static RenderState const make (RenderAttrib const attrib1, RenderAttrib const attrib2, int override)
 Returns a RenderState with two attributes set.
static RenderState const make (RenderAttrib const attrib1, RenderAttrib const attrib2, RenderAttrib const attrib3)
 Returns a RenderState with three attributes set.
static RenderState const make (RenderAttrib const attrib1, RenderAttrib const attrib2)
 Returns a RenderState with two attributes set.
static RenderState const makeEmpty ()
 Returns a RenderState with no attributes set.
static RenderState const makeFullDefault ()
 Returns a RenderState with all possible attributes set to their default value.
static bool validateStates ()
 Ensures that the cache is still stored in sorted order, and that none of the cache elements have been inadvertently deleted.

Detailed Description

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.


Member Enumeration Documentation

enum Referenced [inherited]
Enumerator:
RNode 
RCache 

Member Function Documentation

RenderState const addAttrib ( RenderAttrib const  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).

RenderState const addAttrib ( RenderAttrib const  attrib)

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).

RenderState const adjustAllPriorities ( 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.

cacheRef ( )

Overrides this method to update PStats appropriately.

Reimplemented from CachedTypedWritableReferenceCount.

bool cacheUnref ( )

Overrides this method to update PStats appropriately.

Reimplemented from CachedTypedWritableReferenceCount.

static int clearCache ( ) [static]

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.

static clearMungerCache ( ) [static]

Completely empties the cache of state + gsg -> munger, for all states and all gsg's.

Normally there is no need to empty this cache.

int compareSort ( RenderState const  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 operator <.

RenderState const compose ( RenderState const  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.

bool cullCallback ( CullTraverser  trav,
CullTraverserData const  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.

static TypedWritableReferenceCount decodeFromBamStream ( string  data,
BamReader  reader 
) [static, inherited]

Reads the string created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on that string.

Returns NULL on error.

This method is intended to replace decode_raw_from_bam_stream() when you know the stream in question returns an object of type TypedWritableReferenceCount, allowing for easier reference count management. Note that the caller is still responsible for maintaining the reference count on the return value.

static TypedWritableReferenceCount decodeFromBamStream ( string  data) [static, inherited]

Reads the string created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on that string.

Returns NULL on error.

This method is intended to replace decode_raw_from_bam_stream() when you know the stream in question returns an object of type TypedWritableReferenceCount, allowing for easier reference count management. Note that the caller is still responsible for maintaining the reference count on the return value.

string encodeToBamStream ( ) [inherited]

Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string.

Returns empty string on failure.

This is a convenience method particularly useful for cases when you are only serializing a single object. If you have many objects to process, it is more efficient to use the same BamWriter to serialize all of them together.

bool encodeToBamStream ( basic_stringchar  data,
BamWriter  writer 
) [inherited]

Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string.

Returns true on success, false on failure.

This is a convenience method particularly useful for cases when you are only serializing a single object. If you have many objects to process, it is more efficient to use the same BamWriter to serialize all of them together.

bool encodeToBamStream ( basic_stringchar  data) [inherited]

Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string.

Returns true on success, false on failure.

This is a convenience method particularly useful for cases when you are only serializing a single object. If you have many objects to process, it is more efficient to use the same BamWriter to serialize all of them together.

RenderAttrib const getAttrib ( TypeHandle  type)

Looks for a RenderAttrib of the indicated type in the state, and returns it if it is found, or NULL if it is not.

RenderAttrib const getAttrib ( int  slot)

Returns the RenderAttrib with the indicated slot index, or NULL if there is no such RenderAttrib in the state.

RenderAttrib const getAttribDef ( 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.

UpdateSeq getBamModified ( ) [inherited]

Returns the current bam_modified counter.

This counter is normally incremented automatically whenever the object is modified.

int getBinIndex ( )

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.

int getCacheRefCount ( ) [inherited]

Returns the current reference count.

static TypeHandle getClassType ( ) [static]

Reimplemented from NodeCachedReferenceCount.

PyObject getCompositionCache ( )

Returns a list of 2-tuples that represents the composition cache.

For each tuple in the list, the first element is the source render, and the second is the result render. If both are None, there is no entry in the cache at that slot.

In general, a->compose(source) == result.

This has no practical value other than for examining the cache for performance analysis.

int getCompositionCacheNumEntries ( )

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.

RenderState const getCompositionCacheResult ( 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.

int getCompositionCacheSize ( )

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.

RenderState const getCompositionCacheSource ( 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.

int getDrawOrder ( )

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().

int getGeomRendering ( 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.

unsigned int getHash ( )

Returns a suitable hash value for phash_map.

PyObject getInvertCompositionCache ( )

Returns a list of 2-tuples that represents the invert_composition cache.

For each tuple in the list, the first element is the source render, and the second is the result render. If both are None, there is no entry in the cache at that slot.

In general, a->invert_compose(source) == result.

This has no practical value other than for examining the cache for performance analysis.

int getInvertCompositionCacheNumEntries ( )

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().

RenderState const getInvertCompositionCacheResult ( 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.

int getInvertCompositionCacheSize ( )

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.

RenderState const getInvertCompositionCacheSource ( 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.

static int getMaxPriority ( ) [static]

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.

int getNodeRefCount ( ) [inherited]

Returns the current reference count.

static int getNumStates ( ) [static]

Returns the total number of unique RenderState objects allocated in the world.

This will go up and down during normal operations.

static int getNumUnusedStates ( ) [static]

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.

int getOverride ( int  slot)

Looks for a RenderAttrib of the indicated type in the state, and returns its override value if it is found, or 0 if it is not.

int getOverride ( TypeHandle  type)

Looks for a RenderAttrib of the indicated type in the state, and returns its override value if it is found, or 0 if it is not.

int getRefCount ( ) [inherited]

Returns the current reference count.

int getReferencedBits ( ) [inherited]

Returns the union of the values defined in the Referenced enum that represents the various things that appear to be holding a pointer to this object.

If R_node is included, at least one node is holding a pointer; if R_cache is included, at least one cache element is.

static PyObject getStates ( ) [static]

Returns a list of all of the RenderState objects in the state cache.

The order of elements in this cache is arbitrary.

TypeHandle getType ( ) [inherited]

Reimplemented in AnimChannelBase.

int getTypeIndex ( ) [inherited]

Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

This is equivalent to get_type().get_index().

RenderState const getUnique ( )

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.

bool hasAttrib ( TypeHandle  type)

Returns true if an attrib of the indicated type is present, false otherwise.

bool hasAttrib ( int  slot)

Returns true if an attrib of the indicated type is present, false otherwise.

bool hasCullCallback ( )

Returns true if any of the RenderAttribs in this state request a cull_callback(), false if none of them do.

RenderState const invertCompose ( RenderState const  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.

bool isEmpty ( )

Returns true if the state is empty, false otherwise.

bool isExactType ( TypeHandle  handle) [inherited]

Returns true if the current object is the indicated type exactly.

bool isOfType ( TypeHandle  handle) [inherited]

Returns true if the current object is or derives from the indicated type.

static listCycles ( ostream  out) [static]

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.

static listStates ( ostream  out) [static]

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.

static RenderState const make ( RenderAttrib const  attrib1,
RenderAttrib const  attrib2,
RenderAttrib const  attrib3 
) [static]

Returns a RenderState with three attributes set.

static RenderState const make ( RenderAttrib const  attrib1,
RenderAttrib const  attrib2,
RenderAttrib const  attrib3,
RenderAttrib const  attrib4,
int  override 
) [static]

Returns a RenderState with four attributes set.

static RenderState const make ( RenderAttrib const  attrib) [static]

Returns a RenderState with one attribute set.

static RenderState const make ( RenderAttrib const  attrib1,
RenderAttrib const  attrib2,
int  override 
) [static]

Returns a RenderState with two attributes set.

static RenderState const make ( RenderAttrib const  attrib1,
RenderAttrib const  attrib2,
RenderAttrib const  attrib3,
int  override 
) [static]

Returns a RenderState with three attributes set.

static RenderState const make ( RenderAttrib const  attrib1,
RenderAttrib const  attrib2,
RenderAttrib const  attrib3,
RenderAttrib const  attrib4 
) [static]

Returns a RenderState with four attributes set.

static RenderState const make ( RenderAttrib const  attrib1,
RenderAttrib const  attrib2 
) [static]

Returns a RenderState with two attributes set.

static RenderState const make ( RenderAttrib const  attrib,
int  override 
) [static]

Returns a RenderState with one attribute set.

static RenderState const makeEmpty ( ) [static]

Returns a RenderState with no attributes set.

static RenderState const makeFullDefault ( ) [static]

Returns a RenderState with all possible attributes set to their default value.

markBamModified ( ) [inherited]

Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams.

This should normally not need to be called by user code; it should be called internally when the object has been changed in a way that legitimately requires its retransmission to any connected clients.

nodeRef ( )

Overrides this method to update PStats appropriately.

Reimplemented from NodeCachedReferenceCount.

bool nodeUnref ( )

Overrides this method to update PStats appropriately.

Reimplemented from NodeCachedReferenceCount.

bool operator< ( RenderState const  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.

output ( ostream  out)
PyObject reduce ( PyObject  self) [inherited]

This special Python method is implement to provide support for the pickle module.

This hooks into the native pickle and cPickle modules, but it cannot properly handle self-referential BAM objects.

PyObject reducePersist ( PyObject  self,
PyObject  pickler 
) [inherited]

This special Python method is implement to provide support for the pickle module.

This is similar to __reduce__, but it provides additional support for the missing persistent-state object needed to properly support self-referential BAM objects written to the pickle stream. This hooks into the pickle and cPickle modules implemented in direct/src/stdpy.

ref ( ) [inherited]

Explicitly increments the reference count.

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

RenderState const removeAttrib ( int  slot)

Returns a new RenderState object that represents the same as the source state, with the indicated RenderAttrib removed.

RenderState const removeAttrib ( TypeHandle  type)

Returns a new RenderState object that represents the same as the source state, with the indicated RenderAttrib removed.

RenderState const setAttrib ( RenderAttrib const  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 also replaced unconditionally.

RenderState const setAttrib ( RenderAttrib const  attrib)

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.

bool testRefCountIntegrity ( ) [inherited]

Does some easy checks to make sure that the reference count isn't completely bogus.

Reimplemented from CachedTypedWritableReferenceCount.

bool testRefCountNonzero ( ) [inherited]

Does some easy checks to make sure that the reference count isn't zero, or completely bogus.

Returns true if ok, false otherwise.

bool unref ( ) [inherited]

Explicitly decrements the reference count.

Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete().

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is true if the new reference count is nonzero, false if it is zero.

Reimplemented in GeomVertexArrayFormat, and GeomVertexFormat.

static bool validateStates ( ) [static]

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).

write ( ostream  out,
int  indent_level 
)
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties