From 4326314fd1b1cfb05b9b2a3ea6ea71345bdaa667 Mon Sep 17 00:00:00 2001 From: badlogic Date: Sat, 30 Apr 2022 14:59:16 +0200 Subject: [PATCH] [godot] pragma once, clean-up SpineSlotNode, add SpineBoneNode + example --- .../examples/11-bone-node/bone-node.gd | 5 + .../examples/11-bone-node/bone-node.tscn | 19 +++ spine-godot/spine_godot/GodotSpineExtension.h | 6 +- spine-godot/spine_godot/SpineAnimation.h | 5 +- spine-godot/spine_godot/SpineAnimationState.h | 5 +- spine-godot/spine_godot/SpineAnimationTrack.h | 5 +- spine-godot/spine_godot/SpineAtlasResource.h | 7 +- spine-godot/spine_godot/SpineAttachment.h | 5 +- spine-godot/spine_godot/SpineBone.h | 5 +- spine-godot/spine_godot/SpineBoneData.h | 5 +- spine-godot/spine_godot/SpineBoneNode.cpp | 151 ++++++++++++++++++ spine-godot/spine_godot/SpineBoneNode.h | 62 +++++++ spine-godot/spine_godot/SpineConstant.cpp | 7 + spine-godot/spine_godot/SpineConstant.h | 18 ++- spine-godot/spine_godot/SpineConstraintData.h | 5 +- spine-godot/spine_godot/SpineEditorPlugin.h | 5 +- spine-godot/spine_godot/SpineEvent.h | 5 +- spine-godot/spine_godot/SpineEventData.h | 5 +- spine-godot/spine_godot/SpineIkConstraint.h | 5 +- .../spine_godot/SpineIkConstraintData.h | 5 +- spine-godot/spine_godot/SpinePathConstraint.h | 5 +- .../spine_godot/SpinePathConstraintData.h | 4 +- spine-godot/spine_godot/SpineSkeleton.h | 7 +- .../spine_godot/SpineSkeletonDataResource.cpp | 10 ++ .../spine_godot/SpineSkeletonDataResource.h | 8 +- .../spine_godot/SpineSkeletonFileResource.h | 5 +- spine-godot/spine_godot/SpineSkin.h | 5 +- spine-godot/spine_godot/SpineSlot.h | 5 +- spine-godot/spine_godot/SpineSlotData.h | 5 +- spine-godot/spine_godot/SpineSlotNode.cpp | 46 +++++- spine-godot/spine_godot/SpineSlotNode.h | 35 +++- spine-godot/spine_godot/SpineSprite.cpp | 26 ++- spine-godot/spine_godot/SpineSprite.h | 19 +-- spine-godot/spine_godot/SpineTimeline.h | 5 +- spine-godot/spine_godot/SpineTrackEntry.h | 5 +- .../spine_godot/SpineTransformConstraint.h | 5 +- .../SpineTransformConstraintData.h | 5 +- spine-godot/spine_godot/register_types.cpp | 2 + spine-godot/spine_godot/register_types.h | 2 + 39 files changed, 386 insertions(+), 153 deletions(-) create mode 100644 spine-godot/example/examples/11-bone-node/bone-node.gd create mode 100644 spine-godot/example/examples/11-bone-node/bone-node.tscn create mode 100644 spine-godot/spine_godot/SpineBoneNode.cpp create mode 100644 spine-godot/spine_godot/SpineBoneNode.h diff --git a/spine-godot/example/examples/11-bone-node/bone-node.gd b/spine-godot/example/examples/11-bone-node/bone-node.gd new file mode 100644 index 000000000..e2cf328ce --- /dev/null +++ b/spine-godot/example/examples/11-bone-node/bone-node.gd @@ -0,0 +1,5 @@ +extends Node2D + +func _ready(): + $SpineSprite.get_animation_state().set_animation("hoverboard", true, 0) + pass diff --git a/spine-godot/example/examples/11-bone-node/bone-node.tscn b/spine-godot/example/examples/11-bone-node/bone-node.tscn new file mode 100644 index 000000000..4233e2b39 --- /dev/null +++ b/spine-godot/example/examples/11-bone-node/bone-node.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://examples/11-bone-node/bone-node.gd" type="Script" id=1] +[ext_resource path="res://assets/spineboy/spineboy-data-res.tres" type="SpineSkeletonDataResource" id=2] + +[node name="Node2D" type="Node2D"] +script = ExtResource( 1 ) + +[node name="SpineSprite" type="SpineSprite" parent="."] +position = Vector2( 461, 491 ) +scale = Vector2( 0.479082, 0.479082 ) +skeleton_data_res = ExtResource( 2 ) + +[node name="SpineBoneNode" type="SpineBoneNode" parent="SpineSprite"] +position = Vector2( -329.751, -69.5322 ) +rotation = 0.00281584 +scale = Vector2( 1, 1 ) +bone_name = "hoverboard-controller" +bone_mode = 1 diff --git a/spine-godot/spine_godot/GodotSpineExtension.h b/spine-godot/spine_godot/GodotSpineExtension.h index f314d04e1..0d7a3e861 100644 --- a/spine-godot/spine_godot/GodotSpineExtension.h +++ b/spine-godot/spine_godot/GodotSpineExtension.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEEXTENSION_H -#define GODOT_SPINEEXTENSION_H +#pragma once #include @@ -44,6 +43,3 @@ protected: virtual char *_readFile(const spine::String &path, int *length); }; - - -#endif//GODOT_SPINEEXTENSION_H diff --git a/spine-godot/spine_godot/SpineAnimation.h b/spine-godot/spine_godot/SpineAnimation.h index 3ba29b22c..3a04c73c3 100644 --- a/spine-godot/spine_godot/SpineAnimation.h +++ b/spine-godot/spine_godot/SpineAnimation.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEANIMATION_H -#define GODOT_SPINEANIMATION_H +#pragma once #include "SpineCommon.h" #include "SpineConstant.h" @@ -58,5 +57,3 @@ public: void set_duration(float duration); }; - -#endif//GODOT_SPINEANIMATION_H diff --git a/spine-godot/spine_godot/SpineAnimationState.h b/spine-godot/spine_godot/SpineAnimationState.h index 0bab49395..ea5005b34 100644 --- a/spine-godot/spine_godot/SpineAnimationState.h +++ b/spine-godot/spine_godot/SpineAnimationState.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEANIMATIONSTATE_H -#define GODOT_SPINEANIMATIONSTATE_H +#pragma once #include "SpineCommon.h" #include "SpineSkeleton.h" @@ -81,5 +80,3 @@ public: void enable_queue(); }; - -#endif//GODOT_SPINEANIMATIONSTATE_H diff --git a/spine-godot/spine_godot/SpineAnimationTrack.h b/spine-godot/spine_godot/SpineAnimationTrack.h index f4c1d94a2..1a5048add 100644 --- a/spine-godot/spine_godot/SpineAnimationTrack.h +++ b/spine-godot/spine_godot/SpineAnimationTrack.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEANIMATIONTRACK_H -#define GODOT_SPINEANIMATIONTRACK_H +#pragma once #include "SpineSprite.h" #include "scene/animation/animation_player.h" @@ -129,5 +128,3 @@ public: bool get_debug(); }; - -#endif diff --git a/spine-godot/spine_godot/SpineAtlasResource.h b/spine-godot/spine_godot/SpineAtlasResource.h index f63818e84..ddc28ebdf 100644 --- a/spine-godot/spine_godot/SpineAtlasResource.h +++ b/spine-godot/spine_godot/SpineAtlasResource.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEATLASRESOURCE_H -#define GODOT_SPINEATLASRESOURCE_H +#pragma once #include "SpineCommon.h" #include "core/io/resource_loader.h" @@ -36,7 +35,6 @@ #include "core/io/image_loader.h" #include - class GodotSpineTextureLoader; class SpineAtlasResource : public Resource { @@ -105,6 +103,3 @@ public: bool recognize(const RES &resource) const override; }; - - -#endif//GODOT_SPINEATLASRESOURCE_H diff --git a/spine-godot/spine_godot/SpineAttachment.h b/spine-godot/spine_godot/SpineAttachment.h index f50b8b9b9..76826c102 100644 --- a/spine-godot/spine_godot/SpineAttachment.h +++ b/spine-godot/spine_godot/SpineAttachment.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEATTACHMENT_H -#define GODOT_SPINEATTACHMENT_H +#pragma once #include "SpineCommon.h" #include @@ -48,5 +47,3 @@ public: Ref copy(); }; - -#endif//GODOT_SPINEATTACHMENT_H diff --git a/spine-godot/spine_godot/SpineBone.h b/spine-godot/spine_godot/SpineBone.h index 7b5eaee40..c7daebf8f 100644 --- a/spine-godot/spine_godot/SpineBone.h +++ b/spine-godot/spine_godot/SpineBone.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEBONE_H -#define GODOT_SPINEBONE_H +#pragma once #include "SpineCommon.h" #include "SpineBoneData.h" @@ -172,5 +171,3 @@ public: void set_global_transform(Transform2D trans); }; - -#endif//GODOT_SPINEBONE_H diff --git a/spine-godot/spine_godot/SpineBoneData.h b/spine-godot/spine_godot/SpineBoneData.h index 62b74fa97..2c13f2b36 100644 --- a/spine-godot/spine_godot/SpineBoneData.h +++ b/spine-godot/spine_godot/SpineBoneData.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEBONEDATA_H -#define GODOT_SPINEBONEDATA_H +#pragma once #include "SpineCommon.h" #include "SpineConstant.h" @@ -93,5 +92,3 @@ public: void set_color(Color color); }; - -#endif//GODOT_SPINEBONEDATA_H diff --git a/spine-godot/spine_godot/SpineBoneNode.cpp b/spine-godot/spine_godot/SpineBoneNode.cpp new file mode 100644 index 000000000..51db381ca --- /dev/null +++ b/spine-godot/spine_godot/SpineBoneNode.cpp @@ -0,0 +1,151 @@ +/****************************************************************************** +* Spine Runtimes License Agreement + * Last updated January 1, 2020. Replaces all prior versions. + * + * Copyright (c) 2013-2020, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software + * or otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#include "SpineBoneNode.h" + +void SpineBoneNode::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_bone_mode"), &SpineBoneNode::set_bone_mode); + ClassDB::bind_method(D_METHOD("get_bone_mode"), &SpineBoneNode::get_bone_mode); + ClassDB::bind_method(D_METHOD("_before_world_transforms_change", "spine_sprite"), &SpineBoneNode::before_world_transforms_change); + ClassDB::bind_method(D_METHOD("_on_world_transforms_changed", "spine_sprite"), &SpineBoneNode::on_world_transforms_changed); + + ADD_PROPERTY(PropertyInfo(Variant::INT, "bone_mode", PROPERTY_HINT_ENUM, "Follow,Drive"), "set_bone_mode", "get_bone_mode"); +} + +void SpineBoneNode::_notification(int what) { + switch(what) { + case NOTIFICATION_PARENTED: { + SpineSprite *sprite = cast_to(get_parent()); + if (sprite) { +#if VERSION_MAJOR > 3 + sprite->connect("before_world_transforms_change", callable_mp(this, &SpineBoneNode::before_world_transforms_change)); + sprite->connect("world_transforms_changed", callable_mp(this, &SpineSlotNode::on_world_transforms_changed)); +#else + sprite->connect("before_world_transforms_change", this, "_before_world_transforms_change"); + sprite->connect("world_transforms_changed", this, "_on_world_transforms_changed"); +#endif + update_transform(sprite); +#if VERSION_MAJOR == 3 + _change_notify("transform/translation"); + _change_notify("transform/rotation"); + _change_notify("transform/scale"); + _change_notify("translation"); + _change_notify("rotation"); + _change_notify("rotation_deg"); + _change_notify("scale"); +#endif + } else { + WARN_PRINT("SpineSlotNode parent is not a SpineSprite."); + } + NOTIFY_PROPERTY_LIST_CHANGED(); + break; + } + case NOTIFICATION_UNPARENTED: { + SpineSprite *sprite = cast_to(get_parent()); + if (sprite) { +#if VERSION_MAJOR > 3 + sprite->disconnect("before_world_transforms_change", callable_mp(this, &SpineBoneNode::before_world_transforms_change)); + sprite->disconnect("world_transforms_changed", callable_mp(this, &SpineSlotNode::on_world_transforms_changed)); +#else + sprite->disconnect("before_world_transforms_change", this, "_before_world_transforms_change"); + sprite->disconnect("world_transforms_changed", this, "_on_world_transforms_changed"); +#endif + } + } + default: + break; + } +} + +void SpineBoneNode::_get_property_list(List* list) const { + Vector bone_names; + SpineSprite *sprite = cast_to(get_parent()); + if (sprite) sprite->get_skeleton_data_res()->get_bone_names(bone_names); + else bone_names.push_back(bone_name); + auto element = list->front(); + while (element) { + auto property_info = element->get(); + if (property_info.name == "SpineBoneNode") break; + element = element->next(); + } + PropertyInfo slot_name_property; + slot_name_property.name = "bone_name"; + slot_name_property.type = Variant::STRING; + slot_name_property.hint_string = String(",").join(bone_names); + slot_name_property.hint = PROPERTY_HINT_ENUM; + slot_name_property.usage = PROPERTY_USAGE_DEFAULT; + list->insert_after(element, slot_name_property); +} + +bool SpineBoneNode::_get(const StringName& property, Variant& value) const { + if (property == "bone_name") { + value = bone_name; + return true; + } + return false; +} + +bool SpineBoneNode::_set(const StringName& property, const Variant& value) { + if (property == "bone_name") { + bone_name = value; + return true; + } + return false; +} + +void SpineBoneNode::before_world_transforms_change(const Variant& _sprite) { + SpineSprite* sprite = cast_to(_sprite.operator Object*()); + if (bone_mode == SpineConstant::BoneMode_Drive) update_transform(sprite); +} + +void SpineBoneNode::on_world_transforms_changed(const Variant& _sprite) { + SpineSprite* sprite = cast_to(_sprite.operator Object*()); + if (bone_mode == SpineConstant::BoneMode_Follow) update_transform(sprite); +} + +void SpineBoneNode::update_transform(SpineSprite* sprite) { + if (!sprite) return; + if (!sprite->get_skeleton().is_valid() || !sprite->get_skeleton()->get_spine_object()) return; + auto bone = sprite->get_skeleton()->find_bone(bone_name); + if (!bone.is_valid()) return; + + if (bone_mode == SpineConstant::BoneMode_Drive) { + bone->set_global_transform(get_global_transform()); + } else { + this->set_global_transform(bone->get_global_transform()); + } +} + +SpineConstant::BoneMode SpineBoneNode::get_bone_mode() { + return bone_mode; +} + +void SpineBoneNode::set_bone_mode(SpineConstant::BoneMode _bone_mode) { + bone_mode = _bone_mode; +} diff --git a/spine-godot/spine_godot/SpineBoneNode.h b/spine-godot/spine_godot/SpineBoneNode.h new file mode 100644 index 000000000..83fac369c --- /dev/null +++ b/spine-godot/spine_godot/SpineBoneNode.h @@ -0,0 +1,62 @@ +/****************************************************************************** +* Spine Runtimes License Agreement + * Last updated January 1, 2020. Replaces all prior versions. + * + * Copyright (c) 2013-2020, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software + * or otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#pragma once + +#include "SpineCommon.h" +#include "SpineSprite.h" +#include "scene/2d/node_2d.h" + +class SpineBoneNode: public Node2D { + GDCLASS(SpineBoneNode, Node2D) + +protected: + String bone_name; + SpineConstant::BoneMode bone_mode; + + static void _bind_methods(); + void _notification(int what); + void _get_property_list(List *list) const; + bool _get(const StringName &property, Variant &value) const; + bool _set(const StringName &property, const Variant &value); + void before_world_transforms_change(const Variant &_sprite); + void on_world_transforms_changed(const Variant &_sprite); + void update_transform(SpineSprite *sprite); + +public: + SpineBoneNode(): bone_mode(SpineConstant::BoneMode_Follow) {} + + String get_bone_name(); + + void set_bone_name(const String &_bone_name); + + SpineConstant::BoneMode get_bone_mode(); + + void set_bone_mode(SpineConstant::BoneMode bone_mode); +}; diff --git a/spine-godot/spine_godot/SpineConstant.cpp b/spine-godot/spine_godot/SpineConstant.cpp index 8e4d2a92f..ef0f73166 100644 --- a/spine-godot/spine_godot/SpineConstant.cpp +++ b/spine-godot/spine_godot/SpineConstant.cpp @@ -80,4 +80,11 @@ void SpineConstant::_bind_methods() { BIND_ENUM_CONSTANT(BlendMode_Additive) BIND_ENUM_CONSTANT(BlendMode_Multiply) BIND_ENUM_CONSTANT(BlendMode_Screen) + + BIND_ENUM_CONSTANT(UpdateMode_Process) + BIND_ENUM_CONSTANT(UpdateMode_Physics) + BIND_ENUM_CONSTANT(UpdateMode_Manual) + + BIND_ENUM_CONSTANT(BoneMode_Follow) + BIND_ENUM_CONSTANT(BoneMode_Drive) } diff --git a/spine-godot/spine_godot/SpineConstant.h b/spine-godot/spine_godot/SpineConstant.h index bc123ede4..6d90da497 100644 --- a/spine-godot/spine_godot/SpineConstant.h +++ b/spine-godot/spine_godot/SpineConstant.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINECONSTANT_H -#define GODOT_SPINECONSTANT_H +#pragma once #include "SpineCommon.h" @@ -105,6 +104,17 @@ public: BlendMode_Multiply, BlendMode_Screen }; + + enum UpdateMode { + UpdateMode_Process, + UpdateMode_Physics, + UpdateMode_Manual + }; + + enum BoneMode { + BoneMode_Follow, + BoneMode_Drive + }; }; VARIANT_ENUM_CAST(SpineConstant::MixBlend) @@ -115,5 +125,5 @@ VARIANT_ENUM_CAST(SpineConstant::PositionMode) VARIANT_ENUM_CAST(SpineConstant::SpacingMode) VARIANT_ENUM_CAST(SpineConstant::RotateMode) VARIANT_ENUM_CAST(SpineConstant::BlendMode) - -#endif//GODOT_SPINECONSTANT_H +VARIANT_ENUM_CAST(SpineConstant::UpdateMode) +VARIANT_ENUM_CAST(SpineConstant::BoneMode) diff --git a/spine-godot/spine_godot/SpineConstraintData.h b/spine-godot/spine_godot/SpineConstraintData.h index 4e8371071..1ea763bc2 100644 --- a/spine-godot/spine_godot/SpineConstraintData.h +++ b/spine-godot/spine_godot/SpineConstraintData.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINECONSTRAINTDATA_H -#define GODOT_SPINECONSTRAINTDATA_H +#pragma once #include "SpineCommon.h" #include @@ -52,5 +51,3 @@ public: void set_skin_required(bool v); }; - -#endif//GODOT_SPINECONSTRAINTDATA_H diff --git a/spine-godot/spine_godot/SpineEditorPlugin.h b/spine-godot/spine_godot/SpineEditorPlugin.h index 26cce5638..0ab7d3b99 100644 --- a/spine-godot/spine_godot/SpineEditorPlugin.h +++ b/spine-godot/spine_godot/SpineEditorPlugin.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEEDITORPLUGIN_H -#define GODOT_SPINEEDITORPLUGIN_H +#pragma once #ifdef TOOLS_ENABLED #include "SpineCommon.h" @@ -206,5 +205,3 @@ public: }; #endif - -#endif//GODOT_SPINEEDITORPLUGIN_H diff --git a/spine-godot/spine_godot/SpineEvent.h b/spine-godot/spine_godot/SpineEvent.h index 8245d71ac..2dfd90ce8 100644 --- a/spine-godot/spine_godot/SpineEvent.h +++ b/spine-godot/spine_godot/SpineEvent.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEEVENT_H -#define GODOT_SPINEEVENT_H +#pragma once #include "SpineCommon.h" #include "SpineEventData.h" @@ -67,5 +66,3 @@ public: void set_balance(float v); }; - -#endif//GODOT_SPINEEVENT_H diff --git a/spine-godot/spine_godot/SpineEventData.h b/spine-godot/spine_godot/SpineEventData.h index 7f163199d..b6bd18053 100644 --- a/spine-godot/spine_godot/SpineEventData.h +++ b/spine-godot/spine_godot/SpineEventData.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEEVENTDATA_H -#define GODOT_SPINEEVENTDATA_H +#pragma once #include "SpineCommon.h" #include @@ -64,5 +63,3 @@ public: void set_balance(float v); }; - -#endif//GODOT_SPINEEVENTDATA_H diff --git a/spine-godot/spine_godot/SpineIkConstraint.h b/spine-godot/spine_godot/SpineIkConstraint.h index e8600ad6b..06189727b 100644 --- a/spine-godot/spine_godot/SpineIkConstraint.h +++ b/spine-godot/spine_godot/SpineIkConstraint.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEIKCONSTRAINT_H -#define GODOT_SPINEIKCONSTRAINT_H +#pragma once #include "SpineIkConstraintData.h" #include @@ -79,5 +78,3 @@ public: void set_active(bool v); }; - -#endif//GODOT_SPINEIKCONSTRAINT_H diff --git a/spine-godot/spine_godot/SpineIkConstraintData.h b/spine-godot/spine_godot/SpineIkConstraintData.h index 4520d586e..6e60f35dc 100644 --- a/spine-godot/spine_godot/SpineIkConstraintData.h +++ b/spine-godot/spine_godot/SpineIkConstraintData.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEIKCONSTRAINTDATA_H -#define GODOT_SPINEIKCONSTRAINTDATA_H +#pragma once #include "SpineConstraintData.h" #include "SpineBoneData.h" @@ -73,5 +72,3 @@ public: void set_softness(float v); }; - -#endif//GODOT_SPINEIKCONSTRAINTDATA_H diff --git a/spine-godot/spine_godot/SpinePathConstraint.h b/spine-godot/spine_godot/SpinePathConstraint.h index 3e19cf452..7ceb4db92 100644 --- a/spine-godot/spine_godot/SpinePathConstraint.h +++ b/spine-godot/spine_godot/SpinePathConstraint.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEPATHCONSTRAINT_H -#define GODOT_SPINEPATHCONSTRAINT_H +#pragma once #include "SpinePathConstraintData.h" #include "SpineSlot.h" @@ -77,5 +76,3 @@ public: void set_active(bool v); }; - -#endif//GODOT_SPINEPATHCONSTRAINT_H diff --git a/spine-godot/spine_godot/SpinePathConstraintData.h b/spine-godot/spine_godot/SpinePathConstraintData.h index f17173a51..78076c787 100644 --- a/spine-godot/spine_godot/SpinePathConstraintData.h +++ b/spine-godot/spine_godot/SpinePathConstraintData.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINEPATHCONSTRAINTDATA_H -#define GODOT_SPINEPATHCONSTRAINTDATA_H +#pragma once #include "SpineConstraintData.h" #include "SpineConstant.h" @@ -87,4 +86,3 @@ public: void set_mix_y(float v); }; -#endif//GODOT_SPINEPATHCONSTRAINTDATA_H diff --git a/spine-godot/spine_godot/SpineSkeleton.h b/spine-godot/spine_godot/SpineSkeleton.h index 8740f49e7..f312f2b31 100644 --- a/spine-godot/spine_godot/SpineSkeleton.h +++ b/spine-godot/spine_godot/SpineSkeleton.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINESKELETON_H -#define GODOT_SPINESKELETON_H +#pragma once #include "SpineCommon.h" #include "SpineSkeletonDataResource.h" @@ -51,6 +50,8 @@ class SpineSkeleton : public REFCOUNTED { friend class SpineAnimationState; friend class SpineCollisionShapeProxy; friend class SpineAnimationTrack; + friend class SpineBoneNode; + friend class SpineSlotNode; protected: static void _bind_methods(); @@ -137,5 +138,3 @@ public: void set_scale_y(float v); }; - -#endif//GODOT_SPINESKELETON_H diff --git a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp index fe1b70dab..dbed545ca 100644 --- a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp +++ b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp @@ -236,6 +236,16 @@ void SpineSkeletonDataResource::get_slot_names(Vector& slot_names) { } } +void SpineSkeletonDataResource::get_bone_names(Vector& bone_names) { + bone_names.clear(); + if (!is_skeleton_data_loaded()) return; + auto bones = skeleton_data->getBones(); + for (size_t i = 0; i < bones.size(); ++i) { + auto bone = bones[i]; + bone_names.push_back(bone->getName().buffer()); + } +} + void SpineSkeletonDataResource::set_default_mix(float _default_mix) { this->default_mix = _default_mix; update_mixes(); diff --git a/spine-godot/spine_godot/SpineSkeletonDataResource.h b/spine-godot/spine_godot/SpineSkeletonDataResource.h index 250fb8a2b..2b669bb69 100644 --- a/spine-godot/spine_godot/SpineSkeletonDataResource.h +++ b/spine-godot/spine_godot/SpineSkeletonDataResource.h @@ -1,5 +1,4 @@ -#ifndef GODOT_SPINESKELETONDATARESOURCE_H -#define GODOT_SPINESKELETONDATARESOURCE_H +#pragma once #include "SpineAtlasResource.h" #include "SpineSkeletonFileResource.h" @@ -78,6 +77,8 @@ public: void get_slot_names(Vector &slot_names); + void get_bone_names(Vector &bone_names); + void set_default_mix(float default_mix); float get_default_mix(); @@ -146,6 +147,3 @@ public: float get_fps() const; }; - - -#endif //GODOT_SPINESKELETONDATARESOURCE_H diff --git a/spine-godot/spine_godot/SpineSkeletonFileResource.h b/spine-godot/spine_godot/SpineSkeletonFileResource.h index c8ba417a0..d8b6d68c2 100644 --- a/spine-godot/spine_godot/SpineSkeletonFileResource.h +++ b/spine-godot/spine_godot/SpineSkeletonFileResource.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINESKELETONFILERESOURCE_H -#define GODOT_SPINESKELETONFILERESOURCE_H +#pragma once #include "SpineCommon.h" #include "core/io/resource_loader.h" @@ -82,5 +81,3 @@ public: bool recognize(const RES &p_resource) const override; }; - -#endif//GODOT_SPINESKELETONFILERESOURCE_H diff --git a/spine-godot/spine_godot/SpineSkin.h b/spine-godot/spine_godot/SpineSkin.h index deed0bdda..11969f80a 100644 --- a/spine-godot/spine_godot/SpineSkin.h +++ b/spine-godot/spine_godot/SpineSkin.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINESKIN_H -#define GODOT_SPINESKIN_H +#pragma once #include "SpineCommon.h" #include "SpineAttachment.h" @@ -101,5 +100,3 @@ public: Ref get_attachment(); }; - -#endif//GODOT_SPINESKIN_H diff --git a/spine-godot/spine_godot/SpineSlot.h b/spine-godot/spine_godot/SpineSlot.h index 4a39e29a9..795645473 100644 --- a/spine-godot/spine_godot/SpineSlot.h +++ b/spine-godot/spine_godot/SpineSlot.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINESLOT_H -#define GODOT_SPINESLOT_H +#pragma once #include "SpineCommon.h" #include "SpineSlotData.h" @@ -77,5 +76,3 @@ public: void set_sequence_index(int v); }; - -#endif//GODOT_SPINESLOT_H diff --git a/spine-godot/spine_godot/SpineSlotData.h b/spine-godot/spine_godot/SpineSlotData.h index f48fab983..2cc538dfe 100644 --- a/spine-godot/spine_godot/SpineSlotData.h +++ b/spine-godot/spine_godot/SpineSlotData.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINESLOTDATA_H -#define GODOT_SPINESLOTDATA_H +#pragma once #include "SpineCommon.h" #include "SpineBoneData.h" @@ -69,5 +68,3 @@ public: void set_blend_mode(SpineConstant::BlendMode v); }; - -#endif//GODOT_SPINESLOTDATA_H diff --git a/spine-godot/spine_godot/SpineSlotNode.cpp b/spine-godot/spine_godot/SpineSlotNode.cpp index c3c43911e..ef9bbbb20 100644 --- a/spine-godot/spine_godot/SpineSlotNode.cpp +++ b/spine-godot/spine_godot/SpineSlotNode.cpp @@ -1,11 +1,38 @@ -#include "SpineSlotNode.h" +/****************************************************************************** +* Spine Runtimes License Agreement + * Last updated January 1, 2020. Replaces all prior versions. + * + * Copyright (c) 2013-2020, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software + * or otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#include "SpineSlotNode.h" #include "editor/editor_node.h" #include "scene/main/viewport.h" void SpineSlotNode::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_slot_name"), &SpineSlotNode::set_slot_name); - ClassDB::bind_method(D_METHOD("get_slot_name"), &SpineSlotNode::get_slot_name); ClassDB::bind_method(D_METHOD("_on_world_transforms_changed", "spine_sprite"), &SpineSlotNode::on_world_transforms_changed); ClassDB::bind_method(D_METHOD("set_normal_material", "material"), &SpineSlotNode::set_normal_material); @@ -24,13 +51,13 @@ void SpineSlotNode::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "screen_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_screen_material", "get_screen_material"); } -SpineSlotNode::SpineSlotNode(): slot_index(-1), sprite(nullptr) { +SpineSlotNode::SpineSlotNode(): slot_index(-1) { } void SpineSlotNode::_notification(int what) { switch(what) { case NOTIFICATION_PARENTED: { - sprite = Object::cast_to(get_parent()); + SpineSprite *sprite = cast_to(get_parent()); if (sprite) { #if VERSION_MAJOR > 3 sprite->connect("world_transforms_changed", callable_mp(this, &SpineSlotNode::on_world_transforms_changed)); @@ -54,13 +81,15 @@ void SpineSlotNode::_notification(int what) { break; } case NOTIFICATION_UNPARENTED: { + SpineSprite *sprite = cast_to(get_parent()); if (sprite) { #if VERSION_MAJOR > 3 sprite->disconnect("world_transforms_changed", callable_mp(this, &SpineSlotNode::on_world_transforms_changed)); #else sprite->disconnect("world_transforms_changed", this, "_on_world_transforms_changed"); #endif - } + } + break; } default: break; @@ -69,6 +98,7 @@ void SpineSlotNode::_notification(int what) { void SpineSlotNode::_get_property_list(List* list) const { Vector slot_names; + SpineSprite *sprite = cast_to(get_parent()); if (sprite) sprite->get_skeleton_data_res()->get_slot_names(slot_names); else slot_names.push_back(slot_name); auto element = list->front(); @@ -97,6 +127,7 @@ bool SpineSlotNode::_get(const StringName& property, Variant& value) const { bool SpineSlotNode::_set(const StringName& property, const Variant& value) { if (property == "slot_name") { slot_name = value; + SpineSprite *sprite = cast_to(get_parent()); update_transform(sprite); #if VERSION_MAJOR == 3 _change_notify("transform/translation"); @@ -113,12 +144,13 @@ bool SpineSlotNode::_set(const StringName& property, const Variant& value) { } void SpineSlotNode::on_world_transforms_changed(const Variant& _sprite) { - SpineSprite* sprite = Object::cast_to(_sprite.operator Object*()); + SpineSprite* sprite = cast_to(_sprite.operator Object*()); update_transform(sprite); } void SpineSlotNode::update_transform(SpineSprite *sprite) { if (!sprite) return; + if (!sprite->get_skeleton().is_valid() || !sprite->get_skeleton()->get_spine_object()) return; auto slot = sprite->get_skeleton()->find_slot(slot_name); if (!slot.is_valid()) { slot_index = -1; diff --git a/spine-godot/spine_godot/SpineSlotNode.h b/spine-godot/spine_godot/SpineSlotNode.h index 581c77f99..2f10e3012 100644 --- a/spine-godot/spine_godot/SpineSlotNode.h +++ b/spine-godot/spine_godot/SpineSlotNode.h @@ -1,5 +1,33 @@ -#ifndef GODOT_SPINESLOTNODE_H -#define GODOT_SPINESLOTNODE_H +/****************************************************************************** +* Spine Runtimes License Agreement + * Last updated January 1, 2020. Replaces all prior versions. + * + * Copyright (c) 2013-2020, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software + * or otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#pragma once #include "SpineCommon.h" #include "SpineSprite.h" @@ -15,7 +43,6 @@ protected: Ref additive_material; Ref multiply_material; Ref screen_material; - SpineSprite *sprite; static void _bind_methods(); void _notification(int what); @@ -49,5 +76,3 @@ public: void set_screen_material(Ref material); }; - -#endif diff --git a/spine-godot/spine_godot/SpineSprite.cpp b/spine-godot/spine_godot/SpineSprite.cpp index 14bfb3696..037c3d55d 100644 --- a/spine-godot/spine_godot/SpineSprite.cpp +++ b/spine-godot/spine_godot/SpineSprite.cpp @@ -87,13 +87,9 @@ void SpineSprite::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "additive_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_additive_material", "get_additive_material"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiply_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_multiply_material", "get_multiply_material"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "screen_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_screen_material", "get_screen_material"); - - BIND_ENUM_CONSTANT(UpdateMode::UpdateMode_Process) - BIND_ENUM_CONSTANT(UpdateMode::UpdateMode_Physics) - BIND_ENUM_CONSTANT(UpdateMode::UpdateMode_Manual) } -SpineSprite::SpineSprite() : update_mode(UpdateMode_Process), skeleton_clipper(nullptr) { +SpineSprite::SpineSprite() : update_mode(SpineConstant::UpdateMode_Process), skeleton_clipper(nullptr) { skeleton_clipper = new spine::SkeletonClipping(); // One material per blend mode, shared across all sprites. @@ -176,9 +172,9 @@ void SpineSprite::on_skeleton_data_changed() { skeleton->update_world_transform(); generate_meshes_for_slots(skeleton); - if (update_mode == UpdateMode_Process) { + if (update_mode == SpineConstant::UpdateMode_Process) { _notification(NOTIFICATION_INTERNAL_PROCESS); - } else if (update_mode == UpdateMode_Physics) { + } else if (update_mode == SpineConstant::UpdateMode_Physics) { _notification(NOTIFICATION_INTERNAL_PHYSICS_PROCESS); } } @@ -244,17 +240,17 @@ Ref SpineSprite::get_animation_state() { void SpineSprite::_notification(int what) { switch (what) { case NOTIFICATION_READY: { - set_process_internal(update_mode == UpdateMode_Process); - set_physics_process_internal(update_mode == UpdateMode_Physics); + set_process_internal(update_mode == SpineConstant::UpdateMode_Process); + set_physics_process_internal(update_mode == SpineConstant::UpdateMode_Physics); break; } case NOTIFICATION_INTERNAL_PROCESS: { - if (update_mode == UpdateMode_Process) + if (update_mode == SpineConstant::UpdateMode_Process) update_skeleton(get_process_delta_time()); break; } case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { - if (update_mode == UpdateMode_Physics) + if (update_mode == SpineConstant::UpdateMode_Physics) update_skeleton(get_physics_process_delta_time()); break; } @@ -502,14 +498,14 @@ void SpineSprite::set_global_bone_transform(const String &bone_name, Transform2D bone->set_global_transform(transform); } -SpineSprite::UpdateMode SpineSprite::get_update_mode() { +SpineConstant::UpdateMode SpineSprite::get_update_mode() { return update_mode; } -void SpineSprite::set_update_mode(SpineSprite::UpdateMode v) { +void SpineSprite::set_update_mode(SpineConstant::UpdateMode v) { update_mode = v; - set_process_internal(update_mode == UpdateMode_Process); - set_physics_process_internal(update_mode == UpdateMode_Physics); + set_process_internal(update_mode == SpineConstant::UpdateMode_Process); + set_physics_process_internal(update_mode == SpineConstant::UpdateMode_Physics); } Ref SpineSprite::new_skin(const String& name) { diff --git a/spine-godot/spine_godot/SpineSprite.h b/spine-godot/spine_godot/SpineSprite.h index c3f1f1fef..d18451a73 100644 --- a/spine-godot/spine_godot/SpineSprite.h +++ b/spine-godot/spine_godot/SpineSprite.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINESPRITE_H -#define GODOT_SPINESPRITE_H +#pragma once #include "SpineSkeleton.h" #include "SpineAnimationState.h" @@ -40,19 +39,12 @@ class SpineSlotNode; class SpineSprite : public Node2D, public spine::AnimationStateListenerObject { GDCLASS(SpineSprite, Node2D) - -public: - enum UpdateMode { - UpdateMode_Process, - UpdateMode_Physics, - UpdateMode_Manual - }; protected: Ref skeleton_data_res; Ref skeleton; Ref animation_state; - UpdateMode update_mode; + SpineConstant::UpdateMode update_mode; spine::Vector > slot_nodes; Vector mesh_instances; @@ -93,9 +85,9 @@ public: void set_global_bone_transform(const String &bone_name, Transform2D transform); - UpdateMode get_update_mode(); + SpineConstant::UpdateMode get_update_mode(); - void set_update_mode(UpdateMode v); + void set_update_mode(SpineConstant::UpdateMode v); Ref new_skin(const String &name); @@ -120,6 +112,3 @@ public: virtual bool _edit_use_rect() const; #endif }; - -VARIANT_ENUM_CAST(SpineSprite::UpdateMode); -#endif//GODOT_SPINESPRITE_H diff --git a/spine-godot/spine_godot/SpineTimeline.h b/spine-godot/spine_godot/SpineTimeline.h index ddb4eaf1d..6cac70f7b 100644 --- a/spine-godot/spine_godot/SpineTimeline.h +++ b/spine-godot/spine_godot/SpineTimeline.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINETIMELINE_H -#define GODOT_SPINETIMELINE_H +#pragma once #include "SpineCommon.h" #include "SpineConstant.h" @@ -60,5 +59,3 @@ public: String get_type(); }; - -#endif//GODOT_SPINETIMELINE_H diff --git a/spine-godot/spine_godot/SpineTrackEntry.h b/spine-godot/spine_godot/SpineTrackEntry.h index a6d9a886f..a7ae3027b 100644 --- a/spine-godot/spine_godot/SpineTrackEntry.h +++ b/spine-godot/spine_godot/SpineTrackEntry.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINETRACKENTRY_H -#define GODOT_SPINETRACKENTRY_H +#pragma once #include "SpineCommon.h" #include "SpineAnimation.h" @@ -136,5 +135,3 @@ public: float get_track_complete(); }; - -#endif//GODOT_SPINETRACKENTRY_H diff --git a/spine-godot/spine_godot/SpineTransformConstraint.h b/spine-godot/spine_godot/SpineTransformConstraint.h index 8be8ded46..95f7cdcc4 100644 --- a/spine-godot/spine_godot/SpineTransformConstraint.h +++ b/spine-godot/spine_godot/SpineTransformConstraint.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINETRANSFORMCONSTRAINT_H -#define GODOT_SPINETRANSFORMCONSTRAINT_H +#pragma once #include "SpineCommon.h" #include "SpineTransformConstraintData.h" @@ -82,5 +81,3 @@ public: void set_active(bool v); }; - -#endif//GODOT_SPINETRANSFORMCONSTRAINT_H diff --git a/spine-godot/spine_godot/SpineTransformConstraintData.h b/spine-godot/spine_godot/SpineTransformConstraintData.h index 0618a6be6..3d0b899c3 100644 --- a/spine-godot/spine_godot/SpineTransformConstraintData.h +++ b/spine-godot/spine_godot/SpineTransformConstraintData.h @@ -27,8 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef GODOT_SPINETRANSFORMCONSTRAINTDATA_H -#define GODOT_SPINETRANSFORMCONSTRAINTDATA_H +#pragma once #include "SpineConstraintData.h" #include "SpineBoneData.h" @@ -75,5 +74,3 @@ public: bool is_local(); }; - -#endif//GODOT_SPINETRANSFORMCONSTRAINTDATA_H diff --git a/spine-godot/spine_godot/register_types.cpp b/spine-godot/spine_godot/register_types.cpp index 48bf5e458..923600d4f 100644 --- a/spine-godot/spine_godot/register_types.cpp +++ b/spine-godot/spine_godot/register_types.cpp @@ -50,6 +50,7 @@ #include "SpineTimeline.h" #include "SpineConstant.h" #include "SpineSlotNode.h" +#include "SpineBoneNode.h" static Ref atlas_loader; static Ref atlas_saver; @@ -100,6 +101,7 @@ void register_spine_godot_types() { ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); #if VERSION_MAJOR > 3 diff --git a/spine-godot/spine_godot/register_types.h b/spine-godot/spine_godot/register_types.h index 59ef9515f..0f86de090 100644 --- a/spine-godot/spine_godot/register_types.h +++ b/spine-godot/spine_godot/register_types.h @@ -27,5 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#pragma once + void register_spine_godot_types(); void unregister_spine_godot_types();