Пример #1
0
bool Skeleton::is_bone_parent_of(int p_bone, int p_parent_bone_id) const {

	int parent_of_bone = get_bone_parent(p_bone);

	if (-1 == parent_of_bone)
		return false;

	if (parent_of_bone == p_parent_bone_id)
		return true;

	return is_bone_parent_of(parent_of_bone, p_parent_bone_id);
}
Пример #2
0
bool Skeleton::_get(const StringName& p_name,Variant &r_ret) const {

	String path=p_name;

	if (!path.begins_with("bones/"))
		return false;

	int which=path.get_slicec('/',1).to_int();
	String what=path.get_slicec('/',2);

	ERR_FAIL_INDEX_V( which, bones.size(), false );

	if (what=="name")
		r_ret=get_bone_name(which);
	else if (what=="parent")
		r_ret=get_bone_parent(which);
	else if (what=="rest")
		r_ret=get_bone_rest(which);
	else if (what=="enabled")
		r_ret=is_bone_enabled(which);
	else if (what=="pose")
		r_ret=get_bone_pose(which);
	else if (what=="bound_childs") {
		Array children;

		for (const List<uint32_t>::Element *E=bones[which].nodes_bound.front();E;E=E->next()) {

			Object *obj=ObjectDB::get_instance(E->get());
			ERR_CONTINUE(!obj);
			Node *node=obj->cast_to<Node>();
			ERR_CONTINUE(!node);
			NodePath path=get_path_to(node);
			children.push_back(path);

		}

		r_ret=children;
	} else
		return false;

	return true;

}