Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

RenderEffects Class Reference

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

#include <renderEffects.h>

Inheritance diagram for RenderEffects:

TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject List of all members.

Public Member Functions

virtual ~RenderEffects ()
 The destructor is responsible for removing the RenderEffects from the global set if it is there.

bool operator< (const RenderEffects &other) const
 Provides an arbitrary ordering among all unique RenderEffectss, so we can store the essentially different ones in a big set and throw away the rest.

bool safe_to_transform () const
 Returns true if all of the effects in this set can safely be transformed, and therefore the complete set can be transformed, by calling xform().

bool safe_to_combine () const
 Returns true if all of the effects in this set can safely be shared with a sibling node that has the exact same set of effects, or false if this would be bad for any of the effects.

ConstPointerTo< RenderEffects > xform (const LMatrix4f &mat) const
 Returns a new RenderEffects transformed by the indicated matrix.

bool is_empty () const
 Returns true if the state is empty, false otherwise.

int get_num_effects () const
 Returns the number of separate effects indicated in the state.

const RenderEffectget_effect (int n) const
 Returns the nth effect in the state.

int find_effect (TypeHandle type) const
 Searches for an effect with the indicated type in the state, and returns its index if it is found, or -1 if it is not.

ConstPointerTo< RenderEffects > add_effect (const RenderEffect *effect) const
 Returns a new RenderEffects object that represents the same as the source state, with the new RenderEffect added.

ConstPointerTo< RenderEffects > remove_effect (TypeHandle type) const
 Returns a new RenderEffects object that represents the same as the source state, with the indicated RenderEffect removed.

const RenderEffectget_effect (TypeHandle type) const
 Looks for a RenderEffect 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
const BillboardEffectget_billboard () const
 This function is provided as an optimization, to speed up the render-time checking for the existance of a BillboardEffect on this state.

bool has_decal () const
 This function is provided as an optimization, to speed up the render-time checking for the existance of a DecalEffect on this state.

const CompassEffectget_compass () const
 This function is provided as an optimization, to speed up the render-time checking for the existance of a CompassEffect on this state.

bool has_show_bounds () const
 This function is provided as an optimization, to speed up the render-time checking for the existance of a ShowBoundsEffect on this 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< RenderEffects > make_empty ()
 Returns a RenderEffects with no effects set.

ConstPointerTo< RenderEffects > make (const RenderEffect *effect)
 Returns a RenderEffects with one effect set.

ConstPointerTo< RenderEffects > make (const RenderEffect *effect1, const RenderEffect *effect2)
 Returns a RenderEffects with two effects set.

ConstPointerTo< RenderEffects > make (const RenderEffect *effect1, const RenderEffect *effect2, const RenderEffect *effect3)
 Returns a RenderEffects with three effects set.

ConstPointerTo< RenderEffects > make (const RenderEffect *effect1, const RenderEffect *effect2, const RenderEffect *effect3, const RenderEffect *effect4)
 Returns a RenderEffects with four effects set.

void register_with_read_factory ()
 Tells the BamReader how to create objects of type RenderEffects.

TypedWritablechange_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

 RenderEffects ()
 Actually, this could be a private constructor, since no one inherits from RenderEffects, 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 RenderEffects.


Static Protected Member Functions

TypedWritablemake_from_bam (const FactoryParams &params)
 This function is called by the BamReader's factory when a new object of type RenderEffects is encountered in the Bam file.


Private Types

typedef pset< const RenderEffects *,
IndirectLess< RenderEffects > > 
States
typedef ov_set< EffectEffects
enum  Flags {
  F_checked_billboard = 0x0001, F_checked_decal = 0x0002, F_has_decal = 0x0004, F_checked_show_bounds = 0x0008,
  F_has_show_bounds = 0x0010, F_checked_compass = 0x0020
}

Private Member Functions

 RenderEffects (const RenderEffects &copy)
 RenderEffectss are not meant to be copied.

void operator= (const RenderEffects &copy)
 RenderEffectss are not meant to be copied.

void determine_billboard ()
 This is the private implementation of get_billboard().

void determine_decal ()
 This is the private implementation of has_decal().

void determine_compass ()
 This is the private implementation of has_compass().

void determine_show_bounds ()
 This is the private implementation of has_show_bounds().


Static Private Member Functions

ConstPointerTo< RenderEffects > return_new (RenderEffects *state)
 This function is used to share a common RenderEffects pointer for all equivalent RenderEffects objects.


Private Attributes

States::iterator _saved_entry
Effects _effects
const BillboardEffect_billboard
const CompassEffect_compass
short _flags

Static Private Attributes

States _states
ConstPointerTo< RenderEffects > _empty_state
TypeHandle _type_handle

Detailed Description

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

You should not attempt to create or modify a RenderEffects object directly. Instead, call one of the make() functions to create one for you. And instead of modifying a RenderEffects object, create a new one.

Definition at line 60 of file renderEffects.h.


Member Typedef Documentation

typedef ov_set<Effect> RenderEffects::Effects [private]
 

Definition at line 143 of file renderEffects.h.

typedef pset<const RenderEffects *, IndirectLess<RenderEffects> > RenderEffects::States [private]
 

Definition at line 118 of file renderEffects.h.


Member Enumeration Documentation

enum RenderEffects::Flags [private]
 

Enumeration values:
F_checked_billboard 
F_checked_decal 
F_has_decal 
F_checked_show_bounds 
F_has_show_bounds 
F_checked_compass 

Definition at line 151 of file renderEffects.h.


Constructor & Destructor Documentation

RenderEffects::RenderEffects  )  [protected]
 

Actually, this could be a private constructor, since no one inherits from RenderEffects, but gcc gives us a spurious warning if all constructors are private.

Definition at line 51 of file renderEffects.cxx.

References nassertv.

RenderEffects::RenderEffects const RenderEffects &  copy  )  [private]
 

RenderEffectss are not meant to be copied.

Definition at line 65 of file renderEffects.cxx.

RenderEffects::~RenderEffects  )  [virtual]
 

The destructor is responsible for removing the RenderEffects from the global set if it is there.

Definition at line 93 of file renderEffects.cxx.

References _effects.


Member Function Documentation

ConstPointerTo< RenderEffects > RenderEffects::add_effect const RenderEffect effect  )  const
 

Returns a new RenderEffects object that represents the same as the source state, with the new RenderEffect added.

If there is already a RenderEffect with the same type, it is replaced.

Definition at line 352 of file renderEffects.cxx.

References _effects.

TypedWritable * RenderEffects::change_this TypedWritable old_ptr,
BamReader manager
[static]
 

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 698 of file renderEffects.cxx.

Referenced by register_with_read_factory().

int RenderEffects::complete_pointers TypedWritable **  plist,
BamReader manager
[virtual]
 

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 655 of file renderEffects.cxx.

void RenderEffects::determine_billboard  )  [private]
 

This is the private implementation of get_billboard().

Definition at line 540 of file renderEffects.cxx.

void RenderEffects::determine_compass  )  [private]
 

This is the private implementation of has_compass().

Definition at line 575 of file renderEffects.cxx.

References BamReader::register_finalize().

void RenderEffects::determine_decal  )  [private]
 

This is the private implementation of has_decal().

Definition at line 558 of file renderEffects.cxx.

References CPT, DCAST, and return_new().

void RenderEffects::determine_show_bounds  )  [private]
 

This is the private implementation of has_show_bounds().

Definition at line 593 of file renderEffects.cxx.

References ReferenceCount::get_ref_count(), nassertv, and ReferenceCount::unref().

void RenderEffects::fillin DatagramIterator scan,
BamReader manager
[protected]
 

This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new RenderEffects.

Reimplemented from TypedWritable.

Definition at line 783 of file renderEffects.cxx.

Referenced by register_with_read_factory().

void RenderEffects::finalize void   )  [virtual]
 

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 731 of file renderEffects.cxx.

int RenderEffects::find_effect TypeHandle  type  )  const
 

Searches for an effect with the indicated type in the state, and returns its index if it is found, or -1 if it is not.

Definition at line 230 of file renderEffects.cxx.

virtual TypeHandle RenderEffects::force_init_type void   )  [inline, virtual]
 

Reimplemented from TypedWritableReferenceCount.

Definition at line 184 of file renderEffects.h.

const BillboardEffect * RenderEffects::get_billboard  )  const [inline]
 

This function is provided as an optimization, to speed up the render-time checking for the existance of a BillboardEffect on this state.

It returns a pointer to the BillboardEffect, if there is one, or NULL if there is not.

Definition at line 205 of file renderEffects.I.

References _flags, F_checked_show_bounds, F_has_show_bounds, and INLINE.

TypeHandle RenderEffects::get_class_type void   )  [inline, static]
 

Reimplemented from TypedWritableReferenceCount.

Definition at line 173 of file renderEffects.h.

const CompassEffect * RenderEffects::get_compass  )  const [inline]
 

This function is provided as an optimization, to speed up the render-time checking for the existance of a CompassEffect on this state.

It returns a pointer to the CompassEffect, if there is one, or NULL if there is not.

Definition at line 261 of file renderEffects.I.

const RenderEffect * RenderEffects::get_effect TypeHandle  type  )  const
 

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

Definition at line 429 of file renderEffects.cxx.

const RenderEffect * RenderEffects::get_effect int  n  )  const [inline]
 

Returns the nth effect in the state.

Definition at line 183 of file renderEffects.I.

References _compass, _flags, F_checked_compass, and INLINE.

int RenderEffects::get_num_effects  )  const [inline]
 

Returns the number of separate effects indicated in the state.

Definition at line 170 of file renderEffects.I.

References _flags, F_checked_decal, F_has_decal, and INLINE.

int ReferenceCount::get_ref_count  )  const [inline, inherited]
 

Returns the current reference count.

Definition at line 183 of file referenceCount.I.

Referenced by RenderState::determine_bin_index(), determine_show_bounds(), FontPool::ns_garbage_collect(), TexturePool::ns_garbage_collect(), MaterialPool::ns_get_material(), and TexturePool::ns_release_texture().

virtual TypeHandle RenderEffects::get_type void   )  const [inline, virtual]
 

Reimplemented from TypedWritableReferenceCount.

Definition at line 181 of file renderEffects.h.

int TypedObject::get_type_index  )  const [inline, 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().

Definition at line 71 of file typedObject.I.

References TypeHandle::get_name(), TypedObject::get_type(), and INLINE.

bool RenderEffects::has_decal  )  const [inline]
 

This function is provided as an optimization, to speed up the render-time checking for the existance of a DecalEffect on this state.

It returns true if a DecalEffect exists, false otherwise. Note that since there is no additional information stored on the DecalEffect, there's no point in returning it if it exists.

Definition at line 235 of file renderEffects.I.

bool RenderEffects::has_show_bounds  )  const [inline]
 

This function is provided as an optimization, to speed up the render-time checking for the existance of a ShowBoundsEffect on this state.

It returns true if a ShowBoundsEffect exists, false otherwise. Note that since there is no additional information stored on the ShowBoundsEffect, there's no point in returning it if it exists.

Definition at line 291 of file renderEffects.I.

Referenced by CullTraverser::traverse().

void RenderEffects::init_type void   )  [inline, static]
 

Reimplemented from TypedWritableReferenceCount.

Definition at line 176 of file renderEffects.h.

References INLINE, and output().

bool RenderEffects::is_empty  )  const [inline]
 

Returns true if the state is empty, false otherwise.

Definition at line 155 of file renderEffects.I.

Referenced by safe_to_transform().

bool TypedObject::is_exact_type TypeHandle  handle  )  const [inline, inherited]
 

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

bool TypedObject::is_of_type TypeHandle  handle  )  const [inline, inherited]
 

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

Definition at line 86 of file typedObject.I.

Referenced by EggMaterialCollection::collapse_equivalent_materials(), EggTextureCollection::collapse_equivalent_textures(), DeferredNodeProperty::compose(), AnimBundleMaker::create_s_channel(), CharacterMaker::create_slider(), ProjectionScreen::cull_callback(), DataNode::define_output(), EggNode::determine_draw_order(), CharacterMaker::egg_to_index(), EggGroupUniquifier::EggGroupUniquifier(), EggPoolUniquifier::EggPoolUniquifier(), EggGroupNode::find_textures(), StaticTextFont::get_glyph(), EggMaterialCollection::insert_materials(), EggTextureCollection::insert_textures(), CharacterJoint::make_copy(), PT(), EggGroupNode::r_flatten_transforms(), EggGroupNode::r_transform_vertices(), EggGroupNode::recompute_polygon_normals(), CollisionLevelState::reserve(), PandaFramework::reset_frame_rate(), PandaFramework::set_texture(), EggGroupNode::steal_children(), and DataGraphTraverser::traverse().

ConstPointerTo< RenderEffects > RenderEffects::make const RenderEffect effect1,
const RenderEffect effect2,
const RenderEffect effect3,
const RenderEffect effect4
[static]
 

Returns a RenderEffects with four effects set.

Definition at line 323 of file renderEffects.cxx.

References _effects, and return_new().

ConstPointerTo< RenderEffects > RenderEffects::make const RenderEffect effect1,
const RenderEffect effect2,
const RenderEffect effect3
[static]
 

Returns a RenderEffects with three effects set.

Definition at line 302 of file renderEffects.cxx.

ConstPointerTo< RenderEffects > RenderEffects::make const RenderEffect effect1,
const RenderEffect effect2
[static]
 

Returns a RenderEffects with two effects set.

Definition at line 283 of file renderEffects.cxx.

References _effects.

ConstPointerTo< RenderEffects > RenderEffects::make const RenderEffect effect  )  [static]
 

Returns a RenderEffects with one effect set.

Definition at line 267 of file renderEffects.cxx.

ConstPointerTo< RenderEffects > RenderEffects::make_empty  )  [static]
 

Returns a RenderEffects with no effects set.

Definition at line 247 of file renderEffects.cxx.

Referenced by PandaNode::has_attrib().

TypedWritable * RenderEffects::make_from_bam const FactoryParams params  )  [static, protected]
 

This function is called by the BamReader's factory when a new object of type RenderEffects is encountered in the Bam file.

It should create the RenderEffects and extract its information from the file.

Definition at line 758 of file renderEffects.cxx.

bool RenderEffects::operator< const RenderEffects &  other  )  const
 

Provides an arbitrary ordering among all unique RenderEffectss, 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 RenderEffects class because all equivalent RenderEffects objects are guaranteed to share the same pointer; thus, a pointer comparison is always sufficient.

Definition at line 124 of file renderEffects.cxx.

References RenderEffects::Effect::_effect, and _effects.

void RenderEffects::operator= const RenderEffects &  copy  )  [private]
 

RenderEffectss are not meant to be copied.

Definition at line 78 of file renderEffects.cxx.

References _saved_entry, and _states.

void RenderEffects::output ostream &  out  )  const
 

Definition at line 447 of file renderEffects.cxx.

References _flags, and F_checked_billboard.

Referenced by init_type().

int ReferenceCount::ref  )  const [inline, 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.

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

void RenderEffects::register_with_read_factory void   )  [static]
 

Tells the BamReader how to create objects of type RenderEffects.

Definition at line 612 of file renderEffects.cxx.

References change_this(), fillin(), parse_params(), and BamReader::register_change_this().

ConstPointerTo< RenderEffects > RenderEffects::remove_effect TypeHandle  type  )  const
 

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

Definition at line 398 of file renderEffects.cxx.

References _saved_entry, _states, CPT, nassertr, and NULL.

ConstPointerTo< RenderEffects > RenderEffects::return_new RenderEffects *  state  )  [static, private]
 

This function is used to share a common RenderEffects pointer for all equivalent RenderEffects objects.

See the similar logic in RenderEffect. The idea is to create a new RenderEffects object and pass it through this function, which will share the pointer with a previously-created RenderEffects object if it is equivalent.

Definition at line 505 of file renderEffects.cxx.

References RenderEffects::Effect::_effect, _effects, Datagram::add_uint16(), nassertv, PN_uint16, TypedWritable::write_datagram(), and BamWriter::write_pointer().

Referenced by determine_decal(), make(), safe_to_transform(), and xform().

bool RenderEffects::safe_to_combine  )  const
 

Returns true if all of the effects in this set can safely be shared with a sibling node that has the exact same set of effects, or false if this would be bad for any of the effects.

Definition at line 172 of file renderEffects.cxx.

References _effects.

bool RenderEffects::safe_to_transform  )  const
 

Returns true if all of the effects in this set can safely be transformed, and therefore the complete set can be transformed, by calling xform().

Definition at line 145 of file renderEffects.cxx.

References RenderEffects::Effect::_effect, _effects, is_empty(), and return_new().

void ReferenceCount::test_ref_count_integrity  )  const [inline, inherited]
 

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

int ReferenceCount::unref  )  const [inline, 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; 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 RenderState::determine_bin_index(), and determine_show_bounds().

void RenderEffects::write ostream &  out,
int  indent_level
const
 

Definition at line 473 of file renderEffects.cxx.

References _compass, DCAST, and NULL.

void RenderEffects::write_datagram BamWriter manager,
Datagram dg
[virtual]
 

Writes the contents of this object to the datagram for shipping out to a Bam file.

Implements TypedWritableReferenceCount.

Definition at line 627 of file renderEffects.cxx.

ConstPointerTo< RenderEffects > RenderEffects::xform const LMatrix4f &  mat  )  const
 

Returns a new RenderEffects transformed by the indicated matrix.

Definition at line 195 of file renderEffects.cxx.

References _empty_state, NULL, and return_new().


Member Data Documentation

const BillboardEffect* RenderEffects::_billboard [private]
 

Definition at line 148 of file renderEffects.h.

const CompassEffect* RenderEffects::_compass [private]
 

Definition at line 149 of file renderEffects.h.

Referenced by get_effect(), and write().

Effects RenderEffects::_effects [private]
 

Definition at line 144 of file renderEffects.h.

Referenced by add_effect(), make(), operator<(), return_new(), safe_to_combine(), safe_to_transform(), and ~RenderEffects().

ConstPointerTo< RenderEffects > RenderEffects::_empty_state [static, private]
 

Definition at line 35 of file renderEffects.cxx.

Referenced by xform().

short RenderEffects::_flags [private]
 

Definition at line 159 of file renderEffects.h.

Referenced by get_billboard(), get_effect(), get_num_effects(), and output().

States::iterator RenderEffects::_saved_entry [private]
 

Definition at line 125 of file renderEffects.h.

Referenced by operator=(), and remove_effect().

RenderEffects::States RenderEffects::_states [static, private]
 

Definition at line 34 of file renderEffects.cxx.

Referenced by operator=(), and remove_effect().

TypeHandle RenderEffects::_type_handle [static, private]
 

Reimplemented from TypedWritableReferenceCount.

Definition at line 36 of file renderEffects.cxx.

TypedWritable *const TypedWritable::Null = (TypedWritable*)0L [static, inherited]
 

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


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:54:42 2003 for Panda by doxygen1.3