From b9f3d3b26a2938e0667d3029f96c9f1df5c3ff4e Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 28 Aug 2022 13:57:25 +0200 Subject: [PATCH] Moved Skeleton2D and it's related classes into a module. --- editor/editor_node.cpp | 2 - editor/plugins/canvas_item_editor_plugin.cpp | 15 ++++++- editor/plugins/polygon_2d_editor_plugin.cpp | 31 ++++++++----- modules/skeleton_2d/.gitignore | 7 +++ modules/skeleton_2d/SCsub | 24 ++++++++++ modules/skeleton_2d/config.py | 18 ++++++++ .../doc_classes}/PhysicalBone2D.xml | 0 .../skeleton_2d/doc_classes}/Skeleton2D.xml | 0 .../doc_classes}/SkeletonModification2D.xml | 0 .../SkeletonModification2DCCDIK.xml | 0 .../SkeletonModification2DFABRIK.xml | 0 .../SkeletonModification2DJiggle.xml | 0 .../SkeletonModification2DLookAt.xml | 0 .../SkeletonModification2DPhysicalBones.xml | 0 .../SkeletonModification2DStackHolder.xml | 0 .../SkeletonModification2DTwoBoneIK.xml | 0 .../editor}/skeleton_2d_editor_plugin.cpp | 4 +- .../editor}/skeleton_2d_editor_plugin.h | 1 + .../skeleton_2d}/icons/icon_skeleton_2d.svg | 0 .../skeleton_2d/nodes}/physical_bone_2d.cpp | 0 .../skeleton_2d/nodes}/physical_bone_2d.h | 2 +- .../skeleton_2d/nodes}/skeleton_2d.cpp | 4 +- .../skeleton_2d/nodes}/skeleton_2d.h | 3 +- modules/skeleton_2d/register_types.cpp | 44 +++++++++++++++++++ modules/skeleton_2d/register_types.h | 3 ++ .../resources/skeleton_modification_2d.cpp | 4 +- .../resources/skeleton_modification_2d.h | 0 .../skeleton_modification_2d_ccdik.cpp | 2 +- .../skeleton_modification_2d_ccdik.h | 2 +- .../skeleton_modification_2d_fabrik.cpp | 2 +- .../skeleton_modification_2d_fabrik.h | 2 +- .../skeleton_modification_2d_jiggle.cpp | 2 +- .../skeleton_modification_2d_jiggle.h | 2 +- .../skeleton_modification_2d_lookat.cpp | 2 +- .../skeleton_modification_2d_lookat.h | 2 +- ...skeleton_modification_2d_physicalbones.cpp | 4 +- .../skeleton_modification_2d_physicalbones.h | 2 +- .../skeleton_modification_2d_stackholder.cpp | 2 +- .../skeleton_modification_2d_stackholder.h | 2 +- .../skeleton_modification_2d_twoboneik.cpp | 2 +- .../skeleton_modification_2d_twoboneik.h | 2 +- .../skeleton_modification_stack_2d.cpp | 4 +- .../skeleton_modification_stack_2d.h | 0 scene/2d/joints_2d.h | 1 + scene/2d/polygon_2d.cpp | 11 ++++- scene/2d/polygon_2d.h | 1 + scene/animation/animation_player.cpp | 9 +++- scene/register_scene_types.cpp | 26 +---------- 48 files changed, 177 insertions(+), 67 deletions(-) create mode 100644 modules/skeleton_2d/.gitignore create mode 100644 modules/skeleton_2d/SCsub create mode 100644 modules/skeleton_2d/config.py rename {doc/classes => modules/skeleton_2d/doc_classes}/PhysicalBone2D.xml (100%) rename {doc/classes => modules/skeleton_2d/doc_classes}/Skeleton2D.xml (100%) rename {doc/classes => modules/skeleton_2d/doc_classes}/SkeletonModification2D.xml (100%) rename {doc/classes => modules/skeleton_2d/doc_classes}/SkeletonModification2DCCDIK.xml (100%) rename {doc/classes => modules/skeleton_2d/doc_classes}/SkeletonModification2DFABRIK.xml (100%) rename {doc/classes => modules/skeleton_2d/doc_classes}/SkeletonModification2DJiggle.xml (100%) rename {doc/classes => modules/skeleton_2d/doc_classes}/SkeletonModification2DLookAt.xml (100%) rename {doc/classes => modules/skeleton_2d/doc_classes}/SkeletonModification2DPhysicalBones.xml (100%) rename {doc/classes => modules/skeleton_2d/doc_classes}/SkeletonModification2DStackHolder.xml (100%) rename {doc/classes => modules/skeleton_2d/doc_classes}/SkeletonModification2DTwoBoneIK.xml (100%) rename {editor/plugins => modules/skeleton_2d/editor}/skeleton_2d_editor_plugin.cpp (98%) rename {editor/plugins => modules/skeleton_2d/editor}/skeleton_2d_editor_plugin.h (99%) rename {editor => modules/skeleton_2d}/icons/icon_skeleton_2d.svg (100%) rename {scene/2d => modules/skeleton_2d/nodes}/physical_bone_2d.cpp (100%) rename {scene/2d => modules/skeleton_2d/nodes}/physical_bone_2d.h (99%) rename {scene/2d => modules/skeleton_2d/nodes}/skeleton_2d.cpp (99%) rename {scene/2d => modules/skeleton_2d/nodes}/skeleton_2d.h (99%) create mode 100644 modules/skeleton_2d/register_types.cpp create mode 100644 modules/skeleton_2d/register_types.h rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d.cpp (99%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d.h (100%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_ccdik.cpp (99%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_ccdik.h (99%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_fabrik.cpp (99%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_fabrik.h (98%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_jiggle.cpp (99%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_jiggle.h (99%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_lookat.cpp (99%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_lookat.h (98%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_physicalbones.cpp (99%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_physicalbones.h (98%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_stackholder.cpp (99%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_stackholder.h (98%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_twoboneik.cpp (99%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_2d_twoboneik.h (98%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_stack_2d.cpp (99%) rename {scene => modules/skeleton_2d}/resources/skeleton_modification_stack_2d.h (100%) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 74ef413cd..9243fd192 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -137,7 +137,6 @@ #include "editor/plugins/script_editor_plugin.h" #include "editor/plugins/script_text_editor.h" #include "editor/plugins/shader_editor_plugin.h" -#include "editor/plugins/skeleton_2d_editor_plugin.h" #include "editor/plugins/skeleton_ik_editor_plugin.h" #include "editor/plugins/spatial_editor_plugin.h" #include "editor/plugins/sprite_editor_plugin.h" @@ -6800,7 +6799,6 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(AnimationTreeEditorPlugin(this))); add_editor_plugin(memnew(StyleBoxEditorPlugin(this))); add_editor_plugin(memnew(SpriteEditorPlugin(this))); - add_editor_plugin(memnew(Skeleton2DEditorPlugin(this))); add_editor_plugin(memnew(CPUParticles2DEditorPlugin(this))); add_editor_plugin(memnew(CPUParticlesEditorPlugin(this))); add_editor_plugin(memnew(ResourcePreloaderEditorPlugin(this))); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index ff5b547d6..f6bd2405c 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -30,6 +30,12 @@ #include "canvas_item_editor_plugin.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_SKELETON_2D_ENABLED +#include "modules/skeleton_2d/nodes/skeleton_2d.h" +#endif + #include "core/config/engine.h" #include "core/config/project_settings.h" #include "core/containers/pool_vector.h" @@ -62,7 +68,7 @@ #include "scene/2d/light_2d.h" #include "scene/2d/node_2d.h" #include "scene/2d/polygon_2d.h" -#include "scene/2d/skeleton_2d.h" + #include "scene/2d/sprite.h" #include "scene/2d/touch_screen_button.h" #include "scene/gui/base_button.h" @@ -3749,6 +3755,7 @@ void CanvasItemEditor::_notification(int p_what) { anchor_mode_button->set_visible(false); } +#ifdef MODULE_SKELETON_2D_ENABLED // Update the viewport if bones changes for (Map::Element *E = bone_list.front(); E; E = E->next()) { Object *b = ObjectDB::get_instance(E->key().from); @@ -3775,6 +3782,7 @@ void CanvasItemEditor::_notification(int p_what) { viewport->update(); } } +#endif } if (p_what == NOTIFICATION_ENTER_TREE) { @@ -4520,6 +4528,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { snap_dialog->popup_centered(Size2(220, 160) * EDSCALE); } break; case SKELETON_SHOW_BONES: { +#ifdef MODULE_SKELETON_2D_ENABLED List selection = editor_selection->get_selected_node_list(); for (List::Element *E = selection.front(); E; E = E->next()) { // Add children nodes so they are processed @@ -4533,6 +4542,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } bone_2d->_editor_set_show_bone_gizmo(!bone_2d->_editor_get_show_bone_gizmo()); } +#endif } break; case SHOW_HELPERS: { show_helpers = !show_helpers; @@ -4876,6 +4886,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; case SKELETON_MAKE_BONES: { +#ifdef MODULE_SKELETON_2D_ENABLED Map &selection = editor_selection->get_selection(); Node *editor_root = EditorNode::get_singleton()->get_edited_scene()->get_tree()->get_edited_scene_root(); @@ -4908,7 +4919,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { } undo_redo->commit_action(); - +#endif } break; } } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 359b534b6..8be63e820 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -30,27 +30,31 @@ #include "polygon_2d_editor_plugin.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_SKELETON_2D_ENABLED +#include "modules/skeleton_2d/nodes/skeleton_2d.h" +#endif + #include "canvas_item_editor_plugin.h" #include "core/input/input.h" -#include "core/os/keyboard.h" -#include "editor/editor_scale.h" -#include "editor/editor_settings.h" -#include "scene/2d/skeleton_2d.h" -#include "scene/gui/panel.h" -#include "core/object/class_db.h" +#include "core/input/input_event.h" #include "core/math/geometry.h" #include "core/math/math_defs.h" #include "core/math/math_funcs.h" #include "core/math/rect2.h" #include "core/math/transform_2d.h" -#include "core/string/node_path.h" -#include "core/input/input_event.h" -#include "core/os/memory.h" -#include "core/string/string_name.h" -#include "core/typedefs.h" +#include "core/object/class_db.h" #include "core/object/undo_redo.h" +#include "core/os/keyboard.h" +#include "core/os/memory.h" +#include "core/string/node_path.h" +#include "core/string/string_name.h" #include "core/string/ustring.h" +#include "core/typedefs.h" #include "core/variant/variant.h" +#include "editor/editor_scale.h" +#include "editor/editor_settings.h" #include "scene/2d/canvas_item.h" #include "scene/2d/polygon_2d.h" #include "scene/gui/box_container.h" @@ -60,6 +64,7 @@ #include "scene/gui/dialogs.h" #include "scene/gui/label.h" #include "scene/gui/menu_button.h" +#include "scene/gui/panel.h" #include "scene/gui/popup_menu.h" #include "scene/gui/scroll_bar.h" #include "scene/gui/scroll_container.h" @@ -135,6 +140,7 @@ void Polygon2DEditor::_notification(int p_what) { } void Polygon2DEditor::_sync_bones() { +#ifdef MODULE_SKELETON_2D_ENABLED Skeleton2D *skeleton = nullptr; if (!node->has_node(node->get_skeleton())) { error->set_text(TTR("The skeleton property of the Polygon2D does not point to a Skeleton2D node")); @@ -186,6 +192,7 @@ void Polygon2DEditor::_sync_bones() { undo_redo->add_do_method(uv_edit_draw, "update"); undo_redo->add_undo_method(uv_edit_draw, "update"); undo_redo->commit_action(); +#endif } void Polygon2DEditor::_update_bone_list() { @@ -1139,6 +1146,7 @@ void Polygon2DEditor::_uv_draw() { } } +#ifdef MODULE_SKELETON_2D_ENABLED if (uv_mode == UV_MODE_PAINT_WEIGHT || uv_mode == UV_MODE_CLEAR_WEIGHT) { NodePath bone_path; for (int i = 0; i < bone_scroll_vb->get_child_count(); i++) { @@ -1196,6 +1204,7 @@ void Polygon2DEditor::_uv_draw() { //draw paint circle uv_edit_draw->draw_circle(bone_paint_pos, bone_paint_radius->get_value() * EDSCALE, Color(1, 1, 1, 0.1)); } +#endif rect.position -= uv_edit_draw->get_size(); rect.size += uv_edit_draw->get_size() * 2.0; diff --git a/modules/skeleton_2d/.gitignore b/modules/skeleton_2d/.gitignore new file mode 100644 index 000000000..e795fbef5 --- /dev/null +++ b/modules/skeleton_2d/.gitignore @@ -0,0 +1,7 @@ +.import +*.d +*.o +*.meta +*.obj +*.pyc +*.bc diff --git a/modules/skeleton_2d/SCsub b/modules/skeleton_2d/SCsub new file mode 100644 index 000000000..4355250d2 --- /dev/null +++ b/modules/skeleton_2d/SCsub @@ -0,0 +1,24 @@ +import os + +Import('env') + +module_env = env.Clone() + +module_env.add_source_files(env.modules_sources,"register_types.cpp") + +module_env.add_source_files(env.modules_sources,"nodes/skeleton_2d.cpp") +module_env.add_source_files(env.modules_sources,"nodes/physical_bone_2d.cpp") + + +module_env.add_source_files(env.modules_sources,"resources/skeleton_modification_2d.cpp") +module_env.add_source_files(env.modules_sources,"resources/skeleton_modification_2d_ccdik.cpp") +module_env.add_source_files(env.modules_sources,"resources/skeleton_modification_2d_fabrik.cpp") +module_env.add_source_files(env.modules_sources,"resources/skeleton_modification_2d_jiggle.cpp") +module_env.add_source_files(env.modules_sources,"resources/skeleton_modification_2d_lookat.cpp") +module_env.add_source_files(env.modules_sources,"resources/skeleton_modification_2d_physicalbones.cpp") +module_env.add_source_files(env.modules_sources,"resources/skeleton_modification_2d_stackholder.cpp") +module_env.add_source_files(env.modules_sources,"resources/skeleton_modification_2d_twoboneik.cpp") +module_env.add_source_files(env.modules_sources,"resources/skeleton_modification_stack_2d.cpp") + +if env["tools"]: + module_env.add_source_files(env.modules_sources,"editor/skeleton_2d_editor_plugin.cpp") diff --git a/modules/skeleton_2d/config.py b/modules/skeleton_2d/config.py new file mode 100644 index 000000000..62728a796 --- /dev/null +++ b/modules/skeleton_2d/config.py @@ -0,0 +1,18 @@ + + +def can_build(env, platform): + return True + + +def configure(env): + pass + + +def get_doc_classes(): + return [ + "Skeleton2D", + "PhysicalBone2D", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/doc/classes/PhysicalBone2D.xml b/modules/skeleton_2d/doc_classes/PhysicalBone2D.xml similarity index 100% rename from doc/classes/PhysicalBone2D.xml rename to modules/skeleton_2d/doc_classes/PhysicalBone2D.xml diff --git a/doc/classes/Skeleton2D.xml b/modules/skeleton_2d/doc_classes/Skeleton2D.xml similarity index 100% rename from doc/classes/Skeleton2D.xml rename to modules/skeleton_2d/doc_classes/Skeleton2D.xml diff --git a/doc/classes/SkeletonModification2D.xml b/modules/skeleton_2d/doc_classes/SkeletonModification2D.xml similarity index 100% rename from doc/classes/SkeletonModification2D.xml rename to modules/skeleton_2d/doc_classes/SkeletonModification2D.xml diff --git a/doc/classes/SkeletonModification2DCCDIK.xml b/modules/skeleton_2d/doc_classes/SkeletonModification2DCCDIK.xml similarity index 100% rename from doc/classes/SkeletonModification2DCCDIK.xml rename to modules/skeleton_2d/doc_classes/SkeletonModification2DCCDIK.xml diff --git a/doc/classes/SkeletonModification2DFABRIK.xml b/modules/skeleton_2d/doc_classes/SkeletonModification2DFABRIK.xml similarity index 100% rename from doc/classes/SkeletonModification2DFABRIK.xml rename to modules/skeleton_2d/doc_classes/SkeletonModification2DFABRIK.xml diff --git a/doc/classes/SkeletonModification2DJiggle.xml b/modules/skeleton_2d/doc_classes/SkeletonModification2DJiggle.xml similarity index 100% rename from doc/classes/SkeletonModification2DJiggle.xml rename to modules/skeleton_2d/doc_classes/SkeletonModification2DJiggle.xml diff --git a/doc/classes/SkeletonModification2DLookAt.xml b/modules/skeleton_2d/doc_classes/SkeletonModification2DLookAt.xml similarity index 100% rename from doc/classes/SkeletonModification2DLookAt.xml rename to modules/skeleton_2d/doc_classes/SkeletonModification2DLookAt.xml diff --git a/doc/classes/SkeletonModification2DPhysicalBones.xml b/modules/skeleton_2d/doc_classes/SkeletonModification2DPhysicalBones.xml similarity index 100% rename from doc/classes/SkeletonModification2DPhysicalBones.xml rename to modules/skeleton_2d/doc_classes/SkeletonModification2DPhysicalBones.xml diff --git a/doc/classes/SkeletonModification2DStackHolder.xml b/modules/skeleton_2d/doc_classes/SkeletonModification2DStackHolder.xml similarity index 100% rename from doc/classes/SkeletonModification2DStackHolder.xml rename to modules/skeleton_2d/doc_classes/SkeletonModification2DStackHolder.xml diff --git a/doc/classes/SkeletonModification2DTwoBoneIK.xml b/modules/skeleton_2d/doc_classes/SkeletonModification2DTwoBoneIK.xml similarity index 100% rename from doc/classes/SkeletonModification2DTwoBoneIK.xml rename to modules/skeleton_2d/doc_classes/SkeletonModification2DTwoBoneIK.xml diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/modules/skeleton_2d/editor/skeleton_2d_editor_plugin.cpp similarity index 98% rename from editor/plugins/skeleton_2d_editor_plugin.cpp rename to modules/skeleton_2d/editor/skeleton_2d_editor_plugin.cpp index b9e4ba07a..265ffd6f6 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.cpp +++ b/modules/skeleton_2d/editor/skeleton_2d_editor_plugin.cpp @@ -30,12 +30,12 @@ #include "skeleton_2d_editor_plugin.h" -#include "canvas_item_editor_plugin.h" +#include "editor/plugins/canvas_item_editor_plugin.h" #include "core/object/class_db.h" #include "core/os/memory.h" #include "core/object/undo_redo.h" #include "editor/editor_node.h" -#include "scene/2d/skeleton_2d.h" +#include "../nodes/skeleton_2d.h" #include "scene/gui/dialogs.h" #include "scene/gui/menu_button.h" #include "scene/gui/popup_menu.h" diff --git a/editor/plugins/skeleton_2d_editor_plugin.h b/modules/skeleton_2d/editor/skeleton_2d_editor_plugin.h similarity index 99% rename from editor/plugins/skeleton_2d_editor_plugin.h rename to modules/skeleton_2d/editor/skeleton_2d_editor_plugin.h index 44da4dd89..2545818e0 100644 --- a/editor/plugins/skeleton_2d_editor_plugin.h +++ b/modules/skeleton_2d/editor/skeleton_2d_editor_plugin.h @@ -1,5 +1,6 @@ #ifndef SKELETON_2D_EDITOR_PLUGIN_H #define SKELETON_2D_EDITOR_PLUGIN_H + /*************************************************************************/ /* skeleton_2d_editor_plugin.h */ /*************************************************************************/ diff --git a/editor/icons/icon_skeleton_2d.svg b/modules/skeleton_2d/icons/icon_skeleton_2d.svg similarity index 100% rename from editor/icons/icon_skeleton_2d.svg rename to modules/skeleton_2d/icons/icon_skeleton_2d.svg diff --git a/scene/2d/physical_bone_2d.cpp b/modules/skeleton_2d/nodes/physical_bone_2d.cpp similarity index 100% rename from scene/2d/physical_bone_2d.cpp rename to modules/skeleton_2d/nodes/physical_bone_2d.cpp diff --git a/scene/2d/physical_bone_2d.h b/modules/skeleton_2d/nodes/physical_bone_2d.h similarity index 99% rename from scene/2d/physical_bone_2d.h rename to modules/skeleton_2d/nodes/physical_bone_2d.h index 7417d972f..c53bbb868 100644 --- a/scene/2d/physical_bone_2d.h +++ b/modules/skeleton_2d/nodes/physical_bone_2d.h @@ -32,7 +32,7 @@ #define PHYSICAL_BONE_2D_H #include "scene/2d/physics_body_2d.h" -#include "scene/2d/skeleton_2d.h" +#include "skeleton_2d.h" class Joint2D; diff --git a/scene/2d/skeleton_2d.cpp b/modules/skeleton_2d/nodes/skeleton_2d.cpp similarity index 99% rename from scene/2d/skeleton_2d.cpp rename to modules/skeleton_2d/nodes/skeleton_2d.cpp index e33554764..190291c24 100644 --- a/scene/2d/skeleton_2d.cpp +++ b/modules/skeleton_2d/nodes/skeleton_2d.cpp @@ -30,8 +30,8 @@ #include "skeleton_2d.h" -#include "scene/resources/skeleton_modification_2d.h" -#include "scene/resources/skeleton_modification_stack_2d.h" +#include "../resources/skeleton_modification_2d.h" +#include "../resources/skeleton_modification_stack_2d.h" #include "core/config/engine.h" #ifdef TOOLS_ENABLED diff --git a/scene/2d/skeleton_2d.h b/modules/skeleton_2d/nodes/skeleton_2d.h similarity index 99% rename from scene/2d/skeleton_2d.h rename to modules/skeleton_2d/nodes/skeleton_2d.h index aceb22a93..30c4bb2d9 100644 --- a/scene/2d/skeleton_2d.h +++ b/modules/skeleton_2d/nodes/skeleton_2d.h @@ -1,5 +1,6 @@ #ifndef SKELETON_2D_H #define SKELETON_2D_H + /*************************************************************************/ /* skeleton_2d.h */ /*************************************************************************/ @@ -31,7 +32,7 @@ /*************************************************************************/ #include "scene/2d/node_2d.h" -#include "scene/resources/skeleton_modification_2d.h" +#include "../resources/skeleton_modification_2d.h" class Skeleton2D; diff --git a/modules/skeleton_2d/register_types.cpp b/modules/skeleton_2d/register_types.cpp new file mode 100644 index 000000000..4fb5e65d9 --- /dev/null +++ b/modules/skeleton_2d/register_types.cpp @@ -0,0 +1,44 @@ + +#include "register_types.h" + +#include "nodes/physical_bone_2d.h" +#include "nodes/skeleton_2d.h" + +#include "resources/skeleton_modification_2d.h" +#include "resources/skeleton_modification_2d_ccdik.h" +#include "resources/skeleton_modification_2d_fabrik.h" +#include "resources/skeleton_modification_2d_jiggle.h" +#include "resources/skeleton_modification_2d_lookat.h" +#include "resources/skeleton_modification_2d_physicalbones.h" +#include "resources/skeleton_modification_2d_stackholder.h" +#include "resources/skeleton_modification_2d_twoboneik.h" +#include "resources/skeleton_modification_stack_2d.h" + +#ifdef TOOLS_ENABLED +#include "editor/skeleton_2d_editor_plugin.h" +#endif + +void register_skeleton_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(); + +#ifdef TOOLS_ENABLED + EditorPlugins::add_by_type(); +#endif +} + +void unregister_skeleton_2d_types() { +} diff --git a/modules/skeleton_2d/register_types.h b/modules/skeleton_2d/register_types.h new file mode 100644 index 000000000..048dfcd85 --- /dev/null +++ b/modules/skeleton_2d/register_types.h @@ -0,0 +1,3 @@ + +void register_skeleton_2d_types(); +void unregister_skeleton_2d_types(); diff --git a/scene/resources/skeleton_modification_2d.cpp b/modules/skeleton_2d/resources/skeleton_modification_2d.cpp similarity index 99% rename from scene/resources/skeleton_modification_2d.cpp rename to modules/skeleton_2d/resources/skeleton_modification_2d.cpp index c3d2aa58a..945b211ad 100644 --- a/scene/resources/skeleton_modification_2d.cpp +++ b/modules/skeleton_2d/resources/skeleton_modification_2d.cpp @@ -29,12 +29,12 @@ /*************************************************************************/ #include "skeleton_modification_2d.h" -#include "scene/2d/skeleton_2d.h" +#include "../nodes/skeleton_2d.h" #include "core/config/engine.h" #include "scene/2d/collision_object_2d.h" #include "scene/2d/collision_shape_2d.h" -#include "scene/2d/physical_bone_2d.h" +#include "../nodes/physical_bone_2d.h" #include "skeleton_modification_stack_2d.h" diff --git a/scene/resources/skeleton_modification_2d.h b/modules/skeleton_2d/resources/skeleton_modification_2d.h similarity index 100% rename from scene/resources/skeleton_modification_2d.h rename to modules/skeleton_2d/resources/skeleton_modification_2d.h diff --git a/scene/resources/skeleton_modification_2d_ccdik.cpp b/modules/skeleton_2d/resources/skeleton_modification_2d_ccdik.cpp similarity index 99% rename from scene/resources/skeleton_modification_2d_ccdik.cpp rename to modules/skeleton_2d/resources/skeleton_modification_2d_ccdik.cpp index 614234192..2220f88f2 100644 --- a/scene/resources/skeleton_modification_2d_ccdik.cpp +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_ccdik.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "skeleton_modification_2d_ccdik.h" -#include "scene/2d/skeleton_2d.h" +#include "../nodes/skeleton_2d.h" #include "skeleton_modification_stack_2d.h" #include "scene/2d/node_2d.h" #include "core/config/engine.h" diff --git a/scene/resources/skeleton_modification_2d_ccdik.h b/modules/skeleton_2d/resources/skeleton_modification_2d_ccdik.h similarity index 99% rename from scene/resources/skeleton_modification_2d_ccdik.h rename to modules/skeleton_2d/resources/skeleton_modification_2d_ccdik.h index f9c8c5ea1..10ee5f11f 100644 --- a/scene/resources/skeleton_modification_2d_ccdik.h +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_ccdik.h @@ -31,7 +31,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "scene/resources/skeleton_modification_2d.h" +#include "skeleton_modification_2d.h" /////////////////////////////////////// // SkeletonModification2DCCDIK diff --git a/scene/resources/skeleton_modification_2d_fabrik.cpp b/modules/skeleton_2d/resources/skeleton_modification_2d_fabrik.cpp similarity index 99% rename from scene/resources/skeleton_modification_2d_fabrik.cpp rename to modules/skeleton_2d/resources/skeleton_modification_2d_fabrik.cpp index ee0f1a280..e92e46813 100644 --- a/scene/resources/skeleton_modification_2d_fabrik.cpp +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_fabrik.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "skeleton_modification_2d_fabrik.h" -#include "scene/2d/skeleton_2d.h" +#include "../nodes/skeleton_2d.h" #include "skeleton_modification_stack_2d.h" #ifdef TOOLS_ENABLED diff --git a/scene/resources/skeleton_modification_2d_fabrik.h b/modules/skeleton_2d/resources/skeleton_modification_2d_fabrik.h similarity index 98% rename from scene/resources/skeleton_modification_2d_fabrik.h rename to modules/skeleton_2d/resources/skeleton_modification_2d_fabrik.h index 938e9629f..48436455f 100644 --- a/scene/resources/skeleton_modification_2d_fabrik.h +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_fabrik.h @@ -31,7 +31,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "scene/resources/skeleton_modification_2d.h" +#include "skeleton_modification_2d.h" /////////////////////////////////////// // SkeletonModification2DFABRIK diff --git a/scene/resources/skeleton_modification_2d_jiggle.cpp b/modules/skeleton_2d/resources/skeleton_modification_2d_jiggle.cpp similarity index 99% rename from scene/resources/skeleton_modification_2d_jiggle.cpp rename to modules/skeleton_2d/resources/skeleton_modification_2d_jiggle.cpp index ca9a95c4a..206907ec4 100644 --- a/scene/resources/skeleton_modification_2d_jiggle.cpp +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_jiggle.cpp @@ -31,7 +31,7 @@ #include "skeleton_modification_2d_jiggle.h" #include "scene/2d/node_2d.h" -#include "scene/2d/skeleton_2d.h" +#include "../nodes/skeleton_2d.h" #include "scene/resources/world_2d.h" #include "skeleton_modification_stack_2d.h" diff --git a/scene/resources/skeleton_modification_2d_jiggle.h b/modules/skeleton_2d/resources/skeleton_modification_2d_jiggle.h similarity index 99% rename from scene/resources/skeleton_modification_2d_jiggle.h rename to modules/skeleton_2d/resources/skeleton_modification_2d_jiggle.h index ffaa679a3..6c0d87b89 100644 --- a/scene/resources/skeleton_modification_2d_jiggle.h +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_jiggle.h @@ -31,7 +31,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "scene/resources/skeleton_modification_2d.h" +#include "skeleton_modification_2d.h" /////////////////////////////////////// // SkeletonModification2DJIGGLE diff --git a/scene/resources/skeleton_modification_2d_lookat.cpp b/modules/skeleton_2d/resources/skeleton_modification_2d_lookat.cpp similarity index 99% rename from scene/resources/skeleton_modification_2d_lookat.cpp rename to modules/skeleton_2d/resources/skeleton_modification_2d_lookat.cpp index c5f359db5..164e4b22a 100644 --- a/scene/resources/skeleton_modification_2d_lookat.cpp +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_lookat.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "skeleton_modification_2d_lookat.h" -#include "scene/2d/skeleton_2d.h" +#include "../nodes/skeleton_2d.h" #include "skeleton_modification_stack_2d.h" #include "core/config/engine.h" diff --git a/scene/resources/skeleton_modification_2d_lookat.h b/modules/skeleton_2d/resources/skeleton_modification_2d_lookat.h similarity index 98% rename from scene/resources/skeleton_modification_2d_lookat.h rename to modules/skeleton_2d/resources/skeleton_modification_2d_lookat.h index fbbd094f0..e30495ac9 100644 --- a/scene/resources/skeleton_modification_2d_lookat.h +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_lookat.h @@ -31,7 +31,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "scene/resources/skeleton_modification_2d.h" +#include "skeleton_modification_2d.h" /////////////////////////////////////// // SkeletonModification2DLookAt diff --git a/scene/resources/skeleton_modification_2d_physicalbones.cpp b/modules/skeleton_2d/resources/skeleton_modification_2d_physicalbones.cpp similarity index 99% rename from scene/resources/skeleton_modification_2d_physicalbones.cpp rename to modules/skeleton_2d/resources/skeleton_modification_2d_physicalbones.cpp index df7a58bd4..ac3527781 100644 --- a/scene/resources/skeleton_modification_2d_physicalbones.cpp +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_physicalbones.cpp @@ -29,8 +29,8 @@ /*************************************************************************/ #include "skeleton_modification_2d_physicalbones.h" -#include "scene/2d/physical_bone_2d.h" -#include "scene/2d/skeleton_2d.h" +#include "../nodes/physical_bone_2d.h" +#include "../nodes/skeleton_2d.h" #include "skeleton_modification_stack_2d.h" #include "core/config/engine.h" diff --git a/scene/resources/skeleton_modification_2d_physicalbones.h b/modules/skeleton_2d/resources/skeleton_modification_2d_physicalbones.h similarity index 98% rename from scene/resources/skeleton_modification_2d_physicalbones.h rename to modules/skeleton_2d/resources/skeleton_modification_2d_physicalbones.h index 13d3174ab..a53aaf88a 100644 --- a/scene/resources/skeleton_modification_2d_physicalbones.h +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_physicalbones.h @@ -35,7 +35,7 @@ #include "core/containers/vector.h" #include "core/object/object_id.h" -#include "scene/resources/skeleton_modification_2d.h" +#include "skeleton_modification_2d.h" /////////////////////////////////////// // SkeletonModification2DJIGGLE diff --git a/scene/resources/skeleton_modification_2d_stackholder.cpp b/modules/skeleton_2d/resources/skeleton_modification_2d_stackholder.cpp similarity index 99% rename from scene/resources/skeleton_modification_2d_stackholder.cpp rename to modules/skeleton_2d/resources/skeleton_modification_2d_stackholder.cpp index b7e25a238..e1ef05570 100644 --- a/scene/resources/skeleton_modification_2d_stackholder.cpp +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_stackholder.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "skeleton_modification_2d_stackholder.h" -#include "scene/2d/skeleton_2d.h" +#include "../nodes/skeleton_2d.h" #include "skeleton_modification_stack_2d.h" #include "core/config/engine.h" diff --git a/scene/resources/skeleton_modification_2d_stackholder.h b/modules/skeleton_2d/resources/skeleton_modification_2d_stackholder.h similarity index 98% rename from scene/resources/skeleton_modification_2d_stackholder.h rename to modules/skeleton_2d/resources/skeleton_modification_2d_stackholder.h index 886e24850..d462ed4df 100644 --- a/scene/resources/skeleton_modification_2d_stackholder.h +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_stackholder.h @@ -31,7 +31,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "scene/resources/skeleton_modification_2d.h" +#include "skeleton_modification_2d.h" /////////////////////////////////////// // SkeletonModification2DJIGGLE diff --git a/scene/resources/skeleton_modification_2d_twoboneik.cpp b/modules/skeleton_2d/resources/skeleton_modification_2d_twoboneik.cpp similarity index 99% rename from scene/resources/skeleton_modification_2d_twoboneik.cpp rename to modules/skeleton_2d/resources/skeleton_modification_2d_twoboneik.cpp index 77e740580..83caffcf5 100644 --- a/scene/resources/skeleton_modification_2d_twoboneik.cpp +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_twoboneik.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "skeleton_modification_2d_twoboneik.h" -#include "scene/2d/skeleton_2d.h" +#include "../nodes/skeleton_2d.h" #include "skeleton_modification_stack_2d.h" #include "core/config/engine.h" diff --git a/scene/resources/skeleton_modification_2d_twoboneik.h b/modules/skeleton_2d/resources/skeleton_modification_2d_twoboneik.h similarity index 98% rename from scene/resources/skeleton_modification_2d_twoboneik.h rename to modules/skeleton_2d/resources/skeleton_modification_2d_twoboneik.h index 4fe9a4c8f..d89bccf91 100644 --- a/scene/resources/skeleton_modification_2d_twoboneik.h +++ b/modules/skeleton_2d/resources/skeleton_modification_2d_twoboneik.h @@ -31,7 +31,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "scene/resources/skeleton_modification_2d.h" +#include "skeleton_modification_2d.h" /////////////////////////////////////// // SkeletonModification2DJIGGLE diff --git a/scene/resources/skeleton_modification_stack_2d.cpp b/modules/skeleton_2d/resources/skeleton_modification_stack_2d.cpp similarity index 99% rename from scene/resources/skeleton_modification_stack_2d.cpp rename to modules/skeleton_2d/resources/skeleton_modification_stack_2d.cpp index fe1867611..366d47219 100644 --- a/scene/resources/skeleton_modification_stack_2d.cpp +++ b/modules/skeleton_2d/resources/skeleton_modification_stack_2d.cpp @@ -29,8 +29,8 @@ /*************************************************************************/ #include "skeleton_modification_stack_2d.h" -#include "scene/2d/skeleton_2d.h" -#include "scene/resources/skeleton_modification_2d.h" +#include "../nodes/skeleton_2d.h" +#include "skeleton_modification_2d.h" void SkeletonModificationStack2D::_get_property_list(List *p_list) const { for (int i = 0; i < modifications.size(); i++) { diff --git a/scene/resources/skeleton_modification_stack_2d.h b/modules/skeleton_2d/resources/skeleton_modification_stack_2d.h similarity index 100% rename from scene/resources/skeleton_modification_stack_2d.h rename to modules/skeleton_2d/resources/skeleton_modification_stack_2d.h diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h index d29caef5f..f2f7f0900 100644 --- a/scene/2d/joints_2d.h +++ b/scene/2d/joints_2d.h @@ -1,5 +1,6 @@ #ifndef JOINTS_2D_H #define JOINTS_2D_H + /*************************************************************************/ /* joints_2d.h */ /*************************************************************************/ diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 82ed287af..b3b9631a3 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -31,7 +31,12 @@ #include "polygon_2d.h" #include "core/math/geometry.h" -#include "skeleton_2d.h" + +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_SKELETON_2D_ENABLED +#include "modules/skeleton_2d/nodes/skeleton_2d.h" +#endif #ifdef TOOLS_ENABLED Dictionary Polygon2D::_edit_get_state() const { @@ -101,6 +106,7 @@ void Polygon2D::_notification(int p_what) { return; } +#ifdef MODULE_SKELETON_2D_ENABLED Skeleton2D *skeleton_node = nullptr; if (has_node(skeleton)) { skeleton_node = Object::cast_to(get_node(skeleton)); @@ -127,6 +133,7 @@ void Polygon2D::_notification(int p_what) { current_skeleton_id = new_skeleton_id; } +#endif Vector points; Vector uvs; @@ -223,6 +230,7 @@ void Polygon2D::_notification(int p_what) { } } +#ifdef MODULE_SKELETON_2D_ENABLED if (skeleton_node && !invert && bone_weights.size()) { //a skeleton is set! fill indices and weights int vc = len; @@ -287,6 +295,7 @@ void Polygon2D::_notification(int p_what) { } } } +#endif Vector colors; if (vertex_colors.size() == points.size()) { diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index f5c0bee94..3205d46c6 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -1,5 +1,6 @@ #ifndef POLYGON_2D_H #define POLYGON_2D_H + /*************************************************************************/ /* polygon_2d.h */ /*************************************************************************/ diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 804021e33..632b43ab8 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -42,7 +42,12 @@ #ifdef TOOLS_ENABLED #include "editor/editor_node.h" #include "editor/editor_settings.h" -#include "scene/2d/skeleton_2d.h" + +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_SKELETON_2D_ENABLED +#include "modules/skeleton_2d/nodes/skeleton_2d.h" +#endif void AnimatedValuesBackup::update_skeletons() { for (int i = 0; i < entries.size(); i++) { @@ -50,11 +55,13 @@ void AnimatedValuesBackup::update_skeletons() { // 3D bone Object::cast_to(entries[i].object)->notification(Skeleton::NOTIFICATION_UPDATE_SKELETON); } else { +#ifdef MODULE_SKELETON_2D_ENABLED Bone2D *bone = Object::cast_to(entries[i].object); if (bone && bone->skeleton) { // 2D bone bone->skeleton->_update_transform(); } +#endif } } } diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 0b65383b1..5acec288d 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -58,14 +58,12 @@ #include "scene/2d/parallax_background.h" #include "scene/2d/parallax_layer.h" #include "scene/2d/path_2d.h" -#include "scene/2d/physical_bone_2d.h" #include "scene/2d/physics_body_2d.h" #include "scene/2d/polygon_2d.h" #include "scene/2d/position_2d.h" #include "scene/2d/ray_cast_2d.h" #include "scene/2d/remote_transform_2d.h" #include "scene/2d/shape_cast_2d.h" -#include "scene/2d/skeleton_2d.h" #include "scene/2d/sprite.h" #include "scene/2d/touch_screen_button.h" #include "scene/2d/visibility_notifier_2d.h" @@ -167,15 +165,7 @@ #include "scene/resources/rectangle_shape_2d.h" #include "scene/resources/resource_format_text.h" #include "scene/resources/segment_shape_2d.h" -#include "scene/resources/skeleton_modification_2d.h" -#include "scene/resources/skeleton_modification_2d_ccdik.h" -#include "scene/resources/skeleton_modification_2d_fabrik.h" -#include "scene/resources/skeleton_modification_2d_jiggle.h" -#include "scene/resources/skeleton_modification_2d_lookat.h" -#include "scene/resources/skeleton_modification_2d_physicalbones.h" -#include "scene/resources/skeleton_modification_2d_stackholder.h" -#include "scene/resources/skeleton_modification_2d_twoboneik.h" -#include "scene/resources/skeleton_modification_stack_2d.h" + #include "scene/resources/skin.h" #include "scene/resources/sky.h" #include "scene/resources/sphere_shape.h" @@ -558,8 +548,6 @@ void register_scene_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(); @@ -579,18 +567,6 @@ void register_scene_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(); - OS::get_singleton()->yield(); //may take time to init /* REGISTER RESOURCES */