Panda3D
Loading...
Searching...
No Matches
bindAnimRequest.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file bindAnimRequest.cxx
10 * @author drose
11 * @date 2008-08-05
12 */
13
14#include "bindAnimRequest.h"
15#include "animBundleNode.h"
16#include "animControl.h"
17#include "partBundle.h"
18
19TypeHandle BindAnimRequest::_type_handle;
20
21/**
22 *
23 */
24BindAnimRequest::
25BindAnimRequest(const std::string &name,
26 const Filename &filename, const LoaderOptions &options,
27 Loader *loader,
28 AnimControl *control, int hierarchy_match_flags,
29 const PartSubset &subset) :
30 ModelLoadRequest(name, filename, options, loader),
31 _control(control),
32 _hierarchy_match_flags(hierarchy_match_flags),
33 _subset(subset)
34{
35}
36
37/**
38 * Performs the task: that is, loads and binds the animation.
39 */
40AsyncTask::DoneStatus BindAnimRequest::
41do_task() {
42 ModelLoadRequest::do_task();
43
44 PartBundle *part = _control->get_part();
45
46 if (_control->get_ref_count() == 1) {
47 // We're holding the only remaining reference to this AnimControl.
48 // Therefore, forget the bind attempt; no one cares anyway.
49 _control->fail_anim(part);
50 return DS_done;
51 }
52
53 PT(PandaNode) model = get_model();
54 if (model == nullptr) {
55 // Couldn't load the file.
56 _control->fail_anim(part);
57 return DS_done;
58 }
59 _control->set_anim_model(model);
60
62 if (anim == nullptr) {
63 // No anim bundle.
64 _control->fail_anim(part);
65 return DS_done;
66 }
67
68 if (!part->do_bind_anim(_control, anim, _hierarchy_match_flags, _subset)) {
69 // Couldn't bind.
70 _control->fail_anim(part);
71 return DS_done;
72 }
73
74 return DS_done;
75}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static AnimBundle * find_anim_bundle(PandaNode *root)
Recursively walks the scene graph beginning at the indicated node (which need not be an AnimBundleNod...
This is the root of an AnimChannel hierarchy.
Definition animBundle.h:29
Controls the timing of a character animation.
Definition animControl.h:38
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
Specifies parameters that may be passed to the loader.
A convenient class for loading models from disk, in bam or egg format (or any of a number of other fo...
Definition loader.h:42
A class object that manages a single asynchronous model load request.
PandaNode * get_model() const
Returns the model that was loaded asynchronously, if any, or null if there was an error.
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
This is the root of a MovingPart hierarchy.
Definition partBundle.h:46
bool do_bind_anim(AnimControl *control, AnimBundle *anim, int hierarchy_match_flags, const PartSubset &subset)
The internal implementation of bind_anim(), this receives a pointer to an uninitialized AnimControl a...
This class is used to define a subset of part names to apply to the PartBundle::bind_anim() operation...
Definition partSubset.h:25
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.