mirror of
https://github.com/Relintai/terraman.git
synced 2025-04-23 21:43:23 +02:00
Changed the cached material api a bit to be more efficient.
This commit is contained in:
parent
ac786ab720
commit
40c0b2373e
@ -22,6 +22,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "terraman_library.h"
|
#include "terraman_library.h"
|
||||||
|
|
||||||
|
#include "../world/terra_chunk.h"
|
||||||
|
|
||||||
#ifdef PROPS_PRESENT
|
#ifdef PROPS_PRESENT
|
||||||
#include "../../props/props/prop_data.h"
|
#include "../../props/props/prop_data.h"
|
||||||
#endif
|
#endif
|
||||||
@ -65,11 +67,19 @@ Ref<Material> TerramanLibrary::material_lod_get(const int index) {
|
|||||||
return _materials[index];
|
return _materials[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Material> TerramanLibrary::material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
Variant TerramanLibrary::material_cached_get_key(const Ref<TerraChunk> &chunk) {
|
||||||
return call("_material_lod_cached_get", index, surfaces);
|
return call("_material_cached_get_key", chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Material> TerramanLibrary::_material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
Variant TerramanLibrary::_material_cached_get_key(Ref<TerraChunk> chunk) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::material_lod_cached_get(const int index, const Variant &key) {
|
||||||
|
return call("_material_lod_cached_get", index, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::_material_lod_cached_get(const int index, const Variant &key) {
|
||||||
ERR_FAIL_V_MSG(material_lod_get(index), "This TerramanLibrary doesn't support cached materials!");
|
ERR_FAIL_V_MSG(material_lod_get(index), "This TerramanLibrary doesn't support cached materials!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,15 +142,22 @@ Ref<Material> TerramanLibrary::liquid_material_lod_get(const int index) {
|
|||||||
return _liquid_materials[index];
|
return _liquid_materials[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Material> TerramanLibrary::liquid_material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
Variant TerramanLibrary::liquid_material_cached_get_key(const Ref<TerraChunk> &chunk) {
|
||||||
return call("_liquid_material_lod_cached_get", index, surfaces);
|
return call("_liquid_material_cached_get_key", chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Material> TerramanLibrary::_liquid_material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
Variant TerramanLibrary::_liquid_material_cached_get_key(Ref<TerraChunk> chunk) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::liquid_material_lod_cached_get(const int index, const Variant &key) {
|
||||||
|
return call("_liquid_material_lod_cached_get", index, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::_liquid_material_lod_cached_get(const int index, const Variant &key) {
|
||||||
ERR_FAIL_V_MSG(liquid_material_lod_get(index), "This TerramanLibrary doesn't support cached liquid materials!");
|
ERR_FAIL_V_MSG(liquid_material_lod_get(index), "This TerramanLibrary doesn't support cached liquid materials!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TerramanLibrary::liquid_material_add(const Ref<Material> &value) {
|
void TerramanLibrary::liquid_material_add(const Ref<Material> &value) {
|
||||||
ERR_FAIL_COND(!value.is_valid());
|
ERR_FAIL_COND(!value.is_valid());
|
||||||
|
|
||||||
@ -200,15 +217,22 @@ Ref<Material> TerramanLibrary::prop_material_lod_get(const int index) {
|
|||||||
return _prop_materials[index];
|
return _prop_materials[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Material> TerramanLibrary::prop_material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
Variant TerramanLibrary::prop_material_cached_get_key(const Ref<TerraChunk> &chunk) {
|
||||||
return call("_prop_material_lod_cached_get", index, surfaces);
|
return call("_prop_material_cached_get_key", chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Material> TerramanLibrary::_prop_material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
Variant TerramanLibrary::_prop_material_cached_get_key(Ref<TerraChunk> chunk) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::prop_material_lod_cached_get(const int index, const Variant &key) {
|
||||||
|
return call("_prop_material_lod_cached_get", index, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::_prop_material_lod_cached_get(const int index, const Variant &key) {
|
||||||
ERR_FAIL_V_MSG(prop_material_lod_get(index), "This TerramanLibrary doesn't support cached prop materials!");
|
ERR_FAIL_V_MSG(prop_material_lod_get(index), "This TerramanLibrary doesn't support cached prop materials!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TerramanLibrary::prop_material_add(const Ref<Material> &value) {
|
void TerramanLibrary::prop_material_add(const Ref<Material> &value) {
|
||||||
ERR_FAIL_COND(!value.is_valid());
|
ERR_FAIL_COND(!value.is_valid());
|
||||||
|
|
||||||
@ -323,12 +347,17 @@ void TerramanLibrary::_bind_methods() {
|
|||||||
|
|
||||||
BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::INT, "material_index"), PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")));
|
BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::INT, "material_index"), PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture")));
|
||||||
|
|
||||||
BIND_VMETHOD(MethodInfo("_material_lod_cached_get", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::POOL_INT_ARRAY, "surfaces")));
|
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::NIL, "ret"), "_material_cached_get_key"));
|
||||||
|
BIND_VMETHOD(MethodInfo("_material_lod_cached_get", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "key")));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("material_get", "index"), &TerramanLibrary::material_get);
|
ClassDB::bind_method(D_METHOD("material_get", "index"), &TerramanLibrary::material_get);
|
||||||
ClassDB::bind_method(D_METHOD("material_lod_get", "index"), &TerramanLibrary::material_lod_get);
|
ClassDB::bind_method(D_METHOD("material_lod_get", "index"), &TerramanLibrary::material_lod_get);
|
||||||
ClassDB::bind_method(D_METHOD("material_lod_cached_get", "index", "surfaces"), &TerramanLibrary::material_lod_cached_get);
|
|
||||||
ClassDB::bind_method(D_METHOD("_material_lod_cached_get", "index", "surfaces"), &TerramanLibrary::_material_lod_cached_get);
|
ClassDB::bind_method(D_METHOD("material_cached_get_key", "chunk"), &TerramanLibrary::material_cached_get_key);
|
||||||
|
ClassDB::bind_method(D_METHOD("_material_cached_get_key", "chunk"), &TerramanLibrary::_material_cached_get_key);
|
||||||
|
ClassDB::bind_method(D_METHOD("material_lod_cached_get", "index", "key"), &TerramanLibrary::material_lod_cached_get);
|
||||||
|
ClassDB::bind_method(D_METHOD("_material_lod_cached_get", "index", "key"), &TerramanLibrary::_material_lod_cached_get);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("material_add", "value"), &TerramanLibrary::material_add);
|
ClassDB::bind_method(D_METHOD("material_add", "value"), &TerramanLibrary::material_add);
|
||||||
ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &TerramanLibrary::material_set);
|
ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &TerramanLibrary::material_set);
|
||||||
ClassDB::bind_method(D_METHOD("material_remove", "index"), &TerramanLibrary::material_remove);
|
ClassDB::bind_method(D_METHOD("material_remove", "index"), &TerramanLibrary::material_remove);
|
||||||
@ -339,12 +368,17 @@ void TerramanLibrary::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("materials_set"), &TerramanLibrary::materials_set);
|
ClassDB::bind_method(D_METHOD("materials_set"), &TerramanLibrary::materials_set);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get");
|
||||||
|
|
||||||
BIND_VMETHOD(MethodInfo("_liquid_material_lod_cached_get", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::POOL_INT_ARRAY, "surfaces")));
|
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::NIL, "ret"), "_liquid_material_cached_get_key"));
|
||||||
|
BIND_VMETHOD(MethodInfo("_liquid_material_lod_cached_get", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "key")));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("liquid_material_get", "index"), &TerramanLibrary::liquid_material_get);
|
ClassDB::bind_method(D_METHOD("liquid_material_get", "index"), &TerramanLibrary::liquid_material_get);
|
||||||
ClassDB::bind_method(D_METHOD("liquid_material_lod_get", "index"), &TerramanLibrary::liquid_material_lod_get);
|
ClassDB::bind_method(D_METHOD("liquid_material_lod_get", "index"), &TerramanLibrary::liquid_material_lod_get);
|
||||||
ClassDB::bind_method(D_METHOD("liquid_material_lod_cached_get", "index", "surfaces"), &TerramanLibrary::liquid_material_lod_cached_get);
|
|
||||||
ClassDB::bind_method(D_METHOD("_liquid_material_lod_cached_get", "index", "surfaces"), &TerramanLibrary::_liquid_material_lod_cached_get);
|
ClassDB::bind_method(D_METHOD("liquid_material_cached_get_key", "chunk"), &TerramanLibrary::liquid_material_cached_get_key);
|
||||||
|
ClassDB::bind_method(D_METHOD("_liquid_material_cached_get_key", "chunk"), &TerramanLibrary::_liquid_material_cached_get_key);
|
||||||
|
ClassDB::bind_method(D_METHOD("liquid_material_lod_cached_get", "index", "key"), &TerramanLibrary::liquid_material_lod_cached_get);
|
||||||
|
ClassDB::bind_method(D_METHOD("_liquid_material_lod_cached_get", "index", "key"), &TerramanLibrary::_liquid_material_lod_cached_get);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("liquid_material_add", "value"), &TerramanLibrary::liquid_material_add);
|
ClassDB::bind_method(D_METHOD("liquid_material_add", "value"), &TerramanLibrary::liquid_material_add);
|
||||||
ClassDB::bind_method(D_METHOD("liquid_material_set", "index", "value"), &TerramanLibrary::liquid_material_set);
|
ClassDB::bind_method(D_METHOD("liquid_material_set", "index", "value"), &TerramanLibrary::liquid_material_set);
|
||||||
ClassDB::bind_method(D_METHOD("liquid_material_remove", "index"), &TerramanLibrary::liquid_material_remove);
|
ClassDB::bind_method(D_METHOD("liquid_material_remove", "index"), &TerramanLibrary::liquid_material_remove);
|
||||||
@ -355,12 +389,17 @@ void TerramanLibrary::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("liquid_materials_set"), &TerramanLibrary::liquid_materials_set);
|
ClassDB::bind_method(D_METHOD("liquid_materials_set"), &TerramanLibrary::liquid_materials_set);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "liquid_materials_set", "liquid_materials_get");
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "liquid_materials_set", "liquid_materials_get");
|
||||||
|
|
||||||
BIND_VMETHOD(MethodInfo("_material_lod_cached_get", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::POOL_INT_ARRAY, "surfaces")));
|
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::NIL, "ret"), "_prop_material_cached_get_key"));
|
||||||
|
BIND_VMETHOD(MethodInfo("_prop_material_lod_cached_get", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::NIL, "key")));
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("prop_material_get", "index"), &TerramanLibrary::prop_material_get);
|
ClassDB::bind_method(D_METHOD("prop_material_get", "index"), &TerramanLibrary::prop_material_get);
|
||||||
ClassDB::bind_method(D_METHOD("prop_material_lod_get", "index"), &TerramanLibrary::prop_material_lod_get);
|
ClassDB::bind_method(D_METHOD("prop_material_lod_get", "index"), &TerramanLibrary::prop_material_lod_get);
|
||||||
ClassDB::bind_method(D_METHOD("prop_material_lod_cached_get", "index", "surfaces"), &TerramanLibrary::prop_material_lod_cached_get);
|
|
||||||
ClassDB::bind_method(D_METHOD("_prop_material_lod_cached_get", "index", "surfaces"), &TerramanLibrary::_prop_material_lod_cached_get);
|
ClassDB::bind_method(D_METHOD("prop_material_cached_get_key", "chunk"), &TerramanLibrary::prop_material_cached_get_key);
|
||||||
|
ClassDB::bind_method(D_METHOD("_prop_material_cached_get_key", "chunk"), &TerramanLibrary::_prop_material_cached_get_key);
|
||||||
|
ClassDB::bind_method(D_METHOD("prop_material_lod_cached_get", "index", "key"), &TerramanLibrary::prop_material_lod_cached_get);
|
||||||
|
ClassDB::bind_method(D_METHOD("_prop_material_lod_cached_get", "index", "key"), &TerramanLibrary::_prop_material_lod_cached_get);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("prop_material_add", "value"), &TerramanLibrary::prop_material_add);
|
ClassDB::bind_method(D_METHOD("prop_material_add", "value"), &TerramanLibrary::prop_material_add);
|
||||||
ClassDB::bind_method(D_METHOD("prop_material_set", "index", "value"), &TerramanLibrary::prop_material_set);
|
ClassDB::bind_method(D_METHOD("prop_material_set", "index", "value"), &TerramanLibrary::prop_material_set);
|
||||||
ClassDB::bind_method(D_METHOD("prop_material_remove", "index"), &TerramanLibrary::prop_material_remove);
|
ClassDB::bind_method(D_METHOD("prop_material_remove", "index"), &TerramanLibrary::prop_material_remove);
|
||||||
|
@ -46,6 +46,7 @@ SOFTWARE.
|
|||||||
class TerraSurface;
|
class TerraSurface;
|
||||||
class TerraMesher;
|
class TerraMesher;
|
||||||
class PackedScene;
|
class PackedScene;
|
||||||
|
class TerraChunk;
|
||||||
#ifdef PROPS_PRESENT
|
#ifdef PROPS_PRESENT
|
||||||
class PropData;
|
class PropData;
|
||||||
#endif
|
#endif
|
||||||
@ -69,8 +70,12 @@ public:
|
|||||||
|
|
||||||
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);
|
||||||
Ref<Material> material_lod_cached_get(const int index, const PoolIntArray &surfaces);
|
|
||||||
virtual Ref<Material> _material_lod_cached_get(const int index, const PoolIntArray &surfaces);
|
Variant material_cached_get_key(const Ref<TerraChunk> &chunk);
|
||||||
|
virtual Variant _material_cached_get_key(Ref<TerraChunk> chunk);
|
||||||
|
Ref<Material> material_lod_cached_get(const int index, const Variant &key);
|
||||||
|
virtual Ref<Material> _material_lod_cached_get(const int index, const Variant &key);
|
||||||
|
|
||||||
void material_add(const Ref<Material> &value);
|
void material_add(const Ref<Material> &value);
|
||||||
void material_set(const int index, const Ref<Material> &value);
|
void material_set(const int index, const Ref<Material> &value);
|
||||||
void material_remove(const int index);
|
void material_remove(const int index);
|
||||||
@ -82,8 +87,12 @@ public:
|
|||||||
|
|
||||||
Ref<Material> liquid_material_get(const int index);
|
Ref<Material> liquid_material_get(const int index);
|
||||||
Ref<Material> liquid_material_lod_get(const int index);
|
Ref<Material> liquid_material_lod_get(const int index);
|
||||||
Ref<Material> liquid_material_lod_cached_get(const int index, const PoolIntArray &surfaces);
|
|
||||||
virtual Ref<Material> _liquid_material_lod_cached_get(const int index, const PoolIntArray &surfaces);
|
Variant liquid_material_cached_get_key(const Ref<TerraChunk> &chunk);
|
||||||
|
virtual Variant _liquid_material_cached_get_key(Ref<TerraChunk> chunk);
|
||||||
|
Ref<Material> liquid_material_lod_cached_get(const int index, const Variant &key);
|
||||||
|
virtual Ref<Material> _liquid_material_lod_cached_get(const int index, const Variant &key);
|
||||||
|
|
||||||
void liquid_material_add(const Ref<Material> &value);
|
void liquid_material_add(const Ref<Material> &value);
|
||||||
void liquid_material_set(const int index, const Ref<Material> &value);
|
void liquid_material_set(const int index, const Ref<Material> &value);
|
||||||
void liquid_material_remove(const int index);
|
void liquid_material_remove(const int index);
|
||||||
@ -95,8 +104,12 @@ public:
|
|||||||
|
|
||||||
Ref<Material> prop_material_get(const int index);
|
Ref<Material> prop_material_get(const int index);
|
||||||
Ref<Material> prop_material_lod_get(const int index);
|
Ref<Material> prop_material_lod_get(const int index);
|
||||||
Ref<Material> prop_material_lod_cached_get(const int index, const PoolIntArray &surfaces);
|
|
||||||
virtual Ref<Material> _prop_material_lod_cached_get(const int index, const PoolIntArray &surfaces);
|
Variant prop_material_cached_get_key(const Ref<TerraChunk> &chunk);
|
||||||
|
virtual Variant _prop_material_cached_get_key(Ref<TerraChunk> chunk);
|
||||||
|
Ref<Material> prop_material_lod_cached_get(const int index, const Variant &key);
|
||||||
|
virtual Ref<Material> _prop_material_lod_cached_get(const int index, const Variant &key);
|
||||||
|
|
||||||
void prop_material_add(const Ref<Material> &value);
|
void prop_material_add(const Ref<Material> &value);
|
||||||
void prop_material_set(const int index, const Ref<Material> &value);
|
void prop_material_set(const int index, const Ref<Material> &value);
|
||||||
void prop_material_remove(const int index);
|
void prop_material_remove(const int index);
|
||||||
|
Loading…
Reference in New Issue
Block a user