mirror of
https://github.com/Relintai/terraman.git
synced 2025-04-23 21:43:23 +02:00
Added an api to terraman library to be able to support cached per chunk materials.
This commit is contained in:
parent
0d26975678
commit
cc634fb760
@ -37,13 +37,42 @@ void TerramanLibrary::set_initialized(const bool value) {
|
|||||||
_initialized = value;
|
_initialized = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TerramanLibrary::supports_caching() {
|
||||||
|
return call("_supports_caching");
|
||||||
|
}
|
||||||
|
bool TerramanLibrary::_supports_caching() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//Materials
|
//Materials
|
||||||
Ref<Material> TerramanLibrary::material_get(const int index) {
|
Ref<Material> TerramanLibrary::material_get(const int index) {
|
||||||
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<TerraSurface>(NULL));
|
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>(NULL));
|
||||||
|
|
||||||
return _materials[index];
|
return _materials[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::material_lod_get(const int index) {
|
||||||
|
ERR_FAIL_COND_V(_materials.size() == 0, Ref<Material>(NULL));
|
||||||
|
|
||||||
|
if (index < 0) {
|
||||||
|
return _materials[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index >= _materials.size()) {
|
||||||
|
return _materials[_materials.size() - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _materials[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
||||||
|
return call("_material_lod_cached_get", index, surfaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::_material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
||||||
|
ERR_FAIL_V_MSG(material_lod_get(index), "This TerramanLibrary doesn't support cached materials!");
|
||||||
|
}
|
||||||
|
|
||||||
void TerramanLibrary::material_add(const Ref<Material> &value) {
|
void TerramanLibrary::material_add(const Ref<Material> &value) {
|
||||||
ERR_FAIL_COND(!value.is_valid());
|
ERR_FAIL_COND(!value.is_valid());
|
||||||
|
|
||||||
@ -84,11 +113,34 @@ void TerramanLibrary::materials_set(const Vector<Variant> &materials) {
|
|||||||
|
|
||||||
//Liquid Materials
|
//Liquid Materials
|
||||||
Ref<Material> TerramanLibrary::liquid_material_get(const int index) {
|
Ref<Material> TerramanLibrary::liquid_material_get(const int index) {
|
||||||
ERR_FAIL_INDEX_V(index, _liquid_materials.size(), Ref<TerraSurface>(NULL));
|
ERR_FAIL_INDEX_V(index, _liquid_materials.size(), Ref<Material>(NULL));
|
||||||
|
|
||||||
return _liquid_materials[index];
|
return _liquid_materials[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::liquid_material_lod_get(const int index) {
|
||||||
|
ERR_FAIL_COND_V(_materials.size() == 0, Ref<Material>(NULL));
|
||||||
|
|
||||||
|
if (index < 0) {
|
||||||
|
return _liquid_materials[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index >= _liquid_materials.size()) {
|
||||||
|
return _liquid_materials[_liquid_materials.size() - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _liquid_materials[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::liquid_material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
||||||
|
return call("_liquid_material_lod_cached_get", index, surfaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::_liquid_material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
||||||
|
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());
|
||||||
|
|
||||||
@ -129,11 +181,34 @@ void TerramanLibrary::liquid_materials_set(const Vector<Variant> &materials) {
|
|||||||
|
|
||||||
//Prop Materials
|
//Prop Materials
|
||||||
Ref<Material> TerramanLibrary::prop_material_get(const int index) {
|
Ref<Material> TerramanLibrary::prop_material_get(const int index) {
|
||||||
ERR_FAIL_INDEX_V(index, _prop_materials.size(), Ref<TerraSurface>(NULL));
|
ERR_FAIL_INDEX_V(index, _prop_materials.size(), Ref<Material>(NULL));
|
||||||
|
|
||||||
return _prop_materials[index];
|
return _prop_materials[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::prop_material_lod_get(const int index) {
|
||||||
|
ERR_FAIL_COND_V(_prop_materials.size() == 0, Ref<Material>(NULL));
|
||||||
|
|
||||||
|
if (index < 0) {
|
||||||
|
return _prop_materials[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index >= _prop_materials.size()) {
|
||||||
|
return _prop_materials[_prop_materials.size() - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _prop_materials[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::prop_material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
||||||
|
return call("_prop_material_lod_cached_get", index, surfaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Material> TerramanLibrary::_prop_material_lod_cached_get(const int index, const PoolIntArray &surfaces) {
|
||||||
|
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());
|
||||||
|
|
||||||
@ -248,7 +323,12 @@ 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")));
|
||||||
|
|
||||||
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_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_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);
|
||||||
@ -259,7 +339,12 @@ 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")));
|
||||||
|
|
||||||
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_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_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);
|
||||||
@ -270,7 +355,12 @@ 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")));
|
||||||
|
|
||||||
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_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_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);
|
||||||
|
@ -64,7 +64,13 @@ public:
|
|||||||
bool get_initialized() const;
|
bool get_initialized() const;
|
||||||
void set_initialized(const bool value);
|
void set_initialized(const bool value);
|
||||||
|
|
||||||
|
bool supports_caching();
|
||||||
|
virtual bool _supports_caching();
|
||||||
|
|
||||||
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_cached_get(const int index, const PoolIntArray &surfaces);
|
||||||
|
virtual Ref<Material> _material_lod_cached_get(const int index, const PoolIntArray &surfaces);
|
||||||
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);
|
||||||
@ -75,6 +81,9 @@ public:
|
|||||||
void materials_set(const Vector<Variant> &materials);
|
void materials_set(const Vector<Variant> &materials);
|
||||||
|
|
||||||
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_cached_get(const int index, const PoolIntArray &surfaces);
|
||||||
|
virtual Ref<Material> _liquid_material_lod_cached_get(const int index, const PoolIntArray &surfaces);
|
||||||
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);
|
||||||
@ -85,6 +94,9 @@ public:
|
|||||||
void liquid_materials_set(const Vector<Variant> &materials);
|
void liquid_materials_set(const Vector<Variant> &materials);
|
||||||
|
|
||||||
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_cached_get(const int index, const PoolIntArray &surfaces);
|
||||||
|
virtual Ref<Material> _prop_material_lod_cached_get(const int index, const PoolIntArray &surfaces);
|
||||||
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