From 83ba44ed37bc13be3d16ff0a6f16ad45f361fa4b Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 29 Sep 2025 17:20:26 +0200 Subject: [PATCH] Formatting --- spine-godot/spine_godot/SpineIkConstraint.cpp | 72 +++-------- spine-godot/spine_godot/SpineIkConstraint.h | 23 +--- .../spine_godot/SpineIkConstraintData.cpp | 66 ++-------- .../spine_godot/SpineIkConstraintData.h | 24 +--- .../spine_godot/SpineIkConstraintPose.cpp | 94 ++++++++++++++ .../spine_godot/SpineIkConstraintPose.h | 67 ++++++++++ .../spine_godot/SpinePathConstraint.cpp | 73 +++-------- spine-godot/spine_godot/SpinePathConstraint.h | 22 +--- .../spine_godot/SpinePathConstraintData.cpp | 66 ++-------- .../spine_godot/SpinePathConstraintData.h | 22 +--- .../spine_godot/SpinePathConstraintPose.cpp | 94 ++++++++++++++ .../spine_godot/SpinePathConstraintPose.h | 68 ++++++++++ .../spine_godot/SpinePhysicsConstraint.cpp | 105 ++++------------ .../spine_godot/SpinePhysicsConstraint.h | 29 +---- .../SpinePhysicsConstraintData.cpp | 51 +++----- .../spine_godot/SpinePhysicsConstraintData.h | 18 +-- .../SpinePhysicsConstraintPose.cpp | 118 ++++++++++++++++++ .../spine_godot/SpinePhysicsConstraintPose.h | 74 +++++++++++ spine-godot/spine_godot/SpineSkeleton.cpp | 4 + spine-godot/spine_godot/SpineSkeleton.h | 9 +- .../spine_godot/SpineSkeletonDataResource.cpp | 8 +- spine-godot/spine_godot/SpineSliderPose.cpp | 58 +++++++++ spine-godot/spine_godot/SpineSliderPose.h | 58 +++++++++ spine-godot/spine_godot/SpineSlot.cpp | 95 -------------- spine-godot/spine_godot/SpineSlot.h | 26 ---- spine-godot/spine_godot/SpineTimeline.cpp | 6 +- spine-godot/spine_godot/SpineTimeline.h | 2 +- .../spine_godot/SpineTransformConstraint.cpp | 103 ++++----------- .../spine_godot/SpineTransformConstraint.h | 30 +---- .../SpineTransformConstraintData.cpp | 64 ++++------ .../SpineTransformConstraintData.h | 18 +-- .../SpineTransformConstraintPose.cpp | 106 ++++++++++++++++ .../SpineTransformConstraintPose.h | 71 +++++++++++ spine-godot/spine_godot/register_types.cpp | 14 +++ 34 files changed, 1013 insertions(+), 745 deletions(-) create mode 100644 spine-godot/spine_godot/SpineIkConstraintPose.cpp create mode 100644 spine-godot/spine_godot/SpineIkConstraintPose.h create mode 100644 spine-godot/spine_godot/SpinePathConstraintPose.cpp create mode 100644 spine-godot/spine_godot/SpinePathConstraintPose.h create mode 100644 spine-godot/spine_godot/SpinePhysicsConstraintPose.cpp create mode 100644 spine-godot/spine_godot/SpinePhysicsConstraintPose.h create mode 100644 spine-godot/spine_godot/SpineSliderPose.cpp create mode 100644 spine-godot/spine_godot/SpineSliderPose.h create mode 100644 spine-godot/spine_godot/SpineTransformConstraintPose.cpp create mode 100644 spine-godot/spine_godot/SpineTransformConstraintPose.h diff --git a/spine-godot/spine_godot/SpineIkConstraint.cpp b/spine-godot/spine_godot/SpineIkConstraint.cpp index 35cacc156..368ab1a24 100644 --- a/spine-godot/spine_godot/SpineIkConstraint.cpp +++ b/spine-godot/spine_godot/SpineIkConstraint.cpp @@ -28,6 +28,7 @@ *****************************************************************************/ #include "SpineIkConstraint.h" +#include "SpineIkConstraintPose.h" #include "SpineBone.h" #include "SpineCommon.h" #include "SpineSprite.h" @@ -38,16 +39,8 @@ void SpineIkConstraint::_bind_methods() { ClassDB::bind_method(D_METHOD("get_bones"), &SpineIkConstraint::get_bones); ClassDB::bind_method(D_METHOD("get_target"), &SpineIkConstraint::get_target); ClassDB::bind_method(D_METHOD("set_target", "v"), &SpineIkConstraint::set_target); - ClassDB::bind_method(D_METHOD("get_bend_direction"), &SpineIkConstraint::get_bend_direction); - ClassDB::bind_method(D_METHOD("set_bend_direction", "v"), &SpineIkConstraint::set_bend_direction); - ClassDB::bind_method(D_METHOD("get_compress"), &SpineIkConstraint::get_compress); - ClassDB::bind_method(D_METHOD("set_compress", "v"), &SpineIkConstraint::set_compress); - ClassDB::bind_method(D_METHOD("get_stretch"), &SpineIkConstraint::get_stretch); - ClassDB::bind_method(D_METHOD("set_stretch", "v"), &SpineIkConstraint::set_stretch); - ClassDB::bind_method(D_METHOD("get_mix"), &SpineIkConstraint::get_mix); - ClassDB::bind_method(D_METHOD("set_mix", "v"), &SpineIkConstraint::set_mix); - ClassDB::bind_method(D_METHOD("get_softness"), &SpineIkConstraint::get_softness); - ClassDB::bind_method(D_METHOD("set_softness", "v"), &SpineIkConstraint::set_softness); + ClassDB::bind_method(D_METHOD("get_pose"), &SpineIkConstraint::get_pose); + ClassDB::bind_method(D_METHOD("get_applied_pose"), &SpineIkConstraint::get_applied_pose); ClassDB::bind_method(D_METHOD("is_active"), &SpineIkConstraint::is_active); ClassDB::bind_method(D_METHOD("set_active", "v"), &SpineIkConstraint::set_active); } @@ -72,7 +65,7 @@ Array SpineIkConstraint::get_bones() { result.resize((int) bones.size()); for (int i = 0; i < bones.size(); ++i) { auto bone = bones[i]; - Ref bone_ref(memnew(SpineBone)); + Ref bone_ref(memnew(SpineBonePose)); bone_ref->set_spine_object(get_spine_owner(), bone); result[i] = bone_ref; } @@ -95,53 +88,20 @@ void SpineIkConstraint::set_target(Ref v) { } } -int SpineIkConstraint::get_bend_direction() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getBendDirection(); +Ref SpineIkConstraint::get_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_object()->getPose(); + Ref pose_ref(memnew(SpineIkConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; } -void SpineIkConstraint::set_bend_direction(int v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setBendDirection(v); -} - -bool SpineIkConstraint::get_compress() { - SPINE_CHECK(get_spine_object(), false) - return get_spine_object()->getPose().getCompress(); -} - -void SpineIkConstraint::set_compress(bool v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setCompress(v); -} - -bool SpineIkConstraint::get_stretch() { - SPINE_CHECK(get_spine_object(), false) - return get_spine_object()->getPose().getStretch(); -} - -void SpineIkConstraint::set_stretch(bool v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setStretch(v); -} - -float SpineIkConstraint::get_mix() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getMix(); -} -void SpineIkConstraint::set_mix(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setMix(v); -} - -float SpineIkConstraint::get_softness() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getSoftness(); -} - -void SpineIkConstraint::set_softness(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setSoftness(v); +Ref SpineIkConstraint::get_applied_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_object()->getAppliedPose(); + Ref pose_ref(memnew(SpineIkConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; } bool SpineIkConstraint::is_active() { diff --git a/spine-godot/spine_godot/SpineIkConstraint.h b/spine-godot/spine_godot/SpineIkConstraint.h index 64ed9ba8b..886e539e9 100644 --- a/spine-godot/spine_godot/SpineIkConstraint.h +++ b/spine-godot/spine_godot/SpineIkConstraint.h @@ -31,10 +31,11 @@ #include "SpineIkConstraintData.h" #include -#include "SpineSkeleton.h" class SpineBone; class SpineSprite; +class SpineSkeleton; +class SpineIkConstraintPose; class SpineIkConstraint : public SpineSpriteOwnedObject { GDCLASS(SpineIkConstraint, SpineObjectWrapper) @@ -53,25 +54,9 @@ public: void set_target(Ref v); - int get_bend_direction(); + Ref get_pose(); - void set_bend_direction(int v); - - bool get_compress(); - - void set_compress(bool v); - - bool get_stretch(); - - void set_stretch(bool v); - - float get_mix(); - - void set_mix(float v); - - float get_softness(); - - void set_softness(float v); + Ref get_applied_pose(); bool is_active(); diff --git a/spine-godot/spine_godot/SpineIkConstraintData.cpp b/spine-godot/spine_godot/SpineIkConstraintData.cpp index 4efb8946a..436646c64 100644 --- a/spine-godot/spine_godot/SpineIkConstraintData.cpp +++ b/spine-godot/spine_godot/SpineIkConstraintData.cpp @@ -28,24 +28,16 @@ *****************************************************************************/ #include "SpineIkConstraintData.h" +#include "SpineIkConstraintPose.h" #include "SpineCommon.h" void SpineIkConstraintData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_bones"), &SpineIkConstraintData::get_bones); ClassDB::bind_method(D_METHOD("get_target"), &SpineIkConstraintData::get_target); ClassDB::bind_method(D_METHOD("set_target", "v"), &SpineIkConstraintData::set_target); - ClassDB::bind_method(D_METHOD("get_bend_direction"), &SpineIkConstraintData::get_bend_direction); - ClassDB::bind_method(D_METHOD("set_bend_direction", "v"), &SpineIkConstraintData::set_bend_direction); - ClassDB::bind_method(D_METHOD("get_compress"), &SpineIkConstraintData::get_compress); - ClassDB::bind_method(D_METHOD("set_compress", "v"), &SpineIkConstraintData::set_compress); - ClassDB::bind_method(D_METHOD("get_stretch"), &SpineIkConstraintData::get_stretch); - ClassDB::bind_method(D_METHOD("set_stretch", "v"), &SpineIkConstraintData::set_stretch); ClassDB::bind_method(D_METHOD("get_uniform"), &SpineIkConstraintData::get_uniform); ClassDB::bind_method(D_METHOD("set_uniform", "v"), &SpineIkConstraintData::set_uniform); - ClassDB::bind_method(D_METHOD("get_mix"), &SpineIkConstraintData::get_mix); - ClassDB::bind_method(D_METHOD("set_mix", "v"), &SpineIkConstraintData::set_mix); - ClassDB::bind_method(D_METHOD("get_softness"), &SpineIkConstraintData::get_softness); - ClassDB::bind_method(D_METHOD("set_softness", "v"), &SpineIkConstraintData::set_softness); + ClassDB::bind_method(D_METHOD("get_setup_pose"), &SpineIkConstraintData::get_setup_pose); } Array SpineIkConstraintData::get_bones() { @@ -77,36 +69,6 @@ void SpineIkConstraintData::set_target(Ref v) { } } -int SpineIkConstraintData::get_bend_direction() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_constraint_data()->getSetupPose().getBendDirection(); -} - -void SpineIkConstraintData::set_bend_direction(int v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_constraint_data()->getSetupPose().setBendDirection(v); -} - -bool SpineIkConstraintData::get_compress() { - SPINE_CHECK(get_spine_object(), false) - return get_spine_constraint_data()->getSetupPose().getCompress(); -} - -void SpineIkConstraintData::set_compress(bool v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_constraint_data()->getSetupPose().setCompress(v); -} - -bool SpineIkConstraintData::get_stretch() { - SPINE_CHECK(get_spine_object(), false) - return get_spine_constraint_data()->getSetupPose().getStretch(); -} - -void SpineIkConstraintData::set_stretch(bool v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_constraint_data()->getSetupPose().setStretch(v); -} - bool SpineIkConstraintData::get_uniform() { SPINE_CHECK(get_spine_object(), false) return get_spine_constraint_data()->getUniform(); @@ -117,22 +79,10 @@ void SpineIkConstraintData::set_uniform(bool v) { get_spine_constraint_data()->setUniform(v); } -float SpineIkConstraintData::get_mix() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_constraint_data()->getSetupPose().getMix(); -} - -void SpineIkConstraintData::set_mix(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_constraint_data()->getSetupPose().setMix(v); -} - -float SpineIkConstraintData::get_softness() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_constraint_data()->getSetupPose().getSoftness(); -} - -void SpineIkConstraintData::set_softness(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_constraint_data()->getSetupPose().setSoftness(v); +Ref SpineIkConstraintData::get_setup_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_constraint_data()->getSetupPose(); + Ref pose_ref(memnew(SpineIkConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; } diff --git a/spine-godot/spine_godot/SpineIkConstraintData.h b/spine-godot/spine_godot/SpineIkConstraintData.h index 85e50b537..08e82b72c 100644 --- a/spine-godot/spine_godot/SpineIkConstraintData.h +++ b/spine-godot/spine_godot/SpineIkConstraintData.h @@ -33,6 +33,8 @@ #include "SpineBoneData.h" #include +class SpineIkConstraintPose; + class SpineIkConstraintData : public SpineConstraintData { GDCLASS(SpineIkConstraintData, SpineConstraintData) @@ -47,30 +49,10 @@ public: Array get_bones(); Ref get_target(); - void set_target(Ref v); - int get_bend_direction(); - - void set_bend_direction(int v); - - bool get_compress(); - - void set_compress(bool v); - - bool get_stretch(); - - void set_stretch(bool v); - bool get_uniform(); - void set_uniform(bool v); - float get_mix(); - - void set_mix(float v); - - float get_softness(); - - void set_softness(float v); + Ref get_setup_pose(); }; diff --git a/spine-godot/spine_godot/SpineIkConstraintPose.cpp b/spine-godot/spine_godot/SpineIkConstraintPose.cpp new file mode 100644 index 000000000..0f9d7ff7c --- /dev/null +++ b/spine-godot/spine_godot/SpineIkConstraintPose.cpp @@ -0,0 +1,94 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * Copyright (c) 2013-2025, 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 "SpineIkConstraintPose.h" +#include "SpineCommon.h" + +void SpineIkConstraintPose::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_mix"), &SpineIkConstraintPose::get_mix); + ClassDB::bind_method(D_METHOD("set_mix", "value"), &SpineIkConstraintPose::set_mix); + ClassDB::bind_method(D_METHOD("get_softness"), &SpineIkConstraintPose::get_softness); + ClassDB::bind_method(D_METHOD("set_softness", "value"), &SpineIkConstraintPose::set_softness); + ClassDB::bind_method(D_METHOD("get_bend_direction"), &SpineIkConstraintPose::get_bend_direction); + ClassDB::bind_method(D_METHOD("set_bend_direction", "value"), &SpineIkConstraintPose::set_bend_direction); + ClassDB::bind_method(D_METHOD("get_compress"), &SpineIkConstraintPose::get_compress); + ClassDB::bind_method(D_METHOD("set_compress", "value"), &SpineIkConstraintPose::set_compress); + ClassDB::bind_method(D_METHOD("get_stretch"), &SpineIkConstraintPose::get_stretch); + ClassDB::bind_method(D_METHOD("set_stretch", "value"), &SpineIkConstraintPose::set_stretch); +} + +float SpineIkConstraintPose::get_mix() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMix(); +} + +void SpineIkConstraintPose::set_mix(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMix(value); +} + +float SpineIkConstraintPose::get_softness() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getSoftness(); +} + +void SpineIkConstraintPose::set_softness(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setSoftness(value); +} + +int SpineIkConstraintPose::get_bend_direction() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getBendDirection(); +} + +void SpineIkConstraintPose::set_bend_direction(int value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setBendDirection(value); +} + +bool SpineIkConstraintPose::get_compress() { + SPINE_CHECK(get_spine_object(), false) + return get_spine_object()->getCompress(); +} + +void SpineIkConstraintPose::set_compress(bool value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setCompress(value); +} + +bool SpineIkConstraintPose::get_stretch() { + SPINE_CHECK(get_spine_object(), false) + return get_spine_object()->getStretch(); +} + +void SpineIkConstraintPose::set_stretch(bool value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setStretch(value); +} \ No newline at end of file diff --git a/spine-godot/spine_godot/SpineIkConstraintPose.h b/spine-godot/spine_godot/SpineIkConstraintPose.h new file mode 100644 index 000000000..20927da76 --- /dev/null +++ b/spine-godot/spine_godot/SpineIkConstraintPose.h @@ -0,0 +1,67 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * Copyright (c) 2013-2025, 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 + +class SpineSprite; + +class SpineIkConstraintPose : public SpineObjectWrapper { + GDCLASS(SpineIkConstraintPose, SpineObjectWrapper) + +protected: + static void _bind_methods(); + +public: + // Can be used by both SpineSprite and SpineSkeletonDataResource + void set_spine_object(void *owner, spine::IkConstraintPose *object) { + _set_spine_object_internal(owner, object); + } + + spine::IkConstraintPose *get_spine_object() { + return (spine::IkConstraintPose *) _get_spine_object_internal(); + } + + float get_mix(); + void set_mix(float value); + + float get_softness(); + void set_softness(float value); + + int get_bend_direction(); + void set_bend_direction(int value); + + bool get_compress(); + void set_compress(bool value); + + bool get_stretch(); + void set_stretch(bool value); +}; \ No newline at end of file diff --git a/spine-godot/spine_godot/SpinePathConstraint.cpp b/spine-godot/spine_godot/SpinePathConstraint.cpp index c5bde872c..0f44b79a6 100644 --- a/spine-godot/spine_godot/SpinePathConstraint.cpp +++ b/spine-godot/spine_godot/SpinePathConstraint.cpp @@ -28,22 +28,15 @@ *****************************************************************************/ #include "SpinePathConstraint.h" +#include "SpinePathConstraintPose.h" #include "SpineBone.h" #include "SpineCommon.h" #include "SpineSprite.h" void SpinePathConstraint::_bind_methods() { ClassDB::bind_method(D_METHOD("update", "skeleton"), &SpinePathConstraint::update); - ClassDB::bind_method(D_METHOD("get_position"), &SpinePathConstraint::get_position); - ClassDB::bind_method(D_METHOD("set_position", "v"), &SpinePathConstraint::set_position); - ClassDB::bind_method(D_METHOD("get_spacing"), &SpinePathConstraint::get_spacing); - ClassDB::bind_method(D_METHOD("set_spacing", "v"), &SpinePathConstraint::set_spacing); - ClassDB::bind_method(D_METHOD("get_mix_rotate"), &SpinePathConstraint::get_mix_rotate); - ClassDB::bind_method(D_METHOD("set_mix_rotate", "v"), &SpinePathConstraint::set_mix_rotate); - ClassDB::bind_method(D_METHOD("get_mix_x"), &SpinePathConstraint::get_mix_x); - ClassDB::bind_method(D_METHOD("set_mix_x", "v"), &SpinePathConstraint::set_mix_x); - ClassDB::bind_method(D_METHOD("get_mix_y"), &SpinePathConstraint::get_mix_y); - ClassDB::bind_method(D_METHOD("set_mix_y", "v"), &SpinePathConstraint::set_mix_y); + ClassDB::bind_method(D_METHOD("get_pose"), &SpinePathConstraint::get_pose); + ClassDB::bind_method(D_METHOD("get_applied_pose"), &SpinePathConstraint::get_applied_pose); ClassDB::bind_method(D_METHOD("get_bones"), &SpinePathConstraint::get_bones); ClassDB::bind_method(D_METHOD("get_slot"), &SpinePathConstraint::get_slot); ClassDB::bind_method(D_METHOD("set_slot", "v"), &SpinePathConstraint::set_slot); @@ -57,54 +50,20 @@ void SpinePathConstraint::update(Ref skeleton) { get_spine_object()->update(*skeleton->get_spine_object(), spine::Physics_Update); } -float SpinePathConstraint::get_position() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getPosition(); +Ref SpinePathConstraint::get_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_object()->getPose(); + Ref pose_ref(memnew(SpinePathConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; } -void SpinePathConstraint::set_position(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setPosition(v); -} - -float SpinePathConstraint::get_spacing() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getSpacing(); -} - -void SpinePathConstraint::set_spacing(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setSpacing(v); -} - -float SpinePathConstraint::get_mix_rotate() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getMixRotate(); -} - -void SpinePathConstraint::set_mix_rotate(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setMixRotate(v); -} - -float SpinePathConstraint::get_mix_x() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getMixX(); -} - -void SpinePathConstraint::set_mix_x(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setMixX(v); -} - -float SpinePathConstraint::get_mix_y() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getMixY(); -} - -void SpinePathConstraint::set_mix_y(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setMixY(v); +Ref SpinePathConstraint::get_applied_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_object()->getAppliedPose(); + Ref pose_ref(memnew(SpinePathConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; } Array SpinePathConstraint::get_bones() { @@ -114,7 +73,7 @@ Array SpinePathConstraint::get_bones() { result.resize((int) bones.size()); for (int i = 0; i < bones.size(); ++i) { auto bone = bones[i]; - Ref bone_ref(memnew(SpineBone)); + Ref bone_ref(memnew(SpineBonePose)); bone_ref->set_spine_object(get_spine_owner(), bone); result[i] = bone_ref; } diff --git a/spine-godot/spine_godot/SpinePathConstraint.h b/spine-godot/spine_godot/SpinePathConstraint.h index a623c271c..6d35c504d 100644 --- a/spine-godot/spine_godot/SpinePathConstraint.h +++ b/spine-godot/spine_godot/SpinePathConstraint.h @@ -33,6 +33,8 @@ #include "SpineSlot.h" #include +class SpinePathConstraintPose; + class SpinePathConstraint : public SpineSpriteOwnedObject { GDCLASS(SpinePathConstraint, SpineObjectWrapper) @@ -42,25 +44,9 @@ protected: public: void update(Ref skeleton); - float get_position(); + Ref get_pose(); - void set_position(float v); - - float get_spacing(); - - void set_spacing(float v); - - float get_mix_rotate(); - - void set_mix_rotate(float v); - - float get_mix_x(); - - void set_mix_x(float v); - - float get_mix_y(); - - void set_mix_y(float v); + Ref get_applied_pose(); Array get_bones(); diff --git a/spine-godot/spine_godot/SpinePathConstraintData.cpp b/spine-godot/spine_godot/SpinePathConstraintData.cpp index 270471935..9ac852070 100644 --- a/spine-godot/spine_godot/SpinePathConstraintData.cpp +++ b/spine-godot/spine_godot/SpinePathConstraintData.cpp @@ -28,6 +28,7 @@ *****************************************************************************/ #include "SpinePathConstraintData.h" +#include "SpinePathConstraintPose.h" #include "SpineCommon.h" #include "SpineSkeletonDataResource.h" @@ -43,16 +44,7 @@ void SpinePathConstraintData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_rotate_mode", "v"), &SpinePathConstraintData::set_rotate_mode); ClassDB::bind_method(D_METHOD("get_offset_rotation"), &SpinePathConstraintData::get_offset_rotation); ClassDB::bind_method(D_METHOD("set_offset_rotation", "v"), &SpinePathConstraintData::set_offset_rotation); - ClassDB::bind_method(D_METHOD("get_position"), &SpinePathConstraintData::get_position); - ClassDB::bind_method(D_METHOD("set_position", "v"), &SpinePathConstraintData::set_position); - ClassDB::bind_method(D_METHOD("get_spacing"), &SpinePathConstraintData::get_spacing); - ClassDB::bind_method(D_METHOD("set_spacing", "v"), &SpinePathConstraintData::set_spacing); - ClassDB::bind_method(D_METHOD("get_mix_rotate"), &SpinePathConstraintData::get_mix_rotate); - ClassDB::bind_method(D_METHOD("set_mix_rotate", "v"), &SpinePathConstraintData::set_mix_rotate); - ClassDB::bind_method(D_METHOD("get_mix_x"), &SpinePathConstraintData::get_mix_x); - ClassDB::bind_method(D_METHOD("set_mix_x", "v"), &SpinePathConstraintData::set_mix_x); - ClassDB::bind_method(D_METHOD("get_mix_y"), &SpinePathConstraintData::get_mix_y); - ClassDB::bind_method(D_METHOD("set_mix_y", "v"), &SpinePathConstraintData::set_mix_y); + ClassDB::bind_method(D_METHOD("get_setup_pose"), &SpinePathConstraintData::get_setup_pose); } Array SpinePathConstraintData::get_bones() { @@ -124,52 +116,10 @@ void SpinePathConstraintData::set_offset_rotation(float v) { get_spine_constraint_data()->setOffsetRotation(v); } -float SpinePathConstraintData::get_position() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getPosition(); -} - -void SpinePathConstraintData::set_position(float v) { - SPINE_CHECK(get_spine_constraint_data(), ) - get_spine_constraint_data()->getSetupPose().setPosition(v); -} - -float SpinePathConstraintData::get_spacing() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getSpacing(); -} - -void SpinePathConstraintData::set_spacing(float v) { - SPINE_CHECK(get_spine_constraint_data(), ) - get_spine_constraint_data()->getSetupPose().setSpacing(v); -} - -float SpinePathConstraintData::get_mix_rotate() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getMixRotate(); -} - -void SpinePathConstraintData::set_mix_rotate(float v) { - SPINE_CHECK(get_spine_constraint_data(), ) - get_spine_constraint_data()->getSetupPose().setMixRotate(v); -} - -float SpinePathConstraintData::get_mix_x() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getMixX(); -} - -void SpinePathConstraintData::set_mix_x(float v) { - SPINE_CHECK(get_spine_constraint_data(), ) - get_spine_constraint_data()->getSetupPose().setMixX(v); -} - -float SpinePathConstraintData::get_mix_y() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getMixY(); -} - -void SpinePathConstraintData::set_mix_y(float v) { - SPINE_CHECK(get_spine_constraint_data(), ) - get_spine_constraint_data()->getSetupPose().setMixY(v); +Ref SpinePathConstraintData::get_setup_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_constraint_data()->getSetupPose(); + Ref pose_ref(memnew(SpinePathConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; } diff --git a/spine-godot/spine_godot/SpinePathConstraintData.h b/spine-godot/spine_godot/SpinePathConstraintData.h index 5ef7e81a9..0f224b9f6 100644 --- a/spine-godot/spine_godot/SpinePathConstraintData.h +++ b/spine-godot/spine_godot/SpinePathConstraintData.h @@ -35,6 +35,8 @@ #include "SpineSlotData.h" #include +class SpinePathConstraintPose; + class SpinePathConstraintData : public SpineConstraintData { GDCLASS(SpinePathConstraintData, SpineConstraintData) @@ -68,23 +70,5 @@ public: void set_offset_rotation(float v); - float get_position(); - - void set_position(float v); - - float get_spacing(); - - void set_spacing(float v); - - float get_mix_rotate(); - - void set_mix_rotate(float v); - - float get_mix_x(); - - void set_mix_x(float v); - - float get_mix_y(); - - void set_mix_y(float v); + Ref get_setup_pose(); }; diff --git a/spine-godot/spine_godot/SpinePathConstraintPose.cpp b/spine-godot/spine_godot/SpinePathConstraintPose.cpp new file mode 100644 index 000000000..e898d3c2d --- /dev/null +++ b/spine-godot/spine_godot/SpinePathConstraintPose.cpp @@ -0,0 +1,94 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * Copyright (c) 2013-2025, 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 "SpinePathConstraintPose.h" +#include "SpineCommon.h" + +void SpinePathConstraintPose::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_position"), &SpinePathConstraintPose::get_position); + ClassDB::bind_method(D_METHOD("set_position", "value"), &SpinePathConstraintPose::set_position); + ClassDB::bind_method(D_METHOD("get_spacing"), &SpinePathConstraintPose::get_spacing); + ClassDB::bind_method(D_METHOD("set_spacing", "value"), &SpinePathConstraintPose::set_spacing); + ClassDB::bind_method(D_METHOD("get_mix_rotate"), &SpinePathConstraintPose::get_mix_rotate); + ClassDB::bind_method(D_METHOD("set_mix_rotate", "value"), &SpinePathConstraintPose::set_mix_rotate); + ClassDB::bind_method(D_METHOD("get_mix_x"), &SpinePathConstraintPose::get_mix_x); + ClassDB::bind_method(D_METHOD("set_mix_x", "value"), &SpinePathConstraintPose::set_mix_x); + ClassDB::bind_method(D_METHOD("get_mix_y"), &SpinePathConstraintPose::get_mix_y); + ClassDB::bind_method(D_METHOD("set_mix_y", "value"), &SpinePathConstraintPose::set_mix_y); +} + +float SpinePathConstraintPose::get_position() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getPosition(); +} + +void SpinePathConstraintPose::set_position(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setPosition(value); +} + +float SpinePathConstraintPose::get_spacing() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getSpacing(); +} + +void SpinePathConstraintPose::set_spacing(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setSpacing(value); +} + +float SpinePathConstraintPose::get_mix_rotate() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMixRotate(); +} + +void SpinePathConstraintPose::set_mix_rotate(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMixRotate(value); +} + +float SpinePathConstraintPose::get_mix_x() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMixX(); +} + +void SpinePathConstraintPose::set_mix_x(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMixX(value); +} + +float SpinePathConstraintPose::get_mix_y() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMixY(); +} + +void SpinePathConstraintPose::set_mix_y(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMixY(value); +} \ No newline at end of file diff --git a/spine-godot/spine_godot/SpinePathConstraintPose.h b/spine-godot/spine_godot/SpinePathConstraintPose.h new file mode 100644 index 000000000..3f97ac192 --- /dev/null +++ b/spine-godot/spine_godot/SpinePathConstraintPose.h @@ -0,0 +1,68 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * Copyright (c) 2013-2025, 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 "spine-cpp/include/spine/PathConstraintPose.h" +#include + +class SpineSprite; + +class SpinePathConstraintPose : public SpineObjectWrapper { + GDCLASS(SpinePathConstraintPose, SpineObjectWrapper) + +protected: + static void _bind_methods(); + +public: + // Can be used by both SpineSprite and SpineSkeletonDataResource + void set_spine_object(void *owner, spine::PathConstraintPose *object) { + _set_spine_object_internal(owner, object); + } + + spine::PathConstraintPose *get_spine_object() { + return (spine::PathConstraintPose *) _get_spine_object_internal(); + } + + float get_position(); + void set_position(float value); + + float get_spacing(); + void set_spacing(float value); + + float get_mix_rotate(); + void set_mix_rotate(float value); + + float get_mix_x(); + void set_mix_x(float value); + + float get_mix_y(); + void set_mix_y(float value); +}; \ No newline at end of file diff --git a/spine-godot/spine_godot/SpinePhysicsConstraint.cpp b/spine-godot/spine_godot/SpinePhysicsConstraint.cpp index c546a4393..5548ab3bb 100644 --- a/spine-godot/spine_godot/SpinePhysicsConstraint.cpp +++ b/spine-godot/spine_godot/SpinePhysicsConstraint.cpp @@ -28,26 +28,17 @@ *****************************************************************************/ #include "SpinePhysicsConstraint.h" +#include "SpinePhysicsConstraintPose.h" #include "SpineCommon.h" #include "SpineSprite.h" void SpinePhysicsConstraint::_bind_methods() { ClassDB::bind_method(D_METHOD("update", "skeleton", "physics"), &SpinePhysicsConstraint::update); + ClassDB::bind_method(D_METHOD("get_data"), &SpinePhysicsConstraint::get_data); ClassDB::bind_method(D_METHOD("get_bone"), &SpinePhysicsConstraint::get_bone); - ClassDB::bind_method(D_METHOD("set_inertia", "value"), &SpinePhysicsConstraint::set_inertia); - ClassDB::bind_method(D_METHOD("get_inertia"), &SpinePhysicsConstraint::get_inertia); - ClassDB::bind_method(D_METHOD("set_strength", "value"), &SpinePhysicsConstraint::set_strength); - ClassDB::bind_method(D_METHOD("get_strength"), &SpinePhysicsConstraint::get_strength); - ClassDB::bind_method(D_METHOD("set_damping", "value"), &SpinePhysicsConstraint::set_damping); - ClassDB::bind_method(D_METHOD("get_damping"), &SpinePhysicsConstraint::get_damping); - ClassDB::bind_method(D_METHOD("set_mass_inverse", "value"), &SpinePhysicsConstraint::set_mass_inverse); - ClassDB::bind_method(D_METHOD("get_mass_inverse"), &SpinePhysicsConstraint::get_mass_inverse); - ClassDB::bind_method(D_METHOD("set_wind", "value"), &SpinePhysicsConstraint::set_wind); - ClassDB::bind_method(D_METHOD("get_wind"), &SpinePhysicsConstraint::get_wind); - ClassDB::bind_method(D_METHOD("set_gravity", "value"), &SpinePhysicsConstraint::set_gravity); - ClassDB::bind_method(D_METHOD("get_gravity"), &SpinePhysicsConstraint::get_gravity); - ClassDB::bind_method(D_METHOD("set_mix", "value"), &SpinePhysicsConstraint::set_mix); - ClassDB::bind_method(D_METHOD("get_mix"), &SpinePhysicsConstraint::get_mix); + ClassDB::bind_method(D_METHOD("set_bone", "v"), &SpinePhysicsConstraint::set_bone); + ClassDB::bind_method(D_METHOD("get_pose"), &SpinePhysicsConstraint::get_pose); + ClassDB::bind_method(D_METHOD("get_applied_pose"), &SpinePhysicsConstraint::get_applied_pose); ClassDB::bind_method(D_METHOD("reset", "skeleton"), &SpinePhysicsConstraint::reset); ClassDB::bind_method(D_METHOD("translate", "x", "y"), &SpinePhysicsConstraint::translate); ClassDB::bind_method(D_METHOD("rotate", "x", "y", "degrees"), &SpinePhysicsConstraint::rotate); @@ -66,90 +57,36 @@ Ref SpinePhysicsConstraint::get_data() { return data_ref; } -Ref SpinePhysicsConstraint::get_bone() { +Ref SpinePhysicsConstraint::get_bone() { SPINE_CHECK(get_spine_object(), nullptr) auto target = &get_spine_object()->getBone(); if (!target) return nullptr; - Ref target_ref(memnew(SpineBone)); + Ref target_ref(memnew(SpineBonePose)); target_ref->set_spine_object(get_spine_owner(), target); return target_ref; } -void SpinePhysicsConstraint::set_bone(Ref v) { +void SpinePhysicsConstraint::set_bone(Ref v) { SPINE_CHECK(get_spine_object(), ) if (v.is_valid() && v->get_spine_object()) { - get_spine_object()->setBone(v->get_spine_object()); + get_spine_object()->setBone(*v->get_spine_object()); } } -void SpinePhysicsConstraint::set_inertia(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setInertia(value); +Ref SpinePhysicsConstraint::get_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_object()->getPose(); + Ref pose_ref(memnew(SpinePhysicsConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; } -float SpinePhysicsConstraint::get_inertia() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getInertia(); -} - -void SpinePhysicsConstraint::set_strength(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setStrength(value); -} - -float SpinePhysicsConstraint::get_strength() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getStrength(); -} - -void SpinePhysicsConstraint::set_damping(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setDamping(value); -} - -float SpinePhysicsConstraint::get_damping() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getDamping(); -} - -void SpinePhysicsConstraint::set_mass_inverse(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setMassInverse(value); -} - -float SpinePhysicsConstraint::get_mass_inverse() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getMassInverse(); -} - -void SpinePhysicsConstraint::set_wind(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setWind(value); -} - -float SpinePhysicsConstraint::get_wind() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getWind(); -} - -void SpinePhysicsConstraint::set_gravity(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setGravity(value); -} - -float SpinePhysicsConstraint::get_gravity() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getGravity(); -} - -void SpinePhysicsConstraint::set_mix(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setMix(value); -} - -float SpinePhysicsConstraint::get_mix() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getPose().getMix(); +Ref SpinePhysicsConstraint::get_applied_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_object()->getAppliedPose(); + Ref pose_ref(memnew(SpinePhysicsConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; } void SpinePhysicsConstraint::reset(Ref skeleton) { diff --git a/spine-godot/spine_godot/SpinePhysicsConstraint.h b/spine-godot/spine_godot/SpinePhysicsConstraint.h index 2f19ba6c0..ee12fd6ca 100644 --- a/spine-godot/spine_godot/SpinePhysicsConstraint.h +++ b/spine-godot/spine_godot/SpinePhysicsConstraint.h @@ -34,6 +34,8 @@ #include "SpineBone.h" #include +class SpinePhysicsConstraintPose; + class SpinePhysicsConstraint : public SpineSpriteOwnedObject { GDCLASS(SpinePhysicsConstraint, SpineObjectWrapper) @@ -45,30 +47,11 @@ public: Ref get_data(); - Ref get_bone(); + Ref get_bone(); + void set_bone(Ref v); - void set_bone(Ref v); - - void set_inertia(float value); - float get_inertia(); - - void set_strength(float value); - float get_strength(); - - void set_damping(float value); - float get_damping(); - - void set_mass_inverse(float value); - float get_mass_inverse(); - - void set_wind(float value); - float get_wind(); - - void set_gravity(float value); - float get_gravity(); - - void set_mix(float value); - float get_mix(); + Ref get_pose(); + Ref get_applied_pose(); void reset(Ref skeleton); diff --git a/spine-godot/spine_godot/SpinePhysicsConstraintData.cpp b/spine-godot/spine_godot/SpinePhysicsConstraintData.cpp index fa8fbd8c4..a019c43b8 100644 --- a/spine-godot/spine_godot/SpinePhysicsConstraintData.cpp +++ b/spine-godot/spine_godot/SpinePhysicsConstraintData.cpp @@ -28,21 +28,18 @@ *****************************************************************************/ #include "SpinePhysicsConstraintData.h" +#include "SpinePhysicsConstraintPose.h" #include "SpineCommon.h" void SpinePhysicsConstraintData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_bone"), &SpinePhysicsConstraintData::get_bone); + ClassDB::bind_method(D_METHOD("get_x"), &SpinePhysicsConstraintData::get_x); + ClassDB::bind_method(D_METHOD("get_y"), &SpinePhysicsConstraintData::get_y); + ClassDB::bind_method(D_METHOD("get_rotate"), &SpinePhysicsConstraintData::get_rotate); ClassDB::bind_method(D_METHOD("get_scale_x"), &SpinePhysicsConstraintData::get_scale_x); ClassDB::bind_method(D_METHOD("get_shear_x"), &SpinePhysicsConstraintData::get_shear_x); ClassDB::bind_method(D_METHOD("get_limit"), &SpinePhysicsConstraintData::get_limit); ClassDB::bind_method(D_METHOD("get_step"), &SpinePhysicsConstraintData::get_step); - ClassDB::bind_method(D_METHOD("get_inertia"), &SpinePhysicsConstraintData::get_inertia); - ClassDB::bind_method(D_METHOD("get_strength"), &SpinePhysicsConstraintData::get_strength); - ClassDB::bind_method(D_METHOD("get_damping"), &SpinePhysicsConstraintData::get_damping); - ClassDB::bind_method(D_METHOD("get_mass_inverse"), &SpinePhysicsConstraintData::get_mass_inverse); - ClassDB::bind_method(D_METHOD("get_wind"), &SpinePhysicsConstraintData::get_wind); - ClassDB::bind_method(D_METHOD("get_gravity"), &SpinePhysicsConstraintData::get_gravity); - ClassDB::bind_method(D_METHOD("get_mix"), &SpinePhysicsConstraintData::get_mix); ClassDB::bind_method(D_METHOD("is_inertia_global"), &SpinePhysicsConstraintData::is_inertia_global); ClassDB::bind_method(D_METHOD("is_strength_global"), &SpinePhysicsConstraintData::is_strength_global); ClassDB::bind_method(D_METHOD("is_damping_global"), &SpinePhysicsConstraintData::is_damping_global); @@ -50,6 +47,7 @@ void SpinePhysicsConstraintData::_bind_methods() { ClassDB::bind_method(D_METHOD("is_wind_global"), &SpinePhysicsConstraintData::is_wind_global); ClassDB::bind_method(D_METHOD("is_gravity_global"), &SpinePhysicsConstraintData::is_gravity_global); ClassDB::bind_method(D_METHOD("is_mix_global"), &SpinePhysicsConstraintData::is_mix_global); + ClassDB::bind_method(D_METHOD("get_setup_pose"), &SpinePhysicsConstraintData::get_setup_pose); } @@ -82,40 +80,21 @@ float SpinePhysicsConstraintData::get_step() { return get_spine_constraint_data()->getStep(); } -float SpinePhysicsConstraintData::get_inertia() { +float SpinePhysicsConstraintData::get_x() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getInertia(); + return get_spine_constraint_data()->getX(); } -float SpinePhysicsConstraintData::get_strength() { +float SpinePhysicsConstraintData::get_y() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getStrength(); + return get_spine_constraint_data()->getY(); } -float SpinePhysicsConstraintData::get_damping() { +float SpinePhysicsConstraintData::get_rotate() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getDamping(); + return get_spine_constraint_data()->getRotate(); } -float SpinePhysicsConstraintData::get_mass_inverse() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getMassInverse(); -} - -float SpinePhysicsConstraintData::get_wind() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getWind(); -} - -float SpinePhysicsConstraintData::get_gravity() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getGravity(); -} - -float SpinePhysicsConstraintData::get_mix() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getMix(); -} bool SpinePhysicsConstraintData::is_inertia_global() { SPINE_CHECK(get_spine_constraint_data(), false) @@ -151,3 +130,11 @@ bool SpinePhysicsConstraintData::is_mix_global() { SPINE_CHECK(get_spine_constraint_data(), false) return get_spine_constraint_data()->getMixGlobal(); } + +Ref SpinePhysicsConstraintData::get_setup_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_constraint_data()->getSetupPose(); + Ref pose_ref(memnew(SpinePhysicsConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; +} diff --git a/spine-godot/spine_godot/SpinePhysicsConstraintData.h b/spine-godot/spine_godot/SpinePhysicsConstraintData.h index 411b05481..1338c7827 100644 --- a/spine-godot/spine_godot/SpinePhysicsConstraintData.h +++ b/spine-godot/spine_godot/SpinePhysicsConstraintData.h @@ -33,6 +33,8 @@ #include "SpineBoneData.h" #include +class SpinePhysicsConstraintPose; + class SpinePhysicsConstraintData : public SpineConstraintData { GDCLASS(SpinePhysicsConstraintData, SpineConstraintData) @@ -60,20 +62,6 @@ public: float get_step(); - float get_inertia(); - - float get_strength(); - - float get_damping(); - - float get_mass_inverse(); - - float get_wind(); - - float get_gravity(); - - float get_mix(); - bool is_inertia_global(); bool is_strength_global(); @@ -87,4 +75,6 @@ public: bool is_gravity_global(); bool is_mix_global(); + + Ref get_setup_pose(); }; diff --git a/spine-godot/spine_godot/SpinePhysicsConstraintPose.cpp b/spine-godot/spine_godot/SpinePhysicsConstraintPose.cpp new file mode 100644 index 000000000..e1bbb95a9 --- /dev/null +++ b/spine-godot/spine_godot/SpinePhysicsConstraintPose.cpp @@ -0,0 +1,118 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * Copyright (c) 2013-2025, 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 "SpinePhysicsConstraintPose.h" +#include "SpineCommon.h" + +void SpinePhysicsConstraintPose::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_inertia"), &SpinePhysicsConstraintPose::get_inertia); + ClassDB::bind_method(D_METHOD("set_inertia", "value"), &SpinePhysicsConstraintPose::set_inertia); + ClassDB::bind_method(D_METHOD("get_strength"), &SpinePhysicsConstraintPose::get_strength); + ClassDB::bind_method(D_METHOD("set_strength", "value"), &SpinePhysicsConstraintPose::set_strength); + ClassDB::bind_method(D_METHOD("get_damping"), &SpinePhysicsConstraintPose::get_damping); + ClassDB::bind_method(D_METHOD("set_damping", "value"), &SpinePhysicsConstraintPose::set_damping); + ClassDB::bind_method(D_METHOD("get_mass_inverse"), &SpinePhysicsConstraintPose::get_mass_inverse); + ClassDB::bind_method(D_METHOD("set_mass_inverse", "value"), &SpinePhysicsConstraintPose::set_mass_inverse); + ClassDB::bind_method(D_METHOD("get_wind"), &SpinePhysicsConstraintPose::get_wind); + ClassDB::bind_method(D_METHOD("set_wind", "value"), &SpinePhysicsConstraintPose::set_wind); + ClassDB::bind_method(D_METHOD("get_gravity"), &SpinePhysicsConstraintPose::get_gravity); + ClassDB::bind_method(D_METHOD("set_gravity", "value"), &SpinePhysicsConstraintPose::set_gravity); + ClassDB::bind_method(D_METHOD("get_mix"), &SpinePhysicsConstraintPose::get_mix); + ClassDB::bind_method(D_METHOD("set_mix", "value"), &SpinePhysicsConstraintPose::set_mix); +} + +float SpinePhysicsConstraintPose::get_inertia() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getInertia(); +} + +void SpinePhysicsConstraintPose::set_inertia(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setInertia(value); +} + +float SpinePhysicsConstraintPose::get_strength() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getStrength(); +} + +void SpinePhysicsConstraintPose::set_strength(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setStrength(value); +} + +float SpinePhysicsConstraintPose::get_damping() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getDamping(); +} + +void SpinePhysicsConstraintPose::set_damping(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setDamping(value); +} + +float SpinePhysicsConstraintPose::get_mass_inverse() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMassInverse(); +} + +void SpinePhysicsConstraintPose::set_mass_inverse(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMassInverse(value); +} + +float SpinePhysicsConstraintPose::get_wind() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getWind(); +} + +void SpinePhysicsConstraintPose::set_wind(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setWind(value); +} + +float SpinePhysicsConstraintPose::get_gravity() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getGravity(); +} + +void SpinePhysicsConstraintPose::set_gravity(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setGravity(value); +} + +float SpinePhysicsConstraintPose::get_mix() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMix(); +} + +void SpinePhysicsConstraintPose::set_mix(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMix(value); +} \ No newline at end of file diff --git a/spine-godot/spine_godot/SpinePhysicsConstraintPose.h b/spine-godot/spine_godot/SpinePhysicsConstraintPose.h new file mode 100644 index 000000000..9a9c60508 --- /dev/null +++ b/spine-godot/spine_godot/SpinePhysicsConstraintPose.h @@ -0,0 +1,74 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * Copyright (c) 2013-2025, 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 "spine-cpp/include/spine/PhysicsConstraintPose.h" +#include + +class SpineSprite; + +class SpinePhysicsConstraintPose : public SpineObjectWrapper { + GDCLASS(SpinePhysicsConstraintPose, SpineObjectWrapper) + +protected: + static void _bind_methods(); + +public: + // Can be used by both SpineSprite and SpineSkeletonDataResource + void set_spine_object(void *owner, spine::PhysicsConstraintPose *object) { + _set_spine_object_internal(owner, object); + } + + spine::PhysicsConstraintPose *get_spine_object() { + return (spine::PhysicsConstraintPose *) _get_spine_object_internal(); + } + + float get_inertia(); + void set_inertia(float value); + + float get_strength(); + void set_strength(float value); + + float get_damping(); + void set_damping(float value); + + float get_mass_inverse(); + void set_mass_inverse(float value); + + float get_wind(); + void set_wind(float value); + + float get_gravity(); + void set_gravity(float value); + + float get_mix(); + void set_mix(float value); +}; \ No newline at end of file diff --git a/spine-godot/spine_godot/SpineSkeleton.cpp b/spine-godot/spine_godot/SpineSkeleton.cpp index 3b525d13e..b4f46e9bc 100644 --- a/spine-godot/spine_godot/SpineSkeleton.cpp +++ b/spine-godot/spine_godot/SpineSkeleton.cpp @@ -30,6 +30,10 @@ #include "SpineSkeleton.h" #include "SpineCommon.h" #include "SpineSprite.h" +#include "SpineIkConstraint.h" +#include "SpineTransformConstraint.h" +#include "SpinePathConstraint.h" +#include "SpinePhysicsConstraint.h" #include "spine/IkConstraint.h" #include "spine/PathConstraint.h" #include "spine/PhysicsConstraint.h" diff --git a/spine-godot/spine_godot/SpineSkeleton.h b/spine-godot/spine_godot/SpineSkeleton.h index e3d7893b7..87b127aa1 100644 --- a/spine-godot/spine_godot/SpineSkeleton.h +++ b/spine-godot/spine_godot/SpineSkeleton.h @@ -33,14 +33,15 @@ #include "SpineSkeletonDataResource.h" #include "SpineBone.h" #include "SpineSlot.h" -#include "SpineIkConstraint.h" -#include "SpineTransformConstraint.h" -#include "SpinePathConstraint.h" -#include "SpinePhysicsConstraint.h" #include +// Forward declarations to avoid circular includes class SpineSprite; +class SpineIkConstraint; +class SpineTransformConstraint; +class SpinePathConstraint; +class SpinePhysicsConstraint; class SpineSkeleton : public REFCOUNTED { GDCLASS(SpineSkeleton, REFCOUNTED); diff --git a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp index 673ac98ff..fec05a063 100644 --- a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp +++ b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp @@ -629,7 +629,7 @@ Array SpineSkeletonDataResource::get_ik_constraints() const { result.resize((int) constraints.size()); int size = 0; for (int i = 0; i < constraints.size(); ++i) { - if (!constraints[i].getRtti().isExactly(spine::IkConstraintData::rtti)) continue; + if (!constraints[i]->getRTTI().isExactly(spine::IkConstraintData::rtti)) continue; Ref constraint_ref(memnew(SpineIkConstraintData)); constraint_ref->set_spine_object(this, constraints[i]); result[i] = constraint_ref; @@ -646,7 +646,7 @@ Array SpineSkeletonDataResource::get_transform_constraints() const { result.resize((int) constraints.size()); int size = 0; for (int i = 0; i < constraints.size(); ++i) { - if (!constraints[i].getRtti().isExactly(spine::TransformConstraintData::rtti)) continue; + if (!constraints[i]->getRTTI().isExactly(spine::TransformConstraintData::rtti)) continue; Ref constraint_ref(memnew(SpineTransformConstraintData)); constraint_ref->set_spine_object(this, constraints[i]); result[i] = constraint_ref; @@ -663,7 +663,7 @@ Array SpineSkeletonDataResource::get_path_constraints() const { result.resize((int) constraints.size()); int size = 0; for (int i = 0; i < constraints.size(); ++i) { - if (!constraints[i].getRtti().isExactly(spine::PathConstraintData::rtti)) continue; + if (!constraints[i]->getRTTI().isExactly(spine::PathConstraintData::rtti)) continue; Ref constraint_ref(memnew(SpinePathConstraintData)); constraint_ref->set_spine_object(this, constraints[i]); result[i] = constraint_ref; @@ -680,7 +680,7 @@ Array SpineSkeletonDataResource::get_physics_constraints() const { result.resize((int) constraints.size()); int size = 0; for (int i = 0; i < constraints.size(); ++i) { - if (!constraints[i].getRtti().isExactly(spine::PhysicsConstraintData::rtti)) continue; + if (!constraints[i]->getRTTI().isExactly(spine::PhysicsConstraintData::rtti)) continue; Ref constraint_ref(memnew(SpinePhysicsConstraintData)); constraint_ref->set_spine_object(this, constraints[i]); result[i] = constraint_ref; diff --git a/spine-godot/spine_godot/SpineSliderPose.cpp b/spine-godot/spine_godot/SpineSliderPose.cpp new file mode 100644 index 000000000..51c2c4aae --- /dev/null +++ b/spine-godot/spine_godot/SpineSliderPose.cpp @@ -0,0 +1,58 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * Copyright (c) 2013-2025, 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 "SpineSliderPose.h" +#include "SpineCommon.h" + +void SpineSliderPose::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_time"), &SpineSliderPose::get_time); + ClassDB::bind_method(D_METHOD("set_time", "value"), &SpineSliderPose::set_time); + ClassDB::bind_method(D_METHOD("get_mix"), &SpineSliderPose::get_mix); + ClassDB::bind_method(D_METHOD("set_mix", "value"), &SpineSliderPose::set_mix); +} + +float SpineSliderPose::get_time() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getTime(); +} + +void SpineSliderPose::set_time(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setTime(value); +} + +float SpineSliderPose::get_mix() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMix(); +} + +void SpineSliderPose::set_mix(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMix(value); +} \ No newline at end of file diff --git a/spine-godot/spine_godot/SpineSliderPose.h b/spine-godot/spine_godot/SpineSliderPose.h new file mode 100644 index 000000000..959561224 --- /dev/null +++ b/spine-godot/spine_godot/SpineSliderPose.h @@ -0,0 +1,58 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * Copyright (c) 2013-2025, 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 + +class SpineSprite; + +class SpineSliderPose : public SpineObjectWrapper { + GDCLASS(SpineSliderPose, SpineObjectWrapper) + +protected: + static void _bind_methods(); + +public: + // Can be used by both SpineSprite and SpineSkeletonDataResource + void set_spine_object(void *owner, spine::SliderPose *object) { + _set_spine_object_internal(owner, object); + } + + spine::SliderPose *get_spine_object() { + return (spine::SliderPose *) _get_spine_object_internal(); + } + + float get_time(); + void set_time(float value); + + float get_mix(); + void set_mix(float value); +}; \ No newline at end of file diff --git a/spine-godot/spine_godot/SpineSlot.cpp b/spine-godot/spine_godot/SpineSlot.cpp index e5ebd1a55..45e61bd5c 100644 --- a/spine-godot/spine_godot/SpineSlot.cpp +++ b/spine-godot/spine_godot/SpineSlot.cpp @@ -37,19 +37,6 @@ void SpineSlot::_bind_methods() { ClassDB::bind_method(D_METHOD("set_to_setup_pose"), &SpineSlot::set_to_setup_pose); ClassDB::bind_method(D_METHOD("get_data"), &SpineSlot::get_data); ClassDB::bind_method(D_METHOD("get_bone"), &SpineSlot::get_bone); - ClassDB::bind_method(D_METHOD("get_color"), &SpineSlot::get_color); - ClassDB::bind_method(D_METHOD("set_color"), &SpineSlot::set_color); - ClassDB::bind_method(D_METHOD("get_dark_color"), &SpineSlot::get_dark_color); - ClassDB::bind_method(D_METHOD("set_dark_color", "v"), &SpineSlot::set_dark_color); - ClassDB::bind_method(D_METHOD("has_dark_color"), &SpineSlot::has_dark_color); - ClassDB::bind_method(D_METHOD("get_attachment"), &SpineSlot::get_attachment); - ClassDB::bind_method(D_METHOD("set_attachment", "v"), &SpineSlot::set_attachment); - ClassDB::bind_method(D_METHOD("get_attachment_state"), &SpineSlot::get_attachment_state); - ClassDB::bind_method(D_METHOD("set_attachment_state", "v"), &SpineSlot::set_attachment_state); - ClassDB::bind_method(D_METHOD("get_deform"), &SpineSlot::get_deform); - ClassDB::bind_method(D_METHOD("set_deform", "v"), &SpineSlot::set_deform); - ClassDB::bind_method(D_METHOD("get_sequence_index"), &SpineSlot::get_sequence_index); - ClassDB::bind_method(D_METHOD("set_sequence_index", "v"), &SpineSlot::set_sequence_index); ClassDB::bind_method(D_METHOD("get_pose"), &SpineSlot::get_pose); ClassDB::bind_method(D_METHOD("get_applied_pose"), &SpineSlot::get_applied_pose); } @@ -85,88 +72,6 @@ Ref SpineSlot::get_bone() { } } -Color SpineSlot::get_color() { - SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0)) - auto &color = get_spine_object()->getAppliedPose().getColor(); - return Color(color.r, color.g, color.b, color.a); -} - -void SpineSlot::set_color(Color v) { - SPINE_CHECK(get_spine_object(), ) - auto &color = get_spine_object()->getPose().getColor(); - color.set(v.r, v.g, v.b, v.a); -} - -Color SpineSlot::get_dark_color() { - SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0)) - auto &color = get_spine_object()->getAppliedPose().getDarkColor(); - return Color(color.r, color.g, color.b, color.a); -} - -void SpineSlot::set_dark_color(Color v) { - SPINE_CHECK(get_spine_object(), ) - auto &color = get_spine_object()->getPose().getDarkColor(); - color.set(v.r, v.g, v.b, v.a); -} - -bool SpineSlot::has_dark_color() { - SPINE_CHECK(get_spine_object(), false) - return get_spine_object()->getAppliedPose().hasDarkColor(); -} - -Ref SpineSlot::get_attachment() { - SPINE_CHECK(get_spine_object(), nullptr) - auto attachment = get_spine_object()->getAppliedPose().getAttachment(); - if (!attachment) return nullptr; - Ref attachment_ref(memnew(SpineAttachment)); - attachment_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), attachment); - return attachment_ref; -} - -void SpineSlot::set_attachment(Ref v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setAttachment(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr); -} - -int SpineSlot::get_attachment_state() { - // TODO: attachmentState is no longer exposed in the new API - SPINE_CHECK(get_spine_object(), 0) - return 0; -} - -void SpineSlot::set_attachment_state(int v){// TODO: attachmentState is no longer exposed in the new API - SPINE_CHECK(get_spine_object(), )} - -Array SpineSlot::get_deform() { - Array result; - SPINE_CHECK(get_spine_object(), result) - auto &deform = get_spine_object()->getAppliedPose().getDeform(); - result.resize((int) deform.size()); - for (int i = 0; i < (int) deform.size(); ++i) { - result[i] = deform[i]; - } - return result; -} - -void SpineSlot::set_deform(Array v) { - SPINE_CHECK(get_spine_object(), ) - auto &deform = get_spine_object()->getPose().getDeform(); - deform.setSize(v.size(), 0); - for (int i = 0; i < v.size(); ++i) { - deform[i] = v[i]; - } -} - -int SpineSlot::get_sequence_index() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getAppliedPose().getSequenceIndex(); -} - -void SpineSlot::set_sequence_index(int v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->getPose().setSequenceIndex(v); -} - Ref SpineSlot::get_pose() { SPINE_CHECK(get_spine_object(), nullptr) auto &pose = get_spine_object()->getPose(); diff --git a/spine-godot/spine_godot/SpineSlot.h b/spine-godot/spine_godot/SpineSlot.h index 1fb89bed2..296946856 100644 --- a/spine-godot/spine_godot/SpineSlot.h +++ b/spine-godot/spine_godot/SpineSlot.h @@ -56,32 +56,6 @@ public: Ref get_bone(); - Color get_color(); - - void set_color(Color v); - - Color get_dark_color(); - - void set_dark_color(Color v); - - bool has_dark_color(); - - Ref get_attachment(); - - void set_attachment(Ref v); - - int get_attachment_state(); - - void set_attachment_state(int v); - - Array get_deform(); - - void set_deform(Array v); - - int get_sequence_index(); - - void set_sequence_index(int v); - Ref get_pose(); Ref get_applied_pose(); diff --git a/spine-godot/spine_godot/SpineTimeline.cpp b/spine-godot/spine_godot/SpineTimeline.cpp index c323e3b1c..dee19b706 100644 --- a/spine-godot/spine_godot/SpineTimeline.cpp +++ b/spine-godot/spine_godot/SpineTimeline.cpp @@ -45,16 +45,16 @@ void SpineTimeline::_bind_methods() { } void SpineTimeline::apply(Ref skeleton, float last_time, float time, Array events, float alpha, SpineConstant::MixBlend blend, - SpineConstant::MixDirection direction) { + SpineConstant::MixDirection direction, bool applied_pose) { SPINE_CHECK(get_spine_object(), ) if (!skeleton->get_spine_object()) return; - spine::Vector spine_events; + spine::Array spine_events; spine_events.setSize((int) events.size(), nullptr); for (int i = 0; i < events.size(); ++i) { events[i] = ((Ref) spine_events[i])->get_spine_object(); } get_spine_object()->apply(*(skeleton->get_spine_object()), last_time, time, &spine_events, alpha, (spine::MixBlend) blend, - (spine::MixDirection) direction); + (spine::MixDirection) direction, applied_pose); } int SpineTimeline::get_frame_entries() { diff --git a/spine-godot/spine_godot/SpineTimeline.h b/spine-godot/spine_godot/SpineTimeline.h index 0eb82e1a3..c4613ad7b 100644 --- a/spine-godot/spine_godot/SpineTimeline.h +++ b/spine-godot/spine_godot/SpineTimeline.h @@ -46,7 +46,7 @@ protected: public: void apply(Ref skeleton, float last_time, float time, Array events, float alpha, SpineConstant::MixBlend blend, - SpineConstant::MixDirection direction); + SpineConstant::MixDirection direction, bool applied_pose); int get_frame_entries(); diff --git a/spine-godot/spine_godot/SpineTransformConstraint.cpp b/spine-godot/spine_godot/SpineTransformConstraint.cpp index 37450909f..9c715f113 100644 --- a/spine-godot/spine_godot/SpineTransformConstraint.cpp +++ b/spine-godot/spine_godot/SpineTransformConstraint.cpp @@ -28,6 +28,7 @@ *****************************************************************************/ #include "SpineTransformConstraint.h" +#include "SpineTransformConstraintPose.h" #include "SpineCommon.h" #include "SpineSkeleton.h" #include "SpineSprite.h" @@ -36,20 +37,10 @@ void SpineTransformConstraint::_bind_methods() { ClassDB::bind_method(D_METHOD("update", "skeleton"), &SpineTransformConstraint::update); ClassDB::bind_method(D_METHOD("get_data"), &SpineTransformConstraint::get_data); ClassDB::bind_method(D_METHOD("get_bones"), &SpineTransformConstraint::get_bones); - ClassDB::bind_method(D_METHOD("get_target"), &SpineTransformConstraint::get_target); - ClassDB::bind_method(D_METHOD("set_target", "v"), &SpineTransformConstraint::set_target); - ClassDB::bind_method(D_METHOD("get_mix_rotate"), &SpineTransformConstraint::get_mix_rotate); - ClassDB::bind_method(D_METHOD("set_mix_rotate", "v"), &SpineTransformConstraint::set_mix_rotate); - ClassDB::bind_method(D_METHOD("get_mix_x"), &SpineTransformConstraint::get_mix_x); - ClassDB::bind_method(D_METHOD("set_mix_x", "v"), &SpineTransformConstraint::set_mix_x); - ClassDB::bind_method(D_METHOD("get_mix_y"), &SpineTransformConstraint::get_mix_y); - ClassDB::bind_method(D_METHOD("set_mix_y", "v"), &SpineTransformConstraint::set_mix_y); - ClassDB::bind_method(D_METHOD("get_mix_scale_x"), &SpineTransformConstraint::get_mix_scale_x); - ClassDB::bind_method(D_METHOD("set_mix_scale_x", "v"), &SpineTransformConstraint::set_mix_scale_x); - ClassDB::bind_method(D_METHOD("get_mix_scale_y"), &SpineTransformConstraint::get_mix_scale_y); - ClassDB::bind_method(D_METHOD("set_mix_scale_y", "v"), &SpineTransformConstraint::set_mix_scale_y); - ClassDB::bind_method(D_METHOD("get_mix_shear_y"), &SpineTransformConstraint::get_mix_shear_y); - ClassDB::bind_method(D_METHOD("set_mix_shear_y", "v"), &SpineTransformConstraint::set_mix_shear_y); + ClassDB::bind_method(D_METHOD("get_source"), &SpineTransformConstraint::get_source); + ClassDB::bind_method(D_METHOD("set_source", "v"), &SpineTransformConstraint::set_source); + ClassDB::bind_method(D_METHOD("get_pose"), &SpineTransformConstraint::get_pose); + ClassDB::bind_method(D_METHOD("get_applied_pose"), &SpineTransformConstraint::get_applied_pose); ClassDB::bind_method(D_METHOD("is_active"), &SpineTransformConstraint::is_active); ClassDB::bind_method(D_METHOD("set_active", "v"), &SpineTransformConstraint::set_active); } @@ -74,85 +65,43 @@ Array SpineTransformConstraint::get_bones() { result.resize((int) bones.size()); for (int i = 0; i < bones.size(); ++i) { auto bone = bones[i]; - Ref bone_ref(memnew(SpineBone)); + Ref bone_ref(memnew(SpineBonePose)); bone_ref->set_spine_object(get_spine_owner(), bone); result[i] = bone_ref; } return result; } -Ref SpineTransformConstraint::get_target() { +Ref SpineTransformConstraint::get_source() { SPINE_CHECK(get_spine_object(), nullptr) - auto target = get_spine_object()->getTarget(); - if (!target) return nullptr; + auto source = &get_spine_object()->getSource(); + if (!source) return nullptr; Ref target_ref(memnew(SpineBone)); - target_ref->set_spine_object(get_spine_owner(), target); + target_ref->set_spine_object(get_spine_owner(), source); return target_ref; } -void SpineTransformConstraint::set_target(Ref v) { +void SpineTransformConstraint::set_source(Ref v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr); + if (v.is_valid() && v->get_spine_object()) { + get_spine_object()->setSource(*v->get_spine_object()); + } } -float SpineTransformConstraint::get_mix_rotate() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMixRotate(); +Ref SpineTransformConstraint::get_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_object()->getPose(); + Ref pose_ref(memnew(SpineTransformConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; } -void SpineTransformConstraint::set_mix_rotate(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMixRotate(v); -} - -float SpineTransformConstraint::get_mix_x() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMixX(); -} - -void SpineTransformConstraint::set_mix_x(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMixX(v); -} - -float SpineTransformConstraint::get_mix_y() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMixY(); -} - -void SpineTransformConstraint::set_mix_y(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMixY(v); -} - -float SpineTransformConstraint::get_mix_scale_x() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMixScaleX(); -} - -void SpineTransformConstraint::set_mix_scale_x(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMixScaleX(v); -} - -float SpineTransformConstraint::get_mix_scale_y() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMixScaleY(); -} - -void SpineTransformConstraint::set_mix_scale_y(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMixScaleY(v); -} - -float SpineTransformConstraint::get_mix_shear_y() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMixShearY(); -} - -void SpineTransformConstraint::set_mix_shear_y(float v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMixShearY(v); +Ref SpineTransformConstraint::get_applied_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_object()->getAppliedPose(); + Ref pose_ref(memnew(SpineTransformConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; } bool SpineTransformConstraint::is_active() { diff --git a/spine-godot/spine_godot/SpineTransformConstraint.h b/spine-godot/spine_godot/SpineTransformConstraint.h index e47b0759d..7853d932d 100644 --- a/spine-godot/spine_godot/SpineTransformConstraint.h +++ b/spine-godot/spine_godot/SpineTransformConstraint.h @@ -35,6 +35,8 @@ #include "SpineBone.h" #include +class SpineTransformConstraintPose; + class SpineTransformConstraint : public SpineSpriteOwnedObject { GDCLASS(SpineTransformConstraint, SpineObjectWrapper) @@ -48,33 +50,13 @@ public: Array get_bones(); - Ref get_target(); + Ref get_source(); - void set_target(Ref v); + void set_source(Ref v); - float get_mix_rotate(); + Ref get_pose(); - void set_mix_rotate(float v); - - float get_mix_x(); - - void set_mix_x(float v); - - float get_mix_y(); - - void set_mix_y(float v); - - float get_mix_scale_x(); - - void set_mix_scale_x(float v); - - float get_mix_scale_y(); - - void set_mix_scale_y(float v); - - float get_mix_shear_y(); - - void set_mix_shear_y(float v); + Ref get_applied_pose(); bool is_active(); diff --git a/spine-godot/spine_godot/SpineTransformConstraintData.cpp b/spine-godot/spine_godot/SpineTransformConstraintData.cpp index a86a32b86..bd519c7d4 100644 --- a/spine-godot/spine_godot/SpineTransformConstraintData.cpp +++ b/spine-godot/spine_godot/SpineTransformConstraintData.cpp @@ -28,23 +28,21 @@ *****************************************************************************/ #include "SpineTransformConstraintData.h" +#include "SpineTransformConstraintPose.h" #include "SpineCommon.h" void SpineTransformConstraintData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_bones"), &SpineTransformConstraintData::get_bones); - ClassDB::bind_method(D_METHOD("get_target"), &SpineTransformConstraintData::get_target); - ClassDB::bind_method(D_METHOD("get_mix_rotate"), &SpineTransformConstraintData::get_mix_rotate); - ClassDB::bind_method(D_METHOD("get_mix_x"), &SpineTransformConstraintData::get_mix_x); - ClassDB::bind_method(D_METHOD("get_mix_y"), &SpineTransformConstraintData::get_mix_y); - ClassDB::bind_method(D_METHOD("get_mix_scale_x"), &SpineTransformConstraintData::get_mix_scale_x); - ClassDB::bind_method(D_METHOD("get_mix_scale_y"), &SpineTransformConstraintData::get_mix_scale_y); - ClassDB::bind_method(D_METHOD("get_mix_shear_y"), &SpineTransformConstraintData::get_mix_shear_y); + ClassDB::bind_method(D_METHOD("get_source"), &SpineTransformConstraintData::get_source); ClassDB::bind_method(D_METHOD("get_offset_rotation"), &SpineTransformConstraintData::get_offset_rotation); ClassDB::bind_method(D_METHOD("get_offset_x"), &SpineTransformConstraintData::get_offset_x); ClassDB::bind_method(D_METHOD("get_offset_y"), &SpineTransformConstraintData::get_offset_y); ClassDB::bind_method(D_METHOD("get_offset_scale_x"), &SpineTransformConstraintData::get_offset_scale_x); ClassDB::bind_method(D_METHOD("get_offset_scale_y"), &SpineTransformConstraintData::get_offset_scale_y); ClassDB::bind_method(D_METHOD("get_offset_shear_y"), &SpineTransformConstraintData::get_offset_shear_y); + ClassDB::bind_method(D_METHOD("is_relative"), &SpineTransformConstraintData::is_relative); + ClassDB::bind_method(D_METHOD("is_local"), &SpineTransformConstraintData::is_local); + ClassDB::bind_method(D_METHOD("get_setup_pose"), &SpineTransformConstraintData::get_setup_pose); } Array SpineTransformConstraintData::get_bones() { @@ -60,45 +58,15 @@ Array SpineTransformConstraintData::get_bones() { return result; } -Ref SpineTransformConstraintData::get_target() { +Ref SpineTransformConstraintData::get_source() { SPINE_CHECK(get_spine_constraint_data(), nullptr) - auto bone = get_spine_constraint_data()->getTarget(); + auto bone = &get_spine_constraint_data()->getSource(); if (!bone) return nullptr; Ref slot_ref(memnew(SpineBoneData)); slot_ref->set_spine_object(get_spine_owner(), bone); return slot_ref; } -float SpineTransformConstraintData::get_mix_rotate() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getMixRotate(); -} - -float SpineTransformConstraintData::get_mix_x() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getMixX(); -} - -float SpineTransformConstraintData::get_mix_y() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getMixY(); -} - -float SpineTransformConstraintData::get_mix_scale_x() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getMixScaleX(); -} - -float SpineTransformConstraintData::get_mix_scale_y() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getMixScaleY(); -} - -float SpineTransformConstraintData::get_mix_shear_y() { - SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSetupPose().getMixShearY(); -} - float SpineTransformConstraintData::get_offset_rotation() { SPINE_CHECK(get_spine_constraint_data(), 0) return get_spine_constraint_data()->getOffsetRotation(); @@ -128,3 +96,21 @@ float SpineTransformConstraintData::get_offset_shear_y() { SPINE_CHECK(get_spine_constraint_data(), 0) return get_spine_constraint_data()->getOffsetShearY(); } + +bool SpineTransformConstraintData::is_relative() { + SPINE_CHECK(get_spine_constraint_data(), false) + return get_spine_constraint_data()->getRelative(); +} + +bool SpineTransformConstraintData::is_local() { + SPINE_CHECK(get_spine_constraint_data(), false) + return get_spine_constraint_data()->getLocal(); +} + +Ref SpineTransformConstraintData::get_setup_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_constraint_data()->getSetupPose(); + Ref pose_ref(memnew(SpineTransformConstraintPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; +} diff --git a/spine-godot/spine_godot/SpineTransformConstraintData.h b/spine-godot/spine_godot/SpineTransformConstraintData.h index 76adbb352..2b3d7a888 100644 --- a/spine-godot/spine_godot/SpineTransformConstraintData.h +++ b/spine-godot/spine_godot/SpineTransformConstraintData.h @@ -33,6 +33,8 @@ #include "SpineBoneData.h" #include +class SpineTransformConstraintPose; + class SpineTransformConstraintData : public SpineConstraintData { GDCLASS(SpineTransformConstraintData, SpineConstraintData) @@ -46,19 +48,7 @@ protected: public: Array get_bones(); - Ref get_target(); - - float get_mix_rotate(); - - float get_mix_x(); - - float get_mix_y(); - - float get_mix_scale_x(); - - float get_mix_scale_y(); - - float get_mix_shear_y(); + Ref get_source(); float get_offset_rotation(); @@ -75,4 +65,6 @@ public: bool is_relative(); bool is_local(); + + Ref get_setup_pose(); }; diff --git a/spine-godot/spine_godot/SpineTransformConstraintPose.cpp b/spine-godot/spine_godot/SpineTransformConstraintPose.cpp new file mode 100644 index 000000000..a8adc3452 --- /dev/null +++ b/spine-godot/spine_godot/SpineTransformConstraintPose.cpp @@ -0,0 +1,106 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * Copyright (c) 2013-2025, 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 "SpineTransformConstraintPose.h" +#include "SpineCommon.h" + +void SpineTransformConstraintPose::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_mix_rotate"), &SpineTransformConstraintPose::get_mix_rotate); + ClassDB::bind_method(D_METHOD("set_mix_rotate", "value"), &SpineTransformConstraintPose::set_mix_rotate); + ClassDB::bind_method(D_METHOD("get_mix_x"), &SpineTransformConstraintPose::get_mix_x); + ClassDB::bind_method(D_METHOD("set_mix_x", "value"), &SpineTransformConstraintPose::set_mix_x); + ClassDB::bind_method(D_METHOD("get_mix_y"), &SpineTransformConstraintPose::get_mix_y); + ClassDB::bind_method(D_METHOD("set_mix_y", "value"), &SpineTransformConstraintPose::set_mix_y); + ClassDB::bind_method(D_METHOD("get_mix_scale_x"), &SpineTransformConstraintPose::get_mix_scale_x); + ClassDB::bind_method(D_METHOD("set_mix_scale_x", "value"), &SpineTransformConstraintPose::set_mix_scale_x); + ClassDB::bind_method(D_METHOD("get_mix_scale_y"), &SpineTransformConstraintPose::get_mix_scale_y); + ClassDB::bind_method(D_METHOD("set_mix_scale_y", "value"), &SpineTransformConstraintPose::set_mix_scale_y); + ClassDB::bind_method(D_METHOD("get_mix_shear_y"), &SpineTransformConstraintPose::get_mix_shear_y); + ClassDB::bind_method(D_METHOD("set_mix_shear_y", "value"), &SpineTransformConstraintPose::set_mix_shear_y); +} + +float SpineTransformConstraintPose::get_mix_rotate() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMixRotate(); +} + +void SpineTransformConstraintPose::set_mix_rotate(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMixRotate(value); +} + +float SpineTransformConstraintPose::get_mix_x() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMixX(); +} + +void SpineTransformConstraintPose::set_mix_x(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMixX(value); +} + +float SpineTransformConstraintPose::get_mix_y() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMixY(); +} + +void SpineTransformConstraintPose::set_mix_y(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMixY(value); +} + +float SpineTransformConstraintPose::get_mix_scale_x() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMixScaleX(); +} + +void SpineTransformConstraintPose::set_mix_scale_x(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMixScaleX(value); +} + +float SpineTransformConstraintPose::get_mix_scale_y() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMixScaleY(); +} + +void SpineTransformConstraintPose::set_mix_scale_y(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMixScaleY(value); +} + +float SpineTransformConstraintPose::get_mix_shear_y() { + SPINE_CHECK(get_spine_object(), 0) + return get_spine_object()->getMixShearY(); +} + +void SpineTransformConstraintPose::set_mix_shear_y(float value) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setMixShearY(value); +} \ No newline at end of file diff --git a/spine-godot/spine_godot/SpineTransformConstraintPose.h b/spine-godot/spine_godot/SpineTransformConstraintPose.h new file mode 100644 index 000000000..e54edf5f6 --- /dev/null +++ b/spine-godot/spine_godot/SpineTransformConstraintPose.h @@ -0,0 +1,71 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated April 5, 2025. Replaces all prior versions. + * + * Copyright (c) 2013-2025, 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 "spine-cpp/include/spine/TransformConstraintPose.h" +#include + +class SpineSprite; + +class SpineTransformConstraintPose : public SpineObjectWrapper { + GDCLASS(SpineTransformConstraintPose, SpineObjectWrapper) + +protected: + static void _bind_methods(); + +public: + // Can be used by both SpineSprite and SpineSkeletonDataResource + void set_spine_object(void *owner, spine::TransformConstraintPose *object) { + _set_spine_object_internal(owner, object); + } + + spine::TransformConstraintPose *get_spine_object() { + return (spine::TransformConstraintPose *) _get_spine_object_internal(); + } + + float get_mix_rotate(); + void set_mix_rotate(float value); + + float get_mix_x(); + void set_mix_x(float value); + + float get_mix_y(); + void set_mix_y(float value); + + float get_mix_scale_x(); + void set_mix_scale_x(float value); + + float get_mix_scale_y(); + void set_mix_scale_y(float value); + + float get_mix_shear_y(); + void set_mix_shear_y(float value); +}; \ No newline at end of file diff --git a/spine-godot/spine_godot/register_types.cpp b/spine-godot/spine_godot/register_types.cpp index 4e2f4183f..821561b96 100644 --- a/spine-godot/spine_godot/register_types.cpp +++ b/spine-godot/spine_godot/register_types.cpp @@ -52,9 +52,18 @@ #include "SpineConstraintData.h" #include "SpineSkin.h" #include "SpineIkConstraintData.h" +#include "SpineIkConstraint.h" +#include "SpineIkConstraintPose.h" #include "SpineTransformConstraintData.h" +#include "SpineTransformConstraint.h" +#include "SpineTransformConstraintPose.h" #include "SpinePathConstraintData.h" +#include "SpinePathConstraint.h" +#include "SpinePathConstraintPose.h" #include "SpinePhysicsConstraintData.h" +#include "SpinePhysicsConstraint.h" +#include "SpinePhysicsConstraintPose.h" +#include "SpineSliderPose.h" #include "SpineTimeline.h" #include "SpineConstant.h" #include "SpineSlotNode.h" @@ -147,9 +156,14 @@ void register_spine_godot_types() { GDREGISTER_CLASS(SpineBonePose); GDREGISTER_CLASS(SpineSlot); GDREGISTER_CLASS(SpineIkConstraint); + GDREGISTER_CLASS(SpineIkConstraintPose); GDREGISTER_CLASS(SpinePathConstraint); + GDREGISTER_CLASS(SpinePathConstraintPose); GDREGISTER_CLASS(SpineTransformConstraint); + GDREGISTER_CLASS(SpineTransformConstraintPose); GDREGISTER_CLASS(SpinePhysicsConstraint); + GDREGISTER_CLASS(SpinePhysicsConstraintPose); + GDREGISTER_CLASS(SpineSliderPose); GDREGISTER_CLASS(SpineTimeline); GDREGISTER_CLASS(SpineConstant);