From a364f91bd5b55e74e562ed11f8cf08b2b22be953 Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 20 May 2021 19:16:25 +0200 Subject: [PATCH] Set up job's texture packer property. --- prop_instance_merger.cpp | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/prop_instance_merger.cpp b/prop_instance_merger.cpp index b8fc0c3..dba31ea 100644 --- a/prop_instance_merger.cpp +++ b/prop_instance_merger.cpp @@ -45,6 +45,10 @@ typedef class RenderingServer VS; #include "./props/prop_data_prop.h" #include "./props/prop_data_scene.h" +#if TEXTURE_PACKER_PRESENT +#include "./singleton/prop_texture_cache.h" +#endif + Ref PropInstanceMerger::get_job() { return _job; } @@ -197,16 +201,35 @@ void PropInstanceMerger::_build() { _building = true; _build_queued = false; - if (!_job.is_valid()) { - _job = Ref(memnew(PropInstancePropJob())); - } - - _job->set_prop_instace(this); - - if (!is_inside_tree()) { + if (!_prop_data.is_valid()) { + _building = false; return; } + if (!_job.is_valid()) { + _job = Ref(memnew(PropInstancePropJob())); + _job->set_prop_instace(this); + } + + if (!is_inside_tree()) { + _building = false; + _build_queued = true; + return; + } + +#if TEXTURE_PACKER_PRESENT + Ref packer = PropTextureCache::get_singleton()->get_or_create_texture_threaded(_prop_data); + + if (packer->get_generated_texture_count() == 0) { + _building = false; + _build_queued = true; + return; + } + + _job->set_texture_packer(packer); +#endif + + for (int i = 0; i < get_child_count(); ++i) { Node *n = get_child(i);