Panda3D
|
This defines a single entry in a TransformBlendTable. More...
#include "transformBlend.h"
Public Member Functions | |
TransformBlend (const VertexTransform *transform0, PN_stdfloat weight0) | |
TransformBlend (const VertexTransform *transform0, PN_stdfloat weight0, const VertexTransform *transform1, PN_stdfloat weight1) | |
TransformBlend (const VertexTransform *transform0, PN_stdfloat weight0, const VertexTransform *transform1, PN_stdfloat weight1, const VertexTransform *transform2, PN_stdfloat weight2) | |
TransformBlend (const VertexTransform *transform0, PN_stdfloat weight0, const VertexTransform *transform1, PN_stdfloat weight1, const VertexTransform *transform2, PN_stdfloat weight2, const VertexTransform *transform3, PN_stdfloat weight3) | |
TransformBlend (const TransformBlend ©) | |
void | add_transform (const VertexTransform *transform, PN_stdfloat weight) |
Adds a new transform to the blend. More... | |
int | compare_to (const TransformBlend &other) const |
Defines an arbitrary ordering for TransformBlend objects. More... | |
int | complete_pointers (TypedWritable **plist, BamReader *manager) |
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). More... | |
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 PandaNode. More... | |
void | get_blend (LMatrix4 &result, Thread *current_thread) const |
Returns the current value of the blend, based on the current value of all of the nested transform objects and their associated weights. More... | |
UpdateSeq | get_modified (Thread *current_thread) const |
Returns a counter which is guaranteed to increment at least as often as the result of get_blend() changes. More... | |
int | get_num_transforms () const |
Returns the number of transforms stored in the blend object. More... | |
const VertexTransform * | get_transform (int n) const |
Returns the nth transform stored in the blend object. More... | |
PN_stdfloat | get_weight (const VertexTransform *transform) const |
Returns the weight associated with the indicated transform, or 0 if there is no entry for the transform. More... | |
PN_stdfloat | get_weight (int n) const |
Returns the weight associated with the nth transform stored in the blend object. More... | |
bool | has_transform (const VertexTransform *transform) const |
Returns true if the blend has the indicated transform, false otherwise. More... | |
void | limit_transforms (int max_transforms) |
If the total number of transforms in the blend exceeds max_transforms, removes the n least-important transforms as needed to reduce the number of transforms to max_transforms. More... | |
MAKE_SEQ (get_transforms, get_num_transforms, get_transform) | |
void | normalize_weights () |
Rescales all of the weights on the various transforms so that they sum to 1.0. More... | |
bool | operator!= (const TransformBlend &other) const |
bool | operator< (const TransformBlend &other) const |
void | operator= (const TransformBlend ©) |
bool | operator== (const TransformBlend &other) const |
void | output (ostream &out) const |
void | remove_transform (const VertexTransform *transform) |
Removes the indicated transform from the blend. More... | |
void | set_transform (int n, const VertexTransform *transform) |
Replaces the nth transform stored in the blend object. More... | |
void | set_weight (int n, PN_stdfloat weight) |
Replaces the weight associated with the nth transform stored in the blend object. More... | |
void | transform_point (LPoint4f &point, Thread *current_thread) const |
Transforms the indicated point by the blend matrix. More... | |
void | transform_point (LPoint3f &point, Thread *current_thread) const |
Transforms the indicated point by the blend matrix. More... | |
void | transform_point (LPoint4d &point, Thread *current_thread) const |
Transforms the indicated point by the blend matrix. More... | |
void | transform_point (LPoint3d &point, Thread *current_thread) const |
Transforms the indicated point by the blend matrix. More... | |
void | transform_vector (LVector3f &point, Thread *current_thread) const |
Transforms the indicated vector by the blend matrix. More... | |
void | transform_vector (LVector3d &point, Thread *current_thread) const |
Transforms the indicated vector by the blend matrix. More... | |
void | update_blend (Thread *current_thread) const |
Recomputes the internal representation of the blend value, if necessary. More... | |
void | write (ostream &out, int indent_level) const |
void | write_datagram (BamWriter *manager, Datagram &dg) const |
Writes the contents of this object to the datagram for shipping out to a Bam file. More... | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Friends | |
class | VertexTransform |
This defines a single entry in a TransformBlendTable.
It represents a unique combination of VertexTransform pointers and blend amounts.
Definition at line 36 of file transformBlend.h.
void TransformBlend::add_transform | ( | const VertexTransform * | transform, |
PN_stdfloat | weight | ||
) |
Adds a new transform to the blend.
If the transform already existed, increases its weight factor.
Definition at line 58 of file transformBlend.cxx.
References Thread::get_current_thread(), and remove_transform().
Referenced by compare_to(), and EggLoader::make_polyset().
int TransformBlend::compare_to | ( | const TransformBlend & | other | ) | const |
Defines an arbitrary ordering for TransformBlend objects.
Definition at line 29 of file transformBlend.cxx.
References add_transform(), ordered_vector< Key, Compare, Vector >::begin(), ordered_vector< Key, Compare, Vector >::end(), and ordered_vector< Key, Compare, Vector >::size().
int TransformBlend::complete_pointers | ( | TypedWritable ** | p_list, |
BamReader * | manager | ||
) |
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Returns the number of pointers processed.
Definition at line 302 of file transformBlend.cxx.
References ordered_vector< Key, Compare, Vector >::begin(), ordered_vector< Key, Compare, Vector >::end(), fillin(), and ov_set< Key, Compare, Vector >::sort().
Referenced by write_datagram().
void TransformBlend::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 PandaNode.
Definition at line 325 of file transformBlend.cxx.
References DatagramIterator::get_stdfloat(), DatagramIterator::get_uint16(), ordered_vector< Key, Compare, Vector >::push_back(), BamReader::read_pointer(), and ordered_vector< Key, Compare, Vector >::reserve().
Referenced by complete_pointers(), and TransformBlendTable::complete_pointers().
Returns the current value of the blend, based on the current value of all of the nested transform objects and their associated weights.
You should call update_blend() to ensure that the cache is up-to-date before calling this.
Definition at line 228 of file transformBlend.I.
References transform_point().
Referenced by EggSaver::add_node(), GeomVertexData::copy_from(), get_weight(), and update_blend().
Returns a counter which is guaranteed to increment at least as often as the result of get_blend() changes.
Definition at line 390 of file transformBlend.I.
References VertexTransform::get_global_modified(), and LMatrix4f::ident_mat().
Referenced by transform_vector().
|
inline |
Returns the number of transforms stored in the blend object.
Definition at line 149 of file transformBlend.I.
References get_transform(), and ordered_vector< Key, Compare, Vector >::size().
Referenced by TransformBlendTable::add_blend(), EggSaver::add_node(), GeomVertexData::copy_from(), and Character::force_update().
|
inline |
Returns the nth transform stored in the blend object.
Definition at line 160 of file transformBlend.I.
References get_weight(), and ordered_vector< Key, Compare, Vector >::size().
Referenced by TransformBlendTable::add_blend(), EggSaver::add_node(), GeomVertexData::copy_from(), Character::force_update(), and get_num_transforms().
PN_stdfloat TransformBlend::get_weight | ( | const VertexTransform * | transform | ) | const |
Returns the weight associated with the indicated transform, or 0 if there is no entry for the transform.
Definition at line 176 of file transformBlend.cxx.
References ordered_vector< Key, Compare, Vector >::begin(), ordered_vector< Key, Compare, Vector >::empty(), ordered_vector< Key, Compare, Vector >::end(), get_blend(), Thread::get_current_thread(), VertexTransform::get_global_modified(), LMatrix4f::ident_mat(), update_blend(), write_datagram(), and LMatrix4f::zeros_mat().
Referenced by EggSaver::add_node(), GeomVertexData::copy_from(), get_transform(), and has_transform().
|
inline |
Returns the weight associated with the nth transform stored in the blend object.
Definition at line 172 of file transformBlend.I.
References set_transform(), and ordered_vector< Key, Compare, Vector >::size().
bool TransformBlend::has_transform | ( | const VertexTransform * | transform | ) | const |
Returns true if the blend has the indicated transform, false otherwise.
Definition at line 160 of file transformBlend.cxx.
References ordered_vector< Key, Compare, Vector >::end(), and get_weight().
Referenced by normalize_weights().
void TransformBlend::limit_transforms | ( | int | max_transforms | ) |
If the total number of transforms in the blend exceeds max_transforms, removes the n least-important transforms as needed to reduce the number of transforms to max_transforms.
Definition at line 106 of file transformBlend.cxx.
References ordered_vector< Key, Compare, Vector >::begin(), ordered_vector< Key, Compare, Vector >::clear(), ordered_vector< Key, Compare, Vector >::empty(), ordered_vector< Key, Compare, Vector >::end(), normalize_weights(), and ordered_vector< Key, Compare, Vector >::size().
Referenced by EggLoader::make_polyset(), and remove_transform().
void TransformBlend::normalize_weights | ( | ) |
Rescales all of the weights on the various transforms so that they sum to 1.0.
It is generally a good idea to call this after adding or removing transforms from the blend.
Definition at line 138 of file transformBlend.cxx.
References ordered_vector< Key, Compare, Vector >::begin(), ordered_vector< Key, Compare, Vector >::end(), Thread::get_current_thread(), and has_transform().
Referenced by limit_transforms(), and EggLoader::make_polyset().
void TransformBlend::remove_transform | ( | const VertexTransform * | transform | ) |
Removes the indicated transform from the blend.
Definition at line 85 of file transformBlend.cxx.
References ordered_vector< Key, Compare, Vector >::end(), Thread::get_current_thread(), and limit_transforms().
Referenced by add_transform().
|
inline |
Replaces the nth transform stored in the blend object.
Definition at line 184 of file transformBlend.I.
References set_weight(), and ordered_vector< Key, Compare, Vector >::size().
Referenced by Character::force_update(), and get_weight().
|
inline |
Replaces the weight associated with the nth transform stored in the blend object.
Definition at line 196 of file transformBlend.I.
References ordered_vector< Key, Compare, Vector >::size(), and update_blend().
Referenced by set_transform().
Transforms the indicated point by the blend matrix.
You should call update_blend() to ensure that the cache is up-to-date before calling this.
Definition at line 242 of file transformBlend.I.
References ordered_vector< Key, Compare, Vector >::empty().
Referenced by get_blend(), transform_point(), and transform_vector().
Transforms the indicated point by the blend matrix.
You should call update_blend() to ensure that the cache is up-to-date before calling this.
Definition at line 258 of file transformBlend.I.
References ordered_vector< Key, Compare, Vector >::empty(), and transform_vector().
Transforms the indicated point by the blend matrix.
You should call update_blend() to ensure that the cache is up-to-date before calling this.
Definition at line 291 of file transformBlend.I.
References ordered_vector< Key, Compare, Vector >::empty(), and transform_point().
Transforms the indicated point by the blend matrix.
You should call update_blend() to ensure that the cache is up-to-date before calling this.
Definition at line 325 of file transformBlend.I.
References ordered_vector< Key, Compare, Vector >::empty(), transform_point(), and transform_vector().
Transforms the indicated vector by the blend matrix.
You should call update_blend() to ensure that the cache is up-to-date before calling this.
Definition at line 274 of file transformBlend.I.
References ordered_vector< Key, Compare, Vector >::empty(), and transform_point().
Referenced by transform_point(), and transform_vector().
Transforms the indicated vector by the blend matrix.
You should call update_blend() to ensure that the cache is up-to-date before calling this.
Definition at line 359 of file transformBlend.I.
References ordered_vector< Key, Compare, Vector >::empty(), get_modified(), and transform_vector().
|
inline |
Recomputes the internal representation of the blend value, if necessary.
You should call this before calling get_blend() or transform_point().
Definition at line 209 of file transformBlend.I.
References get_blend(), and VertexTransform::get_global_modified().
Referenced by get_weight(), and set_weight().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition at line 284 of file transformBlend.cxx.
References Datagram::add_stdfloat(), Datagram::add_uint16(), ordered_vector< Key, Compare, Vector >::begin(), complete_pointers(), ordered_vector< Key, Compare, Vector >::end(), ordered_vector< Key, Compare, Vector >::size(), and BamWriter::write_pointer().
Referenced by get_weight().