Panda3D
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
TransformBlend Class Reference

This defines a single entry in a TransformBlendTable. More...

#include "transformBlend.h"

Public Member Functions

 TransformBlend (const TransformBlend &copy)
 
 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)
 
void add_transform (const VertexTransform *transform, PN_stdfloat weight)
 Adds a new transform to the blend.
 
int compare_to (const TransformBlend &other) const
 Defines an arbitrary ordering for TransformBlend objects.
 
int complete_pointers (TypedWritable **plist, BamReader *manager)
 Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
 
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.
 
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.
 
UpdateSeq get_modified (Thread *current_thread=Thread::get_current_thread()) const
 
size_t get_num_transforms () const
 
const VertexTransformget_transform (size_t n) const
 
PN_stdfloat get_weight (const VertexTransform *transform) const
 
PN_stdfloat get_weight (size_t n) const
 
bool has_transform (const VertexTransform *transform) const
 
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.
 
void normalize_weights ()
 Rescales all of the weights on the various transforms so that they sum to 1.0.
 
bool operator!= (const TransformBlend &other) const
 
bool operator< (const TransformBlend &other) const
 
void operator= (const TransformBlend &copy)
 
bool operator== (const TransformBlend &other) const
 
void output (std::ostream &out) const
 
void remove_transform (const VertexTransform *transform)
 
void remove_transform (size_t n)
 
void set_transform (size_t n, const VertexTransform *transform)
 
void set_weight (size_t n, PN_stdfloat weight)
 Replaces the weight associated with the nth transform stored in the blend object.
 
void transform_point (LPoint3d &point, Thread *current_thread) const
 Transforms the indicated point by the blend matrix.
 
void transform_point (LPoint3f &point, Thread *current_thread) const
 Transforms the indicated point by the blend matrix.
 
void transform_point (LPoint4d &point, Thread *current_thread) const
 Transforms the indicated point by the blend matrix.
 
void transform_point (LPoint4f &point, Thread *current_thread) const
 Transforms the indicated point by the blend matrix.
 
void transform_vector (LVector3d &point, Thread *current_thread) const
 Transforms the indicated vector by the blend matrix.
 
void transform_vector (LVector3f &point, Thread *current_thread) const
 Transforms the indicated vector by the blend matrix.
 
void update_blend (Thread *current_thread) const
 Recomputes the internal representation of the blend value, if necessary.
 
void write (std::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.
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 

Public Attributes

 get_modified
 Returns a counter which is guaranteed to increment at least as often as the result of get_blend() changes.
 
 get_num_transforms
 Returns the number of transforms stored in the blend object.
 
 get_transform
 Returns the nth transform stored in the blend object.
 
 get_weight
 Returns the weight associated with the indicated transform, or 0 if there is no entry for the transform.
 
 has_transform
 Returns true if the blend has the indicated transform, false otherwise.
 
 remove_transform
 Removes the indicated transform from the blend.
 
 set_transform
 Replaces the nth transform stored in the blend object.
 

Friends

class VertexTransform
 

Detailed Description

This defines a single entry in a TransformBlendTable.

It represents a unique combination of VertexTransform pointers and blend amounts.

Definition at line 32 of file transformBlend.h.

Constructor & Destructor Documentation

◆ TransformBlend() [1/6]

TransformBlend::TransformBlend ( )
inline

Definition at line 17 of file transformBlend.I.

◆ TransformBlend() [2/6]

TransformBlend::TransformBlend ( const VertexTransform * transform0,
PN_stdfloat weight0 )
inline

Definition at line 24 of file transformBlend.I.

◆ TransformBlend() [3/6]

TransformBlend::TransformBlend ( const VertexTransform * transform0,
PN_stdfloat weight0,
const VertexTransform * transform1,
PN_stdfloat weight1 )
inline

Definition at line 32 of file transformBlend.I.

◆ TransformBlend() [4/6]

TransformBlend::TransformBlend ( const VertexTransform * transform0,
PN_stdfloat weight0,
const VertexTransform * transform1,
PN_stdfloat weight1,
const VertexTransform * transform2,
PN_stdfloat weight2 )
inline

Definition at line 43 of file transformBlend.I.

◆ TransformBlend() [5/6]

TransformBlend::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 )
inline

Definition at line 56 of file transformBlend.I.

◆ TransformBlend() [6/6]

TransformBlend::TransformBlend ( const TransformBlend & copy)
inline

Definition at line 71 of file transformBlend.I.

◆ ~TransformBlend()

TransformBlend::~TransformBlend ( )
inline

Definition at line 90 of file transformBlend.I.

Member Function Documentation

◆ add_transform()

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 51 of file transformBlend.cxx.

References Thread::get_current_thread.

◆ compare_to()

int TransformBlend::compare_to ( const TransformBlend & other) const

◆ complete_pointers()

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 267 of file transformBlend.cxx.

References ordered_vector< Key, Compare, Vector >::begin(), ordered_vector< Key, Compare, Vector >::end(), and ov_set< Key, Compare, Vector >::sort().

◆ fillin()

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

◆ get_blend()

void TransformBlend::get_blend ( LMatrix4 & result,
Thread * current_thread ) const
inline

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 195 of file transformBlend.I.

Referenced by GeomVertexData::copy_from().

◆ get_class_type()

static TypeHandle TransformBlend::get_class_type ( )
inlinestatic

Definition at line 137 of file transformBlend.h.

◆ init_type()

static void TransformBlend::init_type ( )
inlinestatic

Definition at line 140 of file transformBlend.h.

◆ limit_transforms()

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 94 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(), and ordered_vector< Key, Compare, Vector >::size().

Referenced by GeomVertexData::copy_from().

◆ normalize_weights()

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 123 of file transformBlend.cxx.

References ordered_vector< Key, Compare, Vector >::begin(), ordered_vector< Key, Compare, Vector >::end(), and Thread::get_current_thread.

Referenced by GeomVertexData::copy_from().

◆ operator!=()

bool TransformBlend::operator!= ( const TransformBlend & other) const
inline

Definition at line 113 of file transformBlend.I.

◆ operator<()

bool TransformBlend::operator< ( const TransformBlend & other) const
inline

Definition at line 97 of file transformBlend.I.

◆ operator=()

void TransformBlend::operator= ( const TransformBlend & copy)
inline

Definition at line 80 of file transformBlend.I.

◆ operator==()

bool TransformBlend::operator== ( const TransformBlend & other) const
inline

Definition at line 105 of file transformBlend.I.

◆ output()

void TransformBlend::output ( std::ostream & out) const

Definition at line 170 of file transformBlend.cxx.

◆ set_weight()

void TransformBlend::set_weight ( size_t n,
PN_stdfloat weight )
inline

Replaces the weight associated with the nth transform stored in the blend object.

Definition at line 169 of file transformBlend.I.

References ordered_vector< Key, Compare, Vector >::size().

◆ transform_point() [1/4]

void TransformBlend::transform_point ( LPoint3d & point,
Thread * current_thread ) const
inline

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 280 of file transformBlend.I.

References ordered_vector< Key, Compare, Vector >::empty().

◆ transform_point() [2/4]

void TransformBlend::transform_point ( LPoint3f & point,
Thread * current_thread ) const
inline

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 221 of file transformBlend.I.

References ordered_vector< Key, Compare, Vector >::empty().

◆ transform_point() [3/4]

void TransformBlend::transform_point ( LPoint4d & point,
Thread * current_thread ) const
inline

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 250 of file transformBlend.I.

References ordered_vector< Key, Compare, Vector >::empty().

◆ transform_point() [4/4]

void TransformBlend::transform_point ( LPoint4f & point,
Thread * current_thread ) const
inline

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 207 of file transformBlend.I.

References ordered_vector< Key, Compare, Vector >::empty().

◆ transform_vector() [1/2]

void TransformBlend::transform_vector ( LVector3d & vector,
Thread * current_thread ) const
inline

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 310 of file transformBlend.I.

References ordered_vector< Key, Compare, Vector >::empty().

◆ transform_vector() [2/2]

void TransformBlend::transform_vector ( LVector3f & point,
Thread * current_thread ) const
inline

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 235 of file transformBlend.I.

References ordered_vector< Key, Compare, Vector >::empty().

◆ update_blend()

void TransformBlend::update_blend ( Thread * current_thread) const
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 179 of file transformBlend.I.

References VertexTransform::get_global_modified().

◆ write()

void TransformBlend::write ( std::ostream & out,
int indent_level ) const

Definition at line 188 of file transformBlend.cxx.

◆ write_datagram()

void TransformBlend::write_datagram ( BamWriter * manager,
Datagram & dg ) const

Friends And Related Symbol Documentation

◆ VertexTransform

friend class VertexTransform
friend

Definition at line 134 of file transformBlend.h.

Member Data Documentation

◆ get_modified

UpdateSeq TransformBlend::get_modified
inline

Returns a counter which is guaranteed to increment at least as often as the result of get_blend() changes.

Definition at line 87 of file transformBlend.h.

◆ get_num_transforms

size_t TransformBlend::get_num_transforms
inline

Returns the number of transforms stored in the blend object.

Definition at line 63 of file transformBlend.h.

Referenced by TransformBlendTable::add_blend(), GeomVertexData::copy_from(), and CPT().

◆ get_transform

const VertexTransform * TransformBlend::get_transform
inline

Returns the nth transform stored in the blend object.

Definition at line 63 of file transformBlend.h.

Referenced by GeomVertexData::copy_from(), and CPT().

◆ get_weight

PN_stdfloat TransformBlend::get_weight
inline

Returns the weight associated with the indicated transform, or 0 if there is no entry for the transform.

Returns the weight associated with the nth transform stored in the blend object.

Definition at line 71 of file transformBlend.h.

Referenced by GeomVertexData::copy_from().

◆ has_transform

bool TransformBlend::has_transform

Returns true if the blend has the indicated transform, false otherwise.

Definition at line 71 of file transformBlend.h.

◆ remove_transform

void TransformBlend::remove_transform
inline

Removes the indicated transform from the blend.

Removes the nth transform stored in the blend object.

Definition at line 70 of file transformBlend.h.

◆ set_transform

void TransformBlend::set_transform
inline

Replaces the nth transform stored in the blend object.

Definition at line 70 of file transformBlend.h.

Referenced by CPT().


The documentation for this class was generated from the following files: