Panda3D
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
TransformState Class Reference

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

Inheritance diagram for TransformState:
NodeCachedReferenceCount CachedTypedWritableReferenceCount TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject

Public Member Functions

 cacheRef ()
 Overrides this method to update PStats appropriately. More...
 
bool cacheUnref ()
 Overrides this method to update PStats appropriately. More...
 
int compareTo (const TransformState other)
 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. More...
 
int compareTo (const TransformState other, bool uniquify_matrix)
 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. More...
 
bool componentsGiven ()
 Returns true if the transform was specified componentwise, or false if it was specified with a general 4x4 matrix. More...
 
const TransformState compose (const TransformState other)
 Returns a new TransformState object that represents the composition of this state with the other state. More...
 
object getCompositionCache ()
 
int getCompositionCacheNumEntries ()
 Returns the number of entries in the composition cache for this TransformState. More...
 
const TransformState getCompositionCacheResult (int n)
 Returns the result TransformState of the nth element in the composition cache. More...
 
int getCompositionCacheSize ()
 Returns the number of slots in the composition cache for this TransformState. More...
 
const TransformState getCompositionCacheSource (int n)
 Returns the source TransformState of the nth element in the composition cache. More...
 
int getGeomRendering (int geom_rendering)
 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. More...
 
int getHash ()
 Returns a suitable hash value for phash_map. More...
 
const LVecBase3 getHpr ()
 Returns the rotation component of the transform as a trio of Euler angles. More...
 
const TransformState getInverse ()
 Returns the inverse of this transform. More...
 
object getInvertCompositionCache ()
 
int getInvertCompositionCacheNumEntries ()
 Returns the number of entries in the invert_composition cache for this TransformState. More...
 
const TransformState getInvertCompositionCacheResult (int n)
 Returns the result TransformState of the nth element in the invert composition cache. More...
 
int getInvertCompositionCacheSize ()
 Returns the number of slots in the composition cache for this TransformState. More...
 
const TransformState getInvertCompositionCacheSource (int n)
 Returns the source TransformState of the nth element in the invert composition cache. More...
 
const LMatrix4 getMat ()
 Returns the matrix that describes the transform. More...
 
LMatrix3 getMat3 ()
 Returns the 3x3 matrix that describes the 2-d transform. More...
 
const LQuaternion getNormQuat ()
 Returns the rotation component of the transform as a quaternion. More...
 
const LPoint3 getPos ()
 Returns the pos component of the transform. More...
 
LVecBase2 getPos2d ()
 Returns the pos component of the 2-d transform. More...
 
const LQuaternion getQuat ()
 Returns the rotation component of the transform as a quaternion. More...
 
float getRotate2d ()
 Returns the rotation component of the 2-d transform as an angle in degrees clockwise about the origin. More...
 
const LVecBase3 getScale ()
 Returns the scale component of the transform. More...
 
LVecBase2 getScale2d ()
 Returns the scale component of the 2-d transform. More...
 
const LVecBase3 getShear ()
 Returns the shear component of the transform. More...
 
float getShear2d ()
 Returns the shear component of the 2-d transform. More...
 
float getUniformScale ()
 Returns the scale component of the transform, as a single number. More...
 
const TransformState getUnique ()
 Returns the pointer to the unique TransformState in the cache that is equivalent to this one. More...
 
bool hasComponents ()
 Returns true if the transform can be described by separate pos, hpr, and scale components. More...
 
bool hasHpr ()
 Returns true if the transform's rotation component can be extracted out separately and described as a set of Euler angles. More...
 
bool hasIdentityScale ()
 Returns true if the scale is uniform 1.0, or false if the scale has some real value. More...
 
bool hasMat ()
 Returns true if the transform can be described as a matrix. More...
 
bool hasNonzeroShear ()
 Returns true if the shear component is non-zero, false if it is zero or if the matrix cannot be decomposed. More...
 
bool hasPos ()
 Returns true if the transform's pos component can be extracted out separately. More...
 
bool hasQuat ()
 Returns true if the transform's rotation component can be extracted out separately and described as a quaternion. More...
 
bool hasScale ()
 Returns true if the transform's scale component can be extracted out separately. More...
 
bool hasShear ()
 Returns true if the transform's shear component can be extracted out separately. More...
 
bool hasUniformScale ()
 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. More...
 
bool hprGiven ()
 Returns true if the rotation was specified via a trio of Euler angles, false otherwise. More...
 
const TransformState invertCompose (const TransformState other)
 Returns a new TransformState object that represents the composition of this state's inverse with the other state. More...
 
bool is2d ()
 Returns true if the transform has been constructed entirely using the 2-d transform operations, e.g. More...
 
bool isIdentity ()
 Returns true if the transform represents the identity matrix, false otherwise. More...
 
bool isInvalid ()
 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. More...
 
bool isSingular ()
 Returns true if the transform represents a singular transform (that is, it has a zero scale, and it cannot be inverted), or false otherwise. More...
 
 nodeRef ()
 Overrides this method to update PStats appropriately. More...
 
bool nodeUnref ()
 Overrides this method to update PStats appropriately. More...
 
bool operator != (const TransformState other)
 
bool operator== (const TransformState other)
 
 output (Ostream out)
 
bool quatGiven ()
 Returns true if the rotation was specified via a quaternion, false otherwise. More...
 
const TransformState setHpr (const LVecBase3 hpr)
 Returns a new TransformState object that represents the original TransformState with its rotation component replaced with the indicated value, if possible. More...
 
const TransformState setPos (const LVecBase3 pos)
 Returns a new TransformState object that represents the original TransformState with its pos component replaced with the indicated value. More...
 
const TransformState setPos2d (const LVecBase2 pos)
 Returns a new TransformState object that represents the original 2-d TransformState with its pos component replaced with the indicated value. More...
 
const TransformState setQuat (const LQuaternion quat)
 Returns a new TransformState object that represents the original TransformState with its rotation component replaced with the indicated value, if possible. More...
 
const TransformState setRotate2d (float rotate)
 Returns a new TransformState object that represents the original 2-d TransformState with its rotation component replaced with the indicated value, if possible. More...
 
const TransformState setScale (const LVecBase3 scale)
 Returns a new TransformState object that represents the original TransformState with its scale component replaced with the indicated value, if possible. More...
 
const TransformState setScale2d (const LVecBase2 scale)
 Returns a new TransformState object that represents the original 2-d TransformState with its scale component replaced with the indicated value, if possible. More...
 
const TransformState setShear (const LVecBase3 shear)
 Returns a new TransformState object that represents the original TransformState with its shear component replaced with the indicated value, if possible. More...
 
const TransformState setShear2d (float shear)
 Returns a new TransformState object that represents the original 2-d TransformState with its shear component replaced with the indicated value, if possible. More...
 
bool validateCompositionCache ()
 Returns true if the composition cache and invert composition cache for this particular TransformState are self-consistent and valid, false otherwise. More...
 
 write (Ostream out, int indent_level)
 
 writeCompositionCache (Ostream out, int indent_level)
 Writes a brief description of the composition cache and invert composition cache to the indicated ostream. More...
 
- Public Member Functions inherited from NodeCachedReferenceCount
int getNodeRefCount ()
 Returns the current reference count. More...
 
int getReferencedBits ()
 Returns the union of the values defined in the Referenced enum that represents the various things that appear to be holding a pointer to this object. More...
 
 nodeRef ()
 Explicitly increments the reference count. More...
 
bool nodeUnref ()
 Explicitly decrements the node reference count and the normal reference count simultaneously. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
- Public Member Functions inherited from CachedTypedWritableReferenceCount
 cacheRef ()
 Explicitly increments the cache reference count and the normal reference count simultaneously. More...
 
bool cacheUnref ()
 Explicitly decrements the cache reference count and the normal reference count simultaneously. More...
 
int getCacheRefCount ()
 Returns the current reference count. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
- Public Member Functions inherited from TypedWritable
object __reduce__ ()
 
object __reduce_persist__ (object pickler)
 
VectorUchar encodeToBamStream ()
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. More...
 
bool encodeToBamStream (VectorUchar data, BamWriter writer)
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More...
 
 fillin (DatagramIterator scan, BamReader manager)
 This internal function is intended to be called by each class's make_from_bam() method to read in all of the relevant data from the BamFile for the new object. More...
 
UpdateSeq getBamModified ()
 Returns the current bam_modified counter. More...
 
 markBamModified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More...
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly. More...
 
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type. More...
 
- Public Member Functions inherited from ReferenceCount
int getRefCount ()
 Returns the current reference count. More...
 
 ref ()
 Explicitly increments the reference count. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
bool unref ()
 Explicitly decrements the reference count. More...
 

Static Public Member Functions

static int clearCache ()
 Empties the cache of composed TransformStates. More...
 
static int garbageCollect ()
 Performs a garbage-collection cycle. More...
 
static TypeHandle getClassType ()
 
static int getNumStates ()
 Returns the total number of unique TransformState objects allocated in the world. More...
 
static int getNumUnusedStates ()
 Returns the total number of TransformState objects that have been allocated but have no references outside of the internal TransformState cache. More...
 
static object getStates ()
 
static object getUnusedStates ()
 
static listCycles (Ostream out)
 Detects all of the reference-count cycles in the cache and reports them to standard output. More...
 
static listStates (Ostream out)
 Lists all of the TransformStates in the cache to the output stream, one per line. More...
 
static const TransformState makeHpr (const LVecBase3 hpr)
 Makes a new TransformState with the specified components. More...
 
static const TransformState makeIdentity ()
 Constructs an identity transform. More...
 
static const TransformState makeInvalid ()
 Constructs an invalid transform; for instance, the result of inverting a singular matrix. More...
 
static const TransformState makeMat (const LMatrix4 mat)
 Makes a new TransformState with the specified transformation matrix. More...
 
static const TransformState makeMat3 (const LMatrix3 mat)
 Makes a new two-dimensional TransformState with the specified 3x3 transformation matrix. More...
 
static const TransformState makePos (const LVecBase3 pos)
 Makes a new TransformState with the specified components. More...
 
static const TransformState makePos2d (const LVecBase2 pos)
 Makes a new 2-d TransformState with the specified components. More...
 
static const TransformState makePosHpr (const LVecBase3 pos, const LVecBase3 hpr)
 Makes a new TransformState with the specified components. More...
 
static const TransformState makePosHprScale (const LVecBase3 pos, const LVecBase3 hpr, const LVecBase3 scale)
 Makes a new TransformState with the specified components. More...
 
static const TransformState makePosHprScaleShear (const LVecBase3 pos, const LVecBase3 hpr, const LVecBase3 scale, const LVecBase3 shear)
 Makes a new TransformState with the specified components. More...
 
static const TransformState makePosQuatScale (const LVecBase3 pos, const LQuaternion quat, const LVecBase3 scale)
 Makes a new TransformState with the specified components. More...
 
static const TransformState makePosQuatScaleShear (const LVecBase3 pos, const LQuaternion quat, const LVecBase3 scale, const LVecBase3 shear)
 Makes a new TransformState with the specified components. More...
 
static const TransformState makePosRotate2d (const LVecBase2 pos, float rotate)
 Makes a new 2-d TransformState with the specified components. More...
 
static const TransformState makePosRotateScale2d (const LVecBase2 pos, float rotate, const LVecBase2 scale)
 Makes a new 2-d TransformState with the specified components. More...
 
static const TransformState makePosRotateScaleShear2d (const LVecBase2 pos, float rotate, const LVecBase2 scale, float shear)
 Makes a new two-dimensional TransformState with the specified components. More...
 
static const TransformState makeQuat (const LQuaternion quat)
 Makes a new TransformState with the specified components. More...
 
static const TransformState makeRotate2d (float rotate)
 Makes a new 2-d TransformState with the specified components. More...
 
static const TransformState makeScale (const LVecBase3 scale)
 Makes a new TransformState with the specified components. More...
 
static const TransformState makeScale (float scale)
 Makes a new TransformState with the specified components. More...
 
static const TransformState makeScale2d (const LVecBase2 scale)
 Makes a new 2-d TransformState with the specified components. More...
 
static const TransformState makeScale2d (float scale)
 Makes a new 2-d TransformState with the specified components. More...
 
static const TransformState makeShear (const LVecBase3 shear)
 Makes a new TransformState with the specified components. More...
 
static const TransformState makeShear2d (float shear)
 Makes a new 2-d TransformState with the specified components. More...
 
static bool validateStates ()
 Ensures that the cache is still stored in sorted order, and that none of the cache elements have been inadvertently deleted. More...
 
- Static Public Member Functions inherited from NodeCachedReferenceCount
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from CachedTypedWritableReferenceCount
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedWritableReferenceCount
static TypedWritableReferenceCount decodeFromBamStream (VectorUchar data, BamReader reader)
 Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts and returns the single object on those bytes. More...
 
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedWritable
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 

Public Attributes

const LVecBase3 hpr
 Returns the rotation component of the transform as a trio of Euler angles. More...
 
const LMatrix4 mat
 Returns the matrix that describes the transform. More...
 
const LQuaternion norm_quat
 Returns the rotation component of the transform as a quaternion. More...
 
const LPoint3 pos
 Returns the pos component of the transform. More...
 
const LQuaternion quat
 Returns the rotation component of the transform as a quaternion. More...
 
const LVecBase3 scale
 Returns the scale component of the transform. More...
 
const LVecBase3 shear
 Returns the shear component of the transform. More...
 
- Public Attributes inherited from CachedTypedWritableReferenceCount
int cache_ref_count
 Returns the current reference count. More...
 
- Public Attributes inherited from TypedObject
TypeHandle type
 Returns the TypeHandle representing this object's type. More...
 
- Public Attributes inherited from ReferenceCount
int ref_count
 The current reference count. More...
 

Additional Inherited Members

- Public Types inherited from NodeCachedReferenceCount
enum  Referenced { R_node = 1, R_cache = 2 }
 

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.

Member Function Documentation

◆ cacheRef()

cacheRef ( )

Overrides this method to update PStats appropriately.

◆ cacheUnref()

bool cacheUnref ( )

Overrides this method to update PStats appropriately.

◆ clearCache()

static int clearCache ( )
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.

◆ compareTo() [1/2]

int compareTo ( const TransformState  other)

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.

Note that if this returns 0, it doesn't necessarily imply that operator == returns true; it uses a very slightly different comparison threshold.

◆ compareTo() [2/2]

int compareTo ( const TransformState  other,
bool  uniquify_matrix 
)

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.

Note that if this returns 0, it doesn't necessarily imply that operator == returns true; it uses a very slightly different comparison threshold.

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.

◆ componentsGiven()

bool componentsGiven ( )

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.

◆ compose()

const TransformState compose ( const TransformState  other)

Returns a new TransformState 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 TransformState object and the other TransformState 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.

◆ garbageCollect()

static int garbageCollect ( )
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.

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ getCompositionCache()

object getCompositionCache ( )

◆ getCompositionCacheNumEntries()

int getCompositionCacheNumEntries ( )

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.

◆ getCompositionCacheResult()

const TransformState getCompositionCacheResult ( int  n)

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.

◆ getCompositionCacheSize()

int getCompositionCacheSize ( )

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.

◆ getCompositionCacheSource()

const TransformState getCompositionCacheSource ( int  n)

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.

◆ getGeomRendering()

int getGeomRendering ( int  geom_rendering)

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.

◆ getHash()

int getHash ( )

Returns a suitable hash value for phash_map.

◆ getHpr()

const LVecBase3 getHpr ( )

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.

◆ getInverse()

const TransformState getInverse ( )

Returns the inverse of this transform.

If you are going to immediately compose this result with another TransformState, it is faster to do it in one operation with invert_compose().

◆ getInvertCompositionCache()

object getInvertCompositionCache ( )

◆ getInvertCompositionCacheNumEntries()

int getInvertCompositionCacheNumEntries ( )

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

◆ getInvertCompositionCacheResult()

const TransformState getInvertCompositionCacheResult ( int  n)

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.

◆ getInvertCompositionCacheSize()

int getInvertCompositionCacheSize ( )

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.

◆ getInvertCompositionCacheSource()

const TransformState getInvertCompositionCacheSource ( int  n)

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.

◆ getMat()

const LMatrix4 getMat ( )

Returns the matrix that describes the transform.

◆ getMat3()

LMatrix3 getMat3 ( )

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

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

◆ getNormQuat()

const LQuaternion getNormQuat ( )

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.

◆ getNumStates()

static int getNumStates ( )
static

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

This will go up and down during normal operations.

◆ getNumUnusedStates()

static int getNumUnusedStates ( )
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.

◆ getPos()

const LPoint3 getPos ( )

Returns the pos component of the transform.

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

◆ getPos2d()

LVecBase2 getPos2d ( )

Returns the pos component of the 2-d transform.

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

◆ getQuat()

const LQuaternion getQuat ( )

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.

◆ getRotate2d()

float getRotate2d ( )

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.

◆ getScale()

const LVecBase3 getScale ( )

Returns the scale component of the transform.

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

◆ getScale2d()

LVecBase2 getScale2d ( )

Returns the scale component of the 2-d transform.

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

◆ getShear()

const LVecBase3 getShear ( )

Returns the shear component of the transform.

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

◆ getShear2d()

float getShear2d ( )

Returns the shear component of the 2-d transform.

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

◆ getStates()

static object getStates ( )
static

◆ getUniformScale()

float getUniformScale ( )

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

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

◆ getUnique()

const TransformState getUnique ( )

Returns the pointer to the unique TransformState in the cache that is equivalent to this one.

This may be the same pointer as this object, or it may be a different pointer; but it will be an equivalent object, and it will be a shared pointer. This may be called from time to time to improve cache benefits.

◆ getUnusedStates()

static object getUnusedStates ( )
static

◆ hasComponents()

bool hasComponents ( )

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

◆ hasHpr()

bool hasHpr ( )

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.

◆ hasIdentityScale()

bool hasIdentityScale ( )

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

◆ hasMat()

bool hasMat ( )

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

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

◆ hasNonzeroShear()

bool hasNonzeroShear ( )

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

◆ hasPos()

bool hasPos ( )

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

◆ hasQuat()

bool hasQuat ( )

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.

◆ hasScale()

bool hasScale ( )

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

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

◆ hasShear()

bool hasShear ( )

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

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

◆ hasUniformScale()

bool hasUniformScale ( )

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.

◆ hprGiven()

bool hprGiven ( )

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.

◆ invertCompose()

const TransformState invertCompose ( const TransformState  other)

Returns a new TransformState 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.

◆ is2d()

bool is2d ( )

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.

◆ isIdentity()

bool isIdentity ( )

Returns true if the transform represents the identity matrix, false otherwise.

◆ isInvalid()

bool isInvalid ( )

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.

◆ isSingular()

bool isSingular ( )

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

◆ listCycles()

static listCycles ( Ostream  out)
static

Detects all of the reference-count cycles in the cache and reports them to standard output.

These cycles may be inadvertently created when state compositions cycle back to a starting point. Nowadays, these cycles should be automatically detected and broken, so this method should never list any cycles unless there is a bug in that detection logic.

The cycles listed here are not leaks in the strictest sense of the word, since they can be reclaimed by a call to clear_cache(); but they will not be reclaimed automatically.

◆ listStates()

static listStates ( 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.

◆ makeHpr()

static const TransformState makeHpr ( const LVecBase3  hpr)
static

Makes a new TransformState with the specified components.

◆ makeIdentity()

static const TransformState makeIdentity ( )
static

Constructs an identity transform.

◆ makeInvalid()

static const TransformState makeInvalid ( )
static

Constructs an invalid transform; for instance, the result of inverting a singular matrix.

◆ makeMat()

static const TransformState makeMat ( const LMatrix4  mat)
static

Makes a new TransformState with the specified transformation matrix.

◆ makeMat3()

static const TransformState makeMat3 ( const LMatrix3  mat)
static

Makes a new two-dimensional TransformState with the specified 3x3 transformation matrix.

◆ makePos()

static const TransformState makePos ( const LVecBase3  pos)
static

Makes a new TransformState with the specified components.

◆ makePos2d()

static const TransformState makePos2d ( const LVecBase2  pos)
static

Makes a new 2-d TransformState with the specified components.

◆ makePosHpr()

static const TransformState makePosHpr ( const LVecBase3  pos,
const LVecBase3  hpr 
)
static

Makes a new TransformState with the specified components.

◆ makePosHprScale()

static const TransformState makePosHprScale ( const LVecBase3  pos,
const LVecBase3  hpr,
const LVecBase3  scale 
)
static

Makes a new TransformState with the specified components.

◆ makePosHprScaleShear()

static const TransformState makePosHprScaleShear ( const LVecBase3  pos,
const LVecBase3  hpr,
const LVecBase3  scale,
const LVecBase3  shear 
)
static

Makes a new TransformState with the specified components.

◆ makePosQuatScale()

static const TransformState makePosQuatScale ( const LVecBase3  pos,
const LQuaternion  quat,
const LVecBase3  scale 
)
static

Makes a new TransformState with the specified components.

◆ makePosQuatScaleShear()

static const TransformState makePosQuatScaleShear ( const LVecBase3  pos,
const LQuaternion  quat,
const LVecBase3  scale,
const LVecBase3  shear 
)
static

Makes a new TransformState with the specified components.

◆ makePosRotate2d()

static const TransformState makePosRotate2d ( const LVecBase2  pos,
float  rotate 
)
static

Makes a new 2-d TransformState with the specified components.

◆ makePosRotateScale2d()

static const TransformState makePosRotateScale2d ( const LVecBase2  pos,
float  rotate,
const LVecBase2  scale 
)
static

Makes a new 2-d TransformState with the specified components.

◆ makePosRotateScaleShear2d()

static const TransformState makePosRotateScaleShear2d ( const LVecBase2  pos,
float  rotate,
const LVecBase2  scale,
float  shear 
)
static

Makes a new two-dimensional TransformState with the specified components.

◆ makeQuat()

static const TransformState makeQuat ( const LQuaternion  quat)
static

Makes a new TransformState with the specified components.

◆ makeRotate2d()

static const TransformState makeRotate2d ( float  rotate)
static

Makes a new 2-d TransformState with the specified components.

◆ makeScale() [1/2]

static const TransformState makeScale ( const LVecBase3  scale)
static

Makes a new TransformState with the specified components.

◆ makeScale() [2/2]

static const TransformState makeScale ( float  scale)
static

Makes a new TransformState with the specified components.

◆ makeScale2d() [1/2]

static const TransformState makeScale2d ( const LVecBase2  scale)
static

Makes a new 2-d TransformState with the specified components.

◆ makeScale2d() [2/2]

static const TransformState makeScale2d ( float  scale)
static

Makes a new 2-d TransformState with the specified components.

◆ makeShear()

static const TransformState makeShear ( const LVecBase3  shear)
static

Makes a new TransformState with the specified components.

◆ makeShear2d()

static const TransformState makeShear2d ( float  shear)
static

Makes a new 2-d TransformState with the specified components.

◆ nodeRef()

nodeRef ( )

Overrides this method to update PStats appropriately.

◆ nodeUnref()

bool nodeUnref ( )

Overrides this method to update PStats appropriately.

◆ operator !=()

bool operator != ( const TransformState  other)

◆ operator==()

bool operator== ( const TransformState  other)

◆ output()

output ( Ostream  out)

◆ quatGiven()

bool quatGiven ( )

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.

◆ setHpr()

const TransformState setHpr ( const LVecBase3  hpr)

Returns a new TransformState object that represents the original TransformState with its rotation component replaced with the indicated value, if possible.

◆ setPos()

const TransformState setPos ( const LVecBase3  pos)

Returns a new TransformState object that represents the original TransformState with its pos component replaced with the indicated value.

◆ setPos2d()

const TransformState setPos2d ( const LVecBase2  pos)

Returns a new TransformState object that represents the original 2-d TransformState with its pos component replaced with the indicated value.

◆ setQuat()

const TransformState setQuat ( const LQuaternion  quat)

Returns a new TransformState object that represents the original TransformState with its rotation component replaced with the indicated value, if possible.

◆ setRotate2d()

const TransformState setRotate2d ( float  rotate)

Returns a new TransformState object that represents the original 2-d TransformState with its rotation component replaced with the indicated value, if possible.

◆ setScale()

const TransformState setScale ( const LVecBase3  scale)

Returns a new TransformState object that represents the original TransformState with its scale component replaced with the indicated value, if possible.

◆ setScale2d()

const TransformState setScale2d ( const LVecBase2  scale)

Returns a new TransformState object that represents the original 2-d TransformState with its scale component replaced with the indicated value, if possible.

◆ setShear()

const TransformState setShear ( const LVecBase3  shear)

Returns a new TransformState object that represents the original TransformState with its shear component replaced with the indicated value, if possible.

◆ setShear2d()

const TransformState setShear2d ( float  shear)

Returns a new TransformState object that represents the original 2-d TransformState with its shear component replaced with the indicated value, if possible.

◆ validateCompositionCache()

bool validateCompositionCache ( )

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

◆ validateStates()

static bool validateStates ( )
static

Ensures that the cache is still stored in sorted order, and that none of the cache elements have been inadvertently deleted.

Returns true if so, false if there is a problem (which implies someone has modified one of the supposedly-const TransformState objects).

◆ write()

write ( Ostream  out,
int  indent_level 
)

◆ writeCompositionCache()

writeCompositionCache ( Ostream  out,
int  indent_level 
)

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.

Member Data Documentation

◆ hpr

const LVecBase3 hpr

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.

◆ mat

const LMatrix4 mat

Returns the matrix that describes the transform.

◆ norm_quat

const LQuaternion norm_quat

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.

◆ pos

const LPoint3 pos

Returns the pos component of the transform.

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

◆ quat

const LQuaternion quat

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.

◆ scale

const LVecBase3 scale

Returns the scale component of the transform.

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

◆ shear

const LVecBase3 shear

Returns the shear component of the transform.

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