mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
[godot] Rework invalidation of native spine objects, add unit test.
This commit is contained in:
parent
7866fff884
commit
4c417dd2c2
@ -16,5 +16,5 @@ mix = 0.2
|
||||
[resource]
|
||||
atlas_res = ExtResource( 1 )
|
||||
skeleton_file_res = ExtResource( 2 )
|
||||
default_mix = 0.2
|
||||
default_mix = 0.1
|
||||
animation_mixes = [ SubResource( 1 ), SubResource( 2 ) ]
|
||||
|
||||
@ -19,8 +19,21 @@ func test_spine_timeline():
|
||||
assert(timeline.get_property_ids() == [4294967300])
|
||||
assert(timeline.get_type() == "RotateTimeline")
|
||||
|
||||
func test_spine_object_invalidation():
|
||||
var skeleton_data = get_skeleton().get_data()
|
||||
var bone_data = skeleton_data.find_bone("gun");
|
||||
var old_bone_data_x = bone_data.get_x();
|
||||
var bone = get_skeleton().find_bone("gun")
|
||||
var old_bone_x = bone.get_x()
|
||||
skeleton_data_res = null
|
||||
assert(old_bone_x != bone.get_x())
|
||||
assert(old_bone_data_x == bone_data.get_x())
|
||||
skeleton_data.atlas_res = null;
|
||||
assert(old_bone_data_x != bone_data.get_x())
|
||||
|
||||
func _ready():
|
||||
|
||||
test_spine_animation()
|
||||
test_spine_timeline()
|
||||
test_spine_object_invalidation()
|
||||
print("All tests passed")
|
||||
|
||||
@ -46,26 +46,26 @@ void SpineAnimation::_bind_methods() {
|
||||
}
|
||||
|
||||
String SpineAnimation::get_name() {
|
||||
SPINE_CHECK(spine_object, "")
|
||||
return spine_object->getName().buffer();
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
}
|
||||
|
||||
float SpineAnimation::get_duration() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getDuration();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getDuration();
|
||||
}
|
||||
|
||||
void SpineAnimation::set_duration(float duration) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setDuration(duration);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setDuration(duration);
|
||||
}
|
||||
|
||||
void SpineAnimation::apply(Ref<SpineSkeleton> skeleton, float last_time, float time, bool loop,
|
||||
Array events, float alpha, SpineConstant::MixBlend blend,
|
||||
SpineConstant::MixDirection direction) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
spine::Vector<spine::Event *> spineEvents;
|
||||
spine_object->apply(*(skeleton->get_spine_object()), last_time, time, loop, &spineEvents, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction);
|
||||
get_spine_object()->apply(*(skeleton->get_spine_object()), last_time, time, loop, &spineEvents, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction);
|
||||
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]);
|
||||
@ -75,8 +75,8 @@ void SpineAnimation::apply(Ref<SpineSkeleton> skeleton, float last_time, float t
|
||||
|
||||
Array SpineAnimation::get_timelines() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
auto &timelines = spine_object->getTimelines();
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto &timelines = get_spine_object()->getTimelines();
|
||||
result.resize((int)timelines.size());
|
||||
|
||||
for (int i = 0; i < (int)result.size(); ++i) {
|
||||
@ -88,12 +88,12 @@ Array SpineAnimation::get_timelines() {
|
||||
}
|
||||
|
||||
bool SpineAnimation::has_timeline(Array ids) {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
spine::Vector<spine::PropertyId> property_ids;
|
||||
property_ids.setSize(ids.size(), 0);
|
||||
|
||||
for (int i = 0; i < (int)property_ids.size(); ++i) {
|
||||
property_ids[i] = (spine::PropertyId) ids[i];
|
||||
}
|
||||
return spine_object->hasTimeline(property_ids);
|
||||
return get_spine_object()->hasTimeline(property_ids);
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ class SpineSkeleton;
|
||||
class SpineTimeline;
|
||||
class SpineSkeletonDataResource;
|
||||
|
||||
class SpineAnimation : public SpineObjectWrapper<SpineSkeletonDataResource, spine::Animation> {
|
||||
class SpineAnimation : public SpineSkeletonDataResourceOwnedObject<spine::Animation> {
|
||||
GDCLASS(SpineAnimation, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -36,17 +36,17 @@ void SpineAttachment::_bind_methods() {
|
||||
}
|
||||
|
||||
SpineAttachment::~SpineAttachment() {
|
||||
if (spine_object) spine_object->dereference();
|
||||
if (get_spine_object()) get_spine_object()->dereference();
|
||||
}
|
||||
|
||||
String SpineAttachment::get_attachment_name() {
|
||||
SPINE_CHECK(spine_object, "")
|
||||
return spine_object->getName().buffer();
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
}
|
||||
|
||||
Ref<SpineAttachment> SpineAttachment::copy() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto copy = spine_object->copy();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto copy = get_spine_object()->copy();
|
||||
if (!copy) return nullptr;
|
||||
Ref<SpineAttachment> attachment_ref(memnew(SpineAttachment));
|
||||
attachment_ref->set_spine_object(get_spine_owner(), copy);
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
class SpineSkeletonDataResource;
|
||||
|
||||
class SpineAttachment : public SpineObjectWrapper<SpineSkeletonDataResource, spine::Attachment> {
|
||||
class SpineAttachment : public SpineSkeletonDataResourceOwnedObject<spine::Attachment> {
|
||||
GDCLASS(SpineAttachment, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -99,65 +99,65 @@ void SpineBone::_bind_methods() {
|
||||
}
|
||||
|
||||
void SpineBone::update_world_transform() {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->updateWorldTransform();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->updateWorldTransform();
|
||||
}
|
||||
|
||||
void SpineBone::set_to_setup_pose() {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setToSetupPose();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setToSetupPose();
|
||||
}
|
||||
|
||||
Vector2 SpineBone::world_to_local(Vector2 world_position) {
|
||||
SPINE_CHECK(spine_object, Vector2())
|
||||
SPINE_CHECK(get_spine_object(), Vector2())
|
||||
float x, y;
|
||||
spine_object->worldToLocal(world_position.x, world_position.y, x, y);
|
||||
get_spine_object()->worldToLocal(world_position.x, world_position.y, x, y);
|
||||
return Vector2(x, y);
|
||||
}
|
||||
|
||||
Vector2 SpineBone::local_to_world(Vector2 local_position) {
|
||||
SPINE_CHECK(spine_object, Vector2())
|
||||
SPINE_CHECK(get_spine_object(), Vector2())
|
||||
float x, y;
|
||||
spine_object->localToWorld(local_position.x, local_position.y, x, y);
|
||||
get_spine_object()->localToWorld(local_position.x, local_position.y, x, y);
|
||||
return Vector2(x, y);
|
||||
}
|
||||
|
||||
float SpineBone::world_to_local_rotation(float world_rotation) {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->worldToLocalRotation(world_rotation);
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->worldToLocalRotation(world_rotation);
|
||||
}
|
||||
|
||||
float SpineBone::local_to_world_rotation(float local_rotation) {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->localToWorldRotation(local_rotation);
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->localToWorldRotation(local_rotation);
|
||||
}
|
||||
|
||||
void SpineBone::rotate_world(float degrees) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->rotateWorld(degrees);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->rotateWorld(degrees);
|
||||
}
|
||||
|
||||
float SpineBone::get_world_to_local_rotation_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getWorldToLocalRotationX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getWorldToLocalRotationX();
|
||||
}
|
||||
|
||||
float SpineBone::get_world_to_local_rotation_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getWorldToLocalRotationY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getWorldToLocalRotationY();
|
||||
}
|
||||
|
||||
Ref<SpineBoneData> SpineBone::get_data() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto &bone_data = spine_object->getData();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto &bone_data = get_spine_object()->getData();
|
||||
Ref<SpineBoneData> bone_data_ref(memnew(SpineBoneData));
|
||||
bone_data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &bone_data);
|
||||
return bone_data_ref;
|
||||
}
|
||||
|
||||
Ref<SpineBone> SpineBone::get_parent() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto parent = spine_object->getParent();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto parent = get_spine_object()->getParent();
|
||||
if (!parent) return nullptr;
|
||||
Ref<SpineBone> parent_ref(memnew(SpineBone));
|
||||
parent_ref->set_spine_object(get_spine_owner(), parent);
|
||||
@ -166,8 +166,8 @@ Ref<SpineBone> SpineBone::get_parent() {
|
||||
|
||||
Array SpineBone::get_children() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
auto children = spine_object->getChildren();
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto children = get_spine_object()->getChildren();
|
||||
result.resize((int)children.size());
|
||||
for (int i = 0; i < children.size(); ++i) {
|
||||
auto child = children[i];
|
||||
@ -179,238 +179,238 @@ Array SpineBone::get_children() {
|
||||
}
|
||||
|
||||
float SpineBone::get_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getX();
|
||||
}
|
||||
|
||||
void SpineBone::set_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setX(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getY();
|
||||
}
|
||||
|
||||
void SpineBone::set_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setY(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_rotation() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getRotation();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getRotation();
|
||||
}
|
||||
|
||||
void SpineBone::set_rotation(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setRotation(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setRotation(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_scale_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getScaleX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getScaleX();
|
||||
}
|
||||
|
||||
void SpineBone::set_scale_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setScaleX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setScaleX(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_scale_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getScaleY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getScaleY();
|
||||
}
|
||||
|
||||
void SpineBone::set_scale_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setScaleY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setScaleY(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_shear_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getShearX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getShearX();
|
||||
}
|
||||
|
||||
void SpineBone::set_shear_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setShearX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setShearX(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_shear_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getShearY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getShearY();
|
||||
}
|
||||
|
||||
void SpineBone::set_shear_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setShearY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setShearY(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_applied_rotation() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAppliedRotation();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAppliedRotation();
|
||||
}
|
||||
|
||||
void SpineBone::set_applied_rotation(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAppliedRotation(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAppliedRotation(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_a_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAX();
|
||||
}
|
||||
|
||||
void SpineBone::set_a_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAX(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_a_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAY();
|
||||
}
|
||||
|
||||
void SpineBone::set_a_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAY(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_a_scale_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAScaleX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAScaleX();
|
||||
}
|
||||
|
||||
void SpineBone::set_a_scale_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAScaleX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAScaleX(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_a_scale_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAScaleY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAScaleY();
|
||||
}
|
||||
|
||||
void SpineBone::set_a_scale_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAScaleY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAScaleY(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_a_shear_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAShearX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAShearX();
|
||||
}
|
||||
|
||||
void SpineBone::set_a_shear_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAShearX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAShearX(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_a_shear_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAShearY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAShearY();
|
||||
}
|
||||
|
||||
void SpineBone::set_a_shear_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAShearY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAShearY(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_a() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getA();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getA();
|
||||
}
|
||||
|
||||
void SpineBone::set_a(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setA(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setA(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_b() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getB();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getB();
|
||||
}
|
||||
|
||||
void SpineBone::set_b(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setB(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setB(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_c() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getC();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getC();
|
||||
}
|
||||
|
||||
void SpineBone::set_c(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setC(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setC(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_d() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getD();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getD();
|
||||
}
|
||||
|
||||
void SpineBone::set_d(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setD(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setD(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_world_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getWorldX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getWorldX();
|
||||
}
|
||||
|
||||
void SpineBone::set_world_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setWorldX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setWorldX(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_world_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getWorldY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getWorldY();
|
||||
}
|
||||
|
||||
void SpineBone::set_world_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setWorldY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setWorldY(v);
|
||||
}
|
||||
|
||||
float SpineBone::get_world_rotation_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getWorldRotationX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getWorldRotationX();
|
||||
}
|
||||
|
||||
float SpineBone::get_world_rotation_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getWorldRotationY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getWorldRotationY();
|
||||
}
|
||||
|
||||
|
||||
float SpineBone::get_world_scale_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getWorldScaleX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getWorldScaleX();
|
||||
}
|
||||
|
||||
float SpineBone::get_world_scale_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getWorldScaleY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getWorldScaleY();
|
||||
}
|
||||
|
||||
bool SpineBone::is_active() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->isActive();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->isActive();
|
||||
}
|
||||
void SpineBone::set_active(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setActive(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setActive(v);
|
||||
}
|
||||
|
||||
// External feature functions
|
||||
void SpineBone::apply_world_transform_2d(const Variant &o) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
if (o.get_type() == Variant::OBJECT) {
|
||||
auto node2d = Object::cast_to<Node2D>(o.operator Object*());
|
||||
if (node2d) {
|
||||
@ -429,7 +429,7 @@ void SpineBone::apply_world_transform_2d(const Variant &o) {
|
||||
}
|
||||
|
||||
Transform2D SpineBone::get_transform() {
|
||||
SPINE_CHECK(spine_object, Transform2D())
|
||||
SPINE_CHECK(get_spine_object(), Transform2D())
|
||||
Transform2D transform;
|
||||
transform.rotate(Math::deg2rad(-get_rotation()));
|
||||
transform.scale(Size2(get_scale_x(), get_scale_y()));
|
||||
@ -438,7 +438,7 @@ Transform2D SpineBone::get_transform() {
|
||||
}
|
||||
|
||||
void SpineBone::set_transform(Transform2D transform) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
Vector2 position = transform.get_origin();
|
||||
position.y *= -1;
|
||||
float rotation = Math::rad2deg(-transform.get_rotation());
|
||||
@ -452,7 +452,7 @@ void SpineBone::set_transform(Transform2D transform) {
|
||||
}
|
||||
|
||||
Transform2D SpineBone::get_global_transform() {
|
||||
SPINE_CHECK(spine_object, Transform2D())
|
||||
SPINE_CHECK(get_spine_object(), Transform2D())
|
||||
if (!get_spine_owner()) return get_transform();
|
||||
if (!get_spine_owner()->is_visible_in_tree()) return get_transform();
|
||||
Transform2D local;
|
||||
@ -463,7 +463,7 @@ Transform2D SpineBone::get_global_transform() {
|
||||
}
|
||||
|
||||
void SpineBone::set_global_transform(Transform2D transform) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
if (!get_spine_owner()) set_transform(transform);
|
||||
if (!get_spine_owner()->is_visible_in_tree()) return;
|
||||
transform = get_spine_owner()->get_global_transform().affine_inverse() * transform;
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
class SpineSkeleton;
|
||||
class SpineSprite;
|
||||
|
||||
class SpineBone : public SpineObjectWrapper<SpineSprite, spine::Bone> {
|
||||
class SpineBone : public SpineSpriteOwnedObject<spine::Bone> {
|
||||
GDCLASS(SpineBone, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -59,18 +59,18 @@ void SpineBoneData::_bind_methods() {
|
||||
}
|
||||
|
||||
int SpineBoneData::get_index() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getIndex();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getIndex();
|
||||
}
|
||||
|
||||
String SpineBoneData::get_bone_name() {
|
||||
SPINE_CHECK(spine_object, "")
|
||||
return spine_object->getName().buffer();
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
}
|
||||
|
||||
Ref<SpineBoneData> SpineBoneData::get_parent() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto parent = spine_object->getParent();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto parent = get_spine_object()->getParent();
|
||||
if (!parent) return nullptr;
|
||||
Ref<SpineBoneData> parent_ref(memnew(SpineBoneData));
|
||||
parent_ref->set_spine_object(get_spine_owner(), parent);
|
||||
@ -78,112 +78,112 @@ Ref<SpineBoneData> SpineBoneData::get_parent() {
|
||||
}
|
||||
|
||||
float SpineBoneData::get_length() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getLength();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getLength();
|
||||
}
|
||||
|
||||
void SpineBoneData::set_length(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setLength(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setLength(v);
|
||||
}
|
||||
|
||||
float SpineBoneData::get_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getX();
|
||||
}
|
||||
|
||||
void SpineBoneData::set_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setX(v);
|
||||
}
|
||||
|
||||
float SpineBoneData::get_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getY();
|
||||
}
|
||||
|
||||
void SpineBoneData::set_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setY(v);
|
||||
}
|
||||
|
||||
float SpineBoneData::get_rotation() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getRotation();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getRotation();
|
||||
}
|
||||
|
||||
void SpineBoneData::set_rotation(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setRotation(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setRotation(v);
|
||||
}
|
||||
|
||||
float SpineBoneData::get_scale_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getScaleX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getScaleX();
|
||||
}
|
||||
|
||||
void SpineBoneData::set_scale_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setScaleX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setScaleX(v);
|
||||
}
|
||||
|
||||
float SpineBoneData::get_scale_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getScaleY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getScaleY();
|
||||
}
|
||||
|
||||
void SpineBoneData::set_scale_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setScaleY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setScaleY(v);
|
||||
}
|
||||
|
||||
float SpineBoneData::get_shear_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getShearX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getShearX();
|
||||
}
|
||||
|
||||
void SpineBoneData::set_shear_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setShearX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setShearX(v);
|
||||
}
|
||||
|
||||
float SpineBoneData::get_shear_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getShearY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getShearY();
|
||||
}
|
||||
|
||||
void SpineBoneData::set_shear_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setShearY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setShearY(v);
|
||||
}
|
||||
|
||||
SpineConstant::TransformMode SpineBoneData::get_transform_mode() {
|
||||
SPINE_CHECK(spine_object, SpineConstant::TransformMode::TransformMode_Normal)
|
||||
return (SpineConstant::TransformMode) spine_object->getTransformMode();
|
||||
SPINE_CHECK(get_spine_object(), SpineConstant::TransformMode::TransformMode_Normal)
|
||||
return (SpineConstant::TransformMode) get_spine_object()->getTransformMode();
|
||||
}
|
||||
|
||||
void SpineBoneData::set_transform_mode(SpineConstant::TransformMode v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setTransformMode((spine::TransformMode) v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setTransformMode((spine::TransformMode) v);
|
||||
}
|
||||
|
||||
bool SpineBoneData::is_skin_required() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->isSkinRequired();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->isSkinRequired();
|
||||
}
|
||||
|
||||
void SpineBoneData::set_skin_required(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setSkinRequired(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setSkinRequired(v);
|
||||
}
|
||||
|
||||
Color SpineBoneData::get_color() {
|
||||
SPINE_CHECK(spine_object, Color())
|
||||
auto color = spine_object->getColor();
|
||||
SPINE_CHECK(get_spine_object(), Color())
|
||||
auto color = get_spine_object()->getColor();
|
||||
return Color(color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
void SpineBoneData::set_color(Color color) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->getColor().set(color.r, color.g, color.b, color.a);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->getColor().set(color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
class SpineSkeletonDataResource;
|
||||
|
||||
class SpineBoneData : public SpineObjectWrapper<SpineSkeletonDataResource, spine::BoneData> {
|
||||
class SpineBoneData : public SpineSkeletonDataResourceOwnedObject<spine::BoneData> {
|
||||
GDCLASS(SpineBoneData, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -52,8 +52,6 @@
|
||||
#define VARIANT_FLOAT Variant::REAL
|
||||
#endif
|
||||
|
||||
#include "SpineObjectWrapper.h"
|
||||
|
||||
#define SPINE_CHECK(obj, ret) \
|
||||
if (!(obj)) { \
|
||||
ERR_PRINT("Native Spine object not set."); \
|
||||
@ -62,4 +60,81 @@
|
||||
|
||||
#define SPINE_STRING(x) spine::String((x).utf8())
|
||||
|
||||
// Can't do template classes with Godot's object model :(
|
||||
class SpineObjectWrapper : public REFCOUNTED {
|
||||
GDCLASS(SpineObjectWrapper, REFCOUNTED)
|
||||
|
||||
Object* spine_owner;
|
||||
void* spine_object;
|
||||
|
||||
protected:
|
||||
static void _bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_internal_spine_objects_invalidated"), &SpineObjectWrapper::spine_objects_invalidated);
|
||||
}
|
||||
|
||||
void spine_objects_invalidated() {
|
||||
spine_object = nullptr;
|
||||
spine_owner->disconnect("_internal_spine_objects_invalidated", this, "_internal_spine_objects_invalidated");
|
||||
}
|
||||
|
||||
SpineObjectWrapper(): spine_owner(nullptr), spine_object(nullptr) {
|
||||
}
|
||||
|
||||
template <typename OWNER, typename OBJECT> void _set_spine_object_internal(const OWNER* _owner, OBJECT* _object) {
|
||||
if (spine_owner) {
|
||||
ERR_PRINT("Owner already set.");
|
||||
return;
|
||||
}
|
||||
if (spine_object) {
|
||||
ERR_PRINT("Object already set.");
|
||||
return;
|
||||
}
|
||||
if (!_owner) {
|
||||
ERR_PRINT("Owner must not be null.");
|
||||
return;
|
||||
}
|
||||
|
||||
spine_owner = (Object*)_owner;
|
||||
spine_object = _object;
|
||||
spine_owner->connect("_internal_spine_objects_invalidated", this, "_internal_spine_objects_invalidated");
|
||||
}
|
||||
|
||||
void *_get_spine_object_internal() { return spine_object; }
|
||||
void *_get_spine_owner_internal() { return spine_owner; }
|
||||
};
|
||||
|
||||
class SpineSprite;
|
||||
|
||||
template <typename OBJECT> class SpineSpriteOwnedObject: public SpineObjectWrapper {
|
||||
public:
|
||||
void set_spine_object(const SpineSprite* _owner, OBJECT* _object) {
|
||||
_set_spine_object_internal(_owner, _object);
|
||||
}
|
||||
|
||||
OBJECT *get_spine_object() {
|
||||
return (OBJECT*)_get_spine_object_internal();
|
||||
}
|
||||
|
||||
SpineSprite *get_spine_owner() {
|
||||
return (SpineSprite*)_get_spine_owner_internal();
|
||||
}
|
||||
};
|
||||
|
||||
class SpineSkeletonDataResource;
|
||||
|
||||
template <typename OBJECT> class SpineSkeletonDataResourceOwnedObject: public SpineObjectWrapper {
|
||||
public:
|
||||
void set_spine_object(const SpineSkeletonDataResource* _owner, OBJECT* _object) {
|
||||
_set_spine_object_internal(_owner, _object);
|
||||
}
|
||||
|
||||
OBJECT *get_spine_object() {
|
||||
return (OBJECT*)_get_spine_object_internal();
|
||||
}
|
||||
|
||||
SpineSkeletonDataResource *get_spine_owner() {
|
||||
return (SpineSkeletonDataResource*)_get_spine_owner_internal();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -40,26 +40,26 @@ void SpineConstraintData::_bind_methods() {
|
||||
}
|
||||
|
||||
String SpineConstraintData::get_constraint_name() {
|
||||
SPINE_CHECK(spine_object, "")
|
||||
return spine_object->getName().buffer();
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
}
|
||||
|
||||
int SpineConstraintData::get_order() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return (int)spine_object->getOrder();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return (int)get_spine_object()->getOrder();
|
||||
}
|
||||
|
||||
void SpineConstraintData::set_order(int v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setOrder(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setOrder(v);
|
||||
}
|
||||
|
||||
bool SpineConstraintData::is_skin_required() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->isSkinRequired();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->isSkinRequired();
|
||||
}
|
||||
|
||||
void SpineConstraintData::set_skin_required(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setSkinRequired(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setSkinRequired(v);
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
class SpineSkeletonDataResource;
|
||||
|
||||
class SpineConstraintData : public SpineObjectWrapper<SpineSkeletonDataResource, spine::ConstraintData> {
|
||||
class SpineConstraintData : public SpineSkeletonDataResourceOwnedObject<spine::ConstraintData> {
|
||||
GDCLASS(SpineConstraintData, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -47,63 +47,63 @@ void SpineEvent::_bind_methods() {
|
||||
}
|
||||
|
||||
Ref<SpineEventData> SpineEvent::get_data() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
Ref<SpineEventData> event_data(memnew(SpineEventData));
|
||||
event_data->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), (spine::EventData*)&spine_object->getData());
|
||||
event_data->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), (spine::EventData*)&get_spine_object()->getData());
|
||||
return event_data;
|
||||
}
|
||||
|
||||
float SpineEvent::get_time() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getTime();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getTime();
|
||||
}
|
||||
|
||||
int SpineEvent::get_int_value() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getIntValue();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getIntValue();
|
||||
}
|
||||
|
||||
void SpineEvent::set_int_value(int v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setIntValue(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setIntValue(v);
|
||||
}
|
||||
|
||||
float SpineEvent::get_float_value() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getFloatValue();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getFloatValue();
|
||||
}
|
||||
|
||||
void SpineEvent::set_float_value(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setFloatValue(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setFloatValue(v);
|
||||
}
|
||||
|
||||
String SpineEvent::get_string_value() {
|
||||
SPINE_CHECK(spine_object, "")
|
||||
return spine_object->getStringValue().buffer();
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getStringValue().buffer();
|
||||
}
|
||||
|
||||
void SpineEvent::set_string_value(const String &v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setStringValue(spine::String(v.utf8()));
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setStringValue(spine::String(v.utf8()));
|
||||
}
|
||||
|
||||
float SpineEvent::get_volume() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getVolume();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getVolume();
|
||||
}
|
||||
|
||||
void SpineEvent::set_volume(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setVolume(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setVolume(v);
|
||||
}
|
||||
|
||||
float SpineEvent::get_balance() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getBalance();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getBalance();
|
||||
}
|
||||
|
||||
void SpineEvent::set_balance(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setBalance(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setBalance(v);
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
class SpineSprite;
|
||||
|
||||
class SpineEvent : public SpineObjectWrapper<SpineSprite, spine::Event> {
|
||||
class SpineEvent : public SpineSpriteOwnedObject<spine::Event> {
|
||||
GDCLASS(SpineEvent, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -45,56 +45,56 @@ void SpineEventData::_bind_methods() {
|
||||
}
|
||||
|
||||
String SpineEventData::get_event_name() {
|
||||
SPINE_CHECK(spine_object, "")
|
||||
return spine_object->getName().buffer();
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
}
|
||||
|
||||
int SpineEventData::get_int_value() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getIntValue();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getIntValue();
|
||||
}
|
||||
|
||||
void SpineEventData::set_int_value(int v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setIntValue(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setIntValue(v);
|
||||
}
|
||||
|
||||
float SpineEventData::get_float_value() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getFloatValue();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getFloatValue();
|
||||
}
|
||||
|
||||
void SpineEventData::set_float_value(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setFloatValue(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setFloatValue(v);
|
||||
}
|
||||
|
||||
String SpineEventData::get_string_value() {
|
||||
SPINE_CHECK(spine_object, "")
|
||||
return spine_object->getStringValue().buffer();
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getStringValue().buffer();
|
||||
}
|
||||
|
||||
void SpineEventData::set_string_value(const String &v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setStringValue(spine::String(v.utf8()));
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setStringValue(spine::String(v.utf8()));
|
||||
}
|
||||
|
||||
float SpineEventData::get_volume() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getVolume();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getVolume();
|
||||
}
|
||||
|
||||
void SpineEventData::set_volume(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setVolume(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setVolume(v);
|
||||
}
|
||||
|
||||
float SpineEventData::get_balance() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getBalance();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getBalance();
|
||||
}
|
||||
|
||||
void SpineEventData::set_balance(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setBalance(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setBalance(v);
|
||||
}
|
||||
|
||||
@ -35,8 +35,8 @@
|
||||
|
||||
class SpineSkeletonDataResource;
|
||||
|
||||
class SpineEventData : public SpineObjectWrapper<SpineSkeletonDataResource, spine::EventData> {
|
||||
GDCLASS(SpineEventData, REFCOUNTED);
|
||||
class SpineEventData : public SpineSkeletonDataResourceOwnedObject<spine::EventData> {
|
||||
GDCLASS(SpineEventData, SpineObjectWrapper);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
@ -54,18 +54,18 @@ void SpineIkConstraint::_bind_methods() {
|
||||
}
|
||||
|
||||
void SpineIkConstraint::update() {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->update();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->update();
|
||||
}
|
||||
|
||||
int SpineIkConstraint::get_order() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getOrder();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getOrder();
|
||||
}
|
||||
|
||||
Ref<SpineIkConstraintData> SpineIkConstraint::get_data() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto &ik_constraint_data = spine_object->getData();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto &ik_constraint_data = get_spine_object()->getData();
|
||||
Ref<SpineIkConstraintData> ik_constraint_data_ref(memnew(SpineIkConstraintData));
|
||||
ik_constraint_data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &ik_constraint_data);
|
||||
return ik_constraint_data_ref;
|
||||
@ -73,8 +73,8 @@ Ref<SpineIkConstraintData> SpineIkConstraint::get_data() {
|
||||
|
||||
Array SpineIkConstraint::get_bones() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
auto &bones = spine_object->getBones();
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto &bones = get_spine_object()->getBones();
|
||||
result.resize((int)bones.size());
|
||||
for (int i = 0; i < bones.size(); ++i) {
|
||||
auto bone = bones[i];
|
||||
@ -86,8 +86,8 @@ Array SpineIkConstraint::get_bones() {
|
||||
}
|
||||
|
||||
Ref<SpineBone> SpineIkConstraint::get_target() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto target = spine_object->getTarget();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto target = get_spine_object()->getTarget();
|
||||
if (!target) return nullptr;
|
||||
Ref<SpineBone> target_ref(memnew(SpineBone));
|
||||
target_ref->set_spine_object(get_spine_owner(), target);
|
||||
@ -95,65 +95,65 @@ Ref<SpineBone> SpineIkConstraint::get_target() {
|
||||
}
|
||||
|
||||
void SpineIkConstraint::set_target(Ref<SpineBone> v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
|
||||
}
|
||||
|
||||
int SpineIkConstraint::get_bend_direction() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getBendDirection();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getBendDirection();
|
||||
}
|
||||
|
||||
void SpineIkConstraint::set_bend_direction(int v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setBendDirection(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setBendDirection(v);
|
||||
}
|
||||
|
||||
bool SpineIkConstraint::get_compress() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->getCompress();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->getCompress();
|
||||
}
|
||||
|
||||
void SpineIkConstraint::set_compress(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setCompress(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setCompress(v);
|
||||
}
|
||||
|
||||
bool SpineIkConstraint::get_stretch() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->getStretch();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->getStretch();
|
||||
}
|
||||
|
||||
void SpineIkConstraint::set_stretch(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setStretch(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setStretch(v);
|
||||
}
|
||||
|
||||
float SpineIkConstraint::get_mix() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMix();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMix();
|
||||
}
|
||||
void SpineIkConstraint::set_mix(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMix(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMix(v);
|
||||
}
|
||||
|
||||
float SpineIkConstraint::get_softness() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getSoftness();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getSoftness();
|
||||
}
|
||||
|
||||
void SpineIkConstraint::set_softness(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setSoftness(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setSoftness(v);
|
||||
}
|
||||
|
||||
bool SpineIkConstraint::is_active() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->isActive();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->isActive();
|
||||
}
|
||||
|
||||
void SpineIkConstraint::set_active(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setActive(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setActive(v);
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
class SpineBone;
|
||||
class SpineSprite;
|
||||
|
||||
class SpineIkConstraint : public SpineObjectWrapper<SpineSprite, spine::IkConstraint> {
|
||||
class SpineIkConstraint : public SpineSpriteOwnedObject<spine::IkConstraint> {
|
||||
GDCLASS(SpineIkConstraint, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -50,7 +50,7 @@ void SpineIkConstraintData::_bind_methods() {
|
||||
|
||||
Array SpineIkConstraintData::get_bones() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto bones = get_spine_constraint_data()->getBones();
|
||||
result.resize((int)bones.size());
|
||||
for (int i = 0; i < bones.size(); ++i) {
|
||||
@ -62,7 +62,7 @@ Array SpineIkConstraintData::get_bones() {
|
||||
}
|
||||
|
||||
Ref<SpineBoneData> SpineIkConstraintData::get_target() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto target = get_spine_constraint_data()->getTarget();
|
||||
if (!target) return nullptr;
|
||||
Ref<SpineBoneData> target_ref(memnew(SpineBoneData));
|
||||
@ -71,66 +71,66 @@ Ref<SpineBoneData> SpineIkConstraintData::get_target() {
|
||||
}
|
||||
|
||||
void SpineIkConstraintData::set_target(Ref<SpineBoneData> v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_constraint_data()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
|
||||
}
|
||||
|
||||
int SpineIkConstraintData::get_bend_direction() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_constraint_data()->getBendDirection();
|
||||
}
|
||||
|
||||
void SpineIkConstraintData::set_bend_direction(int v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_constraint_data()->setBendDirection(v);
|
||||
}
|
||||
|
||||
bool SpineIkConstraintData::get_compress() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_constraint_data()->getCompress();
|
||||
}
|
||||
|
||||
void SpineIkConstraintData::set_compress(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_constraint_data()->setCompress(v);
|
||||
}
|
||||
|
||||
bool SpineIkConstraintData::get_stretch() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_constraint_data()->getStretch();
|
||||
}
|
||||
|
||||
void SpineIkConstraintData::set_stretch(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_constraint_data()->setStretch(v);
|
||||
}
|
||||
|
||||
bool SpineIkConstraintData::get_uniform() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_constraint_data()->getUniform();
|
||||
}
|
||||
|
||||
void SpineIkConstraintData::set_uniform(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_constraint_data()->setUniform(v);
|
||||
}
|
||||
|
||||
float SpineIkConstraintData::get_mix() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_constraint_data()->getMix();
|
||||
}
|
||||
|
||||
void SpineIkConstraintData::set_mix(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_constraint_data()->setMix(v);
|
||||
}
|
||||
|
||||
float SpineIkConstraintData::get_softness() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_constraint_data()->getSoftness();
|
||||
}
|
||||
|
||||
void SpineIkConstraintData::set_softness(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_constraint_data()->setSoftness(v);
|
||||
}
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SpineObjectWrapper.h"
|
||||
|
||||
|
||||
|
||||
@ -1,61 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef GODOT_SPINEOBJECTWRAPPER_H
|
||||
#define GODOT_SPINEOBJECTWRAPPER_H
|
||||
|
||||
#include "SpineCommon.h"
|
||||
|
||||
template <typename OWNER, typename OBJECT> class SpineObjectWrapper: public REFCOUNTED {
|
||||
protected:
|
||||
Object *owner;
|
||||
OBJECT *spine_object;
|
||||
|
||||
public:
|
||||
SpineObjectWrapper(): owner(nullptr), spine_object(nullptr) {};
|
||||
|
||||
void set_spine_object(const OWNER *_owner, OBJECT *_object) {
|
||||
if (!_owner) {
|
||||
ERR_PRINT("Owner must not be null.");
|
||||
return;
|
||||
}
|
||||
owner = (Object*)_owner;
|
||||
spine_object = _object;
|
||||
}
|
||||
|
||||
OBJECT *get_spine_object() {
|
||||
return spine_object;
|
||||
}
|
||||
|
||||
OWNER *get_spine_owner() {
|
||||
return (OWNER*)owner;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -54,69 +54,69 @@ void SpinePathConstraint::_bind_methods() {
|
||||
}
|
||||
|
||||
void SpinePathConstraint::update() {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->update();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->update();
|
||||
}
|
||||
|
||||
int SpinePathConstraint::get_order() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getOrder();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getOrder();
|
||||
}
|
||||
|
||||
float SpinePathConstraint::get_position() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getPosition();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getPosition();
|
||||
}
|
||||
|
||||
void SpinePathConstraint::set_position(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setPosition(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setPosition(v);
|
||||
}
|
||||
|
||||
float SpinePathConstraint::get_spacing() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getSpacing();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getSpacing();
|
||||
}
|
||||
|
||||
void SpinePathConstraint::set_spacing(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setSpacing(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setSpacing(v);
|
||||
}
|
||||
|
||||
float SpinePathConstraint::get_mix_rotate() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMixRotate();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMixRotate();
|
||||
}
|
||||
|
||||
void SpinePathConstraint::set_mix_rotate(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixRotate(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixRotate(v);
|
||||
}
|
||||
|
||||
float SpinePathConstraint::get_mix_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMixX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMixX();
|
||||
}
|
||||
|
||||
void SpinePathConstraint::set_mix_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixX(v);
|
||||
}
|
||||
|
||||
float SpinePathConstraint::get_mix_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMixY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMixY();
|
||||
}
|
||||
|
||||
void SpinePathConstraint::set_mix_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixY(v);
|
||||
}
|
||||
|
||||
Array SpinePathConstraint::get_bones() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
auto &bones = spine_object->getBones();
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto &bones = get_spine_object()->getBones();
|
||||
result.resize((int)bones.size());
|
||||
for (int i = 0; i < bones.size(); ++i) {
|
||||
auto bone = bones[i];
|
||||
@ -128,8 +128,8 @@ Array SpinePathConstraint::get_bones() {
|
||||
}
|
||||
|
||||
Ref<SpineSlot> SpinePathConstraint::get_target() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto target = spine_object->getTarget();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto target = get_spine_object()->getTarget();
|
||||
if (!target) return nullptr;
|
||||
Ref<SpineSlot> target_ref(memnew(SpineSlot));
|
||||
target_ref->set_spine_object(get_spine_owner(), target);
|
||||
@ -137,24 +137,24 @@ Ref<SpineSlot> SpinePathConstraint::get_target() {
|
||||
}
|
||||
|
||||
void SpinePathConstraint::set_target(Ref<SpineSlot> v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
|
||||
}
|
||||
|
||||
Ref<SpinePathConstraintData> SpinePathConstraint::get_data() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto &data = spine_object->getData();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto &data = get_spine_object()->getData();
|
||||
Ref<SpinePathConstraintData> data_ref(memnew(SpinePathConstraintData));
|
||||
data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &data);
|
||||
return data_ref;
|
||||
}
|
||||
|
||||
bool SpinePathConstraint::is_active() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->isActive();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->isActive();
|
||||
}
|
||||
|
||||
void SpinePathConstraint::set_active(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setActive(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setActive(v);
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
#include "SpineSlot.h"
|
||||
#include <spine/PathConstraint.h>
|
||||
|
||||
class SpinePathConstraint : public SpineObjectWrapper<SpineSprite, spine::PathConstraint> {
|
||||
class SpinePathConstraint : public SpineSpriteOwnedObject<spine::PathConstraint> {
|
||||
GDCLASS(SpinePathConstraint, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -117,6 +117,7 @@ void SpineSkeletonDataResource::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_fps"), &SpineSkeletonDataResource::get_fps);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("skeleton_data_changed"));
|
||||
ADD_SIGNAL(MethodInfo("_internal_spine_objects_invalidated"));
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "atlas_res", PropertyHint::PROPERTY_HINT_RESOURCE_TYPE, "SpineAtlasResource"), "set_atlas_res", "get_atlas_res");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "skeleton_file_res", PropertyHint::PROPERTY_HINT_RESOURCE_TYPE, "SpineSkeletonFileResource"), "set_skeleton_file_res", "get_skeleton_file_res");
|
||||
@ -146,6 +147,8 @@ void SpineSkeletonDataResource::update_skeleton_data() {
|
||||
animation_state_data = nullptr;
|
||||
}
|
||||
|
||||
emit_signal("_internal_spine_objects_invalidated");
|
||||
|
||||
if (atlas_res.is_valid() && skeleton_file_res.is_valid()) {
|
||||
load_resources(atlas_res->get_spine_atlas(), skeleton_file_res->get_json(), skeleton_file_res->get_binary());
|
||||
}
|
||||
|
||||
@ -51,11 +51,11 @@ SpineSkin::SpineSkin() : owns_skin(false) {
|
||||
}
|
||||
|
||||
SpineSkin::~SpineSkin() {
|
||||
if (owns_skin) delete spine_object;
|
||||
if (owns_skin) delete get_spine_object();
|
||||
}
|
||||
|
||||
Ref<SpineSkin> SpineSkin::init(const String &name, SpineSprite *sprite) {
|
||||
if (spine_object) {
|
||||
if (get_spine_object()) {
|
||||
ERR_PRINT("Can not initialize an already initialized skin.");
|
||||
return this;
|
||||
}
|
||||
@ -73,13 +73,13 @@ Ref<SpineSkin> SpineSkin::init(const String &name, SpineSprite *sprite) {
|
||||
}
|
||||
|
||||
void SpineSkin::set_attachment(int slot_index, const String &name, Ref<SpineAttachment> attachment) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAttachment(slot_index, SPINE_STRING(name), attachment.is_valid() && attachment->get_spine_object()? attachment->get_spine_object() : nullptr);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAttachment(slot_index, SPINE_STRING(name), attachment.is_valid() && attachment->get_spine_owner()? attachment->get_spine_object() : nullptr);
|
||||
}
|
||||
|
||||
Ref<SpineAttachment> SpineSkin::get_attachment(int slot_index, const String &name) {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto attachment = spine_object->getAttachment(slot_index, SPINE_STRING(name));
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto attachment = get_spine_object()->getAttachment(slot_index, SPINE_STRING(name));
|
||||
if (attachment) return nullptr;
|
||||
Ref<SpineAttachment> attachment_ref(memnew(SpineAttachment));
|
||||
attachment_ref->set_spine_object(get_spine_owner(), attachment);
|
||||
@ -87,15 +87,15 @@ Ref<SpineAttachment> SpineSkin::get_attachment(int slot_index, const String &nam
|
||||
}
|
||||
|
||||
void SpineSkin::remove_attachment(int slot_index, const String &name) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->removeAttachment(slot_index, SPINE_STRING(name));
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->removeAttachment(slot_index, SPINE_STRING(name));
|
||||
}
|
||||
|
||||
Array SpineSkin::find_names_for_slot(int slot_index) {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
spine::Vector<spine::String> names;
|
||||
spine_object->findNamesForSlot(slot_index, names);
|
||||
get_spine_object()->findNamesForSlot(slot_index, names);
|
||||
result.resize((int)names.size());
|
||||
for (int i = 0; i < names.size(); ++i) {
|
||||
result[i] = names[i].buffer();
|
||||
@ -105,9 +105,9 @@ Array SpineSkin::find_names_for_slot(int slot_index) {
|
||||
|
||||
Array SpineSkin::find_attachments_for_slot(int slot_index) {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
spine::Vector<spine::Attachment *> attachments;
|
||||
spine_object->findAttachmentsForSlot(slot_index, attachments);
|
||||
get_spine_object()->findAttachmentsForSlot(slot_index, attachments);
|
||||
result.resize((int)attachments.size());
|
||||
for (int i = 0; i < attachments.size(); ++i) {
|
||||
if (!attachments[i]) {
|
||||
@ -122,32 +122,32 @@ Array SpineSkin::find_attachments_for_slot(int slot_index) {
|
||||
}
|
||||
|
||||
String SpineSkin::get_name() {
|
||||
SPINE_CHECK(spine_object, "")
|
||||
return spine_object->getName().buffer();
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
}
|
||||
|
||||
void SpineSkin::add_skin(Ref<SpineSkin> other) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
if (!other.is_valid() || !other->get_spine_object()) {
|
||||
ERR_PRINT("other is not a valid SpineSkin.");
|
||||
return;
|
||||
}
|
||||
spine_object->addSkin(other->get_spine_object());
|
||||
get_spine_object()->addSkin(other->get_spine_object());
|
||||
}
|
||||
|
||||
void SpineSkin::copy_skin(Ref<SpineSkin> other) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
if (!other.is_valid() || !other->get_spine_object()) {
|
||||
ERR_PRINT("other is not a valid SpineSkin.");
|
||||
return;
|
||||
}
|
||||
spine_object->copySkin(other->get_spine_object());
|
||||
get_spine_object()->copySkin(other->get_spine_object());
|
||||
}
|
||||
|
||||
Array SpineSkin::get_attachments() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
auto entries = spine_object->getAttachments();
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto entries = get_spine_object()->getAttachments();
|
||||
while(entries.hasNext()) {
|
||||
spine::Skin::AttachmentMap::Entry &entry = entries.next();
|
||||
Ref<SpineSkinEntry> entry_ref = memnew(SpineSkinEntry);
|
||||
@ -164,8 +164,8 @@ Array SpineSkin::get_attachments() {
|
||||
|
||||
Array SpineSkin::get_bones() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
auto bones = spine_object->getBones();
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto bones = get_spine_object()->getBones();
|
||||
result.resize((int)bones.size());
|
||||
for (int i = 0; i < bones.size(); ++i) {
|
||||
Ref<SpineBoneData> bone_ref(memnew(SpineBoneData));
|
||||
@ -177,8 +177,8 @@ Array SpineSkin::get_bones() {
|
||||
|
||||
Array SpineSkin::get_constraints() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
auto constraints = spine_object->getConstraints();
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto constraints = get_spine_object()->getConstraints();
|
||||
result.resize((int)constraints.size());
|
||||
for (int i = 0; i < constraints.size(); ++i) {
|
||||
Ref<SpineConstraintData> constraint_ref(memnew(SpineConstraintData));
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
class SpineSkeletonDataResource;
|
||||
class SpineSprite;
|
||||
|
||||
class SpineSkin : public SpineObjectWrapper<SpineSkeletonDataResource, spine::Skin> {
|
||||
class SpineSkin : public SpineSkeletonDataResourceOwnedObject<spine::Skin> {
|
||||
GDCLASS(SpineSkin, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -53,58 +53,58 @@ void SpineSlot::_bind_methods() {
|
||||
}
|
||||
|
||||
void SpineSlot::set_to_setup_pose() {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setToSetupPose();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setToSetupPose();
|
||||
}
|
||||
|
||||
Ref<SpineSlotData> SpineSlot::get_data() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto &slot_data = spine_object->getData();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto &slot_data = get_spine_object()->getData();
|
||||
Ref<SpineSlotData> slot_data_ref(memnew(SpineSlotData));
|
||||
slot_data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &slot_data);
|
||||
return slot_data_ref;
|
||||
}
|
||||
|
||||
Ref<SpineBone> SpineSlot::get_bone() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto &bone = spine_object->getBone();
|
||||
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;
|
||||
}
|
||||
|
||||
Color SpineSlot::get_color() {
|
||||
SPINE_CHECK(spine_object, Color(0, 0, 0, 0))
|
||||
auto &color = spine_object->getColor();
|
||||
SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0))
|
||||
auto &color = get_spine_object()->getColor();
|
||||
return Color(color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
void SpineSlot::set_color(Color v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
auto &color = spine_object->getColor();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
auto &color = get_spine_object()->getColor();
|
||||
color.set(v.r, v.g, v.b, v.a);
|
||||
}
|
||||
|
||||
Color SpineSlot::get_dark_color() {
|
||||
SPINE_CHECK(spine_object, Color(0, 0, 0, 0))
|
||||
auto &color = spine_object->getDarkColor();
|
||||
SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0))
|
||||
auto &color = get_spine_object()->getDarkColor();
|
||||
return Color(color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
void SpineSlot::set_dark_color(Color v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
auto &color = spine_object->getDarkColor();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
auto &color = get_spine_object()->getDarkColor();
|
||||
color.set(v.r, v.g, v.b, v.a);
|
||||
}
|
||||
|
||||
bool SpineSlot::has_dark_color() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->hasDarkColor();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->hasDarkColor();
|
||||
}
|
||||
|
||||
Ref<SpineAttachment> SpineSlot::get_attachment() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto attachment = spine_object->getAttachment();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto attachment = get_spine_object()->getAttachment();
|
||||
if (!attachment) return nullptr;
|
||||
Ref<SpineAttachment> attachment_ref(memnew(SpineAttachment));
|
||||
attachment_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), attachment);
|
||||
@ -112,24 +112,24 @@ Ref<SpineAttachment> SpineSlot::get_attachment() {
|
||||
}
|
||||
|
||||
void SpineSlot::set_attachment(Ref<SpineAttachment> v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAttachment(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAttachment(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
|
||||
}
|
||||
|
||||
int SpineSlot::get_attachment_state() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAttachmentState();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAttachmentState();
|
||||
}
|
||||
|
||||
void SpineSlot::set_attachment_state(int v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAttachmentState(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAttachmentState(v);
|
||||
}
|
||||
|
||||
Array SpineSlot::get_deform() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
auto &deform = spine_object->getDeform();
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto &deform = get_spine_object()->getDeform();
|
||||
result.resize((int)deform.size());
|
||||
for (int i = 0; i < (int)deform.size(); ++i) {
|
||||
result[i] = deform[i];
|
||||
@ -138,8 +138,8 @@ Array SpineSlot::get_deform() {
|
||||
}
|
||||
|
||||
void SpineSlot::set_deform(Array v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
auto &deform = spine_object->getDeform();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
auto &deform = get_spine_object()->getDeform();
|
||||
deform.setSize(v.size(), 0);
|
||||
for (int i = 0; i < v.size(); ++i) {
|
||||
deform[i] = v[i];
|
||||
@ -147,11 +147,11 @@ void SpineSlot::set_deform(Array v) {
|
||||
}
|
||||
|
||||
int SpineSlot::get_sequence_index() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAttachmentState();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAttachmentState();
|
||||
}
|
||||
|
||||
void SpineSlot::set_sequence_index(int v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAttachmentState(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAttachmentState(v);
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
class SpineSkeleton;
|
||||
class SpineSprite;
|
||||
|
||||
class SpineSlot : public SpineObjectWrapper<SpineSprite, spine::Slot> {
|
||||
class SpineSlot : public SpineSpriteOwnedObject<spine::Slot> {
|
||||
GDCLASS(SpineSlot, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -48,71 +48,71 @@ void SpineSlotData::_bind_methods() {
|
||||
}
|
||||
|
||||
int SpineSlotData::get_index() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getIndex();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getIndex();
|
||||
}
|
||||
|
||||
String SpineSlotData::get_name() {
|
||||
SPINE_CHECK(spine_object, String(""))
|
||||
return spine_object->getName().buffer();
|
||||
SPINE_CHECK(get_spine_object(), String(""))
|
||||
return get_spine_object()->getName().buffer();
|
||||
}
|
||||
|
||||
Ref<SpineBoneData> SpineSlotData::get_bone_data() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto &bone_data = spine_object->getBoneData();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto &bone_data = get_spine_object()->getBoneData();
|
||||
Ref<SpineBoneData> bone_data_ref(memnew(SpineBoneData));
|
||||
bone_data_ref->set_spine_object(get_spine_owner(), &bone_data);
|
||||
return bone_data_ref;
|
||||
}
|
||||
|
||||
Color SpineSlotData::get_color() {
|
||||
SPINE_CHECK(spine_object, Color(0, 0, 0, 0))
|
||||
auto &color = spine_object->getColor();
|
||||
SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0))
|
||||
auto &color = get_spine_object()->getColor();
|
||||
return Color(color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
void SpineSlotData::set_color(Color v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
auto &color = spine_object->getColor();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
auto &color = get_spine_object()->getColor();
|
||||
color.set(v.r, v.g, v.b, v.a);
|
||||
}
|
||||
|
||||
Color SpineSlotData::get_dark_color() {
|
||||
SPINE_CHECK(spine_object, Color(0, 0, 0, 0))
|
||||
auto &color = spine_object->getDarkColor();
|
||||
SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0))
|
||||
auto &color = get_spine_object()->getDarkColor();
|
||||
return Color(color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
void SpineSlotData::set_dark_color(Color v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
auto &color = spine_object->getDarkColor();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
auto &color = get_spine_object()->getDarkColor();
|
||||
color.set(v.r, v.g, v.b, v.a);
|
||||
}
|
||||
|
||||
bool SpineSlotData::has_dark_color() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->hasDarkColor();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->hasDarkColor();
|
||||
}
|
||||
|
||||
void SpineSlotData::set_has_dark_color(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setHasDarkColor(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setHasDarkColor(v);
|
||||
}
|
||||
|
||||
String SpineSlotData::get_attachment_name() {
|
||||
SPINE_CHECK(spine_object, "")
|
||||
return spine_object->getAttachmentName().buffer();
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getAttachmentName().buffer();
|
||||
}
|
||||
void SpineSlotData::set_attachment_name(const String &v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAttachmentName(SPINE_STRING(v));
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAttachmentName(SPINE_STRING(v));
|
||||
}
|
||||
|
||||
SpineConstant::BlendMode SpineSlotData::get_blend_mode() {
|
||||
SPINE_CHECK(spine_object, SpineConstant::BlendMode_Normal)
|
||||
return (SpineConstant::BlendMode)spine_object->getBlendMode();
|
||||
SPINE_CHECK(get_spine_object(), SpineConstant::BlendMode_Normal)
|
||||
return (SpineConstant::BlendMode)get_spine_object()->getBlendMode();
|
||||
}
|
||||
void SpineSlotData::set_blend_mode(SpineConstant::BlendMode v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setBlendMode((spine::BlendMode) v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setBlendMode((spine::BlendMode) v);
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
class SpineSkeletonDataResource;
|
||||
|
||||
class SpineSlotData : public SpineObjectWrapper<SpineSkeletonDataResource, spine::SlotData> {
|
||||
class SpineSlotData : public SpineSkeletonDataResourceOwnedObject<spine::SlotData> {
|
||||
GDCLASS(SpineSlotData, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -63,6 +63,7 @@ void SpineSprite::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("before_animation_state_apply", PropertyInfo(Variant::OBJECT, "spine_sprite", PROPERTY_HINT_TYPE_STRING, "SpineSprite")));
|
||||
ADD_SIGNAL(MethodInfo("before_world_transforms_change", PropertyInfo(Variant::OBJECT, "spine_sprite", PROPERTY_HINT_TYPE_STRING, "SpineSprite")));
|
||||
ADD_SIGNAL(MethodInfo("world_transforms_changed", PropertyInfo(Variant::OBJECT, "spine_sprite", PROPERTY_HINT_TYPE_STRING, "SpineSprite")));
|
||||
ADD_SIGNAL(MethodInfo("_internal_spine_objects_invalidated"));
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "skeleton_data_res", PropertyHint::PROPERTY_HINT_RESOURCE_TYPE, "SpineSkeletonDataResource"), "set_skeleton_data_res", "get_skeleton_data_res");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "update_mode", PROPERTY_HINT_ENUM, "Process,Physics,Manual"), "set_update_mode", "get_update_mode");
|
||||
@ -118,6 +119,8 @@ void SpineSprite::on_skeleton_data_changed() {
|
||||
skeleton.unref();
|
||||
animation_state.unref();
|
||||
|
||||
emit_signal("_internal_spine_objects_invalidated");
|
||||
|
||||
if (skeleton_data_res.is_valid()) {
|
||||
#if VERSION_MAJOR > 3
|
||||
if (!skeleton_data_res->is_connected("skeleton_data_changed", callable_mp(this, &SpineSprite::on_skeleton_data_changed)))
|
||||
|
||||
@ -46,30 +46,30 @@ void SpineTimeline::_bind_methods() {
|
||||
|
||||
void SpineTimeline::apply(Ref<SpineSkeleton> skeleton, float last_time, float time, Array events, float alpha,
|
||||
SpineConstant::MixBlend blend, SpineConstant::MixDirection direction) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
if (!skeleton->get_spine_object()) return;
|
||||
spine::Vector<spine::Event *> spine_events;
|
||||
spine_events.setSize((int)events.size(), nullptr);
|
||||
for (int i = 0; i < events.size(); ++i) {
|
||||
events[i] = ((Ref<SpineEvent>) spine_events[i])->get_spine_object();
|
||||
}
|
||||
spine_object->apply(*(skeleton->get_spine_object()), last_time, time, &spine_events, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction);
|
||||
get_spine_object()->apply(*(skeleton->get_spine_object()), last_time, time, &spine_events, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction);
|
||||
}
|
||||
|
||||
int SpineTimeline::get_frame_entries() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return (int)spine_object->getFrameEntries();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return (int)get_spine_object()->getFrameEntries();
|
||||
}
|
||||
|
||||
int SpineTimeline::get_frame_count() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return (int)spine_object->getFrameCount();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return (int)get_spine_object()->getFrameCount();
|
||||
}
|
||||
|
||||
Array SpineTimeline::get_frames() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
auto &frames = spine_object->getFrames();
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto &frames = get_spine_object()->getFrames();
|
||||
result.resize((int)frames.size());
|
||||
for (int i = 0; i < result.size(); ++i) {
|
||||
result[i] = frames[i];
|
||||
@ -78,14 +78,14 @@ Array SpineTimeline::get_frames() {
|
||||
}
|
||||
|
||||
float SpineTimeline::get_duration() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getDuration();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getDuration();
|
||||
}
|
||||
|
||||
Array SpineTimeline::get_property_ids() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
auto &ids = spine_object->getPropertyIds();
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto &ids = get_spine_object()->getPropertyIds();
|
||||
result.resize((int)ids.size());
|
||||
for (int i = 0; i < result.size(); ++i) {
|
||||
result[i] = (spine::PropertyId) ids[i];
|
||||
@ -94,6 +94,6 @@ Array SpineTimeline::get_property_ids() {
|
||||
}
|
||||
|
||||
String SpineTimeline::get_type() {
|
||||
SPINE_CHECK(spine_object, "")
|
||||
return spine_object->getRTTI().getClassName();
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getRTTI().getClassName();
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
class SpineSkeleton;
|
||||
class SpineEvent;
|
||||
|
||||
class SpineTimeline : public SpineObjectWrapper<SpineSkeletonDataResource, spine::Timeline> {
|
||||
class SpineTimeline : public SpineSkeletonDataResourceOwnedObject<spine::Timeline> {
|
||||
GDCLASS(SpineTimeline, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
@ -80,13 +80,13 @@ void SpineTrackEntry::_bind_methods() {
|
||||
}
|
||||
|
||||
int SpineTrackEntry::get_track_index() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getTrackIndex();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getTrackIndex();
|
||||
}
|
||||
|
||||
Ref<SpineAnimation> SpineTrackEntry::get_animation() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto animation = spine_object->getAnimation();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto animation = get_spine_object()->getAnimation();
|
||||
if (!animation) return nullptr;
|
||||
Ref<SpineAnimation> animation_ref(memnew(SpineAnimation));
|
||||
animation_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), animation);
|
||||
@ -94,8 +94,8 @@ Ref<SpineAnimation> SpineTrackEntry::get_animation() {
|
||||
}
|
||||
|
||||
Ref<SpineTrackEntry> SpineTrackEntry::get_previous() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto previous = spine_object->getPrevious();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto previous = get_spine_object()->getPrevious();
|
||||
if (!previous) return nullptr;
|
||||
Ref<SpineTrackEntry> previous_ref(memnew(SpineTrackEntry));
|
||||
previous_ref->set_spine_object(get_spine_owner(), previous);
|
||||
@ -103,163 +103,163 @@ Ref<SpineTrackEntry> SpineTrackEntry::get_previous() {
|
||||
}
|
||||
|
||||
bool SpineTrackEntry::get_loop() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->getLoop();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->getLoop();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_loop(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setLoop(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setLoop(v);
|
||||
}
|
||||
|
||||
bool SpineTrackEntry::get_hold_previous() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->getHoldPrevious();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->getHoldPrevious();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_hold_previous(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setHoldPrevious(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setHoldPrevious(v);
|
||||
}
|
||||
|
||||
bool SpineTrackEntry::get_reverse() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->getReverse();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->getReverse();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_reverse(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setReverse(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setReverse(v);
|
||||
}
|
||||
|
||||
bool SpineTrackEntry::get_shortest_rotation() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->getShortestRotation();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->getShortestRotation();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_shortest_rotation(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setShortestRotation(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setShortestRotation(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_delay() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getDelay();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getDelay();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_delay(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setDelay(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setDelay(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_track_time() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getTrackTime();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getTrackTime();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_track_time(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setTrackTime(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setTrackTime(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_track_end() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getTrackEnd();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getTrackEnd();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_track_end(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setTrackEnd(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setTrackEnd(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_animation_start() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAnimationStart();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAnimationStart();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_animation_start(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAnimationStart(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAnimationStart(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_animation_end() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAnimationEnd();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAnimationEnd();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_animation_end(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAnimationEnd(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAnimationEnd(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_animation_last() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAnimationLast();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAnimationLast();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_animation_last(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAnimationLast(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAnimationLast(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_animation_time() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAnimationTime();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAnimationTime();
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_time_scale() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getTimeScale();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getTimeScale();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_time_scale(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setTimeScale(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setTimeScale(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_alpha() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAlpha();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAlpha();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_alpha(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAlpha(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAlpha(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_event_threshold() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getEventThreshold();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getEventThreshold();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_event_threshold(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setEventThreshold(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setEventThreshold(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_attachment_threshold() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getAttachmentThreshold();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getAttachmentThreshold();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_attachment_threshold(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setAttachmentThreshold(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setAttachmentThreshold(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_draw_order_threshold() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getDrawOrderThreshold();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getDrawOrderThreshold();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_draw_order_threshold(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setDrawOrderThreshold(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setDrawOrderThreshold(v);
|
||||
}
|
||||
|
||||
Ref<SpineTrackEntry> SpineTrackEntry::get_next() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto next = spine_object->getNext();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto next = get_spine_object()->getNext();
|
||||
if (!next) return nullptr;
|
||||
Ref<SpineTrackEntry> next_ref(memnew(SpineTrackEntry));
|
||||
next_ref->set_spine_object(get_spine_owner(), next);
|
||||
@ -267,43 +267,43 @@ Ref<SpineTrackEntry> SpineTrackEntry::get_next() {
|
||||
}
|
||||
|
||||
bool SpineTrackEntry::is_complete() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->isComplete();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->isComplete();
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_mix_time() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMixTime();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMixTime();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_mix_time(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixTime(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixTime(v);
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_mix_duration() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMixDuration();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMixDuration();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_mix_duration(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixDuration(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixDuration(v);
|
||||
}
|
||||
|
||||
SpineConstant::MixBlend SpineTrackEntry::get_mix_blend() {
|
||||
SPINE_CHECK(spine_object, SpineConstant::MixBlend_Setup)
|
||||
return (SpineConstant::MixBlend)spine_object->getMixBlend();
|
||||
SPINE_CHECK(get_spine_object(), SpineConstant::MixBlend_Setup)
|
||||
return (SpineConstant::MixBlend)get_spine_object()->getMixBlend();
|
||||
}
|
||||
|
||||
void SpineTrackEntry::set_mix_blend(SpineConstant::MixBlend v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixBlend((spine::MixBlend) v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixBlend((spine::MixBlend) v);
|
||||
}
|
||||
|
||||
Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_from() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto mixing_from = spine_object->getMixingFrom();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto mixing_from = get_spine_object()->getMixingFrom();
|
||||
if (!mixing_from) return nullptr;
|
||||
Ref<SpineTrackEntry> mixing_from_ref(memnew(SpineTrackEntry));
|
||||
mixing_from_ref->set_spine_object(get_spine_owner(), mixing_from);
|
||||
@ -311,8 +311,8 @@ Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_from() {
|
||||
}
|
||||
|
||||
Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_to() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto mixing_to = spine_object->getMixingTo();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto mixing_to = get_spine_object()->getMixingTo();
|
||||
if (!mixing_to) return nullptr;
|
||||
Ref<SpineTrackEntry> mixing_to_ref(memnew(SpineTrackEntry));
|
||||
mixing_to_ref->set_spine_object(get_spine_owner(), mixing_to);
|
||||
@ -320,11 +320,11 @@ Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_to() {
|
||||
}
|
||||
|
||||
void SpineTrackEntry::reset_rotation_directions() {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->resetRotationDirections();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->resetRotationDirections();
|
||||
}
|
||||
|
||||
float SpineTrackEntry::get_track_complete() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getTrackComplete();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getTrackComplete();
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
#include "SpineSprite.h"
|
||||
|
||||
class SpineTrackEntry : public SpineObjectWrapper<SpineSprite, spine::TrackEntry> {
|
||||
class SpineTrackEntry : public SpineSpriteOwnedObject<spine::TrackEntry> {
|
||||
GDCLASS(SpineTrackEntry, SpineObjectWrapper);
|
||||
|
||||
protected:
|
||||
|
||||
@ -54,18 +54,18 @@ void SpineTransformConstraint::_bind_methods() {
|
||||
}
|
||||
|
||||
void SpineTransformConstraint::update() {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->update();
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->update();
|
||||
}
|
||||
|
||||
int SpineTransformConstraint::get_order() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getOrder();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getOrder();
|
||||
}
|
||||
|
||||
Ref<SpineTransformConstraintData> SpineTransformConstraint::get_data() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto &data = spine_object->getData();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto &data = get_spine_object()->getData();
|
||||
Ref<SpineTransformConstraintData> data_ref(memnew(SpineTransformConstraintData));
|
||||
data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &data);
|
||||
return data_ref;
|
||||
@ -73,8 +73,8 @@ Ref<SpineTransformConstraintData> SpineTransformConstraint::get_data() {
|
||||
|
||||
Array SpineTransformConstraint::get_bones() {
|
||||
Array result;
|
||||
SPINE_CHECK(spine_object, result)
|
||||
auto &bones = spine_object->getBones();
|
||||
SPINE_CHECK(get_spine_object(), result)
|
||||
auto &bones = get_spine_object()->getBones();
|
||||
result.resize((int)bones.size());
|
||||
for (int i = 0; i < bones.size(); ++i) {
|
||||
auto bone = bones[i];
|
||||
@ -86,8 +86,8 @@ Array SpineTransformConstraint::get_bones() {
|
||||
}
|
||||
|
||||
Ref<SpineBone> SpineTransformConstraint::get_target() {
|
||||
SPINE_CHECK(spine_object, nullptr)
|
||||
auto target = spine_object->getTarget();
|
||||
SPINE_CHECK(get_spine_object(), nullptr)
|
||||
auto target = get_spine_object()->getTarget();
|
||||
if (!target) return nullptr;
|
||||
Ref<SpineBone> target_ref(memnew(SpineBone));
|
||||
target_ref->set_spine_object(get_spine_owner(), target);
|
||||
@ -95,76 +95,76 @@ Ref<SpineBone> SpineTransformConstraint::get_target() {
|
||||
}
|
||||
|
||||
void SpineTransformConstraint::set_target(Ref<SpineBone> v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
|
||||
}
|
||||
|
||||
float SpineTransformConstraint::get_mix_rotate() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMixRotate();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMixRotate();
|
||||
}
|
||||
|
||||
void SpineTransformConstraint::set_mix_rotate(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixRotate(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixRotate(v);
|
||||
}
|
||||
|
||||
float SpineTransformConstraint::get_mix_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMixX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMixX();
|
||||
}
|
||||
|
||||
void SpineTransformConstraint::set_mix_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixX(v);
|
||||
}
|
||||
|
||||
float SpineTransformConstraint::get_mix_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMixY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMixY();
|
||||
}
|
||||
|
||||
void SpineTransformConstraint::set_mix_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixY(v);
|
||||
}
|
||||
|
||||
float SpineTransformConstraint::get_mix_scale_x() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMixScaleX();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMixScaleX();
|
||||
}
|
||||
|
||||
void SpineTransformConstraint::set_mix_scale_x(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixScaleX(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixScaleX(v);
|
||||
}
|
||||
|
||||
float SpineTransformConstraint::get_mix_scale_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMixScaleY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMixScaleY();
|
||||
}
|
||||
|
||||
void SpineTransformConstraint::set_mix_scale_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixScaleY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixScaleY(v);
|
||||
}
|
||||
|
||||
float SpineTransformConstraint::get_mix_shear_y() {
|
||||
SPINE_CHECK(spine_object, 0)
|
||||
return spine_object->getMixShearY();
|
||||
SPINE_CHECK(get_spine_object(), 0)
|
||||
return get_spine_object()->getMixShearY();
|
||||
}
|
||||
|
||||
void SpineTransformConstraint::set_mix_shear_y(float v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setMixShearY(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setMixShearY(v);
|
||||
}
|
||||
|
||||
bool SpineTransformConstraint::is_active() {
|
||||
SPINE_CHECK(spine_object, false)
|
||||
return spine_object->isActive();
|
||||
SPINE_CHECK(get_spine_object(), false)
|
||||
return get_spine_object()->isActive();
|
||||
}
|
||||
|
||||
void SpineTransformConstraint::set_active(bool v) {
|
||||
SPINE_CHECK(spine_object,)
|
||||
spine_object->setActive(v);
|
||||
SPINE_CHECK(get_spine_object(),)
|
||||
get_spine_object()->setActive(v);
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
#include "SpineBone.h"
|
||||
#include <spine/TransformConstraint.h>
|
||||
|
||||
class SpineTransformConstraint : public SpineObjectWrapper<SpineSprite, spine::TransformConstraint> {
|
||||
class SpineTransformConstraint : public SpineSpriteOwnedObject<spine::TransformConstraint> {
|
||||
GDCLASS(SpineTransformConstraint, SpineObjectWrapper)
|
||||
|
||||
protected:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user