|
Panda3D
|
Indicates a coordinate-system transform on vertices. More...
#include "transformState.h"
Public Member Functions | |
| TransformState (const TransformState ©)=delete | |
| virtual | ~TransformState () |
| The destructor is responsible for removing the TransformState from the global set if it is there. | |
| void | cache_ref () const |
| void | cache_ref_only () const |
| Overrides this method to update PStats appropriately. | |
| bool | cache_unref () const |
| 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. | |
| 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. | |
| 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) compose(const TransformState *other) const | |
| CPT (TransformState) get_inverse() const | |
| CPT (TransformState) get_unique() const | |
| CPT (TransformState) invert_compose(const TransformState *other) const | |
| CPT (TransformState) set_hpr(const LVecBase3 &hpr) const | |
| CPT (TransformState) set_pos(const LVecBase3 &pos) const | |
| CPT (TransformState) set_pos2d(const LVecBase2 &pos) const | |
| CPT (TransformState) set_quat(const LQuaternion &quat) const | |
| CPT (TransformState) set_rotate2d(PN_stdfloat rotate) const | |
| CPT (TransformState) set_scale(const LVecBase3 &scale) const | |
| CPT (TransformState) set_scale2d(const LVecBase2 &scale) const | |
| CPT (TransformState) set_shear(const LVecBase3 &shear) const | |
| CPT (TransformState) set_shear2d(PN_stdfloat shear) const | |
| virtual TypeHandle | force_init_type () |
| size_t | get_composition_cache_num_entries () const |
| const TransformState * | get_composition_cache_result (size_t n) const |
| size_t | get_composition_cache_size () const |
| const TransformState * | get_composition_cache_source (size_t n) const |
| int | get_geom_rendering (int geom_rendering) const |
| size_t | get_hash () const |
| Returns a suitable hash value for phash_map. | |
| const LVecBase3 & | get_hpr () const |
| size_t | get_invert_composition_cache_num_entries () const |
| const TransformState * | get_invert_composition_cache_result (size_t n) const |
| size_t | get_invert_composition_cache_size () const |
| const TransformState * | get_invert_composition_cache_source (size_t n) const |
| const LMatrix4 & | get_mat () const |
| LMatrix3 | get_mat3 () const |
| Returns the 3x3 matrix that describes the 2-d transform. | |
| const LQuaternion & | get_norm_quat () const |
| const LPoint3 & | get_pos () const |
| LVecBase2 | get_pos2d () const |
| Returns the pos component of the 2-d transform. | |
| const LQuaternion & | get_quat () const |
| PN_stdfloat | get_rotate2d () const |
| Returns the rotation component of the 2-d transform as an angle in degrees clockwise about the origin. | |
| const LVecBase3 & | get_scale () const |
| LVecBase2 | get_scale2d () const |
| Returns the scale component of the 2-d transform. | |
| const LVecBase3 & | get_shear () const |
| 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 |
| bool | node_unref () const |
| bool | operator!= (const TransformState &other) const |
| Opposite of operator ==. | |
| TransformState & | operator= (const TransformState ©)=delete |
| bool | operator== (const TransformState &other) const |
| Tests equivalence between two transform states. | |
| void | output (std::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 (std::ostream &out, int indent_level) const |
| void | write_composition_cache (std::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. | |
Public Member Functions inherited from NodeCachedReferenceCount | |
| int | get_node_ref_count () const |
| Returns the current reference count. | |
| int | get_referenced_bits () const |
| 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. | |
| void | node_ref () const |
| Explicitly increments the reference count. | |
| bool | node_unref () const |
| Explicitly decrements the node reference count and the normal reference count simultaneously. | |
| bool | test_ref_count_integrity () const |
| Does some easy checks to make sure that the reference count isn't completely bogus. | |
Public Member Functions inherited from CachedTypedWritableReferenceCount | |
| void | cache_ref () const |
| Explicitly increments the cache reference count and the normal reference count simultaneously. | |
| void | cache_ref_only () const |
| Decrements the cache reference count without affecting the normal reference count. | |
| bool | cache_unref () const |
| Explicitly decrements the cache reference count and the normal reference count simultaneously. | |
| int | get_cache_ref_count () const |
| bool | test_ref_count_integrity () const |
| Does some easy checks to make sure that the reference count isn't completely bogus. | |
Public Member Functions inherited from TypedWritableReferenceCount | |
| TypedWritableReferenceCount (const TypedWritableReferenceCount ©) | |
| virtual ReferenceCount * | as_reference_count () |
| Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. | |
| void | operator= (const TypedWritableReferenceCount ©) |
Public Member Functions inherited from TypedWritable | |
| TypedWritable (const TypedWritable ©) | |
| virtual int | complete_pointers (TypedWritable **p_list, BamReader *manager) |
| Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). | |
| vector_uchar | encode_to_bam_stream () const |
| Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. | |
| bool | encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) const |
| Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. | |
| virtual void | finalize (BamReader *manager) |
| 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. | |
| UpdateSeq | get_bam_modified () const |
| Returns the current bam_modified counter. | |
| void | mark_bam_modified () |
| Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. | |
| void | operator= (const TypedWritable ©) |
| virtual bool | require_fully_complete () const |
| Some objects require all of their nested pointers to have been completed before the objects themselves can be completed. | |
| virtual void | update_bam_nested (BamWriter *manager) |
| Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. | |
Public Member Functions inherited from TypedObject | |
| TypedObject (const TypedObject ©)=default | |
| TypedObject * | as_typed_object () |
| Returns the object, upcast (if necessary) to a TypedObject pointer. | |
| const TypedObject * | as_typed_object () const |
| Returns the object, upcast (if necessary) to a TypedObject pointer. | |
| int | get_best_parent_from_Set (const std::set< int > &) const |
| 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_exact_type (TypeHandle handle) const |
| Returns true if the current object is the indicated type exactly. | |
| bool | is_of_type (TypeHandle handle) const |
| Returns true if the current object is or derives from the indicated type. | |
| TypedObject & | operator= (const TypedObject ©)=default |
Public Member Functions inherited from MemoryBase | |
| void | operator delete (void *, void *) |
| void | operator delete (void *ptr) |
| void | operator delete[] (void *, void *) |
| void | operator delete[] (void *ptr) |
| void * | operator new (size_t size) |
| void * | operator new (size_t size, void *ptr) |
| void * | operator new[] (size_t size) |
| void * | operator new[] (size_t size, void *ptr) |
Public Member Functions inherited from ReferenceCount | |
| int | get_ref_count () const |
| WeakReferenceList * | get_weak_list () const |
| Returns the WeakReferenceList associated with this ReferenceCount object. | |
| bool | has_weak_list () const |
| Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. | |
| void | local_object () |
| This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. | |
| void | ref () const |
| Explicitly increments the reference count. | |
| bool | ref_if_nonzero () const |
| Atomically increases the reference count of this object if it is not zero. | |
| bool | test_ref_count_integrity () const |
| Does some easy checks to make sure that the reference count isn't completely bogus. | |
| bool | test_ref_count_nonzero () const |
| Does some easy checks to make sure that the reference count isn't zero, or completely bogus. | |
| bool | unref_if_one () const |
| Atomically decreases the reference count of this object if it is one. | |
| WeakReferenceList * | weak_ref () |
| Adds the indicated PointerToVoid as a weak reference to this object. | |
| void | weak_unref () |
| Removes the indicated PointerToVoid as a weak reference to this object. | |
Static Public Member Functions | |
| static int | clear_cache () |
| Empties the cache of composed TransformStates. | |
| static | CPT (TransformState) make_hpr(const LVecBase3 &hpr) |
| static | CPT (TransformState) make_identity() |
| static | CPT (TransformState) make_invalid() |
| static | CPT (TransformState) make_mat(const LMatrix4 &mat) |
| static | CPT (TransformState) make_mat3(const LMatrix3 &mat) |
| static | CPT (TransformState) make_pos(const LVecBase3 &pos) |
| static | CPT (TransformState) make_pos2d(const LVecBase2 &pos) |
| static | CPT (TransformState) make_pos_hpr(const LVecBase3 &pos |
| static | CPT (TransformState) make_pos_hpr_scale(const LVecBase3 &pos |
| static | CPT (TransformState) make_pos_hpr_scale_shear(const LVecBase3 &pos |
| static | CPT (TransformState) make_pos_quat_scale(const LVecBase3 &pos |
| static | CPT (TransformState) make_pos_quat_scale_shear(const LVecBase3 &pos |
| static | CPT (TransformState) make_pos_rotate2d(const LVecBase2 &pos |
| static | CPT (TransformState) make_pos_rotate_scale2d(const LVecBase2 &pos |
| static | CPT (TransformState) make_pos_rotate_scale_shear2d(const LVecBase2 &pos |
| static | CPT (TransformState) make_quat(const LQuaternion &quat) |
| static | CPT (TransformState) make_rotate2d(PN_stdfloat rotate) |
| static | CPT (TransformState) make_scale(const LVecBase3 &scale) |
| static | CPT (TransformState) make_scale(PN_stdfloat scale) |
| static | CPT (TransformState) make_scale2d(const LVecBase2 &scale) |
| static | CPT (TransformState) make_scale2d(PN_stdfloat scale) |
| static | CPT (TransformState) make_shear(const LVecBase3 &shear) |
| static | CPT (TransformState) make_shear2d(PN_stdfloat shear) |
| static void | flush_level () |
| 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 (std::ostream &out) |
| Detects all of the reference-count cycles in the cache and reports them to standard output. | |
| static void | list_states (std::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. | |
Static Public Member Functions inherited from NodeCachedReferenceCount | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
Static Public Member Functions inherited from CachedTypedWritableReferenceCount | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
Static Public Member Functions inherited from TypedWritableReferenceCount | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
| static | PT (TypedWritableReferenceCount) decode_from_bam_stream(vector_uchar data |
Static Public Member Functions inherited from TypedWritable | |
| static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr) |
| Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes. | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
Static Public Member Functions inherited from TypedObject | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
| This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
Static Public Member Functions inherited from ReferenceCount | |
| static TypeHandle | get_class_type () |
| static void | init_type () |
Public Attributes | |
| get_hpr | |
| Returns the rotation component of the transform as a trio of Euler angles. | |
| get_mat | |
| Returns the matrix that describes the transform. | |
| get_norm_quat | |
| Returns the rotation component of the transform as a quaternion. | |
| get_pos | |
| Returns the pos component of the transform. | |
| get_quat | |
| Returns the rotation component of the transform as a quaternion. | |
| get_scale | |
| Returns the scale component of the transform. | |
| get_shear | |
| Returns the shear component of the transform. | |
| static const LVecBase3 & | hpr |
| static BamReader * | manager |
| static const LQuaternion & | quat |
| static PN_stdfloat | rotate |
| static const LVecBase3 const LVecBase3 & | scale |
| static const LQuaternion const LVecBase3 & | scale |
| static PN_stdfloat const LVecBase2 & | scale |
| static const LVecBase3 const LVecBase3 const LVecBase3 & | shear |
| static const LQuaternion const LVecBase3 const LVecBase3 & | shear |
| static PN_stdfloat const LVecBase2 PN_stdfloat | shear |
Public Attributes inherited from CachedTypedWritableReferenceCount | |
| get_cache_ref_count | |
| Returns the current reference count. | |
Public Attributes inherited from TypedWritableReferenceCount | |
| static BamReader * | reader = nullptr) |
Public Attributes inherited from TypedObject | |
| get_type | |
Public Attributes inherited from ReferenceCount | |
| get_ref_count | |
| Returns the current reference count. | |
Friends | |
| class | Extension< TransformState > |
Additional Inherited Members | |
Public Types inherited from NodeCachedReferenceCount | |
| enum | Referenced { R_node = 0x001 , R_cache = 0x002 } |
Static Public Attributes inherited from TypedWritable | |
| static TypedWritable *const | Null = nullptr |
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 54 of file transformState.h.
|
virtual |
The destructor is responsible for removing the TransformState from the global set if it is there.
Definition at line 77 of file transformState.cxx.
References ReferenceCount::get_ref_count.
|
inline |
Overrides this method to update PStats appropriately.
Definition at line 759 of file transformState.I.
References CachedTypedWritableReferenceCount::cache_ref_only(), and NodeCachedReferenceCount::get_referenced_bits().
|
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 1104 of file transformState.cxx.
References SimpleHashMap< Key, Value, Compare >::clear(), SimpleHashMap< Key, Value, Compare >::get_data(), SimpleHashMap< Key, Value, Compare >::get_num_entries(), and ReferenceCount::get_ref_count.
|
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.
Note that if this returns 0, it doesn't necessarily imply that operator == returns true; it uses a very slightly different comparison threshold.
Definition at line 29 of file transformState.I.
References compare_to().
Referenced by compare_to().
| 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.
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.
Definition at line 116 of file transformState.cxx.
References get_mat.
|
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 259 of file transformState.I.
|
inlinevirtual |
Reimplemented from TypedWritableReferenceCount.
Definition at line 415 of file transformState.h.
|
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 1174 of file transformState.cxx.
References CachedTypedWritableReferenceCount::get_cache_ref_count, ReferenceCount::get_ref_count, and ReferenceCount::unref_if_one().
Referenced by PandaFramework::task_garbage_collect().
|
inlinestatic |
Definition at line 404 of file transformState.h.
|
inline |
Returns a suitable hash value for phash_map.
Definition at line 37 of file transformState.I.
|
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 525 of file transformState.I.
|
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 989 of file transformState.cxx.
Referenced by GraphicsEngine::render_frame().
|
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 1011 of file transformState.cxx.
References CachedTypedWritableReferenceCount::get_cache_ref_count, SimpleHashMap< Key, Value, Compare >::get_data(), SimpleHashMap< Key, Value, Compare >::get_num_entries(), and ReferenceCount::get_ref_count.
Referenced by GraphicsEngine::render_frame().
|
inline |
|
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 482 of file transformState.I.
References is_2d(), and is_invalid().
|
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 503 of file transformState.I.
References is_2d(), and is_invalid().
|
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 514 of file transformState.I.
References is_2d(), and is_invalid().
|
inlinevirtual |
Reimplemented from TypedWritableReferenceCount.
Definition at line 412 of file transformState.h.
|
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 438 of file transformState.I.
References has_uniform_scale().
Referenced by STTransform::STTransform().
|
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 245 of file transformState.I.
Referenced by STTransform::STTransform(), CompassEffect::adjust_transform(), has_hpr(), has_quat(), has_scale(), and has_shear().
|
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 299 of file transformState.I.
References has_components().
|
inline |
Returns true if the scale is uniform 1.0, or false if the scale has some real value.
Definition at line 327 of file transformState.I.
|
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 367 of file transformState.I.
References is_invalid().
Referenced by get_mat3().
|
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 357 of file transformState.I.
|
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 289 of file transformState.I.
References is_invalid().
Referenced by get_pos2d().
|
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 309 of file transformState.I.
References has_components().
|
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 318 of file transformState.I.
References has_components().
|
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 348 of file transformState.I.
References has_components().
|
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 338 of file transformState.I.
Referenced by STTransform::STTransform(), and get_uniform_scale().
|
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 269 of file transformState.I.
|
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 1425 of file transformState.cxx.
References Thread::get_current_thread, and Thread::get_main_thread.
Referenced by init_libpgraph().
|
inlinestatic |
Definition at line 407 of file transformState.h.
|
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 226 of file transformState.I.
Referenced by get_mat3(), get_pos2d(), get_rotate2d(), get_scale2d(), and get_shear2d().
|
inline |
Returns true if the transform represents the identity matrix, false otherwise.
Definition at line 196 of file transformState.I.
Referenced by BulletTriangleMesh::add_geom(), GeomNode::apply_attribs_to_vertices(), CollisionLevelState< MaskType >::apply_transform(), and CullTraverserData::apply_transform().
|
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 206 of file transformState.I.
Referenced by get_rotate2d(), get_scale2d(), get_shear2d(), has_mat(), has_pos(), PandaNode::set_prev_transform(), and BulletWorld::sweep_test_closest().
|
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 215 of file transformState.I.
Referenced by CullTraverserData::apply_transform().
|
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 1267 of file transformState.cxx.
References ReferenceCount::get_ref_count.
|
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 1344 of file transformState.cxx.
|
inline |
| bool TransformState::operator== | ( | const TransformState & | other | ) | const |
Tests equivalence between two transform states.
We use this instead of compare_to since this is faster, and we don't need an ordering between TransformStates because we use a hash map.
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 185 of file transformState.cxx.
References get_mat.
Referenced by operator!=().
| void TransformState::output | ( | std::ostream & | out | ) | const |
Definition at line 881 of file transformState.cxx.
|
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 279 of file transformState.I.
|
static |
Tells the BamReader how to create objects of type TransformState.
Definition at line 2282 of file transformState.cxx.
References BamReader::get_factory(), and Factory< Type >::register_factory().
Referenced by init_libpgraph().
|
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 785 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 831 of file transformState.cxx.
References SimpleHashMap< Key, Value, Compare >::find().
Referenced by 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 1366 of file transformState.cxx.
References validate_composition_cache().
| void TransformState::write | ( | std::ostream & | out, |
| int | indent_level ) const |
Definition at line 969 of file transformState.cxx.
| void TransformState::write_composition_cache | ( | std::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 979 of file transformState.cxx.
References indent().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from TypedWritable.
Definition at line 2291 of file transformState.cxx.
References Datagram::add_uint32(), get_hpr, and TypedWritable::write_datagram().
|
friend |
Definition at line 418 of file transformState.h.
|
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 163 of file transformState.h.
Referenced by STTransform::STTransform(), PartGroup::apply_freeze(), and write_datagram().
|
inline |
Returns the matrix that describes the transform.
Definition at line 168 of file transformState.h.
Referenced by ShaderTerrainMesh::add_for_draw(), BulletTriangleMesh::add_geom(), Fog::adjust_to_camera(), GeomNode::apply_attribs_to_vertices(), CullPlanes::apply_state(), CollisionLevelState< MaskType >::apply_transform(), DXGraphicsStateGuardian9::bind_light(), DXGraphicsStateGuardian9::bind_light(), DXGraphicsStateGuardian9::bind_light(), compare_to(), NodePath::do_billboard_axis(), NodePath::do_billboard_point_eye(), NodePath::do_billboard_point_world(), GraphicsStateGuardian::fetch_specified_member(), NodePath::get_relative_point(), NodePath::get_relative_vector(), ShaderAttrib::get_shader_input_matrix(), NodePath::heads_up(), NodePath::look_at(), operator==(), PortalClipper::prepare_portal(), PT(), ProjectionScreen::recompute_if_stale(), BulletWorld::sweep_test_closest(), and PSSMCameraRig::update().
|
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 165 of file transformState.h.
|
inline |
Returns the pos component of the transform.
It is an error to call this if has_pos() returned false.
Definition at line 162 of file transformState.h.
Referenced by STTransform::STTransform(), CompassEffect::adjust_transform(), PartGroup::apply_freeze(), NodePath::get_pos(), NodePath::get_pos(), NodePath::get_pos_delta(), NodePath::get_pos_delta(), and BulletWorld::sweep_test_closest().
|
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 164 of file transformState.h.
Referenced by CompassEffect::adjust_transform().
|
inline |
Returns the scale component of the transform.
It is an error to call this if has_components() returned false.
Definition at line 166 of file transformState.h.
Referenced by CompassEffect::adjust_transform(), and PartGroup::apply_freeze().
|
inline |
Returns the shear component of the transform.
It is an error to call this if has_components() returned false.
Definition at line 167 of file transformState.h.
| static const LVecBase3 & TransformState::hpr |
Definition at line 78 of file transformState.h.
| BamReader* TransformState::manager |
Definition at line 397 of file transformState.h.
| static const LQuaternion & TransformState::quat |
Definition at line 86 of file transformState.h.
| static PN_stdfloat TransformState::rotate |
Definition at line 102 of file transformState.h.
| static PN_stdfloat const LVecBase2 & TransformState::scale |
Definition at line 84 of file transformState.h.
| const LQuaternion const LVecBase3& TransformState::scale |
Definition at line 87 of file transformState.h.
| PN_stdfloat const LVecBase2& TransformState::scale |
Definition at line 108 of file transformState.h.
| const LVecBase3 const LVecBase3 const LVecBase3& TransformState::shear |
Definition at line 91 of file transformState.h.
| const LQuaternion const LVecBase3 const LVecBase3& TransformState::shear |
Definition at line 95 of file transformState.h.
| PN_stdfloat const LVecBase2 PN_stdfloat TransformState::shear |
Definition at line 112 of file transformState.h.