Set cache to the job and implement cache initialization for in PropInstanceMerger's _build.

This commit is contained in:
Relintai 2021-08-10 09:57:37 +02:00
parent 604d895ac9
commit 387c6fdedd

View File

@ -48,6 +48,7 @@ typedef class RenderingServer VS;
#include "./props/prop_data_light.h" #include "./props/prop_data_light.h"
#include "./props/prop_data_prop.h" #include "./props/prop_data_prop.h"
#include "./props/prop_data_scene.h" #include "./props/prop_data_scene.h"
#include "material_cache/prop_material_cache.h"
#if TEXTURE_PACKER_PRESENT #if TEXTURE_PACKER_PRESENT
#include "./singleton/prop_cache.h" #include "./singleton/prop_cache.h"
@ -410,24 +411,25 @@ void PropInstanceMerger::_build() {
return; return;
} }
//! Ref<PropMaterialCache> cache = PropCache::get_singleton()->material_cache_get(_prop_data);
//job->cache
//this->cache
//job->cache = cache
//job -> if !has cache query -> buildings can use this to only have one material per building
//move this to job if (!cache->get_initialized()) {
//#if TEXTURE_PACKER_PRESENT cache->mutex_lock();
//Ref<TexturePacker> packer; // = PropCache::get_singleton()->get_or_create_texture_threaded(_prop_data);
/* //check again, this thread might have gotten here after an another one already did the initialization!
if (packer->get_generated_texture_count() == 0) { if (!cache->get_initialized()) {
_building = false; //this will set up materials, and settings
_build_queued = true; cache->initial_setup_default();
return;
cache->prop_add_textures(_prop_data);
cache->refresh_rects();
}
cache->mutex_unlock();
} }
*/
// _job->set_texture_packer(packer); _job->set_material_cache(cache);
//#endif
for (int i = 0; i < get_child_count(); ++i) { for (int i = 0; i < get_child_count(); ++i) {
Node *n = get_child(i); Node *n = get_child(i);