From 6f802fcf686302b4f3810bd3a783c22fbbb243e6 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 24 Nov 2021 14:00:16 +0100 Subject: [PATCH] Postfix every class with 2D. --- clutter/ground_clutter_2d.cpp | 18 +- clutter/ground_clutter_2d.h | 8 +- clutter/ground_clutter_foliage_2d.cpp | 22 +- clutter/ground_clutter_foliage_2d.h | 8 +- config.py | 34 +- editor/prop_editor_plugin_2d.cpp | 36 +- editor/prop_editor_plugin_2d.h | 10 +- jobs/prop_mesher_job_step_2d.cpp | 58 ++-- jobs/prop_mesher_job_step_2d.h | 18 +- jobs/prop_texture_job_2d.cpp | 76 ++-- jobs/prop_texture_job_2d.h | 12 +- lights/prop_light_2d.cpp | 30 +- lights/prop_light_2d.h | 8 +- material_cache/prop_material_cache_2d.cpp | 152 ++++---- material_cache/prop_material_cache_2d.h | 14 +- material_cache/prop_material_cache_pcm_2d.cpp | 62 ++-- material_cache/prop_material_cache_pcm_2d.h | 8 +- prop_ess_entity_2d.cpp | 6 +- prop_ess_entity_2d.h | 8 +- prop_instance_2d.cpp | 100 +++--- prop_instance_2d.h | 18 +- prop_instance_job_2d.cpp | 140 ++++---- prop_instance_job_2d.h | 28 +- prop_instance_merger_2d.cpp | 242 ++++++------- prop_instance_merger_2d.h | 16 +- prop_instance_prop_job_2d.cpp | 154 ++++---- prop_instance_prop_job_2d.h | 56 +-- prop_mesher_2d.cpp | 328 +++++++++--------- prop_mesher_2d.h | 26 +- prop_scene_instance_2d.cpp | 36 +- prop_scene_instance_2d.h | 8 +- props/prop_data_2d.cpp | 86 ++--- props/prop_data_2d.h | 18 +- props/prop_data_entry_2d.cpp | 52 +-- props/prop_data_entry_2d.h | 16 +- props/prop_data_light_2d.cpp | 30 +- props/prop_data_light_2d.h | 10 +- props/prop_data_portal_2d.cpp | 54 +-- props/prop_data_portal_2d.h | 10 +- props/prop_data_prop_2d.cpp | 50 +-- props/prop_data_prop_2d.h | 16 +- props/prop_data_scene_2d.cpp | 44 +-- props/prop_data_scene_2d.h | 10 +- props/prop_data_tiled_wall_2d.cpp | 54 +-- props/prop_data_tiled_wall_2d.h | 18 +- register_types.cpp | 84 ++--- singleton/prop_cache_2d.cpp | 186 +++++----- singleton/prop_cache_2d.h | 32 +- singleton/prop_utils_2d.cpp | 100 +++--- singleton/prop_utils_2d.h | 30 +- tiled_wall/tiled_wall_2d.cpp | 92 ++--- tiled_wall/tiled_wall_2d.h | 24 +- tiled_wall/tiled_wall_data_2d.cpp | 128 +++---- tiled_wall/tiled_wall_data_2d.h | 20 +- 54 files changed, 1452 insertions(+), 1452 deletions(-) diff --git a/clutter/ground_clutter_2d.cpp b/clutter/ground_clutter_2d.cpp index 6056679..fa5c6b2 100644 --- a/clutter/ground_clutter_2d.cpp +++ b/clutter/ground_clutter_2d.cpp @@ -25,45 +25,45 @@ SOFTWARE. #ifdef VOXELMAN_PRESENT #include "../../voxelman/world/voxel_chunk.h" -bool GroundClutter::should_spawn(Ref chunk, int x, int y, int z) { +bool GroundClutter2D::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 GroundClutter::add_meshes_to(Ref mesher, Ref chunk, int x, int y, int z) { +void GroundClutter2D::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 GroundClutter::add_textures_to(Ref packer) { +void GroundClutter2D::add_textures_to(Ref packer) { if (has_method("_add_textures_to")) call("_add_textures_to", packer); } #endif -GroundClutter::GroundClutter() { +GroundClutter2D::GroundClutter2D() { } -GroundClutter::~GroundClutter() { +GroundClutter2D::~GroundClutter2D() { } -void GroundClutter::_bind_methods() { +void GroundClutter2D::_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"), &GroundClutter::add_textures_to); + ClassDB::bind_method(D_METHOD("add_textures_to", "packer"), &GroundClutter2D::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"), &GroundClutter::should_spawn); - ClassDB::bind_method(D_METHOD("add_meshes_to", "mesher", "chunk", "x", "y", "z"), &GroundClutter::add_meshes_to); + 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); #endif } diff --git a/clutter/ground_clutter_2d.h b/clutter/ground_clutter_2d.h index ed207a0..e026064 100644 --- a/clutter/ground_clutter_2d.h +++ b/clutter/ground_clutter_2d.h @@ -42,8 +42,8 @@ SOFTWARE. class VoxelChunk; class VoxelMesher; -class GroundClutter : public Resource { - GDCLASS(GroundClutter, Resource); +class GroundClutter2D : public Resource { + GDCLASS(GroundClutter2D, Resource); public: #ifdef VOXELMAN_PRESENT @@ -56,8 +56,8 @@ public: void add_textures_to(Ref packer); #endif - GroundClutter(); - ~GroundClutter(); + GroundClutter2D(); + ~GroundClutter2D(); private: static void _bind_methods(); diff --git a/clutter/ground_clutter_foliage_2d.cpp b/clutter/ground_clutter_foliage_2d.cpp index d536203..c918552 100644 --- a/clutter/ground_clutter_foliage_2d.cpp +++ b/clutter/ground_clutter_foliage_2d.cpp @@ -22,33 +22,33 @@ SOFTWARE. #include "ground_clutter_foliage_2d.h" -int GroundClutterFoliage::get_texture_count() const { +int GroundClutterFoliage2D::get_texture_count() const { return _textures.size(); } -Ref GroundClutterFoliage::get_texture(const int index) { +Ref GroundClutterFoliage2D::get_texture(const int index) { ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); return _textures.get(index); } -void GroundClutterFoliage::remove_texture(const int index) { +void GroundClutterFoliage2D::remove_texture(const int index) { ERR_FAIL_INDEX(index, _textures.size()); _textures.remove(index); } -void GroundClutterFoliage::add_texture(Ref texture) { +void GroundClutterFoliage2D::add_texture(Ref texture) { _textures.push_back(texture); } -GroundClutterFoliage::GroundClutterFoliage() { +GroundClutterFoliage2D::GroundClutterFoliage2D() { } -GroundClutterFoliage::~GroundClutterFoliage() { +GroundClutterFoliage2D::~GroundClutterFoliage2D() { _textures.clear(); } -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); +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); } diff --git a/clutter/ground_clutter_foliage_2d.h b/clutter/ground_clutter_foliage_2d.h index ec206c7..c4f2026 100644 --- a/clutter/ground_clutter_foliage_2d.h +++ b/clutter/ground_clutter_foliage_2d.h @@ -35,8 +35,8 @@ SOFTWARE. #include "scene/resources/texture.h" -class GroundClutterFoliage : public GroundClutter { - GDCLASS(GroundClutterFoliage, GroundClutter); +class GroundClutterFoliage2D : public GroundClutter2D { + GDCLASS(GroundClutterFoliage2D, GroundClutter2D); public: int get_texture_count() const; @@ -44,8 +44,8 @@ public: void remove_texture(const int index); void add_texture(Ref texture); - GroundClutterFoliage(); - ~GroundClutterFoliage(); + GroundClutterFoliage2D(); + ~GroundClutterFoliage2D(); private: static void _bind_methods(); diff --git a/config.py b/config.py index 7c136b9..cb7bb82 100644 --- a/config.py +++ b/config.py @@ -10,29 +10,29 @@ def configure(env): def get_doc_classes(): return [ - "PropDataEntry", - "PropDataLight", - "PropDataProp", - "PropDataScene", - "PropDataPortal", - "PropDataTiledWall", - "PropData", + "PropDataEntry2D", + "PropDataLight2D", + "PropDataProp2D", + "PropDataScene2D", + "PropDataPortal2D", + "PropDataTiledWall2D", + "PropData2D", - "TiledWall", - "TiledWallData", + "TiledWall2D", + "TiledWallData2D", - "PropDataProcessor", + "PropDataProcessor2D", - "GroundClutterFoliage", - "GroundClutter", + "GroundClutterFoliage2D", + "GroundClutter2D", - "PropESSEntity", - "PropInstance", - "PropMeshUtils", + "PropESSEntity2D", + "PropInstance2D", + "PropMeshUtils2D", - "PropSceneInstance", + "PropSceneInstance2D", - "PropUtils", + "PropUtils2D", ] def get_doc_path(): diff --git a/editor/prop_editor_plugin_2d.cpp b/editor/prop_editor_plugin_2d.cpp index 220a6ce..b1d90b1 100644 --- a/editor/prop_editor_plugin_2d.cpp +++ b/editor/prop_editor_plugin_2d.cpp @@ -41,7 +41,7 @@ SOFTWARE. #define DISCONNECT(sig, obj, target_method_class, method) disconnect(sig, callable_mp(obj, &target_method_class::method)) #endif -void PropEditorPlugin::convert_active_scene_to_prop_data() { +void PropEditorPlugin2D::convert_active_scene_to_prop_data() { SceneTree *st = SceneTree::get_singleton(); if (st) { @@ -55,17 +55,17 @@ void PropEditorPlugin::convert_active_scene_to_prop_data() { } } } -void PropEditorPlugin::convert_selected_scene_to_prop_data() { +void PropEditorPlugin2D::convert_selected_scene_to_prop_data() { } -void PropEditorPlugin::convert_scene(Node *root, const String &path) { - Ref data = PropUtils::get_singleton()->convert_tree(root); +void PropEditorPlugin2D::convert_scene(Node *root, const String &path) { + Ref data = PropUtils2D::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 PropEditorPlugin::convert_scene(Node *root, const String &path) { } } -void PropEditorPlugin::find_room_points(Variant param) { +void PropEditorPlugin2D::find_room_points(Variant param) { #if VERSION_MINOR >= 4 SceneTree *st = SceneTree::get_singleton(); @@ -89,24 +89,24 @@ void PropEditorPlugin::find_room_points(Variant param) { Node *scene = st->get_edited_scene_root(); if (scene) { - PropUtils::get_singleton()->generate_room_points_node(scene); + PropUtils2D::get_singleton()->generate_room_points_node(scene); } } #endif } -void PropEditorPlugin::_quick_convert_button_pressed() { +void PropEditorPlugin2D::_quick_convert_button_pressed() { convert_active_scene_to_prop_data(); } -void PropEditorPlugin::_convert_active_scene_to_prop_data(Variant param) { +void PropEditorPlugin2D::_convert_active_scene_to_prop_data(Variant param) { convert_active_scene_to_prop_data(); } -void PropEditorPlugin::_convert_selected_scene_to_prop_data(Variant param) { +void PropEditorPlugin2D::_convert_selected_scene_to_prop_data(Variant param) { convert_selected_scene_to_prop_data(); } -PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) { +PropEditorPlugin2D::PropEditorPlugin2D(EditorNode *p_node) { editor = p_node; #if VERSION_MAJOR < 4 @@ -126,21 +126,21 @@ PropEditorPlugin::PropEditorPlugin(EditorNode *p_node) { container->add_child(b); b->set_flat(true); - b->CONNECT("pressed", this, PropEditorPlugin, _quick_convert_button_pressed); + b->CONNECT("pressed", this, PropEditorPlugin2D, _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); } -PropEditorPlugin::~PropEditorPlugin() { +PropEditorPlugin2D::~PropEditorPlugin2D() { } -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); +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); - ClassDB::bind_method(D_METHOD("find_room_points"), &PropEditorPlugin::find_room_points); + ClassDB::bind_method(D_METHOD("find_room_points"), &PropEditorPlugin2D::find_room_points); - ClassDB::bind_method(D_METHOD("_quick_convert_button_pressed"), &PropEditorPlugin::_quick_convert_button_pressed); + ClassDB::bind_method(D_METHOD("_quick_convert_button_pressed"), &PropEditorPlugin2D::_quick_convert_button_pressed); } diff --git a/editor/prop_editor_plugin_2d.h b/editor/prop_editor_plugin_2d.h index ea82140..6c46ef6 100644 --- a/editor/prop_editor_plugin_2d.h +++ b/editor/prop_editor_plugin_2d.h @@ -28,16 +28,16 @@ SOFTWARE. #include "core/version.h" -class PropEditorPlugin : public EditorPlugin { +class PropEditorPlugin2D : public EditorPlugin { - GDCLASS(PropEditorPlugin, EditorPlugin); + GDCLASS(PropEditorPlugin2D, EditorPlugin); EditorNode *editor; protected: static void _bind_methods(); public: - virtual String get_name() const { return "PropEditorPlugin"; } + virtual String get_name() const { return "PropEditorPlugin2D"; } 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(); - PropEditorPlugin(EditorNode *p_node); - ~PropEditorPlugin(); + PropEditorPlugin2D(EditorNode *p_node); + ~PropEditorPlugin2D(); }; #endif diff --git a/jobs/prop_mesher_job_step_2d.cpp b/jobs/prop_mesher_job_step_2d.cpp index 0f0ddb6..0f8635f 100644 --- a/jobs/prop_mesher_job_step_2d.cpp +++ b/jobs/prop_mesher_job_step_2d.cpp @@ -22,54 +22,54 @@ SOFTWARE. #include "prop_mesher_job_step_2d.h" -const String PropMesherJobStep::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh"; +const String PropMesherJobStep2D::BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE = "Normal,Normal LOD,Drop UV2,Merge Verts,Bake Texture,Simplify Mesh"; -PropMesherJobStep::PropMesherJobStepType PropMesherJobStep::get_job_type() const { +PropMesherJobStep2D::PropMesherJobStepType2D PropMesherJobStep2D::get_job_type() const { return _job_type; } -void PropMesherJobStep::set_job_type(const PropMesherJobStep::PropMesherJobStepType value) { +void PropMesherJobStep2D::set_job_type(const PropMesherJobStep2D::PropMesherJobStepType2D value) { _job_type = value; } -int PropMesherJobStep::get_lod_index() const { +int PropMesherJobStep2D::get_lod_index() const { return _lod_index; } -void PropMesherJobStep::set_lod_index(const int value) { +void PropMesherJobStep2D::set_lod_index(const int value) { _lod_index = value; } #ifdef MESH_UTILS_PRESENT -Ref PropMesherJobStep::get_fqms() { +Ref PropMesherJobStep2D::get_fqms() { return _fqms; } -void PropMesherJobStep::set_fqms(const Ref &val) { +void PropMesherJobStep2D::set_fqms(const Ref &val) { _fqms = val; } -float PropMesherJobStep::get_simplification_step_ratio() const { +float PropMesherJobStep2D::get_simplification_step_ratio() const { return _simplification_step_ratio; } -void PropMesherJobStep::set_simplification_step_ratio(const float value) { +void PropMesherJobStep2D::set_simplification_step_ratio(const float value) { _simplification_step_ratio = value; } -int PropMesherJobStep::get_simplification_steps() const { +int PropMesherJobStep2D::get_simplification_steps() const { return _simplification_steps; } -void PropMesherJobStep::set_simplification_steps(const int value) { +void PropMesherJobStep2D::set_simplification_steps(const int value) { _simplification_steps = value; } -float PropMesherJobStep::get_simplification_agressiveness() const { +float PropMesherJobStep2D::get_simplification_agressiveness() const { return _simplification_agressiveness; } -void PropMesherJobStep::set_simplification_agressiveness(const float value) { +void PropMesherJobStep2D::set_simplification_agressiveness(const float value) { _simplification_agressiveness = value; } #endif -PropMesherJobStep::PropMesherJobStep() { +PropMesherJobStep2D::PropMesherJobStep2D() { _job_type = TYPE_NORMAL; _lod_index = 0; @@ -80,36 +80,36 @@ PropMesherJobStep::PropMesherJobStep() { #endif } -PropMesherJobStep::~PropMesherJobStep() { +PropMesherJobStep2D::~PropMesherJobStep2D() { #ifdef MESH_UTILS_PRESENT _fqms.unref(); #endif } -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"); +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"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_index"), "set_lod_index", "get_lod_index"); #ifdef MESH_UTILS_PRESENT - ClassDB::bind_method(D_METHOD("get_fqms"), &PropMesherJobStep::get_fqms); - ClassDB::bind_method(D_METHOD("set_fqms", "value"), &PropMesherJobStep::set_fqms); + ClassDB::bind_method(D_METHOD("get_fqms"), &PropMesherJobStep2D::get_fqms); + ClassDB::bind_method(D_METHOD("set_fqms", "value"), &PropMesherJobStep2D::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"), &PropMesherJobStep::get_simplification_step_ratio); - ClassDB::bind_method(D_METHOD("set_simplification_step_ratio", "value"), &PropMesherJobStep::set_simplification_step_ratio); + 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); ADD_PROPERTY(PropertyInfo(Variant::REAL, "simplification_step_ratio"), "set_simplification_step_ratio", "get_simplification_step_ratio"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::INT, "simplification_steps"), "set_simplification_steps", "get_simplification_steps"); - 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); + 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); 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_2d.h index b67cdf1..346d84e 100644 --- a/jobs/prop_mesher_job_step_2d.h +++ b/jobs/prop_mesher_job_step_2d.h @@ -35,15 +35,15 @@ SOFTWARE. #include "../../mesh_utils/fast_quadratic_mesh_simplifier.h" #endif -class PropMesherJobStep : public Reference { - GDCLASS(PropMesherJobStep, Reference); +class PropMesherJobStep2D : public Reference { + GDCLASS(PropMesherJobStep2D, 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 PropMesherJobStepType { + enum PropMesherJobStepType2D { TYPE_NORMAL = 0, TYPE_NORMAL_LOD, TYPE_DROP_UV2, @@ -55,8 +55,8 @@ public: static const String BINDING_STRING_PROP_MESHER_JOB_STEP_TYPE; - PropMesherJobStepType get_job_type() const; - void set_job_type(const PropMesherJobStepType value); + PropMesherJobStepType2D get_job_type() const; + void set_job_type(const PropMesherJobStepType2D 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 - PropMesherJobStep(); - ~PropMesherJobStep(); + PropMesherJobStep2D(); + ~PropMesherJobStep2D(); protected: static void _bind_methods(); - PropMesherJobStepType _job_type; + PropMesherJobStepType2D _job_type; int _lod_index; #ifdef MESH_UTILS_PRESENT @@ -92,6 +92,6 @@ protected: #endif }; -VARIANT_ENUM_CAST(PropMesherJobStep::PropMesherJobStepType); +VARIANT_ENUM_CAST(PropMesherJobStep2D::PropMesherJobStepType2D); #endif diff --git a/jobs/prop_texture_job_2d.cpp b/jobs/prop_texture_job_2d.cpp index 8829273..d1c0f19 100644 --- a/jobs/prop_texture_job_2d.cpp +++ b/jobs/prop_texture_job_2d.cpp @@ -27,16 +27,16 @@ SOFTWARE. #endif #if TEXTURE_PACKER_PRESENT -Ref PropTextureJob::get_merger() { +Ref PropTextureJob2D::get_merger() { return _merger; } -void PropTextureJob::set_merger(const Ref &merger) { +void PropTextureJob2D::set_merger(const Ref &merger) { _merger = merger; } #endif -void PropTextureJob::_execute() { +void PropTextureJob2D::_execute() { #if TEXTURE_PACKER_PRESENT if (!_merger.is_valid()) { set_complete(true); @@ -49,7 +49,7 @@ void PropTextureJob::_execute() { set_complete(true); } -PropTextureJob::PropTextureJob() { +PropTextureJob2D::PropTextureJob2D() { #if !THREAD_POOL_PRESENT _complete = true; _cancelled = false; @@ -62,110 +62,110 @@ PropTextureJob::PropTextureJob() { #endif } -PropTextureJob::~PropTextureJob() { +PropTextureJob2D::~PropTextureJob2D() { } -void PropTextureJob::_bind_methods() { +void PropTextureJob2D::_bind_methods() { #if TEXTURE_PACKER_PRESENT - ClassDB::bind_method(D_METHOD("get_merger"), &PropTextureJob::get_merger); - ClassDB::bind_method(D_METHOD("set_merger", "value"), &PropTextureJob::set_merger); + ClassDB::bind_method(D_METHOD("get_merger"), &PropTextureJob2D::get_merger); + ClassDB::bind_method(D_METHOD("set_merger", "value"), &PropTextureJob2D::set_merger); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "merger", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker"), "set_merger", "get_merger"); #endif - ClassDB::bind_method(D_METHOD("_execute"), &PropTextureJob::_execute); + ClassDB::bind_method(D_METHOD("_execute"), &PropTextureJob2D::_execute); #if !THREAD_POOL_PRESENT - ClassDB::bind_method(D_METHOD("get_complete"), &PropTextureJob::get_complete); - ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropTextureJob::set_complete); + ClassDB::bind_method(D_METHOD("get_complete"), &PropTextureJob2D::get_complete); + ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropTextureJob2D::set_complete); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "complete"), "set_complete", "get_complete"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::INT, "start_time"), "set_start_time", "get_start_time"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::INT, "current_run_stage"), "set_current_run_stage", "get_current_run_stage"); - ClassDB::bind_method(D_METHOD("get_stage"), &PropTextureJob::get_stage); - ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropTextureJob::set_stage); + ClassDB::bind_method(D_METHOD("get_stage"), &PropTextureJob2D::get_stage); + ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropTextureJob2D::set_stage); ADD_PROPERTY(PropertyInfo(Variant::INT, "stage"), "set_stage", "get_stage"); - ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropTextureJob::get_current_execution_time); + ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropTextureJob2D::get_current_execution_time); - ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropTextureJob::should_do, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("should_return"), &PropTextureJob::should_return); + ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropTextureJob2D::should_do, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("should_return"), &PropTextureJob2D::should_return); BIND_VMETHOD(MethodInfo("_execute")); - ClassDB::bind_method(D_METHOD("execute"), &PropTextureJob::execute); + ClassDB::bind_method(D_METHOD("execute"), &PropTextureJob2D::execute); ADD_SIGNAL(MethodInfo("completed")); #endif } #if !THREAD_POOL_PRESENT -bool PropTextureJob::get_complete() const { +bool PropTextureJob2D::get_complete() const { return _complete; } -void PropTextureJob::set_complete(const bool value) { +void PropTextureJob2D::set_complete(const bool value) { _complete = value; } -bool PropTextureJob::get_cancelled() const { +bool PropTextureJob2D::get_cancelled() const { return _cancelled; } -void PropTextureJob::set_cancelled(const bool value) { +void PropTextureJob2D::set_cancelled(const bool value) { _cancelled = value; } -float PropTextureJob::get_max_allocated_time() const { +float PropTextureJob2D::get_max_allocated_time() const { return _max_allocated_time; } -void PropTextureJob::set_max_allocated_time(const float value) { +void PropTextureJob2D::set_max_allocated_time(const float value) { _max_allocated_time = value; } -int PropTextureJob::get_start_time() const { +int PropTextureJob2D::get_start_time() const { return _start_time; } -void PropTextureJob::set_start_time(const int value) { +void PropTextureJob2D::set_start_time(const int value) { _start_time = value; } -int PropTextureJob::get_current_run_stage() const { +int PropTextureJob2D::get_current_run_stage() const { return _current_run_stage; } -void PropTextureJob::set_current_run_stage(const int value) { +void PropTextureJob2D::set_current_run_stage(const int value) { _current_run_stage = value; } -int PropTextureJob::get_stage() const { +int PropTextureJob2D::get_stage() const { return _stage; } -void PropTextureJob::set_stage(const int value) { +void PropTextureJob2D::set_stage(const int value) { _stage = value; } -void PropTextureJob::reset_stages() { +void PropTextureJob2D::reset_stages() { _current_run_stage = 0; _stage = 0; } -float PropTextureJob::get_current_execution_time() { +float PropTextureJob2D::get_current_execution_time() { return 0; } -bool PropTextureJob::should_do(const bool just_check) { +bool PropTextureJob2D::should_do(const bool just_check) { return true; } -bool PropTextureJob::should_return() { +bool PropTextureJob2D::should_return() { if (_cancelled) return true; return false; } -void PropTextureJob::execute() { +void PropTextureJob2D::execute() { ERR_FAIL_COND(!has_method("_execute")); call("_execute"); diff --git a/jobs/prop_texture_job_2d.h b/jobs/prop_texture_job_2d.h index d661950..b300aa3 100644 --- a/jobs/prop_texture_job_2d.h +++ b/jobs/prop_texture_job_2d.h @@ -43,11 +43,11 @@ class TexturePacker; #endif #if THREAD_POOL_PRESENT -class PropTextureJob : public ThreadPoolJob { - GDCLASS(PropTextureJob, ThreadPoolJob); +class PropTextureJob2D : public ThreadPoolJob { + GDCLASS(PropTextureJob2D, ThreadPoolJob); #else -class PropTextureJob : public Reference { - GDCLASS(PropTextureJob, Reference); +class PropTextureJob2D : public Reference { + GDCLASS(PropTextureJob2D, Reference); #endif public: @@ -58,8 +58,8 @@ public: void _execute(); - PropTextureJob(); - ~PropTextureJob(); + PropTextureJob2D(); + ~PropTextureJob2D(); protected: static void _bind_methods(); diff --git a/lights/prop_light_2d.cpp b/lights/prop_light_2d.cpp index c5c4a5c..76feb35 100644 --- a/lights/prop_light_2d.cpp +++ b/lights/prop_light_2d.cpp @@ -22,44 +22,44 @@ SOFTWARE. #include "prop_light_2d.h" -Vector3 PropLight::get_position() { +Vector3 PropLight2D::get_position() { return _position; } -void PropLight::set_position(const Vector3 &pos) { +void PropLight2D::set_position(const Vector3 &pos) { _position = pos; } -Color PropLight::get_color() const { +Color PropLight2D::get_color() const { return _color; } -void PropLight::set_color(const Color &color) { +void PropLight2D::set_color(const Color &color) { _color = color; } -float PropLight::get_size() const { +float PropLight2D::get_size() const { return _size; } -void PropLight::set_size(const float size) { +void PropLight2D::set_size(const float size) { _size = size; } -PropLight::PropLight() { +PropLight2D::PropLight2D() { _size = 0; } -PropLight::~PropLight() { +PropLight2D::~PropLight2D() { } -void PropLight::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_position"), &PropLight::get_position); - ClassDB::bind_method(D_METHOD("set_position"), &PropLight::set_position); +void PropLight2D::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_position"), &PropLight2D::get_position); + ClassDB::bind_method(D_METHOD("set_position"), &PropLight2D::set_position); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "world_position"), "set_position", "get_position"); - ClassDB::bind_method(D_METHOD("get_color"), &PropLight::get_color); - ClassDB::bind_method(D_METHOD("set_color"), &PropLight::set_color); + ClassDB::bind_method(D_METHOD("get_color"), &PropLight2D::get_color); + ClassDB::bind_method(D_METHOD("set_color"), &PropLight2D::set_color); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); - ClassDB::bind_method(D_METHOD("get_size"), &PropLight::get_size); - ClassDB::bind_method(D_METHOD("set_size"), &PropLight::set_size); + ClassDB::bind_method(D_METHOD("get_size"), &PropLight2D::get_size); + ClassDB::bind_method(D_METHOD("set_size"), &PropLight2D::set_size); ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size"); } diff --git a/lights/prop_light_2d.h b/lights/prop_light_2d.h index 7487ca2..19c4ea0 100644 --- a/lights/prop_light_2d.h +++ b/lights/prop_light_2d.h @@ -35,8 +35,8 @@ SOFTWARE. #include "core/color.h" #endif -class PropLight : public Reference { - GDCLASS(PropLight, Reference); +class PropLight2D : public Reference { + GDCLASS(PropLight2D, Reference); public: Vector3 get_position(); @@ -48,8 +48,8 @@ public: float get_size() const; void set_size(const float strength); - PropLight(); - ~PropLight(); + PropLight2D(); + ~PropLight2D(); private: static void _bind_methods(); diff --git a/material_cache/prop_material_cache_2d.cpp b/material_cache/prop_material_cache_2d.cpp index 4c44e2d..aed9510 100644 --- a/material_cache/prop_material_cache_2d.cpp +++ b/material_cache/prop_material_cache_2d.cpp @@ -54,44 +54,44 @@ SOFTWARE. #endif -bool PropMaterialCache::get_initialized() { +bool PropMaterialCache2D::get_initialized() { return _initialized; } -void PropMaterialCache::set_initialized(const bool value) { +void PropMaterialCache2D::set_initialized(const bool value) { _initialized = value; } -bool PropMaterialCache::mutex_locked() { +bool PropMaterialCache2D::mutex_locked() { return _locked; } -void PropMaterialCache::mutex_lock() { +void PropMaterialCache2D::mutex_lock() { _mutex.lock(); } -void PropMaterialCache::mutex_unlock() { +void PropMaterialCache2D::mutex_unlock() { _mutex.unlock(); } -int PropMaterialCache::get_ref_count() { +int PropMaterialCache2D::get_ref_count() { return _ref_count; } -void PropMaterialCache::set_ref_count(const int value) { +void PropMaterialCache2D::set_ref_count(const int value) { _ref_count = value; } -void PropMaterialCache::inc_ref_count() { +void PropMaterialCache2D::inc_ref_count() { _ref_count += 1; } -void PropMaterialCache::dec_ref_count() { +void PropMaterialCache2D::dec_ref_count() { _ref_count -= 1; } //Materials -Ref PropMaterialCache::material_get(const int index) { +Ref PropMaterialCache2D::material_get(const int index) { ERR_FAIL_INDEX_V(index, _materials.size(), Ref(NULL)); return _materials[index]; } -Ref PropMaterialCache::material_lod_get(const int index) { +Ref PropMaterialCache2D::material_lod_get(const int index) { ERR_FAIL_COND_V(_materials.size() == 0, Ref(NULL)); if (index < 0) { @@ -105,35 +105,35 @@ Ref PropMaterialCache::material_lod_get(const int index) { return _materials[index]; } -void PropMaterialCache::material_add(const Ref &value) { +void PropMaterialCache2D::material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); _materials.push_back(value); } -void PropMaterialCache::material_set(const int index, const Ref &value) { +void PropMaterialCache2D::material_set(const int index, const Ref &value) { ERR_FAIL_INDEX(index, _materials.size()); _materials.set(index, value); } -void PropMaterialCache::material_remove(const int index) { +void PropMaterialCache2D::material_remove(const int index) { _materials.remove(index); } -int PropMaterialCache::material_get_num() const { +int PropMaterialCache2D::material_get_num() const { return _materials.size(); } -void PropMaterialCache::materials_clear() { +void PropMaterialCache2D::materials_clear() { _materials.clear(); } -Vector PropMaterialCache::materials_get() { +Vector PropMaterialCache2D::materials_get() { VARIANT_ARRAY_GET(_materials); } -void PropMaterialCache::materials_set(const Vector &materials) { +void PropMaterialCache2D::materials_set(const Vector &materials) { _materials.clear(); for (int i = 0; i < materials.size(); i++) { @@ -143,10 +143,10 @@ void PropMaterialCache::materials_set(const Vector &materials) { } } -void PropMaterialCache::texture_add(const Ref &texture) { +void PropMaterialCache2D::texture_add(const Ref &texture) { _textures.push_back(texture); } -void PropMaterialCache::texture_remove(const Ref &texture) { +void PropMaterialCache2D::texture_remove(const Ref &texture) { for (int i = 0; i < _textures.size(); ++i) { if (_textures[i] == texture) { _textures.remove(i); @@ -154,42 +154,42 @@ void PropMaterialCache::texture_remove(const Ref &texture) { } } } -void PropMaterialCache::texture_remove_index(const int index) { +void PropMaterialCache2D::texture_remove_index(const int index) { ERR_FAIL_INDEX(index, _textures.size()); _textures.remove(index); } -void PropMaterialCache::textures_clear() { +void PropMaterialCache2D::textures_clear() { _textures.clear(); } -int PropMaterialCache::texture_count() { +int PropMaterialCache2D::texture_count() { return _textures.size(); } -Ref PropMaterialCache::texture_get(const int index) { +Ref PropMaterialCache2D::texture_get(const int index) { ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); return _textures[index]; } -Ref PropMaterialCache::texture_get_atlas(const int index) { +Ref PropMaterialCache2D::texture_get_atlas(const int index) { ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); return texture_get_atlas_tex(_textures[index]); } -Ref PropMaterialCache::texture_get_atlas_tex(const Ref &texture) { +Ref PropMaterialCache2D::texture_get_atlas_tex(const Ref &texture) { return Ref(); } -Rect2 PropMaterialCache::texture_get_uv_rect(const Ref &texture) { +Rect2 PropMaterialCache2D::texture_get_uv_rect(const Ref &texture) { return Rect2(0, 0, 1, 1); } -void PropMaterialCache::prop_add_textures(const Ref &prop) { +void PropMaterialCache2D::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 +203,34 @@ void PropMaterialCache::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 PropMaterialCache::prop_remove_textures(const Ref &prop) { +void PropMaterialCache2D::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 +242,10 @@ void PropMaterialCache::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 +269,7 @@ void PropMaterialCache::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 +277,14 @@ void PropMaterialCache::prop_remove_textures(const Ref &prop) { } } -void PropMaterialCache::refresh_rects() { +void PropMaterialCache2D::refresh_rects() { _initialized = true; } -void PropMaterialCache::initial_setup_default() { +void PropMaterialCache2D::initial_setup_default() { //Note: call only on the main thread! Shader->duplicate() can crash if done from an another thread! - PropCache *pc = PropCache::get_singleton(); + PropCache2D *pc = PropCache2D::get_singleton(); pc->ensure_materials_loaded(); @@ -300,64 +300,64 @@ void PropMaterialCache::initial_setup_default() { } } -void PropMaterialCache::setup_material_albedo(Ref texture) { +void PropMaterialCache2D::setup_material_albedo(Ref texture) { if (has_method("_setup_material_albedo")) call("_setup_material_albedo", texture); } -PropMaterialCache::PropMaterialCache() { +PropMaterialCache2D::PropMaterialCache2D() { _ref_count = 0; _initialized = false; _locked = false; } -PropMaterialCache::~PropMaterialCache() { +PropMaterialCache2D::~PropMaterialCache2D() { _materials.clear(); } -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); +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); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "initialized"), "set_initialized", "get_initialized"); - 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("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("get_ref_count"), &PropMaterialCache::get_ref_count); - ClassDB::bind_method(D_METHOD("set_ref_count", "value"), &PropMaterialCache::set_ref_count); + 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); ADD_PROPERTY(PropertyInfo(Variant::INT, "mat_ref_count"), "set_ref_count", "get_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); + ClassDB::bind_method(D_METHOD("inc_ref_count"), &PropMaterialCache2D::inc_ref_count); + ClassDB::bind_method(D_METHOD("dec_ref_count"), &PropMaterialCache2D::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"), &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("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("materials_get"), &PropMaterialCache::materials_get); - ClassDB::bind_method(D_METHOD("materials_set"), &PropMaterialCache::materials_set); + ClassDB::bind_method(D_METHOD("materials_get"), &PropMaterialCache2D::materials_get); + ClassDB::bind_method(D_METHOD("materials_set"), &PropMaterialCache2D::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"), &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("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("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("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("refresh_rects"), &PropMaterialCache::refresh_rects); + ClassDB::bind_method(D_METHOD("refresh_rects"), &PropMaterialCache2D::refresh_rects); - ClassDB::bind_method(D_METHOD("setup_material_albedo", "texture"), &PropMaterialCache::setup_material_albedo); + ClassDB::bind_method(D_METHOD("setup_material_albedo", "texture"), &PropMaterialCache2D::setup_material_albedo); } diff --git a/material_cache/prop_material_cache_2d.h b/material_cache/prop_material_cache_2d.h index ffac2e5..4832ae2 100644 --- a/material_cache/prop_material_cache_2d.h +++ b/material_cache/prop_material_cache_2d.h @@ -39,10 +39,10 @@ SOFTWARE. #include "scene/resources/material.h" #include "core/os/mutex.h" -class PropData; +class PropData2D; -class PropMaterialCache : public Resource { - GDCLASS(PropMaterialCache, Resource) +class PropMaterialCache2D : public Resource { + GDCLASS(PropMaterialCache2D, 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); - PropMaterialCache(); - ~PropMaterialCache(); + PropMaterialCache2D(); + ~PropMaterialCache2D(); protected: static void _bind_methods(); diff --git a/material_cache/prop_material_cache_pcm_2d.cpp b/material_cache/prop_material_cache_pcm_2d.cpp index b417e0a..8db74fd 100644 --- a/material_cache/prop_material_cache_pcm_2d.cpp +++ b/material_cache/prop_material_cache_pcm_2d.cpp @@ -26,49 +26,49 @@ SOFTWARE. #include "../singleton/prop_cache_2d.h" #include "scene/resources/texture.h" -int PropMaterialCachePCM::get_texture_flags() const { +int PropMaterialCachePCM2D::get_texture_flags() const { return _packer->get_texture_flags(); } -void PropMaterialCachePCM::set_texture_flags(const int flags) { +void PropMaterialCachePCM2D::set_texture_flags(const int flags) { _packer->set_texture_flags(flags); } -int PropMaterialCachePCM::get_max_atlas_size() const { +int PropMaterialCachePCM2D::get_max_atlas_size() const { return _packer->get_max_atlas_size(); } -void PropMaterialCachePCM::set_max_atlas_size(const int size) { +void PropMaterialCachePCM2D::set_max_atlas_size(const int size) { _packer->set_max_atlas_size(size); } -bool PropMaterialCachePCM::get_keep_original_atlases() const { +bool PropMaterialCachePCM2D::get_keep_original_atlases() const { return _packer->get_keep_original_atlases(); } -void PropMaterialCachePCM::set_keep_original_atlases(const bool value) { +void PropMaterialCachePCM2D::set_keep_original_atlases(const bool value) { _packer->set_keep_original_atlases(value); } -Color PropMaterialCachePCM::get_background_color() const { +Color PropMaterialCachePCM2D::get_background_color() const { return _packer->get_background_color(); } -void PropMaterialCachePCM::set_background_color(const Color &color) { +void PropMaterialCachePCM2D::set_background_color(const Color &color) { _packer->set_background_color(color); } -int PropMaterialCachePCM::get_margin() const { +int PropMaterialCachePCM2D::get_margin() const { return _packer->get_margin(); } -void PropMaterialCachePCM::set_margin(const int margin) { +void PropMaterialCachePCM2D::set_margin(const int margin) { _packer->set_margin(margin); } -Ref PropMaterialCachePCM::texture_get_atlas_tex(const Ref &texture) { +Ref PropMaterialCachePCM2D::texture_get_atlas_tex(const Ref &texture) { if (!_packer->contains_texture(texture)) { return Ref(); } return _packer->get_texture(texture); } -Rect2 PropMaterialCachePCM::texture_get_uv_rect(const Ref &texture) { +Rect2 PropMaterialCachePCM2D::texture_get_uv_rect(const Ref &texture) { if (!texture.is_valid()) { return Rect2(0, 0, 1, 1); } @@ -102,7 +102,7 @@ Rect2 PropMaterialCachePCM::texture_get_uv_rect(const Ref &texture) { return region; } -void PropMaterialCachePCM::refresh_rects() { +void PropMaterialCachePCM2D::refresh_rects() { bool texture_added = false; for (int i = 0; i < _textures.size(); i++) { @@ -129,10 +129,10 @@ void PropMaterialCachePCM::refresh_rects() { _initialized = true; } -void PropMaterialCachePCM::initial_setup_default() { - PropMaterialCache::initial_setup_default(); +void PropMaterialCachePCM2D::initial_setup_default() { + PropMaterialCache2D::initial_setup_default(); - PropCache *pc = PropCache::get_singleton(); + PropCache2D *pc = PropCache2D::get_singleton(); set_texture_flags(pc->get_texture_flags()); set_max_atlas_size(pc->get_max_atlas_size()); @@ -141,7 +141,7 @@ void PropMaterialCachePCM::initial_setup_default() { set_margin(pc->get_margin()); } -void PropMaterialCachePCM::_setup_material_albedo(Ref texture) { +void PropMaterialCachePCM2D::_setup_material_albedo(Ref texture) { int count = material_get_num(); for (int i = 0; i < count; ++i) { @@ -162,7 +162,7 @@ void PropMaterialCachePCM::_setup_material_albedo(Ref texture) { } } -PropMaterialCachePCM::PropMaterialCachePCM() { +PropMaterialCachePCM2D::PropMaterialCachePCM2D() { _packer.instance(); #if GODOT4 @@ -176,31 +176,31 @@ PropMaterialCachePCM::PropMaterialCachePCM() { _packer->set_margin(0); } -PropMaterialCachePCM::~PropMaterialCachePCM() { +PropMaterialCachePCM2D::~PropMaterialCachePCM2D() { _packer->clear(); _packer.unref(); } -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); +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); 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"), &PropMaterialCachePCM::get_max_atlas_size); - ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropMaterialCachePCM::set_max_atlas_size); + 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); 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"), &PropMaterialCachePCM::get_keep_original_atlases); - ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropMaterialCachePCM::set_keep_original_atlases); + 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); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_original_atlases"), "set_keep_original_atlases", "get_keep_original_atlases"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_background_color", "get_background_color"); - ClassDB::bind_method(D_METHOD("get_margin"), &PropMaterialCachePCM::get_margin); - ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropMaterialCachePCM::set_margin); + ClassDB::bind_method(D_METHOD("get_margin"), &PropMaterialCachePCM2D::get_margin); + ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropMaterialCachePCM2D::set_margin); ADD_PROPERTY(PropertyInfo(Variant::INT, "margin"), "set_margin", "get_margin"); - ClassDB::bind_method(D_METHOD("_setup_material_albedo", "texture"), &PropMaterialCachePCM::_setup_material_albedo); + ClassDB::bind_method(D_METHOD("_setup_material_albedo", "texture"), &PropMaterialCachePCM2D::_setup_material_albedo); } diff --git a/material_cache/prop_material_cache_pcm_2d.h b/material_cache/prop_material_cache_pcm_2d.h index 9a41a9f..1fc8eca 100644 --- a/material_cache/prop_material_cache_pcm_2d.h +++ b/material_cache/prop_material_cache_pcm_2d.h @@ -43,8 +43,8 @@ SOFTWARE. class TexturePacker; class PropData; -class PropMaterialCachePCM : public PropMaterialCache { - GDCLASS(PropMaterialCachePCM, PropMaterialCache); +class PropMaterialCachePCM2D : public PropMaterialCache2D { + GDCLASS(PropMaterialCachePCM2D, PropMaterialCache2D); public: int get_texture_flags() const; @@ -71,8 +71,8 @@ public: void _setup_material_albedo(Ref texture); - PropMaterialCachePCM(); - ~PropMaterialCachePCM(); + PropMaterialCachePCM2D(); + ~PropMaterialCachePCM2D(); protected: static void _bind_methods(); diff --git a/prop_ess_entity_2d.cpp b/prop_ess_entity_2d.cpp index 6b6d918..a7c3f94 100644 --- a/prop_ess_entity_2d.cpp +++ b/prop_ess_entity_2d.cpp @@ -1,9 +1,9 @@ #include "prop_ess_entity_2d.h" -PropESSEntity::PropESSEntity() { +PropESSEntity2D::PropESSEntity2D() { } -PropESSEntity::~PropESSEntity() { +PropESSEntity2D::~PropESSEntity2D() { } -void PropESSEntity::_bind_methods() { +void PropESSEntity2D::_bind_methods() { } diff --git a/prop_ess_entity_2d.h b/prop_ess_entity_2d.h index f486ffd..9c0ae69 100644 --- a/prop_ess_entity_2d.h +++ b/prop_ess_entity_2d.h @@ -35,13 +35,13 @@ SOFTWARE. #include "core/math/vector3.h" -class PropESSEntity : public Spatial { - GDCLASS(PropESSEntity, Spatial); +class PropESSEntity2D : public Spatial { + GDCLASS(PropESSEntity2D, Spatial); OBJ_CATEGORY("Props"); public: - PropESSEntity(); - ~PropESSEntity(); + PropESSEntity2D(); + ~PropESSEntity2D(); protected: static void _bind_methods(); diff --git a/prop_instance_2d.cpp b/prop_instance_2d.cpp index cc14296..5922a02 100644 --- a/prop_instance_2d.cpp +++ b/prop_instance_2d.cpp @@ -28,10 +28,10 @@ #include "tiled_wall/tiled_wall_2d.h" #include "tiled_wall/tiled_wall_data_2d.h" -Ref PropInstance::get_prop_data() { +Ref PropInstance2D::get_prop_data() { return _prop_data; } -void PropInstance::set_prop_data(const Ref &data) { +void PropInstance2D::set_prop_data(const Ref &data) { if (_prop_data == data) return; @@ -44,58 +44,58 @@ void PropInstance::set_prop_data(const Ref &data) { } } -Ref PropInstance::get_material() { +Ref PropInstance2D::get_material() { return _material; } -void PropInstance::set_material(const Ref &material) { +void PropInstance2D::set_material(const Ref &material) { _material = material; } -uint32_t PropInstance::get_collision_layer() const { +uint32_t PropInstance2D::get_collision_layer() const { return _collision_layer; } -void PropInstance::set_collision_layer(uint32_t p_layer) { +void PropInstance2D::set_collision_layer(uint32_t p_layer) { _collision_layer = p_layer; collision_layer_changed(); } -uint32_t PropInstance::get_collision_mask() const { +uint32_t PropInstance2D::get_collision_mask() const { return _collision_mask; } -void PropInstance::set_collision_mask(uint32_t p_mask) { +void PropInstance2D::set_collision_mask(uint32_t p_mask) { _collision_mask = p_mask; collision_mask_changed(); } -void PropInstance::collision_layer_changed() { +void PropInstance2D::collision_layer_changed() { } -void PropInstance::collision_mask_changed() { +void PropInstance2D::collision_mask_changed() { } -void PropInstance::init_materials() { +void PropInstance2D::init_materials() { call("_init_materials"); } -void PropInstance::_init_materials() { +void PropInstance2D::_init_materials() { } -void PropInstance::build() { +void PropInstance2D::build() { call("_build"); } -void PropInstance::queue_build() { +void PropInstance2D::queue_build() { _build_queued = true; } -void PropInstance::build_finished() { +void PropInstance2D::build_finished() { call("_build_finished"); } -void PropInstance::_build() { +void PropInstance2D::_build() { _building = true; _build_queued = false; @@ -118,7 +118,7 @@ void PropInstance::_build() { prop_preprocess(Transform(), _prop_data); } -void PropInstance::_build_finished() { +void PropInstance2D::_build_finished() { _building = false; if (_build_queued) { @@ -126,28 +126,28 @@ void PropInstance::_build_finished() { } } -void PropInstance::prop_preprocess(Transform transform, const Ref &prop) { +void PropInstance2D::prop_preprocess(Transform transform, const Ref &prop) { call("_prop_preprocess", transform, prop); } -void PropInstance::_prop_preprocess(Transform transform, const Ref &prop) { +void PropInstance2D::_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 PropInstance::_prop_preprocess(Transform transform, const Ref &pr continue; } - Ref tiled_wall_data = e; + Ref tiled_wall_data = e; if (tiled_wall_data.is_valid()) { - TiledWall *twn = memnew(TiledWall); + TiledWall2D *twn = memnew(TiledWall2D); twn->set_width(tiled_wall_data->get_width()); twn->set_heigth(tiled_wall_data->get_heigth()); @@ -174,7 +174,7 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref &pr 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 PropInstance::_prop_preprocess(Transform transform, const Ref &pr continue; } - Ref light_data = e; + Ref light_data = e; if (light_data.is_valid()) { OmniLight *light = memnew(OmniLight); @@ -207,7 +207,7 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref &pr } #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 PropInstance::_prop_preprocess(Transform transform, const Ref &pr } } -PropInstance::PropInstance() { +PropInstance2D::PropInstance2D() { _build_queued = false; _building = false; @@ -259,11 +259,11 @@ PropInstance::PropInstance() { _collision_mask = 1; } -PropInstance::~PropInstance() { +PropInstance2D::~PropInstance2D() { _prop_data.unref(); } -void PropInstance::_notification(int p_what) { +void PropInstance2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { if (_prop_data.is_valid()) { @@ -275,20 +275,20 @@ void PropInstance::_notification(int p_what) { } } -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"); +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"); - ClassDB::bind_method(D_METHOD("get_material"), &PropInstance::get_material); - ClassDB::bind_method(D_METHOD("set_material", "material"), &PropInstance::set_material); + ClassDB::bind_method(D_METHOD("get_material"), &PropInstance2D::get_material); + ClassDB::bind_method(D_METHOD("set_material", "material"), &PropInstance2D::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"), &PropInstance::get_collision_layer); - ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &PropInstance::set_collision_layer); + 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_mask"), &PropInstance::get_collision_mask); - ClassDB::bind_method(D_METHOD("set_collision_mask", "layer"), &PropInstance::set_collision_mask); + 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); 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 PropInstance::_bind_methods() { BIND_VMETHOD(MethodInfo("_prop_preprocess", PropertyInfo(Variant::TRANSFORM, "tarnsform"), - PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"))); + PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D"))); - ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &PropInstance::prop_preprocess); - ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &PropInstance::_prop_preprocess); + ClassDB::bind_method(D_METHOD("prop_preprocess", "tarnsform", "prop"), &PropInstance2D::prop_preprocess); + ClassDB::bind_method(D_METHOD("_prop_preprocess", "tarnsform", "prop"), &PropInstance2D::_prop_preprocess); //--- BIND_VMETHOD(MethodInfo("_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("init_materials"), &PropInstance2D::init_materials); + ClassDB::bind_method(D_METHOD("_init_materials"), &PropInstance2D::_init_materials); //--- - 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); + 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); BIND_VMETHOD(MethodInfo("_build")); BIND_VMETHOD(MethodInfo("_build_finished")); - ClassDB::bind_method(D_METHOD("_build"), &PropInstance::_build); - ClassDB::bind_method(D_METHOD("_build_finished"), &PropInstance::_build_finished); + ClassDB::bind_method(D_METHOD("_build"), &PropInstance2D::_build); + ClassDB::bind_method(D_METHOD("_build_finished"), &PropInstance2D::_build_finished); } diff --git a/prop_instance_2d.h b/prop_instance_2d.h index fd0a2de..6b0117e 100644 --- a/prop_instance_2d.h +++ b/prop_instance_2d.h @@ -39,12 +39,12 @@ SOFTWARE. #include "props/prop_data_2d.h" -class PropInstance : public Spatial { - GDCLASS(PropInstance, Spatial); +class PropInstance2D : public Spatial { + GDCLASS(PropInstance2D, 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); - PropInstance(); - ~PropInstance(); + PropInstance2D(); + ~PropInstance2D(); 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_2d.cpp index 787ba09..f863b35 100644 --- a/prop_instance_job_2d.cpp +++ b/prop_instance_job_2d.cpp @@ -28,47 +28,47 @@ SOFTWARE. #include "../opensimplex/open_simplex_noise.h" -const String PropInstanceJob::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process"; +const String PropInstanceJob2D::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process"; -PropInstanceJob::ActiveBuildPhaseType PropInstanceJob::get_build_phase_type() { +PropInstanceJob2D::ActiveBuildPhaseType PropInstanceJob2D::get_build_phase_type() { return _build_phase_type; } -void PropInstanceJob::set_build_phase_type(PropInstanceJob::ActiveBuildPhaseType build_phase_type) { +void PropInstanceJob2D::set_build_phase_type(PropInstanceJob2D::ActiveBuildPhaseType build_phase_type) { _build_phase_type = build_phase_type; } -void PropInstanceJob::set_prop(const Ref &prop) { +void PropInstanceJob2D::set_prop(const Ref &prop) { _prop = prop; _in_tree = true; } -void PropInstanceJob::set_prop_instance(PropInstance *instance) { +void PropInstanceJob2D::set_prop_instance(PropInstance2D *instance) { _instance = instance; } -void PropInstanceJob::set_prop_instance_bind(Node *instance) { - set_prop_instance(Object::cast_to(instance)); +void PropInstanceJob2D::set_prop_instance_bind(Node *instance) { + set_prop_instance(Object::cast_to(instance)); } -int PropInstanceJob::get_phase() { +int PropInstanceJob2D::get_phase() { return _phase; } -void PropInstanceJob::set_phase(const int phase) { +void PropInstanceJob2D::set_phase(const int phase) { _phase = phase; } -void PropInstanceJob::next_phase() { +void PropInstanceJob2D::next_phase() { ++_phase; } -bool PropInstanceJob::get_build_done() { +bool PropInstanceJob2D::get_build_done() { return _build_done; } -void PropInstanceJob::set_build_done(const bool val) { +void PropInstanceJob2D::set_build_done(const bool val) { _build_done = val; } -void PropInstanceJob::finished() { +void PropInstanceJob2D::finished() { set_build_done(true); if (_instance) { @@ -76,15 +76,15 @@ void PropInstanceJob::finished() { } } -void PropInstanceJob::reset() { +void PropInstanceJob2D::reset() { call("_reset"); } -void PropInstanceJob::_reset() { +void PropInstanceJob2D::_reset() { _build_done = false; _phase = 0; } -void PropInstanceJob::_execute() { +void PropInstanceJob2D::_execute() { ActiveBuildPhaseType origpt = _build_phase_type; while (!get_cancelled() && _in_tree && !_build_done && origpt == _build_phase_type && !should_return()) { @@ -92,28 +92,28 @@ void PropInstanceJob::_execute() { } } -void PropInstanceJob::execute_phase() { +void PropInstanceJob2D::execute_phase() { call("_execute_phase"); } -void PropInstanceJob::_execute_phase() { +void PropInstanceJob2D::_execute_phase() { finished(); } -void PropInstanceJob::process(const float delta) { +void PropInstanceJob2D::process(const float delta) { if (has_method("_process")) call("_process", delta); } -void PropInstanceJob::physics_process(const float delta) { +void PropInstanceJob2D::physics_process(const float delta) { if (has_method("_physics_process")) call("_physics_process", delta); } -void PropInstanceJob::prop_instance_enter_tree() { +void PropInstanceJob2D::prop_instance_enter_tree() { _in_tree = true; } -void PropInstanceJob::prop_instance_exit_tree() { +void PropInstanceJob2D::prop_instance_exit_tree() { _in_tree = false; if (get_complete()) { @@ -123,7 +123,7 @@ void PropInstanceJob::prop_instance_exit_tree() { } } -PropInstanceJob::PropInstanceJob() { +PropInstanceJob2D::PropInstanceJob2D() { _instance = NULL; _in_tree = false; @@ -143,137 +143,137 @@ PropInstanceJob::PropInstanceJob() { #endif } -PropInstanceJob::~PropInstanceJob() { +PropInstanceJob2D::~PropInstanceJob2D() { _prop.unref(); _instance = NULL; } -void PropInstanceJob::_bind_methods() { +void PropInstanceJob2D::_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"), &PropInstanceJob::get_build_phase_type); - ClassDB::bind_method(D_METHOD("set_build_phase_type", "value"), &PropInstanceJob::set_build_phase_type); + 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); 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"), &PropInstanceJob::set_prop); - ClassDB::bind_method(D_METHOD("set_prop_instance", "instance"), &PropInstanceJob::set_prop_instance_bind); + 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("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_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_build_done"), &PropInstanceJob::get_build_done); - ClassDB::bind_method(D_METHOD("set_build_done", "val"), &PropInstanceJob::set_build_done); + 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("finished"), &PropInstanceJob::finished); + ClassDB::bind_method(D_METHOD("finished"), &PropInstanceJob2D::finished); BIND_VMETHOD(MethodInfo("_reset")); - ClassDB::bind_method(D_METHOD("reset"), &PropInstanceJob::reset); - ClassDB::bind_method(D_METHOD("_reset"), &PropInstanceJob::_reset); + ClassDB::bind_method(D_METHOD("reset"), &PropInstanceJob2D::reset); + ClassDB::bind_method(D_METHOD("_reset"), &PropInstanceJob2D::_reset); - ClassDB::bind_method(D_METHOD("_execute"), &PropInstanceJob::_execute); + ClassDB::bind_method(D_METHOD("_execute"), &PropInstanceJob2D::_execute); BIND_VMETHOD(MethodInfo("_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("execute_phase"), &PropInstanceJob2D::execute_phase); + ClassDB::bind_method(D_METHOD("_execute_phase"), &PropInstanceJob2D::_execute_phase); - ClassDB::bind_method(D_METHOD("prop_instance_exit_tree"), &PropInstanceJob::prop_instance_exit_tree); + ClassDB::bind_method(D_METHOD("prop_instance_exit_tree"), &PropInstanceJob2D::prop_instance_exit_tree); #if !THREAD_POOL_PRESENT - ClassDB::bind_method(D_METHOD("get_complete"), &PropInstanceJob::get_complete); - ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropInstanceJob::set_complete); + ClassDB::bind_method(D_METHOD("get_complete"), &PropInstanceJob2D::get_complete); + ClassDB::bind_method(D_METHOD("set_complete", "value"), &PropInstanceJob2D::set_complete); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "complete"), "set_complete", "get_complete"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::INT, "start_time"), "set_start_time", "get_start_time"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::INT, "current_run_stage"), "set_current_run_stage", "get_current_run_stage"); - ClassDB::bind_method(D_METHOD("get_stage"), &PropInstanceJob::get_stage); - ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropInstanceJob::set_stage); + ClassDB::bind_method(D_METHOD("get_stage"), &PropInstanceJob2D::get_stage); + ClassDB::bind_method(D_METHOD("set_stage", "value"), &PropInstanceJob2D::set_stage); ADD_PROPERTY(PropertyInfo(Variant::INT, "stage"), "set_stage", "get_stage"); - ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropInstanceJob::get_current_execution_time); + ClassDB::bind_method(D_METHOD("get_current_execution_time"), &PropInstanceJob2D::get_current_execution_time); - ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropInstanceJob::should_do, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("should_return"), &PropInstanceJob::should_return); + ClassDB::bind_method(D_METHOD("should_do", "just_check"), &PropInstanceJob2D::should_do, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("should_return"), &PropInstanceJob2D::should_return); BIND_VMETHOD(MethodInfo("_execute")); - ClassDB::bind_method(D_METHOD("execute"), &PropInstanceJob::execute); + ClassDB::bind_method(D_METHOD("execute"), &PropInstanceJob2D::execute); ADD_SIGNAL(MethodInfo("completed")); #endif } #if !THREAD_POOL_PRESENT -bool PropInstanceJob::get_complete() const { +bool PropInstanceJob2D::get_complete() const { return _complete; } -void PropInstanceJob::set_complete(const bool value) { +void PropInstanceJob2D::set_complete(const bool value) { _complete = value; } -bool PropInstanceJob::get_cancelled() const { +bool PropInstanceJob2D::get_cancelled() const { return _cancelled; } -void PropInstanceJob::set_cancelled(const bool value) { +void PropInstanceJob2D::set_cancelled(const bool value) { _cancelled = value; } -float PropInstanceJob::get_max_allocated_time() const { +float PropInstanceJob2D::get_max_allocated_time() const { return _max_allocated_time; } -void PropInstanceJob::set_max_allocated_time(const float value) { +void PropInstanceJob2D::set_max_allocated_time(const float value) { _max_allocated_time = value; } -int PropInstanceJob::get_start_time() const { +int PropInstanceJob2D::get_start_time() const { return _start_time; } -void PropInstanceJob::set_start_time(const int value) { +void PropInstanceJob2D::set_start_time(const int value) { _start_time = value; } -int PropInstanceJob::get_current_run_stage() const { +int PropInstanceJob2D::get_current_run_stage() const { return _current_run_stage; } -void PropInstanceJob::set_current_run_stage(const int value) { +void PropInstanceJob2D::set_current_run_stage(const int value) { _current_run_stage = value; } -int PropInstanceJob::get_stage() const { +int PropInstanceJob2D::get_stage() const { return _stage; } -void PropInstanceJob::set_stage(const int value) { +void PropInstanceJob2D::set_stage(const int value) { _stage = value; } -void PropInstanceJob::reset_stages() { +void PropInstanceJob2D::reset_stages() { _current_run_stage = 0; _stage = 0; } -float PropInstanceJob::get_current_execution_time() { +float PropInstanceJob2D::get_current_execution_time() { return 0; } -bool PropInstanceJob::should_do(const bool just_check) { +bool PropInstanceJob2D::should_do(const bool just_check) { return true; } -bool PropInstanceJob::should_return() { +bool PropInstanceJob2D::should_return() { if (_cancelled) return true; return false; } -void PropInstanceJob::execute() { +void PropInstanceJob2D::execute() { ERR_FAIL_COND(!has_method("_execute")); call("_execute"); diff --git a/prop_instance_job_2d.h b/prop_instance_job_2d.h index fe0121f..b9e9710 100644 --- a/prop_instance_job_2d.h +++ b/prop_instance_job_2d.h @@ -40,15 +40,15 @@ SOFTWARE. #endif -class PropData; -class PropInstance; +class PropData2D; +class PropInstance2D; #if THREAD_POOL_PRESENT -class PropInstanceJob : public ThreadPoolJob { - GDCLASS(PropInstanceJob, ThreadPoolJob); +class PropInstanceJob2D : public ThreadPoolJob { + GDCLASS(PropInstanceJob2D, ThreadPoolJob); #else -class PropInstanceJob : public Reference { - GDCLASS(PropInstanceJob, Reference); +class PropInstanceJob2D : public Reference { + GDCLASS(PropInstanceJob2D, Reference); #endif public: @@ -62,10 +62,10 @@ public: public: ActiveBuildPhaseType get_build_phase_type(); - void set_build_phase_type(PropInstanceJob::ActiveBuildPhaseType build_phase_type); + void set_build_phase_type(PropInstanceJob2D::ActiveBuildPhaseType build_phase_type); - void set_prop(const Ref &prop); - void set_prop_instance(PropInstance *instance); + void set_prop(const Ref &prop); + void set_prop_instance(PropInstance2D *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(); - PropInstanceJob(); - ~PropInstanceJob(); + PropInstanceJob2D(); + ~PropInstanceJob2D(); protected: static void _bind_methods(); @@ -101,8 +101,8 @@ protected: bool _build_done; int _phase; bool _in_tree; - Ref _prop; - PropInstance *_instance; + Ref _prop; + PropInstance2D *_instance; public: #if !THREAD_POOL_PRESENT @@ -145,6 +145,6 @@ private: #endif }; -VARIANT_ENUM_CAST(PropInstanceJob::ActiveBuildPhaseType); +VARIANT_ENUM_CAST(PropInstanceJob2D::ActiveBuildPhaseType); #endif diff --git a/prop_instance_merger_2d.cpp b/prop_instance_merger_2d.cpp index 97c39c4..354644a 100644 --- a/prop_instance_merger_2d.cpp +++ b/prop_instance_merger_2d.cpp @@ -67,12 +67,12 @@ typedef class RenderingServer VS; #include "scene/resources/box_shape.h" -const float PropInstanceMerger::LOD_CHECK_INTERVAL = 2; +const float PropInstanceMerger2D::LOD_CHECK_INTERVAL = 2; -bool PropInstanceMerger::get_building() { +bool PropInstanceMerger2D::get_building() { return _building; } -void PropInstanceMerger::set_building(const bool value) { +void PropInstanceMerger2D::set_building(const bool value) { _building = value; set_physics_process_internal(_building); @@ -82,10 +82,10 @@ void PropInstanceMerger::set_building(const bool value) { } } -int PropInstanceMerger::get_lod_level() { +int PropInstanceMerger2D::get_lod_level() { return _lod_level; } -void PropInstanceMerger::set_lod_level(const int value) { +void PropInstanceMerger2D::set_lod_level(const int value) { _lod_level = value; if (_lod_level < 0) { @@ -95,62 +95,62 @@ void PropInstanceMerger::set_lod_level(const int value) { apply_lod_level(); } -bool PropInstanceMerger::get_auto_lod() { +bool PropInstanceMerger2D::get_auto_lod() { return _auto_lod; } -void PropInstanceMerger::set_auto_lod(const bool value) { +void PropInstanceMerger2D::set_auto_lod(const bool value) { _auto_lod = value; check_auto_lod(); } -float PropInstanceMerger::get_first_lod_distance_squared() { +float PropInstanceMerger2D::get_first_lod_distance_squared() { return _first_lod_distance_squared; } -void PropInstanceMerger::set_first_lod_distance_squared(const float dist) { +void PropInstanceMerger2D::set_first_lod_distance_squared(const float dist) { _first_lod_distance_squared = dist; } -float PropInstanceMerger::get_lod_reduction_distance_squared() { +float PropInstanceMerger2D::get_lod_reduction_distance_squared() { return _lod_reduction_distance_squared; } -void PropInstanceMerger::set_lod_reduction_distance_squared(const float dist) { +void PropInstanceMerger2D::set_lod_reduction_distance_squared(const float dist) { _lod_reduction_distance_squared = dist; } -Ref PropInstanceMerger::get_job() { +Ref PropInstanceMerger2D::get_job() { return _job; } -void PropInstanceMerger::set_job(const Ref &job) { +void PropInstanceMerger2D::set_job(const Ref &job) { _job = job; } //Materials -Ref PropInstanceMerger::material_get(const int index) { +Ref PropInstanceMerger2D::material_get(const int index) { ERR_FAIL_INDEX_V(index, _materials.size(), Ref(NULL)); return _materials[index]; } -void PropInstanceMerger::material_add(const Ref &value) { +void PropInstanceMerger2D::material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); _materials.push_back(value); } -int PropInstanceMerger::material_get_num() const { +int PropInstanceMerger2D::material_get_num() const { return _materials.size(); } -void PropInstanceMerger::materials_clear() { +void PropInstanceMerger2D::materials_clear() { _materials.clear(); } -Vector PropInstanceMerger::materials_get() { +Vector PropInstanceMerger2D::materials_get() { VARIANT_ARRAY_GET(_materials); } -void PropInstanceMerger::materials_set(const Vector &materials) { +void PropInstanceMerger2D::materials_set(const Vector &materials) { _materials.clear(); for (int i = 0; i < materials.size(); i++) { @@ -161,19 +161,19 @@ void PropInstanceMerger::materials_set(const Vector &materials) { } //Meshes -RID PropInstanceMerger::mesh_get(const int index) { +RID PropInstanceMerger2D::mesh_get(const int index) { ERR_FAIL_INDEX_V(index, _meshes.size(), RID()); return _meshes[index].mesh; } -RID PropInstanceMerger::mesh_instance_get(const int index) { +RID PropInstanceMerger2D::mesh_instance_get(const int index) { ERR_FAIL_INDEX_V(index, _meshes.size(), RID()); return _meshes[index].mesh_instance; } -void PropInstanceMerger::mesh_add(const RID mesh_instance, const RID mesh) { +void PropInstanceMerger2D::mesh_add(const RID mesh_instance, const RID mesh) { MeshEntry e; e.mesh = mesh; e.mesh_instance = mesh_instance; @@ -181,15 +181,15 @@ void PropInstanceMerger::mesh_add(const RID mesh_instance, const RID mesh) { _meshes.push_back(e); } -int PropInstanceMerger::mesh_get_num() const { +int PropInstanceMerger2D::mesh_get_num() const { return _meshes.size(); } -void PropInstanceMerger::meshes_clear() { +void PropInstanceMerger2D::meshes_clear() { _meshes.clear(); } -void PropInstanceMerger::meshes_create(const int num) { +void PropInstanceMerger2D::meshes_create(const int num) { free_meshes(); for (int i = 0; i < num; ++i) { @@ -216,7 +216,7 @@ void PropInstanceMerger::meshes_create(const int num) { apply_lod_level(); } -Vector PropInstanceMerger::meshes_get() { +Vector PropInstanceMerger2D::meshes_get() { Vector r; for (int i = 0; i < _meshes.size(); i++) { Array a; @@ -229,7 +229,7 @@ Vector PropInstanceMerger::meshes_get() { return r; } -void PropInstanceMerger::meshes_set(const Vector &meshs) { +void PropInstanceMerger2D::meshes_set(const Vector &meshs) { _meshes.clear(); for (int i = 0; i < _meshes.size(); i++) { @@ -247,31 +247,31 @@ void PropInstanceMerger::meshes_set(const Vector &meshs) { //Collider -Transform PropInstanceMerger::collider_local_transform_get(const int index) { +Transform PropInstanceMerger2D::collider_local_transform_get(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), Transform()); return _colliders[index].transform; } -RID PropInstanceMerger::collider_body_get(const int index) { +RID PropInstanceMerger2D::collider_body_get(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), RID()); return _colliders[index].body; } -Ref PropInstanceMerger::collider_shape_get(const int index) { +Ref PropInstanceMerger2D::collider_shape_get(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), Ref()); return _colliders[index].shape; } -RID PropInstanceMerger::collider_shape_rid_get(const int index) { +RID PropInstanceMerger2D::collider_shape_rid_get(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), RID()); return _colliders[index].shape_rid; } -int PropInstanceMerger::collider_add(const Transform &local_transform, const Ref &shape, const RID &shape_rid, const RID &body, const bool owns_shape) { +int PropInstanceMerger2D::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 +288,15 @@ int PropInstanceMerger::collider_add(const Transform &local_transform, const Ref return index; } -int PropInstanceMerger::collider_get_num() const { +int PropInstanceMerger2D::collider_get_num() const { return _colliders.size(); } -void PropInstanceMerger::colliders_clear() { +void PropInstanceMerger2D::colliders_clear() { _colliders.clear(); } -Vector PropInstanceMerger::colliders_get() { +Vector PropInstanceMerger2D::colliders_get() { Vector r; for (int i = 0; i < _colliders.size(); i++) { r.push_back(_colliders[i].body); @@ -304,7 +304,7 @@ Vector PropInstanceMerger::colliders_get() { return r; } -void PropInstanceMerger::colliders_set(const Vector &colliders) { +void PropInstanceMerger2D::colliders_set(const Vector &colliders) { _colliders.clear(); for (int i = 0; i < colliders.size(); i++) { @@ -317,7 +317,7 @@ void PropInstanceMerger::colliders_set(const Vector &colliders) { } } -void PropInstanceMerger::check_auto_lod() { +void PropInstanceMerger2D::check_auto_lod() { if (!_auto_lod) { _auto_lod_on = false; return; @@ -337,7 +337,7 @@ void PropInstanceMerger::check_auto_lod() { set_process_internal(true); } -void PropInstanceMerger::apply_lod_level() { +void PropInstanceMerger2D::apply_lod_level() { if (_meshes.size() == 0) { return; } @@ -377,7 +377,7 @@ void PropInstanceMerger::apply_lod_level() { vs->instance_set_visible(mi, true); } -void PropInstanceMerger::debug_mesh_allocate() { +void PropInstanceMerger2D::debug_mesh_allocate() { if (_debug_mesh_rid == RID()) { _debug_mesh_rid = VisualServer::get_singleton()->mesh_create(); } @@ -393,7 +393,7 @@ void PropInstanceMerger::debug_mesh_allocate() { VS::get_singleton()->instance_set_visible(_debug_mesh_instance, true); } } -void PropInstanceMerger::debug_mesh_free() { +void PropInstanceMerger2D::debug_mesh_free() { if (_debug_mesh_instance != RID()) { VisualServer::get_singleton()->free(_debug_mesh_instance); } @@ -402,25 +402,25 @@ void PropInstanceMerger::debug_mesh_free() { VisualServer::get_singleton()->free(_debug_mesh_rid); } } -bool PropInstanceMerger::debug_mesh_has() { +bool PropInstanceMerger2D::debug_mesh_has() { return _debug_mesh_rid != RID(); } -void PropInstanceMerger::debug_mesh_clear() { +void PropInstanceMerger2D::debug_mesh_clear() { if (_debug_mesh_rid != RID()) { VisualServer::get_singleton()->mesh_clear(_debug_mesh_rid); } } -void PropInstanceMerger::debug_mesh_array_clear() { +void PropInstanceMerger2D::debug_mesh_array_clear() { _debug_mesh_array.resize(0); } -void PropInstanceMerger::debug_mesh_add_vertices_to(const PoolVector3Array &arr) { +void PropInstanceMerger2D::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 PropInstanceMerger::debug_mesh_send() { +void PropInstanceMerger2D::debug_mesh_send() { debug_mesh_allocate(); debug_mesh_clear(); @@ -442,7 +442,7 @@ void PropInstanceMerger::debug_mesh_send() { debug_mesh_array_clear(); } -void PropInstanceMerger::draw_debug_mdr_colliders() { +void PropInstanceMerger2D::draw_debug_mdr_colliders() { if (!debug_mesh_has()) { debug_mesh_allocate(); } @@ -462,7 +462,7 @@ void PropInstanceMerger::draw_debug_mdr_colliders() { debug_mesh_send(); } -void PropInstanceMerger::free_meshes() { +void PropInstanceMerger2D::free_meshes() { RID rid; for (int i = 0; i < _meshes.size(); ++i) { @@ -481,7 +481,7 @@ void PropInstanceMerger::free_meshes() { } } -void PropInstanceMerger::free_colliders() { +void PropInstanceMerger2D::free_colliders() { for (int i = 0; i < _colliders.size(); ++i) { ColliderBody &e = _colliders.write[i]; @@ -496,10 +496,10 @@ void PropInstanceMerger::free_colliders() { } } -void PropInstanceMerger::_init_materials() { +void PropInstanceMerger2D::_init_materials() { } -void PropInstanceMerger::_build() { +void PropInstanceMerger2D::_build() { if (_building) { return; } @@ -541,7 +541,7 @@ void PropInstanceMerger::_build() { _job->reset(); _job->set_complete(false); - Ref cache = PropCache::get_singleton()->material_cache_get(_prop_data); + Ref cache = PropCache2D::get_singleton()->material_cache_get(_prop_data); if (cache->material_get_num() == 0) { //lock it! @@ -574,7 +574,7 @@ Don't submit here, as it starts in physics process mode */ } -void PropInstanceMerger::_build_finished() { +void PropInstanceMerger2D::_build_finished() { set_building(false); apply_lod_level(); @@ -587,22 +587,22 @@ void PropInstanceMerger::_build_finished() { } } -void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref &prop) { +void PropInstanceMerger2D::_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 +612,7 @@ void PropInstanceMerger::_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 +636,7 @@ void PropInstanceMerger::_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 +658,11 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref light_data = e; + //PropData2DLight 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 +677,7 @@ void PropInstanceMerger::_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 +695,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref(memnew(PropInstancePropJob())); + _job = Ref(memnew(PropInstancePropJob2D())); _job->set_prop_instace(this); - Ref js; + Ref js; js.instance(); - js->set_job_type(PropMesherJobStep::TYPE_NORMAL); + js->set_job_type(PropMesherJobStep2D::TYPE_NORMAL); _job->add_jobs_step(js); js.instance(); - js->set_job_type(PropMesherJobStep::TYPE_MERGE_VERTS); + js->set_job_type(PropMesherJobStep2D::TYPE_MERGE_VERTS); _job->add_jobs_step(js); js.instance(); - js->set_job_type(PropMesherJobStep::TYPE_BAKE_TEXTURE); + js->set_job_type(PropMesherJobStep2D::TYPE_BAKE_TEXTURE); _job->add_jobs_step(js); } -PropInstanceMerger::~PropInstanceMerger() { +PropInstanceMerger2D::~PropInstanceMerger2D() { _job.unref(); _prop_data.unref(); @@ -757,7 +757,7 @@ PropInstanceMerger::~PropInstanceMerger() { _materials.clear(); } -void PropInstanceMerger::_notification(int p_what) { +void PropInstanceMerger2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { if (_prop_data.is_valid()) { @@ -783,10 +783,10 @@ void PropInstanceMerger::_notification(int p_what) { return; } - if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_PHYSICS_PROCESS) { + if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_PHYSICS_PROCESS) { _job->physics_process(get_physics_process_delta_time()); - if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_NORMAL) { + if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_NORMAL) { #if THREAD_POOL_PRESENT ThreadPool::get_singleton()->add_job(_job); #else @@ -804,10 +804,10 @@ void PropInstanceMerger::_notification(int p_what) { return; } - if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_PROCESS) { + if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_PROCESS) { _job->process(get_process_delta_time()); - if (_job->get_build_phase_type() == PropInstanceJob::BUILD_PHASE_TYPE_NORMAL) { + if (_job->get_build_phase_type() == PropInstanceJob2D::BUILD_PHASE_TYPE_NORMAL) { #if THREAD_POOL_PRESENT ThreadPool::get_singleton()->add_job(_job); #else @@ -909,72 +909,72 @@ void PropInstanceMerger::_notification(int p_what) { } } -void PropInstanceMerger::_bind_methods() { - 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"); +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"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_level"), "set_lod_level", "get_lod_level"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_lod"), "set_auto_lod", "get_auto_lod"); - 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); + 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); 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"), &PropInstanceMerger::get_lod_reduction_distance_squared); - ClassDB::bind_method(D_METHOD("set_lod_reduction_distance_squared", "value"), &PropInstanceMerger::set_lod_reduction_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); 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"), &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("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("materials_get"), &PropInstanceMerger::materials_get); - ClassDB::bind_method(D_METHOD("materials_set"), &PropInstanceMerger::materials_set); + ClassDB::bind_method(D_METHOD("materials_get"), &PropInstanceMerger2D::materials_get); + ClassDB::bind_method(D_METHOD("materials_set"), &PropInstanceMerger2D::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"), &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("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("meshes_get"), &PropInstanceMerger::meshes_get); - ClassDB::bind_method(D_METHOD("meshes_set"), &PropInstanceMerger::meshes_set); + ClassDB::bind_method(D_METHOD("meshes_get"), &PropInstanceMerger2D::meshes_get); + ClassDB::bind_method(D_METHOD("meshes_set"), &PropInstanceMerger2D::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"), &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); + 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); //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("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("check_auto_lod"), &PropInstanceMerger::check_auto_lod); - ClassDB::bind_method(D_METHOD("apply_lod_level"), &PropInstanceMerger::apply_lod_level); + 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("free_meshes"), &PropInstanceMerger::free_meshes); - ClassDB::bind_method(D_METHOD("free_colliders"), &PropInstanceMerger::free_colliders); + ClassDB::bind_method(D_METHOD("free_meshes"), &PropInstanceMerger2D::free_meshes); + ClassDB::bind_method(D_METHOD("free_colliders"), &PropInstanceMerger2D::free_colliders); } diff --git a/prop_instance_merger_2d.h b/prop_instance_merger_2d.h index f89efee..9c3009c 100644 --- a/prop_instance_merger_2d.h +++ b/prop_instance_merger_2d.h @@ -43,8 +43,8 @@ SOFTWARE. class MeshDataInstance; -class PropInstanceMerger : public PropInstance { - GDCLASS(PropInstanceMerger, PropInstance); +class PropInstanceMerger2D : public PropInstance2D { + GDCLASS(PropInstanceMerger2D, PropInstance2D); 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,13 @@ 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(); - PropInstanceMerger(); - ~PropInstanceMerger(); + PropInstanceMerger2D(); + ~PropInstanceMerger2D(); protected: void _notification(int p_what); @@ -158,7 +158,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_2d.cpp index a33c6f1..17010fd 100644 --- a/prop_instance_prop_job_2d.cpp +++ b/prop_instance_prop_job_2d.cpp @@ -62,36 +62,36 @@ SOFTWARE. #include "props/prop_data_tiled_wall_2d.h" #include "tiled_wall/tiled_wall_data_2d.h" -Ref PropInstancePropJob::get_material_cache() { +Ref PropInstancePropJob2D::get_material_cache() { return _material_cache; } -void PropInstancePropJob::set_material_cache(const Ref &cache) { +void PropInstancePropJob2D::set_material_cache(const Ref &cache) { _material_cache = cache; } -Ref PropInstancePropJob::get_jobs_step(int index) const { - ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref()); +Ref PropInstancePropJob2D::get_jobs_step(int index) const { + ERR_FAIL_INDEX_V(index, _job_steps.size(), Ref()); return _job_steps.get(index); } -void PropInstancePropJob::set_jobs_step(int index, const Ref &step) { +void PropInstancePropJob2D::set_jobs_step(int index, const Ref &step) { ERR_FAIL_INDEX(index, _job_steps.size()); _job_steps.set(index, step); } -void PropInstancePropJob::remove_jobs_step(const int index) { +void PropInstancePropJob2D::remove_jobs_step(const int index) { ERR_FAIL_INDEX(index, _job_steps.size()); _job_steps.remove(index); } -void PropInstancePropJob::add_jobs_step(const Ref &step) { +void PropInstancePropJob2D::add_jobs_step(const Ref &step) { _job_steps.push_back(step); } -int PropInstancePropJob::get_jobs_step_count() const { +int PropInstancePropJob2D::get_jobs_step_count() const { return _job_steps.size(); } -void PropInstancePropJob::add_collision_shape(const Ref &shape, const Transform &transform, const bool owns_shape) { +void PropInstancePropJob2D::add_collision_shape(const Ref &shape, const Transform &transform, const bool owns_shape) { CollisionShapeEntry e; e.shape = shape; @@ -100,30 +100,30 @@ void PropInstancePropJob::add_collision_shape(const Ref &shape, const Tra _collision_shapes.push_back(e); } -void PropInstancePropJob::clear_collision_shapes() { +void PropInstancePropJob2D::clear_collision_shapes() { _collision_shapes.clear(); } -PropInstanceMerger *PropInstancePropJob::get_prop_instace() { +PropInstanceMerger2D *PropInstancePropJob2D::get_prop_instace() { return _prop_instace; } -void PropInstancePropJob::set_prop_instace(PropInstanceMerger *prop) { +void PropInstancePropJob2D::set_prop_instace(PropInstanceMerger2D *prop) { _prop_instace = prop; _instance = prop; } -void PropInstancePropJob::set_prop_instace_bind(Node *prop) { - set_prop_instace(Object::cast_to(prop)); +void PropInstancePropJob2D::set_prop_instace_bind(Node *prop) { + set_prop_instace(Object::cast_to(prop)); } -Ref PropInstancePropJob::get_prop_mesher() const { +Ref PropInstancePropJob2D::get_prop_mesher() const { return _prop_mesher; } -void PropInstancePropJob::set_prop_mesher(const Ref &mesher) { +void PropInstancePropJob2D::set_prop_mesher(const Ref &mesher) { _prop_mesher = mesher; } #if MESH_DATA_RESOURCE_PRESENT -void PropInstancePropJob::add_mesh(const Ref &mesh_data, const Transform &base_transform) { +void PropInstancePropJob2D::add_mesh(const Ref &mesh_data, const Transform &base_transform) { PMDREntry e; e.mesh_data = mesh_data; e.base_transform = base_transform; @@ -131,12 +131,12 @@ void PropInstancePropJob::add_mesh(const Ref &mesh_data, const _prop_mesh_datas.push_back(e); } -void PropInstancePropJob::clear_meshes() { +void PropInstancePropJob2D::clear_meshes() { _prop_mesh_datas.clear(); } #endif -void PropInstancePropJob::add_tiled_wall(const Ref &data, const Transform &base_transform) { +void PropInstancePropJob2D::add_tiled_wall(const Ref &data, const Transform &base_transform) { PTWEntry e; e.data = data; e.base_transform = base_transform; @@ -144,25 +144,25 @@ void PropInstancePropJob::add_tiled_wall(const Ref &data, con _prop_tiled_wall_datas.push_back(e); } -void PropInstancePropJob::clear_tiled_walls() { +void PropInstancePropJob2D::clear_tiled_walls() { _prop_tiled_wall_datas.clear(); } -void PropInstancePropJob::add_light(const Ref &light) { +void PropInstancePropJob2D::add_light(const Ref &light) { _prop_mesher->add_light(light); } -void PropInstancePropJob::clear_lights() { +void PropInstancePropJob2D::clear_lights() { _prop_mesher->clear_lights(); } -void PropInstancePropJob::_physics_process(float delta) { +void PropInstancePropJob2D::_physics_process(float delta) { if (_phase == 0) phase_physics_process(); } -void PropInstancePropJob::_execute_phase() { +void PropInstancePropJob2D::_execute_phase() { if (!_material_cache.is_valid()) { - ERR_PRINT("!PropInstancePropJob::_execute_phase(): !_material_cache.is_valid()"); + ERR_PRINT("!PropInstancePropJob2D::_execute_phase(): !_material_cache.is_valid()"); //reset_meshes(); set_complete(true); //So threadpool knows it's done finished(); @@ -186,12 +186,12 @@ void PropInstancePropJob::_execute_phase() { } else if (_phase > 3) { set_complete(true); //So threadpool knows it's done finished(); - ERR_FAIL_MSG("PropInstancePropJob: _phase is too high!"); + ERR_FAIL_MSG("PropInstancePropJob2D: _phase is too high!"); } } -void PropInstancePropJob::_reset() { - PropInstanceJob::_reset(); +void PropInstancePropJob2D::_reset() { + PropInstanceJob2D::_reset(); _build_done = false; _phase = 0; @@ -216,7 +216,7 @@ void PropInstancePropJob::_reset() { set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS); } -void PropInstancePropJob::phase_physics_process() { +void PropInstancePropJob2D::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 +263,7 @@ void PropInstancePropJob::phase_physics_process() { next_phase(); } -void PropInstancePropJob::phase_setup_cache() { +void PropInstancePropJob2D::phase_setup_cache() { if (should_do()) { if (!_material_cache->get_initialized()) { _material_cache->mutex_lock(); @@ -292,7 +292,7 @@ void PropInstancePropJob::phase_setup_cache() { next_phase(); } -void PropInstancePropJob::phase_prop() { +void PropInstancePropJob2D::phase_prop() { if (!_prop_mesher.is_valid()) { set_complete(true); //So threadpool knows it's done return; @@ -330,7 +330,7 @@ void PropInstancePropJob::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 +352,7 @@ void PropInstancePropJob::phase_prop() { } if (should_do()) { - if ((_prop_mesher->get_build_flags() & PropMesher::BUILD_FLAG_USE_LIGHTING) != 0) { + if ((_prop_mesher->get_build_flags() & PropMesher2D::BUILD_FLAG_USE_LIGHTING) != 0) { _prop_mesher->bake_colors(); } @@ -365,7 +365,7 @@ void PropInstancePropJob::phase_prop() { next_phase(); } -void PropInstancePropJob::phase_steps() { +void PropInstancePropJob2D::phase_steps() { ERR_FAIL_COND(!_prop_mesher.is_valid()); if (should_return()) { @@ -388,27 +388,27 @@ void PropInstancePropJob::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 PropMesherJobStep::TYPE_NORMAL: + case PropMesherJobStep2D::TYPE_NORMAL: ++count; break; - case PropMesherJobStep::TYPE_NORMAL_LOD: + case PropMesherJobStep2D::TYPE_NORMAL_LOD: ++count; break; - case PropMesherJobStep::TYPE_DROP_UV2: + case PropMesherJobStep2D::TYPE_DROP_UV2: ++count; break; - case PropMesherJobStep::TYPE_MERGE_VERTS: + case PropMesherJobStep2D::TYPE_MERGE_VERTS: ++count; break; - case PropMesherJobStep::TYPE_BAKE_TEXTURE: + case PropMesherJobStep2D::TYPE_BAKE_TEXTURE: ++count; break; - case PropMesherJobStep::TYPE_SIMPLIFY_MESH: + case PropMesherJobStep2D::TYPE_SIMPLIFY_MESH: #ifdef MESH_UTILS_PRESENT count += step->get_simplification_steps(); #endif @@ -441,30 +441,30 @@ void PropInstancePropJob::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 PropMesherJobStep::TYPE_NORMAL: + case PropMesherJobStep2D::TYPE_NORMAL: step_type_normal(); break; - case PropMesherJobStep::TYPE_NORMAL_LOD: + case PropMesherJobStep2D::TYPE_NORMAL_LOD: step_type_normal_lod(); break; - case PropMesherJobStep::TYPE_DROP_UV2: + case PropMesherJobStep2D::TYPE_DROP_UV2: step_type_drop_uv2(); break; - case PropMesherJobStep::TYPE_MERGE_VERTS: + case PropMesherJobStep2D::TYPE_MERGE_VERTS: step_type_merge_verts(); break; - case PropMesherJobStep::TYPE_BAKE_TEXTURE: + case PropMesherJobStep2D::TYPE_BAKE_TEXTURE: step_type_bake_texture(); break; - case PropMesherJobStep::TYPE_SIMPLIFY_MESH: + case PropMesherJobStep2D::TYPE_SIMPLIFY_MESH: step_type_simplify_mesh(); break; - case PropMesherJobStep::TYPE_OTHER: + case PropMesherJobStep2D::TYPE_OTHER: //do nothing break; } @@ -482,7 +482,7 @@ void PropInstancePropJob::phase_steps() { finished(); } -void PropInstancePropJob::step_type_normal() { +void PropInstancePropJob2D::step_type_normal() { //TODO add a lighting generation step temp_mesh_arr = _prop_mesher->build_mesh(); @@ -500,13 +500,13 @@ void PropInstancePropJob::step_type_normal() { ++_current_mesh; } -void PropInstancePropJob::step_type_normal_lod() { +void PropInstancePropJob2D::step_type_normal_lod() { print_error("Error: step_type_normal_lod doesn't work for TerraPropJobs!"); ++_current_mesh; } -void PropInstancePropJob::step_type_drop_uv2() { +void PropInstancePropJob2D::step_type_drop_uv2() { RID mesh_rid = _prop_instace->mesh_get(_current_mesh); temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant(); @@ -522,7 +522,7 @@ void PropInstancePropJob::step_type_drop_uv2() { ++_current_mesh; } -void PropInstancePropJob::step_type_merge_verts() { +void PropInstancePropJob2D::step_type_merge_verts() { Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr); temp_mesh_arr = temp_mesh_arr2; @@ -539,7 +539,7 @@ void PropInstancePropJob::step_type_merge_verts() { ++_current_mesh; } -void PropInstancePropJob::step_type_bake_texture() { +void PropInstancePropJob2D::step_type_bake_texture() { Ref mat = _material_cache->material_lod_get(0); Ref spmat = _material_cache->material_lod_get(0); Ref tex; @@ -568,10 +568,10 @@ void PropInstancePropJob::step_type_bake_texture() { ++_current_mesh; } -void PropInstancePropJob::step_type_simplify_mesh() { +void PropInstancePropJob2D::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 +598,7 @@ void PropInstancePropJob::step_type_simplify_mesh() { #endif } -Array PropInstancePropJob::merge_mesh_array(Array arr) const { +Array PropInstancePropJob2D::merge_mesh_array(Array arr) const { ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr); PoolVector3Array verts = arr[VisualServer::ARRAY_VERTEX]; @@ -662,7 +662,7 @@ Array PropInstancePropJob::merge_mesh_array(Array arr) const { return arr; } -Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref tex, const float mul_color) const { +Array PropInstancePropJob2D::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 +703,7 @@ Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref tex, const return arr; } -void PropInstancePropJob::reset_meshes() { +void PropInstancePropJob2D::reset_meshes() { if (!_prop_instace) { return; } @@ -725,7 +725,7 @@ void PropInstancePropJob::reset_meshes() { } } -PropInstancePropJob::PropInstancePropJob() { +PropInstancePropJob2D::PropInstancePropJob2D() { set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS); _prop_instace = NULL; @@ -734,29 +734,29 @@ PropInstancePropJob::PropInstancePropJob() { //todo allocate this in a virtual method _prop_mesher.instance(); - _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); + _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); } -PropInstancePropJob::~PropInstancePropJob() { +PropInstancePropJob2D::~PropInstancePropJob2D() { } -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"); +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"); - 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_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_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("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("add_light", "light"), &PropInstancePropJob::add_light); - ClassDB::bind_method(D_METHOD("clear_lights"), &PropInstancePropJob::clear_lights); + 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("_physics_process", "delta"), &PropInstancePropJob::_physics_process); + ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &PropInstancePropJob2D::_physics_process); } diff --git a/prop_instance_prop_job_2d.h b/prop_instance_prop_job_2d.h index 3bec861..cc76850 100644 --- a/prop_instance_prop_job_2d.h +++ b/prop_instance_prop_job_2d.h @@ -25,51 +25,51 @@ SOFTWARE. #include "prop_instance_job_2d.h" -class PropMesher; -class PropInstance; -class PropInstanceMerger; -class PropMesherJobStep; -class PropMaterialCache; +class PropMesher2D; +class PropInstance2D; +class PropInstanceMerger2D; +class PropMesherJobStep2D; +class PropMaterialCache2D; class Shape; -class PropLight; -class PropDataTiledWall; +class PropLight2D; +class PropDataTiledWall2D; #if MESH_DATA_RESOURCE_PRESENT class PropDataMeshData; #endif -class PropInstancePropJob : public PropInstanceJob { - GDCLASS(PropInstancePropJob, PropInstanceJob); +class PropInstancePropJob2D : public PropInstanceJob2D { + GDCLASS(PropInstancePropJob2D, PropInstanceJob2D); 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(); - PropInstanceMerger *get_prop_instace(); - void set_prop_instace(PropInstanceMerger *prop); + PropInstanceMerger2D *get_prop_instace(); + void set_prop_instace(PropInstanceMerger2D *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(); - PropInstancePropJob(); - ~PropInstancePropJob(); + PropInstancePropJob2D(); + ~PropInstancePropJob2D(); protected: static void _bind_methods(); @@ -108,7 +108,7 @@ protected: #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; - PropInstanceMerger *_prop_instace; + Ref _prop_mesher; + PropInstanceMerger2D *_prop_instace; #if MESH_DATA_RESOURCE_PRESENT Vector _prop_mesh_datas; diff --git a/prop_mesher_2d.cpp b/prop_mesher_2d.cpp index 7e1c033..fb093f2 100644 --- a/prop_mesher_2d.cpp +++ b/prop_mesher_2d.cpp @@ -28,9 +28,9 @@ SOFTWARE. #include "material_cache/prop_material_cache_2d.h" #include "tiled_wall/tiled_wall_data_2d.h" -const String PropMesher::BINDING_STRING_BUILD_FLAGS = "Use Lighting,Use AO,Use RAO,Bake Lights"; +const String PropMesher2D::BINDING_STRING_BUILD_FLAGS = "Use Lighting,Use AO,Use RAO,Bake Lights"; -bool PropMesher::Vertex::operator==(const Vertex &p_vertex) const { +bool PropMesher2D::Vertex::operator==(const Vertex &p_vertex) const { if (vertex != p_vertex.vertex) return false; @@ -65,7 +65,7 @@ bool PropMesher::Vertex::operator==(const Vertex &p_vertex) const { return true; } -uint32_t PropMesher::VertexHasher::hash(const Vertex &p_vtx) { +uint32_t PropMesher2D::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 PropMesher::VertexHasher::hash(const Vertex &p_vtx) { return h; } -int PropMesher::get_channel_index_type() const { +int PropMesher2D::get_channel_index_type() const { return _channel_index_type; } -void PropMesher::set_channel_index_type(const int value) { +void PropMesher2D::set_channel_index_type(const int value) { _channel_index_type = value; } -int PropMesher::get_channel_index_isolevel() const { +int PropMesher2D::get_channel_index_isolevel() const { return _channel_index_isolevel; } -void PropMesher::set_channel_index_isolevel(const int value) { +void PropMesher2D::set_channel_index_isolevel(const int value) { _channel_index_isolevel = value; } -int PropMesher::get_mesher_index() const { +int PropMesher2D::get_mesher_index() const { return _mesher_index; } -void PropMesher::set_mesher_index(const int value) { +void PropMesher2D::set_mesher_index(const int value) { _mesher_index = value; } -int PropMesher::get_format() const { +int PropMesher2D::get_format() const { return _format; } -void PropMesher::set_format(const int value) { +void PropMesher2D::set_format(const int value) { _format = value; } -int PropMesher::get_texture_scale() const { +int PropMesher2D::get_texture_scale() const { return _texture_scale; } -void PropMesher::set_texture_scale(const int value) { +void PropMesher2D::set_texture_scale(const int value) { _texture_scale = value; } -Ref PropMesher::get_material() { +Ref PropMesher2D::get_material() { return _material; } -void PropMesher::set_material(const Ref &material) { +void PropMesher2D::set_material(const Ref &material) { _material = material; } -float PropMesher::get_ao_strength() const { +float PropMesher2D::get_ao_strength() const { return _ao_strength; } -void PropMesher::set_ao_strength(float value) { +void PropMesher2D::set_ao_strength(float value) { _ao_strength = value; } -float PropMesher::get_base_light_value() const { +float PropMesher2D::get_base_light_value() const { return _base_light_value; } -void PropMesher::set_base_light_value(float value) { +void PropMesher2D::set_base_light_value(float value) { _base_light_value = value; } -float PropMesher::get_voxel_scale() const { +float PropMesher2D::get_voxel_scale() const { return _voxel_scale; } -void PropMesher::set_voxel_scale(const float voxel_scale) { +void PropMesher2D::set_voxel_scale(const float voxel_scale) { _voxel_scale = voxel_scale; } -Rect2 PropMesher::get_uv_margin() const { +Rect2 PropMesher2D::get_uv_margin() const { return _uv_margin; } -void PropMesher::set_uv_margin(const Rect2 margin) { +void PropMesher2D::set_uv_margin(const Rect2 margin) { _uv_margin = margin; } -_FORCE_INLINE_ int PropMesher::get_build_flags() const { +_FORCE_INLINE_ int PropMesher2D::get_build_flags() const { return _build_flags; } -_FORCE_INLINE_ void PropMesher::set_build_flags(const int flags) { +_FORCE_INLINE_ void PropMesher2D::set_build_flags(const int flags) { _build_flags = flags; - if ((_build_flags & PropMesher::BUILD_FLAG_USE_LIGHTING) != 0) { + if ((_build_flags & PropMesher2D::BUILD_FLAG_USE_LIGHTING) != 0) { _format |= VisualServer::ARRAY_FORMAT_COLOR; } else { _format ^= VisualServer::ARRAY_FORMAT_COLOR; } } -Array PropMesher::build_mesh() { +Array PropMesher2D::build_mesh() { Array a; a.resize(VisualServer::ARRAY_MAX); @@ -305,7 +305,7 @@ Array PropMesher::build_mesh() { return a; } -void PropMesher::build_mesh_into(RID mesh) { +void PropMesher2D::build_mesh_into(RID mesh) { ERR_FAIL_COND(mesh == RID()); VS::get_singleton()->mesh_clear(mesh); @@ -323,7 +323,7 @@ void PropMesher::build_mesh_into(RID mesh) { VS::get_singleton()->mesh_surface_set_material(mesh, 0, _material->get_rid()); } -void PropMesher::generate_normals(bool p_flip) { +void PropMesher2D::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 PropMesher::generate_normals(bool p_flip) { } } -void PropMesher::remove_doubles() { +void PropMesher2D::remove_doubles() { if (_vertices.size() == 0) return; @@ -401,7 +401,7 @@ void PropMesher::remove_doubles() { } //lot faster that normal remove_doubles, but false positives can happen curtesy of hash collisions -void PropMesher::remove_doubles_hashed() { +void PropMesher2D::remove_doubles_hashed() { if (_vertices.size() == 0) return; @@ -453,7 +453,7 @@ void PropMesher::remove_doubles_hashed() { //print_error("after " + String::num(_vertices.size()) + " " + String::num(duration.count())); } -void PropMesher::reset() { +void PropMesher2D::reset() { _vertices.resize(0); _indices.resize(0); @@ -466,7 +466,7 @@ void PropMesher::reset() { _last_tangent = Plane(); } -void PropMesher::add_tiled_wall_simple(const int width, const int height, const Transform &transform, const Ref &tiled_wall_data, Ref cache) { +void PropMesher2D::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 PropMesher::add_tiled_wall_simple(const int width, const int height, const normal_rects.push_back(Rect2(0, 0, 1, 1)); } - TiledWallData::TiledWallTilingType tiling_type = tiled_wall_data->get_tiling_type(); + TiledWallData2D::TiledWallTilingType tiling_type = tiled_wall_data->get_tiling_type(); //todo implement flavour! - if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_NONE) { + if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_NONE) { Rect2 r = normal_rects[0]; if (flavour_rects.size() == 0) { @@ -529,7 +529,7 @@ void PropMesher::add_tiled_wall_simple(const int width, const int height, const } } } - } else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_HORIZONTAL) { + } else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_HORIZONTAL) { Rect2 r; if (flavour_rects.size() == 0) { @@ -555,7 +555,7 @@ void PropMesher::add_tiled_wall_simple(const int width, const int height, const } } } - } else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_VERTICAL) { + } else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_VERTICAL) { Rect2 r; if (flavour_rects.size() == 0) { @@ -581,7 +581,7 @@ void PropMesher::add_tiled_wall_simple(const int width, const int height, const } } } - } else if (tiling_type == TiledWallData::TILED_WALL_TILING_TYPE_BOTH) { + } else if (tiling_type == TiledWallData2D::TILED_WALL_TILING_TYPE_BOTH) { Rect2 r; if (flavour_rects.size() == 0) { @@ -610,7 +610,7 @@ void PropMesher::add_tiled_wall_simple(const int width, const int height, const } } -void PropMesher::add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform &transform, const Rect2 &texture_rect) { +void PropMesher2D::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 PropMesher::add_tiled_wall_mesh_rect_simple(const int x, const int y, const add_indices(vc + 0); } -_FORCE_INLINE_ Vector2 PropMesher::transform_uv(const Vector2 &uv, const Rect2 &rect) const { +_FORCE_INLINE_ Vector2 PropMesher2D::transform_uv(const Vector2 &uv, const Rect2 &rect) const { Vector2 ruv = uv; ruv.x *= rect.size.x; @@ -653,13 +653,13 @@ _FORCE_INLINE_ Vector2 PropMesher::transform_uv(const Vector2 &uv, const Rect2 & } #ifdef MESH_DATA_RESOURCE_PRESENT -void PropMesher::add_mesh_data_resource(Ref mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) { +void PropMesher2D::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 PropMesher::add_mesh_data_resource_transform(Ref mesh, const Transform transform, const Rect2 uv_rect) { +void PropMesher2D::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 PropMesher::add_mesh_data_resource_transform(Ref mesh, co } } -void PropMesher::add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect) { +void PropMesher2D::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 PropMesher::add_mesh_data_resource_transform_colored(Ref #endif //Data Management functions -void PropMesher::generate_ao() { +void PropMesher2D::generate_ao() { /* ERR_FAIL_COND(!_chunk.is_valid()); @@ -787,7 +787,7 @@ void PropMesher::generate_ao() { }*/ } -float PropMesher::get_random_ao(const Vector3 &position) { +float PropMesher2D::get_random_ao(const Vector3 &position) { float val = _noise->get_noise_3d(position.x, position.y, position.z); val *= _rao_scale_factor; @@ -801,12 +801,12 @@ float PropMesher::get_random_ao(const Vector3 &position) { return val; } -Color PropMesher::get_light_color_at(const Vector3 &position, const Vector3 &normal) { +Color PropMesher2D::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 PropMesher::get_light_color_at(const Vector3 &position, const Vector3 &nor return Color(v_lightDiffuse.x, v_lightDiffuse.y, v_lightDiffuse.z); } -void PropMesher::add_mesher(const Ref &mesher) { +void PropMesher2D::add_mesher(const Ref &mesher) { call("_add_mesher", mesher); } -void PropMesher::_add_mesher(const Ref &mesher) { +void PropMesher2D::_add_mesher(const Ref &mesher) { int orig_size = _vertices.size(); _vertices.append_array(mesher->_vertices); @@ -864,14 +864,14 @@ void PropMesher::_add_mesher(const Ref &mesher) { } } -void PropMesher::add_light(const Ref &light) { +void PropMesher2D::add_light(const Ref &light) { _lights.push_back(light); } -void PropMesher::clear_lights() { +void PropMesher2D::clear_lights() { _lights.clear(); } -PoolVector PropMesher::build_collider() const { +PoolVector PropMesher2D::build_collider() const { PoolVector face_points; if (_vertices.size() == 0) @@ -901,13 +901,13 @@ PoolVector PropMesher::build_collider() const { return face_points; } -void PropMesher::bake_colors() { - if ((get_build_flags() & PropMesher::BUILD_FLAG_USE_LIGHTING) == 0) { +void PropMesher2D::bake_colors() { + if ((get_build_flags() & PropMesher2D::BUILD_FLAG_USE_LIGHTING) == 0) { return; } - bool rao = (get_build_flags() & PropMesher::BUILD_FLAG_USE_RAO) != 0; - bool lights = (get_build_flags() & PropMesher::BUILD_FLAG_BAKE_LIGHTS) != 0; + bool rao = (get_build_flags() & PropMesher2D::BUILD_FLAG_USE_RAO) != 0; + bool lights = (get_build_flags() & PropMesher2D::BUILD_FLAG_BAKE_LIGHTS) != 0; if (rao && lights) { bake_colors_lights_rao(); @@ -925,7 +925,7 @@ void PropMesher::bake_colors() { } } -void PropMesher::bake_colors_rao() { +void PropMesher2D::bake_colors_rao() { for (int i = 0; i < _vertices.size(); ++i) { Vertex vertex = _vertices[i]; Vector3 vert = vertex.vertex; @@ -949,7 +949,7 @@ void PropMesher::bake_colors_rao() { _vertices.set(i, vertex); } } -void PropMesher::bake_colors_lights_rao() { +void PropMesher2D::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 PropMesher::bake_colors_lights_rao() { _vertices.set(i, vertex); } } -void PropMesher::bake_colors_lights() { +void PropMesher2D::bake_colors_lights() { for (int i = 0; i < _vertices.size(); ++i) { Vertex vertex = _vertices[i]; Vector3 vert = vertex.vertex; @@ -1001,7 +1001,7 @@ void PropMesher::bake_colors_lights() { } #ifdef TERRAMAN_PRESENT -void PropMesher::bake_lights(MeshInstance *node, Vector> &lights) { +void PropMesher2D::bake_lights(MeshInstance *node, Vector> &lights) { ERR_FAIL_COND(node == NULL); Color darkColor(0, 0, 0, 1); @@ -1089,7 +1089,7 @@ void PropMesher::bake_lights(MeshInstance *node, Vector> &lights } #endif -PoolVector PropMesher::get_vertices() const { +PoolVector PropMesher2D::get_vertices() const { PoolVector arr; arr.resize(_vertices.size()); @@ -1100,7 +1100,7 @@ PoolVector PropMesher::get_vertices() const { return arr; } -void PropMesher::set_vertices(const PoolVector &values) { +void PropMesher2D::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 PropMesher::set_vertices(const PoolVector &values) { } } -int PropMesher::get_vertex_count() const { +int PropMesher2D::get_vertex_count() const { return _vertices.size(); } -void PropMesher::add_vertex(const Vector3 &vertex) { +void PropMesher2D::add_vertex(const Vector3 &vertex) { Vertex vtx; vtx.vertex = vertex; vtx.color = _last_color; @@ -1132,15 +1132,15 @@ void PropMesher::add_vertex(const Vector3 &vertex) { _vertices.push_back(vtx); } -Vector3 PropMesher::get_vertex(const int idx) const { +Vector3 PropMesher2D::get_vertex(const int idx) const { return _vertices.get(idx).vertex; } -void PropMesher::remove_vertex(const int idx) { +void PropMesher2D::remove_vertex(const int idx) { _vertices.remove(idx); } -PoolVector PropMesher::get_normals() const { +PoolVector PropMesher2D::get_normals() const { PoolVector arr; arr.resize(_vertices.size()); @@ -1151,7 +1151,7 @@ PoolVector PropMesher::get_normals() const { return arr; } -void PropMesher::set_normals(const PoolVector &values) { +void PropMesher2D::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 PropMesher::set_normals(const PoolVector &values) { } } -void PropMesher::add_normal(const Vector3 &normal) { +void PropMesher2D::add_normal(const Vector3 &normal) { _last_normal = normal; } -Vector3 PropMesher::get_normal(int idx) const { +Vector3 PropMesher2D::get_normal(int idx) const { return _vertices.get(idx).normal; } -PoolVector PropMesher::get_colors() const { +PoolVector PropMesher2D::get_colors() const { PoolVector arr; arr.resize(_vertices.size()); @@ -1182,7 +1182,7 @@ PoolVector PropMesher::get_colors() const { return arr; } -void PropMesher::set_colors(const PoolVector &values) { +void PropMesher2D::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 PropMesher::set_colors(const PoolVector &values) { } } -void PropMesher::add_color(const Color &color) { +void PropMesher2D::add_color(const Color &color) { _last_color = color; } -Color PropMesher::get_color(const int idx) const { +Color PropMesher2D::get_color(const int idx) const { return _vertices.get(idx).color; } -PoolVector PropMesher::get_uvs() const { +PoolVector PropMesher2D::get_uvs() const { PoolVector arr; arr.resize(_vertices.size()); @@ -1213,7 +1213,7 @@ PoolVector PropMesher::get_uvs() const { return arr; } -void PropMesher::set_uvs(const PoolVector &values) { +void PropMesher2D::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 PropMesher::set_uvs(const PoolVector &values) { } } -void PropMesher::add_uv(const Vector2 &uv) { +void PropMesher2D::add_uv(const Vector2 &uv) { _last_uv = uv; } -Vector2 PropMesher::get_uv(const int idx) const { +Vector2 PropMesher2D::get_uv(const int idx) const { return _vertices.get(idx).uv; } -PoolVector PropMesher::get_uv2s() const { +PoolVector PropMesher2D::get_uv2s() const { PoolVector arr; arr.resize(_vertices.size()); @@ -1244,7 +1244,7 @@ PoolVector PropMesher::get_uv2s() const { return arr; } -void PropMesher::set_uv2s(const PoolVector &values) { +void PropMesher2D::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 PropMesher::set_uv2s(const PoolVector &values) { } } -void PropMesher::add_uv2(const Vector2 &uv) { +void PropMesher2D::add_uv2(const Vector2 &uv) { _last_uv2 = uv; } -Vector2 PropMesher::get_uv2(const int idx) const { +Vector2 PropMesher2D::get_uv2(const int idx) const { return _vertices.get(idx).uv2; } -PoolVector PropMesher::get_indices() const { +PoolVector PropMesher2D::get_indices() const { return _indices; } -void PropMesher::set_indices(const PoolVector &values) { +void PropMesher2D::set_indices(const PoolVector &values) { _indices = values; } -int PropMesher::get_indices_count() const { +int PropMesher2D::get_indices_count() const { return _indices.size(); } -void PropMesher::add_indices(const int index) { +void PropMesher2D::add_indices(const int index) { _indices.push_back(index); } -int PropMesher::get_index(const int idx) const { +int PropMesher2D::get_index(const int idx) const { return _indices.get(idx); } -void PropMesher::remove_index(const int idx) { +void PropMesher2D::remove_index(const int idx) { _indices.remove(idx); } -PropMesher::PropMesher() { +PropMesher2D::PropMesher2D() { _mesher_index = 0; _voxel_scale = 1; _ao_strength = 0.25; @@ -1313,120 +1313,120 @@ PropMesher::PropMesher() { _rao_seed = 2134; } -PropMesher::~PropMesher() { +PropMesher2D::~PropMesher2D() { } -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); +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); 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"), &PropMesher::get_channel_index_isolevel); - ClassDB::bind_method(D_METHOD("set_channel_index_isolevel", "value"), &PropMesher::set_channel_index_isolevel); + 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); ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_index_isolevel"), "set_channel_index_isolevel", "get_channel_index_isolevel"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::INT, "mesher_index"), "set_mesher_index", "get_mesher_index"); - ClassDB::bind_method(D_METHOD("get_format"), &PropMesher::get_format); - ClassDB::bind_method(D_METHOD("set_format", "value"), &PropMesher::set_format); + ClassDB::bind_method(D_METHOD("get_format"), &PropMesher2D::get_format); + ClassDB::bind_method(D_METHOD("set_format", "value"), &PropMesher2D::set_format); ADD_PROPERTY(PropertyInfo(Variant::INT, "format"), "set_format", "get_format"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_scale"), "set_texture_scale", "get_texture_scale"); - ClassDB::bind_method(D_METHOD("get_material"), &PropMesher::get_material); - ClassDB::bind_method(D_METHOD("set_material", "value"), &PropMesher::set_material); + ClassDB::bind_method(D_METHOD("get_material"), &PropMesher2D::get_material); + ClassDB::bind_method(D_METHOD("set_material", "value"), &PropMesher2D::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"), &PropMesher::get_voxel_scale); - ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &PropMesher::set_voxel_scale); + 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); ADD_PROPERTY(PropertyInfo(Variant::REAL, "voxel_scale"), "set_voxel_scale", "get_voxel_scale"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_strength"), "set_ao_strength", "get_ao_strength"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::REAL, "base_light_value"), "set_base_light_value", "get_base_light_value"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "uv_margin"), "set_uv_margin", "get_uv_margin"); - 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("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("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); + 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); #ifdef MESH_DATA_RESOURCE_PRESENT - 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))); + 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))); #endif - ClassDB::bind_method(D_METHOD("generate_ao"), &PropMesher::generate_ao); - ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &PropMesher::get_random_ao); + ClassDB::bind_method(D_METHOD("generate_ao"), &PropMesher2D::generate_ao); + ClassDB::bind_method(D_METHOD("get_random_ao", "position"), &PropMesher2D::get_random_ao); - 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); + 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); - 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("add_light", "light"), &PropMesher2D::add_light); + ClassDB::bind_method(D_METHOD("clear_lights"), &PropMesher2D::clear_lights); - 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_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_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_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_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_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_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_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_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_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_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("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("reset"), &PropMesher::reset); + ClassDB::bind_method(D_METHOD("reset"), &PropMesher2D::reset); - //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("calculate_vertex_ambient_occlusion", "meshinstance_path", "radius", "intensity", "sampleCount"), &PropMesher2D::calculate_vertex_ambient_occlusion_path); - 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("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("bake_colors"), &PropMesher::bake_colors); + ClassDB::bind_method(D_METHOD("bake_colors"), &PropMesher2D::bake_colors); - ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &PropMesher::generate_normals, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &PropMesher2D::generate_normals, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("remove_doubles"), &PropMesher::remove_doubles); - ClassDB::bind_method(D_METHOD("remove_doubles_hashed"), &PropMesher::remove_doubles_hashed); + ClassDB::bind_method(D_METHOD("remove_doubles"), &PropMesher2D::remove_doubles); + ClassDB::bind_method(D_METHOD("remove_doubles_hashed"), &PropMesher2D::remove_doubles_hashed); } diff --git a/prop_mesher_2d.h b/prop_mesher_2d.h index 57dc65d..65a4375 100644 --- a/prop_mesher_2d.h +++ b/prop_mesher_2d.h @@ -61,12 +61,12 @@ using PoolVector = Vector; #endif class OpenSimplexNoise; -class PropLight; -class PropMaterialCache; -class TiledWallData; +class PropLight2D; +class PropMaterialCache2D; +class TiledWallData2D; -class PropMesher : public Reference { - GDCLASS(PropMesher, Reference); +class PropMesher2D : public Reference { + GDCLASS(PropMesher2D, 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; @@ -217,8 +217,8 @@ public: void remove_index(const int idx); void add_indices(const int index); - PropMesher(); - ~PropMesher(); + PropMesher2D(); + ~PropMesher2D(); 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(PropMesher::BuildFlags); +VARIANT_ENUM_CAST(PropMesher2D::BuildFlags); #endif diff --git a/prop_scene_instance_2d.cpp b/prop_scene_instance_2d.cpp index 2b545b0..b300cb9 100644 --- a/prop_scene_instance_2d.cpp +++ b/prop_scene_instance_2d.cpp @@ -8,10 +8,10 @@ #include "core/engine.h" #endif -Ref PropSceneInstance::get_scene() { +Ref PropSceneInstance2D::get_scene() { return _scene; } -void PropSceneInstance::set_scene(const Ref &data) { +void PropSceneInstance2D::set_scene(const Ref &data) { if (_scene == data) return; @@ -20,21 +20,21 @@ void PropSceneInstance::set_scene(const Ref &data) { build(); } -bool PropSceneInstance::get_snap_to_mesh() const { +bool PropSceneInstance2D::get_snap_to_mesh() const { return _snap_to_mesh; } -void PropSceneInstance::set_snap_to_mesh(const bool value) { +void PropSceneInstance2D::set_snap_to_mesh(const bool value) { _snap_to_mesh = value; } -Vector3 PropSceneInstance::get_snap_axis() const { +Vector3 PropSceneInstance2D::get_snap_axis() const { return _snap_axis; } -void PropSceneInstance::set_snap_axis(const Vector3 &value) { +void PropSceneInstance2D::set_snap_axis(const Vector3 &value) { _snap_axis = value; } -void PropSceneInstance::build() { +void PropSceneInstance2D::build() { if (!is_inside_tree()) { return; } @@ -59,15 +59,15 @@ void PropSceneInstance::build() { // n->set_owner(get_tree()->get_edited_scene_root()); } -PropSceneInstance::PropSceneInstance() { +PropSceneInstance2D::PropSceneInstance2D() { _snap_to_mesh = false; _snap_axis = Vector3(0, -1, 0); } -PropSceneInstance::~PropSceneInstance() { +PropSceneInstance2D::~PropSceneInstance2D() { _scene.unref(); } -void PropSceneInstance::_notification(int p_what) { +void PropSceneInstance2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { build(); @@ -75,18 +75,18 @@ void PropSceneInstance::_notification(int p_what) { } } -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); +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); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); - ClassDB::bind_method(D_METHOD("build"), &PropSceneInstance::build); + ClassDB::bind_method(D_METHOD("build"), &PropSceneInstance2D::build); } diff --git a/prop_scene_instance_2d.h b/prop_scene_instance_2d.h index 64abc09..6c5401e 100644 --- a/prop_scene_instance_2d.h +++ b/prop_scene_instance_2d.h @@ -38,8 +38,8 @@ SOFTWARE. #include "props/prop_data_2d.h" #include "scene/resources/packed_scene.h" -class PropSceneInstance : public Spatial { - GDCLASS(PropSceneInstance, Spatial); +class PropSceneInstance2D : public Spatial { + GDCLASS(PropSceneInstance2D, Spatial); public: Ref get_scene(); @@ -53,8 +53,8 @@ public: void build(); - PropSceneInstance(); - ~PropSceneInstance(); + PropSceneInstance2D(); + ~PropSceneInstance2D(); protected: void _notification(int p_what); diff --git a/props/prop_data_2d.cpp b/props/prop_data_2d.cpp index 45623c1..ef55a8c 100644 --- a/props/prop_data_2d.cpp +++ b/props/prop_data_2d.cpp @@ -34,51 +34,51 @@ SOFTWARE. #define Shape Shape3D #endif -int PropData::get_id() const { +int PropData2D::get_id() const { return _id; } -void PropData::set_id(const int value) { +void PropData2D::set_id(const int value) { _id = value; } -bool PropData::get_snap_to_mesh() const { +bool PropData2D::get_snap_to_mesh() const { return _snap_to_mesh; } -void PropData::set_snap_to_mesh(const bool value) { +void PropData2D::set_snap_to_mesh(const bool value) { _snap_to_mesh = value; } -Vector3 PropData::get_snap_axis() const { +Vector3 PropData2D::get_snap_axis() const { return _snap_axis; } -void PropData::set_snap_axis(const Vector3 &value) { +void PropData2D::set_snap_axis(const Vector3 &value) { _snap_axis = value; } -Ref PropData::get_prop(const int index) const { - ERR_FAIL_INDEX_V(index, _props.size(), Ref()); +Ref PropData2D::get_prop(const int index) const { + ERR_FAIL_INDEX_V(index, _props.size(), Ref()); return _props.get(index); } -void PropData::set_prop(const int index, const Ref prop) { +void PropData2D::set_prop(const int index, const Ref prop) { ERR_FAIL_INDEX(index, _props.size()); _props.set(index, prop); } -void PropData::add_prop(const Ref prop) { +void PropData2D::add_prop(const Ref prop) { _props.push_back(prop); } -void PropData::remove_prop(const int index) { +void PropData2D::remove_prop(const int index) { ERR_FAIL_INDEX(index, _props.size()); _props.remove(index); } -int PropData::get_prop_count() const { +int PropData2D::get_prop_count() const { return _props.size(); } -Vector PropData::get_props() { +Vector PropData2D::get_props() { Vector r; for (int i = 0; i < _props.size(); i++) { #if VERSION_MAJOR < 4 @@ -89,21 +89,21 @@ Vector PropData::get_props() { } return r; } -void PropData::set_props(const Vector &props) { +void PropData2D::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 PropData::add_textures_into(Ref texture_packer) { +void PropData2D::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 PropData::add_textures_into(Ref texture_packer) { } #endif -bool PropData::get_is_room() const { +bool PropData2D::get_is_room() const { return _is_room; } -void PropData::set_is_room(const bool value) { +void PropData2D::set_is_room(const bool value) { _is_room = value; } -PoolVector3Array PropData::get_room_bounds() { +PoolVector3Array PropData2D::get_room_bounds() { return _room_bounds; } -void PropData::set_room_bounds(const PoolVector3Array &bounds) { +void PropData2D::set_room_bounds(const PoolVector3Array &bounds) { _room_bounds = bounds; } -void PropData::copy_from(const Ref &prop_data) { +void PropData2D::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 PropData::copy_from(const Ref &prop_data) { emit_changed(); } -PropData::PropData() { +PropData2D::PropData2D() { _id = 0; _snap_to_mesh = false; _is_room = false; _snap_axis = Vector3(0, -1, 0); } -PropData::~PropData() { +PropData2D::~PropData2D() { _props.clear(); } -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); +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); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); - 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", "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_count"), &PropData::get_prop_count); + ClassDB::bind_method(D_METHOD("get_prop_count"), &PropData2D::get_prop_count); - 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"); + 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"); #if TEXTURE_PACKER_PRESENT - ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropData::add_textures_into); + ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropData2D::add_textures_into); #endif - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_room"), "set_is_room", "get_is_room"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY, "room_bounds"), "set_room_bounds", "get_room_bounds"); - ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &PropData::copy_from); + ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &PropData2D::copy_from); } diff --git a/props/prop_data_2d.h b/props/prop_data_2d.h index 53057a3..9113a1a 100644 --- a/props/prop_data_2d.h +++ b/props/prop_data_2d.h @@ -46,8 +46,8 @@ SOFTWARE. #include "../../texture_packer/texture_packer.h" #endif -class PropData : public Resource { - GDCLASS(PropData, Resource); +class PropData2D : public Resource { + GDCLASS(PropData2D, Resource); public: int get_id() const; @@ -59,9 +59,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 +79,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); - PropData(); - ~PropData(); + PropData2D(); + ~PropData2D(); protected: static void _bind_methods(); @@ -92,7 +92,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_2d.cpp index 417c3cf..e8263e3 100644 --- a/props/prop_data_entry_2d.cpp +++ b/props/prop_data_entry_2d.cpp @@ -40,64 +40,64 @@ SOFTWARE. #include "../prop_mesher_2d.h" -Transform PropDataEntry::get_transform() const { +Transform PropDataEntry2D::get_transform() const { return _transform; } -void PropDataEntry::set_transform(const Transform &value) { +void PropDataEntry2D::set_transform(const Transform &value) { _transform = value; } #if TEXTURE_PACKER_PRESENT -void PropDataEntry::add_textures_into(Ref texture_packer) { +void PropDataEntry2D::add_textures_into(Ref texture_packer) { if (has_method("_add_textures_into")) call("_add_textures_into", texture_packer); } #endif -bool PropDataEntry::processor_handles(Node *node) { +bool PropDataEntry2D::processor_handles(Node *node) { return call("_processor_handles", node); } -void PropDataEntry::processor_process(Ref prop_data, Node *node, const Transform &transform) { +void PropDataEntry2D::processor_process(Ref prop_data, Node *node, const Transform &transform) { call("_processor_process", prop_data, node, transform); } -Node *PropDataEntry::processor_get_node_for(const Transform &transform) { +Node *PropDataEntry2D::processor_get_node_for(const Transform &transform) { return call("_processor_get_node_for", transform); } -bool PropDataEntry::processor_evaluate_children() { +bool PropDataEntry2D::processor_evaluate_children() { return call("_processor_evaluate_children"); } -bool PropDataEntry::_processor_handles(Node *node) { +bool PropDataEntry2D::_processor_handles(Node *node) { return false; } -void PropDataEntry::_processor_process(Ref prop_data, Node *node, const Transform &transform) { +void PropDataEntry2D::_processor_process(Ref prop_data, Node *node, const Transform &transform) { } -Node *PropDataEntry::_processor_get_node_for(const Transform &transform) { +Node *PropDataEntry2D::_processor_get_node_for(const Transform &transform) { return NULL; } -bool PropDataEntry::_processor_evaluate_children() { +bool PropDataEntry2D::_processor_evaluate_children() { return true; } -PropDataEntry::PropDataEntry() { +PropDataEntry2D::PropDataEntry2D() { } -PropDataEntry::~PropDataEntry() { +PropDataEntry2D::~PropDataEntry2D() { } -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); +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); 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"), &PropDataEntry::add_textures_into); + ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropDataEntry2D::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, "PropData"), + PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData2D"), PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"), PropertyInfo(Variant::TRANSFORM, "transform"))); @@ -106,14 +106,14 @@ void PropDataEntry::_bind_methods() { BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "evaluate"), "_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", "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", "transform"), &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); } diff --git a/props/prop_data_entry_2d.h b/props/prop_data_entry_2d.h index f7a218a..131db73 100644 --- a/props/prop_data_entry_2d.h +++ b/props/prop_data_entry_2d.h @@ -33,12 +33,12 @@ SOFTWARE. #include "core/math/transform.h" -class PropData; -class PropMesher; +class PropData2D; +class PropMesher2D; class TexturePacker; -class PropDataEntry : public Resource { - GDCLASS(PropDataEntry, Resource); +class PropDataEntry2D : public Resource { + GDCLASS(PropDataEntry2D, Resource); public: Transform get_transform() const; @@ -49,17 +49,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(); - PropDataEntry(); - ~PropDataEntry(); + PropDataEntry2D(); + ~PropDataEntry2D(); protected: static void _bind_methods(); diff --git a/props/prop_data_light_2d.cpp b/props/prop_data_light_2d.cpp index 256ed2e..2ad9559 100644 --- a/props/prop_data_light_2d.cpp +++ b/props/prop_data_light_2d.cpp @@ -32,32 +32,32 @@ SOFTWARE. #define Light Light3D #endif -Color PropDataLight::get_light_color() const { +Color PropDataLight2D::get_light_color() const { return _light_color; } -void PropDataLight::set_light_color(const Color value) { +void PropDataLight2D::set_light_color(const Color value) { _light_color = value; } -int PropDataLight::get_light_size() const { +int PropDataLight2D::get_light_size() const { return _light_size; } -void PropDataLight::set_light_size(const int value) { +void PropDataLight2D::set_light_size(const int value) { _light_size = value; } -bool PropDataLight::_processor_handles(Node *node) { +bool PropDataLight2D::_processor_handles(Node *node) { OmniLight *i = Object::cast_to(node); return i; } -void PropDataLight::_processor_process(Ref prop_data, Node *node, const Transform &transform) { +void PropDataLight2D::_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 PropDataLight::_processor_process(Ref prop_data, Node *node, cons prop_data->add_prop(l); } -Node *PropDataLight::_processor_get_node_for(const Transform &transform) { +Node *PropDataLight2D::_processor_get_node_for(const Transform &transform) { OmniLight *i = memnew(OmniLight); i->set_color(get_light_color()); @@ -75,18 +75,18 @@ Node *PropDataLight::_processor_get_node_for(const Transform &transform) { return i; } -PropDataLight::PropDataLight() { +PropDataLight2D::PropDataLight2D() { _light_size = 0; } -PropDataLight::~PropDataLight() { +PropDataLight2D::~PropDataLight2D() { } -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); +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); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color"), "set_light_color", "get_light_color"); - 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); + 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); 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_2d.h index d4a525d..ce058cb 100644 --- a/props/prop_data_light_2d.h +++ b/props/prop_data_light_2d.h @@ -33,8 +33,8 @@ SOFTWARE. #include "prop_data_entry_2d.h" -class PropDataLight : public PropDataEntry { - GDCLASS(PropDataLight, PropDataEntry); +class PropDataLight2D : public PropDataEntry2D { + GDCLASS(PropDataLight2D, PropDataEntry2D); 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); - PropDataLight(); - ~PropDataLight(); + PropDataLight2D(); + ~PropDataLight2D(); protected: static void _bind_methods(); diff --git a/props/prop_data_portal_2d.cpp b/props/prop_data_portal_2d.cpp index c3cfca4..3c0c16c 100644 --- a/props/prop_data_portal_2d.cpp +++ b/props/prop_data_portal_2d.cpp @@ -26,53 +26,53 @@ SOFTWARE. #include "scene/3d/portal.h" -bool PropDataPortal::get_is_active() const { +bool PropDataPortal2D::get_is_active() const { return _is_active; } -void PropDataPortal::set_is_active(bool p_active) { +void PropDataPortal2D::set_is_active(bool p_active) { _is_active = p_active; } -bool PropDataPortal::get_is_two_way() const { +bool PropDataPortal2D::get_is_two_way() const { return _is_two_way; } -void PropDataPortal::set_is_two_way(bool p_two_way) { +void PropDataPortal2D::set_is_two_way(bool p_two_way) { _is_two_way = p_two_way; } -bool PropDataPortal::get_use_default_margin() const { +bool PropDataPortal2D::get_use_default_margin() const { return _use_default_margin; } -void PropDataPortal::set_use_default_margin(bool p_use) { +void PropDataPortal2D::set_use_default_margin(bool p_use) { _use_default_margin = p_use; } -real_t PropDataPortal::get_portal_margin() const { +real_t PropDataPortal2D::get_portal_margin() const { return _portal_margin; } -void PropDataPortal::set_portal_margin(real_t p_margin) { +void PropDataPortal2D::set_portal_margin(real_t p_margin) { _portal_margin = p_margin; } -PoolVector PropDataPortal::get_points() const { +PoolVector PropDataPortal2D::get_points() const { return _points; } -void PropDataPortal::set_points(const PoolVector &p_points) { +void PropDataPortal2D::set_points(const PoolVector &p_points) { _points = p_points; } -bool PropDataPortal::_processor_handles(Node *node) { +bool PropDataPortal2D::_processor_handles(Node *node) { Portal *p = Object::cast_to(node); return p; } -void PropDataPortal::_processor_process(Ref prop_data, Node *node, const Transform &transform) { +void PropDataPortal2D::_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 PropDataPortal::_processor_process(Ref prop_data, Node *node, con prop_data->add_prop(l); } -Node *PropDataPortal::_processor_get_node_for(const Transform &transform) { +Node *PropDataPortal2D::_processor_get_node_for(const Transform &transform) { Portal *p = memnew(Portal); p->set_portal_active(get_is_active()); @@ -98,33 +98,33 @@ Node *PropDataPortal::_processor_get_node_for(const Transform &transform) { return p; } -PropDataPortal::PropDataPortal() { +PropDataPortal2D::PropDataPortal2D() { _is_active = true; _is_two_way = true; _use_default_margin = true; _portal_margin = 1; } -PropDataPortal::~PropDataPortal() { +PropDataPortal2D::~PropDataPortal2D() { } -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); +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); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_active"), "set_is_active", "get_is_active"); - 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); + 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); 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"), &PropDataPortal::get_use_default_margin); - ClassDB::bind_method(D_METHOD("set_use_default_margin", "value"), &PropDataPortal::set_use_default_margin); + 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); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_default_margin"), "set_use_default_margin", "get_use_default_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); + 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); ADD_PROPERTY(PropertyInfo(Variant::REAL, "portal_margin"), "set_portal_margin", "get_portal_margin"); - ClassDB::bind_method(D_METHOD("get_points"), &PropDataPortal::get_points); - ClassDB::bind_method(D_METHOD("set_points", "value"), &PropDataPortal::set_points); + ClassDB::bind_method(D_METHOD("get_points"), &PropDataPortal2D::get_points); + ClassDB::bind_method(D_METHOD("set_points", "value"), &PropDataPortal2D::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_2d.h index 3f0831b..f3c1212 100644 --- a/props/prop_data_portal_2d.h +++ b/props/prop_data_portal_2d.h @@ -27,8 +27,8 @@ SOFTWARE. #include "prop_data_entry_2d.h" -class PropDataPortal : public PropDataEntry { - GDCLASS(PropDataPortal, PropDataEntry); +class PropDataPortal2D : public PropDataEntry2D { + GDCLASS(PropDataPortal2D, PropDataEntry2D); 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); - PropDataPortal(); - ~PropDataPortal(); + PropDataPortal2D(); + ~PropDataPortal2D(); protected: static void _bind_methods(); diff --git a/props/prop_data_prop_2d.cpp b/props/prop_data_prop_2d.cpp index cd2946b..c4c00ab 100644 --- a/props/prop_data_prop_2d.cpp +++ b/props/prop_data_prop_2d.cpp @@ -25,55 +25,55 @@ SOFTWARE. #include "../prop_instance_2d.h" #include "prop_data_2d.h" -Ref PropDataProp::get_prop() const { +Ref PropDataProp2D::get_prop() const { return _prop; } -void PropDataProp::set_prop(const Ref value) { +void PropDataProp2D::set_prop(const Ref value) { _prop = value; } -bool PropDataProp::get_snap_to_mesh() { +bool PropDataProp2D::get_snap_to_mesh() { return _snap_to_mesh; } -void PropDataProp::set_snap_to_mesh(bool value) { +void PropDataProp2D::set_snap_to_mesh(bool value) { _snap_to_mesh = value; } -Vector3 PropDataProp::get_snap_axis() { +Vector3 PropDataProp2D::get_snap_axis() { return _snap_axis; } -void PropDataProp::set_snap_axis(Vector3 value) { +void PropDataProp2D::set_snap_axis(Vector3 value) { _snap_axis = value; } #if TEXTURE_PACKER_PRESENT -void PropDataProp::_add_textures_into(Ref texture_packer) { +void PropDataProp2D::_add_textures_into(Ref texture_packer) { if (get_prop().is_valid()) { get_prop()->add_textures_into(texture_packer); } } #endif -bool PropDataProp::_processor_handles(Node *node) { - PropInstance *i = Object::cast_to(node); +bool PropDataProp2D::_processor_handles(Node *node) { + PropInstance2D *i = Object::cast_to(node); return i; } -void PropDataProp::_processor_process(Ref prop_data, Node *node, const Transform &transform) { - PropInstance *i = Object::cast_to(node); +void PropDataProp2D::_processor_process(Ref prop_data, Node *node, const Transform &transform) { + PropInstance2D *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 *PropDataProp::_processor_get_node_for(const Transform &transform) { - PropInstance *i = memnew(PropInstance); +Node *PropDataProp2D::_processor_get_node_for(const Transform &transform) { + PropInstance2D *i = memnew(PropInstance2D); i->set_prop_data(get_prop()); i->set_transform(get_transform()); @@ -81,29 +81,29 @@ Node *PropDataProp::_processor_get_node_for(const Transform &transform) { return i; } -PropDataProp::PropDataProp() { +PropDataProp2D::PropDataProp2D() { _snap_to_mesh = false; _snap_axis = Vector3(0, 1, 0); } -PropDataProp::~PropDataProp() { +PropDataProp2D::~PropDataProp2D() { if (_prop.is_valid()) _prop.unref(); } -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"); +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"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - 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); + 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); 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"), &PropDataProp::_add_textures_into); + ClassDB::bind_method(D_METHOD("_add_textures_into", "texture_packer"), &PropDataProp2D::_add_textures_into); #endif } diff --git a/props/prop_data_prop_2d.h b/props/prop_data_prop_2d.h index 2d49da0..b3a5b35 100644 --- a/props/prop_data_prop_2d.h +++ b/props/prop_data_prop_2d.h @@ -32,12 +32,12 @@ SOFTWARE. #include "../../texture_packer/texture_packer.h" #endif -class PropDataProp : public PropDataEntry { - GDCLASS(PropDataProp, PropDataEntry); +class PropDataProp2D : public PropDataEntry2D { + GDCLASS(PropDataProp2D, PropDataEntry2D); 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); - PropDataProp(); - ~PropDataProp(); + PropDataProp2D(); + ~PropDataProp2D(); 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_2d.cpp index 7ad97de..37c30d8 100644 --- a/props/prop_data_scene_2d.cpp +++ b/props/prop_data_scene_2d.cpp @@ -25,47 +25,47 @@ SOFTWARE. #include "../prop_scene_instance_2d.h" #include "prop_data_2d.h" -Ref PropDataScene::get_scene() { +Ref PropDataScene2D::get_scene() { return _scene; } -void PropDataScene::set_scene(const Ref &value) { +void PropDataScene2D::set_scene(const Ref &value) { _scene = value; } -bool PropDataScene::get_snap_to_mesh() { +bool PropDataScene2D::get_snap_to_mesh() { return _snap_to_mesh; } -void PropDataScene::set_snap_to_mesh(bool value) { +void PropDataScene2D::set_snap_to_mesh(bool value) { _snap_to_mesh = value; } -Vector3 PropDataScene::get_snap_axis() { +Vector3 PropDataScene2D::get_snap_axis() { return _snap_axis; } -void PropDataScene::set_snap_axis(Vector3 value) { +void PropDataScene2D::set_snap_axis(Vector3 value) { _snap_axis = value; } -bool PropDataScene::_processor_handles(Node *node) { - PropSceneInstance *i = Object::cast_to(node); +bool PropDataScene2D::_processor_handles(Node *node) { + PropSceneInstance2D *i = Object::cast_to(node); return i; } -void PropDataScene::_processor_process(Ref prop_data, Node *node, const Transform &transform) { - PropSceneInstance *i = Object::cast_to(node); +void PropDataScene2D::_processor_process(Ref prop_data, Node *node, const Transform &transform) { + PropSceneInstance2D *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 *PropDataScene::_processor_get_node_for(const Transform &transform) { - PropSceneInstance *i = memnew(PropSceneInstance); +Node *PropDataScene2D::_processor_get_node_for(const Transform &transform) { + PropSceneInstance2D *i = memnew(PropSceneInstance2D); i->set_scene(get_scene()); i->set_transform(get_transform()); @@ -73,25 +73,25 @@ Node *PropDataScene::_processor_get_node_for(const Transform &transform) { return i; } -PropDataScene::PropDataScene() { +PropDataScene2D::PropDataScene2D() { _snap_to_mesh = true; _snap_axis = Vector3(0, 1, 0); } -PropDataScene::~PropDataScene() { +PropDataScene2D::~PropDataScene2D() { if (_scene.is_valid()) _scene.unref(); } -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); +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); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - 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); + 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); 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_2d.h index 138a81f..46ddcb7 100644 --- a/props/prop_data_scene_2d.h +++ b/props/prop_data_scene_2d.h @@ -28,8 +28,8 @@ SOFTWARE. #include "scene/resources/packed_scene.h" -class PropDataScene : public PropDataEntry { - GDCLASS(PropDataScene, PropDataEntry); +class PropDataScene2D : public PropDataEntry2D { + GDCLASS(PropDataScene2D, PropDataEntry2D); 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); - PropDataScene(); - ~PropDataScene(); + PropDataScene2D(); + ~PropDataScene2D(); protected: static void _bind_methods(); diff --git a/props/prop_data_tiled_wall_2d.cpp b/props/prop_data_tiled_wall_2d.cpp index d17bf9c..3abe9be 100644 --- a/props/prop_data_tiled_wall_2d.cpp +++ b/props/prop_data_tiled_wall_2d.cpp @@ -27,46 +27,46 @@ SOFTWARE. #include "prop_data_2d.h" -int PropDataTiledWall::get_width() const { +int PropDataTiledWall2D::get_width() const { return _width; } -void PropDataTiledWall::set_width(const int value) { +void PropDataTiledWall2D::set_width(const int value) { _width = value; } -int PropDataTiledWall::get_heigth() const { +int PropDataTiledWall2D::get_heigth() const { return _height; } -void PropDataTiledWall::set_heigth(const int value) { +void PropDataTiledWall2D::set_heigth(const int value) { _height = value; } -Ref PropDataTiledWall::get_data() { +Ref PropDataTiledWall2D::get_data() { return _data; } -void PropDataTiledWall::set_data(const Ref &data) { +void PropDataTiledWall2D::set_data(const Ref &data) { _data = data; } -bool PropDataTiledWall::get_collision() const { +bool PropDataTiledWall2D::get_collision() const { return _collision; } -void PropDataTiledWall::set_collision(const int value) { +void PropDataTiledWall2D::set_collision(const int value) { _collision = value; } -bool PropDataTiledWall::_processor_handles(Node *node) { - TiledWall *t = Object::cast_to(node); +bool PropDataTiledWall2D::_processor_handles(Node *node) { + TiledWall2D *t = Object::cast_to(node); return t; } -void PropDataTiledWall::_processor_process(Ref prop_data, Node *node, const Transform &transform) { - TiledWall *t = Object::cast_to(node); +void PropDataTiledWall2D::_processor_process(Ref prop_data, Node *node, const Transform &transform) { + TiledWall2D *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 PropDataTiledWall::_processor_process(Ref prop_data, Node *node, prop_data->add_prop(tw); } -Node *PropDataTiledWall::_processor_get_node_for(const Transform &transform) { - TiledWall *t = memnew(TiledWall); +Node *PropDataTiledWall2D::_processor_get_node_for(const Transform &transform) { + TiledWall2D *t = memnew(TiledWall2D); t->set_width(get_width()); t->set_heigth(get_heigth()); @@ -89,29 +89,29 @@ Node *PropDataTiledWall::_processor_get_node_for(const Transform &transform) { return t; } -PropDataTiledWall::PropDataTiledWall() { +PropDataTiledWall2D::PropDataTiledWall2D() { _width = 1; _height = 1; _collision = true; } -PropDataTiledWall::~PropDataTiledWall() { +PropDataTiledWall2D::~PropDataTiledWall2D() { _data.unref(); } -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); +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); ADD_PROPERTY(PropertyInfo(Variant::INT, "width"), "set_width", "get_width"); - ClassDB::bind_method(D_METHOD("get_heigth"), &PropDataTiledWall::get_heigth); - ClassDB::bind_method(D_METHOD("set_heigth", "value"), &PropDataTiledWall::set_heigth); + ClassDB::bind_method(D_METHOD("get_heigth"), &PropDataTiledWall2D::get_heigth); + ClassDB::bind_method(D_METHOD("set_heigth", "value"), &PropDataTiledWall2D::set_heigth); ADD_PROPERTY(PropertyInfo(Variant::INT, "heigth"), "set_heigth", "get_heigth"); - 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_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_collision"), &PropDataTiledWall::get_collision); - ClassDB::bind_method(D_METHOD("set_collision", "value"), &PropDataTiledWall::set_collision); + ClassDB::bind_method(D_METHOD("get_collision"), &PropDataTiledWall2D::get_collision); + ClassDB::bind_method(D_METHOD("set_collision", "value"), &PropDataTiledWall2D::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_2d.h index 0f3650d..bdcb42f 100644 --- a/props/prop_data_tiled_wall_2d.h +++ b/props/prop_data_tiled_wall_2d.h @@ -26,10 +26,10 @@ SOFTWARE. #include "core/math/vector3.h" #include "prop_data_entry_2d.h" -class TiledWallData; +class TiledWallData2D; -class PropDataTiledWall : public PropDataEntry { - GDCLASS(PropDataTiledWall, PropDataEntry); +class PropDataTiledWall2D : public PropDataEntry2D { + GDCLASS(PropDataTiledWall2D, PropDataEntry2D); 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); - PropDataTiledWall(); - ~PropDataTiledWall(); + PropDataTiledWall2D(); + ~PropDataTiledWall2D(); 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 01e2b44..47b2815 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -74,77 +74,77 @@ SOFTWARE. #include "material_cache/prop_material_cache_pcm_2d.h" #endif -static PropUtils *prop_utils = NULL; -static PropCache *prop_texture_cache = NULL; +static PropUtils2D *prop_utils = NULL; +static PropCache2D *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(PropUtils); - ClassDB::register_class(); - Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton())); + prop_utils = memnew(PropUtils2D); + ClassDB::register_class(); + Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils2D", PropUtils2D::get_singleton())); - prop_texture_cache = memnew(PropCache); - ClassDB::register_class(); - Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache", PropCache::get_singleton())); + prop_texture_cache = memnew(PropCache2D); + ClassDB::register_class(); + Engine::get_singleton()->add_singleton(Engine::Singleton("PropCache2D", PropCache2D::get_singleton())); - Ref light_processor = Ref(memnew(PropDataLight)); - PropUtils::add_processor(light_processor); + Ref light_processor = Ref(memnew(PropDataLight2D)); + PropUtils2D::add_processor(light_processor); - Ref prop_processor = Ref(memnew(PropDataProp)); - PropUtils::add_processor(prop_processor); + Ref prop_processor = Ref(memnew(PropDataProp2D)); + PropUtils2D::add_processor(prop_processor); - Ref scene_processor = Ref(memnew(PropDataScene)); - PropUtils::add_processor(scene_processor); + Ref scene_processor = Ref(memnew(PropDataScene2D)); + PropUtils2D::add_processor(scene_processor); #if VERSION_MINOR >= 4 - Ref portal_processor = Ref(memnew(PropDataPortal)); - PropUtils::add_processor(portal_processor); + Ref portal_processor = Ref(memnew(PropDataPortal2D)); + PropUtils2D::add_processor(portal_processor); #endif - Ref tiled_wall_processor = Ref(memnew(PropDataTiledWall)); - PropUtils::add_processor(tiled_wall_processor); + Ref tiled_wall_processor = Ref(memnew(PropDataTiledWall2D)); + PropUtils2D::add_processor(tiled_wall_processor); #ifdef TOOLS_ENABLED - EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); #endif } diff --git a/singleton/prop_cache_2d.cpp b/singleton/prop_cache_2d.cpp index f83a04f..b35eadc 100644 --- a/singleton/prop_cache_2d.cpp +++ b/singleton/prop_cache_2d.cpp @@ -66,94 +66,94 @@ SOFTWARE. #endif -PropCache *PropCache::_instance; +PropCache2D *PropCache2D::_instance; -PropCache *PropCache::get_singleton() { +PropCache2D *PropCache2D::get_singleton() { return _instance; } -StringName PropCache::get_default_prop_material_cache_class() { +StringName PropCache2D::get_default_prop_material_cache_class() { return _default_prop_material_cache_class; } -void PropCache::set_default_prop_material_cache_class(const StringName &cls_name) { +void PropCache2D::set_default_prop_material_cache_class(const StringName &cls_name) { _default_prop_material_cache_class = cls_name; } #ifdef TEXTURE_PACKER_PRESENT -int PropCache::get_texture_flags() const { +int PropCache2D::get_texture_flags() const { return _texture_flags; } -void PropCache::set_texture_flags(const int flags) { +void PropCache2D::set_texture_flags(const int flags) { _texture_flags = flags; } -int PropCache::get_max_atlas_size() const { +int PropCache2D::get_max_atlas_size() const { return _max_atlas_size; } -void PropCache::set_max_atlas_size(const int size) { +void PropCache2D::set_max_atlas_size(const int size) { _max_atlas_size = size; } -bool PropCache::get_keep_original_atlases() const { +bool PropCache2D::get_keep_original_atlases() const { return _keep_original_atlases; } -void PropCache::set_keep_original_atlases(const bool value) { +void PropCache2D::set_keep_original_atlases(const bool value) { _keep_original_atlases = value; } -Color PropCache::get_background_color() const { +Color PropCache2D::get_background_color() const { return _background_color; } -void PropCache::set_background_color(const Color &color) { +void PropCache2D::set_background_color(const Color &color) { _background_color = color; } -int PropCache::get_margin() const { +int PropCache2D::get_margin() const { return _margin; } -void PropCache::set_margin(const int margin) { +void PropCache2D::set_margin(const int margin) { _margin = margin; } #endif -PoolStringArray PropCache::material_paths_get() const { +PoolStringArray PropCache2D::material_paths_get() const { return _material_paths; } -void PropCache::material_paths_set(const PoolStringArray &value) { +void PropCache2D::material_paths_set(const PoolStringArray &value) { _material_paths = value; } -void PropCache::material_add(const Ref &value) { +void PropCache2D::material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); _materials.push_back(value); } -Ref PropCache::material_get(const int index) { +Ref PropCache2D::material_get(const int index) { ERR_FAIL_INDEX_V(index, _materials.size(), Ref()); return _materials[index]; } -void PropCache::material_set(const int index, const Ref &value) { +void PropCache2D::material_set(const int index, const Ref &value) { ERR_FAIL_INDEX(index, _materials.size()); _materials.set(index, value); } -void PropCache::material_remove(const int index) { +void PropCache2D::material_remove(const int index) { _materials.remove(index); } -int PropCache::material_get_num() const { +int PropCache2D::material_get_num() const { return _materials.size(); } -void PropCache::materials_clear() { +void PropCache2D::materials_clear() { _materials.clear(); } -void PropCache::materials_load() { +void PropCache2D::materials_load() { _materials.clear(); for (int i = 0; i < _material_paths.size(); ++i) { @@ -169,17 +169,17 @@ void PropCache::materials_load() { } } -void PropCache::ensure_materials_loaded() { +void PropCache2D::ensure_materials_loaded() { if (_materials.size() != _material_paths.size()) { materials_load(); } } -Vector PropCache::materials_get() { +Vector PropCache2D::materials_get() { VARIANT_ARRAY_GET(_materials); } -void PropCache::materials_set(const Vector &materials) { +void PropCache2D::materials_set(const Vector &materials) { _materials.clear(); for (int i = 0; i < materials.size(); i++) { @@ -189,16 +189,16 @@ void PropCache::materials_set(const Vector &materials) { } } -Ref PropCache::material_cache_get(const Ref &prop) { - ERR_FAIL_COND_V(!prop.is_valid(), Ref()); +Ref PropCache2D::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 PropCache::material_cache_get(const Ref &prop) return m; } - PropMaterialCache *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); + PropMaterialCache2D *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); if (!p) { - ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class)); + ERR_PRINT("Can't instance the given PropMaterialCache2D! class_name: " + String(_default_prop_material_cache_class)); } - Ref m(p); + Ref m(p); _material_cache[k] = m; @@ -221,21 +221,21 @@ Ref PropCache::material_cache_get(const Ref &prop) return m; } -void PropCache::material_cache_unref(const Ref &prop) { +void PropCache2D::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("PropCache::material_cache_unref: can't find cache!"); + ERR_PRINT("PropCache2D::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 PropCache::material_cache_unref(const Ref &prop) { _material_cache_mutex.unlock(); } -Ref PropCache::tiled_wall_material_cache_get(const Ref &twd) { - ERR_FAIL_COND_V(!twd.is_valid(), Ref()); +Ref PropCache2D::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 PropCache::tiled_wall_material_cache_get(const Ref(ClassDB::instance(_default_prop_material_cache_class)); + PropMaterialCache2D *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); if (!p) { - ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class)); + ERR_PRINT("Can't instance the given PropMaterialCache2D! 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 PropCache::tiled_wall_material_cache_get(const Ref &twd) { +void PropCache2D::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("PropCache::material_cache_unref: can't find cache!"); + ERR_PRINT("PropCache2D::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 PropCache::tiled_wall_material_cache_unref(const Ref &twd) { _tiled_wall_material_cache_mutex.unlock(); } -Ref PropCache::material_cache_custom_key_get(const uint64_t key) { +Ref PropCache2D::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 PropCache::material_cache_custom_key_get(const uint64_t k return m; } - PropMaterialCache *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); + PropMaterialCache2D *p = Object::cast_to(ClassDB::instance(_default_prop_material_cache_class)); if (!p) { - ERR_PRINT("Can't instance the given PropMaterialCache! class_name: " + String(_default_prop_material_cache_class)); + ERR_PRINT("Can't instance the given PropMaterialCache2D! 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 PropCache::material_cache_custom_key_get(const uint64_t k return m; } -void PropCache::material_cache_custom_key_unref(const uint64_t key) { +void PropCache2D::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("PropCache::material_cache_custom_key_unref: can't find cache!"); + ERR_PRINT("PropCache2D::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 PropCache::material_cache_custom_key_unref(const uint64_t key) { _custom_keyed_material_cache_mutex.unlock(); } -Ref PropCache::load_resource(const String &path, const String &type_hint) { +Ref PropCache2D::load_resource(const String &path, const String &type_hint) { _ResourceLoader *rl = _ResourceLoader::get_singleton(); #if VERSION_MAJOR < 4 @@ -365,13 +365,13 @@ Ref PropCache::load_resource(const String &path, const String &type_hi #endif } -PropCache::PropCache() { +PropCache2D::PropCache2D() { _instance = this; #if TEXTURE_PACKER_PRESENT - _default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCachePCM"); + _default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache2DPCM"); #else - _default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache"); + _default_prop_material_cache_class = GLOBAL_DEF("props/default_prop_material_cache_class", "PropMaterialCache2D"); #endif #ifdef TEXTURE_PACKER_PRESENT @@ -390,62 +390,62 @@ PropCache::PropCache() { _material_paths = GLOBAL_DEF("props/material_paths", PoolStringArray()); } -PropCache::~PropCache() { +PropCache2D::~PropCache2D() { _instance = NULL; } -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); +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); 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"), &PropCache::get_texture_flags); - ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &PropCache::set_texture_flags); + 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); 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"), &PropCache::get_max_atlas_size); - ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &PropCache::set_max_atlas_size); + 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); 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"), &PropCache::get_keep_original_atlases); - ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &PropCache::set_keep_original_atlases); + 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); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_original_atlases"), "set_keep_original_atlases", "get_keep_original_atlases"); - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_background_color", "get_background_color"); - ClassDB::bind_method(D_METHOD("get_margin"), &PropCache::get_margin); - ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropCache::set_margin); + ClassDB::bind_method(D_METHOD("get_margin"), &PropCache2D::get_margin); + ClassDB::bind_method(D_METHOD("set_margin", "size"), &PropCache2D::set_margin); ADD_PROPERTY(PropertyInfo(Variant::INT, "margin"), "set_margin", "get_margin"); #endif - 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); + 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); ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "material_paths"), "material_paths_set", "material_paths_get"); - 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("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("materials_get"), &PropCache::materials_get); - ClassDB::bind_method(D_METHOD("materials_set"), &PropCache::materials_set); + ClassDB::bind_method(D_METHOD("materials_get"), &PropCache2D::materials_get); + ClassDB::bind_method(D_METHOD("materials_set"), &PropCache2D::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"), &PropCache::material_cache_get); - ClassDB::bind_method(D_METHOD("material_cache_unref", "prop"), &PropCache::material_cache_unref); + 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("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("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("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("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("load_resource", "path", "type_hint"), &PropCache::load_resource, ""); + ClassDB::bind_method(D_METHOD("load_resource", "path", "type_hint"), &PropCache2D::load_resource, ""); } diff --git a/singleton/prop_cache_2d.h b/singleton/prop_cache_2d.h index 0c25383..2f508bb 100644 --- a/singleton/prop_cache_2d.h +++ b/singleton/prop_cache_2d.h @@ -47,14 +47,14 @@ SOFTWARE. #include "../props/prop_data_2d.h" -class PropMaterialCache; -class TiledWallData; +class PropMaterialCache2D; +class TiledWallData2D; -class PropCache : public Object { - GDCLASS(PropCache, Object); +class PropCache2D : public Object { + GDCLASS(PropCache2D, Object); public: - static PropCache *get_singleton(); + static PropCache2D *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 PropCache *_instance; + static PropCache2D *_instance; public: - PropCache(); - ~PropCache(); + PropCache2D(); + ~PropCache2D(); 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_2d.cpp index e429d07..d817600 100644 --- a/singleton/prop_utils_2d.cpp +++ b/singleton/prop_utils_2d.cpp @@ -46,19 +46,19 @@ SOFTWARE. #include "core/engine.h" #endif -PropUtils *PropUtils::_instance; -Vector > PropUtils::_processors; +PropUtils2D *PropUtils2D::_instance; +Vector > PropUtils2D::_processors; -PropUtils *PropUtils::get_singleton() { +PropUtils2D *PropUtils2D::get_singleton() { return _instance; } -Ref PropUtils::convert_tree(Node *root) { +Ref PropUtils2D::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 PropUtils::convert_tree(Node *root) { return data; } -void PropUtils::_convert_tree(Ref prop_data, Node *node, const Transform &transform) { +void PropUtils2D::_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 < PropUtils::_processors.size(); ++i) { - Ref proc = PropUtils::_processors.get(i); + for (int i = 0; i < PropUtils2D::_processors.size(); ++i) { + Ref proc = PropUtils2D::_processors.get(i); ERR_CONTINUE(!proc.is_valid()); @@ -138,7 +138,7 @@ void PropUtils::_convert_tree(Ref prop_data, Node *node, const Transfo } #if VERSION_MINOR >= 4 -bool PropUtils::generate_room_points_node(Node *node) { +bool PropUtils2D::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 PropUtils::generate_room_points_node(Node *node) { return false; } -void PropUtils::generate_room_points(Room *room) { +void PropUtils2D::generate_room_points(Room *room) { ERR_FAIL_COND(!ObjectDB::instance_validate(room)); Vector > mesh_arrays; @@ -281,7 +281,7 @@ void PropUtils::generate_room_points(Room *room) { } //based on Room::SimplifyInfo::add_plane_if_unique -bool PropUtils::is_plane_unique(const PoolVector &planes, const Plane &p) { +bool PropUtils2D::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 PropUtils::is_plane_unique(const PoolVector &planes, const Plane &p) return true; } -void PropUtils::get_mesh_arrays(Node *node, Vector > *arrs) { +void PropUtils2D::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 PropUtils::get_mesh_arrays(Node *node, Vector > *arrs) #endif -int PropUtils::add_processor(const Ref &processor) { +int PropUtils2D::add_processor(const Ref &processor) { ERR_FAIL_COND_V(!processor.is_valid(), 0); - PropUtils::_processors.push_back(processor); + PropUtils2D::_processors.push_back(processor); - return PropUtils::_processors.size() - 1; + return PropUtils2D::_processors.size() - 1; } -Ref PropUtils::get_processor(const int index) { - ERR_FAIL_INDEX_V(index, PropUtils::_processors.size(), Ref()); +Ref PropUtils2D::get_processor(const int index) { + ERR_FAIL_INDEX_V(index, PropUtils2D::_processors.size(), Ref()); - return PropUtils::_processors[index]; + return PropUtils2D::_processors[index]; } -void PropUtils::swap_processors(const int index1, const int index2) { - ERR_FAIL_INDEX(index1, PropUtils::_processors.size()); - ERR_FAIL_INDEX(index2, PropUtils::_processors.size()); +void PropUtils2D::swap_processors(const int index1, const int index2) { + ERR_FAIL_INDEX(index1, PropUtils2D::_processors.size()); + ERR_FAIL_INDEX(index2, PropUtils2D::_processors.size()); - Ref a = PropUtils::_processors.get(index1); - PropUtils::_processors.set(index1, PropUtils::_processors.get(index2)); - PropUtils::_processors.set(index2, a); + Ref a = PropUtils2D::_processors.get(index1); + PropUtils2D::_processors.set(index1, PropUtils2D::_processors.get(index2)); + PropUtils2D::_processors.set(index2, a); } -void PropUtils::remove_processor(const int index) { - ERR_FAIL_INDEX(index, PropUtils::_processors.size()); +void PropUtils2D::remove_processor(const int index) { + ERR_FAIL_INDEX(index, PropUtils2D::_processors.size()); - PropUtils::_processors.remove(index); + PropUtils2D::_processors.remove(index); } -int PropUtils::get_processor_count() { - return PropUtils::_processors.size(); +int PropUtils2D::get_processor_count() { + return PropUtils2D::_processors.size(); } -PropUtils::PropUtils() { +PropUtils2D::PropUtils2D() { _instance = this; } -PropUtils::~PropUtils() { +PropUtils2D::~PropUtils2D() { _instance = NULL; - PropUtils::_processors.clear(); + PropUtils2D::_processors.clear(); } -void PropUtils::_bind_methods() { - ClassDB::bind_method(D_METHOD("convert_tree", "root"), &PropUtils::convert_tree); +void PropUtils2D::_bind_methods() { + ClassDB::bind_method(D_METHOD("convert_tree", "root"), &PropUtils2D::convert_tree); - 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); + 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); } -int PropUtils::_add_processor_bind(const Ref &processor) { - return PropUtils::add_processor(processor); +int PropUtils2D::_add_processor_bind(const Ref &processor) { + return PropUtils2D::add_processor(processor); } -Ref PropUtils::_get_processor_bind(const int index) { - return PropUtils::get_processor(index); +Ref PropUtils2D::_get_processor_bind(const int index) { + return PropUtils2D::get_processor(index); } -void PropUtils::_swap_processors_bind(const int index1, const int index2) { - PropUtils::swap_processors(index1, index2); +void PropUtils2D::_swap_processors_bind(const int index1, const int index2) { + PropUtils2D::swap_processors(index1, index2); } -void PropUtils::_remove_processor_bind(const int index) { - PropUtils::remove_processor(index); +void PropUtils2D::_remove_processor_bind(const int index) { + PropUtils2D::remove_processor(index); } -int PropUtils::_get_processor_count_bind() { - return PropUtils::get_processor_count(); +int PropUtils2D::_get_processor_count_bind() { + return PropUtils2D::get_processor_count(); } diff --git a/singleton/prop_utils_2d.h b/singleton/prop_utils_2d.h index fa8232a..6573f13 100644 --- a/singleton/prop_utils_2d.h +++ b/singleton/prop_utils_2d.h @@ -39,21 +39,21 @@ SOFTWARE. #include "scene/main/node.h" -class PropData; -class PropDataEntry; +class PropData2D; +class PropDataEntry2D; #if VERSION_MINOR >= 4 class Room; #endif -class PropUtils : public Object { - GDCLASS(PropUtils, Object); +class PropUtils2D : public Object { + GDCLASS(PropUtils2D, Object); public: - static PropUtils *get_singleton(); + static PropUtils2D *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(); - PropUtils(); - ~PropUtils(); + PropUtils2D(); + ~PropUtils2D(); 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 PropUtils *_instance; + static Vector> _processors; + static PropUtils2D *_instance; }; #endif diff --git a/tiled_wall/tiled_wall_2d.cpp b/tiled_wall/tiled_wall_2d.cpp index 08b0988..e058e0b 100644 --- a/tiled_wall/tiled_wall_2d.cpp +++ b/tiled_wall/tiled_wall_2d.cpp @@ -25,30 +25,30 @@ #include "core/core_string_names.h" #include "tiled_wall_data_2d.h" -int TiledWall::get_width() const { +int TiledWall2D::get_width() const { return _width; } -void TiledWall::set_width(const int value) { +void TiledWall2D::set_width(const int value) { _width = value; clear_mesh(); generate_mesh(); } -int TiledWall::get_heigth() const { +int TiledWall2D::get_heigth() const { return _height; } -void TiledWall::set_heigth(const int value) { +void TiledWall2D::set_heigth(const int value) { _height = value; clear_mesh(); generate_mesh(); } -Ref TiledWall::get_data() { +Ref TiledWall2D::get_data() { return _data; } -void TiledWall::set_data(const Ref &data) { +void TiledWall2D::set_data(const Ref &data) { if (_data.is_valid()) { _data->disconnect(CoreStringNames::get_singleton()->changed, this, "refresh"); } @@ -62,10 +62,10 @@ void TiledWall::set_data(const Ref &data) { call_deferred("refresh"); } -bool TiledWall::get_collision() const { +bool TiledWall2D::get_collision() const { return _collision; } -void TiledWall::set_collision(const int value) { +void TiledWall2D::set_collision(const int value) { _collision = value; /* @@ -80,11 +80,11 @@ void TiledWall::set_collision(const int value) { }*/ } -uint32_t TiledWall::get_collision_layer() const { +uint32_t TiledWall2D::get_collision_layer() const { return _collision_layer; } -void TiledWall::set_collision_layer(uint32_t p_layer) { +void TiledWall2D::set_collision_layer(uint32_t p_layer) { _collision_layer = p_layer; if (_physics_body_rid != RID()) { @@ -92,11 +92,11 @@ void TiledWall::set_collision_layer(uint32_t p_layer) { } } -uint32_t TiledWall::get_collision_mask() const { +uint32_t TiledWall2D::get_collision_mask() const { return _collision_mask; } -void TiledWall::set_collision_mask(uint32_t p_mask) { +void TiledWall2D::set_collision_mask(uint32_t p_mask) { _collision_mask = p_mask; if (_physics_body_rid != RID()) { @@ -104,11 +104,11 @@ void TiledWall::set_collision_mask(uint32_t p_mask) { } } -AABB TiledWall::get_aabb() const { +AABB TiledWall2D::get_aabb() const { return AABB(); } -PoolVector TiledWall::get_faces(uint32_t p_usage_flags) const { +PoolVector TiledWall2D::get_faces(uint32_t p_usage_flags) const { PoolVector faces; if (_mesh_array.size() != Mesh::ARRAY_MAX) { @@ -138,7 +138,7 @@ PoolVector TiledWall::get_faces(uint32_t p_usage_flags) const { return faces; } -void TiledWall::refresh() { +void TiledWall2D::refresh() { if (!is_inside_tree()) { return; } @@ -163,14 +163,14 @@ void TiledWall::refresh() { VS::get_singleton()->instance_set_base(get_instance(), _mesh_rid); } - Ref old_cache; + Ref old_cache; old_cache = _cache; - _cache = PropCache::get_singleton()->tiled_wall_material_cache_get(_data); + _cache = PropCache2D::get_singleton()->tiled_wall_material_cache_get(_data); if (old_cache.is_valid() && old_cache != _cache) { - PropCache::get_singleton()->tiled_wall_material_cache_unref(old_cache); + PropCache2D::get_singleton()->tiled_wall_material_cache_unref(old_cache); } if (!_cache->get_initialized()) { @@ -192,7 +192,7 @@ void TiledWall::refresh() { generate_mesh(); } -void TiledWall::generate_mesh() { +void TiledWall2D::generate_mesh() { if (!_data.is_valid()) { return; } @@ -234,7 +234,7 @@ void TiledWall::generate_mesh() { _aabb.size = Vector3(_width, _height, 0); } -void TiledWall::clear_mesh() { +void TiledWall2D::clear_mesh() { _mesher->reset(); _aabb = AABB(); _mesh_array.clear(); @@ -249,7 +249,7 @@ void TiledWall::clear_mesh() { } } -void TiledWall::free_mesh() { +void TiledWall2D::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 TiledWall::free_mesh() { } } -void TiledWall::create_colliders() { +void TiledWall2D::create_colliders() { if (!is_inside_tree()) { return; } @@ -272,7 +272,7 @@ void TiledWall::create_colliders() { PhysicsServer::get_singleton()->body_add_shape(_physics_body_rid, _physics_shape_rid); } -void TiledWall::free_colliders() { +void TiledWall2D::free_colliders() { if (_physics_shape_rid != RID()) { PhysicsServer::get_singleton()->free(_physics_shape_rid); @@ -280,7 +280,7 @@ void TiledWall::free_colliders() { } } -TiledWall::TiledWall() { +TiledWall2D::TiledWall2D() { _width = 1; _height = 1; _collision = true; @@ -296,7 +296,7 @@ TiledWall::TiledWall() { _mesher.instance(); } -TiledWall::~TiledWall() { +TiledWall2D::~TiledWall2D() { _data.unref(); _cache.unref(); _mesher.unref(); @@ -309,7 +309,7 @@ TiledWall::~TiledWall() { free_colliders(); } -void TiledWall::_notification(int p_what) { +void TiledWall2D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_WORLD: { Transform t = get_global_transform(); @@ -341,38 +341,38 @@ void TiledWall::_notification(int p_what) { } } -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); +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); ADD_PROPERTY(PropertyInfo(Variant::INT, "width"), "set_width", "get_width"); - ClassDB::bind_method(D_METHOD("get_heigth"), &TiledWall::get_heigth); - ClassDB::bind_method(D_METHOD("set_heigth", "value"), &TiledWall::set_heigth); + ClassDB::bind_method(D_METHOD("get_heigth"), &TiledWall2D::get_heigth); + ClassDB::bind_method(D_METHOD("set_heigth", "value"), &TiledWall2D::set_heigth); ADD_PROPERTY(PropertyInfo(Variant::INT, "heigth"), "set_heigth", "get_heigth"); - 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_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_collision"), &TiledWall::get_collision); - ClassDB::bind_method(D_METHOD("set_collision", "value"), &TiledWall::set_collision); + ClassDB::bind_method(D_METHOD("get_collision"), &TiledWall2D::get_collision); + ClassDB::bind_method(D_METHOD("set_collision", "value"), &TiledWall2D::set_collision); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision"), "set_collision", "get_collision"); - 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_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_mask"), &TiledWall::get_collision_mask); - ClassDB::bind_method(D_METHOD("set_collision_mask", "value"), &TiledWall::set_collision_mask); + 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); 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"), &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("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("create_colliders"), &TiledWall::create_colliders); - ClassDB::bind_method(D_METHOD("free_colliders"), &TiledWall::free_colliders); + ClassDB::bind_method(D_METHOD("create_colliders"), &TiledWall2D::create_colliders); + ClassDB::bind_method(D_METHOD("free_colliders"), &TiledWall2D::free_colliders); } diff --git a/tiled_wall/tiled_wall_2d.h b/tiled_wall/tiled_wall_2d.h index 78a4db8..90f9045 100644 --- a/tiled_wall/tiled_wall_2d.h +++ b/tiled_wall/tiled_wall_2d.h @@ -38,12 +38,12 @@ SOFTWARE. #include "core/math/vector3.h" -class TiledWallData; -class PropMaterialCache; -class PropMesher; +class TiledWallData2D; +class PropMaterialCache2D; +class PropMesher2D; -class TiledWall : public GeometryInstance { - GDCLASS(TiledWall, GeometryInstance); +class TiledWall2D : public GeometryInstance { + GDCLASS(TiledWall2D, 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(); - TiledWall(); - ~TiledWall(); + TiledWall2D(); + ~TiledWall2D(); 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_2d.cpp index 8038345..2df11e5 100644 --- a/tiled_wall/tiled_wall_data_2d.cpp +++ b/tiled_wall/tiled_wall_data_2d.cpp @@ -59,33 +59,33 @@ SOFTWARE. #include "../material_cache/prop_material_cache_2d.h" -const String TiledWallData::BINDING_STRING_TILED_WALL_TILING_TYPE = "None,Horizontal,Vertical,Both"; +const String TiledWallData2D::BINDING_STRING_TILED_WALL_TILING_TYPE = "None,Horizontal,Vertical,Both"; -TiledWallData::TiledWallTilingType TiledWallData::get_tiling_type() const { +TiledWallData2D::TiledWallTilingType TiledWallData2D::get_tiling_type() const { return _tiling_type; } -void TiledWallData::set_tiling_type(const TiledWallData::TiledWallTilingType value) { +void TiledWallData2D::set_tiling_type(const TiledWallData2D::TiledWallTilingType value) { _tiling_type = value; emit_changed(); } -Ref TiledWallData::get_texture(const int index) const { +Ref TiledWallData2D::get_texture(const int index) const { ERR_FAIL_INDEX_V(index, _textures.size(), Ref()); return _textures.get(index); } -void TiledWallData::set_texture(const int index, const Ref &texture) { +void TiledWallData2D::set_texture(const int index, const Ref &texture) { ERR_FAIL_INDEX(index, _textures.size()); _textures.set(index, texture); emit_changed(); } -void TiledWallData::add_texture(const Ref &texture) { +void TiledWallData2D::add_texture(const Ref &texture) { _textures.push_back(texture); } -void TiledWallData::remove_texture(const int index) { +void TiledWallData2D::remove_texture(const int index) { ERR_FAIL_INDEX(index, _textures.size()); _textures.remove(index); @@ -93,11 +93,11 @@ void TiledWallData::remove_texture(const int index) { emit_changed(); } -int TiledWallData::get_texture_count() const { +int TiledWallData2D::get_texture_count() const { return _textures.size(); } -Vector TiledWallData::get_textures() { +Vector TiledWallData2D::get_textures() { Vector r; for (int i = 0; i < _textures.size(); i++) { #if VERSION_MAJOR < 4 @@ -108,7 +108,7 @@ Vector TiledWallData::get_textures() { } return r; } -void TiledWallData::set_textures(const Vector &textures) { +void TiledWallData2D::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 TiledWallData::set_textures(const Vector &textures) { } //flavour_textures -Ref TiledWallData::get_flavour_texture(const int index) const { +Ref TiledWallData2D::get_flavour_texture(const int index) const { ERR_FAIL_INDEX_V(index, _flavour_textures.size(), Ref()); return _flavour_textures.get(index); } -void TiledWallData::set_flavour_texture(const int index, const Ref &texture) { +void TiledWallData2D::set_flavour_texture(const int index, const Ref &texture) { ERR_FAIL_INDEX(index, _flavour_textures.size()); _flavour_textures.set(index, texture); emit_changed(); } -void TiledWallData::add_flavour_texture(const Ref &texture) { +void TiledWallData2D::add_flavour_texture(const Ref &texture) { _flavour_textures.push_back(texture); } -void TiledWallData::remove_flavour_texture(const int index) { +void TiledWallData2D::remove_flavour_texture(const int index) { ERR_FAIL_INDEX(index, _flavour_textures.size()); _flavour_textures.remove(index); @@ -141,11 +141,11 @@ void TiledWallData::remove_flavour_texture(const int index) { emit_changed(); } -int TiledWallData::get_flavour_texture_count() const { +int TiledWallData2D::get_flavour_texture_count() const { return _flavour_textures.size(); } -Vector TiledWallData::get_flavour_textures() { +Vector TiledWallData2D::get_flavour_textures() { Vector r; for (int i = 0; i < _flavour_textures.size(); i++) { #if VERSION_MAJOR < 4 @@ -156,7 +156,7 @@ Vector TiledWallData::get_flavour_textures() { } return r; } -void TiledWallData::set_flavour_textures(const Vector &textures) { +void TiledWallData2D::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 TiledWallData::set_flavour_textures(const Vector &textures) { emit_changed(); } -float TiledWallData::get_flavour_chance() const { +float TiledWallData2D::get_flavour_chance() const { return _flavour_chance; } -void TiledWallData::set_flavour_chance(const float value) { +void TiledWallData2D::set_flavour_chance(const float value) { _flavour_chance = value; } //materials -void TiledWallData::material_add(const Ref &value) { +void TiledWallData2D::material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); _materials.push_back(value); } -void TiledWallData::material_set(const int index, const Ref &value) { +void TiledWallData2D::material_set(const int index, const Ref &value) { ERR_FAIL_INDEX(index, _materials.size()); _materials.set(index, value); @@ -189,25 +189,25 @@ void TiledWallData::material_set(const int index, const Ref &value) { emit_changed(); } -void TiledWallData::material_remove(const int index) { +void TiledWallData2D::material_remove(const int index) { _materials.remove(index); emit_changed(); } -int TiledWallData::material_get_num() const { +int TiledWallData2D::material_get_num() const { return _materials.size(); } -void TiledWallData::materials_clear() { +void TiledWallData2D::materials_clear() { _materials.clear(); } -Vector TiledWallData::materials_get() { +Vector TiledWallData2D::materials_get() { VARIANT_ARRAY_GET(_materials); } -void TiledWallData::materials_set(const Vector &materials) { +void TiledWallData2D::materials_set(const Vector &materials) { _materials.clear(); for (int i = 0; i < materials.size(); i++) { @@ -220,7 +220,7 @@ void TiledWallData::materials_set(const Vector &materials) { } #if TEXTURE_PACKER_PRESENT -void TiledWallData::add_textures_into(Ref texture_packer) { +void TiledWallData2D::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 TiledWallData::add_textures_into(Ref texture_packer) { } #endif -void TiledWallData::setup_cache(Ref cache) { +void TiledWallData2D::setup_cache(Ref cache) { //Note: the caller should lock and unlock the cache! call("_setup_cache", cache); } -void TiledWallData::_setup_cache(Ref cache) { +void TiledWallData2D::_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 TiledWallData::_setup_cache(Ref cache) { } } -void TiledWallData::copy_from(const Ref &tiled_wall_data) { +void TiledWallData2D::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 TiledWallData::copy_from(const Ref &tiled_wall_data) { emit_changed(); } -TiledWallData::TiledWallData() { +TiledWallData2D::TiledWallData2D() { _tiling_type = TILED_WALL_TILING_TYPE_NONE; _flavour_chance = 0.15; } -TiledWallData::~TiledWallData() { +TiledWallData2D::~TiledWallData2D() { _textures.clear(); _flavour_textures.clear(); _materials.clear(); } -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"); +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"); //textures - 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", "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_count"), &TiledWallData::get_texture_count); + ClassDB::bind_method(D_METHOD("get_texture_count"), &TiledWallData2D::get_texture_count); - ClassDB::bind_method(D_METHOD("get_textures"), &TiledWallData::get_textures); - ClassDB::bind_method(D_METHOD("set_textures", "textures"), &TiledWallData::set_textures); + ClassDB::bind_method(D_METHOD("get_textures"), &TiledWallData2D::get_textures); + ClassDB::bind_method(D_METHOD("set_textures", "textures"), &TiledWallData2D::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"), &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", "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_count"), &TiledWallData::get_flavour_texture_count); + ClassDB::bind_method(D_METHOD("get_flavour_texture_count"), &TiledWallData2D::get_flavour_texture_count); - 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); + 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); 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"), &TiledWallData::get_flavour_chance); - ClassDB::bind_method(D_METHOD("set_flavour_chance", "texture"), &TiledWallData::set_flavour_chance); + 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); ADD_PROPERTY(PropertyInfo(Variant::REAL, "flavour_chance"), "set_flavour_chance", "get_flavour_chance"); //materials - 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("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("materials_get"), &TiledWallData::materials_get); - ClassDB::bind_method(D_METHOD("materials_set"), &TiledWallData::materials_set); + ClassDB::bind_method(D_METHOD("materials_get"), &TiledWallData2D::materials_get); + ClassDB::bind_method(D_METHOD("materials_set"), &TiledWallData2D::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"), &TiledWallData::add_textures_into); + ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &TiledWallData2D::add_textures_into); #endif - BIND_VMETHOD(MethodInfo("_setup_cache", PropertyInfo(Variant::OBJECT, "cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache"))); + BIND_VMETHOD(MethodInfo("_setup_cache", PropertyInfo(Variant::OBJECT, "cache", PROPERTY_HINT_RESOURCE_TYPE, "PropMaterialCache2D"))); - 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("setup_cache", "cache"), &TiledWallData2D::setup_cache); + ClassDB::bind_method(D_METHOD("_setup_cache", "cache"), &TiledWallData2D::_setup_cache); - ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &TiledWallData::copy_from); + ClassDB::bind_method(D_METHOD("copy_from", "prop_data"), &TiledWallData2D::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_2d.h index c322c3a..bdf6127 100644 --- a/tiled_wall/tiled_wall_data_2d.h +++ b/tiled_wall/tiled_wall_data_2d.h @@ -47,11 +47,11 @@ SOFTWARE. #include "../../texture_packer/texture_packer.h" #endif -class PropMaterialCache; -class PropMesher; +class PropMaterialCache2D; +class PropMesher2D; -class TiledWallData : public Resource { - GDCLASS(TiledWallData, Resource); +class TiledWallData2D : public Resource { + GDCLASS(TiledWallData2D, 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(); - TiledWallData(); - ~TiledWallData(); + TiledWallData2D(); + ~TiledWallData2D(); protected: static void _bind_methods(); @@ -129,6 +129,6 @@ private: Vector> _materials; }; -VARIANT_ENUM_CAST(TiledWallData::TiledWallTilingType); +VARIANT_ENUM_CAST(TiledWallData2D::TiledWallTilingType); #endif