mirror of
https://github.com/Relintai/terraman.git
synced 2025-04-23 21:43:23 +02:00
Added initialized property to TerraMaterialCache.
This commit is contained in:
parent
c1b0ee6651
commit
66278f0ab8
@ -22,6 +22,13 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "terra_material_cache.h"
|
#include "terra_material_cache.h"
|
||||||
|
|
||||||
|
bool TerraMaterialCache::get_initialized() {
|
||||||
|
return _initialized;
|
||||||
|
}
|
||||||
|
void TerraMaterialCache::set_initialized(const bool value) {
|
||||||
|
_initialized = value;
|
||||||
|
}
|
||||||
|
|
||||||
//Materials
|
//Materials
|
||||||
Ref<Material> TerraMaterialCache::material_get(const int index) {
|
Ref<Material> TerraMaterialCache::material_get(const int index) {
|
||||||
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>(NULL));
|
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>(NULL));
|
||||||
@ -127,6 +134,7 @@ void TerraMaterialCache::surfaces_clear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TerraMaterialCache::refresh_rects() {
|
void TerraMaterialCache::refresh_rects() {
|
||||||
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerraMaterialCache::setup_material_albedo(Ref<Texture> texture) {
|
void TerraMaterialCache::setup_material_albedo(Ref<Texture> texture) {
|
||||||
@ -136,6 +144,7 @@ void TerraMaterialCache::setup_material_albedo(Ref<Texture> texture) {
|
|||||||
|
|
||||||
TerraMaterialCache::TerraMaterialCache() {
|
TerraMaterialCache::TerraMaterialCache() {
|
||||||
material_users = 0;
|
material_users = 0;
|
||||||
|
_initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TerraMaterialCache::~TerraMaterialCache() {
|
TerraMaterialCache::~TerraMaterialCache() {
|
||||||
@ -144,6 +153,10 @@ TerraMaterialCache::~TerraMaterialCache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TerraMaterialCache::_bind_methods() {
|
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")));
|
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);
|
ClassDB::bind_method(D_METHOD("material_get", "index"), &TerraMaterialCache::material_get);
|
||||||
|
@ -48,6 +48,9 @@ class TerraMaterialCache : public Resource {
|
|||||||
GDCLASS(TerraMaterialCache, Resource)
|
GDCLASS(TerraMaterialCache, Resource)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
bool get_initialized();
|
||||||
|
void set_initialized(const bool value);
|
||||||
|
|
||||||
Ref<Material> material_get(const int index);
|
Ref<Material> material_get(const int index);
|
||||||
Ref<Material> material_lod_get(const int index);
|
Ref<Material> material_lod_get(const int index);
|
||||||
void material_add(const Ref<Material> &value);
|
void material_add(const Ref<Material> &value);
|
||||||
@ -77,9 +80,11 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
bool _initialized;
|
||||||
|
|
||||||
Vector<Ref<TerraSurface>> _surfaces;
|
Vector<Ref<TerraSurface>> _surfaces;
|
||||||
Vector<Ref<Material>> _materials;
|
Vector<Ref<Material>> _materials;
|
||||||
//Ref<TextureMerger> merger; inherited
|
|
||||||
int material_users;
|
int material_users;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,6 +101,8 @@ void TerraMaterialCachePCM::refresh_rects() {
|
|||||||
surface->refresh_rects();
|
surface->refresh_rects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerraMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
|
void TerraMaterialCachePCM::_setup_material_albedo(Ref<Texture> texture) {
|
||||||
|
Loading…
Reference in New Issue
Block a user