You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-13 13:31:48 +00:00
Fix NodeTransition initialization and AnimationNode remapping method
This commit is contained in:
@@ -453,6 +453,8 @@ void AnimationNode::_bind_methods() {
|
||||
GDVIRTUAL_BIND(_has_filter);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("tree_changed"));
|
||||
ADD_SIGNAL(MethodInfo("animation_node_renamed", PropertyInfo(Variant::INT, "object_id"), PropertyInfo(Variant::STRING, "old_name"), PropertyInfo(Variant::STRING, "new_name")));
|
||||
ADD_SIGNAL(MethodInfo("animation_node_removed", PropertyInfo(Variant::INT, "object_id"), PropertyInfo(Variant::STRING, "name")));
|
||||
|
||||
BIND_ENUM_CONSTANT(FILTER_IGNORE);
|
||||
BIND_ENUM_CONSTANT(FILTER_PASS);
|
||||
@@ -465,15 +467,33 @@ AnimationNode::AnimationNode() {
|
||||
|
||||
////////////////////
|
||||
|
||||
void AnimationRootNode::_tree_changed() {
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationRootNode::_animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) {
|
||||
emit_signal(SNAME("animation_node_renamed"), p_oid, p_old_name, p_new_name);
|
||||
}
|
||||
|
||||
void AnimationRootNode::_animation_node_removed(const ObjectID &p_oid, const StringName &p_node) {
|
||||
emit_signal(SNAME("animation_node_removed"), p_oid, p_node);
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
void AnimationTree::set_tree_root(const Ref<AnimationNode> &p_root) {
|
||||
if (root.is_valid()) {
|
||||
root->disconnect("tree_changed", callable_mp(this, &AnimationTree::_tree_changed));
|
||||
root->disconnect("animation_node_renamed", callable_mp(this, &AnimationTree::_animation_node_renamed));
|
||||
root->disconnect("animation_node_removed", callable_mp(this, &AnimationTree::_animation_node_removed));
|
||||
}
|
||||
|
||||
root = p_root;
|
||||
|
||||
if (root.is_valid()) {
|
||||
root->connect("tree_changed", callable_mp(this, &AnimationTree::_tree_changed));
|
||||
root->connect("animation_node_renamed", callable_mp(this, &AnimationTree::_animation_node_renamed));
|
||||
root->connect("animation_node_removed", callable_mp(this, &AnimationTree::_animation_node_removed));
|
||||
}
|
||||
|
||||
properties_dirty = true;
|
||||
@@ -1982,11 +2002,46 @@ void AnimationTree::_tree_changed() {
|
||||
properties_dirty = true;
|
||||
}
|
||||
|
||||
void AnimationTree::_animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) {
|
||||
ERR_FAIL_COND(!property_reference_map.has(p_oid));
|
||||
String base_path = property_reference_map[p_oid];
|
||||
String old_base = base_path + p_old_name;
|
||||
String new_base = base_path + p_new_name;
|
||||
for (const PropertyInfo &E : properties) {
|
||||
if (E.name.begins_with(old_base)) {
|
||||
String new_name = E.name.replace_first(old_base, new_base);
|
||||
property_map[new_name] = property_map[E.name];
|
||||
property_map.erase(E.name);
|
||||
}
|
||||
}
|
||||
|
||||
//update tree second
|
||||
properties_dirty = true;
|
||||
_update_properties();
|
||||
}
|
||||
|
||||
void AnimationTree::_animation_node_removed(const ObjectID &p_oid, const StringName &p_node) {
|
||||
ERR_FAIL_COND(!property_reference_map.has(p_oid));
|
||||
String base_path = String(property_reference_map[p_oid]) + String(p_node);
|
||||
for (const PropertyInfo &E : properties) {
|
||||
if (E.name.begins_with(base_path)) {
|
||||
property_map.erase(E.name);
|
||||
}
|
||||
}
|
||||
|
||||
//update tree second
|
||||
properties_dirty = true;
|
||||
_update_properties();
|
||||
}
|
||||
|
||||
void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref<AnimationNode> node) {
|
||||
ERR_FAIL_COND(node.is_null());
|
||||
if (!property_parent_map.has(p_base_path)) {
|
||||
property_parent_map[p_base_path] = HashMap<StringName, StringName>();
|
||||
}
|
||||
if (!property_reference_map.has(node->get_instance_id())) {
|
||||
property_reference_map[node->get_instance_id()] = p_base_path;
|
||||
}
|
||||
|
||||
if (node->get_input_count() && !input_activity_map.has(p_base_path)) {
|
||||
Vector<Activity> activity;
|
||||
@@ -2032,6 +2087,7 @@ void AnimationTree::_update_properties() {
|
||||
}
|
||||
|
||||
properties.clear();
|
||||
property_reference_map.clear();
|
||||
property_parent_map.clear();
|
||||
input_activity_map.clear();
|
||||
input_activity_map_get.clear();
|
||||
|
||||
Reference in New Issue
Block a user