From ef7bd48e66c54bff0f9da2e6fad3ed121a237c8e Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 23 Sep 2025 18:35:16 +0200 Subject: [PATCH] [godot] WIP update to 4.3 spine-cpp --- spine-godot/spine_godot/SpineAnimation.cpp | 10 +- spine-godot/spine_godot/SpineAnimation.h | 2 +- .../spine_godot/SpineAnimationState.cpp | 18 +- spine-godot/spine_godot/SpineAttachment.cpp | 2 +- spine-godot/spine_godot/SpineBone.cpp | 144 ++++------ spine-godot/spine_godot/SpineBone.h | 8 - spine-godot/spine_godot/SpineBoneData.cpp | 36 +-- .../spine_godot/SpineConstraintData.cpp | 20 +- spine-godot/spine_godot/SpineEvent.cpp | 12 +- spine-godot/spine_godot/SpineEventData.cpp | 12 +- spine-godot/spine_godot/SpineIkConstraint.cpp | 38 ++- spine-godot/spine_godot/SpineIkConstraint.h | 5 +- .../spine_godot/SpineIkConstraintData.cpp | 26 +- .../spine_godot/SpinePathConstraint.cpp | 46 ++- spine-godot/spine_godot/SpinePathConstraint.h | 8 +- .../spine_godot/SpinePathConstraintData.cpp | 34 +-- .../spine_godot/SpinePathConstraintData.h | 4 +- .../spine_godot/SpinePhysicsConstraint.cpp | 262 ++---------------- .../spine_godot/SpinePhysicsConstraint.h | 58 +--- .../SpinePhysicsConstraintData.cpp | 30 +- spine-godot/spine_godot/SpineSkeleton.h | 6 +- .../spine_godot/SpineSkeletonFileResource.h | 2 +- spine-godot/spine_godot/SpineSkin.cpp | 8 +- spine-godot/spine_godot/SpineSlotData.cpp | 12 +- spine-godot/spine_godot/SpineSprite.h | 2 +- .../spine_godot/SpineTransformConstraint.cpp | 12 +- .../spine_godot/SpineTransformConstraint.h | 5 +- 27 files changed, 248 insertions(+), 574 deletions(-) diff --git a/spine-godot/spine_godot/SpineAnimation.cpp b/spine-godot/spine_godot/SpineAnimation.cpp index 3eea8bb03..d91e1a511 100644 --- a/spine-godot/spine_godot/SpineAnimation.cpp +++ b/spine-godot/spine_godot/SpineAnimation.cpp @@ -40,7 +40,7 @@ void SpineAnimation::_bind_methods() { ClassDB::bind_method(D_METHOD("get_duration"), &SpineAnimation::get_duration); ClassDB::bind_method(D_METHOD("set_duration", "duration"), &SpineAnimation::set_duration); - ClassDB::bind_method(D_METHOD("apply", "skeleton", "last_time", "time", "loop", "events", "alpha", "blend", "direction"), &SpineAnimation::apply); + ClassDB::bind_method(D_METHOD("apply", "skeleton", "last_time", "time", "loop", "events", "alpha", "blend", "direction", "appliedPose"), &SpineAnimation::apply); ClassDB::bind_method(D_METHOD("get_timelines"), &SpineAnimation::get_timelines); ClassDB::bind_method(D_METHOD("has_timeline", "ids"), &SpineAnimation::has_timeline); } @@ -63,11 +63,11 @@ void SpineAnimation::set_duration(float duration) { } void SpineAnimation::apply(Ref skeleton, float last_time, float time, bool loop, Array events, float alpha, - SpineConstant::MixBlend blend, SpineConstant::MixDirection direction) { + SpineConstant::MixBlend blend, SpineConstant::MixDirection direction, bool appliedPose) { SPINE_CHECK(get_spine_object(), ) - spine::Vector spineEvents; + spine::Array spineEvents; get_spine_object()->apply(*(skeleton->get_spine_object()), last_time, time, loop, &spineEvents, alpha, (spine::MixBlend) blend, - (spine::MixDirection) direction); + (spine::MixDirection) direction, appliedPose); for (int i = 0; i < (int) spineEvents.size(); ++i) { auto event_ref = memnew(SpineEvent); event_ref->set_spine_object(skeleton->get_spine_owner(), spineEvents[i]); @@ -95,7 +95,7 @@ Array SpineAnimation::get_timelines() { bool SpineAnimation::has_timeline(Array ids) { SPINE_CHECK(get_spine_object(), false) - spine::Vector property_ids; + spine::Array property_ids; property_ids.setSize(ids.size(), 0); for (int i = 0; i < (int) property_ids.size(); ++i) { diff --git a/spine-godot/spine_godot/SpineAnimation.h b/spine-godot/spine_godot/SpineAnimation.h index f32de2e96..fab68e75a 100644 --- a/spine-godot/spine_godot/SpineAnimation.h +++ b/spine-godot/spine_godot/SpineAnimation.h @@ -46,7 +46,7 @@ protected: public: void apply(Ref skeleton, float last_time, float time, bool loop, Array events, float alpha, SpineConstant::MixBlend blend, - SpineConstant::MixDirection direction); + SpineConstant::MixDirection direction, bool appliedPose); Array get_timelines(); diff --git a/spine-godot/spine_godot/SpineAnimationState.cpp b/spine-godot/spine_godot/SpineAnimationState.cpp index c88dca1f4..4d3bf5825 100644 --- a/spine-godot/spine_godot/SpineAnimationState.cpp +++ b/spine-godot/spine_godot/SpineAnimationState.cpp @@ -62,7 +62,7 @@ void SpineAnimationState::set_spine_sprite(SpineSprite *_sprite) { animation_state = nullptr; sprite = _sprite; if (!sprite || !sprite->get_skeleton_data_res().is_valid() || !sprite->get_skeleton_data_res()->is_skeleton_data_loaded()) return; - animation_state = new spine::AnimationState(sprite->get_skeleton_data_res()->get_animation_state_data()); + animation_state = new spine::AnimationState(*sprite->get_skeleton_data_res()->get_animation_state_data()); } void SpineAnimationState::update(float delta) { @@ -98,13 +98,13 @@ int SpineAnimationState::get_num_tracks() { Ref SpineAnimationState::set_animation(const String &animation_name, bool loop, int track) { SPINE_CHECK(animation_state, nullptr) - auto skeleton_data = animation_state->getData()->getSkeletonData(); - auto animation = skeleton_data->findAnimation(animation_name.utf8().ptr()); + auto &skeleton_data = animation_state->getData().getSkeletonData(); + auto animation = skeleton_data.findAnimation(animation_name.utf8().ptr()); if (!animation) { ERR_PRINT(String("Can not find animation: ") + animation_name); return nullptr; } - auto track_entry = animation_state->setAnimation(track, animation, loop); + auto track_entry = &animation_state->setAnimation(track, *animation, loop); Ref track_entry_ref(memnew(SpineTrackEntry)); track_entry_ref->set_spine_object(sprite, track_entry); return track_entry_ref; @@ -112,13 +112,13 @@ Ref SpineAnimationState::set_animation(const String &animation_ Ref SpineAnimationState::add_animation(const String &animation_name, float delay, bool loop, int track) { SPINE_CHECK(animation_state, nullptr) - auto skeleton_data = animation_state->getData()->getSkeletonData(); - auto animation = skeleton_data->findAnimation(animation_name.utf8().ptr()); + auto &skeleton_data = animation_state->getData().getSkeletonData(); + auto animation = skeleton_data.findAnimation(animation_name.utf8().ptr()); if (!animation) { ERR_PRINT(String("Can not find animation: ") + animation_name); return nullptr; } - auto track_entry = animation_state->addAnimation(track, animation, loop, delay); + auto track_entry = &animation_state->addAnimation(track, *animation, loop, delay); Ref track_entry_ref(memnew(SpineTrackEntry)); track_entry_ref->set_spine_object(sprite, track_entry); return track_entry_ref; @@ -126,14 +126,14 @@ Ref SpineAnimationState::add_animation(const String &animation_ Ref SpineAnimationState::set_empty_animation(int track_id, float mix_duration) { SPINE_CHECK(animation_state, nullptr) - auto track_entry = animation_state->setEmptyAnimation(track_id, mix_duration); + auto track_entry = &animation_state->setEmptyAnimation(track_id, mix_duration); Ref track_entry_ref(memnew(SpineTrackEntry)); track_entry_ref->set_spine_object(sprite, track_entry); return track_entry_ref; } Ref SpineAnimationState::add_empty_animation(int track_id, float mix_duration, float delay) { SPINE_CHECK(animation_state, nullptr) - auto track_entry = animation_state->addEmptyAnimation(track_id, mix_duration, delay); + auto track_entry = &animation_state->addEmptyAnimation(track_id, mix_duration, delay); Ref track_entry_ref(memnew(SpineTrackEntry)); track_entry_ref->set_spine_object(sprite, track_entry); return track_entry_ref; diff --git a/spine-godot/spine_godot/SpineAttachment.cpp b/spine-godot/spine_godot/SpineAttachment.cpp index a0b97ff6f..0161a43ad 100644 --- a/spine-godot/spine_godot/SpineAttachment.cpp +++ b/spine-godot/spine_godot/SpineAttachment.cpp @@ -48,7 +48,7 @@ String SpineAttachment::get_attachment_name() { Ref SpineAttachment::copy() { SPINE_CHECK(get_spine_object(), nullptr) - auto copy = get_spine_object()->copy(); + auto copy = &get_spine_object()->copy(); if (!copy) return nullptr; Ref attachment_ref(memnew(SpineAttachment)); attachment_ref->set_spine_object(get_spine_owner(), copy); diff --git a/spine-godot/spine_godot/SpineBone.cpp b/spine-godot/spine_godot/SpineBone.cpp index 741ad8eeb..bee78ccf3 100644 --- a/spine-godot/spine_godot/SpineBone.cpp +++ b/spine-godot/spine_godot/SpineBone.cpp @@ -34,8 +34,6 @@ #include "SpineCommon.h" void SpineBone::_bind_methods() { - ClassDB::bind_method(D_METHOD("update_world_transform"), &SpineBone::update_world_transform); - ClassDB::bind_method(D_METHOD("set_to_setup_pose"), &SpineBone::set_to_setup_pose); ClassDB::bind_method(D_METHOD("world_to_local", "world_position"), &SpineBone::world_to_local); ClassDB::bind_method(D_METHOD("world_to_parent", "world_position"), &SpineBone::world_to_parent); ClassDB::bind_method(D_METHOD("local_to_world", "local_position"), &SpineBone::local_to_world); @@ -43,8 +41,6 @@ void SpineBone::_bind_methods() { ClassDB::bind_method(D_METHOD("world_to_local_rotation", "world_rotation"), &SpineBone::world_to_local_rotation); ClassDB::bind_method(D_METHOD("local_to_world_rotation", "local_rotation"), &SpineBone::local_to_world_rotation); ClassDB::bind_method(D_METHOD("rotate_world"), &SpineBone::rotate_world); - ClassDB::bind_method(D_METHOD("get_world_to_local_rotation_x"), &SpineBone::get_world_to_local_rotation_x); - ClassDB::bind_method(D_METHOD("get_world_to_local_rotation_y"), &SpineBone::get_world_to_local_rotation_y); ClassDB::bind_method(D_METHOD("get_data"), &SpineBone::get_data); ClassDB::bind_method(D_METHOD("get_parent"), &SpineBone::get_parent); ClassDB::bind_method(D_METHOD("get_children"), &SpineBone::get_children); @@ -102,67 +98,47 @@ void SpineBone::_bind_methods() { ClassDB::bind_method(D_METHOD("set_global_transform", "global_transform"), &SpineBone::set_global_transform); } -void SpineBone::update_world_transform() { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->updateWorldTransform(); -} - -void SpineBone::set_to_setup_pose() { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setToSetupPose(); -} - Vector2 SpineBone::world_to_local(Vector2 world_position) { SPINE_CHECK(get_spine_object(), Vector2()) float x, y; - get_spine_object()->worldToLocal(world_position.x, world_position.y, x, y); + get_spine_object()->getAppliedPose().worldToLocal(world_position.x, world_position.y, x, y); return Vector2(x, y); } Vector2 SpineBone::world_to_parent(Vector2 world_position) { SPINE_CHECK(get_spine_object(), Vector2()) float x, y; - get_spine_object()->worldToParent(world_position.x, world_position.y, x, y); + get_spine_object()->getAppliedPose().worldToParent(world_position.x, world_position.y, x, y); return Vector2(x, y); } Vector2 SpineBone::local_to_world(Vector2 local_position) { SPINE_CHECK(get_spine_object(), Vector2()) float x, y; - get_spine_object()->localToWorld(local_position.x, local_position.y, x, y); + get_spine_object()->getAppliedPose().localToWorld(local_position.x, local_position.y, x, y); return Vector2(x, y); } Vector2 SpineBone::parent_to_world(Vector2 local_position) { SPINE_CHECK(get_spine_object(), Vector2()) float x, y; - get_spine_object()->parentToWorld(local_position.x, local_position.y, x, y); + get_spine_object()->getAppliedPose().parentToWorld(local_position.x, local_position.y, x, y); return Vector2(x, y); } float SpineBone::world_to_local_rotation(float world_rotation) { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->worldToLocalRotation(world_rotation); + return get_spine_object()->getAppliedPose().worldToLocalRotation(world_rotation); } float SpineBone::local_to_world_rotation(float local_rotation) { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->localToWorldRotation(local_rotation); + return get_spine_object()->getAppliedPose().localToWorldRotation(local_rotation); } void SpineBone::rotate_world(float degrees) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->rotateWorld(degrees); -} - -float SpineBone::get_world_to_local_rotation_x() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getWorldToLocalRotationX(); -} - -float SpineBone::get_world_to_local_rotation_y() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getWorldToLocalRotationY(); + get_spine_object()->getAppliedPose().rotateWorld(degrees); } Ref SpineBone::get_data() { @@ -198,223 +174,223 @@ Array SpineBone::get_children() { float SpineBone::get_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getX(); + return get_spine_object()->getPose().getX(); } void SpineBone::set_x(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setX(v); + get_spine_object()->getPose().setX(v); } float SpineBone::get_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getY(); + return get_spine_object()->getPose().getY(); } void SpineBone::set_y(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setY(v); + get_spine_object()->getPose().setY(v); } float SpineBone::get_rotation() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getRotation(); + return get_spine_object()->getPose().getRotation(); } void SpineBone::set_rotation(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setRotation(v); + get_spine_object()->getPose().setRotation(v); } float SpineBone::get_scale_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getScaleX(); + return get_spine_object()->getPose().getScaleX(); } void SpineBone::set_scale_x(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setScaleX(v); + get_spine_object()->getPose().setScaleX(v); } float SpineBone::get_scale_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getScaleY(); + return get_spine_object()->getPose().getScaleY(); } void SpineBone::set_scale_y(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setScaleY(v); + get_spine_object()->getPose().setScaleY(v); } float SpineBone::get_shear_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getShearX(); + return get_spine_object()->getPose().getShearX(); } void SpineBone::set_shear_x(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setShearX(v); + get_spine_object()->getPose().setShearX(v); } float SpineBone::get_shear_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getShearY(); + return get_spine_object()->getPose().getShearY(); } void SpineBone::set_shear_y(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setShearY(v); + get_spine_object()->getPose().setShearY(v); } float SpineBone::get_applied_rotation() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getAppliedRotation(); + return get_spine_object()->getAppliedPose().getRotation(); } void SpineBone::set_applied_rotation(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setAppliedRotation(v); + get_spine_object()->getAppliedPose().setRotation(v); } float SpineBone::get_a_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getAX(); + return get_spine_object()->getAppliedPose().getX(); } void SpineBone::set_a_x(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setAX(v); + get_spine_object()->getAppliedPose().setX(v); } float SpineBone::get_a_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getAY(); + return get_spine_object()->getAppliedPose().getY(); } void SpineBone::set_a_y(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setAY(v); + get_spine_object()->getAppliedPose().setY(v); } float SpineBone::get_a_scale_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getAScaleX(); + return get_spine_object()->getAppliedPose().getScaleX(); } void SpineBone::set_a_scale_x(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setAScaleX(v); + get_spine_object()->getAppliedPose().setScaleX(v); } float SpineBone::get_a_scale_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getAScaleY(); + return get_spine_object()->getAppliedPose().getScaleY(); } void SpineBone::set_a_scale_y(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setAScaleY(v); + get_spine_object()->getAppliedPose().setScaleY(v); } float SpineBone::get_a_shear_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getAShearX(); + return get_spine_object()->getAppliedPose().getShearX(); } void SpineBone::set_a_shear_x(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setAShearX(v); + get_spine_object()->getAppliedPose().setShearX(v); } float SpineBone::get_a_shear_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getAShearY(); + return get_spine_object()->getAppliedPose().getShearY(); } void SpineBone::set_a_shear_y(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setAShearY(v); + get_spine_object()->getAppliedPose().setShearY(v); } float SpineBone::get_a() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getA(); + return get_spine_object()->getAppliedPose().getA(); } void SpineBone::set_a(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setA(v); + get_spine_object()->getAppliedPose().setA(v); } float SpineBone::get_b() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getB(); + return get_spine_object()->getAppliedPose().getB(); } void SpineBone::set_b(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setB(v); + get_spine_object()->getAppliedPose().setB(v); } float SpineBone::get_c() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getC(); + return get_spine_object()->getAppliedPose().getC(); } void SpineBone::set_c(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setC(v); + get_spine_object()->getAppliedPose().setC(v); } float SpineBone::get_d() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getD(); + return get_spine_object()->getAppliedPose().getD(); } void SpineBone::set_d(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setD(v); + get_spine_object()->getAppliedPose().setD(v); } float SpineBone::get_world_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getWorldX(); + return get_spine_object()->getAppliedPose().getWorldX(); } void SpineBone::set_world_x(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setWorldX(v); + get_spine_object()->getAppliedPose().setWorldX(v); } float SpineBone::get_world_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getWorldY(); + return get_spine_object()->getAppliedPose().getWorldY(); } void SpineBone::set_world_y(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setWorldY(v); + get_spine_object()->getAppliedPose().setWorldY(v); } float SpineBone::get_world_rotation_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getWorldRotationX(); + return get_spine_object()->getAppliedPose().getWorldRotationX(); } float SpineBone::get_world_rotation_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getWorldRotationY(); + return get_spine_object()->getAppliedPose().getWorldRotationY(); } float SpineBone::get_world_scale_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getWorldScaleX(); + return get_spine_object()->getAppliedPose().getWorldScaleX(); } float SpineBone::get_world_scale_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getWorldScaleY(); + return get_spine_object()->getAppliedPose().getWorldScaleY(); } bool SpineBone::is_active() { @@ -428,12 +404,12 @@ void SpineBone::set_active(bool v) { SpineConstant::Inherit SpineBone::get_inherit() { SPINE_CHECK(get_spine_object(), SpineConstant::Inherit_Normal); - return (SpineConstant::Inherit) get_spine_object()->getInherit(); + return (SpineConstant::Inherit) get_spine_object()->getPose().getInherit(); } void SpineBone::set_inherit(SpineConstant::Inherit inherit) { SPINE_CHECK(get_spine_object(), ); - get_spine_object()->setInherit((spine::Inherit) inherit); + get_spine_object()->getPose().setInherit((spine::Inherit) inherit); } Transform2D SpineBone::get_transform() { @@ -484,17 +460,17 @@ void SpineBone::set_global_transform(Transform2D transform) { float rotation = spine::MathUtil::Rad_Deg * transform.get_rotation(); Vector2 scale = transform.get_scale(); Vector2 local_position = position; - float local_rotation = bone->worldToLocalRotation(rotation) - 180; + float local_rotation = bone->getAppliedPose().worldToLocalRotation(rotation) - 180; Vector2 local_scale = scale; spine::Bone *parent = bone->getParent(); if (parent) { - parent->worldToLocal(local_position.x, local_position.y, local_position.x, local_position.y); + parent->getAppliedPose().worldToLocal(local_position.x, local_position.y, local_position.x, local_position.y); } - bone->setX(local_position.x); - bone->setY(local_position.y); - bone->setRotation(local_rotation); - bone->setScaleX(local_scale.x); - bone->setScaleY(local_scale.y); + bone->getPose().setX(local_position.x); + bone->getPose().setY(local_position.y); + bone->getPose().setRotation(local_rotation); + bone->getPose().setScaleX(local_scale.x); + bone->getPose().setScaleY(local_scale.y); get_spine_owner()->set_modified_bones(); } diff --git a/spine-godot/spine_godot/SpineBone.h b/spine-godot/spine_godot/SpineBone.h index 9a286cfd0..4c86e2455 100644 --- a/spine-godot/spine_godot/SpineBone.h +++ b/spine-godot/spine_godot/SpineBone.h @@ -49,10 +49,6 @@ protected: static void _bind_methods(); public: - void update_world_transform(); - - void set_to_setup_pose(); - Vector2 world_to_local(Vector2 world_position); Vector2 world_to_parent(Vector2 world_position); @@ -67,10 +63,6 @@ public: void rotate_world(float degrees); - float get_world_to_local_rotation_x(); - - float get_world_to_local_rotation_y(); - Ref get_data(); Ref get_parent(); diff --git a/spine-godot/spine_godot/SpineBoneData.cpp b/spine-godot/spine_godot/SpineBoneData.cpp index 0dfcdf157..0d6bd2e29 100644 --- a/spine-godot/spine_godot/SpineBoneData.cpp +++ b/spine-godot/spine_godot/SpineBoneData.cpp @@ -94,87 +94,87 @@ void SpineBoneData::set_length(float v) { float SpineBoneData::get_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getX(); + return get_spine_object()->getSetupPose().getX(); } void SpineBoneData::set_x(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setX(v); + get_spine_object()->getSetupPose().setX(v); } float SpineBoneData::get_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getY(); + return get_spine_object()->getSetupPose().getY(); } void SpineBoneData::set_y(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setY(v); + get_spine_object()->getSetupPose().setY(v); } float SpineBoneData::get_rotation() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getRotation(); + return get_spine_object()->getSetupPose().getRotation(); } void SpineBoneData::set_rotation(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setRotation(v); + get_spine_object()->getSetupPose().setRotation(v); } float SpineBoneData::get_scale_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getScaleX(); + return get_spine_object()->getSetupPose().getScaleX(); } void SpineBoneData::set_scale_x(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setScaleX(v); + get_spine_object()->getSetupPose().setScaleX(v); } float SpineBoneData::get_scale_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getScaleY(); + return get_spine_object()->getSetupPose().getScaleY(); } void SpineBoneData::set_scale_y(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setScaleY(v); + get_spine_object()->getSetupPose().setScaleY(v); } float SpineBoneData::get_shear_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getShearX(); + return get_spine_object()->getSetupPose().getShearX(); } void SpineBoneData::set_shear_x(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setShearX(v); + get_spine_object()->getSetupPose().setShearX(v); } float SpineBoneData::get_shear_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getShearY(); + return get_spine_object()->getSetupPose().getShearY(); } void SpineBoneData::set_shear_y(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setShearY(v); + get_spine_object()->getSetupPose().setShearY(v); } SpineConstant::Inherit SpineBoneData::get_inherit() { SPINE_CHECK(get_spine_object(), SpineConstant::Inherit::Inherit_Normal) - return (SpineConstant::Inherit) get_spine_object()->getInherit(); + return (SpineConstant::Inherit) get_spine_object()->getSetupPose().getInherit(); } void SpineBoneData::set_inherit(SpineConstant::Inherit v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setInherit((spine::Inherit) v); + get_spine_object()->getSetupPose().setInherit((spine::Inherit) v); } bool SpineBoneData::is_skin_required() { SPINE_CHECK(get_spine_object(), false) - return get_spine_object()->isSkinRequired(); + return get_spine_object()->getSkinRequired(); } void SpineBoneData::set_skin_required(bool v) { @@ -200,7 +200,7 @@ String SpineBoneData::get_icon() { bool SpineBoneData::is_visible() { SPINE_CHECK(get_spine_object(), true) - return get_spine_object()->isVisible(); + return get_spine_object()->getVisible(); } void SpineBoneData::set_visible(bool v) { diff --git a/spine-godot/spine_godot/SpineConstraintData.cpp b/spine-godot/spine_godot/SpineConstraintData.cpp index b97e0961e..7ff974bc7 100644 --- a/spine-godot/spine_godot/SpineConstraintData.cpp +++ b/spine-godot/spine_godot/SpineConstraintData.cpp @@ -33,10 +33,7 @@ void SpineConstraintData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_constraint_name"), &SpineConstraintData::get_constraint_name); - ClassDB::bind_method(D_METHOD("get_order"), &SpineConstraintData::get_order); - ClassDB::bind_method(D_METHOD("set_order", "v"), &SpineConstraintData::set_order); ClassDB::bind_method(D_METHOD("is_skin_required"), &SpineConstraintData::is_skin_required); - ClassDB::bind_method(D_METHOD("set_skin_required", "v"), &SpineConstraintData::set_skin_required); } String SpineConstraintData::get_constraint_name() { @@ -46,22 +43,7 @@ String SpineConstraintData::get_constraint_name() { return name; } -int SpineConstraintData::get_order() { - SPINE_CHECK(get_spine_object(), 0) - return (int) get_spine_object()->getOrder(); -} - -void SpineConstraintData::set_order(int v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setOrder(v); -} - bool SpineConstraintData::is_skin_required() { SPINE_CHECK(get_spine_object(), false) - return get_spine_object()->isSkinRequired(); -} - -void SpineConstraintData::set_skin_required(bool v) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setSkinRequired(v); + return get_spine_object()->getSkinRequired(); } diff --git a/spine-godot/spine_godot/SpineEvent.cpp b/spine-godot/spine_godot/SpineEvent.cpp index e36764142..3cf68d63b 100644 --- a/spine-godot/spine_godot/SpineEvent.cpp +++ b/spine-godot/spine_godot/SpineEvent.cpp @@ -60,32 +60,32 @@ float SpineEvent::get_time() { int SpineEvent::get_int_value() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getIntValue(); + return get_spine_object()->getInt(); } void SpineEvent::set_int_value(int v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setIntValue(v); + get_spine_object()->setInt(v); } float SpineEvent::get_float_value() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getFloatValue(); + return get_spine_object()->getFloat(); } void SpineEvent::set_float_value(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setFloatValue(v); + get_spine_object()->setFloat(v); } String SpineEvent::get_string_value() { SPINE_CHECK(get_spine_object(), "") - return get_spine_object()->getStringValue().buffer(); + return get_spine_object()->getString().buffer(); } void SpineEvent::set_string_value(const String &v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setStringValue(spine::String(v.utf8())); + get_spine_object()->setString(spine::String(v.utf8())); } float SpineEvent::get_volume() { diff --git a/spine-godot/spine_godot/SpineEventData.cpp b/spine-godot/spine_godot/SpineEventData.cpp index 2ab921618..43c2893b9 100644 --- a/spine-godot/spine_godot/SpineEventData.cpp +++ b/spine-godot/spine_godot/SpineEventData.cpp @@ -55,32 +55,32 @@ String SpineEventData::get_event_name() { int SpineEventData::get_int_value() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getIntValue(); + return get_spine_object()->getInt(); } void SpineEventData::set_int_value(int v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setIntValue(v); + get_spine_object()->setInt(v); } float SpineEventData::get_float_value() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getFloatValue(); + return get_spine_object()->getFloat(); } void SpineEventData::set_float_value(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setFloatValue(v); + get_spine_object()->setFloat(v); } String SpineEventData::get_string_value() { SPINE_CHECK(get_spine_object(), "") - return get_spine_object()->getStringValue().buffer(); + return get_spine_object()->getString().buffer(); } void SpineEventData::set_string_value(const String &v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setStringValue(spine::String(v.utf8())); + get_spine_object()->setString(spine::String(v.utf8())); } String SpineEventData::get_audio_path() { diff --git a/spine-godot/spine_godot/SpineIkConstraint.cpp b/spine-godot/spine_godot/SpineIkConstraint.cpp index 429b2a9df..35cacc156 100644 --- a/spine-godot/spine_godot/SpineIkConstraint.cpp +++ b/spine-godot/spine_godot/SpineIkConstraint.cpp @@ -33,8 +33,7 @@ #include "SpineSprite.h" void SpineIkConstraint::_bind_methods() { - ClassDB::bind_method(D_METHOD("update"), &SpineIkConstraint::update); - ClassDB::bind_method(D_METHOD("get_order"), &SpineIkConstraint::get_order); + ClassDB::bind_method(D_METHOD("update", "skeleton"), &SpineIkConstraint::update); ClassDB::bind_method(D_METHOD("get_data"), &SpineIkConstraint::get_data); ClassDB::bind_method(D_METHOD("get_bones"), &SpineIkConstraint::get_bones); ClassDB::bind_method(D_METHOD("get_target"), &SpineIkConstraint::get_target); @@ -53,14 +52,9 @@ void SpineIkConstraint::_bind_methods() { ClassDB::bind_method(D_METHOD("set_active", "v"), &SpineIkConstraint::set_active); } -void SpineIkConstraint::update() { +void SpineIkConstraint::update(Ref skeleton) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->update(spine::Physics_Update); -} - -int SpineIkConstraint::get_order() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getOrder(); + get_spine_object()->update(*skeleton->get_spine_object(), spine::Physics_Update); } Ref SpineIkConstraint::get_data() { @@ -87,7 +81,7 @@ Array SpineIkConstraint::get_bones() { Ref SpineIkConstraint::get_target() { SPINE_CHECK(get_spine_object(), nullptr) - auto target = get_spine_object()->getTarget(); + auto target = &get_spine_object()->getTarget(); if (!target) return nullptr; Ref target_ref(memnew(SpineBone)); target_ref->set_spine_object(get_spine_owner(), target); @@ -96,56 +90,58 @@ Ref SpineIkConstraint::get_target() { void SpineIkConstraint::set_target(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()->setTarget(*v->get_spine_object()); + } } int SpineIkConstraint::get_bend_direction() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getBendDirection(); + return get_spine_object()->getPose().getBendDirection(); } void SpineIkConstraint::set_bend_direction(int v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setBendDirection(v); + get_spine_object()->getPose().setBendDirection(v); } bool SpineIkConstraint::get_compress() { SPINE_CHECK(get_spine_object(), false) - return get_spine_object()->getCompress(); + return get_spine_object()->getPose().getCompress(); } void SpineIkConstraint::set_compress(bool v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setCompress(v); + get_spine_object()->getPose().setCompress(v); } bool SpineIkConstraint::get_stretch() { SPINE_CHECK(get_spine_object(), false) - return get_spine_object()->getStretch(); + return get_spine_object()->getPose().getStretch(); } void SpineIkConstraint::set_stretch(bool v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setStretch(v); + get_spine_object()->getPose().setStretch(v); } float SpineIkConstraint::get_mix() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMix(); + return get_spine_object()->getPose().getMix(); } void SpineIkConstraint::set_mix(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMix(v); + get_spine_object()->getPose().setMix(v); } float SpineIkConstraint::get_softness() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getSoftness(); + return get_spine_object()->getPose().getSoftness(); } void SpineIkConstraint::set_softness(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setSoftness(v); + get_spine_object()->getPose().setSoftness(v); } bool SpineIkConstraint::is_active() { diff --git a/spine-godot/spine_godot/SpineIkConstraint.h b/spine-godot/spine_godot/SpineIkConstraint.h index ce74e07bf..64ed9ba8b 100644 --- a/spine-godot/spine_godot/SpineIkConstraint.h +++ b/spine-godot/spine_godot/SpineIkConstraint.h @@ -31,6 +31,7 @@ #include "SpineIkConstraintData.h" #include +#include "SpineSkeleton.h" class SpineBone; class SpineSprite; @@ -42,9 +43,7 @@ protected: static void _bind_methods(); public: - void update(); - - int get_order(); + void update(Ref skeleton); Ref get_data(); diff --git a/spine-godot/spine_godot/SpineIkConstraintData.cpp b/spine-godot/spine_godot/SpineIkConstraintData.cpp index d359fcee0..017f2cb76 100644 --- a/spine-godot/spine_godot/SpineIkConstraintData.cpp +++ b/spine-godot/spine_godot/SpineIkConstraintData.cpp @@ -63,7 +63,7 @@ Array SpineIkConstraintData::get_bones() { Ref SpineIkConstraintData::get_target() { SPINE_CHECK(get_spine_object(), nullptr) - auto target = get_spine_constraint_data()->getTarget(); + auto target = &get_spine_constraint_data()->getTarget(); if (!target) return nullptr; Ref target_ref(memnew(SpineBoneData)); target_ref->set_spine_object(get_spine_owner(), target); @@ -72,37 +72,39 @@ Ref SpineIkConstraintData::get_target() { void SpineIkConstraintData::set_target(Ref v) { SPINE_CHECK(get_spine_object(), ) - get_spine_constraint_data()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr); + if (v.is_valid() && v->get_spine_object()) { + get_spine_constraint_data()->setTarget(*v->get_spine_object()); + } } int SpineIkConstraintData::get_bend_direction() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_constraint_data()->getBendDirection(); + return get_spine_constraint_data()->getSetupPose().getBendDirection(); } void SpineIkConstraintData::set_bend_direction(int v) { SPINE_CHECK(get_spine_object(), ) - get_spine_constraint_data()->setBendDirection(v); + get_spine_constraint_data()->getSetupPose().setBendDirection(v); } bool SpineIkConstraintData::get_compress() { SPINE_CHECK(get_spine_object(), false) - return get_spine_constraint_data()->getCompress(); + return get_spine_constraint_data()->getSetupPose().getCompress(); } void SpineIkConstraintData::set_compress(bool v) { SPINE_CHECK(get_spine_object(), ) - get_spine_constraint_data()->setCompress(v); + get_spine_constraint_data()->getSetupPose().setCompress(v); } bool SpineIkConstraintData::get_stretch() { SPINE_CHECK(get_spine_object(), false) - return get_spine_constraint_data()->getStretch(); + return get_spine_constraint_data()->getSetupPose().getStretch(); } void SpineIkConstraintData::set_stretch(bool v) { SPINE_CHECK(get_spine_object(), ) - get_spine_constraint_data()->setStretch(v); + get_spine_constraint_data()->getSetupPose().setStretch(v); } bool SpineIkConstraintData::get_uniform() { @@ -117,20 +119,20 @@ void SpineIkConstraintData::set_uniform(bool v) { float SpineIkConstraintData::get_mix() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_constraint_data()->getMix(); + return get_spine_constraint_data()->getSetupPose().getMix(); } void SpineIkConstraintData::set_mix(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_constraint_data()->setMix(v); + get_spine_constraint_data()->getSetupPose().setMix(v); } float SpineIkConstraintData::get_softness() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_constraint_data()->getSoftness(); + return get_spine_constraint_data()->getSetupPose().getSoftness(); } void SpineIkConstraintData::set_softness(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_constraint_data()->setSoftness(v); + get_spine_constraint_data()->getSetupPose().setSoftness(v); } diff --git a/spine-godot/spine_godot/SpinePathConstraint.cpp b/spine-godot/spine_godot/SpinePathConstraint.cpp index 88f28a7b3..c5bde872c 100644 --- a/spine-godot/spine_godot/SpinePathConstraint.cpp +++ b/spine-godot/spine_godot/SpinePathConstraint.cpp @@ -33,8 +33,7 @@ #include "SpineSprite.h" void SpinePathConstraint::_bind_methods() { - ClassDB::bind_method(D_METHOD("update"), &SpinePathConstraint::update); - ClassDB::bind_method(D_METHOD("get_order"), &SpinePathConstraint::get_order); + 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); @@ -46,71 +45,66 @@ void SpinePathConstraint::_bind_methods() { 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_bones"), &SpinePathConstraint::get_bones); - ClassDB::bind_method(D_METHOD("get_target"), &SpinePathConstraint::get_target); - ClassDB::bind_method(D_METHOD("set_target", "v"), &SpinePathConstraint::set_target); + ClassDB::bind_method(D_METHOD("get_slot"), &SpinePathConstraint::get_slot); + ClassDB::bind_method(D_METHOD("set_slot", "v"), &SpinePathConstraint::set_slot); ClassDB::bind_method(D_METHOD("get_data"), &SpinePathConstraint::get_data); ClassDB::bind_method(D_METHOD("is_active"), &SpinePathConstraint::is_active); ClassDB::bind_method(D_METHOD("set_active", "v"), &SpinePathConstraint::set_active); } -void SpinePathConstraint::update() { +void SpinePathConstraint::update(Ref skeleton) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->update(spine::Physics_Update); -} - -int SpinePathConstraint::get_order() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getOrder(); + 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()->getPosition(); + return get_spine_object()->getPose().getPosition(); } void SpinePathConstraint::set_position(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setPosition(v); + get_spine_object()->getPose().setPosition(v); } float SpinePathConstraint::get_spacing() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getSpacing(); + return get_spine_object()->getPose().getSpacing(); } void SpinePathConstraint::set_spacing(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setSpacing(v); + get_spine_object()->getPose().setSpacing(v); } float SpinePathConstraint::get_mix_rotate() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMixRotate(); + return get_spine_object()->getPose().getMixRotate(); } void SpinePathConstraint::set_mix_rotate(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMixRotate(v); + get_spine_object()->getPose().setMixRotate(v); } float SpinePathConstraint::get_mix_x() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMixX(); + return get_spine_object()->getPose().getMixX(); } void SpinePathConstraint::set_mix_x(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMixX(v); + get_spine_object()->getPose().setMixX(v); } float SpinePathConstraint::get_mix_y() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMixY(); + return get_spine_object()->getPose().getMixY(); } void SpinePathConstraint::set_mix_y(float v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMixY(v); + get_spine_object()->getPose().setMixY(v); } Array SpinePathConstraint::get_bones() { @@ -127,18 +121,20 @@ Array SpinePathConstraint::get_bones() { return result; } -Ref SpinePathConstraint::get_target() { +Ref SpinePathConstraint::get_slot() { SPINE_CHECK(get_spine_object(), nullptr) - auto target = get_spine_object()->getTarget(); + auto target = &get_spine_object()->getSlot(); if (!target) return nullptr; Ref target_ref(memnew(SpineSlot)); target_ref->set_spine_object(get_spine_owner(), target); return target_ref; } -void SpinePathConstraint::set_target(Ref v) { +void SpinePathConstraint::set_slot(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()->setSlot(*v->get_spine_object()); + } } Ref SpinePathConstraint::get_data() { diff --git a/spine-godot/spine_godot/SpinePathConstraint.h b/spine-godot/spine_godot/SpinePathConstraint.h index 276cbac4c..a623c271c 100644 --- a/spine-godot/spine_godot/SpinePathConstraint.h +++ b/spine-godot/spine_godot/SpinePathConstraint.h @@ -40,9 +40,7 @@ protected: static void _bind_methods(); public: - void update(); - - int get_order(); + void update(Ref skeleton); float get_position(); @@ -66,9 +64,9 @@ public: Array get_bones(); - Ref get_target(); + Ref get_slot(); - void set_target(Ref v); + void set_slot(Ref v); Ref get_data(); diff --git a/spine-godot/spine_godot/SpinePathConstraintData.cpp b/spine-godot/spine_godot/SpinePathConstraintData.cpp index b0a3f90a4..bf5638c26 100644 --- a/spine-godot/spine_godot/SpinePathConstraintData.cpp +++ b/spine-godot/spine_godot/SpinePathConstraintData.cpp @@ -33,8 +33,8 @@ void SpinePathConstraintData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_bones"), &SpinePathConstraintData::get_bones); - ClassDB::bind_method(D_METHOD("get_target"), &SpinePathConstraintData::get_target); - ClassDB::bind_method(D_METHOD("set_target", "v"), &SpinePathConstraintData::set_target); + ClassDB::bind_method(D_METHOD("get_slot"), &SpinePathConstraintData::get_slot); + ClassDB::bind_method(D_METHOD("set_slot", "v"), &SpinePathConstraintData::set_slot); ClassDB::bind_method(D_METHOD("get_position_mode"), &SpinePathConstraintData::get_position_mode); ClassDB::bind_method(D_METHOD("set_position_mode", "v"), &SpinePathConstraintData::set_position_mode); ClassDB::bind_method(D_METHOD("get_spacing_mode"), &SpinePathConstraintData::get_spacing_mode); @@ -68,18 +68,20 @@ Array SpinePathConstraintData::get_bones() { return result; } -Ref SpinePathConstraintData::get_target() { +Ref SpinePathConstraintData::get_slot() { SPINE_CHECK(get_spine_constraint_data(), nullptr) - auto slot = get_spine_constraint_data()->getTarget(); + auto slot = &get_spine_constraint_data()->getSlot(); if (!slot) return nullptr; Ref slot_ref(memnew(SpineSlotData)); slot_ref->set_spine_object(get_spine_owner(), slot); return slot_ref; } -void SpinePathConstraintData::set_target(Ref v) { +void SpinePathConstraintData::set_slot(Ref v) { SPINE_CHECK(get_spine_constraint_data(), ) - get_spine_constraint_data()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr); + if (v.is_valid() && v->get_spine_object()) { + get_spine_constraint_data()->setSlot(*v->get_spine_object()); + } } SpineConstant::PositionMode SpinePathConstraintData::get_position_mode() { @@ -124,50 +126,50 @@ void SpinePathConstraintData::set_offset_rotation(float v) { float SpinePathConstraintData::get_position() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getPosition(); + return get_spine_constraint_data()->getSetupPose().getPosition(); } void SpinePathConstraintData::set_position(float v) { SPINE_CHECK(get_spine_constraint_data(), ) - get_spine_constraint_data()->setPosition(v); + get_spine_constraint_data()->getSetupPose().setPosition(v); } float SpinePathConstraintData::get_spacing() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getSpacing(); + return get_spine_constraint_data()->getSetupPose().getSpacing(); } void SpinePathConstraintData::set_spacing(float v) { SPINE_CHECK(get_spine_constraint_data(), ) - get_spine_constraint_data()->setSpacing(v); + get_spine_constraint_data()->getSetupPose().setSpacing(v); } float SpinePathConstraintData::get_mix_rotate() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getMixRotate(); + return get_spine_constraint_data()->getSetupPose().getMixRotate(); } void SpinePathConstraintData::set_mix_rotate(float v) { SPINE_CHECK(get_spine_constraint_data(), ) - get_spine_constraint_data()->setMixRotate(v); + get_spine_constraint_data()->getSetupPose().setMixRotate(v); } float SpinePathConstraintData::get_mix_x() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getMixX(); + return get_spine_constraint_data()->getSetupPose().getMixX(); } void SpinePathConstraintData::set_mix_x(float v) { SPINE_CHECK(get_spine_constraint_data(), ) - get_spine_constraint_data()->setMixX(v); + get_spine_constraint_data()->getSetupPose().setMixX(v); } float SpinePathConstraintData::get_mix_y() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getMixY(); + return get_spine_constraint_data()->getSetupPose().getMixY(); } void SpinePathConstraintData::set_mix_y(float v) { SPINE_CHECK(get_spine_constraint_data(), ) - get_spine_constraint_data()->setMixY(v); + get_spine_constraint_data()->getSetupPose().setMixY(v); } diff --git a/spine-godot/spine_godot/SpinePathConstraintData.h b/spine-godot/spine_godot/SpinePathConstraintData.h index 67528d94e..5ef7e81a9 100644 --- a/spine-godot/spine_godot/SpinePathConstraintData.h +++ b/spine-godot/spine_godot/SpinePathConstraintData.h @@ -48,9 +48,9 @@ protected: public: Array get_bones(); - Ref get_target(); + Ref get_slot(); - void set_target(Ref v); + void set_slot(Ref v); SpineConstant::PositionMode get_position_mode(); diff --git a/spine-godot/spine_godot/SpinePhysicsConstraint.cpp b/spine-godot/spine_godot/SpinePhysicsConstraint.cpp index 94e6a5af0..c546a4393 100644 --- a/spine-godot/spine_godot/SpinePhysicsConstraint.cpp +++ b/spine-godot/spine_godot/SpinePhysicsConstraint.cpp @@ -32,7 +32,7 @@ #include "SpineSprite.h" void SpinePhysicsConstraint::_bind_methods() { - ClassDB::bind_method(D_METHOD("update", "physics"), &SpinePhysicsConstraint::update); + ClassDB::bind_method(D_METHOD("update", "skeleton", "physics"), &SpinePhysicsConstraint::update); 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); @@ -48,50 +48,14 @@ void SpinePhysicsConstraint::_bind_methods() { 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_reset", "value"), &SpinePhysicsConstraint::set_reset); - ClassDB::bind_method(D_METHOD("get_reset"), &SpinePhysicsConstraint::get_reset); - ClassDB::bind_method(D_METHOD("set_ux", "value"), &SpinePhysicsConstraint::set_ux); - ClassDB::bind_method(D_METHOD("get_ux"), &SpinePhysicsConstraint::get_ux); - ClassDB::bind_method(D_METHOD("set_uy", "value"), &SpinePhysicsConstraint::set_uy); - ClassDB::bind_method(D_METHOD("get_uy"), &SpinePhysicsConstraint::get_uy); - ClassDB::bind_method(D_METHOD("set_cx", "value"), &SpinePhysicsConstraint::set_cx); - ClassDB::bind_method(D_METHOD("get_cx"), &SpinePhysicsConstraint::get_cx); - ClassDB::bind_method(D_METHOD("set_cy", "value"), &SpinePhysicsConstraint::set_cy); - ClassDB::bind_method(D_METHOD("get_cy"), &SpinePhysicsConstraint::get_cy); - ClassDB::bind_method(D_METHOD("set_tx", "value"), &SpinePhysicsConstraint::set_tx); - ClassDB::bind_method(D_METHOD("get_tx"), &SpinePhysicsConstraint::get_tx); - ClassDB::bind_method(D_METHOD("set_ty", "value"), &SpinePhysicsConstraint::set_ty); - ClassDB::bind_method(D_METHOD("get_ty"), &SpinePhysicsConstraint::get_ty); - ClassDB::bind_method(D_METHOD("set_x_offset", "value"), &SpinePhysicsConstraint::set_x_offset); - ClassDB::bind_method(D_METHOD("get_x_offset"), &SpinePhysicsConstraint::get_x_offset); - ClassDB::bind_method(D_METHOD("set_x_velocity", "value"), &SpinePhysicsConstraint::set_x_velocity); - ClassDB::bind_method(D_METHOD("get_x_velocity"), &SpinePhysicsConstraint::get_x_velocity); - ClassDB::bind_method(D_METHOD("set_y_offset", "value"), &SpinePhysicsConstraint::set_y_offset); - ClassDB::bind_method(D_METHOD("get_y_offset"), &SpinePhysicsConstraint::get_y_offset); - ClassDB::bind_method(D_METHOD("set_y_velocity", "value"), &SpinePhysicsConstraint::set_y_velocity); - ClassDB::bind_method(D_METHOD("get_y_velocity"), &SpinePhysicsConstraint::get_y_velocity); - ClassDB::bind_method(D_METHOD("set_rotate_offset", "value"), &SpinePhysicsConstraint::set_rotate_offset); - ClassDB::bind_method(D_METHOD("get_rotate_offset"), &SpinePhysicsConstraint::get_rotate_offset); - ClassDB::bind_method(D_METHOD("set_rotate_velocity", "value"), &SpinePhysicsConstraint::set_rotate_velocity); - ClassDB::bind_method(D_METHOD("get_rotate_velocity"), &SpinePhysicsConstraint::get_rotate_velocity); - ClassDB::bind_method(D_METHOD("set_scale_offset", "value"), &SpinePhysicsConstraint::set_scale_offset); - ClassDB::bind_method(D_METHOD("get_scale_offset"), &SpinePhysicsConstraint::get_scale_offset); - ClassDB::bind_method(D_METHOD("set_scale_velocity", "value"), &SpinePhysicsConstraint::set_scale_velocity); - ClassDB::bind_method(D_METHOD("get_scale_velocity"), &SpinePhysicsConstraint::get_scale_velocity); - ClassDB::bind_method(D_METHOD("set_active", "value"), &SpinePhysicsConstraint::set_active); - ClassDB::bind_method(D_METHOD("is_active"), &SpinePhysicsConstraint::is_active); - ClassDB::bind_method(D_METHOD("set_remaining", "value"), &SpinePhysicsConstraint::set_remaining); - ClassDB::bind_method(D_METHOD("get_remaining"), &SpinePhysicsConstraint::get_remaining); - ClassDB::bind_method(D_METHOD("set_last_Time", "value"), &SpinePhysicsConstraint::set_last_Time); - ClassDB::bind_method(D_METHOD("get_last_Time"), &SpinePhysicsConstraint::get_last_Time); - ClassDB::bind_method(D_METHOD("reset"), &SpinePhysicsConstraint::reset); + 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); } -void SpinePhysicsConstraint::update(SpineConstant::Physics physics) { +void SpinePhysicsConstraint::update(Ref skeleton, SpineConstant::Physics physics) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->update((spine::Physics) physics); + get_spine_object()->update(*skeleton->get_spine_object(), (spine::Physics) physics); } Ref SpinePhysicsConstraint::get_data() { @@ -104,7 +68,7 @@ Ref SpinePhysicsConstraint::get_data() { Ref SpinePhysicsConstraint::get_bone() { SPINE_CHECK(get_spine_object(), nullptr) - auto target = get_spine_object()->getBone(); + auto target = &get_spine_object()->getBone(); if (!target) return nullptr; Ref target_ref(memnew(SpineBone)); target_ref->set_spine_object(get_spine_owner(), target); @@ -113,262 +77,84 @@ Ref SpinePhysicsConstraint::get_bone() { void SpinePhysicsConstraint::set_bone(Ref v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setBone(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr); + if (v.is_valid() && 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()->setInertia(value); + get_spine_object()->getPose().setInertia(value); } float SpinePhysicsConstraint::get_inertia() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getInertia(); + return get_spine_object()->getPose().getInertia(); } void SpinePhysicsConstraint::set_strength(float value) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setStrength(value); + get_spine_object()->getPose().setStrength(value); } float SpinePhysicsConstraint::get_strength() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getStrength(); + return get_spine_object()->getPose().getStrength(); } void SpinePhysicsConstraint::set_damping(float value) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setDamping(value); + get_spine_object()->getPose().setDamping(value); } float SpinePhysicsConstraint::get_damping() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getDamping(); + return get_spine_object()->getPose().getDamping(); } void SpinePhysicsConstraint::set_mass_inverse(float value) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMassInverse(value); + get_spine_object()->getPose().setMassInverse(value); } float SpinePhysicsConstraint::get_mass_inverse() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMassInverse(); + return get_spine_object()->getPose().getMassInverse(); } void SpinePhysicsConstraint::set_wind(float value) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setWind(value); + get_spine_object()->getPose().setWind(value); } float SpinePhysicsConstraint::get_wind() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getWind(); + return get_spine_object()->getPose().getWind(); } void SpinePhysicsConstraint::set_gravity(float value) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setGravity(value); + get_spine_object()->getPose().setGravity(value); } float SpinePhysicsConstraint::get_gravity() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getGravity(); + return get_spine_object()->getPose().getGravity(); } void SpinePhysicsConstraint::set_mix(float value) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setMix(value); + get_spine_object()->getPose().setMix(value); } float SpinePhysicsConstraint::get_mix() { SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getMix(); + return get_spine_object()->getPose().getMix(); } -void SpinePhysicsConstraint::set_reset(bool value) { +void SpinePhysicsConstraint::reset(Ref skeleton) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setReset(value); -} - -bool SpinePhysicsConstraint::get_reset() { - SPINE_CHECK(get_spine_object(), false) - return get_spine_object()->getReset(); -} - -void SpinePhysicsConstraint::set_ux(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setUx(value); -} - -float SpinePhysicsConstraint::get_ux() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getUx(); -} - -void SpinePhysicsConstraint::set_uy(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setUy(value); -} - -float SpinePhysicsConstraint::get_uy() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getUy(); -} - -void SpinePhysicsConstraint::set_cx(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setCx(value); -} - -float SpinePhysicsConstraint::get_cx() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getCx(); -} - -void SpinePhysicsConstraint::set_cy(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setCy(value); -} - -float SpinePhysicsConstraint::get_cy() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getCy(); -} - -void SpinePhysicsConstraint::set_tx(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setTx(value); -} - -float SpinePhysicsConstraint::get_tx() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getTx(); -} - -void SpinePhysicsConstraint::set_ty(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setTy(value); -} - -float SpinePhysicsConstraint::get_ty() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getTy(); -} - -void SpinePhysicsConstraint::set_x_offset(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setXOffset(value); -} - -float SpinePhysicsConstraint::get_x_offset() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getXOffset(); -} - -void SpinePhysicsConstraint::set_x_velocity(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setXVelocity(value); -} - -float SpinePhysicsConstraint::get_x_velocity() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getXVelocity(); -} - -void SpinePhysicsConstraint::set_y_offset(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setYOffset(value); -} - -float SpinePhysicsConstraint::get_y_offset() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getYOffset(); -} - -void SpinePhysicsConstraint::set_y_velocity(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setYVelocity(value); -} - -float SpinePhysicsConstraint::get_y_velocity() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getYVelocity(); -} - -void SpinePhysicsConstraint::set_rotate_offset(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setRotateOffset(value); -} - -float SpinePhysicsConstraint::get_rotate_offset() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getRotateOffset(); -} - -void SpinePhysicsConstraint::set_rotate_velocity(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setRotateVelocity(value); -} - -float SpinePhysicsConstraint::get_rotate_velocity() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getRotateVelocity(); -} - -void SpinePhysicsConstraint::set_scale_offset(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setScaleOffset(value); -} - -float SpinePhysicsConstraint::get_scale_offset() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getScaleOffset(); -} - -void SpinePhysicsConstraint::set_scale_velocity(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setScaleVelocity(value); -} - -float SpinePhysicsConstraint::get_scale_velocity() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getScaleVelocity(); -} - -void SpinePhysicsConstraint::set_active(bool value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setActive(value); -} - -bool SpinePhysicsConstraint::is_active() { - SPINE_CHECK(get_spine_object(), false) - return get_spine_object()->isActive(); -} - -void SpinePhysicsConstraint::set_remaining(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setRemaining(value); -} - -float SpinePhysicsConstraint::get_remaining() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getRemaining(); -} - -void SpinePhysicsConstraint::set_last_Time(float value) { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setLastTime(value); -} - -float SpinePhysicsConstraint::get_last_Time() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getLastTime(); -} - -void SpinePhysicsConstraint::reset() { - SPINE_CHECK(get_spine_object(), ) - get_spine_object()->reset(); + get_spine_object()->reset(*skeleton->get_spine_object()); } void SpinePhysicsConstraint::translate(float x, float y) { diff --git a/spine-godot/spine_godot/SpinePhysicsConstraint.h b/spine-godot/spine_godot/SpinePhysicsConstraint.h index e435668c7..2f19ba6c0 100644 --- a/spine-godot/spine_godot/SpinePhysicsConstraint.h +++ b/spine-godot/spine_godot/SpinePhysicsConstraint.h @@ -41,7 +41,7 @@ protected: static void _bind_methods(); public: - void update(SpineConstant::Physics physics); + void update(Ref skeleton, SpineConstant::Physics physics); Ref get_data(); @@ -70,61 +70,7 @@ public: void set_mix(float value); float get_mix(); - void set_reset(bool value); - bool get_reset(); - - void set_ux(float value); - float get_ux(); - - void set_uy(float value); - float get_uy(); - - void set_cx(float value); - float get_cx(); - - void set_cy(float value); - float get_cy(); - - void set_tx(float value); - float get_tx(); - - void set_ty(float value); - float get_ty(); - - void set_x_offset(float value); - float get_x_offset(); - - void set_x_velocity(float value); - float get_x_velocity(); - - void set_y_offset(float value); - float get_y_offset(); - - void set_y_velocity(float value); - float get_y_velocity(); - - void set_rotate_offset(float value); - float get_rotate_offset(); - - void set_rotate_velocity(float value); - float get_rotate_velocity(); - - void set_scale_offset(float value); - float get_scale_offset(); - - void set_scale_velocity(float value); - float get_scale_velocity(); - - void set_active(bool value); - bool is_active(); - - void set_remaining(float value); - float get_remaining(); - - void set_last_Time(float value); - float get_last_Time(); - - void reset(); + void reset(Ref skeleton); void translate(float x, float y); diff --git a/spine-godot/spine_godot/SpinePhysicsConstraintData.cpp b/spine-godot/spine_godot/SpinePhysicsConstraintData.cpp index 8c6bb4474..fa8fbd8c4 100644 --- a/spine-godot/spine_godot/SpinePhysicsConstraintData.cpp +++ b/spine-godot/spine_godot/SpinePhysicsConstraintData.cpp @@ -55,7 +55,7 @@ void SpinePhysicsConstraintData::_bind_methods() { Ref SpinePhysicsConstraintData::get_bone() { SPINE_CHECK(get_spine_constraint_data(), nullptr) - auto bone = get_spine_constraint_data()->getBone(); + auto bone = &get_spine_constraint_data()->getBone(); if (!bone) return nullptr; Ref slot_ref(memnew(SpineBoneData)); slot_ref->set_spine_object(get_spine_owner(), bone); @@ -84,70 +84,70 @@ float SpinePhysicsConstraintData::get_step() { float SpinePhysicsConstraintData::get_inertia() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getInertia(); + return get_spine_constraint_data()->getSetupPose().getInertia(); } float SpinePhysicsConstraintData::get_strength() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getStrength(); + return get_spine_constraint_data()->getSetupPose().getStrength(); } float SpinePhysicsConstraintData::get_damping() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getDamping(); + return get_spine_constraint_data()->getSetupPose().getDamping(); } float SpinePhysicsConstraintData::get_mass_inverse() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getMassInverse(); + return get_spine_constraint_data()->getSetupPose().getMassInverse(); } float SpinePhysicsConstraintData::get_wind() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getWind(); + return get_spine_constraint_data()->getSetupPose().getWind(); } float SpinePhysicsConstraintData::get_gravity() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getGravity(); + return get_spine_constraint_data()->getSetupPose().getGravity(); } float SpinePhysicsConstraintData::get_mix() { SPINE_CHECK(get_spine_constraint_data(), 0) - return get_spine_constraint_data()->getMix(); + return get_spine_constraint_data()->getSetupPose().getMix(); } bool SpinePhysicsConstraintData::is_inertia_global() { SPINE_CHECK(get_spine_constraint_data(), false) - return get_spine_constraint_data()->isInertiaGlobal(); + return get_spine_constraint_data()->getInertiaGlobal(); } bool SpinePhysicsConstraintData::is_strength_global() { SPINE_CHECK(get_spine_constraint_data(), false) - return get_spine_constraint_data()->isStrengthGlobal(); + return get_spine_constraint_data()->getStrengthGlobal(); } bool SpinePhysicsConstraintData::is_damping_global() { SPINE_CHECK(get_spine_constraint_data(), false) - return get_spine_constraint_data()->isDampingGlobal(); + return get_spine_constraint_data()->getDampingGlobal(); } bool SpinePhysicsConstraintData::is_mass_global() { SPINE_CHECK(get_spine_constraint_data(), false) - return get_spine_constraint_data()->isMassGlobal(); + return get_spine_constraint_data()->getMassGlobal(); } bool SpinePhysicsConstraintData::is_wind_global() { SPINE_CHECK(get_spine_constraint_data(), false) - return get_spine_constraint_data()->isWindGlobal(); + return get_spine_constraint_data()->getWindGlobal(); } bool SpinePhysicsConstraintData::is_gravity_global() { SPINE_CHECK(get_spine_constraint_data(), false) - return get_spine_constraint_data()->isGravityGlobal(); + return get_spine_constraint_data()->getGravityGlobal(); } bool SpinePhysicsConstraintData::is_mix_global() { SPINE_CHECK(get_spine_constraint_data(), false) - return get_spine_constraint_data()->isMixGlobal(); + return get_spine_constraint_data()->getMixGlobal(); } diff --git a/spine-godot/spine_godot/SpineSkeleton.h b/spine-godot/spine_godot/SpineSkeleton.h index c2634b99b..e3d7893b7 100644 --- a/spine-godot/spine_godot/SpineSkeleton.h +++ b/spine-godot/spine_godot/SpineSkeleton.h @@ -54,6 +54,10 @@ class SpineSkeleton : public REFCOUNTED { friend class SpineAnimationTrack; friend class SpineBoneNode; friend class SpineSlotNode; + friend class SpinePhysicsConstraint; + friend class SpineIkConstraint; + friend class SpineTransformConstraint; + friend class SpinePathConstraint; protected: static void _bind_methods(); @@ -70,7 +74,7 @@ protected: private: spine::Skeleton *skeleton; SpineSprite *sprite; - spine::Vector bounds_vertex_buffer; + spine::Array bounds_vertex_buffer; Ref last_skin; std::unordered_map> _cached_bones; diff --git a/spine-godot/spine_godot/SpineSkeletonFileResource.h b/spine-godot/spine_godot/SpineSkeletonFileResource.h index 960dd089b..d13106d0a 100644 --- a/spine-godot/spine_godot/SpineSkeletonFileResource.h +++ b/spine-godot/spine_godot/SpineSkeletonFileResource.h @@ -41,7 +41,7 @@ #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" #endif -#include +#include class SpineSkeletonFileResource : public Resource { GDCLASS(SpineSkeletonFileResource, Resource); diff --git a/spine-godot/spine_godot/SpineSkin.cpp b/spine-godot/spine_godot/SpineSkin.cpp index db633871d..cd073f0cb 100644 --- a/spine-godot/spine_godot/SpineSkin.cpp +++ b/spine-godot/spine_godot/SpineSkin.cpp @@ -95,7 +95,7 @@ void SpineSkin::remove_attachment(int slot_index, const String &name) { Array SpineSkin::find_names_for_slot(int slot_index) { Array result; SPINE_CHECK(get_spine_object(), result) - spine::Vector names; + spine::Array names; get_spine_object()->findNamesForSlot(slot_index, names); result.resize((int) names.size()); for (int i = 0; i < names.size(); ++i) { @@ -107,7 +107,7 @@ Array SpineSkin::find_names_for_slot(int slot_index) { Array SpineSkin::find_attachments_for_slot(int slot_index) { Array result; SPINE_CHECK(get_spine_object(), result) - spine::Vector attachments; + spine::Array attachments; get_spine_object()->findAttachmentsForSlot(slot_index, attachments); result.resize((int) attachments.size()); for (int i = 0; i < attachments.size(); ++i) { @@ -135,7 +135,7 @@ void SpineSkin::add_skin(Ref other) { ERR_PRINT("other is not a valid SpineSkin."); return; } - get_spine_object()->addSkin(other->get_spine_object()); + get_spine_object()->addSkin(*other->get_spine_object()); } void SpineSkin::copy_skin(Ref other) { @@ -144,7 +144,7 @@ void SpineSkin::copy_skin(Ref other) { ERR_PRINT("other is not a valid SpineSkin."); return; } - get_spine_object()->copySkin(other->get_spine_object()); + get_spine_object()->copySkin(*other->get_spine_object()); } Array SpineSkin::get_attachments() { diff --git a/spine-godot/spine_godot/SpineSlotData.cpp b/spine-godot/spine_godot/SpineSlotData.cpp index 077b38d9e..29b0f24e0 100644 --- a/spine-godot/spine_godot/SpineSlotData.cpp +++ b/spine-godot/spine_godot/SpineSlotData.cpp @@ -68,36 +68,36 @@ Ref SpineSlotData::get_bone_data() { Color SpineSlotData::get_color() { SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0)) - auto &color = get_spine_object()->getColor(); + auto &color = get_spine_object()->getSetupPose().getColor(); return Color(color.r, color.g, color.b, color.a); } void SpineSlotData::set_color(Color v) { SPINE_CHECK(get_spine_object(), ) - auto &color = get_spine_object()->getColor(); + auto &color = get_spine_object()->getSetupPose().getColor(); color.set(v.r, v.g, v.b, v.a); } Color SpineSlotData::get_dark_color() { SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0)) - auto &color = get_spine_object()->getDarkColor(); + auto &color = get_spine_object()->getSetupPose().getDarkColor(); return Color(color.r, color.g, color.b, color.a); } void SpineSlotData::set_dark_color(Color v) { SPINE_CHECK(get_spine_object(), ) - auto &color = get_spine_object()->getDarkColor(); + auto &color = get_spine_object()->getSetupPose().getDarkColor(); color.set(v.r, v.g, v.b, v.a); } bool SpineSlotData::has_dark_color() { SPINE_CHECK(get_spine_object(), false) - return get_spine_object()->hasDarkColor(); + return get_spine_object()->getSetupPose().hasDarkColor(); } void SpineSlotData::set_has_dark_color(bool v) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->setHasDarkColor(v); + get_spine_object()->getSetupPose().setHasDarkColor(v); } String SpineSlotData::get_attachment_name() { diff --git a/spine-godot/spine_godot/SpineSprite.h b/spine-godot/spine_godot/SpineSprite.h index 4dbaaee98..e67643f51 100644 --- a/spine-godot/spine_godot/SpineSprite.h +++ b/spine-godot/spine_godot/SpineSprite.h @@ -159,7 +159,7 @@ protected: bool debug_clipping; Color debug_clipping_color; - spine::Vector> slot_nodes; + spine::Array> slot_nodes; Vector mesh_instances; Ref normal_material; Ref additive_material; diff --git a/spine-godot/spine_godot/SpineTransformConstraint.cpp b/spine-godot/spine_godot/SpineTransformConstraint.cpp index 4d7a81dc0..37450909f 100644 --- a/spine-godot/spine_godot/SpineTransformConstraint.cpp +++ b/spine-godot/spine_godot/SpineTransformConstraint.cpp @@ -29,10 +29,11 @@ #include "SpineTransformConstraint.h" #include "SpineCommon.h" +#include "SpineSkeleton.h" #include "SpineSprite.h" void SpineTransformConstraint::_bind_methods() { - ClassDB::bind_method(D_METHOD("update"), &SpineTransformConstraint::update); + 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); @@ -53,14 +54,9 @@ void SpineTransformConstraint::_bind_methods() { ClassDB::bind_method(D_METHOD("set_active", "v"), &SpineTransformConstraint::set_active); } -void SpineTransformConstraint::update() { +void SpineTransformConstraint::update(Ref skeleton) { SPINE_CHECK(get_spine_object(), ) - get_spine_object()->update(spine::Physics_Update); -} - -int SpineTransformConstraint::get_order() { - SPINE_CHECK(get_spine_object(), 0) - return get_spine_object()->getOrder(); + get_spine_object()->update(*skeleton->get_spine_object(), spine::Physics_Update); } Ref SpineTransformConstraint::get_data() { diff --git a/spine-godot/spine_godot/SpineTransformConstraint.h b/spine-godot/spine_godot/SpineTransformConstraint.h index 6fc6ea23a..e47b0759d 100644 --- a/spine-godot/spine_godot/SpineTransformConstraint.h +++ b/spine-godot/spine_godot/SpineTransformConstraint.h @@ -30,6 +30,7 @@ #pragma once #include "SpineCommon.h" +#include "SpineSkeleton.h" #include "SpineTransformConstraintData.h" #include "SpineBone.h" #include @@ -41,9 +42,7 @@ protected: static void _bind_methods(); public: - void update(); - - int get_order(); + void update(Ref skeleton); Ref get_data();