Panda3D
|
00001 // Filename: bindAnimRequest.cxx 00002 // Created by: drose (05Aug08) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "bindAnimRequest.h" 00016 #include "animBundleNode.h" 00017 #include "animControl.h" 00018 #include "partBundle.h" 00019 00020 TypeHandle BindAnimRequest::_type_handle; 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Function: BindAnimRequest::Constructor 00024 // Access: Public 00025 // Description: 00026 //////////////////////////////////////////////////////////////////// 00027 BindAnimRequest:: 00028 BindAnimRequest(const string &name, 00029 const Filename &filename, const LoaderOptions &options, 00030 Loader *loader, 00031 AnimControl *control, int hierarchy_match_flags, 00032 const PartSubset &subset) : 00033 ModelLoadRequest(name, filename, options, loader), 00034 _control(control), 00035 _hierarchy_match_flags(hierarchy_match_flags), 00036 _subset(subset) 00037 { 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: BindAnimRequest::do_task 00042 // Access: Protected, Virtual 00043 // Description: Performs the task: that is, loads and binds the 00044 // animation. 00045 //////////////////////////////////////////////////////////////////// 00046 AsyncTask::DoneStatus BindAnimRequest:: 00047 do_task() { 00048 ModelLoadRequest::do_task(); 00049 00050 PartBundle *part = _control->get_part(); 00051 00052 if (_control->get_ref_count() == 1) { 00053 // We're holding the only remaining reference to this AnimControl. 00054 // Therefore, forget the bind attempt; no one cares anyway. 00055 _control->fail_anim(part); 00056 return DS_done; 00057 } 00058 00059 PT(PandaNode) model = get_model(); 00060 if (model == (PandaNode *)NULL) { 00061 // Couldn't load the file. 00062 _control->fail_anim(part); 00063 return DS_done; 00064 } 00065 _control->set_anim_model(model); 00066 00067 AnimBundle *anim = AnimBundleNode::find_anim_bundle(model); 00068 if (anim == (AnimBundle *)NULL) { 00069 // No anim bundle. 00070 _control->fail_anim(part); 00071 return DS_done; 00072 } 00073 00074 if (!part->do_bind_anim(_control, anim, _hierarchy_match_flags, _subset)) { 00075 // Couldn't bind. 00076 _control->fail_anim(part); 00077 return DS_done; 00078 } 00079 00080 return DS_done; 00081 }