Panda3D
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions

TransformState Class Reference

Indicates a coordinate-system transform on vertices. More...

#include "transformState.h"

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

List of all members.

Classes

class  Composition
class  CompositionCycleDescEntry
class  Empty

Public Member Functions

virtual ~TransformState ()
 The destructor is responsible for removing the TransformState from the global set if it is there.
void cache_ref () const
 Overrides this method to update PStats appropriately.
bool cache_unref () const
 Overrides this method to update PStats appropriately.
int compare_to (const TransformState &other, bool uniquify_matrix) const
 Provides an arbitrary ordering among all unique TransformStates, so we can store the essentially different ones in a big set and throw away the rest.
int compare_to (const TransformState &other) const
 Provides an arbitrary ordering among all unique TransformStates, so we can store the essentially different ones in a big set and throw away the rest.
bool components_given () const
 Returns true if the transform was specified componentwise, or false if it was specified with a general 4x4 matrix.
 CPT (TransformState) set_pos(const LVecBase3 &pos) const
 CPT (TransformState) set_hpr(const LVecBase3 &hpr) const
 CPT (TransformState) set_quat(const LQuaternion &quat) const
 CPT (TransformState) set_scale(const LVecBase3 &scale) const
 CPT (TransformState) set_shear(const LVecBase3 &shear) const
 CPT (TransformState) set_pos2d(const LVecBase2 &pos) const
 CPT (TransformState) set_rotate2d(PN_stdfloat rotate) const
 CPT (TransformState) set_scale2d(const LVecBase2 &scale) const
 CPT (TransformState) set_shear2d(PN_stdfloat shear) const
 CPT (TransformState) compose(const TransformState *other) const
 CPT (TransformState) invert_compose(const TransformState *other) const
 CPT (TransformState) get_inverse() const
 CPT (TransformState) get_unique() const
virtual TypeHandle force_init_type ()
int get_composition_cache_num_entries () const
 Returns the number of entries in the composition cache for this TransformState.
const TransformStateget_composition_cache_result (int n) const
 Returns the result TransformState of the nth element in the composition cache.
int get_composition_cache_size () const
 Returns the number of slots in the composition cache for this TransformState.
const TransformStateget_composition_cache_source (int n) const
 Returns the source TransformState of the nth element in the composition cache.
int get_geom_rendering (int geom_rendering) const
 Returns the union of the Geom::GeomRendering bits that will be required once this TransformState is applied to a geom which includes the indicated geom_rendering bits.
size_t get_hash () const
 Returns a suitable hash value for phash_map.
const LVecBase3get_hpr () const
 Returns the rotation component of the transform as a trio of Euler angles.
int get_invert_composition_cache_num_entries () const
 Returns the number of entries in the invert_composition cache for this TransformState.
const TransformStateget_invert_composition_cache_result (int n) const
 Returns the result TransformState of the nth element in the invert composition cache.
int get_invert_composition_cache_size () const
 Returns the number of slots in the composition cache for this TransformState.
const TransformStateget_invert_composition_cache_source (int n) const
 Returns the source TransformState of the nth element in the invert composition cache.
const LMatrix4get_mat () const
 Returns the matrix that describes the transform.
LMatrix3 get_mat3 () const
 Returns the 3x3 matrix that describes the 2-d transform.
const LQuaternionget_norm_quat () const
 Returns the rotation component of the transform as a quaternion.
const LPoint3get_pos () const
 Returns the pos component of the transform.
LVecBase2 get_pos2d () const
 Returns the pos component of the 2-d transform.
const LQuaternionget_quat () const
 Returns the rotation component of the transform as a quaternion.
PN_stdfloat get_rotate2d () const
 Returns the rotation component of the 2-d transform as an angle in degrees clockwise about the origin.
const LVecBase3get_scale () const
 Returns the scale component of the transform.
LVecBase2 get_scale2d () const
 Returns the scale component of the 2-d transform.
const LVecBase3get_shear () const
 Returns the shear component of the transform.
PN_stdfloat get_shear2d () const
 Returns the shear component of the 2-d transform.
virtual TypeHandle get_type () const
PN_stdfloat get_uniform_scale () const
 Returns the scale component of the transform, as a single number.
bool has_components () const
 Returns true if the transform can be described by separate pos, hpr, and scale components.
bool has_hpr () const
 Returns true if the transform's rotation component can be extracted out separately and described as a set of Euler angles.
bool has_identity_scale () const
 Returns true if the scale is uniform 1.0, or false if the scale has some real value.
bool has_mat () const
 Returns true if the transform can be described as a matrix.
bool has_nonzero_shear () const
 Returns true if the shear component is non-zero, false if it is zero or if the matrix cannot be decomposed.
bool has_pos () const
 Returns true if the transform's pos component can be extracted out separately.
bool has_quat () const
 Returns true if the transform's rotation component can be extracted out separately and described as a quaternion.
bool has_scale () const
 Returns true if the transform's scale component can be extracted out separately.
bool has_shear () const
 Returns true if the transform's shear component can be extracted out separately.
bool has_uniform_scale () const
 Returns true if the scale is uniform across all three axes (and therefore can be expressed as a single number), or false if the transform has a different scale in different dimensions.
bool hpr_given () const
 Returns true if the rotation was specified via a trio of Euler angles, false otherwise.
bool is_2d () const
 Returns true if the transform has been constructed entirely using the 2-d transform operations, e.g.
bool is_identity () const
 Returns true if the transform represents the identity matrix, false otherwise.
bool is_invalid () const
 Returns true if the transform represents an invalid matrix, for instance the result of inverting a singular matrix, or false if the transform is valid.
bool is_singular () const
 Returns true if the transform represents a singular transform (that is, it has a zero scale, and it cannot be inverted), or false otherwise.
void node_ref () const
 Overrides this method to update PStats appropriately.
bool node_unref () const
 Overrides this method to update PStats appropriately.
bool operator< (const TransformState &other) const
 Provides an arbitrary ordering among all unique TransformStates, so we can store the essentially different ones in a big set and throw away the rest.
void output (ostream &out) const
bool quat_given () const
 Returns true if the rotation was specified via a quaternion, false otherwise.
virtual bool unref () const
 This method overrides ReferenceCount::unref() to check whether the remaining reference count is entirely in the cache, and if so, it checks for and breaks a cycle in the cache involving this object.
bool validate_composition_cache () const
 Returns true if the composition cache and invert composition cache for this particular TransformState are self-consistent and valid, false otherwise.
void write (ostream &out, int indent_level) const
void write_composition_cache (ostream &out, int indent_level) const
 Writes a brief description of the composition cache and invert composition cache to the indicated ostream.
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.

Static Public Member Functions

static int clear_cache ()
 Empties the cache of composed TransformStates.
static CPT (TransformState) make_invalid()
static CPT (TransformState) make_hpr(const LVecBase3 &hpr)
static CPT (TransformState) make_scale(const LVecBase3 &scale)
static CPT (TransformState) make_rotate2d(PN_stdfloat rotate)
static CPT (TransformState) make_pos_rotate2d(const LVecBase2 &pos
static CPT (TransformState) make_shear(const LVecBase3 &shear)
static CPT (TransformState) make_scale2d(PN_stdfloat scale)
static CPT (TransformState) make_scale2d(const LVecBase2 &scale)
static CPT (TransformState) make_quat(const LQuaternion &quat)
static CPT (TransformState) make_pos_hpr_scale(const LVecBase3 &pos
static CPT (TransformState) make_pos_quat_scale_shear(const LVecBase3 &pos
static CPT (TransformState) make_shear2d(PN_stdfloat shear)
static CPT (TransformState) make_pos_rotate_scale2d(const LVecBase2 &pos
static CPT (TransformState) make_pos_quat_scale(const LVecBase3 &pos
static CPT (TransformState) make_pos_rotate_scale_shear2d(const LVecBase2 &pos
static CPT (TransformState) make_mat3(const LMatrix3 &mat)
static CPT (TransformState) make_identity()
static CPT (TransformState) make_pos(const LVecBase3 &pos)
static CPT (TransformState) make_pos_hpr_scale_shear(const LVecBase3 &pos
static CPT (TransformState) make_pos_hpr(const LVecBase3 &pos
static CPT (TransformState) make_scale(PN_stdfloat scale)
static CPT (TransformState) make_mat(const LMatrix4 &mat)
static CPT (TransformState) make_pos2d(const LVecBase2 &pos)
static void flush_level ()
 Flushes the PStatCollectors used during traversal.
static int garbage_collect ()
 Performs a garbage-collection cycle.
static TypeHandle get_class_type ()
static int get_num_states ()
 Returns the total number of unique TransformState objects allocated in the world.
static int get_num_unused_states ()
 Returns the total number of TransformState objects that have been allocated but have no references outside of the internal TransformState cache.
static void init_states ()
 Make sure the global _states map is allocated.
static void init_type ()
static void list_cycles (ostream &out)
 Detects all of the reference-count cycles in the cache and reports them to standard output.
static void list_states (ostream &out)
 Lists all of the TransformStates in the cache to the output stream, one per line.
static PT (TypedWritableReferenceCount) change_this(TypedWritableReferenceCount *old_ptr
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type TransformState.
static bool validate_states ()
 Ensures that the cache is still stored in sorted order, and that none of the cache elements have been inadvertently deleted.

Public Attributes

static const LVecBase3hpr
static BamReadermanager
static const LQuaternionquat
static PN_stdfloat rotate
static const LQuaternion const
LVecBase3
scale
static PN_stdfloat const
LVecBase2
scale
static const LVecBase3 const
LVecBase3
scale
static PN_stdfloat const
LVecBase2 PN_stdfloat 
shear
static const LVecBase3 const
LVecBase3 const LVecBase3
shear
static const LQuaternion const
LVecBase3 const LVecBase3
shear

Protected Member Functions

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

Static Protected Member Functions

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

Detailed Description

Indicates a coordinate-system transform on vertices.

TransformStates are the primary means for storing transformations on the scene graph.

Transforms may be specified in one of two ways: componentwise, with a pos-hpr-scale, or with an arbitrary transform matrix. If you specify a transform componentwise, it will remember its original components.

TransformState objects are managed very much like RenderState objects. They are immutable and reference-counted automatically.

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

Definition at line 61 of file transformState.h.


Constructor & Destructor Documentation

TransformState::TransformState ( ) [protected]

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

Definition at line 60 of file transformState.cxx.

TransformState::~TransformState ( ) [virtual]

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

Definition at line 97 of file transformState.cxx.

References CacheStats::add_num_states(), ReferenceCount::get_ref_count(), and SimpleHashMap< Key, Value, Compare >::is_empty().


Member Function Documentation

void TransformState::cache_ref ( ) const [inline]

Overrides this method to update PStats appropriately.

Reimplemented from CachedTypedWritableReferenceCount.

Definition at line 736 of file transformState.I.

References NodeCachedReferenceCount::get_referenced_bits().

bool TransformState::cache_unref ( ) const [inline]

Overrides this method to update PStats appropriately.

Reimplemented from CachedTypedWritableReferenceCount.

Definition at line 752 of file transformState.I.

References NodeCachedReferenceCount::get_referenced_bits().

Referenced by clear_cache(), and garbage_collect().

int TransformState::clear_cache ( ) [static]

Empties the cache of composed TransformStates.

This makes every TransformState forget what results when it is composed with other TransformStates.

This will eliminate any TransformState objects that have been allocated but have no references outside of the internal TransformState map. It will not eliminate TransformState 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 TransformStates freed by this operation.

Definition at line 1199 of file transformState.cxx.

References CacheStats::add_total_size(), cache_unref(), SimpleHashMap< Key, Value, Compare >::clear(), SimpleHashMap< Key, Value, Compare >::get_data(), SimpleHashMap< Key, Value, Compare >::get_key(), SimpleHashMap< Key, Value, Compare >::get_num_entries(), ReferenceCount::get_ref_count(), SimpleHashMap< Key, Value, Compare >::get_size(), and SimpleHashMap< Key, Value, Compare >::has_element().

int TransformState::compare_to ( const TransformState other) const [inline]

Provides an arbitrary ordering among all unique TransformStates, so we can store the essentially different ones in a big set and throw away the rest.

Definition at line 36 of file transformState.I.

Referenced by operator<(), and validate_states().

int TransformState::compare_to ( const TransformState other,
bool  uniquify_matrix 
) const

Provides an arbitrary ordering among all unique TransformStates, so we can store the essentially different ones in a big set and throw away the rest.

If uniquify_matrix is true, then matrix-defined TransformStates are also uniqified. If uniquify_matrix is false, then only component-defined TransformStates are uniquified, which is less expensive.

Definition at line 134 of file transformState.cxx.

References LMatrix4f::compare_to(), LVecBase4f::compare_to(), LVecBase3f::compare_to(), and get_mat().

bool TransformState::components_given ( ) const [inline]

Returns true if the transform was specified componentwise, or false if it was specified with a general 4x4 matrix.

If this is true, the components returned by get_pos() and get_scale() will be exactly those that were set; otherwise, these functions will return computed values. If this is true, the rotation may have been set either with a hpr trio or with a quaternion; hpr_given() or quat_given() can resolve the difference.

Definition at line 336 of file transformState.I.

void TransformState::fillin ( DatagramIterator scan,
BamReader manager 
) [protected, virtual]

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

Reimplemented from TypedWritable.

Definition at line 2797 of file transformState.cxx.

References DatagramIterator::get_uint32(), LMatrix4f::read_datagram(), LVecBase4f::read_datagram(), and LVecBase3f::read_datagram().

Referenced by make_from_bam().

void TransformState::flush_level ( ) [inline, static]

Flushes the PStatCollectors used during traversal.

Definition at line 955 of file transformState.I.

Referenced by GraphicsEngine::render_frame().

int TransformState::garbage_collect ( ) [static]

Performs a garbage-collection cycle.

This must be called periodically if garbage-collect-states is true to ensure that TransformStates 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.

Definition at line 1281 of file transformState.cxx.

References cache_unref(), CachedTypedWritableReferenceCount::get_cache_ref_count(), SimpleHashMap< Key, Value, Compare >::get_key(), SimpleHashMap< Key, Value, Compare >::get_num_entries(), ReferenceCount::get_ref_count(), SimpleHashMap< Key, Value, Compare >::get_size(), SimpleHashMap< Key, Value, Compare >::has_element(), and SimpleHashMap< Key, Value, Compare >::validate().

Referenced by PandaFramework::task_garbage_collect().

int TransformState::get_composition_cache_num_entries ( ) const [inline]

Returns the number of entries in the composition cache for this TransformState.

This is the number of other TransformStates whose composition with this one has been cached. This number is not useful for any practical reason other than performance analysis.

Definition at line 806 of file transformState.I.

References SimpleHashMap< Key, Value, Compare >::get_num_entries().

const TransformState * TransformState::get_composition_cache_result ( int  n) const [inline]

Returns the result TransformState 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.

Definition at line 879 of file transformState.I.

References SimpleHashMap< Key, Value, Compare >::get_data(), and SimpleHashMap< Key, Value, Compare >::has_element().

int TransformState::get_composition_cache_size ( ) const [inline]

Returns the number of slots in the composition cache for this TransformState.

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.

Definition at line 839 of file transformState.I.

References SimpleHashMap< Key, Value, Compare >::get_size().

const TransformState * TransformState::get_composition_cache_source ( int  n) const [inline]

Returns the source TransformState 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.

Definition at line 856 of file transformState.I.

References SimpleHashMap< Key, Value, Compare >::get_key(), and SimpleHashMap< Key, Value, Compare >::has_element().

int TransformState::get_geom_rendering ( int  geom_rendering) const [inline]

Returns the union of the Geom::GeomRendering bits that will be required once this TransformState is applied to a geom which includes the indicated geom_rendering bits.

The RenderState's get_geom_rendering() should already have been applied.

Definition at line 720 of file transformState.I.

References has_identity_scale().

size_t TransformState::get_hash ( ) const [inline]

Returns a suitable hash value for phash_map.

Definition at line 46 of file transformState.I.

const LVecBase3 & TransformState::get_hpr ( ) const [inline]

Returns the rotation component of the transform as a trio of Euler angles.

It is an error to call this if has_components() returned false.

Definition at line 501 of file transformState.I.

References is_invalid().

Referenced by PartGroup::apply_freeze(), NodePath::set_pos_hpr(), STTransform::STTransform(), and write_datagram().

int TransformState::get_invert_composition_cache_num_entries ( ) const [inline]

Returns the number of entries in the invert_composition cache for this TransformState.

This is similar to the composition cache, but it records cache entries for the invert_compose() operation. See get_composition_cache_num_entries().

Definition at line 821 of file transformState.I.

References SimpleHashMap< Key, Value, Compare >::get_num_entries().

const TransformState * TransformState::get_invert_composition_cache_result ( int  n) const [inline]

Returns the result TransformState 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.

Definition at line 941 of file transformState.I.

References SimpleHashMap< Key, Value, Compare >::get_data(), and SimpleHashMap< Key, Value, Compare >::has_element().

int TransformState::get_invert_composition_cache_size ( ) const [inline]

Returns the number of slots in the composition cache for this TransformState.

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.

Definition at line 900 of file transformState.I.

References SimpleHashMap< Key, Value, Compare >::get_size().

const TransformState * TransformState::get_invert_composition_cache_source ( int  n) const [inline]

Returns the source TransformState 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.

Definition at line 917 of file transformState.I.

References SimpleHashMap< Key, Value, Compare >::get_key(), and SimpleHashMap< Key, Value, Compare >::has_element().

const LMatrix4 & TransformState::get_mat ( ) const [inline]
LMatrix3 TransformState::get_mat3 ( ) const [inline]

Returns the 3x3 matrix that describes the 2-d transform.

It is an error to call this if is_2d() returned false.

Definition at line 673 of file transformState.I.

References has_mat(), LMatrix3f::ident_mat(), and is_2d().

const LQuaternion & TransformState::get_norm_quat ( ) const [inline]

Returns the rotation component of the transform as a quaternion.

Unlike the result of get_quat(), the return value of this method is guaranteed to be normalized. It is an error to call this if has_components() returned false.

Definition at line 538 of file transformState.I.

References is_invalid().

int TransformState::get_num_states ( ) [static]

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

This will go up and down during normal operations.

Definition at line 1073 of file transformState.cxx.

References SimpleHashMap< Key, Value, Compare >::get_num_entries().

Referenced by GraphicsEngine::render_frame().

int TransformState::get_num_unused_states ( ) [static]

Returns the total number of TransformState objects that have been allocated but have no references outside of the internal TransformState cache.

A nonzero return value is not necessarily indicative of leaked references; it is normal for two TransformState objects, both of which have references held outside the cache, to have the result of their composition stored within the cache. This result will be retained within the cache until one of the base TransformStates is released.

Use list_cycles() to get an idea of the number of actual "leaked" TransformState objects.

Definition at line 1100 of file transformState.cxx.

References CachedTypedWritableReferenceCount::get_cache_ref_count(), SimpleHashMap< Key, Value, Compare >::get_data(), SimpleHashMap< Key, Value, Compare >::get_key(), ReferenceCount::get_ref_count(), SimpleHashMap< Key, Value, Compare >::get_size(), and SimpleHashMap< Key, Value, Compare >::has_element().

Referenced by GraphicsEngine::render_frame().

const LPoint3 & TransformState::get_pos ( ) const [inline]

Returns the pos component of the transform.

It is an error to call this if has_pos() returned false.

Definition at line 487 of file transformState.I.

References has_pos().

Referenced by CompassEffect::adjust_transform(), PartGroup::apply_freeze(), NodePath::get_pos(), NodePath::get_pos_delta(), NodePath::set_pos_hpr(), NodePath::set_pos_quat(), STTransform::STTransform(), and ModelNode::test_transform().

LVecBase2 TransformState::get_pos2d ( ) const [inline]

Returns the pos component of the 2-d transform.

It is an error to call this if has_pos() or is_2d() returned false.

Definition at line 606 of file transformState.I.

References has_pos(), is_2d(), and LVecBase2f::zero().

const LQuaternion & TransformState::get_quat ( ) const [inline]

Returns the rotation component of the transform as a quaternion.

The return value will be normalized if a normalized quaternion was given to the constructor (or if the quaternion was computed implicitly); it will be non-normalized if a non-normalized quaternion was given to the constructor. See also get_norm_quat().

It is an error to call this if has_components() returned false.

Definition at line 522 of file transformState.I.

References is_invalid().

Referenced by CompassEffect::adjust_transform(), and NodePath::set_pos_quat().

PN_stdfloat TransformState::get_rotate2d ( ) const [inline]

Returns the rotation component of the 2-d transform as an angle in degrees clockwise about the origin.

It is an error to call this if has_components() or is_2d() returned false.

Definition at line 621 of file transformState.I.

References is_2d(), and is_invalid().

const LVecBase3 & TransformState::get_scale ( ) const [inline]

Returns the scale component of the transform.

It is an error to call this if has_components() returned false.

Definition at line 552 of file transformState.I.

References is_invalid().

Referenced by CompassEffect::adjust_transform(), and PartGroup::apply_freeze().

LVecBase2 TransformState::get_scale2d ( ) const [inline]

Returns the scale component of the 2-d transform.

It is an error to call this if has_components() or is_2d() returned false.

Definition at line 645 of file transformState.I.

References is_2d(), is_invalid(), and LVecBase2f::zero().

const LVecBase3 & TransformState::get_shear ( ) const [inline]

Returns the shear component of the transform.

It is an error to call this if has_components() returned false.

Definition at line 580 of file transformState.I.

References is_invalid().

PN_stdfloat TransformState::get_shear2d ( ) const [inline]

Returns the shear component of the 2-d transform.

It is an error to call this if has_components() or is_2d() returned false.

Definition at line 659 of file transformState.I.

References is_2d(), and is_invalid().

PN_stdfloat TransformState::get_uniform_scale ( ) const [inline]

Returns the scale component of the transform, as a single number.

It is an error to call this if has_uniform_scale() returned false.

Definition at line 566 of file transformState.I.

References has_uniform_scale().

Referenced by STTransform::STTransform().

bool TransformState::has_components ( ) const [inline]

Returns true if the transform can be described by separate pos, hpr, and scale components.

Most transforms we use in everyday life can be so described, but some kinds of transforms (for instance, those involving a skew) cannot.

This is not related to whether the transform was originally described componentwise. Even a transform that was constructed with a 4x4 may return true here if the matrix is a simple affine matrix with no skew.

If this returns true, you may safely call get_hpr() and get_scale() to retrieve the components. (You may always safely call get_pos() whether this returns true or false.)

Definition at line 317 of file transformState.I.

Referenced by CompassEffect::adjust_transform(), has_hpr(), has_quat(), has_scale(), has_shear(), NodePath::set_pos_hpr(), NodePath::set_pos_quat(), and STTransform::STTransform().

bool TransformState::has_hpr ( ) const [inline]

Returns true if the transform's rotation component can be extracted out separately and described as a set of Euler angles.

This is generally true only when has_components() is true.

Definition at line 388 of file transformState.I.

References has_components().

bool TransformState::has_identity_scale ( ) const [inline]

Returns true if the scale is uniform 1.0, or false if the scale has some real value.

Definition at line 424 of file transformState.I.

Referenced by get_geom_rendering().

bool TransformState::has_mat ( ) const [inline]

Returns true if the transform can be described as a matrix.

This is generally always true, unless is_invalid() is true.

Definition at line 476 of file transformState.I.

References is_invalid().

Referenced by get_mat(), and get_mat3().

bool TransformState::has_nonzero_shear ( ) const [inline]

Returns true if the shear component is non-zero, false if it is zero or if the matrix cannot be decomposed.

Definition at line 463 of file transformState.I.

bool TransformState::has_pos ( ) const [inline]

Returns true if the transform's pos component can be extracted out separately.

This is generally always true, unless the transform is invalid (i.e. is_invalid() returns true).

Definition at line 375 of file transformState.I.

References is_invalid().

Referenced by get_pos(), and get_pos2d().

bool TransformState::has_quat ( ) const [inline]

Returns true if the transform's rotation component can be extracted out separately and described as a quaternion.

This is generally true only when has_components() is true.

Definition at line 401 of file transformState.I.

References has_components().

bool TransformState::has_scale ( ) const [inline]

Returns true if the transform's scale component can be extracted out separately.

This is generally true only when has_components() is true.

Definition at line 413 of file transformState.I.

References has_components().

bool TransformState::has_shear ( ) const [inline]

Returns true if the transform's shear component can be extracted out separately.

This is generally true only when has_components() is true.

Definition at line 451 of file transformState.I.

References has_components().

bool TransformState::has_uniform_scale ( ) const [inline]

Returns true if the scale is uniform across all three axes (and therefore can be expressed as a single number), or false if the transform has a different scale in different dimensions.

Definition at line 438 of file transformState.I.

Referenced by get_uniform_scale(), and STTransform::STTransform().

bool TransformState::hpr_given ( ) const [inline]

Returns true if the rotation was specified via a trio of Euler angles, false otherwise.

If this is true, get_hpr() will be exactly as set; otherwise, it will return a computed value.

Definition at line 349 of file transformState.I.

void TransformState::init_states ( ) [static]

Make sure the global _states map is allocated.

This only has to be done once. We could make this map static, but then we run into problems if anyone creates a TransformState object at static init time; it also seems to cause problems when the Panda shared library is unloaded at application exit time.

Definition at line 1618 of file transformState.cxx.

References Thread::get_current_thread(), Thread::get_main_thread(), and CacheStats::init().

bool TransformState::is_2d ( ) const [inline]

Returns true if the transform has been constructed entirely using the 2-d transform operations, e.g.

make_pos2d(), and therefore operates strictly in two-dimensional space on X and Y only.

Definition at line 293 of file transformState.I.

Referenced by get_mat3(), get_pos2d(), get_rotate2d(), get_scale2d(), and get_shear2d().

bool TransformState::is_identity ( ) const [inline]
bool TransformState::is_invalid ( ) const [inline]

Returns true if the transform represents an invalid matrix, for instance the result of inverting a singular matrix, or false if the transform is valid.

Definition at line 267 of file transformState.I.

Referenced by get_hpr(), get_norm_quat(), get_quat(), get_rotate2d(), get_scale(), get_scale2d(), get_shear(), get_shear2d(), has_mat(), has_pos(), and CullTraverserData::is_in_view().

bool TransformState::is_singular ( ) const [inline]

Returns true if the transform represents a singular transform (that is, it has a zero scale, and it cannot be inverted), or false otherwise.

Definition at line 279 of file transformState.I.

Referenced by CullTraverserData::apply_transform_and_state(), and LODNode::compute_child().

void TransformState::list_cycles ( 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.

Definition at line 1358 of file transformState.cxx.

References SimpleHashMap< Key, Value, Compare >::get_key(), ReferenceCount::get_ref_count(), SimpleHashMap< Key, Value, Compare >::get_size(), and SimpleHashMap< Key, Value, Compare >::has_element().

void TransformState::list_states ( ostream &  out) [static]

Lists all of the TransformStates 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.

Definition at line 1440 of file transformState.cxx.

References SimpleHashMap< Key, Value, Compare >::get_key(), SimpleHashMap< Key, Value, Compare >::get_num_entries(), SimpleHashMap< Key, Value, Compare >::get_size(), and SimpleHashMap< Key, Value, Compare >::has_element().

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

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

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

Definition at line 2777 of file transformState.cxx.

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

Referenced by register_with_read_factory().

void TransformState::node_ref ( ) const [inline]

Overrides this method to update PStats appropriately.

Reimplemented from NodeCachedReferenceCount.

Definition at line 769 of file transformState.I.

References NodeCachedReferenceCount::get_referenced_bits().

bool TransformState::node_unref ( ) const [inline]

Overrides this method to update PStats appropriately.

Reimplemented from NodeCachedReferenceCount.

Definition at line 785 of file transformState.I.

References NodeCachedReferenceCount::get_referenced_bits().

bool TransformState::operator< ( const TransformState other) const [inline]

Provides an arbitrary ordering among all unique TransformStates, so we can store the essentially different ones in a big set and throw away the rest.

Definition at line 24 of file transformState.I.

References compare_to().

bool TransformState::quat_given ( ) const [inline]

Returns true if the rotation was specified via a quaternion, false otherwise.

If this is true, get_quat() will be exactly as set; otherwise, it will return a computed value.

Definition at line 362 of file transformState.I.

void TransformState::register_with_read_factory ( ) [static]

Tells the BamReader how to create objects of type TransformState.

Definition at line 2691 of file transformState.cxx.

References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().

bool TransformState::unref ( ) const [virtual]

This method overrides ReferenceCount::unref() to check whether the remaining reference count is entirely in the cache, and if so, it checks for and breaks a cycle in the cache involving this object.

This is designed to prevent leaks from cyclical references within the cache.

Reimplemented from ReferenceCount.

Definition at line 719 of file transformState.cxx.

References CachedTypedWritableReferenceCount::get_cache_ref_count(), ReferenceCount::get_ref_count(), and ReferenceCount::unref().

bool TransformState::validate_composition_cache ( ) const

Returns true if the composition cache and invert composition cache for this particular TransformState are self-consistent and valid, false otherwise.

Definition at line 769 of file transformState.cxx.

References SimpleHashMap< Key, Value, Compare >::find(), SimpleHashMap< Key, Value, Compare >::get_key(), SimpleHashMap< Key, Value, Compare >::get_size(), and SimpleHashMap< Key, Value, Compare >::has_element().

bool TransformState::validate_states ( ) [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 TransformState objects).

Definition at line 1470 of file transformState.cxx.

References compare_to(), SimpleHashMap< Key, Value, Compare >::get_key(), SimpleHashMap< Key, Value, Compare >::get_size(), SimpleHashMap< Key, Value, Compare >::is_empty(), and SimpleHashMap< Key, Value, Compare >::validate().

void TransformState::write_composition_cache ( ostream &  out,
int  indent_level 
) const

Writes a brief description of the composition cache and invert composition cache to the indicated ostream.

This is not useful except for performance analysis, to examine the cache structure.

Definition at line 1060 of file transformState.cxx.

void TransformState::write_datagram ( BamWriter manager,
Datagram dg 
) [virtual]

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

Reimplemented from TypedWritable.

Definition at line 2702 of file transformState.cxx.

References Datagram::add_uint32(), get_hpr(), LMatrix4f::write_datagram(), LVecBase4f::write_datagram(), and LVecBase3f::write_datagram().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations