From fea813eae344c455c5765b5a21dcf4be7ec64115 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 9 Aug 2021 15:57:21 +0200 Subject: [PATCH] Renamed the PropTextureCache singleton to PropCache. --- SCsub | 2 +- prop_instance_merger.cpp | 4 +- register_types.cpp | 10 ++-- ...{prop_texture_cache.cpp => prop_cache.cpp} | 54 +++++++++---------- .../{prop_texture_cache.h => prop_cache.h} | 20 +++---- 5 files changed, 45 insertions(+), 45 deletions(-) rename singleton/{prop_texture_cache.cpp => prop_cache.cpp} (65%) rename singleton/{prop_texture_cache.h => prop_cache.h} (86%) diff --git a/SCsub b/SCsub index ad58024..08832f2 100644 --- a/SCsub +++ b/SCsub @@ -45,7 +45,7 @@ sources = [ "prop_scene_instance.cpp", "singleton/prop_utils.cpp", - "singleton/prop_texture_cache.cpp", + "singleton/prop_cache.cpp", "editor/prop_editor_plugin.cpp", diff --git a/prop_instance_merger.cpp b/prop_instance_merger.cpp index 4b8d039..ea9ee2d 100644 --- a/prop_instance_merger.cpp +++ b/prop_instance_merger.cpp @@ -50,7 +50,7 @@ typedef class RenderingServer VS; #include "./props/prop_data_scene.h" #if TEXTURE_PACKER_PRESENT -#include "./singleton/prop_texture_cache.h" +#include "./singleton/prop_cache.h" #endif #if THREAD_POOL_PRESENT @@ -411,7 +411,7 @@ void PropInstanceMerger::_build() { } #if TEXTURE_PACKER_PRESENT - Ref packer = PropTextureCache::get_singleton()->get_or_create_texture_threaded(_prop_data); + Ref packer = PropCache::get_singleton()->get_or_create_texture_threaded(_prop_data); if (packer->get_generated_texture_count() == 0) { _building = false; diff --git a/register_types.cpp b/register_types.cpp index 4ecd271..d9e805d 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -51,7 +51,7 @@ SOFTWARE. #include "prop_scene_instance.h" -#include "singleton/prop_texture_cache.h" +#include "singleton/prop_cache.h" #include "singleton/prop_utils.h" #include "./editor/prop_editor_plugin.h" @@ -65,7 +65,7 @@ SOFTWARE. #endif static PropUtils *prop_utils = NULL; -static PropTextureCache *prop_texture_cache = NULL; +static PropCache *prop_texture_cache = NULL; void register_props_types() { ClassDB::register_class(); @@ -102,9 +102,9 @@ void register_props_types() { ClassDB::register_class(); Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton())); - prop_texture_cache = memnew(PropTextureCache); - ClassDB::register_class(); - Engine::get_singleton()->add_singleton(Engine::Singleton("PropTextureCache", PropTextureCache::get_singleton())); + prop_texture_cache = memnew(PropCache); + ClassDB::register_class(); + Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache", PropCache::get_singleton())); Ref light_processor = Ref(memnew(PropDataLight)); PropUtils::add_processor(light_processor); diff --git a/singleton/prop_texture_cache.cpp b/singleton/prop_cache.cpp similarity index 65% rename from singleton/prop_texture_cache.cpp rename to singleton/prop_cache.cpp index c02aec0..8aead21 100644 --- a/singleton/prop_texture_cache.cpp +++ b/singleton/prop_cache.cpp @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_texture_cache.h" +#include "prop_cache.h" #include "../props/prop_data.h" #include "../props/prop_data_entry.h" @@ -43,14 +43,14 @@ SOFTWARE. #include "../../texture_packer/texture_packer.h" #endif -PropTextureCache *PropTextureCache::_instance; +PropCache *PropCache::_instance; -PropTextureCache *PropTextureCache::get_singleton() { +PropCache *PropCache::get_singleton() { return _instance; } #if TEXTURE_PACKER_PRESENT -bool PropTextureCache::has_texture(const Ref &prop) { +bool PropCache::has_texture(const Ref &prop) { for (int i = 0; i < _entries.size(); ++i) { if (_entries[i].prop == prop) { return true; @@ -60,9 +60,9 @@ bool PropTextureCache::has_texture(const Ref &prop) { return false; } -void PropTextureCache::set_texture(const Ref &prop, const Ref &merger) { +void PropCache::set_texture(const Ref &prop, const Ref &merger) { for (int i = 0; i < _entries.size(); ++i) { - PropTextureCacheEntry &e = _entries.write[i]; + PropCacheEntry &e = _entries.write[i]; if (e.prop == prop) { e.merger = merger; @@ -70,9 +70,9 @@ void PropTextureCache::set_texture(const Ref &prop, const Ref PropTextureCache::get_texture(const Ref &prop) { +Ref PropCache::get_texture(const Ref &prop) { for (int i = 0; i < _entries.size(); ++i) { - PropTextureCacheEntry &e = _entries.write[i]; + PropCacheEntry &e = _entries.write[i]; if (e.prop == prop) { e.refcount++; @@ -84,9 +84,9 @@ Ref PropTextureCache::get_texture(const Ref &prop) { return Ref(); } -void PropTextureCache::ref_texture(const Ref &prop) { +void PropCache::ref_texture(const Ref &prop) { for (int i = 0; i < _entries.size(); ++i) { - PropTextureCacheEntry &e = _entries.write[i]; + PropCacheEntry &e = _entries.write[i]; if (e.prop == prop) { e.refcount++; @@ -96,9 +96,9 @@ void PropTextureCache::ref_texture(const Ref &prop) { } } -void PropTextureCache::unref_texture(const Ref &prop) { +void PropCache::unref_texture(const Ref &prop) { for (int i = 0; i < _entries.size(); ++i) { - PropTextureCacheEntry &e = _entries.write[i]; + PropCacheEntry &e = _entries.write[i]; if (e.prop == prop) { e.refcount--; @@ -112,7 +112,7 @@ void PropTextureCache::unref_texture(const Ref &prop) { } } -Ref PropTextureCache::create_texture(const Ref &prop) { +Ref PropCache::create_texture(const Ref &prop) { ERR_FAIL_COND_V(has_texture(prop), Ref()); Ref merger; @@ -124,7 +124,7 @@ Ref PropTextureCache::create_texture(const Ref &prop) { e->add_textures_into(merger); } - PropTextureCacheEntry e; + PropCacheEntry e; e.merger = merger; e.prop = prop; e.refcount = 1; @@ -134,7 +134,7 @@ Ref PropTextureCache::create_texture(const Ref &prop) { return merger; } -Ref PropTextureCache::get_or_create_texture_immediate(const Ref &prop) { +Ref PropCache::get_or_create_texture_immediate(const Ref &prop) { if (!has_texture(prop)) { Ref merger = create_texture(prop); @@ -147,7 +147,7 @@ Ref PropTextureCache::get_or_create_texture_immediate(const Ref

PropTextureCache::get_or_create_texture_threaded(const Ref &prop) { +Ref PropCache::get_or_create_texture_threaded(const Ref &prop) { #if THREAD_POOL_PRESENT if (!has_texture(prop)) { @@ -171,29 +171,29 @@ Ref PropTextureCache::get_or_create_texture_threaded(const Ref merger; Ref prop; }; public: - static PropTextureCache *get_singleton(); + static PropCache *get_singleton(); bool has_texture(const Ref &prop); void set_texture(const Ref &prop, const Ref &merger); @@ -70,15 +70,15 @@ public: Ref get_or_create_texture_threaded(const Ref &prop); private: - Vector _entries; + Vector _entries; - static PropTextureCache *_instance; + static PropCache *_instance; #endif public: - PropTextureCache(); - ~PropTextureCache(); + PropCache(); + ~PropCache(); protected: static void _bind_methods();