1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-16 14:00:40 +00:00

Unify determination of default property values

This commit is contained in:
Pedro J. Estébanez
2021-09-14 13:05:45 +02:00
parent 837f2c5f82
commit 76b7d23a10
7 changed files with 301 additions and 332 deletions

View File

@@ -34,7 +34,6 @@
#include "core/os/input.h"
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "editor/editor_feature_profile.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
@@ -46,6 +45,7 @@
#include "editor/plugins/spatial_editor_plugin.h"
#include "editor/script_editor_debugger.h"
#include "scene/main/viewport.h"
#include "scene/property_utils.h"
#include "scene/resources/packed_scene.h"
void SceneTreeDock::_nodes_drag_begin() {
@@ -3086,7 +3086,9 @@ void SceneTreeDock::_clear_clipboard() {
void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap) {
List<PropertyInfo> props;
p_node->get_property_list(&props);
bool is_instanced = EditorPropertyRevert::may_node_be_in_instance(p_node);
Vector<SceneState::PackState> states_stack;
bool states_stack_ready = false;
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) {
@@ -3097,13 +3099,14 @@ void SceneTreeDock::_create_remap_for_node(Node *p_node, Map<RES, RES> &r_remap)
if (v.is_ref()) {
RES res = v;
if (res.is_valid()) {
if (is_instanced) {
Variant orig;
if (EditorPropertyRevert::get_instanced_node_original_property(p_node, E->get().name, orig)) {
if (!EditorPropertyRevert::is_node_property_different(p_node, v, orig)) {
continue;
}
}
if (!states_stack_ready) {
states_stack = PropertyUtils::get_node_states_stack(p_node);
states_stack_ready = true;
}
Variant orig = PropertyUtils::get_property_default_value(p_node, E->get().name, &states_stack);
if (!PropertyUtils::is_property_value_different(v, orig)) {
continue;
}
if ((res->get_path() == "" || res->get_path().find("::") > -1) && !r_remap.has(res)) {