From 8667cc8eaf6a46e36a12b9919d19c0ee52019244 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 27 Apr 2021 16:52:36 +0200 Subject: [PATCH] Made prop_preprocess overrideable. --- prop_instance.cpp | 11 +++++++++++ prop_instance.h | 1 + prop_instance_merger.cpp | 2 +- prop_instance_merger.h | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/prop_instance.cpp b/prop_instance.cpp index 2faefdd..7ace004 100644 --- a/prop_instance.cpp +++ b/prop_instance.cpp @@ -76,6 +76,10 @@ void PropInstance::_build_finished() { } void PropInstance::prop_preprocess(Transform transform, const Ref &prop) { + call("_prop_preprocess", transform, prop); +} + +void PropInstance::_prop_preprocess(Transform transform, const Ref &prop) { ERR_FAIL_COND(!prop.is_valid()); int count = prop->get_prop_count(); @@ -185,6 +189,13 @@ void PropInstance::_bind_methods() { ClassDB::bind_method(D_METHOD("set_prop_data", "value"), &PropInstance::set_prop_data); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop_data", "get_prop_data"); + BIND_VMETHOD(MethodInfo("_prop_preprocess", + PropertyInfo(Variant::TRANSFORM, "tarnsform"), + PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"))); + + ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &PropInstance::prop_preprocess); + ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &PropInstance::_prop_preprocess); + //--- BIND_VMETHOD(MethodInfo("_init_materials")); diff --git a/prop_instance.h b/prop_instance.h index 20b7b0f..d7b00ce 100644 --- a/prop_instance.h +++ b/prop_instance.h @@ -55,6 +55,7 @@ public: virtual void _build_finished(); void prop_preprocess(Transform tarnsform, const Ref &prop); + virtual void _prop_preprocess(Transform tarnsform, const Ref &prop); PropInstance(); ~PropInstance(); diff --git a/prop_instance_merger.cpp b/prop_instance_merger.cpp index 1001d97..4b4b4ae 100644 --- a/prop_instance_merger.cpp +++ b/prop_instance_merger.cpp @@ -225,7 +225,7 @@ void PropInstanceMerger::_build() { void PropInstanceMerger::_build_finished() { } -void PropInstanceMerger::prop_preprocess(Transform transform, const Ref &prop) { +void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref &prop) { ERR_FAIL_COND(!prop.is_valid()); int count = prop->get_prop_count(); diff --git a/prop_instance_merger.h b/prop_instance_merger.h index 2626d6b..1e77a04 100644 --- a/prop_instance_merger.h +++ b/prop_instance_merger.h @@ -96,7 +96,7 @@ public: virtual void _build(); virtual void _build_finished(); - void prop_preprocess(Transform tarnsform, const Ref &prop); + void _prop_preprocess(Transform tarnsform, const Ref &prop); PropInstanceMerger(); ~PropInstanceMerger();