mirror of
https://github.com/Relintai/terraman.git
synced 2025-04-23 21:43:23 +02:00
Renamed _cache_mutex to _material_cache_mutex, and added a new _prop_material_cache_mutex.
This commit is contained in:
parent
6cf36fcd05
commit
63a488d16d
@ -101,7 +101,7 @@ void TerramanLibraryMergerPCM::_material_cache_get_key(Ref<TerraChunk> chunk) {
|
|||||||
chunk->material_cache_key_set(hash);
|
chunk->material_cache_key_set(hash);
|
||||||
chunk->material_cache_key_has_set(true);
|
chunk->material_cache_key_has_set(true);
|
||||||
|
|
||||||
_cache_mutex.lock();
|
_material_cache_mutex.lock();
|
||||||
|
|
||||||
if (_material_cache.has(hash)) {
|
if (_material_cache.has(hash)) {
|
||||||
Ref<TerraMaterialCachePCM> cc = _material_cache[hash];
|
Ref<TerraMaterialCachePCM> cc = _material_cache[hash];
|
||||||
@ -110,7 +110,7 @@ void TerramanLibraryMergerPCM::_material_cache_get_key(Ref<TerraChunk> chunk) {
|
|||||||
cc->inc_ref_count();
|
cc->inc_ref_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
_cache_mutex.unlock();
|
_material_cache_mutex.unlock();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ void TerramanLibraryMergerPCM::_material_cache_get_key(Ref<TerraChunk> chunk) {
|
|||||||
_material_cache[hash] = cache;
|
_material_cache[hash] = cache;
|
||||||
|
|
||||||
//unlock here, so if a different thread need the cache it will be able to immediately access the materials and surfaces when it gets it.
|
//unlock here, so if a different thread need the cache it will be able to immediately access the materials and surfaces when it gets it.
|
||||||
_cache_mutex.unlock();
|
_material_cache_mutex.unlock();
|
||||||
|
|
||||||
//this will generate the atlases
|
//this will generate the atlases
|
||||||
cache->refresh_rects();
|
cache->refresh_rects();
|
||||||
@ -179,7 +179,7 @@ Ref<TerraMaterialCache> TerramanLibraryMergerPCM::_material_cache_get(const int
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TerramanLibraryMergerPCM::_material_cache_unref(const int key) {
|
void TerramanLibraryMergerPCM::_material_cache_unref(const int key) {
|
||||||
_cache_mutex.lock();
|
_material_cache_mutex.lock();
|
||||||
|
|
||||||
if (!_material_cache.has(key)) {
|
if (!_material_cache.has(key)) {
|
||||||
return;
|
return;
|
||||||
@ -197,7 +197,7 @@ void TerramanLibraryMergerPCM::_material_cache_unref(const int key) {
|
|||||||
_material_cache.erase(key);
|
_material_cache.erase(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
_cache_mutex.unlock();
|
_material_cache_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TerramanLibraryMergerPCM::get_texture_flags() const {
|
int TerramanLibraryMergerPCM::get_texture_flags() const {
|
||||||
|
@ -54,6 +54,7 @@ class TerramanLibraryMergerPCM : public TerramanLibrary {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
bool _supports_caching();
|
bool _supports_caching();
|
||||||
|
|
||||||
void _material_cache_get_key(Ref<TerraChunk> chunk);
|
void _material_cache_get_key(Ref<TerraChunk> chunk);
|
||||||
Ref<TerraMaterialCache> _material_cache_get(const int key);
|
Ref<TerraMaterialCache> _material_cache_get(const int key);
|
||||||
void _material_cache_unref(const int key);
|
void _material_cache_unref(const int key);
|
||||||
@ -125,7 +126,8 @@ protected:
|
|||||||
Ref<TexturePacker> _packer;
|
Ref<TexturePacker> _packer;
|
||||||
Ref<TexturePacker> _prop_packer;
|
Ref<TexturePacker> _prop_packer;
|
||||||
|
|
||||||
Mutex _cache_mutex;
|
Mutex _material_cache_mutex;
|
||||||
|
Mutex _prop_material_cache_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user