change node graph property and improved some bindings
This commit is contained in:
parent
c633b770cb
commit
de1ff22eae
2 changed files with 31 additions and 8 deletions
|
@ -60,7 +60,7 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p
|
|||
|
||||
Ref<AnimationNodeBlendTree> tree = get_parent();
|
||||
|
||||
if (!tree.is_valid() && get_tree()->get_graph_root().ptr() != this) {
|
||||
if (!tree.is_valid() && get_tree()->get_tree_root().ptr() != this) {
|
||||
make_invalid(RTR("Can't blend input because node is not in a tree"));
|
||||
return 0;
|
||||
}
|
||||
|
@ -225,6 +225,11 @@ void AnimationNode::set_input_connection(int p_input, const StringName &p_connec
|
|||
}
|
||||
|
||||
String AnimationNode::get_caption() const {
|
||||
|
||||
if (get_script_instance()) {
|
||||
return get_script_instance()->call("get_caption");
|
||||
}
|
||||
|
||||
return "Node";
|
||||
}
|
||||
|
||||
|
@ -253,8 +258,17 @@ void AnimationNode::remove_input(int p_index) {
|
|||
emit_changed();
|
||||
}
|
||||
|
||||
|
||||
void AnimationNode::_set_parent(Object *p_parent) {
|
||||
set_parent(Object::cast_to<AnimationNode>(p_parent));
|
||||
}
|
||||
|
||||
|
||||
void AnimationNode::set_parent(AnimationNode *p_parent) {
|
||||
parent = p_parent; //do not use ref because parent contains children
|
||||
if (get_script_instance()) {
|
||||
get_script_instance()->call("_parent_set",p_parent);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<AnimationNode> AnimationNode::get_parent() const {
|
||||
|
@ -375,10 +389,17 @@ void AnimationNode::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("blend_node", "node", "time", "seek", "blend", "filter", "optimize"), &AnimationNode::blend_node, DEFVAL(FILTER_IGNORE), DEFVAL(true));
|
||||
ClassDB::bind_method(D_METHOD("blend_input", "input_index", "time", "seek", "blend", "filter", "optimize"), &AnimationNode::blend_input, DEFVAL(FILTER_IGNORE), DEFVAL(true));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_parent","parent"), &AnimationNode::_set_parent);
|
||||
ClassDB::bind_method(D_METHOD("get_parent"), &AnimationNode::get_parent);
|
||||
ClassDB::bind_method(D_METHOD("get_tree"), &AnimationNode::get_tree);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter_enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_filter_enabled", "is_filter_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "filters", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_filters", "_get_filters");
|
||||
|
||||
BIND_VMETHOD(MethodInfo("process", PropertyInfo(Variant::REAL, "time"), PropertyInfo(Variant::BOOL, "seek")));
|
||||
BIND_VMETHOD(MethodInfo(Variant::STRING,"get_caption"));
|
||||
BIND_VMETHOD(MethodInfo(Variant::STRING,"has_filter"));
|
||||
BIND_VMETHOD(MethodInfo("_parent_set", PropertyInfo(Variant::OBJECT, "parent")));
|
||||
|
||||
ADD_SIGNAL(MethodInfo("removed_from_graph"));
|
||||
BIND_ENUM_CONSTANT(FILTER_IGNORE);
|
||||
|
@ -398,7 +419,7 @@ AnimationNode::AnimationNode() {
|
|||
|
||||
////////////////////
|
||||
|
||||
void AnimationTree::set_graph_root(const Ref<AnimationNode> &p_root) {
|
||||
void AnimationTree::set_tree_root(const Ref<AnimationNode> &p_root) {
|
||||
|
||||
if (root.is_valid()) {
|
||||
root->set_tree(NULL);
|
||||
|
@ -416,7 +437,7 @@ void AnimationTree::set_graph_root(const Ref<AnimationNode> &p_root) {
|
|||
update_configuration_warning();
|
||||
}
|
||||
|
||||
Ref<AnimationNode> AnimationTree::get_graph_root() const {
|
||||
Ref<AnimationNode> AnimationTree::get_tree_root() const {
|
||||
return root;
|
||||
}
|
||||
|
||||
|
@ -1253,8 +1274,8 @@ void AnimationTree::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_active", "active"), &AnimationTree::set_active);
|
||||
ClassDB::bind_method(D_METHOD("is_active"), &AnimationTree::is_active);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_graph_root", "root"), &AnimationTree::set_graph_root);
|
||||
ClassDB::bind_method(D_METHOD("get_graph_root"), &AnimationTree::get_graph_root);
|
||||
ClassDB::bind_method(D_METHOD("set_tree_root", "root"), &AnimationTree::set_tree_root);
|
||||
ClassDB::bind_method(D_METHOD("get_tree_root"), &AnimationTree::get_tree_root);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_process_mode", "mode"), &AnimationTree::set_process_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_process_mode"), &AnimationTree::get_process_mode);
|
||||
|
@ -1267,7 +1288,7 @@ void AnimationTree::_bind_methods() {
|
|||
|
||||
ClassDB::bind_method(D_METHOD("_node_removed"), &AnimationTree::_node_removed);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "graph_root", PROPERTY_HINT_RESOURCE_TYPE, "AnimationRootNode", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE), "set_graph_root", "get_graph_root");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "tree_root", PROPERTY_HINT_RESOURCE_TYPE, "AnimationRootNode", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE), "set_tree_root", "get_tree_root");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "anim_player"), "set_animation_player", "get_animation_player");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "active"), "set_active", "is_active");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_process_mode", "get_process_mode");
|
||||
|
|
|
@ -82,6 +82,8 @@ protected:
|
|||
|
||||
void _validate_property(PropertyInfo &property) const;
|
||||
|
||||
void _set_parent(Object *p_parent);
|
||||
|
||||
public:
|
||||
void set_parent(AnimationNode *p_parent);
|
||||
Ref<AnimationNode> get_parent() const;
|
||||
|
@ -246,8 +248,8 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void set_graph_root(const Ref<AnimationNode> &p_root);
|
||||
Ref<AnimationNode> get_graph_root() const;
|
||||
void set_tree_root(const Ref<AnimationNode> &p_root);
|
||||
Ref<AnimationNode> get_tree_root() const;
|
||||
|
||||
void set_active(bool p_active);
|
||||
bool is_active() const;
|
||||
|
|
Loading…
Reference in a new issue