From 66278f0ab8e94197fb1c3605e6aaa52dd7cfc13a Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 3 Aug 2021 00:16:29 +0200 Subject: [PATCH] Added initialized property to TerraMaterialCache. --- library/terra_material_cache.cpp | 13 +++++++++++++ library/terra_material_cache.h | 7 ++++++- library/terra_material_cache_pcm.cpp | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/library/terra_material_cache.cpp b/library/terra_material_cache.cpp index 1fb65b2..e2dfd82 100644 --- a/library/terra_material_cache.cpp +++ b/library/terra_material_cache.cpp @@ -22,6 +22,13 @@ SOFTWARE. #include "terra_material_cache.h" +bool TerraMaterialCache::get_initialized() { + return _initialized; +} +void TerraMaterialCache::set_initialized(const bool value) { + _initialized = value; +} + //Materials Ref TerraMaterialCache::material_get(const int index) { ERR_FAIL_INDEX_V(index, _materials.size(), Ref(NULL)); @@ -127,6 +134,7 @@ void TerraMaterialCache::surfaces_clear() { } void TerraMaterialCache::refresh_rects() { + _initialized = true; } void TerraMaterialCache::setup_material_albedo(Ref texture) { @@ -136,6 +144,7 @@ void TerraMaterialCache::setup_material_albedo(Ref texture) { TerraMaterialCache::TerraMaterialCache() { material_users = 0; + _initialized = false; } TerraMaterialCache::~TerraMaterialCache() { @@ -144,6 +153,10 @@ TerraMaterialCache::~TerraMaterialCache() { } void TerraMaterialCache::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_initialized"), &TerraMaterialCache::get_initialized); + ClassDB::bind_method(D_METHOD("set_initialized", "value"), &TerraMaterialCache::set_initialized); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "initialized"), "set_initialized", "get_initialized"); + BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"))); ClassDB::bind_method(D_METHOD("material_get", "index"), &TerraMaterialCache::material_get); diff --git a/library/terra_material_cache.h b/library/terra_material_cache.h index 66a1219..f8240cd 100644 --- a/library/terra_material_cache.h +++ b/library/terra_material_cache.h @@ -48,6 +48,9 @@ class TerraMaterialCache : public Resource { GDCLASS(TerraMaterialCache, Resource) public: + bool get_initialized(); + void set_initialized(const bool value); + Ref material_get(const int index); Ref material_lod_get(const int index); void material_add(const Ref &value); @@ -77,9 +80,11 @@ public: protected: static void _bind_methods(); + bool _initialized; + Vector> _surfaces; Vector> _materials; - //Ref merger; inherited + int material_users; }; diff --git a/library/terra_material_cache_pcm.cpp b/library/terra_material_cache_pcm.cpp index bc6f956..104ce6d 100644 --- a/library/terra_material_cache_pcm.cpp +++ b/library/terra_material_cache_pcm.cpp @@ -101,6 +101,8 @@ void TerraMaterialCachePCM::refresh_rects() { surface->refresh_rects(); } } + + _initialized = true; } void TerraMaterialCachePCM::_setup_material_albedo(Ref texture) {