#include <renderState.h>
Inheritance diagram for RenderState:
Public Member Functions | |
virtual | ~RenderState () |
The destructor is responsible for removing the RenderState from the global set if it is there. | |
bool | operator< (const RenderState &other) const |
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. | |
bool | is_empty () const |
Returns true if the state is empty, false otherwise. | |
int | get_num_attribs () const |
Returns the number of separate attributes indicated in the state. | |
const RenderAttrib * | get_attrib (int n) const |
Returns the nth attribute in the state. | |
int | get_override (int n) const |
Returns the override associated with the nth attribute in the state. | |
int | find_attrib (TypeHandle type) const |
Searches for an attribute with the indicated type in the state, and returns its index if it is found, or -1 if it is not. | |
ConstPointerTo< RenderState > | compose (const RenderState *other) const |
Returns a new RenderState object that represents the composition of this state with the other state. | |
ConstPointerTo< RenderState > | invert_compose (const RenderState *other) const |
Returns a new RenderState object that represents the composition of this state's inverse with the other state. | |
ConstPointerTo< RenderState > | add_attrib (const RenderAttrib *attrib, int override=0) const |
Returns a new RenderState object that represents the same as the source state, with the new RenderAttrib added. | |
ConstPointerTo< RenderState > | remove_attrib (TypeHandle type) const |
Returns a new RenderState object that represents the same as the source state, with the indicated RenderAttrib removed. | |
ConstPointerTo< RenderState > | adjust_all_priorities (int adjustment) const |
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. | |
const RenderAttrib * | get_attrib (TypeHandle type) const |
Looks for a RenderAttrib of the indicated type in the state, and returns it if it is found, or NULL if it is not. | |
void | output (ostream &out) const |
void | write (ostream &out, int indent_level) const |
int | get_bin_index () const |
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 | get_draw_order () const |
Returns the draw order indicated by the CullBinAttrib, if any, associated by this state (or 0 if there is no CullBinAttrib). | |
const FogAttrib * | get_fog () const |
This function is provided as an optimization, to speed up the render-time checking for the existance of a FogAttrib on this state. | |
const CullBinAttrib * | get_bin () const |
This function is provided as an optimization, to speed up the render-time checking for the existance of a BinAttrib on this state. | |
const TransparencyAttrib * | get_transparency () const |
This function is provided as an optimization, to speed up the render-time checking for the existance of a TransparencyAttrib on this state. | |
ConstPointerTo< RenderState > | issue_delta_modify (const RenderState *other, GraphicsStateGuardianBase *gsg) const |
This is intended to be called only from GraphicsStateGuardian::modify_state(). | |
ConstPointerTo< RenderState > | issue_delta_set (const RenderState *other, GraphicsStateGuardianBase *gsg) const |
This is intended to be called only from GraphicsStateGuardian::set_state(). | |
virtual void | write_datagram (BamWriter *manager, Datagram &dg) |
Writes the contents of this object to the datagram for shipping out to a Bam file. | |
virtual int | complete_pointers (TypedWritable **plist, BamReader *manager) |
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). | |
virtual void | finalize () |
Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed. | |
virtual TypeHandle | get_type () const |
virtual TypeHandle | force_init_type () |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. | |
int | get_ref_count () const |
Returns the current reference count. | |
int | ref () const |
Explicitly increments the reference count. | |
int | unref () const |
Explicitly decrements the reference count. | |
void | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
Static Public Member Functions | |
ConstPointerTo< RenderState > | make_empty () |
Returns a RenderState with no attributes set. | |
ConstPointerTo< RenderState > | make (const RenderAttrib *attrib, int override=0) |
Returns a RenderState with one attribute set. | |
ConstPointerTo< RenderState > | make (const RenderAttrib *attrib1, const RenderAttrib *attrib2, int override=0) |
Returns a RenderState with two attributes set. | |
ConstPointerTo< RenderState > | make (const RenderAttrib *attrib1, const RenderAttrib *attrib2, const RenderAttrib *attrib3, int override=0) |
Returns a RenderState with three attributes set. | |
ConstPointerTo< RenderState > | make (const RenderAttrib *attrib1, const RenderAttrib *attrib2, const RenderAttrib *attrib3, const RenderAttrib *attrib4, int override=0) |
Returns a RenderState with four attributes set. | |
ConstPointerTo< RenderState > | make (const RenderAttrib *const *attrib, int num_attribs, int override=0) |
Returns a RenderState with n attributes set. | |
int | get_max_priority () |
Returns the maximum priority number (sometimes called override) that may be set on any node. | |
int | get_num_states () |
Returns the total number of unique RenderState objects allocated in the world. | |
int | get_num_unused_states () |
Returns the total number of RenderState objects that have been allocated but have no references outside of the internal RenderState map. | |
int | clear_cache () |
Empties the cache of composed RenderStates. | |
void | bin_removed (int bin_index) |
Intended to be called by CullBinManager::remove_bin(), this informs all the RenderStates in the world to remove the indicated bin_index from their cache if it has been cached. | |
void | register_with_read_factory () |
Tells the BamReader how to create objects of type RenderState. | |
TypedWritable * | change_this (TypedWritable *old_ptr, BamReader *manager) |
Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointer if desired. | |
TypeHandle | get_class_type () |
void | init_type () |
Static Public Attributes | |
TypedWritable *const | Null = (TypedWritable*)0L |
Protected Member Functions | |
RenderState () | |
Actually, this could be a private constructor, since no one inherits from RenderState, but gcc gives us a spurious warning if all constructors are private. | |
void | fillin (DatagramIterator &scan, BamReader *manager) |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new RenderState. | |
Static Protected Member Functions | |
TypedWritable * | make_from_bam (const FactoryParams ¶ms) |
This function is called by the BamReader's factory when a new object of type RenderState is encountered in the Bam file. | |
Private Types | |
typedef pset< const RenderState *, IndirectLess< RenderState > > | States |
typedef pmap< const RenderState *, Composition > | CompositionCache |
typedef ov_set< Attribute > | Attributes |
enum | Flags { F_checked_bin_index = 0x0001, F_checked_fog = 0x0002, F_checked_bin = 0x0004, F_checked_transparency = 0x0008, F_is_destructing = 0x8000 } |
Private Member Functions | |
RenderState (const RenderState ©) | |
RenderStates are not meant to be copied. | |
void | operator= (const RenderState ©) |
RenderStates are not meant to be copied. | |
ConstPointerTo< RenderState > | do_compose (const RenderState *other) const |
The private implemention of compose(); this actually composes two RenderStates, without bothering with the cache. | |
ConstPointerTo< RenderState > | do_invert_compose (const RenderState *other) const |
The private implemention of invert_compose(). | |
void | determine_bin_index () |
This is the private implementation of get_bin_index() and get_draw_order(). | |
void | determine_fog () |
This is the private implementation of get_fog(). | |
void | determine_bin () |
This is the private implementation of get_bin(). | |
void | determine_transparency () |
This is the private implementation of get_transparency(). | |
void | set_destructing () |
This function should only be called from the destructor; it indicates that this RenderState object is beginning destruction. | |
bool | is_destructing () const |
Returns true if the RenderState object is currently within its destructor (i.e. | |
Static Private Member Functions | |
ConstPointerTo< RenderState > | return_new (RenderState *state) |
This function is used to share a common RenderState pointer for all equivalent RenderState objects. | |
Private Attributes | |
States::iterator | _saved_entry |
CompositionCache | _composition_cache |
CompositionCache | _invert_composition_cache |
const RenderState * | _self_compose |
Attributes | _attributes |
int | _bin_index |
int | _draw_order |
const FogAttrib * | _fog |
const CullBinAttrib * | _bin |
const TransparencyAttrib * | _transparency |
unsigned short | _flags |
Static Private Attributes | |
States * | _states = NULL |
ConstPointerTo< RenderState > | _empty_state |
TypeHandle | _type_handle |
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.
Definition at line 62 of file renderState.h.
|
Definition at line 194 of file renderState.h. |
|
Definition at line 165 of file renderState.h. |
|
Definition at line 143 of file renderState.h. |
|
Definition at line 208 of file renderState.h. |
|
Actually, this could be a private constructor, since no one inherits from RenderState, but gcc gives us a spurious warning if all constructors are private.
Definition at line 53 of file renderState.cxx. |
|
RenderStates are not meant to be copied.
Definition at line 76 of file renderState.cxx. |
|
The destructor is responsible for removing the RenderState from the global set if it is there.
Definition at line 104 of file renderState.cxx. References _composition_cache, and nassertv. |
|
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. Definition at line 548 of file renderState.cxx. Referenced by CullResult::get_binary_state(). |
|
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. Definition at line 629 of file renderState.cxx. |
|
Intended to be called by CullBinManager::remove_bin(), this informs all the RenderStates in the world to remove the indicated bin_index from their cache if it has been cached.
Definition at line 1107 of file renderState.cxx. |
|
Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointer if desired. Most objects don't change pointers after completion, but some need to. Once this function has been called, the old pointer will no longer be accessed. Definition at line 1498 of file renderState.cxx. |
|
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. Normally, RenderState objects will remove themselves from the interal map when their reference counts go to 0, but since circular references are possible there may be some cycles that cannot remove themselves. Calling this function from time to time will ensure there is no wasteful memory leakage, but calling it too often may result in decreased performance as the cache is forced to be recomputed. The return value is the number of RenderStates freed by this operation. Definition at line 892 of file renderState.cxx. |
|
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). Returns the number of pointers processed. Reimplemented from TypedWritable. Definition at line 1455 of file renderState.cxx. |
|
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. Definition at line 402 of file renderState.cxx. Referenced by CullResult::add_object(), StaticTextFont::find_character_gsets(), StaticTextFont::get_glyph(), NodePath::get_transparency(), NodePath::has_transparency(), and NodePath::set_transparency(). |
|
This is the private implementation of get_bin().
Definition at line 1370 of file renderState.cxx. |
|
This is the private implementation of get_bin_index() and get_draw_order().
Definition at line 1302 of file renderState.cxx. References ReferenceCount::get_ref_count(), nassertv, and ReferenceCount::unref(). |
|
This is the private implementation of get_fog().
Definition at line 1352 of file renderState.cxx. References _attributes. |
|
This is the private implementation of get_transparency().
Definition at line 1388 of file renderState.cxx. |
|
The private implemention of compose(); this actually composes two RenderStates, without bothering with the cache.
Definition at line 1173 of file renderState.cxx. References _bin, _flags, DCAST, F_checked_bin, get_attrib(), CullBinAttrib::get_class_type(), and NULL. |
|
The private implemention of invert_compose().
Definition at line 1244 of file renderState.cxx. References RenderState::Attribute::_attrib, _attributes, RenderState::Attribute::_type, TypedWritable::complete_pointers(), DCAST, nassertr, NULL, and ov_set< Attribute >::sort(). |
|
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new RenderState.
Reimplemented from TypedWritable. Definition at line 1583 of file renderState.cxx. |
|
Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.
Reimplemented from TypedWritable. Definition at line 1531 of file renderState.cxx. |
|
Searches for an attribute with the indicated type in the state, and returns its index if it is found, or -1 if it is not.
Definition at line 252 of file renderState.cxx. |
|
Reimplemented from TypedWritableReferenceCount. Definition at line 240 of file renderState.h. |
|
Looks for a RenderAttrib of the indicated type in the state, and returns it if it is found, or NULL if it is not.
Definition at line 656 of file renderState.cxx. |
|
Returns the nth attribute in the state.
Definition at line 218 of file renderState.I. References _draw_order. Referenced by do_compose(). |
|
This function is provided as an optimization, to speed up the render-time checking for the existance of a BinAttrib on this state. It returns a pointer to the BinAttrib, if there is one, or NULL if there is not. Definition at line 330 of file renderState.I. Referenced by CullResult::add_object(). |
|
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. Definition at line 256 of file renderState.I. References _bin. |
|
Reimplemented from TypedWritableReferenceCount. Definition at line 229 of file renderState.h. |
|
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(). Definition at line 278 of file renderState.I. References _flags, F_is_destructing, and INLINE. |
|
This function is provided as an optimization, to speed up the render-time checking for the existance of a FogAttrib on this state. It returns a pointer to the FogAttrib, if there is one, or NULL if there is not. Definition at line 304 of file renderState.I. References _flags, and F_is_destructing. |
|
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. Definition at line 728 of file renderState.cxx. Referenced by CullResult::bin_removed(), and CullResult::make_new_bin(). |
|
Returns the number of separate attributes indicated in the state.
Definition at line 205 of file renderState.I. References _flags, F_checked_bin_index, and INLINE. |
|
Returns the total number of unique RenderState objects allocated in the world. This will go up and down during normal operations. Definition at line 745 of file renderState.cxx. |
|
Returns the total number of RenderState objects that have been allocated but have no references outside of the internal RenderState map.
Definition at line 765 of file renderState.cxx. |
|
Returns the override associated with the nth attribute in the state.
Definition at line 234 of file renderState.I. |
|
Returns the current reference count.
Definition at line 183 of file referenceCount.I. Referenced by determine_bin_index(), RenderEffects::determine_show_bounds(), FontPool::ns_garbage_collect(), TexturePool::ns_garbage_collect(), MaterialPool::ns_get_material(), and TexturePool::ns_release_texture(). |
|
This function is provided as an optimization, to speed up the render-time checking for the existance of a TransparencyAttrib on this state. It returns a pointer to the TransparencyAttrib, if there is one, or NULL if there is not. Definition at line 356 of file renderState.I. |
|
Reimplemented from TypedWritableReferenceCount. Definition at line 237 of file renderState.h. Referenced by RenderState::Composition::Composition(). |
|
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(). Definition at line 71 of file typedObject.I. References TypeHandle::get_name(), TypedObject::get_type(), and INLINE. |
|
Reimplemented from TypedWritableReferenceCount. Definition at line 232 of file renderState.h. |
|
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. Definition at line 487 of file renderState.cxx. References _attributes. |
|
Returns true if the RenderState object is currently within its destructor (i.e. set_destructing() has been called). This is only used as a sanity check, and is only meaningful when NDEBUG is not defined. Definition at line 405 of file renderState.I. |
|
Returns true if the state is empty, false otherwise.
Definition at line 190 of file renderState.I. References _bin_index, _flags, F_checked_bin_index, and INLINE. |
|
Returns true if the current object is the indicated type exactly.
Definition at line 101 of file typedObject.I. Referenced by PT(), and CollisionNode::xform(). |
|
|
This is intended to be called only from GraphicsStateGuardian::modify_state(). It calls issue() for each attribute given in the other state that differs from the current state (which is assumed to represent the GSG's current state). Returns the RenderState representing the newly composed result. Definition at line 954 of file renderState.cxx. References _saved_entry, _states, CPT, nassertr, and NULL. |
|
This is intended to be called only from GraphicsStateGuardian::set_state(). It calls issue() for each attribute given in the other state that differs from the current state (which is assumed to represent the GSG's current state). Returns the RenderState representing the newly composed result (which will be the same as other). Definition at line 1045 of file renderState.cxx. |
|
Returns a RenderState with n attributes set.
Definition at line 368 of file renderState.cxx. |
|
Returns a RenderState with four attributes set.
Definition at line 345 of file renderState.cxx. |
|
Returns a RenderState with three attributes set.
Definition at line 324 of file renderState.cxx. |
|
Returns a RenderState with two attributes set.
Definition at line 305 of file renderState.cxx. |
|
Returns a RenderState with one attribute set.
Definition at line 289 of file renderState.cxx. Referenced by GraphicsStateGuardian::begin_bind_clip_planes(), GraphicsStateGuardian::begin_scene(), CullResult::bin_removed(), CollisionSolid::fillin(), CullTraverser::get_bounds_outer_viz_state(), CollisionSolid::get_solid_viz_state(), CullTraverser::make_bounds_viz(), and CullResult::make_new_bin(). |
|
Returns a RenderState with no attributes set.
Definition at line 269 of file renderState.cxx. Referenced by CollisionNode::combine_with(), NodePath::do_billboard_point_eye(), PandaNode::set_attrib(), TextGlyph::TextGlyph(), and GraphicsStateGuardian::~GraphicsStateGuardian(). |
|
This function is called by the BamReader's factory when a new object of type RenderState is encountered in the Bam file. It should create the RenderState and extract its information from the file. Definition at line 1558 of file renderState.cxx. |
|
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. Definition at line 230 of file renderState.cxx. References _empty_state, NULL, and return_new(). |
|
RenderStates are not meant to be copied.
Definition at line 89 of file renderState.cxx. References _saved_entry, and _states. |
|
Definition at line 674 of file renderState.cxx. Referenced by init_type(). |
|
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. The return value is the new reference count. Definition at line 225 of file referenceCount.I. Referenced by ClientDevice::ClientDevice(), EggGroupNode::find_textures(), EggGroupNode::r_apply_texmats(), EggGroupNode::r_flatten_transforms(), and EggGroupNode::reverse_vertex_ordering(). |
|
Tells the BamReader how to create objects of type RenderState.
Definition at line 1409 of file renderState.cxx. |
|
Returns a new RenderState object that represents the same as the source state, with the indicated RenderAttrib removed.
Definition at line 594 of file renderState.cxx. References RenderState::Attribute::_attrib, _attributes, and indent(). |
|
This function is used to share a common RenderState pointer for all equivalent RenderState objects. See the similar logic in RenderAttrib. The idea is to create a new RenderState object and pass it through this function, which will share the pointer with a previously-created RenderState object if it is equivalent. Definition at line 1135 of file renderState.cxx. References TransparencyAttrib::M_alpha_sorted, and TransparencyAttrib::M_dual. Referenced by operator<(). |
|
This function should only be called from the destructor; it indicates that this RenderState object is beginning destruction. It is only used as a sanity check, and is only meaningful when NDEBUG is not defined. Definition at line 382 of file renderState.I. |
|
Does some easy checks to make sure that the reference count isn't completely bogus.
Definition at line 328 of file referenceCount.I. References INLINE. Referenced by EggNode::determine_bin(), and ReferenceCount::~ReferenceCount(). |
|
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; plus, we don't have a virtual destructor anyway.) 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 the new reference count. Definition at line 293 of file referenceCount.I. References INLINE. Referenced by determine_bin_index(), and RenderEffects::determine_show_bounds(). |
|
Definition at line 700 of file renderState.cxx. Referenced by GraphicsStateGuardian::reset_if_new(). |
|
Writes the contents of this object to the datagram for shipping out to a Bam file.
Implements TypedWritableReferenceCount. Definition at line 1424 of file renderState.cxx. |
|
Definition at line 195 of file renderState.h. Referenced by determine_fog(), do_invert_compose(), invert_compose(), and remove_attrib(). |
|
Definition at line 205 of file renderState.h. Referenced by do_compose(), and get_bin_index(). |
|
Definition at line 199 of file renderState.h. Referenced by is_empty(). |
|
Definition at line 166 of file renderState.h. Referenced by ~RenderState(). |
|
Definition at line 200 of file renderState.h. Referenced by get_attrib(). |
|
Definition at line 36 of file renderState.cxx. Referenced by operator<(). |
|
Definition at line 215 of file renderState.h. Referenced by do_compose(), get_draw_order(), get_fog(), get_num_attribs(), and is_empty(). |
|
Definition at line 204 of file renderState.h. |
|
Definition at line 167 of file renderState.h. |
|
Definition at line 150 of file renderState.h. Referenced by issue_delta_modify(), and operator=(). |
|
Definition at line 175 of file renderState.h. |
|
Definition at line 35 of file renderState.cxx. Referenced by adjust_all_priorities(), get_attrib(), get_num_states(), get_num_unused_states(), issue_delta_modify(), and operator=(). |
|
Definition at line 206 of file renderState.h. |
|
Reimplemented from TypedWritableReferenceCount. Definition at line 37 of file renderState.cxx. |
|
Definition at line 25 of file typedWritable.cxx. Referenced by Child::complete_pointers(), Parent::complete_pointers(), Person::complete_pointers(), LoaderFileTypeBam::get_extension(), PartGroup::pick_channel_index(), BamReader::read_pointer(), and AnimGroup::write_datagram(). |