summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-01-11 16:44:18 -0300
committerGitHub <noreply@github.com>2018-01-11 16:44:18 -0300
commit9a6282975938106d17ccd49ef1b8c7fc4b11b3d2 (patch)
tree99ea03bf071b792ceb4d65a511173b3190f1dba9
parentb63384a9f1d318d22f67519de8c93144d45251bb (diff)
parent09a6a74074332b964316683fdfca90094f40a2f5 (diff)
Merge pull request #15531 from AndreaCatania/p2
Fixed crash on duplicate GIProbe baking
-rw-r--r--core/object.h1
-rw-r--r--scene/3d/gi_probe.cpp2
-rw-r--r--scene/animation/animation_player.cpp2
-rw-r--r--scene/main/node.cpp11
4 files changed, 13 insertions, 3 deletions
diff --git a/core/object.h b/core/object.h
index 5de87b8a7d..98ce62551b 100644
--- a/core/object.h
+++ b/core/object.h
@@ -111,6 +111,7 @@ enum PropertyUsageFlags {
PROPERTY_USAGE_CLASS_IS_ENUM = 1 << 18,
PROPERTY_USAGE_NIL_IS_VARIANT = 1 << 19,
PROPERTY_USAGE_INTERNAL = 1 << 20,
+ PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE = 1 << 21, // If the object is duplicated also this property will be duplicated
PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK,
PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNATIONALIZED,
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index ce9e801385..4ad2eb60ee 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -535,7 +535,7 @@ void GIProbe::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "normal_bias", PROPERTY_HINT_RANGE, "0,4,0.001"), "set_normal_bias", "get_normal_bias");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_interior", "is_interior");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "compress"), "set_compress", "is_compressed");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "GIProbeData"), "set_probe_data", "get_probe_data");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "GIProbeData", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE), "set_probe_data", "get_probe_data");
BIND_ENUM_CONSTANT(SUBDIV_64);
BIND_ENUM_CONSTANT(SUBDIV_128);
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index f56e8fa9e3..7d909d0cb3 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -158,7 +158,7 @@ void AnimationPlayer::_get_property_list(List<PropertyInfo> *p_list) const {
for (Map<StringName, AnimationData>::Element *E = animation_set.front(); E; E = E->next()) {
- anim_names.push_back(PropertyInfo(Variant::OBJECT, "anims/" + String(E->key()), PROPERTY_HINT_RESOURCE_TYPE, "Animation", PROPERTY_USAGE_NOEDITOR));
+ anim_names.push_back(PropertyInfo(Variant::OBJECT, "anims/" + String(E->key()), PROPERTY_HINT_RESOURCE_TYPE, "Animation", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE));
if (E->get().next != StringName())
anim_names.push_back(PropertyInfo(Variant::STRING, "next/" + String(E->key()), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
names.push_back(E->key());
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index a36f398024..bc03d322b6 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2169,7 +2169,16 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
value = Array(value).duplicate();
}
- current_node->set(name, value);
+ if (E->get().usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE) {
+
+ Resource *res = Object::cast_to<Resource>(value);
+ if (res) // Duplicate only if it's a resource
+ current_node->set(name, res->duplicate());
+
+ } else {
+
+ current_node->set(name, value);
+ }
}
}