diff --git a/LICENSE b/LICENSE index dfbc805..01f5bc2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/SCsub b/SCsub index 7df318d..51e2202 100644 --- a/SCsub +++ b/SCsub @@ -6,8 +6,8 @@ module_env = env.Clone() import version -#if os.path.isdir('../mesh_data_resource'): - #module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) +if os.path.isdir('../mesh_data_resource'): + module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) has_texture_packer = False @@ -29,48 +29,48 @@ sources = [ "register_types.cpp", - "lights/prop_light_2d.cpp", + "lights/prop_light.cpp", - "tiled_wall/tiled_wall_2d.cpp", - "tiled_wall/tiled_wall_data_2d.cpp", + "tiled_wall/tiled_wall.cpp", + "tiled_wall/tiled_wall_data.cpp", - "props/prop_data_2d.cpp", - "props/prop_data_entry_2d.cpp", - "props/prop_data_scene_2d.cpp", - "props/prop_data_light_2d.cpp", - "props/prop_data_prop_2d.cpp", - "props/prop_data_tiled_wall_2d.cpp", + "props/prop_data.cpp", + "props/prop_data_entry.cpp", + "props/prop_data_scene.cpp", + "props/prop_data_light.cpp", + "props/prop_data_prop.cpp", + "props/prop_data_tiled_wall.cpp", - "clutter/ground_clutter_2d.cpp", - "clutter/ground_clutter_foliage_2d.cpp", + "clutter/ground_clutter.cpp", + "clutter/ground_clutter_foliage.cpp", - "prop_instance_2d.cpp", - "prop_instance_merger_2d.cpp", - "prop_ess_entity_2d.cpp", - "prop_instance_job_2d.cpp", - "prop_instance_prop_job_2d.cpp", + "prop_instance.cpp", + "prop_instance_merger.cpp", + "prop_ess_entity.cpp", + "prop_instance_job.cpp", + "prop_instance_prop_job.cpp", - "prop_scene_instance_2d.cpp", + "prop_scene_instance.cpp", - "singleton/prop_utils_2d.cpp", - "singleton/prop_cache_2d.cpp", + "singleton/prop_utils.cpp", + "singleton/prop_cache.cpp", - "editor/prop_editor_plugin_2d.cpp", + "editor/prop_editor_plugin.cpp", - "prop_mesher_2d.cpp", + "prop_mesher.cpp", - "jobs/prop_texture_job_2d.cpp", + "jobs/prop_texture_job.cpp", - "jobs/prop_mesher_job_step_2d.cpp", + "jobs/prop_mesher_job_step.cpp", - "material_cache/prop_material_cache_2d.cpp" + "material_cache/prop_material_cache.cpp" ] if version.minor >= 4: - sources.append("props/prop_data_portal_2d.cpp") + sources.append("props/prop_data_portal.cpp") if has_texture_packer: - sources.append("material_cache/prop_material_cache_pcm_2d.cpp") + sources.append("material_cache/prop_material_cache_pcm.cpp") if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': # Shared lib compilation diff --git a/clutter/ground_clutter_2d.cpp b/clutter/ground_clutter.cpp similarity index 80% rename from clutter/ground_clutter_2d.cpp rename to clutter/ground_clutter.cpp index fa5c6b2..ef7e590 100644 --- a/clutter/ground_clutter_2d.cpp +++ b/clutter/ground_clutter.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,50 +20,50 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "ground_clutter_2d.h" +#include "ground_clutter.h" #ifdef VOXELMAN_PRESENT #include "../../voxelman/world/voxel_chunk.h" -bool GroundClutter2D::should_spawn(Ref chunk, int x, int y, int z) { +bool GroundClutter::should_spawn(Ref chunk, int x, int y, int z) { if (has_method("_should_spawn")) return call("_should_spawn", chunk, x, y, z); return false; } -void GroundClutter2D::add_meshes_to(Ref mesher, Ref chunk, int x, int y, int z) { +void GroundClutter::add_meshes_to(Ref mesher, Ref chunk, int x, int y, int z) { if (has_method("_add_meshes_to")) call("_add_meshes_to", mesher, chunk, x, y, z); } #endif #ifdef TEXTURE_PACKER_PRESENT -void GroundClutter2D::add_textures_to(Ref packer) { +void GroundClutter::add_textures_to(Ref packer) { if (has_method("_add_textures_to")) call("_add_textures_to", packer); } #endif -GroundClutter2D::GroundClutter2D() { +GroundClutter::GroundClutter() { } -GroundClutter2D::~GroundClutter2D() { +GroundClutter::~GroundClutter() { } -void GroundClutter2D::_bind_methods() { +void GroundClutter::_bind_methods() { #ifdef TEXTURE_PACKER_PRESENT BIND_VMETHOD(MethodInfo("_add_textures_to", PropertyInfo(Variant::OBJECT, "packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker"))); - ClassDB::bind_method(D_METHOD("add_textures_to", "packer"), &GroundClutter2D::add_textures_to); + ClassDB::bind_method(D_METHOD("add_textures_to", "packer"), &GroundClutter::add_textures_to); #endif #ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "should"), "_should_spawn", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z"))); BIND_VMETHOD(MethodInfo("_add_meshes_to", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z"))); - ClassDB::bind_method(D_METHOD("should_spawn", "chunk", "x", "y", "z"), &GroundClutter2D::should_spawn); - ClassDB::bind_method(D_METHOD("add_meshes_to", "mesher", "chunk", "x", "y", "z"), &GroundClutter2D::add_meshes_to); + ClassDB::bind_method(D_METHOD("should_spawn", "chunk", "x", "y", "z"), &GroundClutter::should_spawn); + ClassDB::bind_method(D_METHOD("add_meshes_to", "mesher", "chunk", "x", "y", "z"), &GroundClutter::add_meshes_to); #endif } diff --git a/clutter/ground_clutter_2d.h b/clutter/ground_clutter.h similarity index 88% rename from clutter/ground_clutter_2d.h rename to clutter/ground_clutter.h index e026064..981c6ca 100644 --- a/clutter/ground_clutter_2d.h +++ b/clutter/ground_clutter.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef GROUND_CLUTTER_2D_H -#define GROUND_CLUTTER_2D_H +#ifndef GROUND_CLUTTER_H +#define GROUND_CLUTTER_H #include "core/version.h" @@ -42,8 +42,8 @@ SOFTWARE. class VoxelChunk; class VoxelMesher; -class GroundClutter2D : public Resource { - GDCLASS(GroundClutter2D, Resource); +class GroundClutter : public Resource { + GDCLASS(GroundClutter, Resource); public: #ifdef VOXELMAN_PRESENT @@ -56,8 +56,8 @@ public: void add_textures_to(Ref packer); #endif - GroundClutter2D(); - ~GroundClutter2D(); + GroundClutter(); + ~GroundClutter(); private: static void _bind_methods(); diff --git a/clutter/ground_clutter_foliage_2d.cpp b/clutter/ground_clutter_foliage.cpp similarity index 71% rename from clutter/ground_clutter_foliage_2d.cpp rename to clutter/ground_clutter_foliage.cpp index c918552..2f399f1 100644 --- a/clutter/ground_clutter_foliage_2d.cpp +++ b/clutter/ground_clutter_foliage.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,35 +20,35 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "ground_clutter_foliage_2d.h" +#include "ground_clutter_foliage.h" -int GroundClutterFoliage2D::get_texture_count() const { +int GroundClutterFoliage::get_texture_count() const { return _textures.size(); } -Ref GroundClutterFoliage2D::get_texture(const int index) { +Ref GroundClutterFoliage::get_texture(const int index) { ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); return _textures.get(index); } -void GroundClutterFoliage2D::remove_texture(const int index) { +void GroundClutterFoliage::remove_texture(const int index) { ERR_FAIL_INDEX(index, _textures.size()); _textures.remove(index); } -void GroundClutterFoliage2D::add_texture(Ref texture) { +void GroundClutterFoliage::add_texture(Ref texture) { _textures.push_back(texture); } -GroundClutterFoliage2D::GroundClutterFoliage2D() { +GroundClutterFoliage::GroundClutterFoliage() { } -GroundClutterFoliage2D::~GroundClutterFoliage2D() { +GroundClutterFoliage::~GroundClutterFoliage() { _textures.clear(); } -void GroundClutterFoliage2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_texture_count"), &GroundClutterFoliage2D::get_texture_count); - ClassDB::bind_method(D_METHOD("get_texture", "index"), &GroundClutterFoliage2D::get_texture); - ClassDB::bind_method(D_METHOD("remove_texture", "index"), &GroundClutterFoliage2D::remove_texture); - ClassDB::bind_method(D_METHOD("add_texture", "texture"), &GroundClutterFoliage2D::add_texture); +void GroundClutterFoliage::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_texture_count"), &GroundClutterFoliage::get_texture_count); + ClassDB::bind_method(D_METHOD("get_texture", "index"), &GroundClutterFoliage::get_texture); + ClassDB::bind_method(D_METHOD("remove_texture", "index"), &GroundClutterFoliage::remove_texture); + ClassDB::bind_method(D_METHOD("add_texture", "texture"), &GroundClutterFoliage::add_texture); } diff --git a/clutter/ground_clutter_foliage_2d.h b/clutter/ground_clutter_foliage.h similarity index 82% rename from clutter/ground_clutter_foliage_2d.h rename to clutter/ground_clutter_foliage.h index c4f2026..a92f24c 100644 --- a/clutter/ground_clutter_foliage_2d.h +++ b/clutter/ground_clutter_foliage.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef GROUND_CLUTTER_FOLIAGE_2D_H -#define GROUND_CLUTTER_FOLIAGE_2D_H +#ifndef GROUND_CLUTTER_FOLIAGE_H +#define GROUND_CLUTTER_FOLIAGE_H #include "core/version.h" @@ -31,12 +31,12 @@ SOFTWARE. #include "core/vector.h" #endif -#include "ground_clutter_2d.h" +#include "ground_clutter.h" #include "scene/resources/texture.h" -class GroundClutterFoliage2D : public GroundClutter2D { - GDCLASS(GroundClutterFoliage2D, GroundClutter2D); +class GroundClutterFoliage : public GroundClutter { + GDCLASS(GroundClutterFoliage, GroundClutter); public: int get_texture_count() const; @@ -44,8 +44,8 @@ public: void remove_texture(const int index); void add_texture(Ref texture); - GroundClutterFoliage2D(); - ~GroundClutterFoliage2D(); + GroundClutterFoliage(); + ~GroundClutterFoliage(); private: static void _bind_methods(); diff --git a/config.py b/config.py index cb7bb82..b7f8515 100644 --- a/config.py +++ b/config.py @@ -10,29 +10,41 @@ def configure(env): def get_doc_classes(): return [ - "PropDataEntry2D", - "PropDataLight2D", - "PropDataProp2D", - "PropDataScene2D", - "PropDataPortal2D", - "PropDataTiledWall2D", - "PropData2D", + "PropDataEntry", + "PropDataLight", + "PropDataProp", + "PropDataScene", + "PropDataPortal", + "PropDataTiledWall", + "PropData", - "TiledWall2D", - "TiledWallData2D", + "TiledWall", + "TiledWallData", - "PropDataProcessor2D", + "PropDataProcessor", - "GroundClutterFoliage2D", - "GroundClutter2D", + "GroundClutterFoliage", + "GroundClutter", - "PropESSEntity2D", - "PropInstance2D", - "PropMeshUtils2D", + "PropESSEntity", + "PropInstance", + "PropMeshUtils", - "PropSceneInstance2D", + "PropSceneInstance", - "PropUtils2D", + "PropUtils", + + "PropInstanceMerger", + "PropCache", + "PropInstanceJob", + "PropInstanceMerger", + "PropInstancePropJob", + "PropMaterialCache", + "PropMaterialCachePCM", + "PropMesher", + "PropMesherJobStep", + "PropTextureJob", + "PropLight", ] def get_doc_path(): diff --git a/doc_classes/GroundClutter.xml b/doc_classes/GroundClutter.xml index 6729c31..721e0bb 100644 --- a/doc_classes/GroundClutter.xml +++ b/doc_classes/GroundClutter.xml @@ -1,5 +1,5 @@ - + @@ -7,79 +7,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - + + diff --git a/doc_classes/GroundClutterFoliage.xml b/doc_classes/GroundClutterFoliage.xml index 7ea8b98..7ce59e4 100644 --- a/doc_classes/GroundClutterFoliage.xml +++ b/doc_classes/GroundClutterFoliage.xml @@ -1,5 +1,5 @@ - + @@ -8,32 +8,25 @@ - - - - + + - - - - + + - - + - - - - + + diff --git a/doc_classes/PropCache.xml b/doc_classes/PropCache.xml new file mode 100644 index 0000000..3b9570c --- /dev/null +++ b/doc_classes/PropCache.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropData.xml b/doc_classes/PropData.xml new file mode 100644 index 0000000..0fc6b8c --- /dev/null +++ b/doc_classes/PropData.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropDataEntry.xml b/doc_classes/PropDataEntry.xml new file mode 100644 index 0000000..a0dcade --- /dev/null +++ b/doc_classes/PropDataEntry.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropDataLight.xml b/doc_classes/PropDataLight.xml new file mode 100644 index 0000000..7d3770d --- /dev/null +++ b/doc_classes/PropDataLight.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropDataPortal.xml b/doc_classes/PropDataPortal.xml new file mode 100644 index 0000000..6c62881 --- /dev/null +++ b/doc_classes/PropDataPortal.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropDataProp.xml b/doc_classes/PropDataProp.xml new file mode 100644 index 0000000..09dbbd6 --- /dev/null +++ b/doc_classes/PropDataProp.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropDataScene.xml b/doc_classes/PropDataScene.xml new file mode 100644 index 0000000..1519e09 --- /dev/null +++ b/doc_classes/PropDataScene.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropDataTiledWall.xml b/doc_classes/PropDataTiledWall.xml new file mode 100644 index 0000000..5165c12 --- /dev/null +++ b/doc_classes/PropDataTiledWall.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropESSEntity.xml b/doc_classes/PropESSEntity.xml index 135cbc0..98366da 100644 --- a/doc_classes/PropESSEntity.xml +++ b/doc_classes/PropESSEntity.xml @@ -1,5 +1,5 @@ - + diff --git a/doc_classes/PropInstance.xml b/doc_classes/PropInstance.xml index e63a044..159c139 100644 --- a/doc_classes/PropInstance.xml +++ b/doc_classes/PropInstance.xml @@ -1,5 +1,5 @@ - + @@ -7,11 +7,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + diff --git a/doc_classes/PropInstanceJob.xml b/doc_classes/PropInstanceJob.xml new file mode 100644 index 0000000..ab1cb04 --- /dev/null +++ b/doc_classes/PropInstanceJob.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropInstanceMerger.xml b/doc_classes/PropInstanceMerger.xml new file mode 100644 index 0000000..cee2ed3 --- /dev/null +++ b/doc_classes/PropInstanceMerger.xml @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropInstancePropJob.xml b/doc_classes/PropInstancePropJob.xml new file mode 100644 index 0000000..d905cc3 --- /dev/null +++ b/doc_classes/PropInstancePropJob.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropLight.xml b/doc_classes/PropLight.xml new file mode 100644 index 0000000..6c95f5e --- /dev/null +++ b/doc_classes/PropLight.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropMaterialCache.xml b/doc_classes/PropMaterialCache.xml new file mode 100644 index 0000000..cf5cd39 --- /dev/null +++ b/doc_classes/PropMaterialCache.xml @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropMaterialCachePCM.xml b/doc_classes/PropMaterialCachePCM.xml new file mode 100644 index 0000000..8382f30 --- /dev/null +++ b/doc_classes/PropMaterialCachePCM.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropMeshUtils.xml b/doc_classes/PropMeshUtils.xml deleted file mode 100644 index f30ab80..0000000 --- a/doc_classes/PropMeshUtils.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/doc_classes/PropMesher.xml b/doc_classes/PropMesher.xml new file mode 100644 index 0000000..1532dd9 --- /dev/null +++ b/doc_classes/PropMesher.xml @@ -0,0 +1,326 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropMesherJobStep.xml b/doc_classes/PropMesherJobStep.xml new file mode 100644 index 0000000..5667548 --- /dev/null +++ b/doc_classes/PropMesherJobStep.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropSceneInstance.xml b/doc_classes/PropSceneInstance.xml new file mode 100644 index 0000000..28949b6 --- /dev/null +++ b/doc_classes/PropSceneInstance.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropMeshDataInstance.xml b/doc_classes/PropTextureJob.xml similarity index 51% rename from doc_classes/PropMeshDataInstance.xml rename to doc_classes/PropTextureJob.xml index 4516244..6a1f40a 100644 --- a/doc_classes/PropMeshDataInstance.xml +++ b/doc_classes/PropTextureJob.xml @@ -1,5 +1,5 @@ - + @@ -8,6 +8,10 @@ + + + + diff --git a/doc_classes/PropUtils.xml b/doc_classes/PropUtils.xml new file mode 100644 index 0000000..65b13a8 --- /dev/null +++ b/doc_classes/PropUtils.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/PropVoxelmanLight.xml b/doc_classes/PropVoxelmanLight.xml deleted file mode 100644 index 315dd70..0000000 --- a/doc_classes/PropVoxelmanLight.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/doc_classes/TiledWall.xml b/doc_classes/TiledWall.xml new file mode 100644 index 0000000..b7cc150 --- /dev/null +++ b/doc_classes/TiledWall.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc_classes/TiledWallData.xml b/doc_classes/TiledWallData.xml new file mode 100644 index 0000000..23fdc37 --- /dev/null +++ b/doc_classes/TiledWallData.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/editor/prop_editor_plugin_2d.cpp b/editor/prop_editor_plugin.cpp similarity index 73% rename from editor/prop_editor_plugin_2d.cpp rename to editor/prop_editor_plugin.cpp index b1d90b1..21519d9 100644 --- a/editor/prop_editor_plugin_2d.cpp +++ b/editor/prop_editor_plugin.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2020 Péter Magyar +Copyright (c) 2020-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_editor_plugin_2d.h" +#include "prop_editor_plugin.h" -#include "../props/prop_data_2d.h" -#include "../singleton/prop_utils_2d.h" +#include "../props/prop_data.h" +#include "../singleton/prop_utils.h" #include "core/os/keyboard.h" #include "core/version.h" @@ -41,7 +41,7 @@ SOFTWARE. #define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method)) #endif -void PropEditorPlugin2D::convert_active_scene_to_prop_data() { +void PropEditorPlugin::convert_active_scene_to_prop_data() { SceneTree *st = SceneTree::get_singleton(); if (st) { @@ -55,17 +55,17 @@ void PropEditorPlugin2D::convert_active_scene_to_prop_data() { } } } -void PropEditorPlugin2D::convert_selected_scene_to_prop_data() { +void PropEditorPlugin::convert_selected_scene_to_prop_data() { } -void PropEditorPlugin2D::convert_scene(Node *root, const String &path) { - Ref data = PropUtils2D::get_singleton()->convert_tree(root); +void PropEditorPlugin::convert_scene(Node *root, const String &path) { + Ref data = PropUtils::get_singleton()->convert_tree(root); ERR_FAIL_COND(!data.is_valid()); ResourceLoader l; if (l.exists(path)) { - Ref res = l.load(path, "PropData"); + Ref res = l.load(path, "PropData"); ERR_FAIL_COND(!res.is_valid()); @@ -81,7 +81,7 @@ void PropEditorPlugin2D::convert_scene(Node *root, const String &path) { } } -void PropEditorPlugin2D::find_room_points(Variant param) { +void PropEditorPlugin::find_room_points(Variant param) { #if VERSION_MINOR >= 4 SceneTree *st = SceneTree::get_singleton(); @@ -89,24 +89,24 @@ void PropEditorPlugin2D::find_room_points(Variant param) { Node *scene = st->get_edited_scene_root(); if (scene) { - PropUtils2D::get_singleton()->generate_room_points_node(scene); + PropUtils::get_singleton()->generate_room_points_node(scene); } } #endif } -void PropEditorPlugin2D::_quick_convert_button_pressed() { +void PropEditorPlugin::_quick_convert_button_pressed() { convert_active_scene_to_prop_data(); } -void PropEditorPlugin2D::_convert_active_scene_to_prop_data(Variant param) { +void PropEditorPlugin::_convert_active_scene_to_prop_data(Variant param) { convert_active_scene_to_prop_data(); } -void PropEditorPlugin2D::_convert_selected_scene_to_prop_data(Variant param) { +void PropEditorPlugin::_convert_selected_scene_to_prop_data(Variant param) { convert_selected_scene_to_prop_data(); } -PropEditorPlugin2D::PropEditorPlugin2D(EditorNode *p_node) { +PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) { editor = p_node; #if VERSION_MAJOR < 4 @@ -126,21 +126,21 @@ PropEditorPlugin2D::PropEditorPlugin2D(EditorNode *p_node) { container->add_child(b); b->set_flat(true); - b->CONNECT("pressed", this, PropEditorPlugin2D, _quick_convert_button_pressed); + b->CONNECT("pressed", this, PropEditorPlugin, _quick_convert_button_pressed); b->set_text("To Prop"); b->set_shortcut(ED_SHORTCUT("spatial_editor/quick_prop_convert", "Quick convert scene to PropData.", KEY_MASK_ALT + KEY_U)); add_control_to_container(EditorPlugin::CONTAINER_SPATIAL_EDITOR_MENU, container); } -PropEditorPlugin2D::~PropEditorPlugin2D() { +PropEditorPlugin::~PropEditorPlugin() { } -void PropEditorPlugin2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("convert_active_scene_to_prop_data"), &PropEditorPlugin2D::_convert_active_scene_to_prop_data); - ClassDB::bind_method(D_METHOD("convert_selected_scene_to_prop_data"), &PropEditorPlugin2D::_convert_active_scene_to_prop_data); +void PropEditorPlugin::_bind_methods() { + ClassDB::bind_method(D_METHOD("convert_active_scene_to_prop_data"), &PropEditorPlugin::_convert_active_scene_to_prop_data); + ClassDB::bind_method(D_METHOD("convert_selected_scene_to_prop_data"), &PropEditorPlugin::_convert_active_scene_to_prop_data); - ClassDB::bind_method(D_METHOD("find_room_points"), &PropEditorPlugin2D::find_room_points); + ClassDB::bind_method(D_METHOD("find_room_points"), &PropEditorPlugin::find_room_points); - ClassDB::bind_method(D_METHOD("_quick_convert_button_pressed"), &PropEditorPlugin2D::_quick_convert_button_pressed); + ClassDB::bind_method(D_METHOD("_quick_convert_button_pressed"), &PropEditorPlugin::_quick_convert_button_pressed); } diff --git a/editor/prop_editor_plugin_2d.h b/editor/prop_editor_plugin.h similarity index 84% rename from editor/prop_editor_plugin_2d.h rename to editor/prop_editor_plugin.h index 6c46ef6..f764755 100644 --- a/editor/prop_editor_plugin_2d.h +++ b/editor/prop_editor_plugin.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2020 Péter Magyar +Copyright (c) 2020-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,24 +20,24 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_EDITOR_PLUGIN_2D_H -#define PROP_EDITOR_PLUGIN_2D_H +#ifndef PROP_EDITOR_PLUGIN_H +#define PROP_EDITOR_PLUGIN_H #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "core/version.h" -class PropEditorPlugin2D : public EditorPlugin { +class PropEditorPlugin : public EditorPlugin { - GDCLASS(PropEditorPlugin2D, EditorPlugin); + GDCLASS(PropEditorPlugin, EditorPlugin); EditorNode *editor; protected: static void _bind_methods(); public: - virtual String get_name() const { return "PropEditorPlugin2D"; } + virtual String get_name() const { return "PropEditorPlugin"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object) {} virtual bool handles(Object *p_object) const { return false; } @@ -53,8 +53,8 @@ public: void _convert_selected_scene_to_prop_data(Variant param); void _quick_convert_button_pressed(); - PropEditorPlugin2D(EditorNode *p_node); - ~PropEditorPlugin2D(); + PropEditorPlugin(EditorNode *p_node); + ~PropEditorPlugin(); }; #endif diff --git a/jobs/prop_mesher_job_step_2d.cpp b/jobs/prop_mesher_job_step.cpp similarity index 64% rename from jobs/prop_mesher_job_step_2d.cpp rename to jobs/prop_mesher_job_step.cpp index 0f8635f..20d69fd 100644 --- a/jobs/prop_mesher_job_step_2d.cpp +++ b/jobs/prop_mesher_job_step.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,56 +20,56 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_mesher_job_step_2d.h" +#include "prop_mesher_job_step.h" -const String PropMesherJobStep2D::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh"; +const String PropMesherJobStep::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh"; -PropMesherJobStep2D::PropMesherJobStepType2D PropMesherJobStep2D::get_job_type() const { +PropMesherJobStep::PropMesherJobStepType PropMesherJobStep::get_job_type() const { return _job_type; } -void PropMesherJobStep2D::set_job_type(const PropMesherJobStep2D::PropMesherJobStepType2D value) { +void PropMesherJobStep::set_job_type(const PropMesherJobStep::PropMesherJobStepType value) { _job_type = value; } -int PropMesherJobStep2D::get_lod_index() const { +int PropMesherJobStep::get_lod_index() const { return _lod_index; } -void PropMesherJobStep2D::set_lod_index(const int value) { +void PropMesherJobStep::set_lod_index(const int value) { _lod_index = value; } #ifdef MESH_UTILS_PRESENT -Ref PropMesherJobStep2D::get_fqms() { +Ref PropMesherJobStep::get_fqms() { return _fqms; } -void PropMesherJobStep2D::set_fqms(const Ref &val) { +void PropMesherJobStep::set_fqms(const Ref &val) { _fqms = val; } -float PropMesherJobStep2D::get_simplification_step_ratio() const { +float PropMesherJobStep::get_simplification_step_ratio() const { return _simplification_step_ratio; } -void PropMesherJobStep2D::set_simplification_step_ratio(const float value) { +void PropMesherJobStep::set_simplification_step_ratio(const float value) { _simplification_step_ratio = value; } -int PropMesherJobStep2D::get_simplification_steps() const { +int PropMesherJobStep::get_simplification_steps() const { return _simplification_steps; } -void PropMesherJobStep2D::set_simplification_steps(const int value) { +void PropMesherJobStep::set_simplification_steps(const int value) { _simplification_steps = value; } -float PropMesherJobStep2D::get_simplification_agressiveness() const { +float PropMesherJobStep::get_simplification_agressiveness() const { return _simplification_agressiveness; } -void PropMesherJobStep2D::set_simplification_agressiveness(const float value) { +void PropMesherJobStep::set_simplification_agressiveness(const float value) { _simplification_agressiveness = value; } #endif -PropMesherJobStep2D::PropMesherJobStep2D() { +PropMesherJobStep::PropMesherJobStep() { _job_type = TYPE_NORMAL; _lod_index = 0; @@ -80,36 +80,36 @@ PropMesherJobStep2D::PropMesherJobStep2D() { #endif } -PropMesherJobStep2D::~PropMesherJobStep2D() { +PropMesherJobStep::~PropMesherJobStep() { #ifdef MESH_UTILS_PRESENT _fqms.unref(); #endif } -void PropMesherJobStep2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_job_type"), &PropMesherJobStep2D::get_job_type); - ClassDB::bind_method(D_METHOD("set_job_type", "value"), &PropMesherJobStep2D::set_job_type); - ADD_PROPERTY(PropertyInfo(Variant::INT, "job_type", PROPERTY_HINT_ENUM, PropMesherJobStep2D::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE), "set_job_type", "get_job_type"); +void PropMesherJobStep::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_job_type"), &PropMesherJobStep::get_job_type); + ClassDB::bind_method(D_METHOD("set_job_type", "value"), &PropMesherJobStep::set_job_type); + ADD_PROPERTY(PropertyInfo(Variant::INT, "job_type", PROPERTY_HINT_ENUM, PropMesherJobStep::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE), "set_job_type", "get_job_type"); - ClassDB::bind_method(D_METHOD("get_lod_index"), &PropMesherJobStep2D::get_lod_index); - ClassDB::bind_method(D_METHOD("set_lod_index", "value"), &PropMesherJobStep2D::set_lod_index); + ClassDB::bind_method(D_METHOD("get_lod_index"), &PropMesherJobStep::get_lod_index); + ClassDB::bind_method(D_METHOD("set_lod_index", "value"), &PropMesherJobStep::set_lod_index); ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_index"), "set_lod_index", "get_lod_index"); #ifdef MESH_UTILS_PRESENT - ClassDB::bind_method(D_METHOD("get_fqms"), &PropMesherJobStep2D::get_fqms); - ClassDB::bind_method(D_METHOD("set_fqms", "value"), &PropMesherJobStep2D::set_fqms); + ClassDB::bind_method(D_METHOD("get_fqms"), &PropMesherJobStep::get_fqms); + ClassDB::bind_method(D_METHOD("set_fqms", "value"), &PropMesherJobStep::set_fqms); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fqms", PROPERTY_HINT_RESOURCE_TYPE, "FastQuadraticMeshSimplifier"), "set_fqms", "get_fqms"); - ClassDB::bind_method(D_METHOD("get_simplification_step_ratio"), &PropMesherJobStep2D::get_simplification_step_ratio); - ClassDB::bind_method(D_METHOD("set_simplification_step_ratio", "value"), &PropMesherJobStep2D::set_simplification_step_ratio); + ClassDB::bind_method(D_METHOD("get_simplification_step_ratio"), &PropMesherJobStep::get_simplification_step_ratio); + ClassDB::bind_method(D_METHOD("set_simplification_step_ratio", "value"), &PropMesherJobStep::set_simplification_step_ratio); ADD_PROPERTY(PropertyInfo(Variant::REAL, "simplification_step_ratio"), "set_simplification_step_ratio", "get_simplification_step_ratio"); - ClassDB::bind_method(D_METHOD("get_simplification_steps"), &PropMesherJobStep2D::get_simplification_steps); - ClassDB::bind_method(D_METHOD("set_simplification_steps", "value"), &PropMesherJobStep2D::set_simplification_steps); + ClassDB::bind_method(D_METHOD("get_simplification_steps"), &PropMesherJobStep::get_simplification_steps); + ClassDB::bind_method(D_METHOD("set_simplification_steps", "value"), &PropMesherJobStep::set_simplification_steps); ADD_PROPERTY(PropertyInfo(Variant::INT, "simplification_steps"), "set_simplification_steps", "get_simplification_steps"); - ClassDB::bind_method(D_METHOD("get_simplification_agressiveness"), &PropMesherJobStep2D::get_simplification_agressiveness); - ClassDB::bind_method(D_METHOD("set_simplification_agressiveness", "value"), &PropMesherJobStep2D::set_simplification_agressiveness); + ClassDB::bind_method(D_METHOD("get_simplification_agressiveness"), &PropMesherJobStep::get_simplification_agressiveness); + ClassDB::bind_method(D_METHOD("set_simplification_agressiveness", "value"), &PropMesherJobStep::set_simplification_agressiveness); ADD_PROPERTY(PropertyInfo(Variant::REAL, "simplification_agressiveness"), "set_simplification_agressiveness", "get_simplification_agressiveness"); #endif diff --git a/jobs/prop_mesher_job_step_2d.h b/jobs/prop_mesher_job_step.h similarity index 83% rename from jobs/prop_mesher_job_step_2d.h rename to jobs/prop_mesher_job_step.h index 346d84e..4ed5791 100644 --- a/jobs/prop_mesher_job_step_2d.h +++ b/jobs/prop_mesher_job_step.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_MESHER_JOB_STEP_2D_H -#define PROP_MESHER_JOB_STEP_2D_H +#ifndef PROP_MESHER_JOB_STEP_H +#define PROP_MESHER_JOB_STEP_H #include "core/version.h" @@ -35,15 +35,15 @@ SOFTWARE. #include "../../mesh_utils/fast_quadratic_mesh_simplifier.h" #endif -class PropMesherJobStep2D : public Reference { - GDCLASS(PropMesherJobStep2D, Reference); +class PropMesherJobStep : public Reference { + GDCLASS(PropMesherJobStep, Reference); public: //todo add: //type generate lighting, //type skip (this would leave the mesh empty) //type previous mesh (this would set the previous mesh's rid to the current lod level) - enum PropMesherJobStepType2D { + enum PropMesherJobStepType { TYPE_NORMAL = 0, TYPE_NORMAL_LOD, TYPE_DROP_UV2, @@ -55,8 +55,8 @@ public: static const String BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE; - PropMesherJobStepType2D get_job_type() const; - void set_job_type(const PropMesherJobStepType2D value); + PropMesherJobStepType get_job_type() const; + void set_job_type(const PropMesherJobStepType value); int get_lod_index() const; void set_lod_index(const int value); @@ -75,13 +75,13 @@ public: void set_simplification_agressiveness(const float value); #endif - PropMesherJobStep2D(); - ~PropMesherJobStep2D(); + PropMesherJobStep(); + ~PropMesherJobStep(); protected: static void _bind_methods(); - PropMesherJobStepType2D _job_type; + PropMesherJobStepType _job_type; int _lod_index; #ifdef MESH_UTILS_PRESENT @@ -92,6 +92,6 @@ protected: #endif }; -VARIANT_ENUM_CAST(PropMesherJobStep2D::PropMesherJobStepType2D); +VARIANT_ENUM_CAST(PropMesherJobStep::PropMesherJobStepType); #endif diff --git a/jobs/prop_texture_job_2d.cpp b/jobs/prop_texture_job.cpp similarity index 63% rename from jobs/prop_texture_job_2d.cpp rename to jobs/prop_texture_job.cpp index d1c0f19..5444bc9 100644 --- a/jobs/prop_texture_job_2d.cpp +++ b/jobs/prop_texture_job.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,23 +20,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_texture_job_2d.h" +#include "prop_texture_job.h" #if TEXTURE_PACKER_PRESENT #include "../../texture_packer/texture_packer.h" #endif #if TEXTURE_PACKER_PRESENT -Ref PropTextureJob2D::get_merger() { +Ref PropTextureJob::get_merger() { return _merger; } -void PropTextureJob2D::set_merger(const Ref &merger) { +void PropTextureJob::set_merger(const Ref &merger) { _merger = merger; } #endif -void PropTextureJob2D::_execute() { +void PropTextureJob::_execute() { #if TEXTURE_PACKER_PRESENT if (!_merger.is_valid()) { set_complete(true); @@ -49,7 +49,7 @@ void PropTextureJob2D::_execute() { set_complete(true); } -PropTextureJob2D::PropTextureJob2D() { +PropTextureJob::PropTextureJob() { #if !THREAD_POOL_PRESENT _complete = true; _cancelled = false; @@ -62,110 +62,110 @@ PropTextureJob2D::PropTextureJob2D() { #endif } -PropTextureJob2D::~PropTextureJob2D() { +PropTextureJob::~PropTextureJob() { } -void PropTextureJob2D::_bind_methods() { +void PropTextureJob::_bind_methods() { #if TEXTURE_PACKER_PRESENT - ClassDB::bind_method(D_METHOD("get_merger"), &PropTextureJob2D::get_merger); - ClassDB::bind_method(D_METHOD("set_merger", "value"), &PropTextureJob2D::set_merger); + ClassDB::bind_method(D_METHOD("get_merger"), &PropTextureJob::get_merger); + ClassDB::bind_method(D_METHOD("set_merger", "value"), &PropTextureJob::set_merger); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "merger", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker"), "set_merger", "get_merger"); #endif - ClassDB::bind_method(D_METHOD("_execute"), &PropTextureJob2D::_execute); + ClassDB::bind_method(D_METHOD("_execute"), &PropTextureJob::_execute); #if !THREAD_POOL_PRESENT - ClassDB::bind_method(D_METHOD("get_complete"), &PropTextureJob2D::get_complete); - ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropTextureJob2D::set_complete); + ClassDB::bind_method(D_METHOD("get_complete"), &PropTextureJob::get_complete); + ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropTextureJob::set_complete); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "complete"), "set_complete", "get_complete"); - ClassDB::bind_method(D_METHOD("get_start_time"), &PropTextureJob2D::get_start_time); - ClassDB::bind_method(D_METHOD("set_start_time", "value"), &PropTextureJob2D::set_start_time); + ClassDB::bind_method(D_METHOD("get_start_time"), &PropTextureJob::get_start_time); + ClassDB::bind_method(D_METHOD("set_start_time", "value"), &PropTextureJob::set_start_time); ADD_PROPERTY(PropertyInfo(Variant::INT, "start_time"), "set_start_time", "get_start_time"); - ClassDB::bind_method(D_METHOD("get_current_run_stage"), &PropTextureJob2D::get_current_run_stage); - ClassDB::bind_method(D_METHOD("set_current_run_stage", "value"), &PropTextureJob2D::set_current_run_stage); + ClassDB::bind_method(D_METHOD("get_current_run_stage"), &PropTextureJob::get_current_run_stage); + ClassDB::bind_method(D_METHOD("set_current_run_stage", "value"), &PropTextureJob::set_current_run_stage); ADD_PROPERTY(PropertyInfo(Variant::INT, "current_run_stage"), "set_current_run_stage", "get_current_run_stage"); - ClassDB::bind_method(D_METHOD("get_stage"), &PropTextureJob2D::get_stage); - ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropTextureJob2D::set_stage); + ClassDB::bind_method(D_METHOD("get_stage"), &PropTextureJob::get_stage); + ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropTextureJob::set_stage); ADD_PROPERTY(PropertyInfo(Variant::INT, "stage"), "set_stage", "get_stage"); - ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropTextureJob2D::get_current_execution_time); + ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropTextureJob::get_current_execution_time); - ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropTextureJob2D::should_do, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("should_return"), &PropTextureJob2D::should_return); + ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropTextureJob::should_do, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("should_return"), &PropTextureJob::should_return); BIND_VMETHOD(MethodInfo("_execute")); - ClassDB::bind_method(D_METHOD("execute"), &PropTextureJob2D::execute); + ClassDB::bind_method(D_METHOD("execute"), &PropTextureJob::execute); ADD_SIGNAL(MethodInfo("completed")); #endif } #if !THREAD_POOL_PRESENT -bool PropTextureJob2D::get_complete() const { +bool PropTextureJob::get_complete() const { return _complete; } -void PropTextureJob2D::set_complete(const bool value) { +void PropTextureJob::set_complete(const bool value) { _complete = value; } -bool PropTextureJob2D::get_cancelled() const { +bool PropTextureJob::get_cancelled() const { return _cancelled; } -void PropTextureJob2D::set_cancelled(const bool value) { +void PropTextureJob::set_cancelled(const bool value) { _cancelled = value; } -float PropTextureJob2D::get_max_allocated_time() const { +float PropTextureJob::get_max_allocated_time() const { return _max_allocated_time; } -void PropTextureJob2D::set_max_allocated_time(const float value) { +void PropTextureJob::set_max_allocated_time(const float value) { _max_allocated_time = value; } -int PropTextureJob2D::get_start_time() const { +int PropTextureJob::get_start_time() const { return _start_time; } -void PropTextureJob2D::set_start_time(const int value) { +void PropTextureJob::set_start_time(const int value) { _start_time = value; } -int PropTextureJob2D::get_current_run_stage() const { +int PropTextureJob::get_current_run_stage() const { return _current_run_stage; } -void PropTextureJob2D::set_current_run_stage(const int value) { +void PropTextureJob::set_current_run_stage(const int value) { _current_run_stage = value; } -int PropTextureJob2D::get_stage() const { +int PropTextureJob::get_stage() const { return _stage; } -void PropTextureJob2D::set_stage(const int value) { +void PropTextureJob::set_stage(const int value) { _stage = value; } -void PropTextureJob2D::reset_stages() { +void PropTextureJob::reset_stages() { _current_run_stage = 0; _stage = 0; } -float PropTextureJob2D::get_current_execution_time() { +float PropTextureJob::get_current_execution_time() { return 0; } -bool PropTextureJob2D::should_do(const bool just_check) { +bool PropTextureJob::should_do(const bool just_check) { return true; } -bool PropTextureJob2D::should_return() { +bool PropTextureJob::should_return() { if (_cancelled) return true; return false; } -void PropTextureJob2D::execute() { +void PropTextureJob::execute() { ERR_FAIL_COND(!has_method("_execute")); call("_execute"); diff --git a/jobs/prop_texture_job_2d.h b/jobs/prop_texture_job.h similarity index 88% rename from jobs/prop_texture_job_2d.h rename to jobs/prop_texture_job.h index b300aa3..526a28d 100644 --- a/jobs/prop_texture_job_2d.h +++ b/jobs/prop_texture_job.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_TEXTURE_JOB_2D_H -#define PROP_TEXTURE_JOB_2D_H +#ifndef PROP_TEXTURE_JOB +#define PROP_TEXTURE_JOB #include "scene/resources/texture.h" @@ -43,11 +43,11 @@ class TexturePacker; #endif #if THREAD_POOL_PRESENT -class PropTextureJob2D : public ThreadPoolJob { - GDCLASS(PropTextureJob2D, ThreadPoolJob); +class PropTextureJob : public ThreadPoolJob { + GDCLASS(PropTextureJob, ThreadPoolJob); #else -class PropTextureJob2D : public Reference { - GDCLASS(PropTextureJob2D, Reference); +class PropTextureJob : public Reference { + GDCLASS(PropTextureJob, Reference); #endif public: @@ -58,8 +58,8 @@ public: void _execute(); - PropTextureJob2D(); - ~PropTextureJob2D(); + PropTextureJob(); + ~PropTextureJob(); protected: static void _bind_methods(); diff --git a/lights/prop_light_2d.cpp b/lights/prop_light.cpp similarity index 62% rename from lights/prop_light_2d.cpp rename to lights/prop_light.cpp index 76feb35..8957798 100644 --- a/lights/prop_light_2d.cpp +++ b/lights/prop_light.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,46 +20,46 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_light_2d.h" +#include "prop_light.h" -Vector3 PropLight2D::get_position() { +Vector3 PropLight::get_position() { return _position; } -void PropLight2D::set_position(const Vector3 &pos) { +void PropLight::set_position(const Vector3 &pos) { _position = pos; } -Color PropLight2D::get_color() const { +Color PropLight::get_color() const { return _color; } -void PropLight2D::set_color(const Color &color) { +void PropLight::set_color(const Color &color) { _color = color; } -float PropLight2D::get_size() const { +float PropLight::get_size() const { return _size; } -void PropLight2D::set_size(const float size) { +void PropLight::set_size(const float size) { _size = size; } -PropLight2D::PropLight2D() { +PropLight::PropLight() { _size = 0; } -PropLight2D::~PropLight2D() { +PropLight::~PropLight() { } -void PropLight2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_position"), &PropLight2D::get_position); - ClassDB::bind_method(D_METHOD("set_position"), &PropLight2D::set_position); +void PropLight::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_position"), &PropLight::get_position); + ClassDB::bind_method(D_METHOD("set_position"), &PropLight::set_position); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "world_position"), "set_position", "get_position"); - ClassDB::bind_method(D_METHOD("get_color"), &PropLight2D::get_color); - ClassDB::bind_method(D_METHOD("set_color"), &PropLight2D::set_color); + ClassDB::bind_method(D_METHOD("get_color"), &PropLight::get_color); + ClassDB::bind_method(D_METHOD("set_color"), &PropLight::set_color); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); - ClassDB::bind_method(D_METHOD("get_size"), &PropLight2D::get_size); - ClassDB::bind_method(D_METHOD("set_size"), &PropLight2D::set_size); + ClassDB::bind_method(D_METHOD("get_size"), &PropLight::get_size); + ClassDB::bind_method(D_METHOD("set_size"), &PropLight::set_size); ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size"); } diff --git a/lights/prop_light_2d.h b/lights/prop_light.h similarity index 89% rename from lights/prop_light_2d.h rename to lights/prop_light.h index 19c4ea0..0778d4f 100644 --- a/lights/prop_light_2d.h +++ b/lights/prop_light.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_LIGHT_2D_H -#define PROP_LIGHT_2D_H +#ifndef PROP_LIGHT_H +#define PROP_LIGHT_H #include "core/version.h" @@ -35,8 +35,8 @@ SOFTWARE. #include "core/color.h" #endif -class PropLight2D : public Reference { - GDCLASS(PropLight2D, Reference); +class PropLight : public Reference { + GDCLASS(PropLight, Reference); public: Vector3 get_position(); @@ -48,8 +48,8 @@ public: float get_size() const; void set_size(const float strength); - PropLight2D(); - ~PropLight2D(); + PropLight(); + ~PropLight(); private: static void _bind_methods(); diff --git a/material_cache/prop_material_cache_2d.cpp b/material_cache/prop_material_cache.cpp similarity index 65% rename from material_cache/prop_material_cache_2d.cpp rename to material_cache/prop_material_cache.cpp index aed9510..3837003 100644 --- a/material_cache/prop_material_cache_2d.cpp +++ b/material_cache/prop_material_cache.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,18 +20,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_material_cache_2d.h" +#include "prop_material_cache.h" -#include "../props/prop_data_2d.h" -#include "../props/prop_data_prop_2d.h" -#include "../props/prop_data_tiled_wall_2d.h" -#include "../singleton/prop_cache_2d.h" -#include "../tiled_wall/tiled_wall_data_2d.h" +#include "../props/prop_data.h" +#include "../props/prop_data_prop.h" +#include "../props/prop_data_tiled_wall.h" +#include "../singleton/prop_cache.h" +#include "../tiled_wall/tiled_wall_data.h" #if MESH_DATA_RESOURCE_PRESENT -#define PROPS_PRESENT 1 -#include "../../mesh_data_resource/props/prop_data_mesh_data.h" -#undef PROPS_PRESENT +//define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling, +//but not when included from here. +#define PROPS_2D_PRESENT 1 +#include "../../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h" #endif #if VERSION_MAJOR > 3 @@ -54,44 +55,44 @@ SOFTWARE. #endif -bool PropMaterialCache2D::get_initialized() { +bool PropMaterialCache::get_initialized() { return _initialized; } -void PropMaterialCache2D::set_initialized(const bool value) { +void PropMaterialCache::set_initialized(const bool value) { _initialized = value; } -bool PropMaterialCache2D::mutex_locked() { +bool PropMaterialCache::mutex_locked() { return _locked; } -void PropMaterialCache2D::mutex_lock() { +void PropMaterialCache::mutex_lock() { _mutex.lock(); } -void PropMaterialCache2D::mutex_unlock() { +void PropMaterialCache::mutex_unlock() { _mutex.unlock(); } -int PropMaterialCache2D::get_ref_count() { +int PropMaterialCache::get_ref_count() { return _ref_count; } -void PropMaterialCache2D::set_ref_count(const int value) { +void PropMaterialCache::set_ref_count(const int value) { _ref_count = value; } -void PropMaterialCache2D::inc_ref_count() { +void PropMaterialCache::inc_ref_count() { _ref_count += 1; } -void PropMaterialCache2D::dec_ref_count() { +void PropMaterialCache::dec_ref_count() { _ref_count -= 1; } //Materials -Ref PropMaterialCache2D::material_get(const int index) { +Ref PropMaterialCache::material_get(const int index) { ERR_FAIL_INDEX_V(index, _materials.size(), Ref(NULL)); return _materials[index]; } -Ref PropMaterialCache2D::material_lod_get(const int index) { +Ref PropMaterialCache::material_lod_get(const int index) { ERR_FAIL_COND_V(_materials.size() == 0, Ref(NULL)); if (index < 0) { @@ -105,35 +106,35 @@ Ref PropMaterialCache2D::material_lod_get(const int index) { return _materials[index]; } -void PropMaterialCache2D::material_add(const Ref &value) { +void PropMaterialCache::material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); _materials.push_back(value); } -void PropMaterialCache2D::material_set(const int index, const Ref &value) { +void PropMaterialCache::material_set(const int index, const Ref &value) { ERR_FAIL_INDEX(index, _materials.size()); _materials.set(index, value); } -void PropMaterialCache2D::material_remove(const int index) { +void PropMaterialCache::material_remove(const int index) { _materials.remove(index); } -int PropMaterialCache2D::material_get_num() const { +int PropMaterialCache::material_get_num() const { return _materials.size(); } -void PropMaterialCache2D::materials_clear() { +void PropMaterialCache::materials_clear() { _materials.clear(); } -Vector PropMaterialCache2D::materials_get() { +Vector PropMaterialCache::materials_get() { VARIANT_ARRAY_GET(_materials); } -void PropMaterialCache2D::materials_set(const Vector &materials) { +void PropMaterialCache::materials_set(const Vector &materials) { _materials.clear(); for (int i = 0; i < materials.size(); i++) { @@ -143,10 +144,10 @@ void PropMaterialCache2D::materials_set(const Vector &materials) { } } -void PropMaterialCache2D::texture_add(const Ref &texture) { +void PropMaterialCache::texture_add(const Ref &texture) { _textures.push_back(texture); } -void PropMaterialCache2D::texture_remove(const Ref &texture) { +void PropMaterialCache::texture_remove(const Ref &texture) { for (int i = 0; i < _textures.size(); ++i) { if (_textures[i] == texture) { _textures.remove(i); @@ -154,42 +155,42 @@ void PropMaterialCache2D::texture_remove(const Ref &texture) { } } } -void PropMaterialCache2D::texture_remove_index(const int index) { +void PropMaterialCache::texture_remove_index(const int index) { ERR_FAIL_INDEX(index, _textures.size()); _textures.remove(index); } -void PropMaterialCache2D::textures_clear() { +void PropMaterialCache::textures_clear() { _textures.clear(); } -int PropMaterialCache2D::texture_count() { +int PropMaterialCache::texture_count() { return _textures.size(); } -Ref PropMaterialCache2D::texture_get(const int index) { +Ref PropMaterialCache::texture_get(const int index) { ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); return _textures[index]; } -Ref PropMaterialCache2D::texture_get_atlas(const int index) { +Ref PropMaterialCache::texture_get_atlas(const int index) { ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); return texture_get_atlas_tex(_textures[index]); } -Ref PropMaterialCache2D::texture_get_atlas_tex(const Ref &texture) { +Ref PropMaterialCache::texture_get_atlas_tex(const Ref &texture) { return Ref(); } -Rect2 PropMaterialCache2D::texture_get_uv_rect(const Ref &texture) { +Rect2 PropMaterialCache::texture_get_uv_rect(const Ref &texture) { return Rect2(0, 0, 1, 1); } -void PropMaterialCache2D::prop_add_textures(const Ref &prop) { +void PropMaterialCache::prop_add_textures(const Ref &prop) { if (!prop.is_valid()) { return; } for (int i = 0; i < prop->get_prop_count(); ++i) { #if MESH_DATA_RESOURCE_PRESENT - Ref pdm = prop->get_prop(i); + Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { Ref tex = pdm->get_texture(); @@ -203,34 +204,34 @@ void PropMaterialCache2D::prop_add_textures(const Ref &prop) { } #endif - Ref pdtw = prop->get_prop(i); + Ref pdtw = prop->get_prop(i); if (pdtw.is_valid()) { - Ref twd = pdtw->get_data(); + Ref twd = pdtw->get_data(); if (!twd.is_valid()) continue; - twd->setup_cache(Ref(this)); + twd->setup_cache(Ref(this)); continue; } - Ref pdp = prop->get_prop(i); + Ref pdp = prop->get_prop(i); if (pdp.is_valid()) { prop_add_textures(pdp->get_prop()); } } } -void PropMaterialCache2D::prop_remove_textures(const Ref &prop) { +void PropMaterialCache::prop_remove_textures(const Ref &prop) { if (!prop.is_valid()) { return; } for (int i = 0; i < prop->get_prop_count(); ++i) { #if MESH_DATA_RESOURCE_PRESENT - Ref pdm = prop->get_prop(i); + Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { Ref tex = pdm->get_texture(); @@ -242,10 +243,10 @@ void PropMaterialCache2D::prop_remove_textures(const Ref &prop) { } #endif - Ref pdtw = prop->get_prop(i); + Ref pdtw = prop->get_prop(i); if (pdtw.is_valid()) { - Ref twd = pdtw->get_data(); + Ref twd = pdtw->get_data(); if (!twd.is_valid()) continue; @@ -269,7 +270,7 @@ void PropMaterialCache2D::prop_remove_textures(const Ref &prop) { continue; } - Ref pdp = prop->get_prop(i); + Ref pdp = prop->get_prop(i); if (pdp.is_valid()) { prop_remove_textures(pdp); @@ -277,14 +278,14 @@ void PropMaterialCache2D::prop_remove_textures(const Ref &prop) { } } -void PropMaterialCache2D::refresh_rects() { +void PropMaterialCache::refresh_rects() { _initialized = true; } -void PropMaterialCache2D::initial_setup_default() { +void PropMaterialCache::initial_setup_default() { //Note: call only on the main thread! Shader->duplicate() can crash if done from an another thread! - PropCache2D *pc = PropCache2D::get_singleton(); + PropCache *pc = PropCache::get_singleton(); pc->ensure_materials_loaded(); @@ -300,64 +301,64 @@ void PropMaterialCache2D::initial_setup_default() { } } -void PropMaterialCache2D::setup_material_albedo(Ref texture) { +void PropMaterialCache::setup_material_albedo(Ref texture) { if (has_method("_setup_material_albedo")) call("_setup_material_albedo", texture); } -PropMaterialCache2D::PropMaterialCache2D() { +PropMaterialCache::PropMaterialCache() { _ref_count = 0; _initialized = false; _locked = false; } -PropMaterialCache2D::~PropMaterialCache2D() { +PropMaterialCache::~PropMaterialCache() { _materials.clear(); } -void PropMaterialCache2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_initialized"), &PropMaterialCache2D::get_initialized); - ClassDB::bind_method(D_METHOD("set_initialized", "value"), &PropMaterialCache2D::set_initialized); +void PropMaterialCache::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_initialized"), &PropMaterialCache::get_initialized); + ClassDB::bind_method(D_METHOD("set_initialized", "value"), &PropMaterialCache::set_initialized); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "initialized"), "set_initialized", "get_initialized"); - ClassDB::bind_method(D_METHOD("mutex_locked"), &PropMaterialCache2D::mutex_locked); - ClassDB::bind_method(D_METHOD("mutex_lock"), &PropMaterialCache2D::mutex_lock); - ClassDB::bind_method(D_METHOD("mutex_unlock"), &PropMaterialCache2D::mutex_unlock); + ClassDB::bind_method(D_METHOD("mutex_locked"), &PropMaterialCache::mutex_locked); + ClassDB::bind_method(D_METHOD("mutex_lock"), &PropMaterialCache::mutex_lock); + ClassDB::bind_method(D_METHOD("mutex_unlock"), &PropMaterialCache::mutex_unlock); - ClassDB::bind_method(D_METHOD("get_ref_count"), &PropMaterialCache2D::get_ref_count); - ClassDB::bind_method(D_METHOD("set_ref_count", "value"), &PropMaterialCache2D::set_ref_count); + ClassDB::bind_method(D_METHOD("get_ref_count"), &PropMaterialCache::get_ref_count); + ClassDB::bind_method(D_METHOD("set_ref_count", "value"), &PropMaterialCache::set_ref_count); ADD_PROPERTY(PropertyInfo(Variant::INT, "mat_ref_count"), "set_ref_count", "get_ref_count"); - ClassDB::bind_method(D_METHOD("inc_ref_count"), &PropMaterialCache2D::inc_ref_count); - ClassDB::bind_method(D_METHOD("dec_ref_count"), &PropMaterialCache2D::dec_ref_count); + ClassDB::bind_method(D_METHOD("inc_ref_count"), &PropMaterialCache::inc_ref_count); + ClassDB::bind_method(D_METHOD("dec_ref_count"), &PropMaterialCache::dec_ref_count); BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"))); - ClassDB::bind_method(D_METHOD("material_get", "index"), &PropMaterialCache2D::material_get); - ClassDB::bind_method(D_METHOD("material_lod_get", "index"), &PropMaterialCache2D::material_lod_get); - ClassDB::bind_method(D_METHOD("material_add", "value"), &PropMaterialCache2D::material_add); - ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &PropMaterialCache2D::material_set); - ClassDB::bind_method(D_METHOD("material_remove", "index"), &PropMaterialCache2D::material_remove); - ClassDB::bind_method(D_METHOD("material_get_num"), &PropMaterialCache2D::material_get_num); - ClassDB::bind_method(D_METHOD("materials_clear"), &PropMaterialCache2D::materials_clear); + ClassDB::bind_method(D_METHOD("material_get", "index"), &PropMaterialCache::material_get); + ClassDB::bind_method(D_METHOD("material_lod_get", "index"), &PropMaterialCache::material_lod_get); + ClassDB::bind_method(D_METHOD("material_add", "value"), &PropMaterialCache::material_add); + ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &PropMaterialCache::material_set); + ClassDB::bind_method(D_METHOD("material_remove", "index"), &PropMaterialCache::material_remove); + ClassDB::bind_method(D_METHOD("material_get_num"), &PropMaterialCache::material_get_num); + ClassDB::bind_method(D_METHOD("materials_clear"), &PropMaterialCache::materials_clear); - ClassDB::bind_method(D_METHOD("materials_get"), &PropMaterialCache2D::materials_get); - ClassDB::bind_method(D_METHOD("materials_set"), &PropMaterialCache2D::materials_set); + ClassDB::bind_method(D_METHOD("materials_get"), &PropMaterialCache::materials_get); + ClassDB::bind_method(D_METHOD("materials_set"), &PropMaterialCache::materials_set); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get"); - ClassDB::bind_method(D_METHOD("texture_add", "texture"), &PropMaterialCache2D::texture_add); - ClassDB::bind_method(D_METHOD("texture_remove", "texture"), &PropMaterialCache2D::texture_remove); - ClassDB::bind_method(D_METHOD("texture_remove_index", "index"), &PropMaterialCache2D::texture_remove_index); - ClassDB::bind_method(D_METHOD("textures_clear"), &PropMaterialCache2D::textures_clear); - ClassDB::bind_method(D_METHOD("texture_count"), &PropMaterialCache2D::texture_count); - ClassDB::bind_method(D_METHOD("texture_get", "index"), &PropMaterialCache2D::texture_get); - ClassDB::bind_method(D_METHOD("texture_get_atlas", "index"), &PropMaterialCache2D::texture_get_atlas); - ClassDB::bind_method(D_METHOD("texture_get_atlas_tex", "index"), &PropMaterialCache2D::texture_get_atlas_tex); - ClassDB::bind_method(D_METHOD("texture_get_uv_rect", "texture"), &PropMaterialCache2D::texture_get_uv_rect); + ClassDB::bind_method(D_METHOD("texture_add", "texture"), &PropMaterialCache::texture_add); + ClassDB::bind_method(D_METHOD("texture_remove", "texture"), &PropMaterialCache::texture_remove); + ClassDB::bind_method(D_METHOD("texture_remove_index", "index"), &PropMaterialCache::texture_remove_index); + ClassDB::bind_method(D_METHOD("textures_clear"), &PropMaterialCache::textures_clear); + ClassDB::bind_method(D_METHOD("texture_count"), &PropMaterialCache::texture_count); + ClassDB::bind_method(D_METHOD("texture_get", "index"), &PropMaterialCache::texture_get); + ClassDB::bind_method(D_METHOD("texture_get_atlas", "index"), &PropMaterialCache::texture_get_atlas); + ClassDB::bind_method(D_METHOD("texture_get_atlas_tex", "index"), &PropMaterialCache::texture_get_atlas_tex); + ClassDB::bind_method(D_METHOD("texture_get_uv_rect", "texture"), &PropMaterialCache::texture_get_uv_rect); - ClassDB::bind_method(D_METHOD("prop_add_textures", "prop"), &PropMaterialCache2D::prop_add_textures); - ClassDB::bind_method(D_METHOD("prop_remove_textures", "prop"), &PropMaterialCache2D::prop_remove_textures); + ClassDB::bind_method(D_METHOD("prop_add_textures", "prop"), &PropMaterialCache::prop_add_textures); + ClassDB::bind_method(D_METHOD("prop_remove_textures", "prop"), &PropMaterialCache::prop_remove_textures); - ClassDB::bind_method(D_METHOD("refresh_rects"), &PropMaterialCache2D::refresh_rects); + ClassDB::bind_method(D_METHOD("refresh_rects"), &PropMaterialCache::refresh_rects); - ClassDB::bind_method(D_METHOD("setup_material_albedo", "texture"), &PropMaterialCache2D::setup_material_albedo); + ClassDB::bind_method(D_METHOD("setup_material_albedo", "texture"), &PropMaterialCache::setup_material_albedo); } diff --git a/material_cache/prop_material_cache_2d.h b/material_cache/prop_material_cache.h similarity index 88% rename from material_cache/prop_material_cache_2d.h rename to material_cache/prop_material_cache.h index 4832ae2..77c175e 100644 --- a/material_cache/prop_material_cache_2d.h +++ b/material_cache/prop_material_cache.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_MATERIAL_CACHE_2D_H -#define PROP_MATERIAL_CACHE_2D_H +#ifndef PROP_MATERIAL_CACHE_H +#define PROP_MATERIAL_CACHE_H #include "core/version.h" @@ -39,10 +39,10 @@ SOFTWARE. #include "scene/resources/material.h" #include "core/os/mutex.h" -class PropData2D; +class PropData; -class PropMaterialCache2D : public Resource { - GDCLASS(PropMaterialCache2D, Resource) +class PropMaterialCache : public Resource { + GDCLASS(PropMaterialCache, Resource) public: bool get_initialized(); @@ -78,8 +78,8 @@ public: virtual Ref texture_get_atlas_tex(const Ref &texture); virtual Rect2 texture_get_uv_rect(const Ref &texture); - void prop_add_textures(const Ref &prop); - void prop_remove_textures(const Ref &prop); + void prop_add_textures(const Ref &prop); + void prop_remove_textures(const Ref &prop); virtual void refresh_rects(); @@ -87,8 +87,8 @@ public: void setup_material_albedo(Ref texture); - PropMaterialCache2D(); - ~PropMaterialCache2D(); + PropMaterialCache(); + ~PropMaterialCache(); protected: static void _bind_methods(); diff --git a/material_cache/prop_material_cache_pcm_2d.cpp b/material_cache/prop_material_cache_pcm.cpp similarity index 72% rename from material_cache/prop_material_cache_pcm_2d.cpp rename to material_cache/prop_material_cache_pcm.cpp index 8db74fd..eb35af8 100644 --- a/material_cache/prop_material_cache_pcm_2d.cpp +++ b/material_cache/prop_material_cache_pcm.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,55 +20,55 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_material_cache_pcm_2d.h" +#include "prop_material_cache_pcm.h" #include "../../texture_packer/texture_packer.h" -#include "../singleton/prop_cache_2d.h" +#include "../singleton/prop_cache.h" #include "scene/resources/texture.h" -int PropMaterialCachePCM2D::get_texture_flags() const { +int PropMaterialCachePCM::get_texture_flags() const { return _packer->get_texture_flags(); } -void PropMaterialCachePCM2D::set_texture_flags(const int flags) { +void PropMaterialCachePCM::set_texture_flags(const int flags) { _packer->set_texture_flags(flags); } -int PropMaterialCachePCM2D::get_max_atlas_size() const { +int PropMaterialCachePCM::get_max_atlas_size() const { return _packer->get_max_atlas_size(); } -void PropMaterialCachePCM2D::set_max_atlas_size(const int size) { +void PropMaterialCachePCM::set_max_atlas_size(const int size) { _packer->set_max_atlas_size(size); } -bool PropMaterialCachePCM2D::get_keep_original_atlases() const { +bool PropMaterialCachePCM::get_keep_original_atlases() const { return _packer->get_keep_original_atlases(); } -void PropMaterialCachePCM2D::set_keep_original_atlases(const bool value) { +void PropMaterialCachePCM::set_keep_original_atlases(const bool value) { _packer->set_keep_original_atlases(value); } -Color PropMaterialCachePCM2D::get_background_color() const { +Color PropMaterialCachePCM::get_background_color() const { return _packer->get_background_color(); } -void PropMaterialCachePCM2D::set_background_color(const Color &color) { +void PropMaterialCachePCM::set_background_color(const Color &color) { _packer->set_background_color(color); } -int PropMaterialCachePCM2D::get_margin() const { +int PropMaterialCachePCM::get_margin() const { return _packer->get_margin(); } -void PropMaterialCachePCM2D::set_margin(const int margin) { +void PropMaterialCachePCM::set_margin(const int margin) { _packer->set_margin(margin); } -Ref PropMaterialCachePCM2D::texture_get_atlas_tex(const Ref &texture) { +Ref PropMaterialCachePCM::texture_get_atlas_tex(const Ref &texture) { if (!_packer->contains_texture(texture)) { return Ref(); } return _packer->get_texture(texture); } -Rect2 PropMaterialCachePCM2D::texture_get_uv_rect(const Ref &texture) { +Rect2 PropMaterialCachePCM::texture_get_uv_rect(const Ref &texture) { if (!texture.is_valid()) { return Rect2(0, 0, 1, 1); } @@ -93,8 +93,8 @@ Rect2 PropMaterialCachePCM2D::texture_get_uv_rect(const Ref &texture) { return Rect2(0, 0, 1, 1); } - float w = image->get_width(); - float h = image->get_height(); + float w = tex->get_width(); + float h = tex->get_height(); region.position = Size2(region.position.x / w, region.position.y / h); region.size = Size2(region.size.x / w, region.size.y / h); @@ -102,7 +102,7 @@ Rect2 PropMaterialCachePCM2D::texture_get_uv_rect(const Ref &texture) { return region; } -void PropMaterialCachePCM2D::refresh_rects() { +void PropMaterialCachePCM::refresh_rects() { bool texture_added = false; for (int i = 0; i < _textures.size(); i++) { @@ -129,10 +129,10 @@ void PropMaterialCachePCM2D::refresh_rects() { _initialized = true; } -void PropMaterialCachePCM2D::initial_setup_default() { - PropMaterialCache2D::initial_setup_default(); +void PropMaterialCachePCM::initial_setup_default() { + PropMaterialCache::initial_setup_default(); - PropCache2D *pc = PropCache2D::get_singleton(); + PropCache *pc = PropCache::get_singleton(); set_texture_flags(pc->get_texture_flags()); set_max_atlas_size(pc->get_max_atlas_size()); @@ -141,7 +141,7 @@ void PropMaterialCachePCM2D::initial_setup_default() { set_margin(pc->get_margin()); } -void PropMaterialCachePCM2D::_setup_material_albedo(Ref texture) { +void PropMaterialCachePCM::_setup_material_albedo(Ref texture) { int count = material_get_num(); for (int i = 0; i < count; ++i) { @@ -151,7 +151,7 @@ void PropMaterialCachePCM2D::_setup_material_albedo(Ref texture) { if (spmat.is_valid()) { spmat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); - return; + continue; } Ref shmat = m; @@ -162,7 +162,7 @@ void PropMaterialCachePCM2D::_setup_material_albedo(Ref texture) { } } -PropMaterialCachePCM2D::PropMaterialCachePCM2D() { +PropMaterialCachePCM::PropMaterialCachePCM() { _packer.instance(); #if GODOT4 @@ -176,31 +176,31 @@ PropMaterialCachePCM2D::PropMaterialCachePCM2D() { _packer->set_margin(0); } -PropMaterialCachePCM2D::~PropMaterialCachePCM2D() { +PropMaterialCachePCM::~PropMaterialCachePCM() { _packer->clear(); _packer.unref(); } -void PropMaterialCachePCM2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_texture_flags"), &PropMaterialCachePCM2D::get_texture_flags); - ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &PropMaterialCachePCM2D::set_texture_flags); +void PropMaterialCachePCM::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_texture_flags"), &PropMaterialCachePCM::get_texture_flags); + ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &PropMaterialCachePCM::set_texture_flags); ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic Linear,Convert to Linear,Mirrored Repeat,Video Surface"), "set_texture_flags", "get_texture_flags"); - ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &PropMaterialCachePCM2D::get_max_atlas_size); - ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropMaterialCachePCM2D::set_max_atlas_size); + ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &PropMaterialCachePCM::get_max_atlas_size); + ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropMaterialCachePCM::set_max_atlas_size); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_atlas_size"), "set_max_atlas_size", "get_max_atlas_size"); - ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &PropMaterialCachePCM2D::get_keep_original_atlases); - ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropMaterialCachePCM2D::set_keep_original_atlases); + ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &PropMaterialCachePCM::get_keep_original_atlases); + ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropMaterialCachePCM::set_keep_original_atlases); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_original_atlases"), "set_keep_original_atlases", "get_keep_original_atlases"); - ClassDB::bind_method(D_METHOD("get_background_color"), &PropMaterialCachePCM2D::get_background_color); - ClassDB::bind_method(D_METHOD("set_background_color", "color"), &PropMaterialCachePCM2D::set_background_color); + ClassDB::bind_method(D_METHOD("get_background_color"), &PropMaterialCachePCM::get_background_color); + ClassDB::bind_method(D_METHOD("set_background_color", "color"), &PropMaterialCachePCM::set_background_color); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_background_color", "get_background_color"); - ClassDB::bind_method(D_METHOD("get_margin"), &PropMaterialCachePCM2D::get_margin); - ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropMaterialCachePCM2D::set_margin); + ClassDB::bind_method(D_METHOD("get_margin"), &PropMaterialCachePCM::get_margin); + ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropMaterialCachePCM::set_margin); ADD_PROPERTY(PropertyInfo(Variant::INT, "margin"), "set_margin", "get_margin"); - ClassDB::bind_method(D_METHOD("_setup_material_albedo", "texture"), &PropMaterialCachePCM2D::_setup_material_albedo); + ClassDB::bind_method(D_METHOD("_setup_material_albedo", "texture"), &PropMaterialCachePCM::_setup_material_albedo); } diff --git a/material_cache/prop_material_cache_pcm_2d.h b/material_cache/prop_material_cache_pcm.h similarity index 86% rename from material_cache/prop_material_cache_pcm_2d.h rename to material_cache/prop_material_cache_pcm.h index 1fc8eca..f11e763 100644 --- a/material_cache/prop_material_cache_pcm_2d.h +++ b/material_cache/prop_material_cache_pcm.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_MATERIAL_CACHE_PCM_2D_H -#define PROP_MATERIAL_CACHE_PCM_2D_H +#ifndef PROP_MATERIAL_CACHE_PCM_H +#define PROP_MATERIAL_CACHE_PCM_H -#include "prop_material_cache_2d.h" +#include "prop_material_cache.h" #include "core/version.h" @@ -43,8 +43,8 @@ SOFTWARE. class TexturePacker; class PropData; -class PropMaterialCachePCM2D : public PropMaterialCache2D { - GDCLASS(PropMaterialCachePCM2D, PropMaterialCache2D); +class PropMaterialCachePCM : public PropMaterialCache { + GDCLASS(PropMaterialCachePCM, PropMaterialCache); public: int get_texture_flags() const; @@ -71,8 +71,8 @@ public: void _setup_material_albedo(Ref texture); - PropMaterialCachePCM2D(); - ~PropMaterialCachePCM2D(); + PropMaterialCachePCM(); + ~PropMaterialCachePCM(); protected: static void _bind_methods(); diff --git a/prop_ess_entity.cpp b/prop_ess_entity.cpp new file mode 100644 index 0000000..947deb2 --- /dev/null +++ b/prop_ess_entity.cpp @@ -0,0 +1,9 @@ +#include "prop_ess_entity.h" + +PropESSEntity::PropESSEntity() { +} +PropESSEntity::~PropESSEntity() { +} + +void PropESSEntity::_bind_methods() { +} diff --git a/prop_ess_entity_2d.h b/prop_ess_entity.h similarity index 86% rename from prop_ess_entity_2d.h rename to prop_ess_entity.h index 9c0ae69..f703a20 100644 --- a/prop_ess_entity_2d.h +++ b/prop_ess_entity.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2020 Péter Magyar +Copyright (c) 2020-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_ESS_ENTITY_2D_H -#define PROP_ESS_ENTITY_2D_H +#ifndef PROP_ESS_ENTITY_H +#define PROP_ESS_ENTITY_H #include "core/version.h" @@ -35,13 +35,13 @@ SOFTWARE. #include "core/math/vector3.h" -class PropESSEntity2D : public Spatial { - GDCLASS(PropESSEntity2D, Spatial); +class PropESSEntity : public Spatial { + GDCLASS(PropESSEntity, Spatial); OBJ_CATEGORY("Props"); public: - PropESSEntity2D(); - ~PropESSEntity2D(); + PropESSEntity(); + ~PropESSEntity(); protected: static void _bind_methods(); diff --git a/prop_ess_entity_2d.cpp b/prop_ess_entity_2d.cpp deleted file mode 100644 index a7c3f94..0000000 --- a/prop_ess_entity_2d.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "prop_ess_entity_2d.h" - -PropESSEntity2D::PropESSEntity2D() { -} -PropESSEntity2D::~PropESSEntity2D() { -} - -void PropESSEntity2D::_bind_methods() { -} diff --git a/prop_instance_2d.cpp b/prop_instance.cpp similarity index 64% rename from prop_instance_2d.cpp rename to prop_instance.cpp index 5922a02..845ed64 100644 --- a/prop_instance_2d.cpp +++ b/prop_instance.cpp @@ -1,4 +1,4 @@ -#include "prop_instance_2d.h" +#include "prop_instance.h" #include "../mesh_data_resource/nodes/mesh_data_instance.h" @@ -15,23 +15,23 @@ #if MESH_DATA_RESOURCE_PRESENT //define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling, //but not when included from here. -#define PROPS_PRESENT 1 -#include "../mesh_data_resource/props/prop_data_mesh_data.h" +#define PROPS_2D_PRESENT 1 +#include "../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h" #endif -#include "./props/prop_data_entry_2d.h" -#include "./props/prop_data_light_2d.h" -#include "./props/prop_data_prop_2d.h" -#include "./props/prop_data_scene_2d.h" -#include "./props/prop_data_tiled_wall_2d.h" +#include "./props/prop_data_entry.h" +#include "./props/prop_data_light.h" +#include "./props/prop_data_prop.h" +#include "./props/prop_data_scene.h" +#include "./props/prop_data_tiled_wall.h" -#include "tiled_wall/tiled_wall_2d.h" -#include "tiled_wall/tiled_wall_data_2d.h" +#include "tiled_wall/tiled_wall.h" +#include "tiled_wall/tiled_wall_data.h" -Ref PropInstance2D::get_prop_data() { +Ref PropInstance::get_prop_data() { return _prop_data; } -void PropInstance2D::set_prop_data(const Ref &data) { +void PropInstance::set_prop_data(const Ref &data) { if (_prop_data == data) return; @@ -44,58 +44,58 @@ void PropInstance2D::set_prop_data(const Ref &data) { } } -Ref PropInstance2D::get_material() { +Ref PropInstance::get_material() { return _material; } -void PropInstance2D::set_material(const Ref &material) { +void PropInstance::set_material(const Ref &material) { _material = material; } -uint32_t PropInstance2D::get_collision_layer() const { +uint32_t PropInstance::get_collision_layer() const { return _collision_layer; } -void PropInstance2D::set_collision_layer(uint32_t p_layer) { +void PropInstance::set_collision_layer(uint32_t p_layer) { _collision_layer = p_layer; collision_layer_changed(); } -uint32_t PropInstance2D::get_collision_mask() const { +uint32_t PropInstance::get_collision_mask() const { return _collision_mask; } -void PropInstance2D::set_collision_mask(uint32_t p_mask) { +void PropInstance::set_collision_mask(uint32_t p_mask) { _collision_mask = p_mask; collision_mask_changed(); } -void PropInstance2D::collision_layer_changed() { +void PropInstance::collision_layer_changed() { } -void PropInstance2D::collision_mask_changed() { +void PropInstance::collision_mask_changed() { } -void PropInstance2D::init_materials() { +void PropInstance::init_materials() { call("_init_materials"); } -void PropInstance2D::_init_materials() { +void PropInstance::_init_materials() { } -void PropInstance2D::build() { +void PropInstance::build() { call("_build"); } -void PropInstance2D::queue_build() { +void PropInstance::queue_build() { _build_queued = true; } -void PropInstance2D::build_finished() { +void PropInstance::build_finished() { call("_build_finished"); } -void PropInstance2D::_build() { +void PropInstance::_build() { _building = true; _build_queued = false; @@ -118,7 +118,7 @@ void PropInstance2D::_build() { prop_preprocess(Transform(), _prop_data); } -void PropInstance2D::_build_finished() { +void PropInstance::_build_finished() { _building = false; if (_build_queued) { @@ -126,28 +126,28 @@ void PropInstance2D::_build_finished() { } } -void PropInstance2D::prop_preprocess(Transform transform, const Ref &prop) { +void PropInstance::prop_preprocess(Transform transform, const Ref &prop) { call("_prop_preprocess", transform, prop); } -void PropInstance2D::_prop_preprocess(Transform transform, const Ref &prop) { +void PropInstance::_prop_preprocess(Transform transform, const Ref &prop) { //don't set owners, to help working with the editor ERR_FAIL_COND(!prop.is_valid()); int count = prop->get_prop_count(); for (int i = 0; i < count; ++i) { - Ref e = prop->get_prop(i); + Ref e = prop->get_prop(i); if (!e.is_valid()) continue; Transform t = transform * e->get_transform(); - Ref prop_entry_data = e; + Ref prop_entry_data = e; if (prop_entry_data.is_valid()) { - Ref p = prop_entry_data->get_prop(); + Ref p = prop_entry_data->get_prop(); if (!p.is_valid()) continue; @@ -157,10 +157,10 @@ void PropInstance2D::_prop_preprocess(Transform transform, const Ref continue; } - Ref tiled_wall_data = e; + Ref tiled_wall_data = e; if (tiled_wall_data.is_valid()) { - TiledWall2D *twn = memnew(TiledWall2D); + TiledWall *twn = memnew(TiledWall); twn->set_width(tiled_wall_data->get_width()); twn->set_heigth(tiled_wall_data->get_heigth()); @@ -174,7 +174,7 @@ void PropInstance2D::_prop_preprocess(Transform transform, const Ref continue; } - Ref scene_data = e; + Ref scene_data = e; if (scene_data.is_valid()) { Ref sc = scene_data->get_scene(); @@ -194,7 +194,7 @@ void PropInstance2D::_prop_preprocess(Transform transform, const Ref continue; } - Ref light_data = e; + Ref light_data = e; if (light_data.is_valid()) { OmniLight *light = memnew(OmniLight); @@ -207,7 +207,7 @@ void PropInstance2D::_prop_preprocess(Transform transform, const Ref } #if MESH_DATA_RESOURCE_PRESENT - Ref mesh_data = e; + Ref mesh_data = e; if (mesh_data.is_valid()) { Ref mdr = mesh_data->get_mesh(); @@ -251,7 +251,7 @@ void PropInstance2D::_prop_preprocess(Transform transform, const Ref } } -PropInstance2D::PropInstance2D() { +PropInstance::PropInstance() { _build_queued = false; _building = false; @@ -259,11 +259,11 @@ PropInstance2D::PropInstance2D() { _collision_mask = 1; } -PropInstance2D::~PropInstance2D() { +PropInstance::~PropInstance() { _prop_data.unref(); } -void PropInstance2D::_notification(int p_what) { +void PropInstance::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { if (_prop_data.is_valid()) { @@ -275,20 +275,20 @@ void PropInstance2D::_notification(int p_what) { } } -void PropInstance2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_prop_data"), &PropInstance2D::get_prop_data); - ClassDB::bind_method(D_METHOD("set_prop_data", "value"), &PropInstance2D::set_prop_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D"), "set_prop_data", "get_prop_data"); +void PropInstance::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_prop_data"), &PropInstance::get_prop_data); + ClassDB::bind_method(D_METHOD("set_prop_data", "value"), &PropInstance::set_prop_data); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop_data", "get_prop_data"); - ClassDB::bind_method(D_METHOD("get_material"), &PropInstance2D::get_material); - ClassDB::bind_method(D_METHOD("set_material", "material"), &PropInstance2D::set_material); + ClassDB::bind_method(D_METHOD("get_material"), &PropInstance::get_material); + ClassDB::bind_method(D_METHOD("set_material", "material"), &PropInstance::set_material); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_material", "get_material"); - ClassDB::bind_method(D_METHOD("get_collision_layer"), &PropInstance2D::get_collision_layer); - ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PropInstance2D::set_collision_layer); + ClassDB::bind_method(D_METHOD("get_collision_layer"), &PropInstance::get_collision_layer); + ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PropInstance::set_collision_layer); - ClassDB::bind_method(D_METHOD("get_collision_mask"), &PropInstance2D::get_collision_mask); - ClassDB::bind_method(D_METHOD("set_collision_mask", "layer"), &PropInstance2D::set_collision_mask); + ClassDB::bind_method(D_METHOD("get_collision_mask"), &PropInstance::get_collision_mask); + ClassDB::bind_method(D_METHOD("set_collision_mask", "layer"), &PropInstance::set_collision_mask); ADD_GROUP("Collision", "collision_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer"); @@ -296,25 +296,25 @@ void PropInstance2D::_bind_methods() { BIND_VMETHOD(MethodInfo("_prop_preprocess", PropertyInfo(Variant::TRANSFORM, "tarnsform"), - PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D"))); + PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"))); - ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &PropInstance2D::prop_preprocess); - ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &PropInstance2D::_prop_preprocess); + ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &PropInstance::prop_preprocess); + ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &PropInstance::_prop_preprocess); //--- BIND_VMETHOD(MethodInfo("_init_materials")); - ClassDB::bind_method(D_METHOD("init_materials"), &PropInstance2D::init_materials); - ClassDB::bind_method(D_METHOD("_init_materials"), &PropInstance2D::_init_materials); + ClassDB::bind_method(D_METHOD("init_materials"), &PropInstance::init_materials); + ClassDB::bind_method(D_METHOD("_init_materials"), &PropInstance::_init_materials); //--- - ClassDB::bind_method(D_METHOD("build"), &PropInstance2D::build); - ClassDB::bind_method(D_METHOD("queue_build"), &PropInstance2D::queue_build); - ClassDB::bind_method(D_METHOD("build_finished"), &PropInstance2D::build_finished); + ClassDB::bind_method(D_METHOD("build"), &PropInstance::build); + ClassDB::bind_method(D_METHOD("queue_build"), &PropInstance::queue_build); + ClassDB::bind_method(D_METHOD("build_finished"), &PropInstance::build_finished); BIND_VMETHOD(MethodInfo("_build")); BIND_VMETHOD(MethodInfo("_build_finished")); - ClassDB::bind_method(D_METHOD("_build"), &PropInstance2D::_build); - ClassDB::bind_method(D_METHOD("_build_finished"), &PropInstance2D::_build_finished); + ClassDB::bind_method(D_METHOD("_build"), &PropInstance::_build); + ClassDB::bind_method(D_METHOD("_build_finished"), &PropInstance::_build_finished); } diff --git a/prop_instance_2d.h b/prop_instance.h similarity index 82% rename from prop_instance_2d.h rename to prop_instance.h index 6b0117e..8ce49bb 100644 --- a/prop_instance_2d.h +++ b/prop_instance.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2020 Péter Magyar +Copyright (c) 2020-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_INSTANCE_2D_H -#define PROP_INSTANCE_2D_H +#ifndef PROP_INSTANCE_H +#define PROP_INSTANCE_H #include "core/version.h" @@ -37,14 +37,14 @@ SOFTWARE. #include "core/math/vector3.h" -#include "props/prop_data_2d.h" +#include "props/prop_data.h" -class PropInstance2D : public Spatial { - GDCLASS(PropInstance2D, Spatial); +class PropInstance : public Spatial { + GDCLASS(PropInstance, Spatial); public: - Ref get_prop_data(); - void set_prop_data(const Ref &data); + Ref get_prop_data(); + void set_prop_data(const Ref &data); Ref get_material(); void set_material(const Ref &material); @@ -68,18 +68,18 @@ public: virtual void _build(); virtual void _build_finished(); - void prop_preprocess(Transform tarnsform, const Ref &prop); - virtual void _prop_preprocess(Transform tarnsform, const Ref &prop); + void prop_preprocess(Transform tarnsform, const Ref &prop); + virtual void _prop_preprocess(Transform tarnsform, const Ref &prop); - PropInstance2D(); - ~PropInstance2D(); + PropInstance(); + ~PropInstance(); protected: void _notification(int p_what); static void _bind_methods(); protected: - Ref _prop_data; + Ref _prop_data; Ref _material; uint32_t _collision_layer; diff --git a/prop_instance_job_2d.cpp b/prop_instance_job.cpp similarity index 58% rename from prop_instance_job_2d.cpp rename to prop_instance_job.cpp index f863b35..fe2af45 100644 --- a/prop_instance_job_2d.cpp +++ b/prop_instance_job.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,55 +20,55 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_instance_job_2d.h" +#include "prop_instance_job.h" -#include "prop_instance_2d.h" +#include "prop_instance.h" -#include "./props/prop_data_2d.h" +#include "./props/prop_data.h" #include "../opensimplex/open_simplex_noise.h" -const String PropInstanceJob2D::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process"; +const String PropInstanceJob::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process"; -PropInstanceJob2D::ActiveBuildPhaseType PropInstanceJob2D::get_build_phase_type() { +PropInstanceJob::ActiveBuildPhaseType PropInstanceJob::get_build_phase_type() { return _build_phase_type; } -void PropInstanceJob2D::set_build_phase_type(PropInstanceJob2D::ActiveBuildPhaseType build_phase_type) { +void PropInstanceJob::set_build_phase_type(PropInstanceJob::ActiveBuildPhaseType build_phase_type) { _build_phase_type = build_phase_type; } -void PropInstanceJob2D::set_prop(const Ref &prop) { +void PropInstanceJob::set_prop(const Ref &prop) { _prop = prop; _in_tree = true; } -void PropInstanceJob2D::set_prop_instance(PropInstance2D *instance) { +void PropInstanceJob::set_prop_instance(PropInstance *instance) { _instance = instance; } -void PropInstanceJob2D::set_prop_instance_bind(Node *instance) { - set_prop_instance(Object::cast_to(instance)); +void PropInstanceJob::set_prop_instance_bind(Node *instance) { + set_prop_instance(Object::cast_to(instance)); } -int PropInstanceJob2D::get_phase() { +int PropInstanceJob::get_phase() { return _phase; } -void PropInstanceJob2D::set_phase(const int phase) { +void PropInstanceJob::set_phase(const int phase) { _phase = phase; } -void PropInstanceJob2D::next_phase() { +void PropInstanceJob::next_phase() { ++_phase; } -bool PropInstanceJob2D::get_build_done() { +bool PropInstanceJob::get_build_done() { return _build_done; } -void PropInstanceJob2D::set_build_done(const bool val) { +void PropInstanceJob::set_build_done(const bool val) { _build_done = val; } -void PropInstanceJob2D::finished() { +void PropInstanceJob::finished() { set_build_done(true); if (_instance) { @@ -76,15 +76,15 @@ void PropInstanceJob2D::finished() { } } -void PropInstanceJob2D::reset() { +void PropInstanceJob::reset() { call("_reset"); } -void PropInstanceJob2D::_reset() { +void PropInstanceJob::_reset() { _build_done = false; _phase = 0; } -void PropInstanceJob2D::_execute() { +void PropInstanceJob::_execute() { ActiveBuildPhaseType origpt = _build_phase_type; while (!get_cancelled() && _in_tree && !_build_done && origpt == _build_phase_type && !should_return()) { @@ -92,28 +92,28 @@ void PropInstanceJob2D::_execute() { } } -void PropInstanceJob2D::execute_phase() { +void PropInstanceJob::execute_phase() { call("_execute_phase"); } -void PropInstanceJob2D::_execute_phase() { +void PropInstanceJob::_execute_phase() { finished(); } -void PropInstanceJob2D::process(const float delta) { +void PropInstanceJob::process(const float delta) { if (has_method("_process")) call("_process", delta); } -void PropInstanceJob2D::physics_process(const float delta) { +void PropInstanceJob::physics_process(const float delta) { if (has_method("_physics_process")) call("_physics_process", delta); } -void PropInstanceJob2D::prop_instance_enter_tree() { +void PropInstanceJob::prop_instance_enter_tree() { _in_tree = true; } -void PropInstanceJob2D::prop_instance_exit_tree() { +void PropInstanceJob::prop_instance_exit_tree() { _in_tree = false; if (get_complete()) { @@ -123,7 +123,7 @@ void PropInstanceJob2D::prop_instance_exit_tree() { } } -PropInstanceJob2D::PropInstanceJob2D() { +PropInstanceJob::PropInstanceJob() { _instance = NULL; _in_tree = false; @@ -143,137 +143,137 @@ PropInstanceJob2D::PropInstanceJob2D() { #endif } -PropInstanceJob2D::~PropInstanceJob2D() { +PropInstanceJob::~PropInstanceJob() { _prop.unref(); _instance = NULL; } -void PropInstanceJob2D::_bind_methods() { +void PropInstanceJob::_bind_methods() { BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta"))); BIND_VMETHOD(MethodInfo("_physics_process", PropertyInfo(Variant::REAL, "delta"))); - ClassDB::bind_method(D_METHOD("get_build_phase_type"), &PropInstanceJob2D::get_build_phase_type); - ClassDB::bind_method(D_METHOD("set_build_phase_type", "value"), &PropInstanceJob2D::set_build_phase_type); + ClassDB::bind_method(D_METHOD("get_build_phase_type"), &PropInstanceJob::get_build_phase_type); + ClassDB::bind_method(D_METHOD("set_build_phase_type", "value"), &PropInstanceJob::set_build_phase_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "build_phase_type", PROPERTY_HINT_ENUM, BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE), "set_build_phase_type", "get_build_phase_type"); - ClassDB::bind_method(D_METHOD("set_prop", "prop"), &PropInstanceJob2D::set_prop); - ClassDB::bind_method(D_METHOD("set_prop_instance", "instance"), &PropInstanceJob2D::set_prop_instance_bind); + ClassDB::bind_method(D_METHOD("set_prop", "prop"), &PropInstanceJob::set_prop); + ClassDB::bind_method(D_METHOD("set_prop_instance", "instance"), &PropInstanceJob::set_prop_instance_bind); - ClassDB::bind_method(D_METHOD("get_phase"), &PropInstanceJob2D::get_phase); - ClassDB::bind_method(D_METHOD("set_phase", "phase"), &PropInstanceJob2D::set_phase); - ClassDB::bind_method(D_METHOD("next_phase"), &PropInstanceJob2D::next_phase); + ClassDB::bind_method(D_METHOD("get_phase"), &PropInstanceJob::get_phase); + ClassDB::bind_method(D_METHOD("set_phase", "phase"), &PropInstanceJob::set_phase); + ClassDB::bind_method(D_METHOD("next_phase"), &PropInstanceJob::next_phase); - ClassDB::bind_method(D_METHOD("get_build_done"), &PropInstanceJob2D::get_build_done); - ClassDB::bind_method(D_METHOD("set_build_done", "val"), &PropInstanceJob2D::set_build_done); + ClassDB::bind_method(D_METHOD("get_build_done"), &PropInstanceJob::get_build_done); + ClassDB::bind_method(D_METHOD("set_build_done", "val"), &PropInstanceJob::set_build_done); - ClassDB::bind_method(D_METHOD("finished"), &PropInstanceJob2D::finished); + ClassDB::bind_method(D_METHOD("finished"), &PropInstanceJob::finished); BIND_VMETHOD(MethodInfo("_reset")); - ClassDB::bind_method(D_METHOD("reset"), &PropInstanceJob2D::reset); - ClassDB::bind_method(D_METHOD("_reset"), &PropInstanceJob2D::_reset); + ClassDB::bind_method(D_METHOD("reset"), &PropInstanceJob::reset); + ClassDB::bind_method(D_METHOD("_reset"), &PropInstanceJob::_reset); - ClassDB::bind_method(D_METHOD("_execute"), &PropInstanceJob2D::_execute); + ClassDB::bind_method(D_METHOD("_execute"), &PropInstanceJob::_execute); BIND_VMETHOD(MethodInfo("_execute_phase")); - ClassDB::bind_method(D_METHOD("execute_phase"), &PropInstanceJob2D::execute_phase); - ClassDB::bind_method(D_METHOD("_execute_phase"), &PropInstanceJob2D::_execute_phase); + ClassDB::bind_method(D_METHOD("execute_phase"), &PropInstanceJob::execute_phase); + ClassDB::bind_method(D_METHOD("_execute_phase"), &PropInstanceJob::_execute_phase); - ClassDB::bind_method(D_METHOD("prop_instance_exit_tree"), &PropInstanceJob2D::prop_instance_exit_tree); + ClassDB::bind_method(D_METHOD("prop_instance_exit_tree"), &PropInstanceJob::prop_instance_exit_tree); #if !THREAD_POOL_PRESENT - ClassDB::bind_method(D_METHOD("get_complete"), &PropInstanceJob2D::get_complete); - ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropInstanceJob2D::set_complete); + ClassDB::bind_method(D_METHOD("get_complete"), &PropInstanceJob::get_complete); + ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropInstanceJob::set_complete); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "complete"), "set_complete", "get_complete"); - ClassDB::bind_method(D_METHOD("get_start_time"), &PropInstanceJob2D::get_start_time); - ClassDB::bind_method(D_METHOD("set_start_time", "value"), &PropInstanceJob2D::set_start_time); + ClassDB::bind_method(D_METHOD("get_start_time"), &PropInstanceJob::get_start_time); + ClassDB::bind_method(D_METHOD("set_start_time", "value"), &PropInstanceJob::set_start_time); ADD_PROPERTY(PropertyInfo(Variant::INT, "start_time"), "set_start_time", "get_start_time"); - ClassDB::bind_method(D_METHOD("get_current_run_stage"), &PropInstanceJob2D::get_current_run_stage); - ClassDB::bind_method(D_METHOD("set_current_run_stage", "value"), &PropInstanceJob2D::set_current_run_stage); + ClassDB::bind_method(D_METHOD("get_current_run_stage"), &PropInstanceJob::get_current_run_stage); + ClassDB::bind_method(D_METHOD("set_current_run_stage", "value"), &PropInstanceJob::set_current_run_stage); ADD_PROPERTY(PropertyInfo(Variant::INT, "current_run_stage"), "set_current_run_stage", "get_current_run_stage"); - ClassDB::bind_method(D_METHOD("get_stage"), &PropInstanceJob2D::get_stage); - ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropInstanceJob2D::set_stage); + ClassDB::bind_method(D_METHOD("get_stage"), &PropInstanceJob::get_stage); + ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropInstanceJob::set_stage); ADD_PROPERTY(PropertyInfo(Variant::INT, "stage"), "set_stage", "get_stage"); - ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropInstanceJob2D::get_current_execution_time); + ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropInstanceJob::get_current_execution_time); - ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropInstanceJob2D::should_do, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("should_return"), &PropInstanceJob2D::should_return); + ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropInstanceJob::should_do, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("should_return"), &PropInstanceJob::should_return); BIND_VMETHOD(MethodInfo("_execute")); - ClassDB::bind_method(D_METHOD("execute"), &PropInstanceJob2D::execute); + ClassDB::bind_method(D_METHOD("execute"), &PropInstanceJob::execute); ADD_SIGNAL(MethodInfo("completed")); #endif } #if !THREAD_POOL_PRESENT -bool PropInstanceJob2D::get_complete() const { +bool PropInstanceJob::get_complete() const { return _complete; } -void PropInstanceJob2D::set_complete(const bool value) { +void PropInstanceJob::set_complete(const bool value) { _complete = value; } -bool PropInstanceJob2D::get_cancelled() const { +bool PropInstanceJob::get_cancelled() const { return _cancelled; } -void PropInstanceJob2D::set_cancelled(const bool value) { +void PropInstanceJob::set_cancelled(const bool value) { _cancelled = value; } -float PropInstanceJob2D::get_max_allocated_time() const { +float PropInstanceJob::get_max_allocated_time() const { return _max_allocated_time; } -void PropInstanceJob2D::set_max_allocated_time(const float value) { +void PropInstanceJob::set_max_allocated_time(const float value) { _max_allocated_time = value; } -int PropInstanceJob2D::get_start_time() const { +int PropInstanceJob::get_start_time() const { return _start_time; } -void PropInstanceJob2D::set_start_time(const int value) { +void PropInstanceJob::set_start_time(const int value) { _start_time = value; } -int PropInstanceJob2D::get_current_run_stage() const { +int PropInstanceJob::get_current_run_stage() const { return _current_run_stage; } -void PropInstanceJob2D::set_current_run_stage(const int value) { +void PropInstanceJob::set_current_run_stage(const int value) { _current_run_stage = value; } -int PropInstanceJob2D::get_stage() const { +int PropInstanceJob::get_stage() const { return _stage; } -void PropInstanceJob2D::set_stage(const int value) { +void PropInstanceJob::set_stage(const int value) { _stage = value; } -void PropInstanceJob2D::reset_stages() { +void PropInstanceJob::reset_stages() { _current_run_stage = 0; _stage = 0; } -float PropInstanceJob2D::get_current_execution_time() { +float PropInstanceJob::get_current_execution_time() { return 0; } -bool PropInstanceJob2D::should_do(const bool just_check) { +bool PropInstanceJob::should_do(const bool just_check) { return true; } -bool PropInstanceJob2D::should_return() { +bool PropInstanceJob::should_return() { if (_cancelled) return true; return false; } -void PropInstanceJob2D::execute() { +void PropInstanceJob::execute() { ERR_FAIL_COND(!has_method("_execute")); call("_execute"); diff --git a/prop_instance_job_2d.h b/prop_instance_job.h similarity index 81% rename from prop_instance_job_2d.h rename to prop_instance_job.h index b9e9710..65d66b5 100644 --- a/prop_instance_job_2d.h +++ b/prop_instance_job.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_INSTANCE_2D_JOB -#define PROP_INSTANCE_2D_JOB +#ifndef PROP_INSTANCE_JOB +#define PROP_INSTANCE_JOB #include "scene/resources/texture.h" @@ -40,15 +40,15 @@ SOFTWARE. #endif -class PropData2D; -class PropInstance2D; +class PropData; +class PropInstance; #if THREAD_POOL_PRESENT -class PropInstanceJob2D : public ThreadPoolJob { - GDCLASS(PropInstanceJob2D, ThreadPoolJob); +class PropInstanceJob : public ThreadPoolJob { + GDCLASS(PropInstanceJob, ThreadPoolJob); #else -class PropInstanceJob2D : public Reference { - GDCLASS(PropInstanceJob2D, Reference); +class PropInstanceJob : public Reference { + GDCLASS(PropInstanceJob, Reference); #endif public: @@ -62,10 +62,10 @@ public: public: ActiveBuildPhaseType get_build_phase_type(); - void set_build_phase_type(PropInstanceJob2D::ActiveBuildPhaseType build_phase_type); + void set_build_phase_type(PropInstanceJob::ActiveBuildPhaseType build_phase_type); - void set_prop(const Ref &prop); - void set_prop_instance(PropInstance2D *instance); + void set_prop(const Ref &prop); + void set_prop_instance(PropInstance *instance); void set_prop_instance_bind(Node *instance); int get_phase(); @@ -91,8 +91,8 @@ public: void prop_instance_enter_tree(); void prop_instance_exit_tree(); - PropInstanceJob2D(); - ~PropInstanceJob2D(); + PropInstanceJob(); + ~PropInstanceJob(); protected: static void _bind_methods(); @@ -101,8 +101,8 @@ protected: bool _build_done; int _phase; bool _in_tree; - Ref _prop; - PropInstance2D *_instance; + Ref _prop; + PropInstance *_instance; public: #if !THREAD_POOL_PRESENT @@ -145,6 +145,6 @@ private: #endif }; -VARIANT_ENUM_CAST(PropInstanceJob2D::ActiveBuildPhaseType); +VARIANT_ENUM_CAST(PropInstanceJob::ActiveBuildPhaseType); #endif diff --git a/prop_instance_merger_2d.cpp b/prop_instance_merger.cpp similarity index 72% rename from prop_instance_merger_2d.cpp rename to prop_instance_merger.cpp index 354644a..7084bf5 100644 --- a/prop_instance_merger_2d.cpp +++ b/prop_instance_merger.cpp @@ -1,4 +1,4 @@ -#include "prop_instance_merger_2d.h" +#include "prop_instance_merger.h" #include "../mesh_data_resource/nodes/mesh_data_instance.h" @@ -40,39 +40,39 @@ typedef class RenderingServer VS; #if MESH_DATA_RESOURCE_PRESENT //define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling, //but not when included from here. -#define PROPS_PRESENT 1 -#include "../mesh_data_resource/props/prop_data_mesh_data.h" +#define PROPS_2D_PRESENT 1 +#include "../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h" #endif -#include "./props/prop_data_entry_2d.h" -#include "./props/prop_data_light_2d.h" -#include "./props/prop_data_prop_2d.h" -#include "./props/prop_data_scene_2d.h" -#include "jobs/prop_mesher_job_step_2d.h" -#include "lights/prop_light_2d.h" -#include "material_cache/prop_material_cache_2d.h" +#include "./props/prop_data_entry.h" +#include "./props/prop_data_light.h" +#include "./props/prop_data_prop.h" +#include "./props/prop_data_scene.h" +#include "jobs/prop_mesher_job_step.h" +#include "lights/prop_light.h" +#include "material_cache/prop_material_cache.h" #include "scene/3d/camera.h" #if TEXTURE_PACKER_PRESENT -#include "./singleton/prop_cache_2d.h" +#include "./singleton/prop_cache.h" #endif #if THREAD_POOL_PRESENT #include "../thread_pool/thread_pool.h" #endif -#include "./props/prop_data_tiled_wall_2d.h" +#include "./props/prop_data_tiled_wall.h" -#include "tiled_wall/tiled_wall_data_2d.h" +#include "tiled_wall/tiled_wall_data.h" #include "scene/resources/box_shape.h" -const float PropInstanceMerger2D::LOD_CHECK_INTERVAL = 2; +const float PropInstanceMerger::LOD_CHECK_INTERVAL = 2; -bool PropInstanceMerger2D::get_building() { +bool PropInstanceMerger::get_building() { return _building; } -void PropInstanceMerger2D::set_building(const bool value) { +void PropInstanceMerger::set_building(const bool value) { _building = value; set_physics_process_internal(_building); @@ -82,10 +82,10 @@ void PropInstanceMerger2D::set_building(const bool value) { } } -int PropInstanceMerger2D::get_lod_level() { +int PropInstanceMerger::get_lod_level() { return _lod_level; } -void PropInstanceMerger2D::set_lod_level(const int value) { +void PropInstanceMerger::set_lod_level(const int value) { _lod_level = value; if (_lod_level < 0) { @@ -95,62 +95,66 @@ void PropInstanceMerger2D::set_lod_level(const int value) { apply_lod_level(); } -bool PropInstanceMerger2D::get_auto_lod() { +bool PropInstanceMerger::get_auto_lod() { return _auto_lod; } -void PropInstanceMerger2D::set_auto_lod(const bool value) { +void PropInstanceMerger::set_auto_lod(const bool value) { _auto_lod = value; check_auto_lod(); } -float PropInstanceMerger2D::get_first_lod_distance_squared() { +float PropInstanceMerger::get_first_lod_distance_squared() { return _first_lod_distance_squared; } -void PropInstanceMerger2D::set_first_lod_distance_squared(const float dist) { +void PropInstanceMerger::set_first_lod_distance_squared(const float dist) { _first_lod_distance_squared = dist; } -float PropInstanceMerger2D::get_lod_reduction_distance_squared() { +float PropInstanceMerger::get_lod_reduction_distance_squared() { return _lod_reduction_distance_squared; } -void PropInstanceMerger2D::set_lod_reduction_distance_squared(const float dist) { +void PropInstanceMerger::set_lod_reduction_distance_squared(const float dist) { _lod_reduction_distance_squared = dist; } -Ref PropInstanceMerger2D::get_job() { +Ref PropInstanceMerger::get_job() { return _job; } -void PropInstanceMerger2D::set_job(const Ref &job) { +void PropInstanceMerger::set_job(const Ref &job) { _job = job; + + if (_job.is_valid() && is_inside_tree()) { + _job->prop_instance_enter_tree(); + } } //Materials -Ref PropInstanceMerger2D::material_get(const int index) { +Ref PropInstanceMerger::material_get(const int index) { ERR_FAIL_INDEX_V(index, _materials.size(), Ref(NULL)); return _materials[index]; } -void PropInstanceMerger2D::material_add(const Ref &value) { +void PropInstanceMerger::material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); _materials.push_back(value); } -int PropInstanceMerger2D::material_get_num() const { +int PropInstanceMerger::material_get_num() const { return _materials.size(); } -void PropInstanceMerger2D::materials_clear() { +void PropInstanceMerger::materials_clear() { _materials.clear(); } -Vector PropInstanceMerger2D::materials_get() { +Vector PropInstanceMerger::materials_get() { VARIANT_ARRAY_GET(_materials); } -void PropInstanceMerger2D::materials_set(const Vector &materials) { +void PropInstanceMerger::materials_set(const Vector &materials) { _materials.clear(); for (int i = 0; i < materials.size(); i++) { @@ -161,19 +165,19 @@ void PropInstanceMerger2D::materials_set(const Vector &materials) { } //Meshes -RID PropInstanceMerger2D::mesh_get(const int index) { +RID PropInstanceMerger::mesh_get(const int index) { ERR_FAIL_INDEX_V(index, _meshes.size(), RID()); return _meshes[index].mesh; } -RID PropInstanceMerger2D::mesh_instance_get(const int index) { +RID PropInstanceMerger::mesh_instance_get(const int index) { ERR_FAIL_INDEX_V(index, _meshes.size(), RID()); return _meshes[index].mesh_instance; } -void PropInstanceMerger2D::mesh_add(const RID mesh_instance, const RID mesh) { +void PropInstanceMerger::mesh_add(const RID mesh_instance, const RID mesh) { MeshEntry e; e.mesh = mesh; e.mesh_instance = mesh_instance; @@ -181,15 +185,15 @@ void PropInstanceMerger2D::mesh_add(const RID mesh_instance, const RID mesh) { _meshes.push_back(e); } -int PropInstanceMerger2D::mesh_get_num() const { +int PropInstanceMerger::mesh_get_num() const { return _meshes.size(); } -void PropInstanceMerger2D::meshes_clear() { +void PropInstanceMerger::meshes_clear() { _meshes.clear(); } -void PropInstanceMerger2D::meshes_create(const int num) { +void PropInstanceMerger::meshes_create(const int num) { free_meshes(); for (int i = 0; i < num; ++i) { @@ -216,7 +220,7 @@ void PropInstanceMerger2D::meshes_create(const int num) { apply_lod_level(); } -Vector PropInstanceMerger2D::meshes_get() { +Vector PropInstanceMerger::meshes_get() { Vector r; for (int i = 0; i < _meshes.size(); i++) { Array a; @@ -229,7 +233,7 @@ Vector PropInstanceMerger2D::meshes_get() { return r; } -void PropInstanceMerger2D::meshes_set(const Vector &meshs) { +void PropInstanceMerger::meshes_set(const Vector &meshs) { _meshes.clear(); for (int i = 0; i < _meshes.size(); i++) { @@ -247,31 +251,31 @@ void PropInstanceMerger2D::meshes_set(const Vector &meshs) { //Collider -Transform PropInstanceMerger2D::collider_local_transform_get(const int index) { +Transform PropInstanceMerger::collider_local_transform_get(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), Transform()); return _colliders[index].transform; } -RID PropInstanceMerger2D::collider_body_get(const int index) { +RID PropInstanceMerger::collider_body_get(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), RID()); return _colliders[index].body; } -Ref PropInstanceMerger2D::collider_shape_get(const int index) { +Ref PropInstanceMerger::collider_shape_get(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), Ref()); return _colliders[index].shape; } -RID PropInstanceMerger2D::collider_shape_rid_get(const int index) { +RID PropInstanceMerger::collider_shape_rid_get(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), RID()); return _colliders[index].shape_rid; } -int PropInstanceMerger2D::collider_add(const Transform &local_transform, const Ref &shape, const RID &shape_rid, const RID &body, const bool owns_shape) { +int PropInstanceMerger::collider_add(const Transform &local_transform, const Ref &shape, const RID &shape_rid, const RID &body, const bool owns_shape) { ERR_FAIL_COND_V(!shape.is_valid() && shape_rid == RID(), 0); int index = _colliders.size(); @@ -288,15 +292,15 @@ int PropInstanceMerger2D::collider_add(const Transform &local_transform, const R return index; } -int PropInstanceMerger2D::collider_get_num() const { +int PropInstanceMerger::collider_get_num() const { return _colliders.size(); } -void PropInstanceMerger2D::colliders_clear() { +void PropInstanceMerger::colliders_clear() { _colliders.clear(); } -Vector PropInstanceMerger2D::colliders_get() { +Vector PropInstanceMerger::colliders_get() { Vector r; for (int i = 0; i < _colliders.size(); i++) { r.push_back(_colliders[i].body); @@ -304,7 +308,7 @@ Vector PropInstanceMerger2D::colliders_get() { return r; } -void PropInstanceMerger2D::colliders_set(const Vector &colliders) { +void PropInstanceMerger::colliders_set(const Vector &colliders) { _colliders.clear(); for (int i = 0; i < colliders.size(); i++) { @@ -317,7 +321,7 @@ void PropInstanceMerger2D::colliders_set(const Vector &colliders) { } } -void PropInstanceMerger2D::check_auto_lod() { +void PropInstanceMerger::check_auto_lod() { if (!_auto_lod) { _auto_lod_on = false; return; @@ -337,7 +341,7 @@ void PropInstanceMerger2D::check_auto_lod() { set_process_internal(true); } -void PropInstanceMerger2D::apply_lod_level() { +void PropInstanceMerger::apply_lod_level() { if (_meshes.size() == 0) { return; } @@ -377,7 +381,7 @@ void PropInstanceMerger2D::apply_lod_level() { vs->instance_set_visible(mi, true); } -void PropInstanceMerger2D::debug_mesh_allocate() { +void PropInstanceMerger::debug_mesh_allocate() { if (_debug_mesh_rid == RID()) { _debug_mesh_rid = VisualServer::get_singleton()->mesh_create(); } @@ -393,7 +397,7 @@ void PropInstanceMerger2D::debug_mesh_allocate() { VS::get_singleton()->instance_set_visible(_debug_mesh_instance, true); } } -void PropInstanceMerger2D::debug_mesh_free() { +void PropInstanceMerger::debug_mesh_free() { if (_debug_mesh_instance != RID()) { VisualServer::get_singleton()->free(_debug_mesh_instance); } @@ -402,25 +406,25 @@ void PropInstanceMerger2D::debug_mesh_free() { VisualServer::get_singleton()->free(_debug_mesh_rid); } } -bool PropInstanceMerger2D::debug_mesh_has() { +bool PropInstanceMerger::debug_mesh_has() { return _debug_mesh_rid != RID(); } -void PropInstanceMerger2D::debug_mesh_clear() { +void PropInstanceMerger::debug_mesh_clear() { if (_debug_mesh_rid != RID()) { VisualServer::get_singleton()->mesh_clear(_debug_mesh_rid); } } -void PropInstanceMerger2D::debug_mesh_array_clear() { +void PropInstanceMerger::debug_mesh_array_clear() { _debug_mesh_array.resize(0); } -void PropInstanceMerger2D::debug_mesh_add_vertices_to(const PoolVector3Array &arr) { +void PropInstanceMerger::debug_mesh_add_vertices_to(const PoolVector3Array &arr) { _debug_mesh_array.append_array(arr); if (_debug_mesh_array.size() % 2 == 1) { _debug_mesh_array.append(_debug_mesh_array[_debug_mesh_array.size() - 1]); } } -void PropInstanceMerger2D::debug_mesh_send() { +void PropInstanceMerger::debug_mesh_send() { debug_mesh_allocate(); debug_mesh_clear(); @@ -442,7 +446,7 @@ void PropInstanceMerger2D::debug_mesh_send() { debug_mesh_array_clear(); } -void PropInstanceMerger2D::draw_debug_mdr_colliders() { +void PropInstanceMerger::draw_debug_mdr_colliders() { if (!debug_mesh_has()) { debug_mesh_allocate(); } @@ -462,7 +466,7 @@ void PropInstanceMerger2D::draw_debug_mdr_colliders() { debug_mesh_send(); } -void PropInstanceMerger2D::free_meshes() { +void PropInstanceMerger::free_meshes() { RID rid; for (int i = 0; i < _meshes.size(); ++i) { @@ -481,7 +485,7 @@ void PropInstanceMerger2D::free_meshes() { } } -void PropInstanceMerger2D::free_colliders() { +void PropInstanceMerger::free_colliders() { for (int i = 0; i < _colliders.size(); ++i) { ColliderBody &e = _colliders.write[i]; @@ -496,10 +500,10 @@ void PropInstanceMerger2D::free_colliders() { } } -void PropInstanceMerger2D::_init_materials() { +void PropInstanceMerger::_init_materials() { } -void PropInstanceMerger2D::_build() { +void PropInstanceMerger::_build() { if (_building) { return; } @@ -540,8 +544,9 @@ void PropInstanceMerger2D::_build() { _job->reset(); _job->set_complete(false); + _job->set_cancelled(false); - Ref cache = PropCache2D::get_singleton()->material_cache_get(_prop_data); + Ref cache = PropCache::get_singleton()->material_cache_get(_prop_data); if (cache->material_get_num() == 0) { //lock it! @@ -574,7 +579,7 @@ Don't submit here, as it starts in physics process mode */ } -void PropInstanceMerger2D::_build_finished() { +void PropInstanceMerger::_build_finished() { set_building(false); apply_lod_level(); @@ -587,22 +592,22 @@ void PropInstanceMerger2D::_build_finished() { } } -void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref &prop) { +void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref &prop) { ERR_FAIL_COND(!prop.is_valid()); int count = prop->get_prop_count(); for (int i = 0; i < count; ++i) { - Ref e = prop->get_prop(i); + Ref e = prop->get_prop(i); if (!e.is_valid()) continue; Transform t = transform * e->get_transform(); - Ref prop_entry_data = e; + Ref prop_entry_data = e; if (prop_entry_data.is_valid()) { - Ref p = prop_entry_data->get_prop(); + Ref p = prop_entry_data->get_prop(); if (!p.is_valid()) continue; @@ -612,7 +617,7 @@ void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref tiled_wall_data = e; + Ref tiled_wall_data = e; if (tiled_wall_data.is_valid()) { _job->add_tiled_wall(tiled_wall_data, t); @@ -636,7 +641,7 @@ void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref scene_data = e; + Ref scene_data = e; if (scene_data.is_valid()) { Ref sc = scene_data->get_scene(); @@ -658,11 +663,11 @@ void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref light_data = e; + //PropDataLight could use standard godot light nodes + Ref light_data = e; if (light_data.is_valid()) { - Ref light; + Ref light; light.instance(); Vector3 v = t.xform(Vector3()); @@ -677,7 +682,7 @@ void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref mesh_data = e; + Ref mesh_data = e; if (mesh_data.is_valid()) { Ref mdr = mesh_data->get_mesh(); @@ -695,7 +700,7 @@ void PropInstanceMerger2D::_prop_preprocess(Transform transform, const Ref(memnew(PropInstancePropJob())); + _job->set_prop_instace(this); + + Ref js; + + js.instance(); + js->set_job_type(PropMesherJobStep::TYPE_NORMAL); + _job->add_jobs_step(js); + + js.instance(); + js->set_job_type(PropMesherJobStep::TYPE_MERGE_VERTS); + _job->add_jobs_step(js); + + js.instance(); + js->set_job_type(PropMesherJobStep::TYPE_BAKE_TEXTURE); + _job->add_jobs_step(js); +} + +PropInstanceMerger::PropInstanceMerger() { _build_queued = false; _auto_lod = true; _auto_lod_on = false; @@ -729,39 +753,32 @@ PropInstanceMerger2D::PropInstanceMerger2D() { _first_lod_distance_squared = 1000; _lod_reduction_distance_squared = 600; - - //todo this should probably be in a virtual method, like in Terraman or Voxelman - _job = Ref(memnew(PropInstancePropJob2D())); - _job->set_prop_instace(this); - - Ref js; - - js.instance(); - js->set_job_type(PropMesherJobStep2D::TYPE_NORMAL); - _job->add_jobs_step(js); - - js.instance(); - js->set_job_type(PropMesherJobStep2D::TYPE_MERGE_VERTS); - _job->add_jobs_step(js); - - js.instance(); - js->set_job_type(PropMesherJobStep2D::TYPE_BAKE_TEXTURE); - _job->add_jobs_step(js); } -PropInstanceMerger2D::~PropInstanceMerger2D() { +PropInstanceMerger::~PropInstanceMerger() { _job.unref(); _prop_data.unref(); _materials.clear(); + + free_meshes(); + free_colliders(); + meshes_clear(); + colliders_clear(); } -void PropInstanceMerger2D::_notification(int p_what) { +void PropInstanceMerger::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_POSTINITIALIZE: { + call("_create_job"); + } break; case NOTIFICATION_ENTER_TREE: { - if (_prop_data.is_valid()) { + if (_job.is_valid()) { _job->prop_instance_enter_tree(); + } + + if (_prop_data.is_valid()) { call_deferred("build"); } @@ -773,8 +790,13 @@ void PropInstanceMerger2D::_notification(int p_what) { _job->set_cancelled(true); } - free_meshes(); - free_colliders(); + if (!_building) { + free_meshes(); + free_colliders(); + meshes_clear(); + colliders_clear(); + } + break; } case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { @@ -783,10 +805,10 @@ void PropInstanceMerger2D::_notification(int p_what) { return; } - if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_PHYSICS_PROCESS) { + if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_PHYSICS_PROCESS) { _job->physics_process(get_physics_process_delta_time()); - if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_NORMAL) { + if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_NORMAL) { #if THREAD_POOL_PRESENT ThreadPool::get_singleton()->add_job(_job); #else @@ -804,10 +826,10 @@ void PropInstanceMerger2D::_notification(int p_what) { return; } - if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_PROCESS) { + if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_PROCESS) { _job->process(get_process_delta_time()); - if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_NORMAL) { + if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_NORMAL) { #if THREAD_POOL_PRESENT ThreadPool::get_singleton()->add_job(_job); #else @@ -909,72 +931,75 @@ void PropInstanceMerger2D::_notification(int p_what) { } } -void PropInstanceMerger2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_job"), &PropInstanceMerger2D::get_job); - ClassDB::bind_method(D_METHOD("set_job", "value"), &PropInstanceMerger2D::set_job); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "job", PROPERTY_HINT_RESOURCE_TYPE, "PropInstanceJob2D", 0), "set_job", "get_job"); +void PropInstanceMerger::_bind_methods() { + BIND_VMETHOD(MethodInfo("_create_job")); + ClassDB::bind_method(D_METHOD("_create_job"), &PropInstanceMerger::_create_job); - ClassDB::bind_method(D_METHOD("get_lod_level"), &PropInstanceMerger2D::get_lod_level); - ClassDB::bind_method(D_METHOD("set_lod_level", "value"), &PropInstanceMerger2D::set_lod_level); + ClassDB::bind_method(D_METHOD("get_job"), &PropInstanceMerger::get_job); + ClassDB::bind_method(D_METHOD("set_job", "value"), &PropInstanceMerger::set_job); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "job", PROPERTY_HINT_RESOURCE_TYPE, "PropInstanceJob", 0), "set_job", "get_job"); + + ClassDB::bind_method(D_METHOD("get_lod_level"), &PropInstanceMerger::get_lod_level); + ClassDB::bind_method(D_METHOD("set_lod_level", "value"), &PropInstanceMerger::set_lod_level); ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_level"), "set_lod_level", "get_lod_level"); - ClassDB::bind_method(D_METHOD("get_auto_lod"), &PropInstanceMerger2D::get_auto_lod); - ClassDB::bind_method(D_METHOD("set_auto_lod", "value"), &PropInstanceMerger2D::set_auto_lod); + ClassDB::bind_method(D_METHOD("get_auto_lod"), &PropInstanceMerger::get_auto_lod); + ClassDB::bind_method(D_METHOD("set_auto_lod", "value"), &PropInstanceMerger::set_auto_lod); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_lod"), "set_auto_lod", "get_auto_lod"); - ClassDB::bind_method(D_METHOD("get_first_lod_distance_squared"), &PropInstanceMerger2D::get_first_lod_distance_squared); - ClassDB::bind_method(D_METHOD("set_first_lod_distance_squared", "value"), &PropInstanceMerger2D::set_first_lod_distance_squared); + ClassDB::bind_method(D_METHOD("get_first_lod_distance_squared"), &PropInstanceMerger::get_first_lod_distance_squared); + ClassDB::bind_method(D_METHOD("set_first_lod_distance_squared", "value"), &PropInstanceMerger::set_first_lod_distance_squared); ADD_PROPERTY(PropertyInfo(Variant::REAL, "first_lod_distance_squared"), "set_first_lod_distance_squared", "get_first_lod_distance_squared"); - ClassDB::bind_method(D_METHOD("get_lod_reduction_distance_squared"), &PropInstanceMerger2D::get_lod_reduction_distance_squared); - ClassDB::bind_method(D_METHOD("set_lod_reduction_distance_squared", "value"), &PropInstanceMerger2D::set_lod_reduction_distance_squared); + ClassDB::bind_method(D_METHOD("get_lod_reduction_distance_squared"), &PropInstanceMerger::get_lod_reduction_distance_squared); + ClassDB::bind_method(D_METHOD("set_lod_reduction_distance_squared", "value"), &PropInstanceMerger::set_lod_reduction_distance_squared); ADD_PROPERTY(PropertyInfo(Variant::REAL, "lod_reduction_distance_squared"), "set_lod_reduction_distance_squared", "get_lod_reduction_distance_squared"); ///Materials - ClassDB::bind_method(D_METHOD("material_get", "index"), &PropInstanceMerger2D::material_get); - ClassDB::bind_method(D_METHOD("material_add", "value"), &PropInstanceMerger2D::material_add); - ClassDB::bind_method(D_METHOD("material_get_num"), &PropInstanceMerger2D::material_get_num); - ClassDB::bind_method(D_METHOD("materials_clear"), &PropInstanceMerger2D::materials_clear); + ClassDB::bind_method(D_METHOD("material_get", "index"), &PropInstanceMerger::material_get); + ClassDB::bind_method(D_METHOD("material_add", "value"), &PropInstanceMerger::material_add); + ClassDB::bind_method(D_METHOD("material_get_num"), &PropInstanceMerger::material_get_num); + ClassDB::bind_method(D_METHOD("materials_clear"), &PropInstanceMerger::materials_clear); - ClassDB::bind_method(D_METHOD("materials_get"), &PropInstanceMerger2D::materials_get); - ClassDB::bind_method(D_METHOD("materials_set"), &PropInstanceMerger2D::materials_set); + ClassDB::bind_method(D_METHOD("materials_get"), &PropInstanceMerger::materials_get); + ClassDB::bind_method(D_METHOD("materials_set"), &PropInstanceMerger::materials_set); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get"); //Meshes - ClassDB::bind_method(D_METHOD("mesh_get", "index"), &PropInstanceMerger2D::mesh_get); - ClassDB::bind_method(D_METHOD("mesh_instance_get", "index"), &PropInstanceMerger2D::mesh_instance_get); - ClassDB::bind_method(D_METHOD("mesh_add", "mesh_instance", "mesh"), &PropInstanceMerger2D::mesh_add); - ClassDB::bind_method(D_METHOD("mesh_get_num"), &PropInstanceMerger2D::mesh_get_num); - ClassDB::bind_method(D_METHOD("meshes_clear"), &PropInstanceMerger2D::meshes_clear); + ClassDB::bind_method(D_METHOD("mesh_get", "index"), &PropInstanceMerger::mesh_get); + ClassDB::bind_method(D_METHOD("mesh_instance_get", "index"), &PropInstanceMerger::mesh_instance_get); + ClassDB::bind_method(D_METHOD("mesh_add", "mesh_instance", "mesh"), &PropInstanceMerger::mesh_add); + ClassDB::bind_method(D_METHOD("mesh_get_num"), &PropInstanceMerger::mesh_get_num); + ClassDB::bind_method(D_METHOD("meshes_clear"), &PropInstanceMerger::meshes_clear); - ClassDB::bind_method(D_METHOD("meshes_get"), &PropInstanceMerger2D::meshes_get); - ClassDB::bind_method(D_METHOD("meshes_set"), &PropInstanceMerger2D::meshes_set); + ClassDB::bind_method(D_METHOD("meshes_get"), &PropInstanceMerger::meshes_get); + ClassDB::bind_method(D_METHOD("meshes_set"), &PropInstanceMerger::meshes_set); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "meshes", PROPERTY_HINT_NONE, "", 0), "meshes_set", "meshes_get"); //Colliders - ClassDB::bind_method(D_METHOD("collider_local_transform_get", "index"), &PropInstanceMerger2D::collider_local_transform_get); - ClassDB::bind_method(D_METHOD("collider_body_get", "index"), &PropInstanceMerger2D::collider_body_get); - ClassDB::bind_method(D_METHOD("collider_shape_get", "index"), &PropInstanceMerger2D::collider_shape_get); - ClassDB::bind_method(D_METHOD("collider_shape_rid_get", "index"), &PropInstanceMerger2D::collider_shape_rid_get); - ClassDB::bind_method(D_METHOD("collider_add", "local_transform", "shape", "shape_rid", "body"), &PropInstanceMerger2D::collider_add); - ClassDB::bind_method(D_METHOD("collider_get_num"), &PropInstanceMerger2D::collider_get_num); - ClassDB::bind_method(D_METHOD("colliders_clear"), &PropInstanceMerger2D::colliders_clear); - ClassDB::bind_method(D_METHOD("meshes_create", "num"), &PropInstanceMerger2D::meshes_create); + ClassDB::bind_method(D_METHOD("collider_local_transform_get", "index"), &PropInstanceMerger::collider_local_transform_get); + ClassDB::bind_method(D_METHOD("collider_body_get", "index"), &PropInstanceMerger::collider_body_get); + ClassDB::bind_method(D_METHOD("collider_shape_get", "index"), &PropInstanceMerger::collider_shape_get); + ClassDB::bind_method(D_METHOD("collider_shape_rid_get", "index"), &PropInstanceMerger::collider_shape_rid_get); + ClassDB::bind_method(D_METHOD("collider_add", "local_transform", "shape", "shape_rid", "body"), &PropInstanceMerger::collider_add); + ClassDB::bind_method(D_METHOD("collider_get_num"), &PropInstanceMerger::collider_get_num); + ClassDB::bind_method(D_METHOD("colliders_clear"), &PropInstanceMerger::colliders_clear); + ClassDB::bind_method(D_METHOD("meshes_create", "num"), &PropInstanceMerger::meshes_create); //Colliders - ClassDB::bind_method(D_METHOD("debug_mesh_allocate"), &PropInstanceMerger2D::debug_mesh_allocate); - ClassDB::bind_method(D_METHOD("debug_mesh_free"), &PropInstanceMerger2D::debug_mesh_free); - ClassDB::bind_method(D_METHOD("debug_mesh_has"), &PropInstanceMerger2D::debug_mesh_has); - ClassDB::bind_method(D_METHOD("debug_mesh_clear"), &PropInstanceMerger2D::debug_mesh_clear); - ClassDB::bind_method(D_METHOD("debug_mesh_array_clear"), &PropInstanceMerger2D::debug_mesh_array_clear); - ClassDB::bind_method(D_METHOD("debug_mesh_add_vertices_to", "arr"), &PropInstanceMerger2D::debug_mesh_add_vertices_to); - ClassDB::bind_method(D_METHOD("debug_mesh_send"), &PropInstanceMerger2D::debug_mesh_send); - ClassDB::bind_method(D_METHOD("draw_debug_mdr_colliders"), &PropInstanceMerger2D::draw_debug_mdr_colliders); + ClassDB::bind_method(D_METHOD("debug_mesh_allocate"), &PropInstanceMerger::debug_mesh_allocate); + ClassDB::bind_method(D_METHOD("debug_mesh_free"), &PropInstanceMerger::debug_mesh_free); + ClassDB::bind_method(D_METHOD("debug_mesh_has"), &PropInstanceMerger::debug_mesh_has); + ClassDB::bind_method(D_METHOD("debug_mesh_clear"), &PropInstanceMerger::debug_mesh_clear); + ClassDB::bind_method(D_METHOD("debug_mesh_array_clear"), &PropInstanceMerger::debug_mesh_array_clear); + ClassDB::bind_method(D_METHOD("debug_mesh_add_vertices_to", "arr"), &PropInstanceMerger::debug_mesh_add_vertices_to); + ClassDB::bind_method(D_METHOD("debug_mesh_send"), &PropInstanceMerger::debug_mesh_send); + ClassDB::bind_method(D_METHOD("draw_debug_mdr_colliders"), &PropInstanceMerger::draw_debug_mdr_colliders); - ClassDB::bind_method(D_METHOD("check_auto_lod"), &PropInstanceMerger2D::check_auto_lod); - ClassDB::bind_method(D_METHOD("apply_lod_level"), &PropInstanceMerger2D::apply_lod_level); + ClassDB::bind_method(D_METHOD("check_auto_lod"), &PropInstanceMerger::check_auto_lod); + ClassDB::bind_method(D_METHOD("apply_lod_level"), &PropInstanceMerger::apply_lod_level); //--- - ClassDB::bind_method(D_METHOD("free_meshes"), &PropInstanceMerger2D::free_meshes); - ClassDB::bind_method(D_METHOD("free_colliders"), &PropInstanceMerger2D::free_colliders); + ClassDB::bind_method(D_METHOD("free_meshes"), &PropInstanceMerger::free_meshes); + ClassDB::bind_method(D_METHOD("free_colliders"), &PropInstanceMerger::free_colliders); } diff --git a/prop_instance_merger_2d.h b/prop_instance_merger.h similarity index 88% rename from prop_instance_merger_2d.h rename to prop_instance_merger.h index 9c3009c..9cc8289 100644 --- a/prop_instance_merger_2d.h +++ b/prop_instance_merger.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2020 Péter Magyar +Copyright (c) 2020-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_INSTANCE_MERGER_2D_H -#define PROP_INSTANCE_MERGER_2D_H +#ifndef PROP_INSTANCE_MERGER_H +#define PROP_INSTANCE_MERGER_H -#include "prop_instance_2d.h" +#include "prop_instance.h" #include "core/version.h" @@ -37,14 +37,14 @@ SOFTWARE. #include "core/math/vector3.h" -#include "prop_instance_prop_job_2d.h" +#include "prop_instance_prop_job.h" -#include "props/prop_data_2d.h" +#include "props/prop_data.h" class MeshDataInstance; -class PropInstanceMerger2D : public PropInstance2D { - GDCLASS(PropInstanceMerger2D, PropInstance2D); +class PropInstanceMerger : public PropInstance { + GDCLASS(PropInstanceMerger, PropInstance); public: static const float LOD_CHECK_INTERVAL; @@ -64,8 +64,8 @@ public: float get_lod_reduction_distance_squared(); void set_lod_reduction_distance_squared(const float dist); - Ref get_job(); - void set_job(const Ref &job); + Ref get_job(); + void set_job(const Ref &job); ///Materials Ref material_get(const int index); @@ -120,13 +120,15 @@ public: virtual void _build(); virtual void _build_finished(); - void _prop_preprocess(Transform tarnsform, const Ref &prop); + void _prop_preprocess(Transform tarnsform, const Ref &prop); void collision_layer_changed(); void collision_mask_changed(); - PropInstanceMerger2D(); - ~PropInstanceMerger2D(); + virtual void _create_job(); + + PropInstanceMerger(); + ~PropInstanceMerger(); protected: void _notification(int p_what); @@ -158,7 +160,7 @@ private: Transform _last_transform; - Ref _job; + Ref _job; Vector> _materials; Vector _meshes; diff --git a/prop_instance_prop_job_2d.cpp b/prop_instance_prop_job.cpp similarity index 75% rename from prop_instance_prop_job_2d.cpp rename to prop_instance_prop_job.cpp index 17010fd..0adacab 100644 --- a/prop_instance_prop_job_2d.cpp +++ b/prop_instance_prop_job.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_instance_prop_job_2d.h" +#include "prop_instance_prop_job.h" #include "core/version.h" @@ -30,14 +30,14 @@ SOFTWARE. #define GET_WORLD get_world #endif -#include "jobs/prop_mesher_job_step_2d.h" -#include "lights/prop_light_2d.h" -#include "material_cache/prop_material_cache_2d.h" -#include "prop_instance_2d.h" -#include "prop_instance_merger_2d.h" -#include "prop_mesher_2d.h" +#include "jobs/prop_mesher_job_step.h" +#include "lights/prop_light.h" +#include "material_cache/prop_material_cache.h" +#include "prop_instance.h" +#include "prop_instance_merger.h" +#include "prop_mesher.h" #include "scene/resources/shape.h" -#include "singleton/prop_cache_2d.h" +#include "singleton/prop_cache.h" #ifdef MESH_DATA_RESOURCE_PRESENT #include "../mesh_data_resource/mesh_data_resource.h" @@ -54,44 +54,43 @@ SOFTWARE. #if MESH_DATA_RESOURCE_PRESENT //define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling, //but not when included from here. -#define PROPS_PRESENT 1 -#include "../mesh_data_resource/props/prop_data_mesh_data.h" -#undef PROPS_PRESENT +#define PROPS_2D_PRESENT 1 +#include "../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h" #endif -#include "props/prop_data_tiled_wall_2d.h" -#include "tiled_wall/tiled_wall_data_2d.h" +#include "props/prop_data_tiled_wall.h" +#include "tiled_wall/tiled_wall_data.h" -Ref PropInstancePropJob2D::get_material_cache() { +Ref PropInstancePropJob::get_material_cache() { return _material_cache; } -void PropInstancePropJob2D::set_material_cache(const Ref &cache) { +void PropInstancePropJob::set_material_cache(const Ref &cache) { _material_cache = cache; } -Ref PropInstancePropJob2D::get_jobs_step(int index) const { - ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref()); +Ref PropInstancePropJob::get_jobs_step(int index) const { + ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref()); return _job_steps.get(index); } -void PropInstancePropJob2D::set_jobs_step(int index, const Ref &step) { +void PropInstancePropJob::set_jobs_step(int index, const Ref &step) { ERR_FAIL_INDEX(index, _job_steps.size()); _job_steps.set(index, step); } -void PropInstancePropJob2D::remove_jobs_step(const int index) { +void PropInstancePropJob::remove_jobs_step(const int index) { ERR_FAIL_INDEX(index, _job_steps.size()); _job_steps.remove(index); } -void PropInstancePropJob2D::add_jobs_step(const Ref &step) { +void PropInstancePropJob::add_jobs_step(const Ref &step) { _job_steps.push_back(step); } -int PropInstancePropJob2D::get_jobs_step_count() const { +int PropInstancePropJob::get_jobs_step_count() const { return _job_steps.size(); } -void PropInstancePropJob2D::add_collision_shape(const Ref &shape, const Transform &transform, const bool owns_shape) { +void PropInstancePropJob::add_collision_shape(const Ref &shape, const Transform &transform, const bool owns_shape) { CollisionShapeEntry e; e.shape = shape; @@ -100,30 +99,30 @@ void PropInstancePropJob2D::add_collision_shape(const Ref &shape, const T _collision_shapes.push_back(e); } -void PropInstancePropJob2D::clear_collision_shapes() { +void PropInstancePropJob::clear_collision_shapes() { _collision_shapes.clear(); } -PropInstanceMerger2D *PropInstancePropJob2D::get_prop_instace() { +PropInstanceMerger *PropInstancePropJob::get_prop_instace() { return _prop_instace; } -void PropInstancePropJob2D::set_prop_instace(PropInstanceMerger2D *prop) { +void PropInstancePropJob::set_prop_instace(PropInstanceMerger *prop) { _prop_instace = prop; _instance = prop; } -void PropInstancePropJob2D::set_prop_instace_bind(Node *prop) { - set_prop_instace(Object::cast_to(prop)); +void PropInstancePropJob::set_prop_instace_bind(Node *prop) { + set_prop_instace(Object::cast_to(prop)); } -Ref PropInstancePropJob2D::get_prop_mesher() const { +Ref PropInstancePropJob::get_prop_mesher() const { return _prop_mesher; } -void PropInstancePropJob2D::set_prop_mesher(const Ref &mesher) { +void PropInstancePropJob::set_prop_mesher(const Ref &mesher) { _prop_mesher = mesher; } #if MESH_DATA_RESOURCE_PRESENT -void PropInstancePropJob2D::add_mesh(const Ref &mesh_data, const Transform &base_transform) { +void PropInstancePropJob::add_mesh(const Ref &mesh_data, const Transform &base_transform) { PMDREntry e; e.mesh_data = mesh_data; e.base_transform = base_transform; @@ -131,12 +130,12 @@ void PropInstancePropJob2D::add_mesh(const Ref &mesh_data, c _prop_mesh_datas.push_back(e); } -void PropInstancePropJob2D::clear_meshes() { +void PropInstancePropJob::clear_meshes() { _prop_mesh_datas.clear(); } #endif -void PropInstancePropJob2D::add_tiled_wall(const Ref &data, const Transform &base_transform) { +void PropInstancePropJob::add_tiled_wall(const Ref &data, const Transform &base_transform) { PTWEntry e; e.data = data; e.base_transform = base_transform; @@ -144,25 +143,25 @@ void PropInstancePropJob2D::add_tiled_wall(const Ref &data, _prop_tiled_wall_datas.push_back(e); } -void PropInstancePropJob2D::clear_tiled_walls() { +void PropInstancePropJob::clear_tiled_walls() { _prop_tiled_wall_datas.clear(); } -void PropInstancePropJob2D::add_light(const Ref &light) { +void PropInstancePropJob::add_light(const Ref &light) { _prop_mesher->add_light(light); } -void PropInstancePropJob2D::clear_lights() { +void PropInstancePropJob::clear_lights() { _prop_mesher->clear_lights(); } -void PropInstancePropJob2D::_physics_process(float delta) { +void PropInstancePropJob::_physics_process(float delta) { if (_phase == 0) phase_physics_process(); } -void PropInstancePropJob2D::_execute_phase() { +void PropInstancePropJob::_execute_phase() { if (!_material_cache.is_valid()) { - ERR_PRINT("!PropInstancePropJob2D::_execute_phase(): !_material_cache.is_valid()"); + ERR_PRINT("!PropInstancePropJob::_execute_phase(): !_material_cache.is_valid()"); //reset_meshes(); set_complete(true); //So threadpool knows it's done finished(); @@ -186,12 +185,12 @@ void PropInstancePropJob2D::_execute_phase() { } else if (_phase > 3) { set_complete(true); //So threadpool knows it's done finished(); - ERR_FAIL_MSG("PropInstancePropJob2D: _phase is too high!"); + ERR_FAIL_MSG("PropInstancePropJob: _phase is too high!"); } } -void PropInstancePropJob2D::_reset() { - PropInstanceJob2D::_reset(); +void PropInstancePropJob::_reset() { + PropInstanceJob::_reset(); _build_done = false; _phase = 0; @@ -207,16 +206,13 @@ void PropInstancePropJob2D::_reset() { _prop_tiled_wall_datas.clear(); -#if MESH_DATA_RESOURCE_PRESENT _prop_mesh_datas.clear(); -#endif - clear_collision_shapes(); set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS); } -void PropInstancePropJob2D::phase_physics_process() { +void PropInstancePropJob::phase_physics_process() { //TODO this should only update the differences //for (int i = 0; i < _prop_instace->collider_get_num(); ++i) { // PhysicsServer::get_singleton()->free(_prop_instace->collider_body_get(i)); @@ -263,7 +259,7 @@ void PropInstancePropJob2D::phase_physics_process() { next_phase(); } -void PropInstancePropJob2D::phase_setup_cache() { +void PropInstancePropJob::phase_setup_cache() { if (should_do()) { if (!_material_cache->get_initialized()) { _material_cache->mutex_lock(); @@ -292,19 +288,14 @@ void PropInstancePropJob2D::phase_setup_cache() { next_phase(); } -void PropInstancePropJob2D::phase_prop() { +void PropInstancePropJob::phase_prop() { if (!_prop_mesher.is_valid()) { set_complete(true); //So threadpool knows it's done return; } if (should_do()) { - - if ( - #if MESH_DATA_RESOURCE_PRESENT - _prop_mesh_datas.size() == 0 && - #endif - _prop_tiled_wall_datas.size() == 0) { + if (_prop_mesh_datas.size() == 0 && _prop_tiled_wall_datas.size() == 0) { //reset_meshes(); reset_stages(); set_complete(true); //So threadpool knows it's done @@ -315,7 +306,7 @@ void PropInstancePropJob2D::phase_prop() { for (int i = 0; i < _prop_mesh_datas.size(); ++i) { PMDREntry &e = _prop_mesh_datas.write[i]; - Ref pmd = e.mesh_data; + Ref pmd = e.mesh_data; Ref mesh = pmd->get_mesh(); Ref tex = pmd->get_texture(); @@ -330,7 +321,7 @@ void PropInstancePropJob2D::phase_prop() { for (int i = 0; i < _prop_tiled_wall_datas.size(); ++i) { PTWEntry &e = _prop_tiled_wall_datas.write[i]; - Ref pdtw = e.data; + Ref pdtw = e.data; //Transform t = pdtw->get_transform(); Transform t = e.base_transform; @@ -352,7 +343,7 @@ void PropInstancePropJob2D::phase_prop() { } if (should_do()) { - if ((_prop_mesher->get_build_flags() & PropMesher2D::BUILD_FLAG_USE_LIGHTING) != 0) { + if ((_prop_mesher->get_build_flags() & PropMesher::BUILD_FLAG_USE_LIGHTING) != 0) { _prop_mesher->bake_colors(); } @@ -365,7 +356,7 @@ void PropInstancePropJob2D::phase_prop() { next_phase(); } -void PropInstancePropJob2D::phase_steps() { +void PropInstancePropJob::phase_steps() { ERR_FAIL_COND(!_prop_mesher.is_valid()); if (should_return()) { @@ -388,27 +379,27 @@ void PropInstancePropJob2D::phase_steps() { //first count how many we need int count = 0; for (int i = 0; i < _job_steps.size(); ++i) { - Ref step = _job_steps[i]; + Ref step = _job_steps[i]; ERR_FAIL_COND(!step.is_valid()); switch (step->get_job_type()) { - case PropMesherJobStep2D::TYPE_NORMAL: + case PropMesherJobStep::TYPE_NORMAL: ++count; break; - case PropMesherJobStep2D::TYPE_NORMAL_LOD: + case PropMesherJobStep::TYPE_NORMAL_LOD: ++count; break; - case PropMesherJobStep2D::TYPE_DROP_UV2: + case PropMesherJobStep::TYPE_DROP_UV2: ++count; break; - case PropMesherJobStep2D::TYPE_MERGE_VERTS: + case PropMesherJobStep::TYPE_MERGE_VERTS: ++count; break; - case PropMesherJobStep2D::TYPE_BAKE_TEXTURE: + case PropMesherJobStep::TYPE_BAKE_TEXTURE: ++count; break; - case PropMesherJobStep2D::TYPE_SIMPLIFY_MESH: + case PropMesherJobStep::TYPE_SIMPLIFY_MESH: #ifdef MESH_UTILS_PRESENT count += step->get_simplification_steps(); #endif @@ -441,30 +432,30 @@ void PropInstancePropJob2D::phase_steps() { } for (; _current_job_step < _job_steps.size();) { - Ref step = _job_steps[_current_job_step]; + Ref step = _job_steps[_current_job_step]; ERR_FAIL_COND(!step.is_valid()); switch (step->get_job_type()) { - case PropMesherJobStep2D::TYPE_NORMAL: + case PropMesherJobStep::TYPE_NORMAL: step_type_normal(); break; - case PropMesherJobStep2D::TYPE_NORMAL_LOD: + case PropMesherJobStep::TYPE_NORMAL_LOD: step_type_normal_lod(); break; - case PropMesherJobStep2D::TYPE_DROP_UV2: + case PropMesherJobStep::TYPE_DROP_UV2: step_type_drop_uv2(); break; - case PropMesherJobStep2D::TYPE_MERGE_VERTS: + case PropMesherJobStep::TYPE_MERGE_VERTS: step_type_merge_verts(); break; - case PropMesherJobStep2D::TYPE_BAKE_TEXTURE: + case PropMesherJobStep::TYPE_BAKE_TEXTURE: step_type_bake_texture(); break; - case PropMesherJobStep2D::TYPE_SIMPLIFY_MESH: + case PropMesherJobStep::TYPE_SIMPLIFY_MESH: step_type_simplify_mesh(); break; - case PropMesherJobStep2D::TYPE_OTHER: + case PropMesherJobStep::TYPE_OTHER: //do nothing break; } @@ -482,7 +473,7 @@ void PropInstancePropJob2D::phase_steps() { finished(); } -void PropInstancePropJob2D::step_type_normal() { +void PropInstancePropJob::step_type_normal() { //TODO add a lighting generation step temp_mesh_arr = _prop_mesher->build_mesh(); @@ -500,13 +491,13 @@ void PropInstancePropJob2D::step_type_normal() { ++_current_mesh; } -void PropInstancePropJob2D::step_type_normal_lod() { +void PropInstancePropJob::step_type_normal_lod() { print_error("Error: step_type_normal_lod doesn't work for TerraPropJobs!"); ++_current_mesh; } -void PropInstancePropJob2D::step_type_drop_uv2() { +void PropInstancePropJob::step_type_drop_uv2() { RID mesh_rid = _prop_instace->mesh_get(_current_mesh); temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant(); @@ -522,7 +513,7 @@ void PropInstancePropJob2D::step_type_drop_uv2() { ++_current_mesh; } -void PropInstancePropJob2D::step_type_merge_verts() { +void PropInstancePropJob::step_type_merge_verts() { Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr); temp_mesh_arr = temp_mesh_arr2; @@ -539,7 +530,7 @@ void PropInstancePropJob2D::step_type_merge_verts() { ++_current_mesh; } -void PropInstancePropJob2D::step_type_bake_texture() { +void PropInstancePropJob::step_type_bake_texture() { Ref mat = _material_cache->material_lod_get(0); Ref spmat = _material_cache->material_lod_get(0); Ref tex; @@ -568,10 +559,10 @@ void PropInstancePropJob2D::step_type_bake_texture() { ++_current_mesh; } -void PropInstancePropJob2D::step_type_simplify_mesh() { +void PropInstancePropJob::step_type_simplify_mesh() { #ifdef MESH_UTILS_PRESENT - Ref step = _job_steps[_current_job_step]; + Ref step = _job_steps[_current_job_step]; ERR_FAIL_COND(!step.is_valid()); Ref fqms = step->get_fqms(); ERR_FAIL_COND(!fqms.is_valid()); @@ -598,7 +589,7 @@ void PropInstancePropJob2D::step_type_simplify_mesh() { #endif } -Array PropInstancePropJob2D::merge_mesh_array(Array arr) const { +Array PropInstancePropJob::merge_mesh_array(Array arr) const { ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr); PoolVector3Array verts = arr[VisualServer::ARRAY_VERTEX]; @@ -662,7 +653,7 @@ Array PropInstancePropJob2D::merge_mesh_array(Array arr) const { return arr; } -Array PropInstancePropJob2D::bake_mesh_array_uv(Array arr, Ref tex, const float mul_color) const { +Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref tex, const float mul_color) const { ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr); ERR_FAIL_COND_V(!tex.is_valid(), arr); @@ -703,7 +694,7 @@ Array PropInstancePropJob2D::bake_mesh_array_uv(Array arr, Ref tex, con return arr; } -void PropInstancePropJob2D::reset_meshes() { +void PropInstancePropJob::reset_meshes() { if (!_prop_instace) { return; } @@ -725,7 +716,7 @@ void PropInstancePropJob2D::reset_meshes() { } } -PropInstancePropJob2D::PropInstancePropJob2D() { +PropInstancePropJob::PropInstancePropJob() { set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS); _prop_instace = NULL; @@ -734,29 +725,29 @@ PropInstancePropJob2D::PropInstancePropJob2D() { //todo allocate this in a virtual method _prop_mesher.instance(); - _prop_mesher->set_build_flags(PropMesher2D::BUILD_FLAG_USE_LIGHTING | PropMesher2D::BUILD_FLAG_USE_AO | PropMesher2D::BUILD_FLAG_USE_RAO | PropMesher2D::BUILD_FLAG_BAKE_LIGHTS); + _prop_mesher->set_build_flags(PropMesher::BUILD_FLAG_USE_LIGHTING | PropMesher::BUILD_FLAG_USE_AO | PropMesher::BUILD_FLAG_USE_RAO | PropMesher::BUILD_FLAG_BAKE_LIGHTS); } -PropInstancePropJob2D::~PropInstancePropJob2D() { +PropInstancePropJob::~PropInstancePropJob() { } -void PropInstancePropJob2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_material_cache"), &PropInstancePropJob2D::get_material_cache); - ClassDB::bind_method(D_METHOD("set_material_cache", "packer"), &PropInstancePropJob2D::set_material_cache); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache2D", 0), "set_material_cache", "get_material_cache"); +void PropInstancePropJob::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_material_cache"), &PropInstancePropJob::get_material_cache); + ClassDB::bind_method(D_METHOD("set_material_cache", "packer"), &PropInstancePropJob::set_material_cache); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache", 0), "set_material_cache", "get_material_cache"); - ClassDB::bind_method(D_METHOD("get_jobs_step", "index"), &PropInstancePropJob2D::get_jobs_step); - ClassDB::bind_method(D_METHOD("set_jobs_step", "index", "mesher"), &PropInstancePropJob2D::set_jobs_step); - ClassDB::bind_method(D_METHOD("remove_jobs_step", "index"), &PropInstancePropJob2D::remove_jobs_step); - ClassDB::bind_method(D_METHOD("add_jobs_step", "mesher"), &PropInstancePropJob2D::add_jobs_step); - ClassDB::bind_method(D_METHOD("get_jobs_step_count"), &PropInstancePropJob2D::get_jobs_step_count); + ClassDB::bind_method(D_METHOD("get_jobs_step", "index"), &PropInstancePropJob::get_jobs_step); + ClassDB::bind_method(D_METHOD("set_jobs_step", "index", "mesher"), &PropInstancePropJob::set_jobs_step); + ClassDB::bind_method(D_METHOD("remove_jobs_step", "index"), &PropInstancePropJob::remove_jobs_step); + ClassDB::bind_method(D_METHOD("add_jobs_step", "mesher"), &PropInstancePropJob::add_jobs_step); + ClassDB::bind_method(D_METHOD("get_jobs_step_count"), &PropInstancePropJob::get_jobs_step_count); - ClassDB::bind_method(D_METHOD("get_prop_mesher"), &PropInstancePropJob2D::get_prop_mesher); - ClassDB::bind_method(D_METHOD("set_prop_mesher", "mesher"), &PropInstancePropJob2D::set_prop_mesher); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher2D", 0), "set_prop_mesher", "get_prop_mesher"); + ClassDB::bind_method(D_METHOD("get_prop_mesher"), &PropInstancePropJob::get_prop_mesher); + ClassDB::bind_method(D_METHOD("set_prop_mesher", "mesher"), &PropInstancePropJob::set_prop_mesher); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher", 0), "set_prop_mesher", "get_prop_mesher"); - ClassDB::bind_method(D_METHOD("add_light", "light"), &PropInstancePropJob2D::add_light); - ClassDB::bind_method(D_METHOD("clear_lights"), &PropInstancePropJob2D::clear_lights); + ClassDB::bind_method(D_METHOD("add_light", "light"), &PropInstancePropJob::add_light); + ClassDB::bind_method(D_METHOD("clear_lights"), &PropInstancePropJob::clear_lights); - ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &PropInstancePropJob2D::_physics_process); + ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &PropInstancePropJob::_physics_process); } diff --git a/prop_instance_prop_job_2d.h b/prop_instance_prop_job.h similarity index 66% rename from prop_instance_prop_job_2d.h rename to prop_instance_prop_job.h index cc76850..3d3e789 100644 --- a/prop_instance_prop_job_2d.h +++ b/prop_instance_prop_job.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,56 +20,56 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_JOB_2D_H -#define PROP_JOB_2D_H +#ifndef PROP_JOB_H +#define PROP_JOB_H -#include "prop_instance_job_2d.h" +#include "prop_instance_job.h" -class PropMesher2D; -class PropInstance2D; -class PropInstanceMerger2D; -class PropMesherJobStep2D; -class PropMaterialCache2D; +class PropMesher; +class PropInstance; +class PropInstanceMerger; +class PropMesherJobStep; +class PropMaterialCache; class Shape; -class PropLight2D; -class PropDataTiledWall2D; +class PropLight; +class PropDataTiledWall; #if MESH_DATA_RESOURCE_PRESENT -class PropDataMeshData; +class Prop2DDataMeshData; #endif -class PropInstancePropJob2D : public PropInstanceJob2D { - GDCLASS(PropInstancePropJob2D, PropInstanceJob2D); +class PropInstancePropJob : public PropInstanceJob { + GDCLASS(PropInstancePropJob, PropInstanceJob); public: - Ref get_material_cache(); - void set_material_cache(const Ref &cache); + Ref get_material_cache(); + void set_material_cache(const Ref &cache); - Ref get_jobs_step(const int index) const; - void set_jobs_step(const int index, const Ref &step); + Ref get_jobs_step(const int index) const; + void set_jobs_step(const int index, const Ref &step); void remove_jobs_step(const int index); - void add_jobs_step(const Ref &step); + void add_jobs_step(const Ref &step); int get_jobs_step_count() const; void add_collision_shape(const Ref &shape, const Transform &transform, const bool owns_shape = false); void clear_collision_shapes(); - PropInstanceMerger2D *get_prop_instace(); - void set_prop_instace(PropInstanceMerger2D *prop); + PropInstanceMerger *get_prop_instace(); + void set_prop_instace(PropInstanceMerger *prop); void set_prop_instace_bind(Node *prop); - Ref get_prop_mesher() const; - void set_prop_mesher(const Ref &mesher); + Ref get_prop_mesher() const; + void set_prop_mesher(const Ref &mesher); #if MESH_DATA_RESOURCE_PRESENT - void add_mesh(const Ref &mesh_data, const Transform &base_transform); + void add_mesh(const Ref &mesh_data, const Transform &base_transform); void clear_meshes(); #endif - void add_tiled_wall(const Ref &data, const Transform &base_transform); + void add_tiled_wall(const Ref &data, const Transform &base_transform); void clear_tiled_walls(); - void add_light(const Ref &light); + void add_light(const Ref &light); void clear_lights(); void _physics_process(float delta); @@ -93,8 +93,8 @@ public: void reset_meshes(); - PropInstancePropJob2D(); - ~PropInstancePropJob2D(); + PropInstancePropJob(); + ~PropInstancePropJob(); protected: static void _bind_methods(); @@ -102,13 +102,13 @@ protected: protected: #if MESH_DATA_RESOURCE_PRESENT struct PMDREntry { - Ref mesh_data; + Ref mesh_data; Transform base_transform; }; #endif struct PTWEntry { - Ref data; + Ref data; Transform base_transform; }; @@ -122,14 +122,14 @@ protected: } }; - Ref _material_cache; + Ref _material_cache; - Vector> _job_steps; + Vector> _job_steps; int _current_job_step; int _current_mesh; - Ref _prop_mesher; - PropInstanceMerger2D *_prop_instace; + Ref _prop_mesher; + PropInstanceMerger *_prop_instace; #if MESH_DATA_RESOURCE_PRESENT Vector _prop_mesh_datas; diff --git a/prop_mesher_2d.cpp b/prop_mesher.cpp similarity index 75% rename from prop_mesher_2d.cpp rename to prop_mesher.cpp index fb093f2..b77d2c0 100644 --- a/prop_mesher_2d.cpp +++ b/prop_mesher.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,17 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_mesher_2d.h" +#include "prop_mesher.h" -#include "lights/prop_light_2d.h" +#include "lights/prop_light.h" #include "modules/opensimplex/open_simplex_noise.h" -#include "material_cache/prop_material_cache_2d.h" -#include "tiled_wall/tiled_wall_data_2d.h" +#include "material_cache/prop_material_cache.h" +#include "tiled_wall/tiled_wall_data.h" -const String PropMesher2D::BINDING_STRING_BUILD_FLAGS = "Use Lighting,Use AO,Use RAO,Bake Lights"; +const String PropMesher::BINDING_STRING_BUILD_FLAGS = "Use Lighting,Use AO,Use RAO,Bake Lights"; -bool PropMesher2D::Vertex::operator==(const Vertex &p_vertex) const { +bool PropMesher::Vertex::operator==(const Vertex &p_vertex) const { if (vertex != p_vertex.vertex) return false; @@ -65,7 +65,7 @@ bool PropMesher2D::Vertex::operator==(const Vertex &p_vertex) const { return true; } -uint32_t PropMesher2D::VertexHasher::hash(const Vertex &p_vtx) { +uint32_t PropMesher::VertexHasher::hash(const Vertex &p_vtx) { uint32_t h = hash_djb2_buffer((const uint8_t *)&p_vtx.vertex, sizeof(real_t) * 3); h = hash_djb2_buffer((const uint8_t *)&p_vtx.normal, sizeof(real_t) * 3, h); h = hash_djb2_buffer((const uint8_t *)&p_vtx.binormal, sizeof(real_t) * 3, h); @@ -78,90 +78,90 @@ uint32_t PropMesher2D::VertexHasher::hash(const Vertex &p_vtx) { return h; } -int PropMesher2D::get_channel_index_type() const { +int PropMesher::get_channel_index_type() const { return _channel_index_type; } -void PropMesher2D::set_channel_index_type(const int value) { +void PropMesher::set_channel_index_type(const int value) { _channel_index_type = value; } -int PropMesher2D::get_channel_index_isolevel() const { +int PropMesher::get_channel_index_isolevel() const { return _channel_index_isolevel; } -void PropMesher2D::set_channel_index_isolevel(const int value) { +void PropMesher::set_channel_index_isolevel(const int value) { _channel_index_isolevel = value; } -int PropMesher2D::get_mesher_index() const { +int PropMesher::get_mesher_index() const { return _mesher_index; } -void PropMesher2D::set_mesher_index(const int value) { +void PropMesher::set_mesher_index(const int value) { _mesher_index = value; } -int PropMesher2D::get_format() const { +int PropMesher::get_format() const { return _format; } -void PropMesher2D::set_format(const int value) { +void PropMesher::set_format(const int value) { _format = value; } -int PropMesher2D::get_texture_scale() const { +int PropMesher::get_texture_scale() const { return _texture_scale; } -void PropMesher2D::set_texture_scale(const int value) { +void PropMesher::set_texture_scale(const int value) { _texture_scale = value; } -Ref PropMesher2D::get_material() { +Ref PropMesher::get_material() { return _material; } -void PropMesher2D::set_material(const Ref &material) { +void PropMesher::set_material(const Ref &material) { _material = material; } -float PropMesher2D::get_ao_strength() const { +float PropMesher::get_ao_strength() const { return _ao_strength; } -void PropMesher2D::set_ao_strength(float value) { +void PropMesher::set_ao_strength(float value) { _ao_strength = value; } -float PropMesher2D::get_base_light_value() const { +float PropMesher::get_base_light_value() const { return _base_light_value; } -void PropMesher2D::set_base_light_value(float value) { +void PropMesher::set_base_light_value(float value) { _base_light_value = value; } -float PropMesher2D::get_voxel_scale() const { +float PropMesher::get_voxel_scale() const { return _voxel_scale; } -void PropMesher2D::set_voxel_scale(const float voxel_scale) { +void PropMesher::set_voxel_scale(const float voxel_scale) { _voxel_scale = voxel_scale; } -Rect2 PropMesher2D::get_uv_margin() const { +Rect2 PropMesher::get_uv_margin() const { return _uv_margin; } -void PropMesher2D::set_uv_margin(const Rect2 margin) { +void PropMesher::set_uv_margin(const Rect2 margin) { _uv_margin = margin; } -_FORCE_INLINE_ int PropMesher2D::get_build_flags() const { +_FORCE_INLINE_ int PropMesher::get_build_flags() const { return _build_flags; } -_FORCE_INLINE_ void PropMesher2D::set_build_flags(const int flags) { +_FORCE_INLINE_ void PropMesher::set_build_flags(const int flags) { _build_flags = flags; - if ((_build_flags & PropMesher2D::BUILD_FLAG_USE_LIGHTING) != 0) { + if ((_build_flags & PropMesher::BUILD_FLAG_USE_LIGHTING) != 0) { _format |= VisualServer::ARRAY_FORMAT_COLOR; } else { _format ^= VisualServer::ARRAY_FORMAT_COLOR; } } -Array PropMesher2D::build_mesh() { +Array PropMesher::build_mesh() { Array a; a.resize(VisualServer::ARRAY_MAX); @@ -305,7 +305,7 @@ Array PropMesher2D::build_mesh() { return a; } -void PropMesher2D::build_mesh_into(RID mesh) { +void PropMesher::build_mesh_into(RID mesh) { ERR_FAIL_COND(mesh == RID()); VS::get_singleton()->mesh_clear(mesh); @@ -323,7 +323,7 @@ void PropMesher2D::build_mesh_into(RID mesh) { VS::get_singleton()->mesh_surface_set_material(mesh, 0, _material->get_rid()); } -void PropMesher2D::generate_normals(bool p_flip) { +void PropMesher::generate_normals(bool p_flip) { _format = _format | VisualServer::ARRAY_FORMAT_NORMAL; for (int i = 0; i < _indices.size(); i += 3) { @@ -355,7 +355,7 @@ void PropMesher2D::generate_normals(bool p_flip) { } } -void PropMesher2D::remove_doubles() { +void PropMesher::remove_doubles() { if (_vertices.size() == 0) return; @@ -401,7 +401,7 @@ void PropMesher2D::remove_doubles() { } //lot faster that normal remove_doubles, but false positives can happen curtesy of hash collisions -void PropMesher2D::remove_doubles_hashed() { +void PropMesher::remove_doubles_hashed() { if (_vertices.size() == 0) return; @@ -453,7 +453,7 @@ void PropMesher2D::remove_doubles_hashed() { //print_error("after " + String::num(_vertices.size()) + " " + String::num(duration.count())); } -void PropMesher2D::reset() { +void PropMesher::reset() { _vertices.resize(0); _indices.resize(0); @@ -466,7 +466,7 @@ void PropMesher2D::reset() { _last_tangent = Plane(); } -void PropMesher2D::add_tiled_wall_simple(const int width, const int height, const Transform &transform, const Ref &tiled_wall_data, Ref cache) { +void PropMesher::add_tiled_wall_simple(const int width, const int height, const Transform &transform, const Ref &tiled_wall_data, Ref cache) { ERR_FAIL_COND(!tiled_wall_data.is_valid()); ERR_FAIL_COND(!cache.is_valid()); ERR_FAIL_COND(width < 0); @@ -503,11 +503,11 @@ void PropMesher2D::add_tiled_wall_simple(const int width, const int height, cons normal_rects.push_back(Rect2(0, 0, 1, 1)); } - TiledWallData2D::TiledWallTilingType tiling_type = tiled_wall_data->get_tiling_type(); + TiledWallData::TiledWallTilingType tiling_type = tiled_wall_data->get_tiling_type(); //todo implement flavour! - if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_NONE) { + if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_NONE) { Rect2 r = normal_rects[0]; if (flavour_rects.size() == 0) { @@ -529,7 +529,7 @@ void PropMesher2D::add_tiled_wall_simple(const int width, const int height, cons } } } - } else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_HORIZONTAL) { + } else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_HORIZONTAL) { Rect2 r; if (flavour_rects.size() == 0) { @@ -555,7 +555,7 @@ void PropMesher2D::add_tiled_wall_simple(const int width, const int height, cons } } } - } else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_VERTICAL) { + } else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_VERTICAL) { Rect2 r; if (flavour_rects.size() == 0) { @@ -581,7 +581,7 @@ void PropMesher2D::add_tiled_wall_simple(const int width, const int height, cons } } } - } else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_BOTH) { + } else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_BOTH) { Rect2 r; if (flavour_rects.size() == 0) { @@ -610,7 +610,7 @@ void PropMesher2D::add_tiled_wall_simple(const int width, const int height, cons } } -void PropMesher2D::add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform &transform, const Rect2 &texture_rect) { +void PropMesher::add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform &transform, const Rect2 &texture_rect) { int vc = get_vertex_count(); //x + 1, y @@ -641,7 +641,7 @@ void PropMesher2D::add_tiled_wall_mesh_rect_simple(const int x, const int y, con add_indices(vc + 0); } -_FORCE_INLINE_ Vector2 PropMesher2D::transform_uv(const Vector2 &uv, const Rect2 &rect) const { +_FORCE_INLINE_ Vector2 PropMesher::transform_uv(const Vector2 &uv, const Rect2 &rect) const { Vector2 ruv = uv; ruv.x *= rect.size.x; @@ -653,13 +653,13 @@ _FORCE_INLINE_ Vector2 PropMesher2D::transform_uv(const Vector2 &uv, const Rect2 } #ifdef MESH_DATA_RESOURCE_PRESENT -void PropMesher2D::add_mesh_data_resource(Ref mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) { +void PropMesher::add_mesh_data_resource(Ref mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) { Transform transform = Transform(Basis(rotation).scaled(scale), position); add_mesh_data_resource_transform(mesh, transform, uv_rect); } -void PropMesher2D::add_mesh_data_resource_transform(Ref mesh, const Transform transform, const Rect2 uv_rect) { +void PropMesher::add_mesh_data_resource_transform(Ref mesh, const Transform transform, const Rect2 uv_rect) { if (mesh->get_array().size() == 0) return; @@ -703,7 +703,7 @@ void PropMesher2D::add_mesh_data_resource_transform(Ref mesh, } } -void PropMesher2D::add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect) { +void PropMesher::add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect) { if (mesh->get_array().size() == 0) return; @@ -748,7 +748,7 @@ void PropMesher2D::add_mesh_data_resource_transform_colored(Refget_noise_3d(position.x, position.y, position.z); val *= _rao_scale_factor; @@ -801,12 +801,12 @@ float PropMesher2D::get_random_ao(const Vector3 &position) { return val; } -Color PropMesher2D::get_light_color_at(const Vector3 &position, const Vector3 &normal) { +Color PropMesher::get_light_color_at(const Vector3 &position, const Vector3 &normal) { Vector3 v_lightDiffuse; //calculate the lights value for (int i = 0; i < _lights.size(); ++i) { - Ref light = _lights.get(i); + Ref light = _lights.get(i); Vector3 lightDir = light->get_position() - position; @@ -843,10 +843,10 @@ Color PropMesher2D::get_light_color_at(const Vector3 &position, const Vector3 &n return Color(v_lightDiffuse.x, v_lightDiffuse.y, v_lightDiffuse.z); } -void PropMesher2D::add_mesher(const Ref &mesher) { +void PropMesher::add_mesher(const Ref &mesher) { call("_add_mesher", mesher); } -void PropMesher2D::_add_mesher(const Ref &mesher) { +void PropMesher::_add_mesher(const Ref &mesher) { int orig_size = _vertices.size(); _vertices.append_array(mesher->_vertices); @@ -864,14 +864,14 @@ void PropMesher2D::_add_mesher(const Ref &mesher) { } } -void PropMesher2D::add_light(const Ref &light) { +void PropMesher::add_light(const Ref &light) { _lights.push_back(light); } -void PropMesher2D::clear_lights() { +void PropMesher::clear_lights() { _lights.clear(); } -PoolVector PropMesher2D::build_collider() const { +PoolVector PropMesher::build_collider() const { PoolVector face_points; if (_vertices.size() == 0) @@ -901,13 +901,13 @@ PoolVector PropMesher2D::build_collider() const { return face_points; } -void PropMesher2D::bake_colors() { - if ((get_build_flags() & PropMesher2D::BUILD_FLAG_USE_LIGHTING) == 0) { +void PropMesher::bake_colors() { + if ((get_build_flags() & PropMesher::BUILD_FLAG_USE_LIGHTING) == 0) { return; } - bool rao = (get_build_flags() & PropMesher2D::BUILD_FLAG_USE_RAO) != 0; - bool lights = (get_build_flags() & PropMesher2D::BUILD_FLAG_BAKE_LIGHTS) != 0; + bool rao = (get_build_flags() & PropMesher::BUILD_FLAG_USE_RAO) != 0; + bool lights = (get_build_flags() & PropMesher::BUILD_FLAG_BAKE_LIGHTS) != 0; if (rao && lights) { bake_colors_lights_rao(); @@ -925,7 +925,7 @@ void PropMesher2D::bake_colors() { } } -void PropMesher2D::bake_colors_rao() { +void PropMesher::bake_colors_rao() { for (int i = 0; i < _vertices.size(); ++i) { Vertex vertex = _vertices[i]; Vector3 vert = vertex.vertex; @@ -949,7 +949,7 @@ void PropMesher2D::bake_colors_rao() { _vertices.set(i, vertex); } } -void PropMesher2D::bake_colors_lights_rao() { +void PropMesher::bake_colors_lights_rao() { for (int i = 0; i < _vertices.size(); ++i) { Vertex vertex = _vertices[i]; Vector3 vert = vertex.vertex; @@ -977,7 +977,7 @@ void PropMesher2D::bake_colors_lights_rao() { _vertices.set(i, vertex); } } -void PropMesher2D::bake_colors_lights() { +void PropMesher::bake_colors_lights() { for (int i = 0; i < _vertices.size(); ++i) { Vertex vertex = _vertices[i]; Vector3 vert = vertex.vertex; @@ -1001,7 +1001,7 @@ void PropMesher2D::bake_colors_lights() { } #ifdef TERRAMAN_PRESENT -void PropMesher2D::bake_lights(MeshInstance *node, Vector> &lights) { +void PropMesher::bake_lights(MeshInstance *node, Vector> &lights) { ERR_FAIL_COND(node == NULL); Color darkColor(0, 0, 0, 1); @@ -1018,7 +1018,7 @@ void PropMesher2D::bake_lights(MeshInstance *node, Vector> &ligh //calculate the lights value for (int i = 0; i < lights.size(); ++i) { - Ref light = lights.get(i); + Ref light = lights.get(i); Vector3 lightDir = light->get_world_position() - vertex; @@ -1089,7 +1089,7 @@ void PropMesher2D::bake_lights(MeshInstance *node, Vector> &ligh } #endif -PoolVector PropMesher2D::get_vertices() const { +PoolVector PropMesher::get_vertices() const { PoolVector arr; arr.resize(_vertices.size()); @@ -1100,7 +1100,7 @@ PoolVector PropMesher2D::get_vertices() const { return arr; } -void PropMesher2D::set_vertices(const PoolVector &values) { +void PropMesher::set_vertices(const PoolVector &values) { ERR_FAIL_COND(values.size() != _vertices.size()); for (int i = 0; i < _vertices.size(); ++i) { @@ -1112,11 +1112,11 @@ void PropMesher2D::set_vertices(const PoolVector &values) { } } -int PropMesher2D::get_vertex_count() const { +int PropMesher::get_vertex_count() const { return _vertices.size(); } -void PropMesher2D::add_vertex(const Vector3 &vertex) { +void PropMesher::add_vertex(const Vector3 &vertex) { Vertex vtx; vtx.vertex = vertex; vtx.color = _last_color; @@ -1132,15 +1132,15 @@ void PropMesher2D::add_vertex(const Vector3 &vertex) { _vertices.push_back(vtx); } -Vector3 PropMesher2D::get_vertex(const int idx) const { +Vector3 PropMesher::get_vertex(const int idx) const { return _vertices.get(idx).vertex; } -void PropMesher2D::remove_vertex(const int idx) { +void PropMesher::remove_vertex(const int idx) { _vertices.remove(idx); } -PoolVector PropMesher2D::get_normals() const { +PoolVector PropMesher::get_normals() const { PoolVector arr; arr.resize(_vertices.size()); @@ -1151,7 +1151,7 @@ PoolVector PropMesher2D::get_normals() const { return arr; } -void PropMesher2D::set_normals(const PoolVector &values) { +void PropMesher::set_normals(const PoolVector &values) { ERR_FAIL_COND(values.size() != _vertices.size()); for (int i = 0; i < _vertices.size(); ++i) { @@ -1163,15 +1163,15 @@ void PropMesher2D::set_normals(const PoolVector &values) { } } -void PropMesher2D::add_normal(const Vector3 &normal) { +void PropMesher::add_normal(const Vector3 &normal) { _last_normal = normal; } -Vector3 PropMesher2D::get_normal(int idx) const { +Vector3 PropMesher::get_normal(int idx) const { return _vertices.get(idx).normal; } -PoolVector PropMesher2D::get_colors() const { +PoolVector PropMesher::get_colors() const { PoolVector arr; arr.resize(_vertices.size()); @@ -1182,7 +1182,7 @@ PoolVector PropMesher2D::get_colors() const { return arr; } -void PropMesher2D::set_colors(const PoolVector &values) { +void PropMesher::set_colors(const PoolVector &values) { ERR_FAIL_COND(values.size() != _vertices.size()); for (int i = 0; i < _vertices.size(); ++i) { @@ -1194,15 +1194,15 @@ void PropMesher2D::set_colors(const PoolVector &values) { } } -void PropMesher2D::add_color(const Color &color) { +void PropMesher::add_color(const Color &color) { _last_color = color; } -Color PropMesher2D::get_color(const int idx) const { +Color PropMesher::get_color(const int idx) const { return _vertices.get(idx).color; } -PoolVector PropMesher2D::get_uvs() const { +PoolVector PropMesher::get_uvs() const { PoolVector arr; arr.resize(_vertices.size()); @@ -1213,7 +1213,7 @@ PoolVector PropMesher2D::get_uvs() const { return arr; } -void PropMesher2D::set_uvs(const PoolVector &values) { +void PropMesher::set_uvs(const PoolVector &values) { ERR_FAIL_COND(values.size() != _vertices.size()); for (int i = 0; i < _vertices.size(); ++i) { @@ -1225,15 +1225,15 @@ void PropMesher2D::set_uvs(const PoolVector &values) { } } -void PropMesher2D::add_uv(const Vector2 &uv) { +void PropMesher::add_uv(const Vector2 &uv) { _last_uv = uv; } -Vector2 PropMesher2D::get_uv(const int idx) const { +Vector2 PropMesher::get_uv(const int idx) const { return _vertices.get(idx).uv; } -PoolVector PropMesher2D::get_uv2s() const { +PoolVector PropMesher::get_uv2s() const { PoolVector arr; arr.resize(_vertices.size()); @@ -1244,7 +1244,7 @@ PoolVector PropMesher2D::get_uv2s() const { return arr; } -void PropMesher2D::set_uv2s(const PoolVector &values) { +void PropMesher::set_uv2s(const PoolVector &values) { ERR_FAIL_COND(values.size() != _vertices.size()); for (int i = 0; i < _vertices.size(); ++i) { @@ -1256,39 +1256,39 @@ void PropMesher2D::set_uv2s(const PoolVector &values) { } } -void PropMesher2D::add_uv2(const Vector2 &uv) { +void PropMesher::add_uv2(const Vector2 &uv) { _last_uv2 = uv; } -Vector2 PropMesher2D::get_uv2(const int idx) const { +Vector2 PropMesher::get_uv2(const int idx) const { return _vertices.get(idx).uv2; } -PoolVector PropMesher2D::get_indices() const { +PoolVector PropMesher::get_indices() const { return _indices; } -void PropMesher2D::set_indices(const PoolVector &values) { +void PropMesher::set_indices(const PoolVector &values) { _indices = values; } -int PropMesher2D::get_indices_count() const { +int PropMesher::get_indices_count() const { return _indices.size(); } -void PropMesher2D::add_indices(const int index) { +void PropMesher::add_indices(const int index) { _indices.push_back(index); } -int PropMesher2D::get_index(const int idx) const { +int PropMesher::get_index(const int idx) const { return _indices.get(idx); } -void PropMesher2D::remove_index(const int idx) { +void PropMesher::remove_index(const int idx) { _indices.remove(idx); } -PropMesher2D::PropMesher2D() { +PropMesher::PropMesher() { _mesher_index = 0; _voxel_scale = 1; _ao_strength = 0.25; @@ -1313,120 +1313,120 @@ PropMesher2D::PropMesher2D() { _rao_seed = 2134; } -PropMesher2D::~PropMesher2D() { +PropMesher::~PropMesher() { } -void PropMesher2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_channel_index_type"), &PropMesher2D::get_channel_index_type); - ClassDB::bind_method(D_METHOD("set_channel_index_type", "value"), &PropMesher2D::set_channel_index_type); +void PropMesher::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_channel_index_type"), &PropMesher::get_channel_index_type); + ClassDB::bind_method(D_METHOD("set_channel_index_type", "value"), &PropMesher::set_channel_index_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_index_type"), "set_channel_index_type", "get_channel_index_type"); - ClassDB::bind_method(D_METHOD("get_channel_index_isolevel"), &PropMesher2D::get_channel_index_isolevel); - ClassDB::bind_method(D_METHOD("set_channel_index_isolevel", "value"), &PropMesher2D::set_channel_index_isolevel); + ClassDB::bind_method(D_METHOD("get_channel_index_isolevel"), &PropMesher::get_channel_index_isolevel); + ClassDB::bind_method(D_METHOD("set_channel_index_isolevel", "value"), &PropMesher::set_channel_index_isolevel); ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_index_isolevel"), "set_channel_index_isolevel", "get_channel_index_isolevel"); - ClassDB::bind_method(D_METHOD("get_mesher_index"), &PropMesher2D::get_mesher_index); - ClassDB::bind_method(D_METHOD("set_mesher_index", "value"), &PropMesher2D::set_mesher_index); + ClassDB::bind_method(D_METHOD("get_mesher_index"), &PropMesher::get_mesher_index); + ClassDB::bind_method(D_METHOD("set_mesher_index", "value"), &PropMesher::set_mesher_index); ADD_PROPERTY(PropertyInfo(Variant::INT, "mesher_index"), "set_mesher_index", "get_mesher_index"); - ClassDB::bind_method(D_METHOD("get_format"), &PropMesher2D::get_format); - ClassDB::bind_method(D_METHOD("set_format", "value"), &PropMesher2D::set_format); + ClassDB::bind_method(D_METHOD("get_format"), &PropMesher::get_format); + ClassDB::bind_method(D_METHOD("set_format", "value"), &PropMesher::set_format); ADD_PROPERTY(PropertyInfo(Variant::INT, "format"), "set_format", "get_format"); - ClassDB::bind_method(D_METHOD("get_texture_scale"), &PropMesher2D::get_texture_scale); - ClassDB::bind_method(D_METHOD("set_texture_scale", "value"), &PropMesher2D::set_texture_scale); + ClassDB::bind_method(D_METHOD("get_texture_scale"), &PropMesher::get_texture_scale); + ClassDB::bind_method(D_METHOD("set_texture_scale", "value"), &PropMesher::set_texture_scale); ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_scale"), "set_texture_scale", "get_texture_scale"); - ClassDB::bind_method(D_METHOD("get_material"), &PropMesher2D::get_material); - ClassDB::bind_method(D_METHOD("set_material", "value"), &PropMesher2D::set_material); + ClassDB::bind_method(D_METHOD("get_material"), &PropMesher::get_material); + ClassDB::bind_method(D_METHOD("set_material", "value"), &PropMesher::set_material); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_material", "get_material"); - ClassDB::bind_method(D_METHOD("get_voxel_scale"), &PropMesher2D::get_voxel_scale); - ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &PropMesher2D::set_voxel_scale); + ClassDB::bind_method(D_METHOD("get_voxel_scale"), &PropMesher::get_voxel_scale); + ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &PropMesher::set_voxel_scale); ADD_PROPERTY(PropertyInfo(Variant::REAL, "voxel_scale"), "set_voxel_scale", "get_voxel_scale"); - ClassDB::bind_method(D_METHOD("get_ao_strength"), &PropMesher2D::get_ao_strength); - ClassDB::bind_method(D_METHOD("set_ao_strength", "value"), &PropMesher2D::set_ao_strength); + ClassDB::bind_method(D_METHOD("get_ao_strength"), &PropMesher::get_ao_strength); + ClassDB::bind_method(D_METHOD("set_ao_strength", "value"), &PropMesher::set_ao_strength); ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_strength"), "set_ao_strength", "get_ao_strength"); - ClassDB::bind_method(D_METHOD("get_base_light_value"), &PropMesher2D::get_base_light_value); - ClassDB::bind_method(D_METHOD("set_base_light_value", "value"), &PropMesher2D::set_base_light_value); + ClassDB::bind_method(D_METHOD("get_base_light_value"), &PropMesher::get_base_light_value); + ClassDB::bind_method(D_METHOD("set_base_light_value", "value"), &PropMesher::set_base_light_value); ADD_PROPERTY(PropertyInfo(Variant::REAL, "base_light_value"), "set_base_light_value", "get_base_light_value"); - ClassDB::bind_method(D_METHOD("get_uv_margin"), &PropMesher2D::get_uv_margin); - ClassDB::bind_method(D_METHOD("set_uv_margin", "value"), &PropMesher2D::set_uv_margin); + ClassDB::bind_method(D_METHOD("get_uv_margin"), &PropMesher::get_uv_margin); + ClassDB::bind_method(D_METHOD("set_uv_margin", "value"), &PropMesher::set_uv_margin); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "uv_margin"), "set_uv_margin", "get_uv_margin"); - ClassDB::bind_method(D_METHOD("get_build_flags"), &PropMesher2D::get_build_flags); - ClassDB::bind_method(D_METHOD("set_build_flags", "value"), &PropMesher2D::set_build_flags); - ADD_PROPERTY(PropertyInfo(Variant::INT, "build_flags", PROPERTY_HINT_FLAGS, PropMesher2D::BINDING_STRING_BUILD_FLAGS), "set_build_flags", "get_build_flags"); + ClassDB::bind_method(D_METHOD("get_build_flags"), &PropMesher::get_build_flags); + ClassDB::bind_method(D_METHOD("set_build_flags", "value"), &PropMesher::set_build_flags); + ADD_PROPERTY(PropertyInfo(Variant::INT, "build_flags", PROPERTY_HINT_FLAGS, PropMesher::BINDING_STRING_BUILD_FLAGS), "set_build_flags", "get_build_flags"); - ClassDB::bind_method(D_METHOD("add_tiled_wall_simple", "width", "height", "transform", "tiled_wall_data", "cache"), &PropMesher2D::add_tiled_wall_simple); - ClassDB::bind_method(D_METHOD("add_tiled_wall_mesh_rect_simple", "x", "y", "transform", "texture_rect"), &PropMesher2D::add_tiled_wall_mesh_rect_simple); - ClassDB::bind_method(D_METHOD("transform_uv", "uv", "rect"), &PropMesher2D::transform_uv); + ClassDB::bind_method(D_METHOD("add_tiled_wall_simple", "width", "height", "transform", "tiled_wall_data", "cache"), &PropMesher::add_tiled_wall_simple); + ClassDB::bind_method(D_METHOD("add_tiled_wall_mesh_rect_simple", "x", "y", "transform", "texture_rect"), &PropMesher::add_tiled_wall_mesh_rect_simple); + ClassDB::bind_method(D_METHOD("transform_uv", "uv", "rect"), &PropMesher::transform_uv); #ifdef MESH_DATA_RESOURCE_PRESENT - ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &PropMesher2D::add_mesh_data_resource, DEFVAL(Rect2(0, 0, 1, 1)), DEFVAL(Vector3(1.0, 1.0, 1.0)), DEFVAL(Vector3()), DEFVAL(Vector3())); - ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform", "mesh", "transform", "uv_rect"), &PropMesher2D::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1))); - ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &PropMesher2D::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1))); + ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &PropMesher::add_mesh_data_resource, DEFVAL(Rect2(0, 0, 1, 1)), DEFVAL(Vector3(1.0, 1.0, 1.0)), DEFVAL(Vector3()), DEFVAL(Vector3())); + ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform", "mesh", "transform", "uv_rect"), &PropMesher::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1))); + ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &PropMesher::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1))); #endif - ClassDB::bind_method(D_METHOD("generate_ao"), &PropMesher2D::generate_ao); - ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &PropMesher2D::get_random_ao); + ClassDB::bind_method(D_METHOD("generate_ao"), &PropMesher::generate_ao); + ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &PropMesher::get_random_ao); - BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher2D"))); - ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &PropMesher2D::add_mesher); - ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &PropMesher2D::_add_mesher); + BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "PropMesher"))); + ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &PropMesher::add_mesher); + ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &PropMesher::_add_mesher); - ClassDB::bind_method(D_METHOD("add_light", "light"), &PropMesher2D::add_light); - ClassDB::bind_method(D_METHOD("clear_lights"), &PropMesher2D::clear_lights); + ClassDB::bind_method(D_METHOD("add_light", "light"), &PropMesher::add_light); + ClassDB::bind_method(D_METHOD("clear_lights"), &PropMesher::clear_lights); - ClassDB::bind_method(D_METHOD("get_vertices"), &PropMesher2D::get_vertices); - ClassDB::bind_method(D_METHOD("set_vertices", "values"), &PropMesher2D::set_vertices); - ClassDB::bind_method(D_METHOD("get_vertex_count"), &PropMesher2D::get_vertex_count); - ClassDB::bind_method(D_METHOD("get_vertex", "idx"), &PropMesher2D::get_vertex); - ClassDB::bind_method(D_METHOD("remove_vertex", "idx"), &PropMesher2D::remove_vertex); - ClassDB::bind_method(D_METHOD("add_vertex", "vertex"), &PropMesher2D::add_vertex); + ClassDB::bind_method(D_METHOD("get_vertices"), &PropMesher::get_vertices); + ClassDB::bind_method(D_METHOD("set_vertices", "values"), &PropMesher::set_vertices); + ClassDB::bind_method(D_METHOD("get_vertex_count"), &PropMesher::get_vertex_count); + ClassDB::bind_method(D_METHOD("get_vertex", "idx"), &PropMesher::get_vertex); + ClassDB::bind_method(D_METHOD("remove_vertex", "idx"), &PropMesher::remove_vertex); + ClassDB::bind_method(D_METHOD("add_vertex", "vertex"), &PropMesher::add_vertex); - ClassDB::bind_method(D_METHOD("get_normals"), &PropMesher2D::get_normals); - ClassDB::bind_method(D_METHOD("set_normals", "values"), &PropMesher2D::set_normals); - ClassDB::bind_method(D_METHOD("get_normal", "idx"), &PropMesher2D::get_normal); - ClassDB::bind_method(D_METHOD("add_normal", "normal"), &PropMesher2D::add_normal); + ClassDB::bind_method(D_METHOD("get_normals"), &PropMesher::get_normals); + ClassDB::bind_method(D_METHOD("set_normals", "values"), &PropMesher::set_normals); + ClassDB::bind_method(D_METHOD("get_normal", "idx"), &PropMesher::get_normal); + ClassDB::bind_method(D_METHOD("add_normal", "normal"), &PropMesher::add_normal); - ClassDB::bind_method(D_METHOD("get_colors"), &PropMesher2D::get_colors); - ClassDB::bind_method(D_METHOD("set_colors", "values"), &PropMesher2D::set_colors); - ClassDB::bind_method(D_METHOD("get_color", "idx"), &PropMesher2D::get_color); - ClassDB::bind_method(D_METHOD("add_color", "color"), &PropMesher2D::add_color); + ClassDB::bind_method(D_METHOD("get_colors"), &PropMesher::get_colors); + ClassDB::bind_method(D_METHOD("set_colors", "values"), &PropMesher::set_colors); + ClassDB::bind_method(D_METHOD("get_color", "idx"), &PropMesher::get_color); + ClassDB::bind_method(D_METHOD("add_color", "color"), &PropMesher::add_color); - ClassDB::bind_method(D_METHOD("get_uvs"), &PropMesher2D::get_uvs); - ClassDB::bind_method(D_METHOD("set_uvs", "values"), &PropMesher2D::set_uvs); - ClassDB::bind_method(D_METHOD("get_uv", "idx"), &PropMesher2D::get_uv); - ClassDB::bind_method(D_METHOD("add_uv", "uv"), &PropMesher2D::add_uv); + ClassDB::bind_method(D_METHOD("get_uvs"), &PropMesher::get_uvs); + ClassDB::bind_method(D_METHOD("set_uvs", "values"), &PropMesher::set_uvs); + ClassDB::bind_method(D_METHOD("get_uv", "idx"), &PropMesher::get_uv); + ClassDB::bind_method(D_METHOD("add_uv", "uv"), &PropMesher::add_uv); - ClassDB::bind_method(D_METHOD("get_uv2s"), &PropMesher2D::get_uv2s); - ClassDB::bind_method(D_METHOD("set_uv2s", "values"), &PropMesher2D::set_uv2s); - ClassDB::bind_method(D_METHOD("get_uv2", "idx"), &PropMesher2D::get_uv2); - ClassDB::bind_method(D_METHOD("add_uv2", "uv"), &PropMesher2D::add_uv2); + ClassDB::bind_method(D_METHOD("get_uv2s"), &PropMesher::get_uv2s); + ClassDB::bind_method(D_METHOD("set_uv2s", "values"), &PropMesher::set_uv2s); + ClassDB::bind_method(D_METHOD("get_uv2", "idx"), &PropMesher::get_uv2); + ClassDB::bind_method(D_METHOD("add_uv2", "uv"), &PropMesher::add_uv2); - ClassDB::bind_method(D_METHOD("get_indices"), &PropMesher2D::get_indices); - ClassDB::bind_method(D_METHOD("set_indices", "values"), &PropMesher2D::set_indices); - ClassDB::bind_method(D_METHOD("get_indices_count"), &PropMesher2D::get_indices_count); - ClassDB::bind_method(D_METHOD("get_index", "idx"), &PropMesher2D::get_index); - ClassDB::bind_method(D_METHOD("remove_index", "idx"), &PropMesher2D::remove_index); - ClassDB::bind_method(D_METHOD("add_indices", "indice"), &PropMesher2D::add_indices); + ClassDB::bind_method(D_METHOD("get_indices"), &PropMesher::get_indices); + ClassDB::bind_method(D_METHOD("set_indices", "values"), &PropMesher::set_indices); + ClassDB::bind_method(D_METHOD("get_indices_count"), &PropMesher::get_indices_count); + ClassDB::bind_method(D_METHOD("get_index", "idx"), &PropMesher::get_index); + ClassDB::bind_method(D_METHOD("remove_index", "idx"), &PropMesher::remove_index); + ClassDB::bind_method(D_METHOD("add_indices", "indice"), &PropMesher::add_indices); - ClassDB::bind_method(D_METHOD("reset"), &PropMesher2D::reset); + ClassDB::bind_method(D_METHOD("reset"), &PropMesher::reset); - //ClassDB::bind_method(D_METHOD("calculate_vertex_ambient_occlusion", "meshinstance_path", "radius", "intensity", "sampleCount"), &PropMesher2D::calculate_vertex_ambient_occlusion_path); + //ClassDB::bind_method(D_METHOD("calculate_vertex_ambient_occlusion", "meshinstance_path", "radius", "intensity", "sampleCount"), &PropMesher::calculate_vertex_ambient_occlusion_path); - ClassDB::bind_method(D_METHOD("build_mesh"), &PropMesher2D::build_mesh); - ClassDB::bind_method(D_METHOD("build_mesh_into", "mesh_rid"), &PropMesher2D::build_mesh_into); - ClassDB::bind_method(D_METHOD("build_collider"), &PropMesher2D::build_collider); + ClassDB::bind_method(D_METHOD("build_mesh"), &PropMesher::build_mesh); + ClassDB::bind_method(D_METHOD("build_mesh_into", "mesh_rid"), &PropMesher::build_mesh_into); + ClassDB::bind_method(D_METHOD("build_collider"), &PropMesher::build_collider); - ClassDB::bind_method(D_METHOD("bake_colors"), &PropMesher2D::bake_colors); + ClassDB::bind_method(D_METHOD("bake_colors"), &PropMesher::bake_colors); - ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &PropMesher2D::generate_normals, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &PropMesher::generate_normals, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("remove_doubles"), &PropMesher2D::remove_doubles); - ClassDB::bind_method(D_METHOD("remove_doubles_hashed"), &PropMesher2D::remove_doubles_hashed); + ClassDB::bind_method(D_METHOD("remove_doubles"), &PropMesher::remove_doubles); + ClassDB::bind_method(D_METHOD("remove_doubles_hashed"), &PropMesher::remove_doubles_hashed); } diff --git a/prop_mesher_2d.h b/prop_mesher.h similarity index 90% rename from prop_mesher_2d.h rename to prop_mesher.h index 65a4375..c648b4a 100644 --- a/prop_mesher_2d.h +++ b/prop_mesher.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_MESHER_2D_H -#define PROP_MESHER_2D_H +#ifndef PROP_MESHER_H +#define PROP_MESHER_H #include "core/version.h" @@ -57,16 +57,16 @@ using PoolVector = Vector; #endif #ifdef TERRAMAN_PRESENT -#include "../terraman/data/terra_light.h" +#include "../terraman/data/terrain_light.h" #endif class OpenSimplexNoise; -class PropLight2D; -class PropMaterialCache2D; -class TiledWallData2D; +class PropLight; +class PropMaterialCache; +class TiledWallData; -class PropMesher2D : public Reference { - GDCLASS(PropMesher2D, Reference); +class PropMesher : public Reference { + GDCLASS(PropMesher, Reference); public: static const String BINDING_STRING_BUILD_FLAGS; @@ -145,7 +145,7 @@ public: void reset(); - void add_tiled_wall_simple(const int width, const int height, const Transform &transform, const Ref &tiled_wall_data, Ref cache); + void add_tiled_wall_simple(const int width, const int height, const Transform &transform, const Ref &tiled_wall_data, Ref cache); void add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform &transform, const Rect2 &texture_rect); Vector2 transform_uv(const Vector2 &uv, const Rect2 &rect) const; @@ -159,10 +159,10 @@ public: float get_random_ao(const Vector3 &position); Color get_light_color_at(const Vector3 &position, const Vector3 &normal); - void add_mesher(const Ref &mesher); - void _add_mesher(const Ref &mesher); + void add_mesher(const Ref &mesher); + void _add_mesher(const Ref &mesher); - void add_light(const Ref &light); + void add_light(const Ref &light); void clear_lights(); PoolVector build_collider() const; @@ -173,7 +173,7 @@ public: void bake_colors_lights(); #ifdef TERRAMAN_PRESENT - void bake_lights(MeshInstance *node, Vector> &lights); + void bake_lights(MeshInstance *node, Vector> &lights); #endif Array build_mesh(); @@ -217,8 +217,8 @@ public: void remove_index(const int idx); void add_indices(const int index); - PropMesher2D(); - ~PropMesher2D(); + PropMesher(); + ~PropMesher(); protected: static void _bind_methods(); @@ -234,7 +234,7 @@ protected: PoolVector _vertices; PoolVector _indices; - Vector> _lights; + Vector> _lights; Color _last_color; Vector3 _last_normal; @@ -258,6 +258,6 @@ protected: int _rao_seed; }; -VARIANT_ENUM_CAST(PropMesher2D::BuildFlags); +VARIANT_ENUM_CAST(PropMesher::BuildFlags); #endif diff --git a/prop_scene_instance_2d.cpp b/prop_scene_instance.cpp similarity index 62% rename from prop_scene_instance_2d.cpp rename to prop_scene_instance.cpp index b300cb9..8609a0c 100644 --- a/prop_scene_instance_2d.cpp +++ b/prop_scene_instance.cpp @@ -1,4 +1,4 @@ -#include "prop_scene_instance_2d.h" +#include "prop_scene_instance.h" #include "core/version.h" @@ -8,10 +8,10 @@ #include "core/engine.h" #endif -Ref PropSceneInstance2D::get_scene() { +Ref PropSceneInstance::get_scene() { return _scene; } -void PropSceneInstance2D::set_scene(const Ref &data) { +void PropSceneInstance::set_scene(const Ref &data) { if (_scene == data) return; @@ -20,21 +20,21 @@ void PropSceneInstance2D::set_scene(const Ref &data) { build(); } -bool PropSceneInstance2D::get_snap_to_mesh() const { +bool PropSceneInstance::get_snap_to_mesh() const { return _snap_to_mesh; } -void PropSceneInstance2D::set_snap_to_mesh(const bool value) { +void PropSceneInstance::set_snap_to_mesh(const bool value) { _snap_to_mesh = value; } -Vector3 PropSceneInstance2D::get_snap_axis() const { +Vector3 PropSceneInstance::get_snap_axis() const { return _snap_axis; } -void PropSceneInstance2D::set_snap_axis(const Vector3 &value) { +void PropSceneInstance::set_snap_axis(const Vector3 &value) { _snap_axis = value; } -void PropSceneInstance2D::build() { +void PropSceneInstance::build() { if (!is_inside_tree()) { return; } @@ -59,15 +59,15 @@ void PropSceneInstance2D::build() { // n->set_owner(get_tree()->get_edited_scene_root()); } -PropSceneInstance2D::PropSceneInstance2D() { +PropSceneInstance::PropSceneInstance() { _snap_to_mesh = false; _snap_axis = Vector3(0, -1, 0); } -PropSceneInstance2D::~PropSceneInstance2D() { +PropSceneInstance::~PropSceneInstance() { _scene.unref(); } -void PropSceneInstance2D::_notification(int p_what) { +void PropSceneInstance::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { build(); @@ -75,18 +75,18 @@ void PropSceneInstance2D::_notification(int p_what) { } } -void PropSceneInstance2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_scene"), &PropSceneInstance2D::get_scene); - ClassDB::bind_method(D_METHOD("set_scene", "value"), &PropSceneInstance2D::set_scene); +void PropSceneInstance::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_scene"), &PropSceneInstance::get_scene); + ClassDB::bind_method(D_METHOD("set_scene", "value"), &PropSceneInstance::set_scene); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene"); - ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropSceneInstance2D::get_snap_to_mesh); - ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropSceneInstance2D::set_snap_to_mesh); + ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropSceneInstance::get_snap_to_mesh); + ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropSceneInstance::set_snap_to_mesh); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropSceneInstance2D::get_snap_axis); - ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropSceneInstance2D::set_snap_axis); + ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropSceneInstance::get_snap_axis); + ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropSceneInstance::set_snap_axis); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); - ClassDB::bind_method(D_METHOD("build"), &PropSceneInstance2D::build); + ClassDB::bind_method(D_METHOD("build"), &PropSceneInstance::build); } diff --git a/prop_scene_instance_2d.h b/prop_scene_instance.h similarity index 86% rename from prop_scene_instance_2d.h rename to prop_scene_instance.h index 6c5401e..6c862c1 100644 --- a/prop_scene_instance_2d.h +++ b/prop_scene_instance.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2020 Péter Magyar +Copyright (c) 2020-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_SCENE_INSTANCE_2D_H -#define PROP_SCENE_INSTANCE_2D_H +#ifndef PROP_SCENE_INSTANCE_H +#define PROP_SCENE_INSTANCE_H #include "core/version.h" @@ -35,11 +35,11 @@ SOFTWARE. #include "core/math/vector3.h" -#include "props/prop_data_2d.h" +#include "props/prop_data.h" #include "scene/resources/packed_scene.h" -class PropSceneInstance2D : public Spatial { - GDCLASS(PropSceneInstance2D, Spatial); +class PropSceneInstance : public Spatial { + GDCLASS(PropSceneInstance, Spatial); public: Ref get_scene(); @@ -53,8 +53,8 @@ public: void build(); - PropSceneInstance2D(); - ~PropSceneInstance2D(); + PropSceneInstance(); + ~PropSceneInstance(); protected: void _notification(int p_what); diff --git a/props/prop_data_2d.cpp b/props/prop_data.cpp similarity index 59% rename from props/prop_data_2d.cpp rename to props/prop_data.cpp index ef55a8c..7015e11 100644 --- a/props/prop_data_2d.cpp +++ b/props/prop_data.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,11 +20,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_data_2d.h" +#include "prop_data.h" -#include "prop_data_entry_2d.h" -#include "prop_data_light_2d.h" -#include "prop_data_prop_2d.h" +#include "prop_data_entry.h" +#include "prop_data_light.h" +#include "prop_data_prop.h" #if VERSION_MAJOR < 4 #include "servers/physics_server.h" @@ -34,51 +34,51 @@ SOFTWARE. #define Shape Shape3D #endif -int PropData2D::get_id() const { +int PropData::get_id() const { return _id; } -void PropData2D::set_id(const int value) { +void PropData::set_id(const int value) { _id = value; } -bool PropData2D::get_snap_to_mesh() const { +bool PropData::get_snap_to_mesh() const { return _snap_to_mesh; } -void PropData2D::set_snap_to_mesh(const bool value) { +void PropData::set_snap_to_mesh(const bool value) { _snap_to_mesh = value; } -Vector3 PropData2D::get_snap_axis() const { +Vector3 PropData::get_snap_axis() const { return _snap_axis; } -void PropData2D::set_snap_axis(const Vector3 &value) { +void PropData::set_snap_axis(const Vector3 &value) { _snap_axis = value; } -Ref PropData2D::get_prop(const int index) const { - ERR_FAIL_INDEX_V(index, _props.size(), Ref()); +Ref PropData::get_prop(const int index) const { + ERR_FAIL_INDEX_V(index, _props.size(), Ref()); return _props.get(index); } -void PropData2D::set_prop(const int index, const Ref prop) { +void PropData::set_prop(const int index, const Ref prop) { ERR_FAIL_INDEX(index, _props.size()); _props.set(index, prop); } -void PropData2D::add_prop(const Ref prop) { +void PropData::add_prop(const Ref prop) { _props.push_back(prop); } -void PropData2D::remove_prop(const int index) { +void PropData::remove_prop(const int index) { ERR_FAIL_INDEX(index, _props.size()); _props.remove(index); } -int PropData2D::get_prop_count() const { +int PropData::get_prop_count() const { return _props.size(); } -Vector PropData2D::get_props() { +Vector PropData::get_props() { Vector r; for (int i = 0; i < _props.size(); i++) { #if VERSION_MAJOR < 4 @@ -89,21 +89,21 @@ Vector PropData2D::get_props() { } return r; } -void PropData2D::set_props(const Vector &props) { +void PropData::set_props(const Vector &props) { _props.clear(); for (int i = 0; i < props.size(); i++) { - Ref prop = Ref(props[i]); + Ref prop = Ref(props[i]); _props.push_back(prop); } } #if TEXTURE_PACKER_PRESENT -void PropData2D::add_textures_into(Ref texture_packer) { +void PropData::add_textures_into(Ref texture_packer) { ERR_FAIL_COND(!texture_packer.is_valid()); for (int i = 0; i < _props.size(); ++i) { - Ref entry = _props.get(i); + Ref entry = _props.get(i); if (entry.is_valid()) { entry->add_textures_into(texture_packer); @@ -112,21 +112,21 @@ void PropData2D::add_textures_into(Ref texture_packer) { } #endif -bool PropData2D::get_is_room() const { +bool PropData::get_is_room() const { return _is_room; } -void PropData2D::set_is_room(const bool value) { +void PropData::set_is_room(const bool value) { _is_room = value; } -PoolVector3Array PropData2D::get_room_bounds() { +PoolVector3Array PropData::get_room_bounds() { return _room_bounds; } -void PropData2D::set_room_bounds(const PoolVector3Array &bounds) { +void PropData::set_room_bounds(const PoolVector3Array &bounds) { _room_bounds = bounds; } -void PropData2D::copy_from(const Ref &prop_data) { +void PropData::copy_from(const Ref &prop_data) { _id = prop_data->_id; _snap_to_mesh = prop_data->_snap_to_mesh; _snap_axis = prop_data->_snap_axis; @@ -143,47 +143,47 @@ void PropData2D::copy_from(const Ref &prop_data) { emit_changed(); } -PropData2D::PropData2D() { +PropData::PropData() { _id = 0; _snap_to_mesh = false; _is_room = false; _snap_axis = Vector3(0, -1, 0); } -PropData2D::~PropData2D() { +PropData::~PropData() { _props.clear(); } -void PropData2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropData2D::get_snap_to_mesh); - ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropData2D::set_snap_to_mesh); +void PropData::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropData::get_snap_to_mesh); + ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropData::set_snap_to_mesh); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropData2D::get_snap_axis); - ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropData2D::set_snap_axis); + ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropData::get_snap_axis); + ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropData::set_snap_axis); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); - ClassDB::bind_method(D_METHOD("get_prop", "index"), &PropData2D::get_prop); - ClassDB::bind_method(D_METHOD("set_prop", "index", "spell"), &PropData2D::set_prop); - ClassDB::bind_method(D_METHOD("add_prop", "prop"), &PropData2D::add_prop); - ClassDB::bind_method(D_METHOD("remove_prop", "index"), &PropData2D::remove_prop); + ClassDB::bind_method(D_METHOD("get_prop", "index"), &PropData::get_prop); + ClassDB::bind_method(D_METHOD("set_prop", "index", "spell"), &PropData::set_prop); + ClassDB::bind_method(D_METHOD("add_prop", "prop"), &PropData::add_prop); + ClassDB::bind_method(D_METHOD("remove_prop", "index"), &PropData::remove_prop); - ClassDB::bind_method(D_METHOD("get_prop_count"), &PropData2D::get_prop_count); + ClassDB::bind_method(D_METHOD("get_prop_count"), &PropData::get_prop_count); - ClassDB::bind_method(D_METHOD("get_props"), &PropData2D::get_props); - ClassDB::bind_method(D_METHOD("set_props", "props"), &PropData2D::set_props); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "17/17:PropDataEntry2D", PROPERTY_USAGE_DEFAULT, "PropDataEntry2D"), "set_props", "get_props"); + ClassDB::bind_method(D_METHOD("get_props"), &PropData::get_props); + ClassDB::bind_method(D_METHOD("set_props", "props"), &PropData::set_props); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "17/17:PropDataEntry", PROPERTY_USAGE_DEFAULT, "PropDataEntry"), "set_props", "get_props"); #if TEXTURE_PACKER_PRESENT - ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropData2D::add_textures_into); + ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropData::add_textures_into); #endif - ClassDB::bind_method(D_METHOD("get_is_room"), &PropData2D::get_is_room); - ClassDB::bind_method(D_METHOD("set_is_room", "value"), &PropData2D::set_is_room); + ClassDB::bind_method(D_METHOD("get_is_room"), &PropData::get_is_room); + ClassDB::bind_method(D_METHOD("set_is_room", "value"), &PropData::set_is_room); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_room"), "set_is_room", "get_is_room"); - ClassDB::bind_method(D_METHOD("get_room_bounds"), &PropData2D::get_room_bounds); - ClassDB::bind_method(D_METHOD("set_room_bounds", "value"), &PropData2D::set_room_bounds); + ClassDB::bind_method(D_METHOD("get_room_bounds"), &PropData::get_room_bounds); + ClassDB::bind_method(D_METHOD("set_room_bounds", "value"), &PropData::set_room_bounds); ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY, "room_bounds"), "set_room_bounds", "get_room_bounds"); - ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &PropData2D::copy_from); + ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &PropData::copy_from); } diff --git a/props/prop_data_2d.h b/props/prop_data.h similarity index 79% rename from props/prop_data_2d.h rename to props/prop_data.h index 9113a1a..f5ff102 100644 --- a/props/prop_data_2d.h +++ b/props/prop_data.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,34 +20,38 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_DATA_2D_H -#define PROP_DATA_2D_H +#ifndef PROP_DATA_H +#define PROP_DATA_H #include "core/version.h" #if VERSION_MAJOR > 3 -#include "core/object/reference.h" +#include "core/object/ref_counted.h" +#ifndef Reference +#define Reference RefCounted +#endif +#include "core/math/transform_3d.h" #include "core/templates/vector.h" #else #include "core/reference.h" #include "core/vector.h" +#include "core/math/transform.h" #endif #include "core/math/rect2.h" -#include "core/math/transform.h" #include "core/math/vector2.h" #include "core/math/vector3.h" #include "core/version.h" -#include "prop_data_entry_2d.h" +#include "prop_data_entry.h" #if TEXTURE_PACKER_PRESENT #include "../../texture_packer/texture_packer.h" #endif -class PropData2D : public Resource { - GDCLASS(PropData2D, Resource); +class PropData : public Resource { + GDCLASS(PropData, Resource); public: int get_id() const; @@ -59,9 +63,9 @@ public: Vector3 get_snap_axis() const; void set_snap_axis(const Vector3 &value); - Ref get_prop(const int index) const; - void set_prop(const int index, const Ref prop); - void add_prop(const Ref prop); + Ref get_prop(const int index) const; + void set_prop(const int index, const Ref prop); + void add_prop(const Ref prop); void remove_prop(const int index); int get_prop_count() const; @@ -79,10 +83,10 @@ public: PoolVector3Array get_room_bounds(); void set_room_bounds(const PoolVector3Array &bounds); - void copy_from(const Ref &prop_data); + void copy_from(const Ref &prop_data); - PropData2D(); - ~PropData2D(); + PropData(); + ~PropData(); protected: static void _bind_methods(); @@ -92,7 +96,7 @@ private: bool _snap_to_mesh; Vector3 _snap_axis; - Vector> _props; + Vector> _props; bool _is_room; PoolVector3Array _room_bounds; diff --git a/props/prop_data_entry_2d.cpp b/props/prop_data_entry.cpp similarity index 66% rename from props/prop_data_entry_2d.cpp rename to props/prop_data_entry.cpp index e8263e3..3843361 100644 --- a/props/prop_data_entry_2d.cpp +++ b/props/prop_data_entry.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,9 +20,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_data_entry_2d.h" +#include "prop_data_entry.h" -#include "prop_data_2d.h" +#include "prop_data.h" #include "core/version.h" @@ -38,66 +38,66 @@ SOFTWARE. #endif -#include "../prop_mesher_2d.h" +#include "../prop_mesher.h" -Transform PropDataEntry2D::get_transform() const { +Transform PropDataEntry::get_transform() const { return _transform; } -void PropDataEntry2D::set_transform(const Transform &value) { +void PropDataEntry::set_transform(const Transform &value) { _transform = value; } #if TEXTURE_PACKER_PRESENT -void PropDataEntry2D::add_textures_into(Ref texture_packer) { +void PropDataEntry::add_textures_into(Ref texture_packer) { if (has_method("_add_textures_into")) call("_add_textures_into", texture_packer); } #endif -bool PropDataEntry2D::processor_handles(Node *node) { +bool PropDataEntry::processor_handles(Node *node) { return call("_processor_handles", node); } -void PropDataEntry2D::processor_process(Ref prop_data, Node *node, const Transform &transform) { +void PropDataEntry::processor_process(Ref prop_data, Node *node, const Transform &transform) { call("_processor_process", prop_data, node, transform); } -Node *PropDataEntry2D::processor_get_node_for(const Transform &transform) { +Node *PropDataEntry::processor_get_node_for(const Transform &transform) { return call("_processor_get_node_for", transform); } -bool PropDataEntry2D::processor_evaluate_children() { +bool PropDataEntry::processor_evaluate_children() { return call("_processor_evaluate_children"); } -bool PropDataEntry2D::_processor_handles(Node *node) { +bool PropDataEntry::_processor_handles(Node *node) { return false; } -void PropDataEntry2D::_processor_process(Ref prop_data, Node *node, const Transform &transform) { +void PropDataEntry::_processor_process(Ref prop_data, Node *node, const Transform &transform) { } -Node *PropDataEntry2D::_processor_get_node_for(const Transform &transform) { +Node *PropDataEntry::_processor_get_node_for(const Transform &transform) { return NULL; } -bool PropDataEntry2D::_processor_evaluate_children() { +bool PropDataEntry::_processor_evaluate_children() { return true; } -PropDataEntry2D::PropDataEntry2D() { +PropDataEntry::PropDataEntry() { } -PropDataEntry2D::~PropDataEntry2D() { +PropDataEntry::~PropDataEntry() { } -void PropDataEntry2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_transform"), &PropDataEntry2D::get_transform); - ClassDB::bind_method(D_METHOD("set_transform", "value"), &PropDataEntry2D::set_transform); +void PropDataEntry::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_transform"), &PropDataEntry::get_transform); + ClassDB::bind_method(D_METHOD("set_transform", "value"), &PropDataEntry::set_transform); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform"); #if TEXTURE_PACKER_PRESENT BIND_VMETHOD(MethodInfo("_add_textures_into", PropertyInfo(Variant::OBJECT, "texture_packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker"))); - ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropDataEntry2D::add_textures_into); + ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropDataEntry::add_textures_into); #endif BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "handles"), "_processor_handles")); BIND_VMETHOD(MethodInfo("_processor_process", - PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D"), + PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::TRANSFORM, "transform"))); @@ -106,14 +106,14 @@ void PropDataEntry2D::_bind_methods() { BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "evaluate"), "_processor_evaluate_children")); - ClassDB::bind_method(D_METHOD("processor_handles", "node"), &PropDataEntry2D::processor_handles); - ClassDB::bind_method(D_METHOD("processor_process", "prop_data", "node", "transform"), &PropDataEntry2D::processor_process); - ClassDB::bind_method(D_METHOD("processor_get_node_for", "prop_data"), &PropDataEntry2D::processor_get_node_for); - ClassDB::bind_method(D_METHOD("processor_evaluate_children"), &PropDataEntry2D::processor_evaluate_children); + ClassDB::bind_method(D_METHOD("processor_handles", "node"), &PropDataEntry::processor_handles); + ClassDB::bind_method(D_METHOD("processor_process", "prop_data", "node", "transform"), &PropDataEntry::processor_process); + ClassDB::bind_method(D_METHOD("processor_get_node_for", "prop_data"), &PropDataEntry::processor_get_node_for); + ClassDB::bind_method(D_METHOD("processor_evaluate_children"), &PropDataEntry::processor_evaluate_children); - ClassDB::bind_method(D_METHOD("_processor_handles", "node"), &PropDataEntry2D::_processor_handles); - ClassDB::bind_method(D_METHOD("_processor_process", "prop_data", "node", "transform"), &PropDataEntry2D::_processor_process); - ClassDB::bind_method(D_METHOD("_processor_get_node_for", "transform"), &PropDataEntry2D::_processor_get_node_for); - ClassDB::bind_method(D_METHOD("_processor_evaluate_children"), &PropDataEntry2D::_processor_evaluate_children); + ClassDB::bind_method(D_METHOD("_processor_handles", "node"), &PropDataEntry::_processor_handles); + ClassDB::bind_method(D_METHOD("_processor_process", "prop_data", "node", "transform"), &PropDataEntry::_processor_process); + ClassDB::bind_method(D_METHOD("_processor_get_node_for", "transform"), &PropDataEntry::_processor_get_node_for); + ClassDB::bind_method(D_METHOD("_processor_evaluate_children"), &PropDataEntry::_processor_evaluate_children); } diff --git a/props/prop_data_entry_2d.h b/props/prop_data_entry.h similarity index 77% rename from props/prop_data_entry_2d.h rename to props/prop_data_entry.h index 131db73..ceeafa7 100644 --- a/props/prop_data_entry_2d.h +++ b/props/prop_data_entry.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,25 +20,29 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_DATA_DATA_2D_H -#define PROP_DATA_DATA_2D_H +#ifndef PROP_DATA_DATA_H +#define PROP_DATA_DATA_H #include "core/version.h" #if VERSION_MAJOR > 3 #include "core/io/resource.h" +#include "core/math/transform_3d.h" + +#ifndef Transform +#define Transform Transform3D +#endif #else #include "core/resource.h" +#include "core/math/transform.h" #endif -#include "core/math/transform.h" - -class PropData2D; -class PropMesher2D; +class PropData; +class PropMesher; class TexturePacker; -class PropDataEntry2D : public Resource { - GDCLASS(PropDataEntry2D, Resource); +class PropDataEntry : public Resource { + GDCLASS(PropDataEntry, Resource); public: Transform get_transform() const; @@ -49,17 +53,17 @@ public: #endif bool processor_handles(Node *node); - void processor_process(Ref prop_data, Node *node, const Transform &transform); + void processor_process(Ref prop_data, Node *node, const Transform &transform); Node *processor_get_node_for(const Transform &transform); bool processor_evaluate_children(); virtual bool _processor_handles(Node *node); - virtual void _processor_process(Ref prop_data, Node *node, const Transform &transform); + virtual void _processor_process(Ref prop_data, Node *node, const Transform &transform); virtual Node *_processor_get_node_for(const Transform &transform); virtual bool _processor_evaluate_children(); - PropDataEntry2D(); - ~PropDataEntry2D(); + PropDataEntry(); + ~PropDataEntry(); protected: static void _bind_methods(); diff --git a/props/prop_data_light_2d.cpp b/props/prop_data_light.cpp similarity index 73% rename from props/prop_data_light_2d.cpp rename to props/prop_data_light.cpp index 2ad9559..e2b61e7 100644 --- a/props/prop_data_light_2d.cpp +++ b/props/prop_data_light.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,9 +20,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_data_light_2d.h" +#include "prop_data_light.h" -#include "prop_data_2d.h" +#include "prop_data.h" #if VERSION_MAJOR < 4 #include "scene/3d/light.h" @@ -32,32 +32,32 @@ SOFTWARE. #define Light Light3D #endif -Color PropDataLight2D::get_light_color() const { +Color PropDataLight::get_light_color() const { return _light_color; } -void PropDataLight2D::set_light_color(const Color value) { +void PropDataLight::set_light_color(const Color value) { _light_color = value; } -int PropDataLight2D::get_light_size() const { +int PropDataLight::get_light_size() const { return _light_size; } -void PropDataLight2D::set_light_size(const int value) { +void PropDataLight::set_light_size(const int value) { _light_size = value; } -bool PropDataLight2D::_processor_handles(Node *node) { +bool PropDataLight::_processor_handles(Node *node) { OmniLight *i = Object::cast_to(node); return i; } -void PropDataLight2D::_processor_process(Ref prop_data, Node *node, const Transform &transform) { +void PropDataLight::_processor_process(Ref prop_data, Node *node, const Transform &transform) { OmniLight *i = Object::cast_to(node); ERR_FAIL_COND(!i); - Ref l; + Ref l; l.instance(); l->set_light_color(i->get_color()); l->set_light_size(i->get_param(Light::PARAM_RANGE)); @@ -65,7 +65,7 @@ void PropDataLight2D::_processor_process(Ref prop_data, Node *node, prop_data->add_prop(l); } -Node *PropDataLight2D::_processor_get_node_for(const Transform &transform) { +Node *PropDataLight::_processor_get_node_for(const Transform &transform) { OmniLight *i = memnew(OmniLight); i->set_color(get_light_color()); @@ -75,18 +75,18 @@ Node *PropDataLight2D::_processor_get_node_for(const Transform &transform) { return i; } -PropDataLight2D::PropDataLight2D() { +PropDataLight::PropDataLight() { _light_size = 0; } -PropDataLight2D::~PropDataLight2D() { +PropDataLight::~PropDataLight() { } -void PropDataLight2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_light_color"), &PropDataLight2D::get_light_color); - ClassDB::bind_method(D_METHOD("set_light_color", "value"), &PropDataLight2D::set_light_color); +void PropDataLight::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_light_color"), &PropDataLight::get_light_color); + ClassDB::bind_method(D_METHOD("set_light_color", "value"), &PropDataLight::set_light_color); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color"), "set_light_color", "get_light_color"); - ClassDB::bind_method(D_METHOD("get_light_size"), &PropDataLight2D::get_light_size); - ClassDB::bind_method(D_METHOD("set_light_size", "value"), &PropDataLight2D::set_light_size); + ClassDB::bind_method(D_METHOD("get_light_size"), &PropDataLight::get_light_size); + ClassDB::bind_method(D_METHOD("set_light_size", "value"), &PropDataLight::set_light_size); ADD_PROPERTY(PropertyInfo(Variant::INT, "light_size"), "set_light_size", "get_light_size"); } diff --git a/props/prop_data_light_2d.h b/props/prop_data_light.h similarity index 80% rename from props/prop_data_light_2d.h rename to props/prop_data_light.h index ce058cb..bbd3588 100644 --- a/props/prop_data_light_2d.h +++ b/props/prop_data_light.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_DATA_LIGHT_2D_H -#define PROP_DATA_LIGHT_2D_H +#ifndef PROP_DATA_LIGHT_H +#define PROP_DATA_LIGHT_H #include "core/version.h" @@ -31,10 +31,10 @@ SOFTWARE. #include "core/color.h" #endif -#include "prop_data_entry_2d.h" +#include "prop_data_entry.h" -class PropDataLight2D : public PropDataEntry2D { - GDCLASS(PropDataLight2D, PropDataEntry2D); +class PropDataLight : public PropDataEntry { + GDCLASS(PropDataLight, PropDataEntry); public: Color get_light_color() const; @@ -44,11 +44,11 @@ public: void set_light_size(const int value); bool _processor_handles(Node *node); - void _processor_process(Ref prop_data, Node *node, const Transform &transform); + void _processor_process(Ref prop_data, Node *node, const Transform &transform); Node *_processor_get_node_for(const Transform &transform); - PropDataLight2D(); - ~PropDataLight2D(); + PropDataLight(); + ~PropDataLight(); protected: static void _bind_methods(); diff --git a/props/prop_data_portal_2d.cpp b/props/prop_data_portal.cpp similarity index 69% rename from props/prop_data_portal_2d.cpp rename to props/prop_data_portal.cpp index 3c0c16c..538d13d 100644 --- a/props/prop_data_portal_2d.cpp +++ b/props/prop_data_portal.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,59 +20,59 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_data_portal_2d.h" +#include "prop_data_portal.h" -#include "prop_data_2d.h" +#include "prop_data.h" #include "scene/3d/portal.h" -bool PropDataPortal2D::get_is_active() const { +bool PropDataPortal::get_is_active() const { return _is_active; } -void PropDataPortal2D::set_is_active(bool p_active) { +void PropDataPortal::set_is_active(bool p_active) { _is_active = p_active; } -bool PropDataPortal2D::get_is_two_way() const { +bool PropDataPortal::get_is_two_way() const { return _is_two_way; } -void PropDataPortal2D::set_is_two_way(bool p_two_way) { +void PropDataPortal::set_is_two_way(bool p_two_way) { _is_two_way = p_two_way; } -bool PropDataPortal2D::get_use_default_margin() const { +bool PropDataPortal::get_use_default_margin() const { return _use_default_margin; } -void PropDataPortal2D::set_use_default_margin(bool p_use) { +void PropDataPortal::set_use_default_margin(bool p_use) { _use_default_margin = p_use; } -real_t PropDataPortal2D::get_portal_margin() const { +real_t PropDataPortal::get_portal_margin() const { return _portal_margin; } -void PropDataPortal2D::set_portal_margin(real_t p_margin) { +void PropDataPortal::set_portal_margin(real_t p_margin) { _portal_margin = p_margin; } -PoolVector PropDataPortal2D::get_points() const { +PoolVector PropDataPortal::get_points() const { return _points; } -void PropDataPortal2D::set_points(const PoolVector &p_points) { +void PropDataPortal::set_points(const PoolVector &p_points) { _points = p_points; } -bool PropDataPortal2D::_processor_handles(Node *node) { +bool PropDataPortal::_processor_handles(Node *node) { Portal *p = Object::cast_to(node); return p; } -void PropDataPortal2D::_processor_process(Ref prop_data, Node *node, const Transform &transform) { +void PropDataPortal::_processor_process(Ref prop_data, Node *node, const Transform &transform) { Portal *p = Object::cast_to(node); ERR_FAIL_COND(!p); - Ref l; + Ref l; l.instance(); l->set_is_active(p->get_portal_active()); l->set_is_two_way(p->is_two_way()); @@ -84,7 +84,7 @@ void PropDataPortal2D::_processor_process(Ref prop_data, Node *node, prop_data->add_prop(l); } -Node *PropDataPortal2D::_processor_get_node_for(const Transform &transform) { +Node *PropDataPortal::_processor_get_node_for(const Transform &transform) { Portal *p = memnew(Portal); p->set_portal_active(get_is_active()); @@ -98,33 +98,33 @@ Node *PropDataPortal2D::_processor_get_node_for(const Transform &transform) { return p; } -PropDataPortal2D::PropDataPortal2D() { +PropDataPortal::PropDataPortal() { _is_active = true; _is_two_way = true; _use_default_margin = true; _portal_margin = 1; } -PropDataPortal2D::~PropDataPortal2D() { +PropDataPortal::~PropDataPortal() { } -void PropDataPortal2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_is_active"), &PropDataPortal2D::get_is_active); - ClassDB::bind_method(D_METHOD("set_is_active", "value"), &PropDataPortal2D::set_is_active); +void PropDataPortal::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_is_active"), &PropDataPortal::get_is_active); + ClassDB::bind_method(D_METHOD("set_is_active", "value"), &PropDataPortal::set_is_active); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_active"), "set_is_active", "get_is_active"); - ClassDB::bind_method(D_METHOD("get_is_two_way"), &PropDataPortal2D::get_is_two_way); - ClassDB::bind_method(D_METHOD("set_is_two_way", "value"), &PropDataPortal2D::set_is_two_way); + ClassDB::bind_method(D_METHOD("get_is_two_way"), &PropDataPortal::get_is_two_way); + ClassDB::bind_method(D_METHOD("set_is_two_way", "value"), &PropDataPortal::set_is_two_way); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_two_way"), "set_is_two_way", "get_is_two_way"); - ClassDB::bind_method(D_METHOD("get_use_default_margin"), &PropDataPortal2D::get_use_default_margin); - ClassDB::bind_method(D_METHOD("set_use_default_margin", "value"), &PropDataPortal2D::set_use_default_margin); + ClassDB::bind_method(D_METHOD("get_use_default_margin"), &PropDataPortal::get_use_default_margin); + ClassDB::bind_method(D_METHOD("set_use_default_margin", "value"), &PropDataPortal::set_use_default_margin); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_default_margin"), "set_use_default_margin", "get_use_default_margin"); - ClassDB::bind_method(D_METHOD("get_portal_margin"), &PropDataPortal2D::get_portal_margin); - ClassDB::bind_method(D_METHOD("set_portal_margin", "value"), &PropDataPortal2D::set_portal_margin); + ClassDB::bind_method(D_METHOD("get_portal_margin"), &PropDataPortal::get_portal_margin); + ClassDB::bind_method(D_METHOD("set_portal_margin", "value"), &PropDataPortal::set_portal_margin); ADD_PROPERTY(PropertyInfo(Variant::REAL, "portal_margin"), "set_portal_margin", "get_portal_margin"); - ClassDB::bind_method(D_METHOD("get_points"), &PropDataPortal2D::get_points); - ClassDB::bind_method(D_METHOD("set_points", "value"), &PropDataPortal2D::set_points); + ClassDB::bind_method(D_METHOD("get_points"), &PropDataPortal::get_points); + ClassDB::bind_method(D_METHOD("set_points", "value"), &PropDataPortal::set_points); ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "points"), "set_points", "get_points"); } diff --git a/props/prop_data_portal_2d.h b/props/prop_data_portal.h similarity index 82% rename from props/prop_data_portal_2d.h rename to props/prop_data_portal.h index f3c1212..66469ea 100644 --- a/props/prop_data_portal_2d.h +++ b/props/prop_data_portal.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,15 +20,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_DATA_PORTAL_2D_H -#define PROP_DATA_PORTAL_2D_H +#ifndef PROP_DATA_PORTAL_H +#define PROP_DATA_PORTAL_H #include "core/version.h" -#include "prop_data_entry_2d.h" +#include "prop_data_entry.h" -class PropDataPortal2D : public PropDataEntry2D { - GDCLASS(PropDataPortal2D, PropDataEntry2D); +class PropDataPortal : public PropDataEntry { + GDCLASS(PropDataPortal, PropDataEntry); public: bool get_is_active() const; @@ -47,11 +47,11 @@ public: void set_points(const PoolVector &p_points); bool _processor_handles(Node *node); - void _processor_process(Ref prop_data, Node *node, const Transform &transform); + void _processor_process(Ref prop_data, Node *node, const Transform &transform); Node *_processor_get_node_for(const Transform &transform); - PropDataPortal2D(); - ~PropDataPortal2D(); + PropDataPortal(); + ~PropDataPortal(); protected: static void _bind_methods(); diff --git a/props/prop_data_prop_2d.cpp b/props/prop_data_prop.cpp similarity index 61% rename from props/prop_data_prop_2d.cpp rename to props/prop_data_prop.cpp index c4c00ab..10317b8 100644 --- a/props/prop_data_prop_2d.cpp +++ b/props/prop_data_prop.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,60 +20,60 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_data_prop_2d.h" +#include "prop_data_prop.h" -#include "../prop_instance_2d.h" -#include "prop_data_2d.h" +#include "../prop_instance.h" +#include "prop_data.h" -Ref PropDataProp2D::get_prop() const { +Ref PropDataProp::get_prop() const { return _prop; } -void PropDataProp2D::set_prop(const Ref value) { +void PropDataProp::set_prop(const Ref value) { _prop = value; } -bool PropDataProp2D::get_snap_to_mesh() { +bool PropDataProp::get_snap_to_mesh() { return _snap_to_mesh; } -void PropDataProp2D::set_snap_to_mesh(bool value) { +void PropDataProp::set_snap_to_mesh(bool value) { _snap_to_mesh = value; } -Vector3 PropDataProp2D::get_snap_axis() { +Vector3 PropDataProp::get_snap_axis() { return _snap_axis; } -void PropDataProp2D::set_snap_axis(Vector3 value) { +void PropDataProp::set_snap_axis(Vector3 value) { _snap_axis = value; } #if TEXTURE_PACKER_PRESENT -void PropDataProp2D::_add_textures_into(Ref texture_packer) { +void PropDataProp::_add_textures_into(Ref texture_packer) { if (get_prop().is_valid()) { get_prop()->add_textures_into(texture_packer); } } #endif -bool PropDataProp2D::_processor_handles(Node *node) { - PropInstance2D *i = Object::cast_to(node); +bool PropDataProp::_processor_handles(Node *node) { + PropInstance *i = Object::cast_to(node); return i; } -void PropDataProp2D::_processor_process(Ref prop_data, Node *node, const Transform &transform) { - PropInstance2D *i = Object::cast_to(node); +void PropDataProp::_processor_process(Ref prop_data, Node *node, const Transform &transform) { + PropInstance *i = Object::cast_to(node); ERR_FAIL_COND(!i); - Ref l; + Ref l; l.instance(); l->set_prop(i->get_prop_data()); l->set_transform(transform * i->get_transform()); prop_data->add_prop(l); } -Node *PropDataProp2D::_processor_get_node_for(const Transform &transform) { - PropInstance2D *i = memnew(PropInstance2D); +Node *PropDataProp::_processor_get_node_for(const Transform &transform) { + PropInstance *i = memnew(PropInstance); i->set_prop_data(get_prop()); i->set_transform(get_transform()); @@ -81,29 +81,29 @@ Node *PropDataProp2D::_processor_get_node_for(const Transform &transform) { return i; } -PropDataProp2D::PropDataProp2D() { +PropDataProp::PropDataProp() { _snap_to_mesh = false; _snap_axis = Vector3(0, 1, 0); } -PropDataProp2D::~PropDataProp2D() { +PropDataProp::~PropDataProp() { if (_prop.is_valid()) _prop.unref(); } -void PropDataProp2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_prop"), &PropDataProp2D::get_prop); - ClassDB::bind_method(D_METHOD("set_prop", "value"), &PropDataProp2D::set_prop); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D"), "set_prop", "get_prop"); +void PropDataProp::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_prop"), &PropDataProp::get_prop); + ClassDB::bind_method(D_METHOD("set_prop", "value"), &PropDataProp::set_prop); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop", "get_prop"); - ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataProp2D::get_snap_to_mesh); - ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataProp2D::set_snap_to_mesh); + ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataProp::get_snap_to_mesh); + ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataProp::set_snap_to_mesh); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropDataProp2D::get_snap_axis); - ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataProp2D::set_snap_axis); + ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropDataProp::get_snap_axis); + ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataProp::set_snap_axis); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); #if TEXTURE_PACKER_PRESENT - ClassDB::bind_method(D_METHOD("_add_textures_into", "texture_packer"), &PropDataProp2D::_add_textures_into); + ClassDB::bind_method(D_METHOD("_add_textures_into", "texture_packer"), &PropDataProp::_add_textures_into); #endif } diff --git a/props/prop_data_prop_2d.h b/props/prop_data_prop.h similarity index 76% rename from props/prop_data_prop_2d.h rename to props/prop_data_prop.h index b3a5b35..66be634 100644 --- a/props/prop_data_prop_2d.h +++ b/props/prop_data_prop.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,24 +20,24 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_DATA_PROP_2D_H -#define PROP_DATA_PROP_2D_H +#ifndef PROP_DATA_PROP_H +#define PROP_DATA_PROP_H #include "core/math/vector3.h" -#include "prop_data_entry_2d.h" +#include "prop_data_entry.h" -#include "prop_data_2d.h" +#include "prop_data.h" #if TEXTURE_PACKER_PRESENT #include "../../texture_packer/texture_packer.h" #endif -class PropDataProp2D : public PropDataEntry2D { - GDCLASS(PropDataProp2D, PropDataEntry2D); +class PropDataProp : public PropDataEntry { + GDCLASS(PropDataProp, PropDataEntry); public: - Ref get_prop() const; - void set_prop(const Ref value); + Ref get_prop() const; + void set_prop(const Ref value); bool get_snap_to_mesh(); void set_snap_to_mesh(bool value); @@ -50,11 +50,11 @@ public: #endif bool _processor_handles(Node *node); - void _processor_process(Ref prop_data, Node *node, const Transform &transform); + void _processor_process(Ref prop_data, Node *node, const Transform &transform); Node *_processor_get_node_for(const Transform &transform); - PropDataProp2D(); - ~PropDataProp2D(); + PropDataProp(); + ~PropDataProp(); protected: static void _bind_methods(); @@ -62,7 +62,7 @@ protected: private: bool _snap_to_mesh; Vector3 _snap_axis; - Ref _prop; + Ref _prop; }; #endif diff --git a/props/prop_data_scene_2d.cpp b/props/prop_data_scene.cpp similarity index 62% rename from props/prop_data_scene_2d.cpp rename to props/prop_data_scene.cpp index 37c30d8..ea814d9 100644 --- a/props/prop_data_scene_2d.cpp +++ b/props/prop_data_scene.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,52 +20,52 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_data_scene_2d.h" +#include "prop_data_scene.h" -#include "../prop_scene_instance_2d.h" -#include "prop_data_2d.h" +#include "../prop_scene_instance.h" +#include "prop_data.h" -Ref PropDataScene2D::get_scene() { +Ref PropDataScene::get_scene() { return _scene; } -void PropDataScene2D::set_scene(const Ref &value) { +void PropDataScene::set_scene(const Ref &value) { _scene = value; } -bool PropDataScene2D::get_snap_to_mesh() { +bool PropDataScene::get_snap_to_mesh() { return _snap_to_mesh; } -void PropDataScene2D::set_snap_to_mesh(bool value) { +void PropDataScene::set_snap_to_mesh(bool value) { _snap_to_mesh = value; } -Vector3 PropDataScene2D::get_snap_axis() { +Vector3 PropDataScene::get_snap_axis() { return _snap_axis; } -void PropDataScene2D::set_snap_axis(Vector3 value) { +void PropDataScene::set_snap_axis(Vector3 value) { _snap_axis = value; } -bool PropDataScene2D::_processor_handles(Node *node) { - PropSceneInstance2D *i = Object::cast_to(node); +bool PropDataScene::_processor_handles(Node *node) { + PropSceneInstance *i = Object::cast_to(node); return i; } -void PropDataScene2D::_processor_process(Ref prop_data, Node *node, const Transform &transform) { - PropSceneInstance2D *i = Object::cast_to(node); +void PropDataScene::_processor_process(Ref prop_data, Node *node, const Transform &transform) { + PropSceneInstance *i = Object::cast_to(node); ERR_FAIL_COND(!i); - Ref l; + Ref l; l.instance(); l->set_scene(i->get_scene()); l->set_transform(transform * i->get_transform()); prop_data->add_prop(l); } -Node *PropDataScene2D::_processor_get_node_for(const Transform &transform) { - PropSceneInstance2D *i = memnew(PropSceneInstance2D); +Node *PropDataScene::_processor_get_node_for(const Transform &transform) { + PropSceneInstance *i = memnew(PropSceneInstance); i->set_scene(get_scene()); i->set_transform(get_transform()); @@ -73,25 +73,25 @@ Node *PropDataScene2D::_processor_get_node_for(const Transform &transform) { return i; } -PropDataScene2D::PropDataScene2D() { +PropDataScene::PropDataScene() { _snap_to_mesh = true; _snap_axis = Vector3(0, 1, 0); } -PropDataScene2D::~PropDataScene2D() { +PropDataScene::~PropDataScene() { if (_scene.is_valid()) _scene.unref(); } -void PropDataScene2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_scene"), &PropDataScene2D::get_scene); - ClassDB::bind_method(D_METHOD("set_scene", "value"), &PropDataScene2D::set_scene); +void PropDataScene::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_scene"), &PropDataScene::get_scene); + ClassDB::bind_method(D_METHOD("set_scene", "value"), &PropDataScene::set_scene); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene"); - ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataScene2D::get_snap_to_mesh); - ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataScene2D::set_snap_to_mesh); + ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataScene::get_snap_to_mesh); + ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataScene::set_snap_to_mesh); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropDataScene2D::get_snap_axis); - ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataScene2D::set_snap_axis); + ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropDataScene::get_snap_axis); + ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataScene::set_snap_axis); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); } diff --git a/props/prop_data_scene_2d.h b/props/prop_data_scene.h similarity index 81% rename from props/prop_data_scene_2d.h rename to props/prop_data_scene.h index 46ddcb7..69dd410 100644 --- a/props/prop_data_scene_2d.h +++ b/props/prop_data_scene.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,16 +20,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_DATA_SCENE_2D_H -#define PROP_DATA_SCENE_2D_H +#ifndef PROP_DATA_SCENE_H +#define PROP_DATA_SCENE_H #include "core/math/vector3.h" -#include "prop_data_entry_2d.h" +#include "prop_data_entry.h" #include "scene/resources/packed_scene.h" -class PropDataScene2D : public PropDataEntry2D { - GDCLASS(PropDataScene2D, PropDataEntry2D); +class PropDataScene : public PropDataEntry { + GDCLASS(PropDataScene, PropDataEntry); public: Ref get_scene(); @@ -42,11 +42,11 @@ public: void set_snap_axis(Vector3 value); bool _processor_handles(Node *node); - void _processor_process(Ref prop_data, Node *node, const Transform &transform); + void _processor_process(Ref prop_data, Node *node, const Transform &transform); Node *_processor_get_node_for(const Transform &transform); - PropDataScene2D(); - ~PropDataScene2D(); + PropDataScene(); + ~PropDataScene(); protected: static void _bind_methods(); diff --git a/props/prop_data_tiled_wall_2d.cpp b/props/prop_data_tiled_wall.cpp similarity index 60% rename from props/prop_data_tiled_wall_2d.cpp rename to props/prop_data_tiled_wall.cpp index 3abe9be..71fd130 100644 --- a/props/prop_data_tiled_wall_2d.cpp +++ b/props/prop_data_tiled_wall.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,53 +20,53 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_data_tiled_wall_2d.h" +#include "prop_data_tiled_wall.h" -#include "../tiled_wall/tiled_wall_2d.h" -#include "../tiled_wall/tiled_wall_data_2d.h" +#include "../tiled_wall/tiled_wall.h" +#include "../tiled_wall/tiled_wall_data.h" -#include "prop_data_2d.h" +#include "prop_data.h" -int PropDataTiledWall2D::get_width() const { +int PropDataTiledWall::get_width() const { return _width; } -void PropDataTiledWall2D::set_width(const int value) { +void PropDataTiledWall::set_width(const int value) { _width = value; } -int PropDataTiledWall2D::get_heigth() const { +int PropDataTiledWall::get_heigth() const { return _height; } -void PropDataTiledWall2D::set_heigth(const int value) { +void PropDataTiledWall::set_heigth(const int value) { _height = value; } -Ref PropDataTiledWall2D::get_data() { +Ref PropDataTiledWall::get_data() { return _data; } -void PropDataTiledWall2D::set_data(const Ref &data) { +void PropDataTiledWall::set_data(const Ref &data) { _data = data; } -bool PropDataTiledWall2D::get_collision() const { +bool PropDataTiledWall::get_collision() const { return _collision; } -void PropDataTiledWall2D::set_collision(const int value) { +void PropDataTiledWall::set_collision(const int value) { _collision = value; } -bool PropDataTiledWall2D::_processor_handles(Node *node) { - TiledWall2D *t = Object::cast_to(node); +bool PropDataTiledWall::_processor_handles(Node *node) { + TiledWall *t = Object::cast_to(node); return t; } -void PropDataTiledWall2D::_processor_process(Ref prop_data, Node *node, const Transform &transform) { - TiledWall2D *t = Object::cast_to(node); +void PropDataTiledWall::_processor_process(Ref prop_data, Node *node, const Transform &transform) { + TiledWall *t = Object::cast_to(node); ERR_FAIL_COND(!t); - Ref tw; + Ref tw; tw.instance(); tw->set_width(t->get_width()); @@ -77,8 +77,8 @@ void PropDataTiledWall2D::_processor_process(Ref prop_data, Node *no prop_data->add_prop(tw); } -Node *PropDataTiledWall2D::_processor_get_node_for(const Transform &transform) { - TiledWall2D *t = memnew(TiledWall2D); +Node *PropDataTiledWall::_processor_get_node_for(const Transform &transform) { + TiledWall *t = memnew(TiledWall); t->set_width(get_width()); t->set_heigth(get_heigth()); @@ -89,29 +89,29 @@ Node *PropDataTiledWall2D::_processor_get_node_for(const Transform &transform) { return t; } -PropDataTiledWall2D::PropDataTiledWall2D() { +PropDataTiledWall::PropDataTiledWall() { _width = 1; _height = 1; _collision = true; } -PropDataTiledWall2D::~PropDataTiledWall2D() { +PropDataTiledWall::~PropDataTiledWall() { _data.unref(); } -void PropDataTiledWall2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_width"), &PropDataTiledWall2D::get_width); - ClassDB::bind_method(D_METHOD("set_width", "value"), &PropDataTiledWall2D::set_width); +void PropDataTiledWall::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_width"), &PropDataTiledWall::get_width); + ClassDB::bind_method(D_METHOD("set_width", "value"), &PropDataTiledWall::set_width); ADD_PROPERTY(PropertyInfo(Variant::INT, "width"), "set_width", "get_width"); - ClassDB::bind_method(D_METHOD("get_heigth"), &PropDataTiledWall2D::get_heigth); - ClassDB::bind_method(D_METHOD("set_heigth", "value"), &PropDataTiledWall2D::set_heigth); + ClassDB::bind_method(D_METHOD("get_heigth"), &PropDataTiledWall::get_heigth); + ClassDB::bind_method(D_METHOD("set_heigth", "value"), &PropDataTiledWall::set_heigth); ADD_PROPERTY(PropertyInfo(Variant::INT, "heigth"), "set_heigth", "get_heigth"); - ClassDB::bind_method(D_METHOD("get_data"), &PropDataTiledWall2D::get_data); - ClassDB::bind_method(D_METHOD("set_data", "value"), &PropDataTiledWall2D::set_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "TiledWall2DData"), "set_data", "get_data"); + ClassDB::bind_method(D_METHOD("get_data"), &PropDataTiledWall::get_data); + ClassDB::bind_method(D_METHOD("set_data", "value"), &PropDataTiledWall::set_data); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "TiledWallData"), "set_data", "get_data"); - ClassDB::bind_method(D_METHOD("get_collision"), &PropDataTiledWall2D::get_collision); - ClassDB::bind_method(D_METHOD("set_collision", "value"), &PropDataTiledWall2D::set_collision); + ClassDB::bind_method(D_METHOD("get_collision"), &PropDataTiledWall::get_collision); + ClassDB::bind_method(D_METHOD("set_collision", "value"), &PropDataTiledWall::set_collision); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision"), "set_collision", "get_collision"); } diff --git a/props/prop_data_tiled_wall_2d.h b/props/prop_data_tiled_wall.h similarity index 73% rename from props/prop_data_tiled_wall_2d.h rename to props/prop_data_tiled_wall.h index bdcb42f..8e5137d 100644 --- a/props/prop_data_tiled_wall_2d.h +++ b/props/prop_data_tiled_wall.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,16 +20,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_DATA_TILED_WALL_2D_H -#define PROP_DATA_TILED_WALL_2D_H +#ifndef PROP_DATA_TILED_WALL_H +#define PROP_DATA_TILED_WALL_H #include "core/math/vector3.h" -#include "prop_data_entry_2d.h" +#include "prop_data_entry.h" -class TiledWallData2D; +class TiledWallData; -class PropDataTiledWall2D : public PropDataEntry2D { - GDCLASS(PropDataTiledWall2D, PropDataEntry2D); +class PropDataTiledWall : public PropDataEntry { + GDCLASS(PropDataTiledWall, PropDataEntry); public: int get_width() const; @@ -38,18 +38,18 @@ public: int get_heigth() const; void set_heigth(const int value); - Ref get_data(); - void set_data(const Ref &data); + Ref get_data(); + void set_data(const Ref &data); bool get_collision() const; void set_collision(const int value); bool _processor_handles(Node *node); - void _processor_process(Ref prop_data, Node *node, const Transform &transform); + void _processor_process(Ref prop_data, Node *node, const Transform &transform); Node *_processor_get_node_for(const Transform &transform); - PropDataTiledWall2D(); - ~PropDataTiledWall2D(); + PropDataTiledWall(); + ~PropDataTiledWall(); protected: static void _bind_methods(); @@ -59,7 +59,7 @@ private: int _height; bool _collision; - Ref _data; + Ref _data; }; #endif diff --git a/register_types.cpp b/register_types.cpp index 47b2815..f6a44a1 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -30,121 +30,121 @@ SOFTWARE. #include "core/engine.h" #endif -#include "tiled_wall/tiled_wall_2d.h" -#include "tiled_wall/tiled_wall_data_2d.h" +#include "tiled_wall/tiled_wall.h" +#include "tiled_wall/tiled_wall_data.h" -#include "props/prop_data_2d.h" -#include "props/prop_data_entry_2d.h" -#include "props/prop_data_light_2d.h" -#include "props/prop_data_prop_2d.h" -#include "props/prop_data_scene_2d.h" -#include "props/prop_data_tiled_wall_2d.h" +#include "props/prop_data.h" +#include "props/prop_data_entry.h" +#include "props/prop_data_light.h" +#include "props/prop_data_prop.h" +#include "props/prop_data_scene.h" +#include "props/prop_data_tiled_wall.h" #if VERSION_MINOR >= 4 -#include "props/prop_data_portal_2d.h" +#include "props/prop_data_portal.h" #endif -#include "clutter/ground_clutter_2d.h" -#include "clutter/ground_clutter_foliage_2d.h" +#include "clutter/ground_clutter.h" +#include "clutter/ground_clutter_foliage.h" -#include "prop_ess_entity_2d.h" -#include "prop_instance_2d.h" -#include "prop_instance_merger_2d.h" +#include "prop_ess_entity.h" +#include "prop_instance.h" +#include "prop_instance_merger.h" -#include "prop_instance_job_2d.h" -#include "prop_instance_prop_job_2d.h" +#include "prop_instance_job.h" +#include "prop_instance_prop_job.h" -#include "jobs/prop_mesher_job_step_2d.h" -#include "jobs/prop_texture_job_2d.h" +#include "jobs/prop_mesher_job_step.h" +#include "jobs/prop_texture_job.h" -#include "prop_scene_instance_2d.h" +#include "prop_scene_instance.h" -#include "singleton/prop_cache_2d.h" -#include "singleton/prop_utils_2d.h" +#include "singleton/prop_cache.h" +#include "singleton/prop_utils.h" -#include "lights/prop_light_2d.h" +#include "lights/prop_light.h" -#include "./editor/prop_editor_plugin_2d.h" +#include "./editor/prop_editor_plugin.h" -#include "prop_mesher_2d.h" +#include "prop_mesher.h" -#include "material_cache/prop_material_cache_2d.h" +#include "material_cache/prop_material_cache.h" #ifdef TEXTURE_PACKER_PRESENT -#include "material_cache/prop_material_cache_pcm_2d.h" +#include "material_cache/prop_material_cache_pcm.h" #endif -static PropUtils2D *prop_utils = NULL; -static PropCache2D *prop_texture_cache = NULL; +static PropUtils *prop_utils = NULL; +static PropCache *prop_texture_cache = NULL; void register_props_2d_types() { - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); #if VERSION_MINOR >= 4 - ClassDB::register_class(); + ClassDB::register_class(); #endif - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); #ifdef TEXTURE_PACKER_PRESENT - ClassDB::register_class(); + ClassDB::register_class(); #endif - prop_utils = memnew(PropUtils2D); - ClassDB::register_class(); - Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils2D", PropUtils2D::get_singleton())); + prop_utils = memnew(PropUtils); + ClassDB::register_class(); + Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton())); - prop_texture_cache = memnew(PropCache2D); - ClassDB::register_class(); - Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache2D", PropCache2D::get_singleton())); + prop_texture_cache = memnew(PropCache); + ClassDB::register_class(); + Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache", PropCache::get_singleton())); - Ref light_processor = Ref(memnew(PropDataLight2D)); - PropUtils2D::add_processor(light_processor); + Ref light_processor = Ref(memnew(PropDataLight)); + PropUtils::add_processor(light_processor); - Ref prop_processor = Ref(memnew(PropDataProp2D)); - PropUtils2D::add_processor(prop_processor); + Ref prop_processor = Ref(memnew(PropDataProp)); + PropUtils::add_processor(prop_processor); - Ref scene_processor = Ref(memnew(PropDataScene2D)); - PropUtils2D::add_processor(scene_processor); + Ref scene_processor = Ref(memnew(PropDataScene)); + PropUtils::add_processor(scene_processor); #if VERSION_MINOR >= 4 - Ref portal_processor = Ref(memnew(PropDataPortal2D)); - PropUtils2D::add_processor(portal_processor); + Ref portal_processor = Ref(memnew(PropDataPortal)); + PropUtils::add_processor(portal_processor); #endif - Ref tiled_wall_processor = Ref(memnew(PropDataTiledWall2D)); - PropUtils2D::add_processor(tiled_wall_processor); + Ref tiled_wall_processor = Ref(memnew(PropDataTiledWall)); + PropUtils::add_processor(tiled_wall_processor); #ifdef TOOLS_ENABLED - EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); #endif } diff --git a/register_types.h b/register_types.h index d0045e5..e32eae7 100644 --- a/register_types.h +++ b/register_types.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROPS_2D_REGISTER_TYPES_H -#define PROPS_2D_REGISTER_TYPES_H +#ifndef PROPS_REGISTER_TYPES_H +#define PROPS_REGISTER_TYPES_H void register_props_2d_types(); void unregister_props_2d_types(); diff --git a/singleton/prop_cache_2d.cpp b/singleton/prop_cache.cpp similarity index 60% rename from singleton/prop_cache_2d.cpp rename to singleton/prop_cache.cpp index b35eadc..49d38e8 100644 --- a/singleton/prop_cache_2d.cpp +++ b/singleton/prop_cache.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_cache_2d.h" +#include "prop_cache.h" -#include "../props/prop_data_2d.h" -#include "../props/prop_data_entry_2d.h" +#include "../props/prop_data.h" +#include "../props/prop_data_entry.h" #include "core/version.h" @@ -35,14 +35,14 @@ SOFTWARE. #include "core/project_settings.h" #endif -#include "../jobs/prop_texture_job_2d.h" +#include "../jobs/prop_texture_job.h" #if THREAD_POOL_PRESENT #include "../../thread_pool/thread_pool.h" #endif -#include "../material_cache/prop_material_cache_2d.h" -#include "../tiled_wall/tiled_wall_data_2d.h" +#include "../material_cache/prop_material_cache.h" +#include "../tiled_wall/tiled_wall_data.h" #include "core/hashfuncs.h" @@ -66,94 +66,94 @@ SOFTWARE. #endif -PropCache2D *PropCache2D::_instance; +PropCache *PropCache::_instance; -PropCache2D *PropCache2D::get_singleton() { +PropCache *PropCache::get_singleton() { return _instance; } -StringName PropCache2D::get_default_prop_material_cache_class() { +StringName PropCache::get_default_prop_material_cache_class() { return _default_prop_material_cache_class; } -void PropCache2D::set_default_prop_material_cache_class(const StringName &cls_name) { +void PropCache::set_default_prop_material_cache_class(const StringName &cls_name) { _default_prop_material_cache_class = cls_name; } #ifdef TEXTURE_PACKER_PRESENT -int PropCache2D::get_texture_flags() const { +int PropCache::get_texture_flags() const { return _texture_flags; } -void PropCache2D::set_texture_flags(const int flags) { +void PropCache::set_texture_flags(const int flags) { _texture_flags = flags; } -int PropCache2D::get_max_atlas_size() const { +int PropCache::get_max_atlas_size() const { return _max_atlas_size; } -void PropCache2D::set_max_atlas_size(const int size) { +void PropCache::set_max_atlas_size(const int size) { _max_atlas_size = size; } -bool PropCache2D::get_keep_original_atlases() const { +bool PropCache::get_keep_original_atlases() const { return _keep_original_atlases; } -void PropCache2D::set_keep_original_atlases(const bool value) { +void PropCache::set_keep_original_atlases(const bool value) { _keep_original_atlases = value; } -Color PropCache2D::get_background_color() const { +Color PropCache::get_background_color() const { return _background_color; } -void PropCache2D::set_background_color(const Color &color) { +void PropCache::set_background_color(const Color &color) { _background_color = color; } -int PropCache2D::get_margin() const { +int PropCache::get_margin() const { return _margin; } -void PropCache2D::set_margin(const int margin) { +void PropCache::set_margin(const int margin) { _margin = margin; } #endif -PoolStringArray PropCache2D::material_paths_get() const { +PoolStringArray PropCache::material_paths_get() const { return _material_paths; } -void PropCache2D::material_paths_set(const PoolStringArray &value) { +void PropCache::material_paths_set(const PoolStringArray &value) { _material_paths = value; } -void PropCache2D::material_add(const Ref &value) { +void PropCache::material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); _materials.push_back(value); } -Ref PropCache2D::material_get(const int index) { +Ref PropCache::material_get(const int index) { ERR_FAIL_INDEX_V(index, _materials.size(), Ref()); return _materials[index]; } -void PropCache2D::material_set(const int index, const Ref &value) { +void PropCache::material_set(const int index, const Ref &value) { ERR_FAIL_INDEX(index, _materials.size()); _materials.set(index, value); } -void PropCache2D::material_remove(const int index) { +void PropCache::material_remove(const int index) { _materials.remove(index); } -int PropCache2D::material_get_num() const { +int PropCache::material_get_num() const { return _materials.size(); } -void PropCache2D::materials_clear() { +void PropCache::materials_clear() { _materials.clear(); } -void PropCache2D::materials_load() { +void PropCache::materials_load() { _materials.clear(); for (int i = 0; i < _material_paths.size(); ++i) { @@ -169,17 +169,17 @@ void PropCache2D::materials_load() { } } -void PropCache2D::ensure_materials_loaded() { +void PropCache::ensure_materials_loaded() { if (_materials.size() != _material_paths.size()) { materials_load(); } } -Vector PropCache2D::materials_get() { +Vector PropCache::materials_get() { VARIANT_ARRAY_GET(_materials); } -void PropCache2D::materials_set(const Vector &materials) { +void PropCache::materials_set(const Vector &materials) { _materials.clear(); for (int i = 0; i < materials.size(); i++) { @@ -189,16 +189,16 @@ void PropCache2D::materials_set(const Vector &materials) { } } -Ref PropCache2D::material_cache_get(const Ref &prop) { - ERR_FAIL_COND_V(!prop.is_valid(), Ref()); +Ref PropCache::material_cache_get(const Ref &prop) { + ERR_FAIL_COND_V(!prop.is_valid(), Ref()); //get pointer's value as uint64 - uint64_t k = make_uint64_t(*prop); + uint64_t k = make_uint64_t(*prop); _material_cache_mutex.lock(); if (_material_cache.has(k)) { - Ref m = _material_cache[k]; + Ref m = _material_cache[k]; m->inc_ref_count(); @@ -207,13 +207,13 @@ Ref PropCache2D::material_cache_get(const Ref & return m; } - PropMaterialCache2D *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); + PropMaterialCache *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); if (!p) { - ERR_PRINT("Can't instance the given PropMaterialCache2D! class_name: " + String(_default_prop_material_cache_class)); + ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class)); } - Ref m(p); + Ref m(p); _material_cache[k] = m; @@ -221,21 +221,21 @@ Ref PropCache2D::material_cache_get(const Ref & return m; } -void PropCache2D::material_cache_unref(const Ref &prop) { +void PropCache::material_cache_unref(const Ref &prop) { //get pointer's value as uint64 - uint64_t k = make_uint64_t(*prop); + uint64_t k = make_uint64_t(*prop); _material_cache_mutex.lock(); if (!_material_cache.has(k)) { _material_cache_mutex.unlock(); - ERR_PRINT("PropCache2D::material_cache_unref: can't find cache!"); + ERR_PRINT("PropCache::material_cache_unref: can't find cache!"); return; } - Ref m = _material_cache[k]; + Ref m = _material_cache[k]; m->dec_ref_count(); if (m->get_ref_count() <= 0) { @@ -245,16 +245,16 @@ void PropCache2D::material_cache_unref(const Ref &prop) { _material_cache_mutex.unlock(); } -Ref PropCache2D::tiled_wall_material_cache_get(const Ref &twd) { - ERR_FAIL_COND_V(!twd.is_valid(), Ref()); +Ref PropCache::tiled_wall_material_cache_get(const Ref &twd) { + ERR_FAIL_COND_V(!twd.is_valid(), Ref()); //get pointer's value as uint64 - uint64_t k = make_uint64_t(*twd); + uint64_t k = make_uint64_t(*twd); _tiled_wall_material_cache_mutex.lock(); if (_tiled_wall_material_cache.has(k)) { - Ref m = _tiled_wall_material_cache[k]; + Ref m = _tiled_wall_material_cache[k]; m->inc_ref_count(); @@ -263,13 +263,13 @@ Ref PropCache2D::tiled_wall_material_cache_get(const Ref(ClassDB::instance(_default_prop_material_cache_class)); + PropMaterialCache *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); if (!p) { - ERR_PRINT("Can't instance the given PropMaterialCache2D! class_name: " + String(_default_prop_material_cache_class)); + ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class)); } - Ref m(p); + Ref m(p); _tiled_wall_material_cache[k] = m; @@ -277,21 +277,21 @@ Ref PropCache2D::tiled_wall_material_cache_get(const Ref &twd) { +void PropCache::tiled_wall_material_cache_unref(const Ref &twd) { //get pointer's value as uint64 - uint64_t k = make_uint64_t(*twd); + uint64_t k = make_uint64_t(*twd); _tiled_wall_material_cache_mutex.lock(); if (!_tiled_wall_material_cache.has(k)) { _tiled_wall_material_cache_mutex.unlock(); - ERR_PRINT("PropCache2D::material_cache_unref: can't find cache!"); + ERR_PRINT("PropCache::material_cache_unref: can't find cache!"); return; } - Ref m = _tiled_wall_material_cache[k]; + Ref m = _tiled_wall_material_cache[k]; m->dec_ref_count(); if (m->get_ref_count() <= 0) { @@ -301,11 +301,11 @@ void PropCache2D::tiled_wall_material_cache_unref(const Ref &tw _tiled_wall_material_cache_mutex.unlock(); } -Ref PropCache2D::material_cache_custom_key_get(const uint64_t key) { +Ref PropCache::material_cache_custom_key_get(const uint64_t key) { _custom_keyed_material_cache_mutex.lock(); if (_custom_keyed_material_cache.has(key)) { - Ref m = _custom_keyed_material_cache[key]; + Ref m = _custom_keyed_material_cache[key]; m->inc_ref_count(); @@ -314,13 +314,13 @@ Ref PropCache2D::material_cache_custom_key_get(const uint64 return m; } - PropMaterialCache2D *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); + PropMaterialCache *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); if (!p) { - ERR_PRINT("Can't instance the given PropMaterialCache2D! class_name: " + String(_default_prop_material_cache_class)); + ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class)); } - Ref m(p); + Ref m(p); _custom_keyed_material_cache[key] = m; @@ -328,18 +328,18 @@ Ref PropCache2D::material_cache_custom_key_get(const uint64 return m; } -void PropCache2D::material_cache_custom_key_unref(const uint64_t key) { +void PropCache::material_cache_custom_key_unref(const uint64_t key) { _custom_keyed_material_cache_mutex.lock(); if (!_material_cache.has(key)) { _custom_keyed_material_cache_mutex.unlock(); - ERR_PRINT("PropCache2D::material_cache_custom_key_unref: can't find cache!"); + ERR_PRINT("PropCache::material_cache_custom_key_unref: can't find cache!"); return; } - Ref m = _custom_keyed_material_cache[key]; + Ref m = _custom_keyed_material_cache[key]; m->dec_ref_count(); if (m->get_ref_count() <= 0) { @@ -349,7 +349,7 @@ void PropCache2D::material_cache_custom_key_unref(const uint64_t key) { _custom_keyed_material_cache_mutex.unlock(); } -Ref PropCache2D::load_resource(const String &path, const String &type_hint) { +Ref PropCache::load_resource(const String &path, const String &type_hint) { _ResourceLoader *rl = _ResourceLoader::get_singleton(); #if VERSION_MAJOR < 4 @@ -365,13 +365,13 @@ Ref PropCache2D::load_resource(const String &path, const String &type_ #endif } -PropCache2D::PropCache2D() { +PropCache::PropCache() { _instance = this; #if TEXTURE_PACKER_PRESENT - _default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache2DPCM"); + _default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCachePCM"); #else - _default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache2D"); + _default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache"); #endif #ifdef TEXTURE_PACKER_PRESENT @@ -390,62 +390,62 @@ PropCache2D::PropCache2D() { _material_paths = GLOBAL_DEF("props/material_paths", PoolStringArray()); } -PropCache2D::~PropCache2D() { +PropCache::~PropCache() { _instance = NULL; } -void PropCache2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_default_prop_material_cache_class"), &PropCache2D::get_default_prop_material_cache_class); - ClassDB::bind_method(D_METHOD("set_default_prop_material_cache_class", "cls_name"), &PropCache2D::set_default_prop_material_cache_class); +void PropCache::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_default_prop_material_cache_class"), &PropCache::get_default_prop_material_cache_class); + ClassDB::bind_method(D_METHOD("set_default_prop_material_cache_class", "cls_name"), &PropCache::set_default_prop_material_cache_class); ADD_PROPERTY(PropertyInfo(Variant::STRING, "default_prop_material_cache_class"), "set_default_prop_material_cache_class", "get_default_prop_material_cache_class"); #ifdef TEXTURE_PACKER_PRESENT - ClassDB::bind_method(D_METHOD("get_texture_flags"), &PropCache2D::get_texture_flags); - ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &PropCache2D::set_texture_flags); + ClassDB::bind_method(D_METHOD("get_texture_flags"), &PropCache::get_texture_flags); + ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &PropCache::set_texture_flags); ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic Linear,Convert to Linear,Mirrored Repeat,Video Surface"), "set_texture_flags", "get_texture_flags"); - ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &PropCache2D::get_max_atlas_size); - ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropCache2D::set_max_atlas_size); + ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &PropCache::get_max_atlas_size); + ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropCache::set_max_atlas_size); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_atlas_size"), "set_max_atlas_size", "get_max_atlas_size"); - ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &PropCache2D::get_keep_original_atlases); - ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropCache2D::set_keep_original_atlases); + ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &PropCache::get_keep_original_atlases); + ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropCache::set_keep_original_atlases); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_original_atlases"), "set_keep_original_atlases", "get_keep_original_atlases"); - ClassDB::bind_method(D_METHOD("get_background_color"), &PropCache2D::get_background_color); - ClassDB::bind_method(D_METHOD("set_background_color", "color"), &PropCache2D::set_background_color); + ClassDB::bind_method(D_METHOD("get_background_color"), &PropCache::get_background_color); + ClassDB::bind_method(D_METHOD("set_background_color", "color"), &PropCache::set_background_color); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_background_color", "get_background_color"); - ClassDB::bind_method(D_METHOD("get_margin"), &PropCache2D::get_margin); - ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropCache2D::set_margin); + ClassDB::bind_method(D_METHOD("get_margin"), &PropCache::get_margin); + ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropCache::set_margin); ADD_PROPERTY(PropertyInfo(Variant::INT, "margin"), "set_margin", "get_margin"); #endif - ClassDB::bind_method(D_METHOD("material_paths_get"), &PropCache2D::material_paths_get); - ClassDB::bind_method(D_METHOD("material_paths_set", "value"), &PropCache2D::material_paths_set); + ClassDB::bind_method(D_METHOD("material_paths_get"), &PropCache::material_paths_get); + ClassDB::bind_method(D_METHOD("material_paths_set", "value"), &PropCache::material_paths_set); ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "material_paths"), "material_paths_set", "material_paths_get"); - ClassDB::bind_method(D_METHOD("material_add", "value"), &PropCache2D::material_add); - ClassDB::bind_method(D_METHOD("material_get", "index"), &PropCache2D::material_get); - ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &PropCache2D::material_set); - ClassDB::bind_method(D_METHOD("material_remove", "index"), &PropCache2D::material_remove); - ClassDB::bind_method(D_METHOD("material_get_num"), &PropCache2D::material_get_num); - ClassDB::bind_method(D_METHOD("materials_clear"), &PropCache2D::materials_clear); - ClassDB::bind_method(D_METHOD("materials_load"), &PropCache2D::materials_load); - ClassDB::bind_method(D_METHOD("ensure_materials_loaded"), &PropCache2D::ensure_materials_loaded); + ClassDB::bind_method(D_METHOD("material_add", "value"), &PropCache::material_add); + ClassDB::bind_method(D_METHOD("material_get", "index"), &PropCache::material_get); + ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &PropCache::material_set); + ClassDB::bind_method(D_METHOD("material_remove", "index"), &PropCache::material_remove); + ClassDB::bind_method(D_METHOD("material_get_num"), &PropCache::material_get_num); + ClassDB::bind_method(D_METHOD("materials_clear"), &PropCache::materials_clear); + ClassDB::bind_method(D_METHOD("materials_load"), &PropCache::materials_load); + ClassDB::bind_method(D_METHOD("ensure_materials_loaded"), &PropCache::ensure_materials_loaded); - ClassDB::bind_method(D_METHOD("materials_get"), &PropCache2D::materials_get); - ClassDB::bind_method(D_METHOD("materials_set"), &PropCache2D::materials_set); + ClassDB::bind_method(D_METHOD("materials_get"), &PropCache::materials_get); + ClassDB::bind_method(D_METHOD("materials_set"), &PropCache::materials_set); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get"); - ClassDB::bind_method(D_METHOD("material_cache_get", "prop"), &PropCache2D::material_cache_get); - ClassDB::bind_method(D_METHOD("material_cache_unref", "prop"), &PropCache2D::material_cache_unref); + ClassDB::bind_method(D_METHOD("material_cache_get", "prop"), &PropCache::material_cache_get); + ClassDB::bind_method(D_METHOD("material_cache_unref", "prop"), &PropCache::material_cache_unref); - ClassDB::bind_method(D_METHOD("tiled_wall_material_cache_get", "twd"), &PropCache2D::tiled_wall_material_cache_get); - ClassDB::bind_method(D_METHOD("tiled_wall_material_cache_unref", "twd"), &PropCache2D::tiled_wall_material_cache_unref); + ClassDB::bind_method(D_METHOD("tiled_wall_material_cache_get", "twd"), &PropCache::tiled_wall_material_cache_get); + ClassDB::bind_method(D_METHOD("tiled_wall_material_cache_unref", "twd"), &PropCache::tiled_wall_material_cache_unref); - ClassDB::bind_method(D_METHOD("material_cache_custom_key_get", "key"), &PropCache2D::material_cache_custom_key_get); - ClassDB::bind_method(D_METHOD("material_cache_custom_key_unref", "key"), &PropCache2D::material_cache_custom_key_unref); + ClassDB::bind_method(D_METHOD("material_cache_custom_key_get", "key"), &PropCache::material_cache_custom_key_get); + ClassDB::bind_method(D_METHOD("material_cache_custom_key_unref", "key"), &PropCache::material_cache_custom_key_unref); - ClassDB::bind_method(D_METHOD("load_resource", "path", "type_hint"), &PropCache2D::load_resource, ""); + ClassDB::bind_method(D_METHOD("load_resource", "path", "type_hint"), &PropCache::load_resource, ""); } diff --git a/singleton/prop_cache_2d.h b/singleton/prop_cache.h similarity index 77% rename from singleton/prop_cache_2d.h rename to singleton/prop_cache.h index 2f508bb..15529e6 100644 --- a/singleton/prop_cache_2d.h +++ b/singleton/prop_cache.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_CACHE_2D_H -#define PROP_CACHE_2D_H +#ifndef PROP_CACHE_H +#define PROP_CACHE_H #include "core/version.h" @@ -45,16 +45,16 @@ SOFTWARE. #include "core/os/mutex.h" -#include "../props/prop_data_2d.h" +#include "../props/prop_data.h" -class PropMaterialCache2D; -class TiledWallData2D; +class PropMaterialCache; +class TiledWallData; -class PropCache2D : public Object { - GDCLASS(PropCache2D, Object); +class PropCache : public Object { + GDCLASS(PropCache, Object); public: - static PropCache2D *get_singleton(); + static PropCache *get_singleton(); StringName get_default_prop_material_cache_class(); void set_default_prop_material_cache_class(const StringName &cls_name); @@ -91,32 +91,32 @@ public: Vector materials_get(); void materials_set(const Vector &materials); - Ref material_cache_get(const Ref &prop); - void material_cache_unref(const Ref &prop); + Ref material_cache_get(const Ref &prop); + void material_cache_unref(const Ref &prop); - Ref tiled_wall_material_cache_get(const Ref &twd); - void tiled_wall_material_cache_unref(const Ref &twd); + Ref tiled_wall_material_cache_get(const Ref &twd); + void tiled_wall_material_cache_unref(const Ref &twd); - Ref material_cache_custom_key_get(const uint64_t key); + Ref material_cache_custom_key_get(const uint64_t key); void material_cache_custom_key_unref(const uint64_t key); Ref load_resource(const String &path, const String &type_hint = ""); private: - static PropCache2D *_instance; + static PropCache *_instance; public: - PropCache2D(); - ~PropCache2D(); + PropCache(); + ~PropCache(); protected: static void _bind_methods(); StringName _default_prop_material_cache_class; - Map> _material_cache; - Map> _tiled_wall_material_cache; - Map> _custom_keyed_material_cache; + Map> _material_cache; + Map> _tiled_wall_material_cache; + Map> _custom_keyed_material_cache; Mutex _material_cache_mutex; Mutex _tiled_wall_material_cache_mutex; diff --git a/singleton/prop_utils_2d.cpp b/singleton/prop_utils.cpp similarity index 78% rename from singleton/prop_utils_2d.cpp rename to singleton/prop_utils.cpp index d817600..26f5c81 100644 --- a/singleton/prop_utils_2d.cpp +++ b/singleton/prop_utils.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,10 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "prop_utils_2d.h" +#include "prop_utils.h" -#include "../props/prop_data_2d.h" -#include "../props/prop_data_entry_2d.h" +#include "../props/prop_data.h" +#include "../props/prop_data_entry.h" #include "core/version.h" @@ -46,19 +46,19 @@ SOFTWARE. #include "core/engine.h" #endif -PropUtils2D *PropUtils2D::_instance; -Vector > PropUtils2D::_processors; +PropUtils *PropUtils::_instance; +Vector > PropUtils::_processors; -PropUtils2D *PropUtils2D::get_singleton() { +PropUtils *PropUtils::get_singleton() { return _instance; } -Ref PropUtils2D::convert_tree(Node *root) { +Ref PropUtils::convert_tree(Node *root) { #if VERSION_MAJOR < 4 - ERR_FAIL_COND_V(!ObjectDB::instance_validate(root), Ref()); + ERR_FAIL_COND_V(!ObjectDB::instance_validate(root), Ref()); #endif - Ref data; + Ref data; data.instance(); Transform t; @@ -67,13 +67,13 @@ Ref PropUtils2D::convert_tree(Node *root) { return data; } -void PropUtils2D::_convert_tree(Ref prop_data, Node *node, const Transform &transform) { +void PropUtils::_convert_tree(Ref prop_data, Node *node, const Transform &transform) { #if VERSION_MAJOR < 4 ERR_FAIL_COND(!ObjectDB::instance_validate(node)); #endif - for (int i = 0; i < PropUtils2D::_processors.size(); ++i) { - Ref proc = PropUtils2D::_processors.get(i); + for (int i = 0; i < PropUtils::_processors.size(); ++i) { + Ref proc = PropUtils::_processors.get(i); ERR_CONTINUE(!proc.is_valid()); @@ -138,7 +138,7 @@ void PropUtils2D::_convert_tree(Ref prop_data, Node *node, const Tra } #if VERSION_MINOR >= 4 -bool PropUtils2D::generate_room_points_node(Node *node) { +bool PropUtils::generate_room_points_node(Node *node) { ERR_FAIL_COND_V(!ObjectDB::instance_validate(node), false); Room *r = Object::cast_to(node); @@ -158,7 +158,7 @@ bool PropUtils2D::generate_room_points_node(Node *node) { return false; } -void PropUtils2D::generate_room_points(Room *room) { +void PropUtils::generate_room_points(Room *room) { ERR_FAIL_COND(!ObjectDB::instance_validate(room)); Vector > mesh_arrays; @@ -281,7 +281,7 @@ void PropUtils2D::generate_room_points(Room *room) { } //based on Room::SimplifyInfo::add_plane_if_unique -bool PropUtils2D::is_plane_unique(const PoolVector &planes, const Plane &p) { +bool PropUtils::is_plane_unique(const PoolVector &planes, const Plane &p) { for (int n = 0; n < planes.size(); n++) { const Plane &o = planes[n]; @@ -306,7 +306,7 @@ bool PropUtils2D::is_plane_unique(const PoolVector &planes, const Plane & return true; } -void PropUtils2D::get_mesh_arrays(Node *node, Vector > *arrs) { +void PropUtils::get_mesh_arrays(Node *node, Vector > *arrs) { ERR_FAIL_COND(!ObjectDB::instance_validate(node)); for (int i = 0; i < node->get_child_count(); ++i) { @@ -462,67 +462,67 @@ void PropUtils2D::get_mesh_arrays(Node *node, Vector > *arrs #endif -int PropUtils2D::add_processor(const Ref &processor) { +int PropUtils::add_processor(const Ref &processor) { ERR_FAIL_COND_V(!processor.is_valid(), 0); - PropUtils2D::_processors.push_back(processor); + PropUtils::_processors.push_back(processor); - return PropUtils2D::_processors.size() - 1; + return PropUtils::_processors.size() - 1; } -Ref PropUtils2D::get_processor(const int index) { - ERR_FAIL_INDEX_V(index, PropUtils2D::_processors.size(), Ref()); +Ref PropUtils::get_processor(const int index) { + ERR_FAIL_INDEX_V(index, PropUtils::_processors.size(), Ref()); - return PropUtils2D::_processors[index]; + return PropUtils::_processors[index]; } -void PropUtils2D::swap_processors(const int index1, const int index2) { - ERR_FAIL_INDEX(index1, PropUtils2D::_processors.size()); - ERR_FAIL_INDEX(index2, PropUtils2D::_processors.size()); +void PropUtils::swap_processors(const int index1, const int index2) { + ERR_FAIL_INDEX(index1, PropUtils::_processors.size()); + ERR_FAIL_INDEX(index2, PropUtils::_processors.size()); - Ref a = PropUtils2D::_processors.get(index1); - PropUtils2D::_processors.set(index1, PropUtils2D::_processors.get(index2)); - PropUtils2D::_processors.set(index2, a); + Ref a = PropUtils::_processors.get(index1); + PropUtils::_processors.set(index1, PropUtils::_processors.get(index2)); + PropUtils::_processors.set(index2, a); } -void PropUtils2D::remove_processor(const int index) { - ERR_FAIL_INDEX(index, PropUtils2D::_processors.size()); +void PropUtils::remove_processor(const int index) { + ERR_FAIL_INDEX(index, PropUtils::_processors.size()); - PropUtils2D::_processors.remove(index); + PropUtils::_processors.remove(index); } -int PropUtils2D::get_processor_count() { - return PropUtils2D::_processors.size(); +int PropUtils::get_processor_count() { + return PropUtils::_processors.size(); } -PropUtils2D::PropUtils2D() { +PropUtils::PropUtils() { _instance = this; } -PropUtils2D::~PropUtils2D() { +PropUtils::~PropUtils() { _instance = NULL; - PropUtils2D::_processors.clear(); + PropUtils::_processors.clear(); } -void PropUtils2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("convert_tree", "root"), &PropUtils2D::convert_tree); +void PropUtils::_bind_methods() { + ClassDB::bind_method(D_METHOD("convert_tree", "root"), &PropUtils::convert_tree); - ClassDB::bind_method(D_METHOD("add_processor", "processor"), &PropUtils2D::_add_processor_bind); - ClassDB::bind_method(D_METHOD("get_processor", "index"), &PropUtils2D::_get_processor_bind); - ClassDB::bind_method(D_METHOD("swap_processors", "index1", "index2"), &PropUtils2D::_swap_processors_bind); - ClassDB::bind_method(D_METHOD("remove_processor", "index"), &PropUtils2D::_remove_processor_bind); - ClassDB::bind_method(D_METHOD("get_processor_count"), &PropUtils2D::_get_processor_count_bind); + ClassDB::bind_method(D_METHOD("add_processor", "processor"), &PropUtils::_add_processor_bind); + ClassDB::bind_method(D_METHOD("get_processor", "index"), &PropUtils::_get_processor_bind); + ClassDB::bind_method(D_METHOD("swap_processors", "index1", "index2"), &PropUtils::_swap_processors_bind); + ClassDB::bind_method(D_METHOD("remove_processor", "index"), &PropUtils::_remove_processor_bind); + ClassDB::bind_method(D_METHOD("get_processor_count"), &PropUtils::_get_processor_count_bind); } -int PropUtils2D::_add_processor_bind(const Ref &processor) { - return PropUtils2D::add_processor(processor); +int PropUtils::_add_processor_bind(const Ref &processor) { + return PropUtils::add_processor(processor); } -Ref PropUtils2D::_get_processor_bind(const int index) { - return PropUtils2D::get_processor(index); +Ref PropUtils::_get_processor_bind(const int index) { + return PropUtils::get_processor(index); } -void PropUtils2D::_swap_processors_bind(const int index1, const int index2) { - PropUtils2D::swap_processors(index1, index2); +void PropUtils::_swap_processors_bind(const int index1, const int index2) { + PropUtils::swap_processors(index1, index2); } -void PropUtils2D::_remove_processor_bind(const int index) { - PropUtils2D::remove_processor(index); +void PropUtils::_remove_processor_bind(const int index) { + PropUtils::remove_processor(index); } -int PropUtils2D::_get_processor_count_bind() { - return PropUtils2D::get_processor_count(); +int PropUtils::_get_processor_count_bind() { + return PropUtils::get_processor_count(); } diff --git a/singleton/prop_utils_2d.h b/singleton/prop_utils.h similarity index 73% rename from singleton/prop_utils_2d.h rename to singleton/prop_utils.h index 6573f13..32dcc54 100644 --- a/singleton/prop_utils_2d.h +++ b/singleton/prop_utils.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef PROP_UTILS_2D_H -#define PROP_UTILS_2D_H +#ifndef PROP_UTILS_H +#define PROP_UTILS_H #include "core/version.h" @@ -39,21 +39,21 @@ SOFTWARE. #include "scene/main/node.h" -class PropData2D; -class PropDataEntry2D; +class PropData; +class PropDataEntry; #if VERSION_MINOR >= 4 class Room; #endif -class PropUtils2D : public Object { - GDCLASS(PropUtils2D, Object); +class PropUtils : public Object { + GDCLASS(PropUtils, Object); public: - static PropUtils2D *get_singleton(); + static PropUtils *get_singleton(); - Ref convert_tree(Node *root); - void _convert_tree(Ref prop_data, Node *node, const Transform &transform); + Ref convert_tree(Node *root); + void _convert_tree(Ref prop_data, Node *node, const Transform &transform); #if VERSION_MINOR >= 4 bool generate_room_points_node(Node *node); @@ -62,27 +62,27 @@ public: bool is_plane_unique(const PoolVector &planes, const Plane &p); #endif - static int add_processor(const Ref &processor); - static Ref get_processor(const int index); + static int add_processor(const Ref &processor); + static Ref get_processor(const int index); static void swap_processors(const int index1, const int index2); static void remove_processor(const int index); static int get_processor_count(); - PropUtils2D(); - ~PropUtils2D(); + PropUtils(); + ~PropUtils(); protected: static void _bind_methods(); private: - int _add_processor_bind(const Ref &processor); - Ref _get_processor_bind(const int index); + int _add_processor_bind(const Ref &processor); + Ref _get_processor_bind(const int index); void _swap_processors_bind(const int index1, const int index2); void _remove_processor_bind(const int index); int _get_processor_count_bind(); - static Vector> _processors; - static PropUtils2D *_instance; + static Vector> _processors; + static PropUtils *_instance; }; #endif diff --git a/tiled_wall/tiled_wall_2d.cpp b/tiled_wall/tiled_wall.cpp similarity index 75% rename from tiled_wall/tiled_wall_2d.cpp rename to tiled_wall/tiled_wall.cpp index e058e0b..b1488ee 100644 --- a/tiled_wall/tiled_wall_2d.cpp +++ b/tiled_wall/tiled_wall.cpp @@ -1,4 +1,4 @@ -#include "tiled_wall_2d.h" +#include "tiled_wall.h" #include "core/version.h" @@ -18,37 +18,37 @@ #include "../../texture_packer/texture_resource/packer_image_resource.h" #endif -#include "../material_cache/prop_material_cache_2d.h" -#include "../prop_mesher_2d.h" -#include "../singleton/prop_cache_2d.h" +#include "../material_cache/prop_material_cache.h" +#include "../prop_mesher.h" +#include "../singleton/prop_cache.h" #include "core/core_string_names.h" -#include "tiled_wall_data_2d.h" +#include "tiled_wall_data.h" -int TiledWall2D::get_width() const { +int TiledWall::get_width() const { return _width; } -void TiledWall2D::set_width(const int value) { +void TiledWall::set_width(const int value) { _width = value; clear_mesh(); generate_mesh(); } -int TiledWall2D::get_heigth() const { +int TiledWall::get_heigth() const { return _height; } -void TiledWall2D::set_heigth(const int value) { +void TiledWall::set_heigth(const int value) { _height = value; clear_mesh(); generate_mesh(); } -Ref TiledWall2D::get_data() { +Ref TiledWall::get_data() { return _data; } -void TiledWall2D::set_data(const Ref &data) { +void TiledWall::set_data(const Ref &data) { if (_data.is_valid()) { _data->disconnect(CoreStringNames::get_singleton()->changed, this, "refresh"); } @@ -62,10 +62,10 @@ void TiledWall2D::set_data(const Ref &data) { call_deferred("refresh"); } -bool TiledWall2D::get_collision() const { +bool TiledWall::get_collision() const { return _collision; } -void TiledWall2D::set_collision(const int value) { +void TiledWall::set_collision(const int value) { _collision = value; /* @@ -80,11 +80,11 @@ void TiledWall2D::set_collision(const int value) { }*/ } -uint32_t TiledWall2D::get_collision_layer() const { +uint32_t TiledWall::get_collision_layer() const { return _collision_layer; } -void TiledWall2D::set_collision_layer(uint32_t p_layer) { +void TiledWall::set_collision_layer(uint32_t p_layer) { _collision_layer = p_layer; if (_physics_body_rid != RID()) { @@ -92,11 +92,11 @@ void TiledWall2D::set_collision_layer(uint32_t p_layer) { } } -uint32_t TiledWall2D::get_collision_mask() const { +uint32_t TiledWall::get_collision_mask() const { return _collision_mask; } -void TiledWall2D::set_collision_mask(uint32_t p_mask) { +void TiledWall::set_collision_mask(uint32_t p_mask) { _collision_mask = p_mask; if (_physics_body_rid != RID()) { @@ -104,11 +104,11 @@ void TiledWall2D::set_collision_mask(uint32_t p_mask) { } } -AABB TiledWall2D::get_aabb() const { +AABB TiledWall::get_aabb() const { return AABB(); } -PoolVector TiledWall2D::get_faces(uint32_t p_usage_flags) const { +PoolVector TiledWall::get_faces(uint32_t p_usage_flags) const { PoolVector faces; if (_mesh_array.size() != Mesh::ARRAY_MAX) { @@ -138,7 +138,7 @@ PoolVector TiledWall2D::get_faces(uint32_t p_usage_flags) const { return faces; } -void TiledWall2D::refresh() { +void TiledWall::refresh() { if (!is_inside_tree()) { return; } @@ -163,14 +163,14 @@ void TiledWall2D::refresh() { VS::get_singleton()->instance_set_base(get_instance(), _mesh_rid); } - Ref old_cache; + Ref old_cache; old_cache = _cache; - _cache = PropCache2D::get_singleton()->tiled_wall_material_cache_get(_data); + _cache = PropCache::get_singleton()->tiled_wall_material_cache_get(_data); if (old_cache.is_valid() && old_cache != _cache) { - PropCache2D::get_singleton()->tiled_wall_material_cache_unref(old_cache); + PropCache::get_singleton()->tiled_wall_material_cache_unref(old_cache); } if (!_cache->get_initialized()) { @@ -192,7 +192,7 @@ void TiledWall2D::refresh() { generate_mesh(); } -void TiledWall2D::generate_mesh() { +void TiledWall::generate_mesh() { if (!_data.is_valid()) { return; } @@ -234,7 +234,7 @@ void TiledWall2D::generate_mesh() { _aabb.size = Vector3(_width, _height, 0); } -void TiledWall2D::clear_mesh() { +void TiledWall::clear_mesh() { _mesher->reset(); _aabb = AABB(); _mesh_array.clear(); @@ -249,7 +249,7 @@ void TiledWall2D::clear_mesh() { } } -void TiledWall2D::free_mesh() { +void TiledWall::free_mesh() { if (_mesh_rid != RID()) { VS::get_singleton()->instance_set_base(get_instance(), RID()); VS::get_singleton()->free(_mesh_rid); @@ -257,7 +257,7 @@ void TiledWall2D::free_mesh() { } } -void TiledWall2D::create_colliders() { +void TiledWall::create_colliders() { if (!is_inside_tree()) { return; } @@ -272,7 +272,7 @@ void TiledWall2D::create_colliders() { PhysicsServer::get_singleton()->body_add_shape(_physics_body_rid, _physics_shape_rid); } -void TiledWall2D::free_colliders() { +void TiledWall::free_colliders() { if (_physics_shape_rid != RID()) { PhysicsServer::get_singleton()->free(_physics_shape_rid); @@ -280,7 +280,7 @@ void TiledWall2D::free_colliders() { } } -TiledWall2D::TiledWall2D() { +TiledWall::TiledWall() { _width = 1; _height = 1; _collision = true; @@ -296,7 +296,7 @@ TiledWall2D::TiledWall2D() { _mesher.instance(); } -TiledWall2D::~TiledWall2D() { +TiledWall::~TiledWall() { _data.unref(); _cache.unref(); _mesher.unref(); @@ -309,7 +309,7 @@ TiledWall2D::~TiledWall2D() { free_colliders(); } -void TiledWall2D::_notification(int p_what) { +void TiledWall::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_WORLD: { Transform t = get_global_transform(); @@ -341,38 +341,38 @@ void TiledWall2D::_notification(int p_what) { } } -void TiledWall2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_width"), &TiledWall2D::get_width); - ClassDB::bind_method(D_METHOD("set_width", "value"), &TiledWall2D::set_width); +void TiledWall::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_width"), &TiledWall::get_width); + ClassDB::bind_method(D_METHOD("set_width", "value"), &TiledWall::set_width); ADD_PROPERTY(PropertyInfo(Variant::INT, "width"), "set_width", "get_width"); - ClassDB::bind_method(D_METHOD("get_heigth"), &TiledWall2D::get_heigth); - ClassDB::bind_method(D_METHOD("set_heigth", "value"), &TiledWall2D::set_heigth); + ClassDB::bind_method(D_METHOD("get_heigth"), &TiledWall::get_heigth); + ClassDB::bind_method(D_METHOD("set_heigth", "value"), &TiledWall::set_heigth); ADD_PROPERTY(PropertyInfo(Variant::INT, "heigth"), "set_heigth", "get_heigth"); - ClassDB::bind_method(D_METHOD("get_data"), &TiledWall2D::get_data); - ClassDB::bind_method(D_METHOD("set_data", "value"), &TiledWall2D::set_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "TiledWallData2D"), "set_data", "get_data"); + ClassDB::bind_method(D_METHOD("get_data"), &TiledWall::get_data); + ClassDB::bind_method(D_METHOD("set_data", "value"), &TiledWall::set_data); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "TiledWallData"), "set_data", "get_data"); - ClassDB::bind_method(D_METHOD("get_collision"), &TiledWall2D::get_collision); - ClassDB::bind_method(D_METHOD("set_collision", "value"), &TiledWall2D::set_collision); + ClassDB::bind_method(D_METHOD("get_collision"), &TiledWall::get_collision); + ClassDB::bind_method(D_METHOD("set_collision", "value"), &TiledWall::set_collision); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision"), "set_collision", "get_collision"); - ClassDB::bind_method(D_METHOD("get_collision_layer"), &TiledWall2D::get_collision_layer); - ClassDB::bind_method(D_METHOD("set_collision_layer", "value"), &TiledWall2D::set_collision_layer); + ClassDB::bind_method(D_METHOD("get_collision_layer"), &TiledWall::get_collision_layer); + ClassDB::bind_method(D_METHOD("set_collision_layer", "value"), &TiledWall::set_collision_layer); - ClassDB::bind_method(D_METHOD("get_collision_mask"), &TiledWall2D::get_collision_mask); - ClassDB::bind_method(D_METHOD("set_collision_mask", "value"), &TiledWall2D::set_collision_mask); + ClassDB::bind_method(D_METHOD("get_collision_mask"), &TiledWall::get_collision_mask); + ClassDB::bind_method(D_METHOD("set_collision_mask", "value"), &TiledWall::set_collision_mask); ADD_GROUP("Collision", "collision_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask"); - ClassDB::bind_method(D_METHOD("refresh"), &TiledWall2D::refresh); - ClassDB::bind_method(D_METHOD("generate_mesh"), &TiledWall2D::generate_mesh); - ClassDB::bind_method(D_METHOD("clear_mesh"), &TiledWall2D::clear_mesh); - ClassDB::bind_method(D_METHOD("free_mesh"), &TiledWall2D::free_mesh); + ClassDB::bind_method(D_METHOD("refresh"), &TiledWall::refresh); + ClassDB::bind_method(D_METHOD("generate_mesh"), &TiledWall::generate_mesh); + ClassDB::bind_method(D_METHOD("clear_mesh"), &TiledWall::clear_mesh); + ClassDB::bind_method(D_METHOD("free_mesh"), &TiledWall::free_mesh); - ClassDB::bind_method(D_METHOD("create_colliders"), &TiledWall2D::create_colliders); - ClassDB::bind_method(D_METHOD("free_colliders"), &TiledWall2D::free_colliders); + ClassDB::bind_method(D_METHOD("create_colliders"), &TiledWall::create_colliders); + ClassDB::bind_method(D_METHOD("free_colliders"), &TiledWall::free_colliders); } diff --git a/tiled_wall/tiled_wall_2d.h b/tiled_wall/tiled_wall.h similarity index 83% rename from tiled_wall/tiled_wall_2d.h rename to tiled_wall/tiled_wall.h index 90f9045..5e54962 100644 --- a/tiled_wall/tiled_wall_2d.h +++ b/tiled_wall/tiled_wall.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2020 Péter Magyar +Copyright (c) 2020-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef TILED_WALL_2D_H -#define TILED_WALL_2D_H +#ifndef TILED_WALL_H +#define TILED_WALL_H #include "core/version.h" #include "scene/resources/texture.h" @@ -38,12 +38,12 @@ SOFTWARE. #include "core/math/vector3.h" -class TiledWallData2D; -class PropMaterialCache2D; -class PropMesher2D; +class TiledWallData; +class PropMaterialCache; +class PropMesher; -class TiledWall2D : public GeometryInstance { - GDCLASS(TiledWall2D, GeometryInstance); +class TiledWall : public GeometryInstance { + GDCLASS(TiledWall, GeometryInstance); public: int get_width() const; @@ -52,8 +52,8 @@ public: int get_heigth() const; void set_heigth(const int value); - Ref get_data(); - void set_data(const Ref &data); + Ref get_data(); + void set_data(const Ref &data); bool get_collision() const; void set_collision(const int value); @@ -75,8 +75,8 @@ public: void create_colliders(); void free_colliders(); - TiledWall2D(); - ~TiledWall2D(); + TiledWall(); + ~TiledWall(); protected: void _notification(int p_what); @@ -90,9 +90,9 @@ private: uint32_t _collision_layer; uint32_t _collision_mask; - Ref _data; - Ref _cache; - Ref _mesher; + Ref _data; + Ref _cache; + Ref _mesher; AABB _aabb; RID _mesh_rid; diff --git a/tiled_wall/tiled_wall_data_2d.cpp b/tiled_wall/tiled_wall_data.cpp similarity index 70% rename from tiled_wall/tiled_wall_data_2d.cpp rename to tiled_wall/tiled_wall_data.cpp index 2df11e5..31a7be6 100644 --- a/tiled_wall/tiled_wall_data_2d.cpp +++ b/tiled_wall/tiled_wall_data.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "tiled_wall_data_2d.h" +#include "tiled_wall_data.h" #if VERSION_MAJOR < 4 #include "servers/physics_server.h" @@ -57,35 +57,35 @@ SOFTWARE. arr_into.push_back(e); \ } -#include "../material_cache/prop_material_cache_2d.h" +#include "../material_cache/prop_material_cache.h" -const String TiledWallData2D::BINDING_STRING_TILED_WALL_TILING_TYPE = "None,Horizontal,Vertical,Both"; +const String TiledWallData::BINDING_STRING_TILED_WALL_TILING_TYPE = "None,Horizontal,Vertical,Both"; -TiledWallData2D::TiledWallTilingType TiledWallData2D::get_tiling_type() const { +TiledWallData::TiledWallTilingType TiledWallData::get_tiling_type() const { return _tiling_type; } -void TiledWallData2D::set_tiling_type(const TiledWallData2D::TiledWallTilingType value) { +void TiledWallData::set_tiling_type(const TiledWallData::TiledWallTilingType value) { _tiling_type = value; emit_changed(); } -Ref TiledWallData2D::get_texture(const int index) const { +Ref TiledWallData::get_texture(const int index) const { ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); return _textures.get(index); } -void TiledWallData2D::set_texture(const int index, const Ref &texture) { +void TiledWallData::set_texture(const int index, const Ref &texture) { ERR_FAIL_INDEX(index, _textures.size()); _textures.set(index, texture); emit_changed(); } -void TiledWallData2D::add_texture(const Ref &texture) { +void TiledWallData::add_texture(const Ref &texture) { _textures.push_back(texture); } -void TiledWallData2D::remove_texture(const int index) { +void TiledWallData::remove_texture(const int index) { ERR_FAIL_INDEX(index, _textures.size()); _textures.remove(index); @@ -93,11 +93,11 @@ void TiledWallData2D::remove_texture(const int index) { emit_changed(); } -int TiledWallData2D::get_texture_count() const { +int TiledWallData::get_texture_count() const { return _textures.size(); } -Vector TiledWallData2D::get_textures() { +Vector TiledWallData::get_textures() { Vector r; for (int i = 0; i < _textures.size(); i++) { #if VERSION_MAJOR < 4 @@ -108,7 +108,7 @@ Vector TiledWallData2D::get_textures() { } return r; } -void TiledWallData2D::set_textures(const Vector &textures) { +void TiledWallData::set_textures(const Vector &textures) { _textures.clear(); for (int i = 0; i < textures.size(); i++) { Ref tex = Ref(textures[i]); @@ -118,22 +118,22 @@ void TiledWallData2D::set_textures(const Vector &textures) { } //flavour_textures -Ref TiledWallData2D::get_flavour_texture(const int index) const { +Ref TiledWallData::get_flavour_texture(const int index) const { ERR_FAIL_INDEX_V(index, _flavour_textures.size(), Ref()); return _flavour_textures.get(index); } -void TiledWallData2D::set_flavour_texture(const int index, const Ref &texture) { +void TiledWallData::set_flavour_texture(const int index, const Ref &texture) { ERR_FAIL_INDEX(index, _flavour_textures.size()); _flavour_textures.set(index, texture); emit_changed(); } -void TiledWallData2D::add_flavour_texture(const Ref &texture) { +void TiledWallData::add_flavour_texture(const Ref &texture) { _flavour_textures.push_back(texture); } -void TiledWallData2D::remove_flavour_texture(const int index) { +void TiledWallData::remove_flavour_texture(const int index) { ERR_FAIL_INDEX(index, _flavour_textures.size()); _flavour_textures.remove(index); @@ -141,11 +141,11 @@ void TiledWallData2D::remove_flavour_texture(const int index) { emit_changed(); } -int TiledWallData2D::get_flavour_texture_count() const { +int TiledWallData::get_flavour_texture_count() const { return _flavour_textures.size(); } -Vector TiledWallData2D::get_flavour_textures() { +Vector TiledWallData::get_flavour_textures() { Vector r; for (int i = 0; i < _flavour_textures.size(); i++) { #if VERSION_MAJOR < 4 @@ -156,7 +156,7 @@ Vector TiledWallData2D::get_flavour_textures() { } return r; } -void TiledWallData2D::set_flavour_textures(const Vector &textures) { +void TiledWallData::set_flavour_textures(const Vector &textures) { _flavour_textures.clear(); for (int i = 0; i < textures.size(); i++) { Ref tex = Ref(textures[i]); @@ -167,21 +167,21 @@ void TiledWallData2D::set_flavour_textures(const Vector &textures) { emit_changed(); } -float TiledWallData2D::get_flavour_chance() const { +float TiledWallData::get_flavour_chance() const { return _flavour_chance; } -void TiledWallData2D::set_flavour_chance(const float value) { +void TiledWallData::set_flavour_chance(const float value) { _flavour_chance = value; } //materials -void TiledWallData2D::material_add(const Ref &value) { +void TiledWallData::material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); _materials.push_back(value); } -void TiledWallData2D::material_set(const int index, const Ref &value) { +void TiledWallData::material_set(const int index, const Ref &value) { ERR_FAIL_INDEX(index, _materials.size()); _materials.set(index, value); @@ -189,25 +189,25 @@ void TiledWallData2D::material_set(const int index, const Ref &value) emit_changed(); } -void TiledWallData2D::material_remove(const int index) { +void TiledWallData::material_remove(const int index) { _materials.remove(index); emit_changed(); } -int TiledWallData2D::material_get_num() const { +int TiledWallData::material_get_num() const { return _materials.size(); } -void TiledWallData2D::materials_clear() { +void TiledWallData::materials_clear() { _materials.clear(); } -Vector TiledWallData2D::materials_get() { +Vector TiledWallData::materials_get() { VARIANT_ARRAY_GET(_materials); } -void TiledWallData2D::materials_set(const Vector &materials) { +void TiledWallData::materials_set(const Vector &materials) { _materials.clear(); for (int i = 0; i < materials.size(); i++) { @@ -220,7 +220,7 @@ void TiledWallData2D::materials_set(const Vector &materials) { } #if TEXTURE_PACKER_PRESENT -void TiledWallData2D::add_textures_into(Ref texture_packer) { +void TiledWallData::add_textures_into(Ref texture_packer) { ERR_FAIL_COND(!texture_packer.is_valid()); for (int i = 0; i < _textures.size(); ++i) { @@ -241,12 +241,12 @@ void TiledWallData2D::add_textures_into(Ref texture_packer) { } #endif -void TiledWallData2D::setup_cache(Ref cache) { +void TiledWallData::setup_cache(Ref cache) { //Note: the caller should lock and unlock the cache! call("_setup_cache", cache); } -void TiledWallData2D::_setup_cache(Ref cache) { +void TiledWallData::_setup_cache(Ref cache) { if (cache->material_get_num() == 0) { for (int i = 0; i < _materials.size(); ++i) { const Ref &m = _materials[i]; @@ -276,7 +276,7 @@ void TiledWallData2D::_setup_cache(Ref cache) { } } -void TiledWallData2D::copy_from(const Ref &tiled_wall_data) { +void TiledWallData::copy_from(const Ref &tiled_wall_data) { ERR_FAIL_COND(!tiled_wall_data.is_valid()); _tiling_type = tiled_wall_data->_tiling_type; @@ -296,70 +296,70 @@ void TiledWallData2D::copy_from(const Ref &tiled_wall_data) { emit_changed(); } -TiledWallData2D::TiledWallData2D() { +TiledWallData::TiledWallData() { _tiling_type = TILED_WALL_TILING_TYPE_NONE; _flavour_chance = 0.15; } -TiledWallData2D::~TiledWallData2D() { +TiledWallData::~TiledWallData() { _textures.clear(); _flavour_textures.clear(); _materials.clear(); } -void TiledWallData2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_tiling_type"), &TiledWallData2D::get_tiling_type); - ClassDB::bind_method(D_METHOD("set_tiling_type", "texture"), &TiledWallData2D::set_tiling_type); - ADD_PROPERTY(PropertyInfo(Variant::INT, "tiling_type", PROPERTY_HINT_ENUM, TiledWallData2D::BINDING_STRING_TILED_WALL_TILING_TYPE), "set_tiling_type", "get_tiling_type"); +void TiledWallData::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_tiling_type"), &TiledWallData::get_tiling_type); + ClassDB::bind_method(D_METHOD("set_tiling_type", "texture"), &TiledWallData::set_tiling_type); + ADD_PROPERTY(PropertyInfo(Variant::INT, "tiling_type", PROPERTY_HINT_ENUM, TiledWallData::BINDING_STRING_TILED_WALL_TILING_TYPE), "set_tiling_type", "get_tiling_type"); //textures - ClassDB::bind_method(D_METHOD("get_texture", "index"), &TiledWallData2D::get_texture); - ClassDB::bind_method(D_METHOD("set_texture", "index", "texture"), &TiledWallData2D::set_texture); - ClassDB::bind_method(D_METHOD("add_texture", "texture"), &TiledWallData2D::add_texture); - ClassDB::bind_method(D_METHOD("remove_texture", "index"), &TiledWallData2D::remove_texture); + ClassDB::bind_method(D_METHOD("get_texture", "index"), &TiledWallData::get_texture); + ClassDB::bind_method(D_METHOD("set_texture", "index", "texture"), &TiledWallData::set_texture); + ClassDB::bind_method(D_METHOD("add_texture", "texture"), &TiledWallData::add_texture); + ClassDB::bind_method(D_METHOD("remove_texture", "index"), &TiledWallData::remove_texture); - ClassDB::bind_method(D_METHOD("get_texture_count"), &TiledWallData2D::get_texture_count); + ClassDB::bind_method(D_METHOD("get_texture_count"), &TiledWallData::get_texture_count); - ClassDB::bind_method(D_METHOD("get_textures"), &TiledWallData2D::get_textures); - ClassDB::bind_method(D_METHOD("set_textures", "textures"), &TiledWallData2D::set_textures); + ClassDB::bind_method(D_METHOD("get_textures"), &TiledWallData::get_textures); + ClassDB::bind_method(D_METHOD("set_textures", "textures"), &TiledWallData::set_textures); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures", PROPERTY_HINT_NONE, "17/17:Texture", PROPERTY_USAGE_DEFAULT, "Texture"), "set_textures", "get_textures"); //flavour_textures - ClassDB::bind_method(D_METHOD("get_flavour_texture", "index"), &TiledWallData2D::get_flavour_texture); - ClassDB::bind_method(D_METHOD("set_flavour_texture", "index", "texture"), &TiledWallData2D::set_flavour_texture); - ClassDB::bind_method(D_METHOD("add_tflavour_exture", "texture"), &TiledWallData2D::add_flavour_texture); - ClassDB::bind_method(D_METHOD("remove_flavour_texture", "index"), &TiledWallData2D::remove_flavour_texture); + ClassDB::bind_method(D_METHOD("get_flavour_texture", "index"), &TiledWallData::get_flavour_texture); + ClassDB::bind_method(D_METHOD("set_flavour_texture", "index", "texture"), &TiledWallData::set_flavour_texture); + ClassDB::bind_method(D_METHOD("add_tflavour_exture", "texture"), &TiledWallData::add_flavour_texture); + ClassDB::bind_method(D_METHOD("remove_flavour_texture", "index"), &TiledWallData::remove_flavour_texture); - ClassDB::bind_method(D_METHOD("get_flavour_texture_count"), &TiledWallData2D::get_flavour_texture_count); + ClassDB::bind_method(D_METHOD("get_flavour_texture_count"), &TiledWallData::get_flavour_texture_count); - ClassDB::bind_method(D_METHOD("get_flavour_textures"), &TiledWallData2D::get_flavour_textures); - ClassDB::bind_method(D_METHOD("set_flavour_textures", "textures"), &TiledWallData2D::set_flavour_textures); + ClassDB::bind_method(D_METHOD("get_flavour_textures"), &TiledWallData::get_flavour_textures); + ClassDB::bind_method(D_METHOD("set_flavour_textures", "textures"), &TiledWallData::set_flavour_textures); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "flavour_textures", PROPERTY_HINT_NONE, "17/17:Texture", PROPERTY_USAGE_DEFAULT, "Texture"), "set_flavour_textures", "get_flavour_textures"); - ClassDB::bind_method(D_METHOD("get_flavour_chance"), &TiledWallData2D::get_flavour_chance); - ClassDB::bind_method(D_METHOD("set_flavour_chance", "texture"), &TiledWallData2D::set_flavour_chance); + ClassDB::bind_method(D_METHOD("get_flavour_chance"), &TiledWallData::get_flavour_chance); + ClassDB::bind_method(D_METHOD("set_flavour_chance", "texture"), &TiledWallData::set_flavour_chance); ADD_PROPERTY(PropertyInfo(Variant::REAL, "flavour_chance"), "set_flavour_chance", "get_flavour_chance"); //materials - ClassDB::bind_method(D_METHOD("material_add", "value"), &TiledWallData2D::material_add); - ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &TiledWallData2D::material_set); - ClassDB::bind_method(D_METHOD("material_remove", "index"), &TiledWallData2D::material_remove); - ClassDB::bind_method(D_METHOD("material_get_num"), &TiledWallData2D::material_get_num); - ClassDB::bind_method(D_METHOD("materials_clear"), &TiledWallData2D::materials_clear); + ClassDB::bind_method(D_METHOD("material_add", "value"), &TiledWallData::material_add); + ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &TiledWallData::material_set); + ClassDB::bind_method(D_METHOD("material_remove", "index"), &TiledWallData::material_remove); + ClassDB::bind_method(D_METHOD("material_get_num"), &TiledWallData::material_get_num); + ClassDB::bind_method(D_METHOD("materials_clear"), &TiledWallData::materials_clear); - ClassDB::bind_method(D_METHOD("materials_get"), &TiledWallData2D::materials_get); - ClassDB::bind_method(D_METHOD("materials_set"), &TiledWallData2D::materials_set); + ClassDB::bind_method(D_METHOD("materials_get"), &TiledWallData::materials_get); + ClassDB::bind_method(D_METHOD("materials_set"), &TiledWallData::materials_set); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get"); #if TEXTURE_PACKER_PRESENT - ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &TiledWallData2D::add_textures_into); + ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &TiledWallData::add_textures_into); #endif - BIND_VMETHOD(MethodInfo("_setup_cache", PropertyInfo(Variant::OBJECT, "cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache2D"))); + BIND_VMETHOD(MethodInfo("_setup_cache", PropertyInfo(Variant::OBJECT, "cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache"))); - ClassDB::bind_method(D_METHOD("setup_cache", "cache"), &TiledWallData2D::setup_cache); - ClassDB::bind_method(D_METHOD("_setup_cache", "cache"), &TiledWallData2D::_setup_cache); + ClassDB::bind_method(D_METHOD("setup_cache", "cache"), &TiledWallData::setup_cache); + ClassDB::bind_method(D_METHOD("_setup_cache", "cache"), &TiledWallData::_setup_cache); - ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &TiledWallData2D::copy_from); + ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &TiledWallData::copy_from); BIND_ENUM_CONSTANT(TILED_WALL_TILING_TYPE_NONE); BIND_ENUM_CONSTANT(TILED_WALL_TILING_TYPE_HORIZONTAL); diff --git a/tiled_wall/tiled_wall_data_2d.h b/tiled_wall/tiled_wall_data.h similarity index 87% rename from tiled_wall/tiled_wall_data_2d.h rename to tiled_wall/tiled_wall_data.h index bdf6127..eeeb422 100644 --- a/tiled_wall/tiled_wall_data_2d.h +++ b/tiled_wall/tiled_wall_data.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2019-2021 Péter Magyar +Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef TILED_WALL_DATA_2D_H -#define TILED_WALL_DATA_2D_H +#ifndef TILED_WALL_DATA_H +#define TILED_WALL_DATA_H #include "core/version.h" @@ -47,11 +47,11 @@ SOFTWARE. #include "../../texture_packer/texture_packer.h" #endif -class PropMaterialCache2D; -class PropMesher2D; +class PropMaterialCache; +class PropMesher; -class TiledWallData2D : public Resource { - GDCLASS(TiledWallData2D, Resource); +class TiledWallData : public Resource { + GDCLASS(TiledWallData, Resource); public: enum TiledWallTilingType { @@ -106,15 +106,15 @@ public: void add_textures_into(Ref texture_packer); #endif - void setup_cache(Ref cache); - void _setup_cache(Ref cache); + void setup_cache(Ref cache); + void _setup_cache(Ref cache); - void copy_from(const Ref &tiled_wall_data); + void copy_from(const Ref &tiled_wall_data); //Ref get_collider_shape(); - TiledWallData2D(); - ~TiledWallData2D(); + TiledWallData(); + ~TiledWallData(); protected: static void _bind_methods(); @@ -129,6 +129,6 @@ private: Vector> _materials; }; -VARIANT_ENUM_CAST(TiledWallData2D::TiledWallTilingType); +VARIANT_ENUM_CAST(TiledWallData::TiledWallTilingType); #endif