diff --git a/library/terraman_library.cpp b/library/terraman_library.cpp index 61a0676..d9d319e 100644 --- a/library/terraman_library.cpp +++ b/library/terraman_library.cpp @@ -22,6 +22,8 @@ SOFTWARE. #include "terraman_library.h" +#include "../world/terra_chunk.h" + #ifdef PROPS_PRESENT #include "../../props/props/prop_data.h" #endif @@ -65,11 +67,19 @@ Ref TerramanLibrary::material_lod_get(const int index) { return _materials[index]; } -Ref TerramanLibrary::material_lod_cached_get(const int index, const PoolIntArray &surfaces) { - return call("_material_lod_cached_get", index, surfaces); +Variant TerramanLibrary::material_cached_get_key(const Ref &chunk) { + return call("_material_cached_get_key", chunk); } -Ref TerramanLibrary::_material_lod_cached_get(const int index, const PoolIntArray &surfaces) { +Variant TerramanLibrary::_material_cached_get_key(Ref chunk) { + return 0; +} + +Ref TerramanLibrary::material_lod_cached_get(const int index, const Variant &key) { + return call("_material_lod_cached_get", index, key); +} + +Ref 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!"); } @@ -132,15 +142,22 @@ Ref TerramanLibrary::liquid_material_lod_get(const int index) { return _liquid_materials[index]; } -Ref TerramanLibrary::liquid_material_lod_cached_get(const int index, const PoolIntArray &surfaces) { - return call("_liquid_material_lod_cached_get", index, surfaces); +Variant TerramanLibrary::liquid_material_cached_get_key(const Ref &chunk) { + return call("_liquid_material_cached_get_key", chunk); } -Ref TerramanLibrary::_liquid_material_lod_cached_get(const int index, const PoolIntArray &surfaces) { +Variant TerramanLibrary::_liquid_material_cached_get_key(Ref chunk) { + return 0; +} + +Ref TerramanLibrary::liquid_material_lod_cached_get(const int index, const Variant &key) { + return call("_liquid_material_lod_cached_get", index, key); +} + +Ref 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!"); } - void TerramanLibrary::liquid_material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); @@ -200,15 +217,22 @@ Ref TerramanLibrary::prop_material_lod_get(const int index) { return _prop_materials[index]; } -Ref TerramanLibrary::prop_material_lod_cached_get(const int index, const PoolIntArray &surfaces) { - return call("_prop_material_lod_cached_get", index, surfaces); +Variant TerramanLibrary::prop_material_cached_get_key(const Ref &chunk) { + return call("_prop_material_cached_get_key", chunk); } -Ref TerramanLibrary::_prop_material_lod_cached_get(const int index, const PoolIntArray &surfaces) { +Variant TerramanLibrary::_prop_material_cached_get_key(Ref chunk) { + return 0; +} + +Ref TerramanLibrary::prop_material_lod_cached_get(const int index, const Variant &key) { + return call("_prop_material_lod_cached_get", index, key); +} + +Ref 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!"); } - void TerramanLibrary::prop_material_add(const Ref &value) { 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("_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_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_set", "index", "value"), &TerramanLibrary::material_set); 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); 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_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_set", "index", "value"), &TerramanLibrary::liquid_material_set); 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); 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_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_set", "index", "value"), &TerramanLibrary::prop_material_set); ClassDB::bind_method(D_METHOD("prop_material_remove", "index"), &TerramanLibrary::prop_material_remove); diff --git a/library/terraman_library.h b/library/terraman_library.h index 5b61bbe..945a560 100644 --- a/library/terraman_library.h +++ b/library/terraman_library.h @@ -46,6 +46,7 @@ SOFTWARE. class TerraSurface; class TerraMesher; class PackedScene; +class TerraChunk; #ifdef PROPS_PRESENT class PropData; #endif @@ -69,8 +70,12 @@ public: Ref material_get(const int index); Ref material_lod_get(const int index); - Ref material_lod_cached_get(const int index, const PoolIntArray &surfaces); - virtual Ref _material_lod_cached_get(const int index, const PoolIntArray &surfaces); + + Variant material_cached_get_key(const Ref &chunk); + virtual Variant _material_cached_get_key(Ref chunk); + Ref material_lod_cached_get(const int index, const Variant &key); + virtual Ref _material_lod_cached_get(const int index, const Variant &key); + void material_add(const Ref &value); void material_set(const int index, const Ref &value); void material_remove(const int index); @@ -82,8 +87,12 @@ public: Ref liquid_material_get(const int index); Ref liquid_material_lod_get(const int index); - Ref liquid_material_lod_cached_get(const int index, const PoolIntArray &surfaces); - virtual Ref _liquid_material_lod_cached_get(const int index, const PoolIntArray &surfaces); + + Variant liquid_material_cached_get_key(const Ref &chunk); + virtual Variant _liquid_material_cached_get_key(Ref chunk); + Ref liquid_material_lod_cached_get(const int index, const Variant &key); + virtual Ref _liquid_material_lod_cached_get(const int index, const Variant &key); + void liquid_material_add(const Ref &value); void liquid_material_set(const int index, const Ref &value); void liquid_material_remove(const int index); @@ -95,8 +104,12 @@ public: Ref prop_material_get(const int index); Ref prop_material_lod_get(const int index); - Ref prop_material_lod_cached_get(const int index, const PoolIntArray &surfaces); - virtual Ref _prop_material_lod_cached_get(const int index, const PoolIntArray &surfaces); + + Variant prop_material_cached_get_key(const Ref &chunk); + virtual Variant _prop_material_cached_get_key(Ref chunk); + Ref prop_material_lod_cached_get(const int index, const Variant &key); + virtual Ref _prop_material_lod_cached_get(const int index, const Variant &key); + void prop_material_add(const Ref &value); void prop_material_set(const int index, const Ref &value); void prop_material_remove(const int index);