mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[godot] Expose slider, fix new/removed properties on Spine object wrappers.
This commit is contained in:
parent
fa0f92958c
commit
7f1daa1607
@ -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);
|
||||
};
|
||||
|
||||
@ -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 <spine/SkeletonClipping.h>
|
||||
|
||||
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<SpinePhysicsConstraint> SpineSkeleton::find_physics_constraint(const String
|
||||
return constraint_ref;
|
||||
}
|
||||
|
||||
Ref<SpineSlider> SpineSkeleton::find_slider(const String &slider_name) {
|
||||
SPINE_CHECK(skeleton, nullptr)
|
||||
if (EMPTY(slider_name)) return nullptr;
|
||||
auto slider = skeleton->findConstraint<spine::Slider>(SPINE_STRING_TMP(slider_name));
|
||||
if (!slider) return nullptr;
|
||||
Ref<SpineSlider> 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<SpineSlider> slider_ref(memnew(SpineSlider));
|
||||
slider_ref->set_spine_object(sprite, (spine::Slider *)constraint);
|
||||
result.append(slider_ref);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Ref<SpineSkin> SpineSkeleton::get_skin() {
|
||||
SPINE_CHECK(skeleton, nullptr)
|
||||
auto skin = skeleton->getSkin();
|
||||
|
||||
@ -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<SpinePhysicsConstraint> find_physics_constraint(const String &constraint_name);
|
||||
|
||||
Ref<SpineSlider> find_slider(const String &slider_name);
|
||||
|
||||
Rect2 get_bounds();
|
||||
|
||||
Ref<SpineBone> get_root_bone();
|
||||
@ -133,6 +137,8 @@ public:
|
||||
|
||||
Array get_physics_constraints();
|
||||
|
||||
Array get_sliders();
|
||||
|
||||
Ref<SpineSkin> get_skin();
|
||||
|
||||
Color get_color();
|
||||
|
||||
99
spine-godot/spine_godot/SpineSlider.cpp
Normal file
99
spine-godot/spine_godot/SpineSlider.cpp
Normal file
@ -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<SpineSkeleton> skeleton, SpineConstant::Physics physics) {
|
||||
SPINE_CHECK(get_spine_object(), )
|
||||
get_spine_object()->update(*skeleton->get_spine_object(), (spine::Physics) physics);
|
||||
}
|
||||
|
||||
Ref<SpineSliderData> SpineSlider::get_data() {
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto &data = get_spine_object()->getData();
|
||||
Ref<SpineSliderData> data_ref(memnew(SpineSliderData));
|
||||
data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &data);
|
||||
return data_ref;
|
||||
}
|
||||
|
||||
Ref<SpineBone> SpineSlider::get_bone() {
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto &bone = get_spine_object()->getBone();
|
||||
Ref<SpineBone> bone_ref(memnew(SpineBone));
|
||||
bone_ref->set_spine_object(get_spine_owner(), &bone);
|
||||
return bone_ref;
|
||||
}
|
||||
|
||||
void SpineSlider::set_bone(Ref<SpineBone> v) {
|
||||
SPINE_CHECK(get_spine_object(), )
|
||||
if (v.is_valid() && v->get_spine_object()) {
|
||||
get_spine_object()->setBone(*v->get_spine_object());
|
||||
}
|
||||
}
|
||||
|
||||
Ref<SpineSliderPose> SpineSlider::get_pose() {
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto &pose = get_spine_object()->getPose();
|
||||
Ref<SpineSliderPose> pose_ref(memnew(SpineSliderPose));
|
||||
pose_ref->set_spine_object(get_spine_owner(), &pose);
|
||||
return pose_ref;
|
||||
}
|
||||
|
||||
Ref<SpineSliderPose> SpineSlider::get_applied_pose() {
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto &pose = get_spine_object()->getAppliedPose();
|
||||
Ref<SpineSliderPose> 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);
|
||||
}
|
||||
59
spine-godot/spine_godot/SpineSlider.h
Normal file
59
spine-godot/spine_godot/SpineSlider.h
Normal file
@ -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 <spine/Slider.h>
|
||||
|
||||
class SpineSliderPose;
|
||||
class SpineSkeleton;
|
||||
|
||||
class SpineSlider : public SpineSpriteOwnedObject<spine::Slider> {
|
||||
GDCLASS(SpineSlider, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void update(Ref<SpineSkeleton> skeleton, SpineConstant::Physics physics);
|
||||
|
||||
Ref<SpineSliderData> get_data();
|
||||
|
||||
Ref<SpineBone> get_bone();
|
||||
void set_bone(Ref<SpineBone> v);
|
||||
|
||||
Ref<SpineSliderPose> get_pose();
|
||||
Ref<SpineSliderPose> get_applied_pose();
|
||||
|
||||
bool is_active();
|
||||
void set_active(bool v);
|
||||
};
|
||||
132
spine-godot/spine_godot/SpineSliderData.cpp
Normal file
132
spine-godot/spine_godot/SpineSliderData.cpp
Normal file
@ -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<SpineAnimation> SpineSliderData::get_animation() {
|
||||
SPINE_CHECK(get_spine_constraint_data(), nullptr)
|
||||
auto &animation = get_spine_constraint_data()->getAnimation();
|
||||
Ref<SpineAnimation> 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<SpineBoneData> SpineSliderData::get_bone() {
|
||||
SPINE_CHECK(get_spine_constraint_data(), nullptr)
|
||||
auto bone = get_spine_constraint_data()->getBone();
|
||||
if (!bone) return nullptr;
|
||||
Ref<SpineBoneData> bone_ref(memnew(SpineBoneData));
|
||||
bone_ref->set_spine_object(get_spine_owner(), bone);
|
||||
return bone_ref;
|
||||
}
|
||||
|
||||
void SpineSliderData::set_bone(Ref<SpineBoneData> 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<SpineSliderPose> SpineSliderData::get_setup_pose() {
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto &pose = get_spine_constraint_data()->getSetupPose();
|
||||
Ref<SpineSliderPose> pose_ref(memnew(SpineSliderPose));
|
||||
pose_ref->set_spine_object(get_spine_owner(), &pose);
|
||||
return pose_ref;
|
||||
}
|
||||
71
spine-godot/spine_godot/SpineSliderData.h
Normal file
71
spine-godot/spine_godot/SpineSliderData.h
Normal file
@ -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 <spine/SliderData.h>
|
||||
|
||||
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<SpineAnimation> get_animation();
|
||||
|
||||
bool get_additive();
|
||||
void set_additive(bool value);
|
||||
|
||||
bool get_loop();
|
||||
void set_loop(bool value);
|
||||
|
||||
Ref<SpineBoneData> get_bone();
|
||||
void set_bone(Ref<SpineBoneData> 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<SpineSliderPose> get_setup_pose();
|
||||
};
|
||||
@ -859,7 +859,7 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> 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<SpineSkeleton> 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
|
||||
|
||||
@ -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<SpineTransformConstraintPose> SpineTransformConstraintData::get_setup_pose() {
|
||||
|
||||
@ -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<SpineTransformConstraintPose> get_setup_pose();
|
||||
};
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user