diff --git a/spine-godot/spine_godot/SpineConstraintData.h b/spine-godot/spine_godot/SpineConstraintData.h index 80b3db7f3..0f250d529 100644 --- a/spine-godot/spine_godot/SpineConstraintData.h +++ b/spine-godot/spine_godot/SpineConstraintData.h @@ -43,11 +43,5 @@ protected: public: String get_constraint_name(); - int get_order(); - - void set_order(int v); - bool is_skin_required(); - - void set_skin_required(bool v); }; diff --git a/spine-godot/spine_godot/SpineSkeleton.cpp b/spine-godot/spine_godot/SpineSkeleton.cpp index b4f46e9bc..388c41a06 100644 --- a/spine-godot/spine_godot/SpineSkeleton.cpp +++ b/spine-godot/spine_godot/SpineSkeleton.cpp @@ -34,10 +34,12 @@ #include "SpineTransformConstraint.h" #include "SpinePathConstraint.h" #include "SpinePhysicsConstraint.h" +#include "SpineSlider.h" #include "spine/IkConstraint.h" #include "spine/PathConstraint.h" #include "spine/PhysicsConstraint.h" #include "spine/TransformConstraint.h" +#include "spine/Slider.h" #include void SpineSkeleton::_bind_methods() { @@ -56,6 +58,7 @@ void SpineSkeleton::_bind_methods() { ClassDB::bind_method(D_METHOD("find_transform_constraint", "constraint_name"), &SpineSkeleton::find_transform_constraint); ClassDB::bind_method(D_METHOD("find_path_constraint", "constraint_name"), &SpineSkeleton::find_path_constraint); ClassDB::bind_method(D_METHOD("find_physics_constraint", "constraint_name"), &SpineSkeleton::find_physics_constraint); + ClassDB::bind_method(D_METHOD("find_slider", "slider_name"), &SpineSkeleton::find_slider); ClassDB::bind_method(D_METHOD("get_bounds"), &SpineSkeleton::get_bounds); ClassDB::bind_method(D_METHOD("get_root_bone"), &SpineSkeleton::get_root_bone); ClassDB::bind_method(D_METHOD("get_data"), &SpineSkeleton::get_skeleton_data_res); @@ -65,6 +68,7 @@ void SpineSkeleton::_bind_methods() { ClassDB::bind_method(D_METHOD("get_ik_constraints"), &SpineSkeleton::get_ik_constraints); ClassDB::bind_method(D_METHOD("get_path_constraints"), &SpineSkeleton::get_path_constraints); ClassDB::bind_method(D_METHOD("get_transform_constraints"), &SpineSkeleton::get_transform_constraints); + ClassDB::bind_method(D_METHOD("get_sliders"), &SpineSkeleton::get_sliders); ClassDB::bind_method(D_METHOD("get_skin"), &SpineSkeleton::get_skin); ClassDB::bind_method(D_METHOD("get_color"), &SpineSkeleton::get_color); ClassDB::bind_method(D_METHOD("set_color", "v"), &SpineSkeleton::set_color); @@ -229,6 +233,16 @@ Ref SpineSkeleton::find_physics_constraint(const String return constraint_ref; } +Ref SpineSkeleton::find_slider(const String &slider_name) { + SPINE_CHECK(skeleton, nullptr) + if (EMPTY(slider_name)) return nullptr; + auto slider = skeleton->findConstraint(SPINE_STRING_TMP(slider_name)); + if (!slider) return nullptr; + Ref slider_ref(memnew(SpineSlider)); + slider_ref->set_spine_object(sprite, slider); + return slider_ref; +} + Rect2 SpineSkeleton::get_bounds() { SPINE_CHECK(skeleton, Rect2(0, 0, 0, 0)) float x, y, w, h; @@ -356,6 +370,20 @@ Array SpineSkeleton::get_physics_constraints() { return result; } +Array SpineSkeleton::get_sliders() { + Array result; + SPINE_CHECK(skeleton, result) + auto &constraints = skeleton->getConstraints(); + for (int i = 0; i < constraints.size(); ++i) { + auto constraint = constraints[i]; + if (!constraint->getRTTI().isExactly(spine::Slider::rtti) == false) continue; + Ref slider_ref(memnew(SpineSlider)); + slider_ref->set_spine_object(sprite, (spine::Slider *)constraint); + result.append(slider_ref); + } + return result; +} + Ref SpineSkeleton::get_skin() { SPINE_CHECK(skeleton, nullptr) auto skin = skeleton->getSkin(); diff --git a/spine-godot/spine_godot/SpineSkeleton.h b/spine-godot/spine_godot/SpineSkeleton.h index 87b127aa1..72b2f7cfc 100644 --- a/spine-godot/spine_godot/SpineSkeleton.h +++ b/spine-godot/spine_godot/SpineSkeleton.h @@ -42,6 +42,7 @@ class SpineIkConstraint; class SpineTransformConstraint; class SpinePathConstraint; class SpinePhysicsConstraint; +class SpineSlider; class SpineSkeleton : public REFCOUNTED { GDCLASS(SpineSkeleton, REFCOUNTED); @@ -59,6 +60,7 @@ class SpineSkeleton : public REFCOUNTED { friend class SpineIkConstraint; friend class SpineTransformConstraint; friend class SpinePathConstraint; + friend class SpineSlider; protected: static void _bind_methods(); @@ -115,6 +117,8 @@ public: Ref find_physics_constraint(const String &constraint_name); + Ref find_slider(const String &slider_name); + Rect2 get_bounds(); Ref get_root_bone(); @@ -133,6 +137,8 @@ public: Array get_physics_constraints(); + Array get_sliders(); + Ref get_skin(); Color get_color(); diff --git a/spine-godot/spine_godot/SpineSlider.cpp b/spine-godot/spine_godot/SpineSlider.cpp new file mode 100644 index 000000000..6837c905c --- /dev/null +++ b/spine-godot/spine_godot/SpineSlider.cpp @@ -0,0 +1,99 @@ +/****************************************************************************** + * 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 "SpineSlider.h" +#include "SpineSliderPose.h" +#include "SpineCommon.h" +#include "SpineSkeleton.h" +#include "SpineSprite.h" + +void SpineSlider::_bind_methods() { + ClassDB::bind_method(D_METHOD("update", "skeleton", "physics"), &SpineSlider::update); + ClassDB::bind_method(D_METHOD("get_data"), &SpineSlider::get_data); + ClassDB::bind_method(D_METHOD("get_bone"), &SpineSlider::get_bone); + ClassDB::bind_method(D_METHOD("set_bone", "v"), &SpineSlider::set_bone); + ClassDB::bind_method(D_METHOD("get_pose"), &SpineSlider::get_pose); + ClassDB::bind_method(D_METHOD("get_applied_pose"), &SpineSlider::get_applied_pose); + ClassDB::bind_method(D_METHOD("is_active"), &SpineSlider::is_active); + ClassDB::bind_method(D_METHOD("set_active", "v"), &SpineSlider::set_active); +} + +void SpineSlider::update(Ref skeleton, SpineConstant::Physics physics) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->update(*skeleton->get_spine_object(), (spine::Physics) physics); +} + +Ref SpineSlider::get_data() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &data = get_spine_object()->getData(); + Ref data_ref(memnew(SpineSliderData)); + data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &data); + return data_ref; +} + +Ref SpineSlider::get_bone() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &bone = get_spine_object()->getBone(); + Ref bone_ref(memnew(SpineBone)); + bone_ref->set_spine_object(get_spine_owner(), &bone); + return bone_ref; +} + +void SpineSlider::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()); + } +} + +Ref SpineSlider::get_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_object()->getPose(); + Ref pose_ref(memnew(SpineSliderPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; +} + +Ref SpineSlider::get_applied_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_object()->getAppliedPose(); + Ref pose_ref(memnew(SpineSliderPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; +} + +bool SpineSlider::is_active() { + SPINE_CHECK(get_spine_object(), false) + return get_spine_object()->isActive(); +} + +void SpineSlider::set_active(bool v) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setActive(v); +} \ No newline at end of file diff --git a/spine-godot/spine_godot/SpineSlider.h b/spine-godot/spine_godot/SpineSlider.h new file mode 100644 index 000000000..bd0e66049 --- /dev/null +++ b/spine-godot/spine_godot/SpineSlider.h @@ -0,0 +1,59 @@ +/****************************************************************************** + * 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 "SpineSliderData.h" +#include "SpineBone.h" +#include + +class SpineSliderPose; +class SpineSkeleton; + +class SpineSlider : public SpineSpriteOwnedObject { + GDCLASS(SpineSlider, SpineObjectWrapper) + +protected: + static void _bind_methods(); + +public: + void update(Ref skeleton, SpineConstant::Physics physics); + + Ref get_data(); + + Ref get_bone(); + void set_bone(Ref v); + + Ref get_pose(); + Ref get_applied_pose(); + + bool is_active(); + void set_active(bool v); +}; \ No newline at end of file diff --git a/spine-godot/spine_godot/SpineSliderData.cpp b/spine-godot/spine_godot/SpineSliderData.cpp new file mode 100644 index 000000000..37c573d01 --- /dev/null +++ b/spine-godot/spine_godot/SpineSliderData.cpp @@ -0,0 +1,132 @@ +/****************************************************************************** + * 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 "SpineSliderData.h" +#include "SpineSliderPose.h" +#include "SpineAnimation.h" +#include "SpineCommon.h" + +void SpineSliderData::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_animation"), &SpineSliderData::get_animation); + ClassDB::bind_method(D_METHOD("get_additive"), &SpineSliderData::get_additive); + ClassDB::bind_method(D_METHOD("set_additive", "value"), &SpineSliderData::set_additive); + ClassDB::bind_method(D_METHOD("get_loop"), &SpineSliderData::get_loop); + ClassDB::bind_method(D_METHOD("set_loop", "value"), &SpineSliderData::set_loop); + ClassDB::bind_method(D_METHOD("get_bone"), &SpineSliderData::get_bone); + ClassDB::bind_method(D_METHOD("set_bone", "value"), &SpineSliderData::set_bone); + ClassDB::bind_method(D_METHOD("get_scale"), &SpineSliderData::get_scale); + ClassDB::bind_method(D_METHOD("set_scale", "value"), &SpineSliderData::set_scale); + ClassDB::bind_method(D_METHOD("get_offset"), &SpineSliderData::get_offset); + ClassDB::bind_method(D_METHOD("set_offset", "value"), &SpineSliderData::set_offset); + ClassDB::bind_method(D_METHOD("get_local"), &SpineSliderData::get_local); + ClassDB::bind_method(D_METHOD("set_local", "value"), &SpineSliderData::set_local); + ClassDB::bind_method(D_METHOD("get_setup_pose"), &SpineSliderData::get_setup_pose); +} + +Ref SpineSliderData::get_animation() { + SPINE_CHECK(get_spine_constraint_data(), nullptr) + auto &animation = get_spine_constraint_data()->getAnimation(); + Ref animation_ref(memnew(SpineAnimation)); + animation_ref->set_spine_object(get_spine_owner(), &animation); + return animation_ref; +} + +bool SpineSliderData::get_additive() { + SPINE_CHECK(get_spine_constraint_data(), false) + return get_spine_constraint_data()->getAdditive(); +} + +void SpineSliderData::set_additive(bool value) { + SPINE_CHECK(get_spine_constraint_data(), ) + get_spine_constraint_data()->setAdditive(value); +} + +bool SpineSliderData::get_loop() { + SPINE_CHECK(get_spine_constraint_data(), false) + return get_spine_constraint_data()->getLoop(); +} + +void SpineSliderData::set_loop(bool value) { + SPINE_CHECK(get_spine_constraint_data(), ) + get_spine_constraint_data()->setLoop(value); +} + +Ref SpineSliderData::get_bone() { + SPINE_CHECK(get_spine_constraint_data(), nullptr) + auto bone = get_spine_constraint_data()->getBone(); + if (!bone) return nullptr; + Ref bone_ref(memnew(SpineBoneData)); + bone_ref->set_spine_object(get_spine_owner(), bone); + return bone_ref; +} + +void SpineSliderData::set_bone(Ref value) { + SPINE_CHECK(get_spine_constraint_data(), ) + if (value.is_valid() && value->get_spine_object()) { + get_spine_constraint_data()->setBone(value->get_spine_object()); + } +} + +float SpineSliderData::get_scale() { + SPINE_CHECK(get_spine_constraint_data(), 0) + return get_spine_constraint_data()->getScale(); +} + +void SpineSliderData::set_scale(float value) { + SPINE_CHECK(get_spine_constraint_data(), ) + get_spine_constraint_data()->setScale(value); +} + +float SpineSliderData::get_offset() { + SPINE_CHECK(get_spine_constraint_data(), 0) + return get_spine_constraint_data()->getOffset(); +} + +void SpineSliderData::set_offset(float value) { + SPINE_CHECK(get_spine_constraint_data(), ) + get_spine_constraint_data()->setOffset(value); +} + +bool SpineSliderData::get_local() { + SPINE_CHECK(get_spine_constraint_data(), false) + return get_spine_constraint_data()->getLocal(); +} + +void SpineSliderData::set_local(bool value) { + SPINE_CHECK(get_spine_constraint_data(), ) + get_spine_constraint_data()->setLocal(value); +} + +Ref SpineSliderData::get_setup_pose() { + SPINE_CHECK(get_spine_object(), nullptr) + auto &pose = get_spine_constraint_data()->getSetupPose(); + Ref pose_ref(memnew(SpineSliderPose)); + pose_ref->set_spine_object(get_spine_owner(), &pose); + return pose_ref; +} \ No newline at end of file diff --git a/spine-godot/spine_godot/SpineSliderData.h b/spine-godot/spine_godot/SpineSliderData.h new file mode 100644 index 000000000..02aa89409 --- /dev/null +++ b/spine-godot/spine_godot/SpineSliderData.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 "SpineConstraintData.h" +#include "SpineBoneData.h" +#include + +class SpineAnimation; +class SpineSliderPose; + +class SpineSliderData : public SpineConstraintData { + GDCLASS(SpineSliderData, SpineConstraintData) + + spine::SliderData *get_spine_constraint_data() { + return (spine::SliderData *) get_spine_object(); + } + +protected: + static void _bind_methods(); + +public: + Ref get_animation(); + + bool get_additive(); + void set_additive(bool value); + + bool get_loop(); + void set_loop(bool value); + + Ref get_bone(); + void set_bone(Ref value); + + float get_scale(); + void set_scale(float value); + + float get_offset(); + void set_offset(float value); + + bool get_local(); + void set_local(bool value); + + Ref get_setup_pose(); +}; \ No newline at end of file diff --git a/spine-godot/spine_godot/SpineSprite.cpp b/spine-godot/spine_godot/SpineSprite.cpp index 41ac7d1b0..8845a9d53 100644 --- a/spine-godot/spine_godot/SpineSprite.cpp +++ b/spine-godot/spine_godot/SpineSprite.cpp @@ -859,7 +859,7 @@ void SpineSprite::update_meshes(Ref skeleton_ref) { vertices->setSize(8, 0); region->computeWorldVertices(*slot, *vertices, 0); - renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) region->getRegion())->page->texture; + renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) region->getRegion())->getPage()->texture; uvs = ®ion->getUVs(); indices = &statics.quad_indices; @@ -872,8 +872,9 @@ void SpineSprite::update_meshes(Ref skeleton_ref) { auto mesh = (spine::MeshAttachment *) attachment; vertices->setSize(mesh->getWorldVerticesLength(), 0); - mesh->computeWorldVertices(*skeleton, *slot, *vertices); - renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) mesh->getRegion())->page->texture; + mesh->computeWorldVertices(*skeleton, *slot, 0, mesh->getWorldVerticesLength(), vertices->buffer(), 0, 2); + + renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) mesh->getRegion())->getPage()->texture; uvs = &mesh->getUVs(); indices = &mesh->getTriangles(); @@ -1075,15 +1076,15 @@ void SpineSprite::draw() { draw_set_transform(Vector2(0, 0), 0, Vector2(1, 1)); auto &draw_order = skeleton->get_spine_object()->getDrawOrder(); for (int i = 0; i < (int) draw_order.size(); i++) { - auto *slot = draw_order[i]; + auto slot = draw_order[i]; if (!slot->getBone().isActive()) continue; - auto *attachment = slot->getAppliedPose().getAttachment(); + auto attachment = slot->getAppliedPose().getAttachment(); if (!attachment) continue; if (!attachment->getRTTI().isExactly(spine::MeshAttachment::rtti)) continue; - auto *mesh = (spine::MeshAttachment *) attachment; - auto *vertices = &statics.scratch_vertices; + auto mesh = (spine::MeshAttachment *) attachment; + auto vertices = &statics.scratch_vertices; vertices->setSize(mesh->getWorldVerticesLength(), 0); - mesh->computeWorldVertices(*slot, *vertices); + mesh->computeWorldVertices(*skeleton->get_spine_object(), *slot, 0, mesh->getWorldVerticesLength(), vertices->buffer(), 0, 2); // Render triangles. createLinesFromMesh(statics.scratch_points, mesh->getTriangles(), vertices); @@ -1123,7 +1124,7 @@ void SpineSprite::draw() { auto bounding_box = (spine::BoundingBoxAttachment *) attachment; auto vertices = &statics.scratch_vertices; vertices->setSize(bounding_box->getWorldVerticesLength(), 0); - bounding_box->computeWorldVertices(*slot, *vertices); + bounding_box->computeWorldVertices(*skeleton->get_spine_object(), *slot, 0, bounding_box->getWorldVerticesLength(), vertices->buffer(), 0, 2); size_t num_vertices = vertices->size() / 2; statics.scratch_points.resize((int) num_vertices); memcpy(statics.scratch_points.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float)); @@ -1144,7 +1145,7 @@ void SpineSprite::draw() { auto clipping = (spine::ClippingAttachment *) attachment; auto vertices = &statics.scratch_vertices; vertices->setSize(clipping->getWorldVerticesLength(), 0); - clipping->computeWorldVertices(*slot, *vertices); + clipping->computeWorldVertices(*skeleton->get_spine_object(), *slot, 0, clipping->getWorldVerticesLength(), vertices->buffer(), 0, 2); size_t num_vertices = vertices->size() / 2; statics.scratch_points.resize((int) num_vertices); memcpy(statics.scratch_points.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float)); @@ -1288,8 +1289,8 @@ void SpineSprite::draw() { } void SpineSprite::draw_bone(spine::Bone *bone, const Color &color) { - draw_set_transform(Vector2(bone->getWorldX(), bone->getWorldY()), spine::MathUtil::Deg_Rad * bone->getWorldRotationX(), - Vector2(bone->getWorldScaleX(), bone->getWorldScaleY())); + draw_set_transform(Vector2(bone->getAppliedPose().getWorldX(), bone->getAppliedPose().getWorldY()), spine::MathUtil::Deg_Rad * bone->getAppliedPose().getWorldRotationX(), + Vector2(bone->getAppliedPose().getWorldScaleX(), bone->getAppliedPose().getWorldScaleY())); float bone_length = bone->getData().getLength(); if (bone_length == 0) bone_length = debug_bones_thickness * 2; #ifdef SPINE_GODOT_EXTENSION diff --git a/spine-godot/spine_godot/SpineTransformConstraintData.cpp b/spine-godot/spine_godot/SpineTransformConstraintData.cpp index bd519c7d4..c9cfbaf6b 100644 --- a/spine-godot/spine_godot/SpineTransformConstraintData.cpp +++ b/spine-godot/spine_godot/SpineTransformConstraintData.cpp @@ -40,8 +40,8 @@ void SpineTransformConstraintData::_bind_methods() { 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("is_local_source"), &SpineTransformConstraintData::is_local_source); + ClassDB::bind_method(D_METHOD("is_local_target"), &SpineTransformConstraintData::is_local_target); ClassDB::bind_method(D_METHOD("get_setup_pose"), &SpineTransformConstraintData::get_setup_pose); } @@ -97,14 +97,14 @@ float SpineTransformConstraintData::get_offset_shear_y() { return get_spine_constraint_data()->getOffsetShearY(); } -bool SpineTransformConstraintData::is_relative() { +bool SpineTransformConstraintData::is_local_source() { SPINE_CHECK(get_spine_constraint_data(), false) - return get_spine_constraint_data()->getRelative(); + return get_spine_constraint_data()->getLocalSource(); } -bool SpineTransformConstraintData::is_local() { +bool SpineTransformConstraintData::is_local_target() { SPINE_CHECK(get_spine_constraint_data(), false) - return get_spine_constraint_data()->getLocal(); + return get_spine_constraint_data()->getLocalTarget(); } Ref SpineTransformConstraintData::get_setup_pose() { diff --git a/spine-godot/spine_godot/SpineTransformConstraintData.h b/spine-godot/spine_godot/SpineTransformConstraintData.h index 2b3d7a888..dfc52b6bf 100644 --- a/spine-godot/spine_godot/SpineTransformConstraintData.h +++ b/spine-godot/spine_godot/SpineTransformConstraintData.h @@ -62,9 +62,9 @@ public: float get_offset_shear_y(); - bool is_relative(); + bool is_local_source(); - bool is_local(); + bool is_local_target(); Ref get_setup_pose(); }; diff --git a/spine-godot/spine_godot/register_types.cpp b/spine-godot/spine_godot/register_types.cpp index 821561b96..e02eadecb 100644 --- a/spine-godot/spine_godot/register_types.cpp +++ b/spine-godot/spine_godot/register_types.cpp @@ -63,6 +63,8 @@ #include "SpinePhysicsConstraintData.h" #include "SpinePhysicsConstraint.h" #include "SpinePhysicsConstraintPose.h" +#include "SpineSlider.h" +#include "SpineSliderData.h" #include "SpineSliderPose.h" #include "SpineTimeline.h" #include "SpineConstant.h" @@ -163,6 +165,8 @@ void register_spine_godot_types() { GDREGISTER_CLASS(SpineTransformConstraintPose); GDREGISTER_CLASS(SpinePhysicsConstraint); GDREGISTER_CLASS(SpinePhysicsConstraintPose); + GDREGISTER_CLASS(SpineSlider); + GDREGISTER_CLASS(SpineSliderData); GDREGISTER_CLASS(SpineSliderPose); GDREGISTER_CLASS(SpineTimeline); GDREGISTER_CLASS(SpineConstant);