void Skeleton::set_bone_global_pose(int p_bone, const Transform &p_pose) { ERR_FAIL_INDEX(p_bone, bones.size()); if (bones[p_bone].parent == -1) { set_bone_pose(p_bone, bones[p_bone].rest_global_inverse * p_pose); //fast } else { set_bone_pose(p_bone, bones[p_bone].rest.affine_inverse() * (get_bone_global_pose(bones[p_bone].parent).affine_inverse() * p_pose)); //slow } }
bool Skeleton::_set(const StringName& p_path, const Variant& p_value) { String path = p_path; if (!path.begins_with("bones/")) return false; int which=path.get_slicec('/',1).to_int(); String what=path.get_slicec('/',2); if (which==bones.size() && what=="name") { add_bone(p_value); return true; } ERR_FAIL_INDEX_V( which, bones.size(), false ); if (what=="parent") set_bone_parent(which, p_value ); else if (what=="rest") set_bone_rest(which, p_value); else if (what=="enabled") set_bone_enabled(which, p_value); else if (what=="pose") set_bone_pose(which, p_value); else if (what=="bound_childs") { Array children=p_value; if (is_inside_tree()) { bones[which].nodes_bound.clear(); for (int i=0;i<children.size();i++) { NodePath path=children[i]; ERR_CONTINUE( path.operator String()=="" ); Node *node = get_node(path); ERR_CONTINUE(!node); bind_child_node_to_bone(which,node); } } } else { return false; } return true; }