diff --git a/prop_instance.cpp b/prop_instance.cpp index 48e8fd7..4957f83 100644 --- a/prop_instance.cpp +++ b/prop_instance.cpp @@ -33,7 +33,11 @@ void PropInstance::set_prop_data(const Ref &data) { _prop_data = data; - queue_build(); + if (_building) { + queue_build(); + } else { + call_deferred("build"); + } } Ref PropInstance::get_material() { @@ -58,11 +62,7 @@ void PropInstance::queue_build() { } void PropInstance::build_finished() { - _building = false; - - if (_build_queued) { - call_deferred("build"); - } + call("_build_finished"); } void PropInstance::_build() { @@ -89,6 +89,11 @@ void PropInstance::_build() { } void PropInstance::_build_finished() { + _building = false; + + if (_build_queued) { + call_deferred("build"); + } } void PropInstance::prop_preprocess(Transform transform, const Ref &prop) { diff --git a/prop_instance_job.cpp b/prop_instance_job.cpp index af3a966..67af8f8 100644 --- a/prop_instance_job.cpp +++ b/prop_instance_job.cpp @@ -70,6 +70,10 @@ void PropInstanceJob::set_build_done(const bool val) { void PropInstanceJob::finished() { set_build_done(true); + + if (_instance) { + _instance->build_finished(); + } } void PropInstanceJob::reset() { diff --git a/prop_instance_merger.cpp b/prop_instance_merger.cpp index 50a5a92..a372d9b 100644 --- a/prop_instance_merger.cpp +++ b/prop_instance_merger.cpp @@ -462,6 +462,10 @@ Don't submit here, as it starts in physics process mode void PropInstanceMerger::_build_finished() { set_building(false); + + if (_build_queued) { + call_deferred("build"); + } } void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref &prop) { diff --git a/prop_instance_prop_job.cpp b/prop_instance_prop_job.cpp index b428931..de96ccf 100644 --- a/prop_instance_prop_job.cpp +++ b/prop_instance_prop_job.cpp @@ -91,6 +91,7 @@ PropInstanceMerger *PropInstancePropJob::get_prop_instace() { } void PropInstancePropJob::set_prop_instace(PropInstanceMerger *prop) { _prop_instace = prop; + _instance = prop; } void PropInstancePropJob::set_prop_instace_bind(Node *prop) { set_prop_instace(Object::cast_to(prop)); @@ -327,6 +328,7 @@ void PropInstancePropJob::_reset() { _build_done = false; _phase = 0; + _current_mesh = 0; _current_job_step = 0; reset_stages();