///Оповещение о присоединении узла void BindNode (Node& child) { try { const char* target_name = child.Name (); if (!target_name) return; TargetMap::iterator iter = targets.find (target_name); if (iter == targets.end ()) return; Target& target = *iter->second; if (target.node) throw xtl::format_operation_exception ("", "Duplicate node for animation target '%s'", target_name); target.BindNode (&child); } catch (std::exception& e) { log.Printf ("%s\n at scene_graph::controllers::AnimationController::Impl::BindNode", e.what ()); } catch (...) { log.Printf ("uknown exception\n at scene_graph::controllers::AnimationController::Impl::BindNode"); } }
Target* LaunchDaemon::FindTarget(const char* name) const { if (name == NULL) return NULL; TargetMap::const_iterator found = fTargets.find(BString(name).ToLower()); if (found != fTargets.end()) return found->second; return NULL; }
///Добавление анимационной цели void AddTarget (const char* target_name, TargetBlender& target_blender) { try { //получение родительского узла Node* root = owner.AttachedNode (); if (!root) throw xtl::format_operation_exception ("", "Animation node was detached"); //проверка корректности if (targets.find (target_name) != targets.end ()) throw xtl::format_operation_exception ("", "Animation target '%s' has already registered", target_name); //создание анимационной цели TargetPtr target (new Target (target_blender), false); //регистрация анимационной цели targets.insert_pair (target_name, target); //поиск потомка Node::Pointer node; if (!strcmp (root->Name (), target_name)) { node = root; } else { node = root->FindChild (target_name, NodeSearchMode_OnAllSublevels); } if (node) target->BindNode (node.get ()); } catch (std::exception& e) { log.Printf ("%s\n at scene_graph::controllers::AnimationController::Impl::AddTarget", e.what ()); } catch (...) { log.Printf ("uknown exception\n at scene_graph::controllers::AnimationController::Impl::AddTarget"); } }
///Оповещение об отсоединении узла void UnbindNode (Node& child) { const char* target_name = child.Name (); if (!target_name) return; TargetMap::iterator iter = targets.find (target_name); if (iter == targets.end ()) return; Target& target = *iter->second; if (target.node == &child) target.UnbindNode (); }