summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-01-22 19:36:40 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-01-22 19:36:40 -0300
commitb30839fb08e4e17ca9ba3a76aa46bb263c62e7b6 (patch)
tree37fe88caa56d4f9096b1a5cff422b21f46527eb0
parent84d7a559e5198478b1ae23d00dbd966461aadfe7 (diff)
-make sure instance placeholder works with duplicate(), fixes #3378
-rw-r--r--scene/main/instance_placeholder.cpp13
-rw-r--r--scene/main/node.cpp10
2 files changed, 22 insertions, 1 deletions
diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp
index 12f6086bf0..f822107918 100644
--- a/scene/main/instance_placeholder.cpp
+++ b/scene/main/instance_placeholder.cpp
@@ -14,11 +14,24 @@ bool InstancePlaceholder::_set(const StringName& p_name, const Variant& p_value)
bool InstancePlaceholder::_get(const StringName& p_name,Variant &r_ret) const{
+ for (const List<PropSet>::Element *E=stored_values.front();E;E=E->next()) {
+ if (E->get().name==p_name) {
+ r_ret=E->get().value;
+ return true;
+ }
+ }
return false;
}
void InstancePlaceholder::_get_property_list( List<PropertyInfo> *p_list) const{
+ for (const List<PropSet>::Element *E=stored_values.front();E;E=E->next()) {
+ PropertyInfo pi;
+ pi.name=E->get().name;
+ pi.type=E->get().value.get_type();
+ pi.usage=PROPERTY_USAGE_STORAGE;
+ p_list->push_back(pi);
+ }
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 191e3ec04c..450578a241 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -33,6 +33,7 @@
#include "scene/resources/packed_scene.h"
#include "io/resource_loader.h"
#include "viewport.h"
+#include "instance_placeholder.h"
VARIANT_ENUM_CAST(Node::PauseMode);
@@ -1471,7 +1472,14 @@ Node *Node::duplicate(bool p_use_instancing) const {
bool instanced=false;
- if (p_use_instancing && get_filename()!=String()) {
+ if (cast_to<InstancePlaceholder>()) {
+
+ const InstancePlaceholder *ip = cast_to<const InstancePlaceholder>();
+ InstancePlaceholder *nip = memnew( InstancePlaceholder );
+ nip->set_instance_path( ip->get_instance_path() );
+ node=nip;
+
+ } else if (p_use_instancing && get_filename()!=String()) {
Ref<PackedScene> res = ResourceLoader::load(get_filename());
ERR_FAIL_COND_V(res.is_null(),NULL);