15 #include "animControl.h" 16 #include "animChannelBase.h" 17 #include "partBundle.h" 18 #include "config_chan.h" 20 #include "mutexHolder.h" 21 #include "throw_event.h" 36 double frame_rate,
int num_frames) :
39 _pending_cvar(_pending_lock),
42 #ifdef DO_MEMORY_USAGE 43 MemoryUsage::update_type(
this, get_class_type());
50 set_frame_rate(frame_rate);
51 set_num_frames(num_frames);
67 nassertv(_pending && part == _part);
70 _channel_index = channel_index;
71 _bound_joints = bound_joints;
72 set_frame_rate(_anim->get_base_frame_rate());
73 set_num_frames(_anim->get_num_frames());
79 if (!_pending_done_event.empty()) {
80 throw_event(_pending_done_event);
93 _bound_joints = bound_joints;
106 nassertv(_pending && part == _part);
109 if (!_pending_done_event.empty()) {
110 throw_event(_pending_done_event);
139 <<
" until " << get_name() <<
" is bound\n";
141 _pending_cvar.
wait();
157 _pending_done_event = done_event;
159 throw_event(_pending_done_event);
172 return _pending_done_event;
192 output(ostream &out)
const {
193 out <<
"AnimControl(" << get_name() <<
", " <<
get_part()->get_name()
195 AnimInterface::output(out);
199 out <<
" (pending bind)";
201 out <<
" (failed bind)";
213 if (_marked_frame < 0) {
218 double this_frac = 0.0;
219 if (frame_blend_flag) {
222 return channel->
has_changed(_marked_frame, _marked_frac,
223 this_frame, this_frac);
236 if (frame_blend_flag) {
249 animation_activated() {
void set_control_effect(AnimControl *control, PN_stdfloat effect)
Sets the amount by which the character is affected by the indicated AnimControl (and its associated a...
void wait()
Waits on the condition.
AnimControl(const string &name, PartBundle *part, double frame_rate, int num_frames)
This constructor is used to create a temporarily uninitialized AnimControl that will serve as a place...
This is the root of an AnimChannel hierarchy.
A lightweight C++ object whose constructor calls acquire() and whose destructor calls release() on a ...
void set_pending_done_event(const string &done_event)
Specifies an event name that will be thrown when the AnimControl is finished binding asynchronously...
bool channel_has_changed(AnimChannelBase *channel, bool frame_blend_flag) const
Returns true if the indicated channel value has changed since the last call to mark_channels().
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac)
Returns true if the value has changed since the last call to has_changed().
PartBundle * get_part() const
Returns the PartBundle bound in with this AnimControl.
void notify_all()
Informs all of the other threads who are currently blocked on wait() that the relevant condition has ...
A dynamic array with an unlimited number of bits.
Parent class for all animation channels.
A base class for all things which can have a name.
string get_pending_done_event() const
Returns the event name that will be thrown when the AnimControl is finished binding asynchronously...
void setup_anim(PartBundle *part, AnimBundle *anim, int channel_index, const BitArray &bound_joints)
This can only be called once for a given AnimControl.
void set_bound_joints(const BitArray &bound_joints)
Called to initialize the AnimControl with its array of bound_joints, before setup_anim() has complete...
void wait_pending()
Blocks the current thread until the AnimControl has finished loading and is fully bound...
bool has_anim() const
Returns true if the AnimControl was successfully loaded, or false if there was a problem.
virtual void control_activated(AnimControl *control)
Called by the AnimControl whenever it starts an animation.
This is the root of a MovingPart hierarchy.
void mark_channels(bool frame_blend_flag)
Marks this point as the point of reference for the next call to channel_has_changed().
TypeHandle is the identifier used to differentiate C++ class types.
int get_frame() const
Returns the current integer frame number.
double get_frac() const
Returns the fractional part of the current frame.
void fail_anim(PartBundle *part)
This can only be called once for a given AnimControl.
bool is_pending() const
Returns true if the AnimControl is being bound asynchronously, and has not yet finished.