[godot] Rework invalidation of native spine objects, add unit test.

This commit is contained in:
badlogic 2022-04-26 23:34:57 +02:00
parent 7866fff884
commit 4c417dd2c2
38 changed files with 672 additions and 672 deletions

View File

@ -16,5 +16,5 @@ mix = 0.2
[resource] [resource]
atlas_res = ExtResource( 1 ) atlas_res = ExtResource( 1 )
skeleton_file_res = ExtResource( 2 ) skeleton_file_res = ExtResource( 2 )
default_mix = 0.2 default_mix = 0.1
animation_mixes = [ SubResource( 1 ), SubResource( 2 ) ] animation_mixes = [ SubResource( 1 ), SubResource( 2 ) ]

View File

@ -19,8 +19,21 @@ func test_spine_timeline():
assert(timeline.get_property_ids() == [4294967300]) assert(timeline.get_property_ids() == [4294967300])
assert(timeline.get_type() == "RotateTimeline") 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(): func _ready():
test_spine_animation() test_spine_animation()
test_spine_timeline() test_spine_timeline()
test_spine_object_invalidation()
print("All tests passed") print("All tests passed")

View File

@ -46,26 +46,26 @@ void SpineAnimation::_bind_methods() {
} }
String SpineAnimation::get_name() { String SpineAnimation::get_name() {
SPINE_CHECK(spine_object, "") SPINE_CHECK(get_spine_object(), "")
return spine_object->getName().buffer(); return get_spine_object()->getName().buffer();
} }
float SpineAnimation::get_duration() { float SpineAnimation::get_duration() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getDuration(); return get_spine_object()->getDuration();
} }
void SpineAnimation::set_duration(float duration) { void SpineAnimation::set_duration(float duration) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setDuration(duration); get_spine_object()->setDuration(duration);
} }
void SpineAnimation::apply(Ref<SpineSkeleton> skeleton, float last_time, float time, bool loop, void SpineAnimation::apply(Ref<SpineSkeleton> skeleton, float last_time, float time, bool loop,
Array events, float alpha, SpineConstant::MixBlend blend, Array events, float alpha, SpineConstant::MixBlend blend,
SpineConstant::MixDirection direction) { SpineConstant::MixDirection direction) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine::Vector<spine::Event *> spineEvents; 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) { for (int i = 0; i < (int)spineEvents.size(); ++i) {
auto event_ref = memnew(SpineEvent); auto event_ref = memnew(SpineEvent);
event_ref->set_spine_object(skeleton->get_spine_owner(), spineEvents[i]); 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 SpineAnimation::get_timelines() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto &timelines = spine_object->getTimelines(); auto &timelines = get_spine_object()->getTimelines();
result.resize((int)timelines.size()); result.resize((int)timelines.size());
for (int i = 0; i < (int)result.size(); ++i) { for (int i = 0; i < (int)result.size(); ++i) {
@ -88,12 +88,12 @@ Array SpineAnimation::get_timelines() {
} }
bool SpineAnimation::has_timeline(Array ids) { bool SpineAnimation::has_timeline(Array ids) {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
spine::Vector<spine::PropertyId> property_ids; spine::Vector<spine::PropertyId> property_ids;
property_ids.setSize(ids.size(), 0); property_ids.setSize(ids.size(), 0);
for (int i = 0; i < (int)property_ids.size(); ++i) { for (int i = 0; i < (int)property_ids.size(); ++i) {
property_ids[i] = (spine::PropertyId) ids[i]; property_ids[i] = (spine::PropertyId) ids[i];
} }
return spine_object->hasTimeline(property_ids); return get_spine_object()->hasTimeline(property_ids);
} }

View File

@ -39,7 +39,7 @@ class SpineSkeleton;
class SpineTimeline; class SpineTimeline;
class SpineSkeletonDataResource; class SpineSkeletonDataResource;
class SpineAnimation : public SpineObjectWrapper<SpineSkeletonDataResource, spine::Animation> { class SpineAnimation : public SpineSkeletonDataResourceOwnedObject<spine::Animation> {
GDCLASS(SpineAnimation, SpineObjectWrapper) GDCLASS(SpineAnimation, SpineObjectWrapper)
protected: protected:

View File

@ -36,17 +36,17 @@ void SpineAttachment::_bind_methods() {
} }
SpineAttachment::~SpineAttachment() { SpineAttachment::~SpineAttachment() {
if (spine_object) spine_object->dereference(); if (get_spine_object()) get_spine_object()->dereference();
} }
String SpineAttachment::get_attachment_name() { String SpineAttachment::get_attachment_name() {
SPINE_CHECK(spine_object, "") SPINE_CHECK(get_spine_object(), "")
return spine_object->getName().buffer(); return get_spine_object()->getName().buffer();
} }
Ref<SpineAttachment> SpineAttachment::copy() { Ref<SpineAttachment> SpineAttachment::copy() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto copy = spine_object->copy(); auto copy = get_spine_object()->copy();
if (!copy) return nullptr; if (!copy) return nullptr;
Ref<SpineAttachment> attachment_ref(memnew(SpineAttachment)); Ref<SpineAttachment> attachment_ref(memnew(SpineAttachment));
attachment_ref->set_spine_object(get_spine_owner(), copy); attachment_ref->set_spine_object(get_spine_owner(), copy);

View File

@ -35,7 +35,7 @@
class SpineSkeletonDataResource; class SpineSkeletonDataResource;
class SpineAttachment : public SpineObjectWrapper<SpineSkeletonDataResource, spine::Attachment> { class SpineAttachment : public SpineSkeletonDataResourceOwnedObject<spine::Attachment> {
GDCLASS(SpineAttachment, SpineObjectWrapper) GDCLASS(SpineAttachment, SpineObjectWrapper)
protected: protected:

View File

@ -99,65 +99,65 @@ void SpineBone::_bind_methods() {
} }
void SpineBone::update_world_transform() { void SpineBone::update_world_transform() {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->updateWorldTransform(); get_spine_object()->updateWorldTransform();
} }
void SpineBone::set_to_setup_pose() { void SpineBone::set_to_setup_pose() {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setToSetupPose(); get_spine_object()->setToSetupPose();
} }
Vector2 SpineBone::world_to_local(Vector2 world_position) { Vector2 SpineBone::world_to_local(Vector2 world_position) {
SPINE_CHECK(spine_object, Vector2()) SPINE_CHECK(get_spine_object(), Vector2())
float x, y; 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); return Vector2(x, y);
} }
Vector2 SpineBone::local_to_world(Vector2 local_position) { Vector2 SpineBone::local_to_world(Vector2 local_position) {
SPINE_CHECK(spine_object, Vector2()) SPINE_CHECK(get_spine_object(), Vector2())
float x, y; 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); return Vector2(x, y);
} }
float SpineBone::world_to_local_rotation(float world_rotation) { float SpineBone::world_to_local_rotation(float world_rotation) {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->worldToLocalRotation(world_rotation); return get_spine_object()->worldToLocalRotation(world_rotation);
} }
float SpineBone::local_to_world_rotation(float local_rotation) { float SpineBone::local_to_world_rotation(float local_rotation) {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->localToWorldRotation(local_rotation); return get_spine_object()->localToWorldRotation(local_rotation);
} }
void SpineBone::rotate_world(float degrees) { void SpineBone::rotate_world(float degrees) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->rotateWorld(degrees); get_spine_object()->rotateWorld(degrees);
} }
float SpineBone::get_world_to_local_rotation_x() { float SpineBone::get_world_to_local_rotation_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getWorldToLocalRotationX(); return get_spine_object()->getWorldToLocalRotationX();
} }
float SpineBone::get_world_to_local_rotation_y() { float SpineBone::get_world_to_local_rotation_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getWorldToLocalRotationY(); return get_spine_object()->getWorldToLocalRotationY();
} }
Ref<SpineBoneData> SpineBone::get_data() { Ref<SpineBoneData> SpineBone::get_data() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto &bone_data = spine_object->getData(); auto &bone_data = get_spine_object()->getData();
Ref<SpineBoneData> bone_data_ref(memnew(SpineBoneData)); Ref<SpineBoneData> bone_data_ref(memnew(SpineBoneData));
bone_data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &bone_data); bone_data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &bone_data);
return bone_data_ref; return bone_data_ref;
} }
Ref<SpineBone> SpineBone::get_parent() { Ref<SpineBone> SpineBone::get_parent() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto parent = spine_object->getParent(); auto parent = get_spine_object()->getParent();
if (!parent) return nullptr; if (!parent) return nullptr;
Ref<SpineBone> parent_ref(memnew(SpineBone)); Ref<SpineBone> parent_ref(memnew(SpineBone));
parent_ref->set_spine_object(get_spine_owner(), parent); parent_ref->set_spine_object(get_spine_owner(), parent);
@ -166,8 +166,8 @@ Ref<SpineBone> SpineBone::get_parent() {
Array SpineBone::get_children() { Array SpineBone::get_children() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto children = spine_object->getChildren(); auto children = get_spine_object()->getChildren();
result.resize((int)children.size()); result.resize((int)children.size());
for (int i = 0; i < children.size(); ++i) { for (int i = 0; i < children.size(); ++i) {
auto child = children[i]; auto child = children[i];
@ -179,238 +179,238 @@ Array SpineBone::get_children() {
} }
float SpineBone::get_x() { float SpineBone::get_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getX(); return get_spine_object()->getX();
} }
void SpineBone::set_x(float v) { void SpineBone::set_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setX(v); get_spine_object()->setX(v);
} }
float SpineBone::get_y() { float SpineBone::get_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getY(); return get_spine_object()->getY();
} }
void SpineBone::set_y(float v) { void SpineBone::set_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setY(v); get_spine_object()->setY(v);
} }
float SpineBone::get_rotation() { float SpineBone::get_rotation() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getRotation(); return get_spine_object()->getRotation();
} }
void SpineBone::set_rotation(float v) { void SpineBone::set_rotation(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setRotation(v); get_spine_object()->setRotation(v);
} }
float SpineBone::get_scale_x() { float SpineBone::get_scale_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getScaleX(); return get_spine_object()->getScaleX();
} }
void SpineBone::set_scale_x(float v) { void SpineBone::set_scale_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setScaleX(v); get_spine_object()->setScaleX(v);
} }
float SpineBone::get_scale_y() { float SpineBone::get_scale_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getScaleY(); return get_spine_object()->getScaleY();
} }
void SpineBone::set_scale_y(float v) { void SpineBone::set_scale_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setScaleY(v); get_spine_object()->setScaleY(v);
} }
float SpineBone::get_shear_x() { float SpineBone::get_shear_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getShearX(); return get_spine_object()->getShearX();
} }
void SpineBone::set_shear_x(float v) { void SpineBone::set_shear_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setShearX(v); get_spine_object()->setShearX(v);
} }
float SpineBone::get_shear_y() { float SpineBone::get_shear_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getShearY(); return get_spine_object()->getShearY();
} }
void SpineBone::set_shear_y(float v) { void SpineBone::set_shear_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setShearY(v); get_spine_object()->setShearY(v);
} }
float SpineBone::get_applied_rotation() { float SpineBone::get_applied_rotation() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAppliedRotation(); return get_spine_object()->getAppliedRotation();
} }
void SpineBone::set_applied_rotation(float v) { void SpineBone::set_applied_rotation(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAppliedRotation(v); get_spine_object()->setAppliedRotation(v);
} }
float SpineBone::get_a_x() { float SpineBone::get_a_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAX(); return get_spine_object()->getAX();
} }
void SpineBone::set_a_x(float v) { void SpineBone::set_a_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAX(v); get_spine_object()->setAX(v);
} }
float SpineBone::get_a_y() { float SpineBone::get_a_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAY(); return get_spine_object()->getAY();
} }
void SpineBone::set_a_y(float v) { void SpineBone::set_a_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAY(v); get_spine_object()->setAY(v);
} }
float SpineBone::get_a_scale_x() { float SpineBone::get_a_scale_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAScaleX(); return get_spine_object()->getAScaleX();
} }
void SpineBone::set_a_scale_x(float v) { void SpineBone::set_a_scale_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAScaleX(v); get_spine_object()->setAScaleX(v);
} }
float SpineBone::get_a_scale_y() { float SpineBone::get_a_scale_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAScaleY(); return get_spine_object()->getAScaleY();
} }
void SpineBone::set_a_scale_y(float v) { void SpineBone::set_a_scale_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAScaleY(v); get_spine_object()->setAScaleY(v);
} }
float SpineBone::get_a_shear_x() { float SpineBone::get_a_shear_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAShearX(); return get_spine_object()->getAShearX();
} }
void SpineBone::set_a_shear_x(float v) { void SpineBone::set_a_shear_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAShearX(v); get_spine_object()->setAShearX(v);
} }
float SpineBone::get_a_shear_y() { float SpineBone::get_a_shear_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAShearY(); return get_spine_object()->getAShearY();
} }
void SpineBone::set_a_shear_y(float v) { void SpineBone::set_a_shear_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAShearY(v); get_spine_object()->setAShearY(v);
} }
float SpineBone::get_a() { float SpineBone::get_a() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getA(); return get_spine_object()->getA();
} }
void SpineBone::set_a(float v) { void SpineBone::set_a(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setA(v); get_spine_object()->setA(v);
} }
float SpineBone::get_b() { float SpineBone::get_b() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getB(); return get_spine_object()->getB();
} }
void SpineBone::set_b(float v) { void SpineBone::set_b(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setB(v); get_spine_object()->setB(v);
} }
float SpineBone::get_c() { float SpineBone::get_c() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getC(); return get_spine_object()->getC();
} }
void SpineBone::set_c(float v) { void SpineBone::set_c(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setC(v); get_spine_object()->setC(v);
} }
float SpineBone::get_d() { float SpineBone::get_d() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getD(); return get_spine_object()->getD();
} }
void SpineBone::set_d(float v) { void SpineBone::set_d(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setD(v); get_spine_object()->setD(v);
} }
float SpineBone::get_world_x() { float SpineBone::get_world_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getWorldX(); return get_spine_object()->getWorldX();
} }
void SpineBone::set_world_x(float v) { void SpineBone::set_world_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setWorldX(v); get_spine_object()->setWorldX(v);
} }
float SpineBone::get_world_y() { float SpineBone::get_world_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getWorldY(); return get_spine_object()->getWorldY();
} }
void SpineBone::set_world_y(float v) { void SpineBone::set_world_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setWorldY(v); get_spine_object()->setWorldY(v);
} }
float SpineBone::get_world_rotation_x() { float SpineBone::get_world_rotation_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getWorldRotationX(); return get_spine_object()->getWorldRotationX();
} }
float SpineBone::get_world_rotation_y() { float SpineBone::get_world_rotation_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getWorldRotationY(); return get_spine_object()->getWorldRotationY();
} }
float SpineBone::get_world_scale_x() { float SpineBone::get_world_scale_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getWorldScaleX(); return get_spine_object()->getWorldScaleX();
} }
float SpineBone::get_world_scale_y() { float SpineBone::get_world_scale_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getWorldScaleY(); return get_spine_object()->getWorldScaleY();
} }
bool SpineBone::is_active() { bool SpineBone::is_active() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->isActive(); return get_spine_object()->isActive();
} }
void SpineBone::set_active(bool v) { void SpineBone::set_active(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setActive(v); get_spine_object()->setActive(v);
} }
// External feature functions // External feature functions
void SpineBone::apply_world_transform_2d(const Variant &o) { void SpineBone::apply_world_transform_2d(const Variant &o) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
if (o.get_type() == Variant::OBJECT) { if (o.get_type() == Variant::OBJECT) {
auto node2d = Object::cast_to<Node2D>(o.operator Object*()); auto node2d = Object::cast_to<Node2D>(o.operator Object*());
if (node2d) { if (node2d) {
@ -429,7 +429,7 @@ void SpineBone::apply_world_transform_2d(const Variant &o) {
} }
Transform2D SpineBone::get_transform() { Transform2D SpineBone::get_transform() {
SPINE_CHECK(spine_object, Transform2D()) SPINE_CHECK(get_spine_object(), Transform2D())
Transform2D transform; Transform2D transform;
transform.rotate(Math::deg2rad(-get_rotation())); transform.rotate(Math::deg2rad(-get_rotation()));
transform.scale(Size2(get_scale_x(), get_scale_y())); transform.scale(Size2(get_scale_x(), get_scale_y()));
@ -438,7 +438,7 @@ Transform2D SpineBone::get_transform() {
} }
void SpineBone::set_transform(Transform2D transform) { void SpineBone::set_transform(Transform2D transform) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
Vector2 position = transform.get_origin(); Vector2 position = transform.get_origin();
position.y *= -1; position.y *= -1;
float rotation = Math::rad2deg(-transform.get_rotation()); float rotation = Math::rad2deg(-transform.get_rotation());
@ -452,7 +452,7 @@ void SpineBone::set_transform(Transform2D transform) {
} }
Transform2D SpineBone::get_global_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()) return get_transform();
if (!get_spine_owner()->is_visible_in_tree()) return get_transform(); if (!get_spine_owner()->is_visible_in_tree()) return get_transform();
Transform2D local; Transform2D local;
@ -463,7 +463,7 @@ Transform2D SpineBone::get_global_transform() {
} }
void SpineBone::set_global_transform(Transform2D 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()) set_transform(transform);
if (!get_spine_owner()->is_visible_in_tree()) return; if (!get_spine_owner()->is_visible_in_tree()) return;
transform = get_spine_owner()->get_global_transform().affine_inverse() * transform; transform = get_spine_owner()->get_global_transform().affine_inverse() * transform;

View File

@ -38,7 +38,7 @@
class SpineSkeleton; class SpineSkeleton;
class SpineSprite; class SpineSprite;
class SpineBone : public SpineObjectWrapper<SpineSprite, spine::Bone> { class SpineBone : public SpineSpriteOwnedObject<spine::Bone> {
GDCLASS(SpineBone, SpineObjectWrapper) GDCLASS(SpineBone, SpineObjectWrapper)
protected: protected:

View File

@ -59,18 +59,18 @@ void SpineBoneData::_bind_methods() {
} }
int SpineBoneData::get_index() { int SpineBoneData::get_index() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getIndex(); return get_spine_object()->getIndex();
} }
String SpineBoneData::get_bone_name() { String SpineBoneData::get_bone_name() {
SPINE_CHECK(spine_object, "") SPINE_CHECK(get_spine_object(), "")
return spine_object->getName().buffer(); return get_spine_object()->getName().buffer();
} }
Ref<SpineBoneData> SpineBoneData::get_parent() { Ref<SpineBoneData> SpineBoneData::get_parent() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto parent = spine_object->getParent(); auto parent = get_spine_object()->getParent();
if (!parent) return nullptr; if (!parent) return nullptr;
Ref<SpineBoneData> parent_ref(memnew(SpineBoneData)); Ref<SpineBoneData> parent_ref(memnew(SpineBoneData));
parent_ref->set_spine_object(get_spine_owner(), parent); parent_ref->set_spine_object(get_spine_owner(), parent);
@ -78,112 +78,112 @@ Ref<SpineBoneData> SpineBoneData::get_parent() {
} }
float SpineBoneData::get_length() { float SpineBoneData::get_length() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getLength(); return get_spine_object()->getLength();
} }
void SpineBoneData::set_length(float v) { void SpineBoneData::set_length(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setLength(v); get_spine_object()->setLength(v);
} }
float SpineBoneData::get_x() { float SpineBoneData::get_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getX(); return get_spine_object()->getX();
} }
void SpineBoneData::set_x(float v) { void SpineBoneData::set_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setX(v); get_spine_object()->setX(v);
} }
float SpineBoneData::get_y() { float SpineBoneData::get_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getY(); return get_spine_object()->getY();
} }
void SpineBoneData::set_y(float v) { void SpineBoneData::set_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setY(v); get_spine_object()->setY(v);
} }
float SpineBoneData::get_rotation() { float SpineBoneData::get_rotation() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getRotation(); return get_spine_object()->getRotation();
} }
void SpineBoneData::set_rotation(float v) { void SpineBoneData::set_rotation(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setRotation(v); get_spine_object()->setRotation(v);
} }
float SpineBoneData::get_scale_x() { float SpineBoneData::get_scale_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getScaleX(); return get_spine_object()->getScaleX();
} }
void SpineBoneData::set_scale_x(float v) { void SpineBoneData::set_scale_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setScaleX(v); get_spine_object()->setScaleX(v);
} }
float SpineBoneData::get_scale_y() { float SpineBoneData::get_scale_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getScaleY(); return get_spine_object()->getScaleY();
} }
void SpineBoneData::set_scale_y(float v) { void SpineBoneData::set_scale_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setScaleY(v); get_spine_object()->setScaleY(v);
} }
float SpineBoneData::get_shear_x() { float SpineBoneData::get_shear_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getShearX(); return get_spine_object()->getShearX();
} }
void SpineBoneData::set_shear_x(float v) { void SpineBoneData::set_shear_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setShearX(v); get_spine_object()->setShearX(v);
} }
float SpineBoneData::get_shear_y() { float SpineBoneData::get_shear_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getShearY(); return get_spine_object()->getShearY();
} }
void SpineBoneData::set_shear_y(float v) { void SpineBoneData::set_shear_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setShearY(v); get_spine_object()->setShearY(v);
} }
SpineConstant::TransformMode SpineBoneData::get_transform_mode() { SpineConstant::TransformMode SpineBoneData::get_transform_mode() {
SPINE_CHECK(spine_object, SpineConstant::TransformMode::TransformMode_Normal) SPINE_CHECK(get_spine_object(), SpineConstant::TransformMode::TransformMode_Normal)
return (SpineConstant::TransformMode) spine_object->getTransformMode(); return (SpineConstant::TransformMode) get_spine_object()->getTransformMode();
} }
void SpineBoneData::set_transform_mode(SpineConstant::TransformMode v) { void SpineBoneData::set_transform_mode(SpineConstant::TransformMode v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setTransformMode((spine::TransformMode) v); get_spine_object()->setTransformMode((spine::TransformMode) v);
} }
bool SpineBoneData::is_skin_required() { bool SpineBoneData::is_skin_required() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->isSkinRequired(); return get_spine_object()->isSkinRequired();
} }
void SpineBoneData::set_skin_required(bool v) { void SpineBoneData::set_skin_required(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setSkinRequired(v); get_spine_object()->setSkinRequired(v);
} }
Color SpineBoneData::get_color() { Color SpineBoneData::get_color() {
SPINE_CHECK(spine_object, Color()) SPINE_CHECK(get_spine_object(), Color())
auto color = spine_object->getColor(); auto color = get_spine_object()->getColor();
return Color(color.r, color.g, color.b, color.a); return Color(color.r, color.g, color.b, color.a);
} }
void SpineBoneData::set_color(Color color) { void SpineBoneData::set_color(Color color) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->getColor().set(color.r, color.g, color.b, color.a); get_spine_object()->getColor().set(color.r, color.g, color.b, color.a);
} }

View File

@ -36,7 +36,7 @@
class SpineSkeletonDataResource; class SpineSkeletonDataResource;
class SpineBoneData : public SpineObjectWrapper<SpineSkeletonDataResource, spine::BoneData> { class SpineBoneData : public SpineSkeletonDataResourceOwnedObject<spine::BoneData> {
GDCLASS(SpineBoneData, SpineObjectWrapper) GDCLASS(SpineBoneData, SpineObjectWrapper)
protected: protected:

View File

@ -52,8 +52,6 @@
#define VARIANT_FLOAT Variant::REAL #define VARIANT_FLOAT Variant::REAL
#endif #endif
#include "SpineObjectWrapper.h"
#define SPINE_CHECK(obj, ret) \ #define SPINE_CHECK(obj, ret) \
if (!(obj)) { \ if (!(obj)) { \
ERR_PRINT("Native Spine object not set."); \ ERR_PRINT("Native Spine object not set."); \
@ -62,4 +60,81 @@
#define SPINE_STRING(x) spine::String((x).utf8()) #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 #endif

View File

@ -40,26 +40,26 @@ void SpineConstraintData::_bind_methods() {
} }
String SpineConstraintData::get_constraint_name() { String SpineConstraintData::get_constraint_name() {
SPINE_CHECK(spine_object, "") SPINE_CHECK(get_spine_object(), "")
return spine_object->getName().buffer(); return get_spine_object()->getName().buffer();
} }
int SpineConstraintData::get_order() { int SpineConstraintData::get_order() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return (int)spine_object->getOrder(); return (int)get_spine_object()->getOrder();
} }
void SpineConstraintData::set_order(int v) { void SpineConstraintData::set_order(int v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setOrder(v); get_spine_object()->setOrder(v);
} }
bool SpineConstraintData::is_skin_required() { bool SpineConstraintData::is_skin_required() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->isSkinRequired(); return get_spine_object()->isSkinRequired();
} }
void SpineConstraintData::set_skin_required(bool v) { void SpineConstraintData::set_skin_required(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setSkinRequired(v); get_spine_object()->setSkinRequired(v);
} }

View File

@ -35,7 +35,7 @@
class SpineSkeletonDataResource; class SpineSkeletonDataResource;
class SpineConstraintData : public SpineObjectWrapper<SpineSkeletonDataResource, spine::ConstraintData> { class SpineConstraintData : public SpineSkeletonDataResourceOwnedObject<spine::ConstraintData> {
GDCLASS(SpineConstraintData, SpineObjectWrapper) GDCLASS(SpineConstraintData, SpineObjectWrapper)
protected: protected:

View File

@ -47,63 +47,63 @@ void SpineEvent::_bind_methods() {
} }
Ref<SpineEventData> SpineEvent::get_data() { Ref<SpineEventData> SpineEvent::get_data() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
Ref<SpineEventData> event_data(memnew(SpineEventData)); 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; return event_data;
} }
float SpineEvent::get_time() { float SpineEvent::get_time() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getTime(); return get_spine_object()->getTime();
} }
int SpineEvent::get_int_value() { int SpineEvent::get_int_value() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getIntValue(); return get_spine_object()->getIntValue();
} }
void SpineEvent::set_int_value(int v) { void SpineEvent::set_int_value(int v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setIntValue(v); get_spine_object()->setIntValue(v);
} }
float SpineEvent::get_float_value() { float SpineEvent::get_float_value() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getFloatValue(); return get_spine_object()->getFloatValue();
} }
void SpineEvent::set_float_value(float v) { void SpineEvent::set_float_value(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setFloatValue(v); get_spine_object()->setFloatValue(v);
} }
String SpineEvent::get_string_value() { String SpineEvent::get_string_value() {
SPINE_CHECK(spine_object, "") SPINE_CHECK(get_spine_object(), "")
return spine_object->getStringValue().buffer(); return get_spine_object()->getStringValue().buffer();
} }
void SpineEvent::set_string_value(const String &v) { void SpineEvent::set_string_value(const String &v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setStringValue(spine::String(v.utf8())); get_spine_object()->setStringValue(spine::String(v.utf8()));
} }
float SpineEvent::get_volume() { float SpineEvent::get_volume() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getVolume(); return get_spine_object()->getVolume();
} }
void SpineEvent::set_volume(float v) { void SpineEvent::set_volume(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setVolume(v); get_spine_object()->setVolume(v);
} }
float SpineEvent::get_balance() { float SpineEvent::get_balance() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getBalance(); return get_spine_object()->getBalance();
} }
void SpineEvent::set_balance(float v) { void SpineEvent::set_balance(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setBalance(v); get_spine_object()->setBalance(v);
} }

View File

@ -36,7 +36,7 @@
class SpineSprite; class SpineSprite;
class SpineEvent : public SpineObjectWrapper<SpineSprite, spine::Event> { class SpineEvent : public SpineSpriteOwnedObject<spine::Event> {
GDCLASS(SpineEvent, SpineObjectWrapper) GDCLASS(SpineEvent, SpineObjectWrapper)
protected: protected:

View File

@ -45,56 +45,56 @@ void SpineEventData::_bind_methods() {
} }
String SpineEventData::get_event_name() { String SpineEventData::get_event_name() {
SPINE_CHECK(spine_object, "") SPINE_CHECK(get_spine_object(), "")
return spine_object->getName().buffer(); return get_spine_object()->getName().buffer();
} }
int SpineEventData::get_int_value() { int SpineEventData::get_int_value() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getIntValue(); return get_spine_object()->getIntValue();
} }
void SpineEventData::set_int_value(int v) { void SpineEventData::set_int_value(int v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setIntValue(v); get_spine_object()->setIntValue(v);
} }
float SpineEventData::get_float_value() { float SpineEventData::get_float_value() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getFloatValue(); return get_spine_object()->getFloatValue();
} }
void SpineEventData::set_float_value(float v) { void SpineEventData::set_float_value(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setFloatValue(v); get_spine_object()->setFloatValue(v);
} }
String SpineEventData::get_string_value() { String SpineEventData::get_string_value() {
SPINE_CHECK(spine_object, "") SPINE_CHECK(get_spine_object(), "")
return spine_object->getStringValue().buffer(); return get_spine_object()->getStringValue().buffer();
} }
void SpineEventData::set_string_value(const String &v) { void SpineEventData::set_string_value(const String &v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setStringValue(spine::String(v.utf8())); get_spine_object()->setStringValue(spine::String(v.utf8()));
} }
float SpineEventData::get_volume() { float SpineEventData::get_volume() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getVolume(); return get_spine_object()->getVolume();
} }
void SpineEventData::set_volume(float v) { void SpineEventData::set_volume(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setVolume(v); get_spine_object()->setVolume(v);
} }
float SpineEventData::get_balance() { float SpineEventData::get_balance() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getBalance(); return get_spine_object()->getBalance();
} }
void SpineEventData::set_balance(float v) { void SpineEventData::set_balance(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setBalance(v); get_spine_object()->setBalance(v);
} }

View File

@ -35,8 +35,8 @@
class SpineSkeletonDataResource; class SpineSkeletonDataResource;
class SpineEventData : public SpineObjectWrapper<SpineSkeletonDataResource, spine::EventData> { class SpineEventData : public SpineSkeletonDataResourceOwnedObject<spine::EventData> {
GDCLASS(SpineEventData, REFCOUNTED); GDCLASS(SpineEventData, SpineObjectWrapper);
protected: protected:
static void _bind_methods(); static void _bind_methods();

View File

@ -54,18 +54,18 @@ void SpineIkConstraint::_bind_methods() {
} }
void SpineIkConstraint::update() { void SpineIkConstraint::update() {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->update(); get_spine_object()->update();
} }
int SpineIkConstraint::get_order() { int SpineIkConstraint::get_order() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getOrder(); return get_spine_object()->getOrder();
} }
Ref<SpineIkConstraintData> SpineIkConstraint::get_data() { Ref<SpineIkConstraintData> SpineIkConstraint::get_data() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto &ik_constraint_data = spine_object->getData(); auto &ik_constraint_data = get_spine_object()->getData();
Ref<SpineIkConstraintData> ik_constraint_data_ref(memnew(SpineIkConstraintData)); 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); ik_constraint_data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &ik_constraint_data);
return ik_constraint_data_ref; return ik_constraint_data_ref;
@ -73,8 +73,8 @@ Ref<SpineIkConstraintData> SpineIkConstraint::get_data() {
Array SpineIkConstraint::get_bones() { Array SpineIkConstraint::get_bones() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto &bones = spine_object->getBones(); auto &bones = get_spine_object()->getBones();
result.resize((int)bones.size()); result.resize((int)bones.size());
for (int i = 0; i < bones.size(); ++i) { for (int i = 0; i < bones.size(); ++i) {
auto bone = bones[i]; auto bone = bones[i];
@ -86,8 +86,8 @@ Array SpineIkConstraint::get_bones() {
} }
Ref<SpineBone> SpineIkConstraint::get_target() { Ref<SpineBone> SpineIkConstraint::get_target() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto target = spine_object->getTarget(); auto target = get_spine_object()->getTarget();
if (!target) return nullptr; if (!target) return nullptr;
Ref<SpineBone> target_ref(memnew(SpineBone)); Ref<SpineBone> target_ref(memnew(SpineBone));
target_ref->set_spine_object(get_spine_owner(), target); 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) { void SpineIkConstraint::set_target(Ref<SpineBone> v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr); get_spine_object()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
} }
int SpineIkConstraint::get_bend_direction() { int SpineIkConstraint::get_bend_direction() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getBendDirection(); return get_spine_object()->getBendDirection();
} }
void SpineIkConstraint::set_bend_direction(int v) { void SpineIkConstraint::set_bend_direction(int v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setBendDirection(v); get_spine_object()->setBendDirection(v);
} }
bool SpineIkConstraint::get_compress() { bool SpineIkConstraint::get_compress() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->getCompress(); return get_spine_object()->getCompress();
} }
void SpineIkConstraint::set_compress(bool v) { void SpineIkConstraint::set_compress(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setCompress(v); get_spine_object()->setCompress(v);
} }
bool SpineIkConstraint::get_stretch() { bool SpineIkConstraint::get_stretch() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->getStretch(); return get_spine_object()->getStretch();
} }
void SpineIkConstraint::set_stretch(bool v) { void SpineIkConstraint::set_stretch(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setStretch(v); get_spine_object()->setStretch(v);
} }
float SpineIkConstraint::get_mix() { float SpineIkConstraint::get_mix() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMix(); return get_spine_object()->getMix();
} }
void SpineIkConstraint::set_mix(float v) { void SpineIkConstraint::set_mix(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMix(v); get_spine_object()->setMix(v);
} }
float SpineIkConstraint::get_softness() { float SpineIkConstraint::get_softness() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getSoftness(); return get_spine_object()->getSoftness();
} }
void SpineIkConstraint::set_softness(float v) { void SpineIkConstraint::set_softness(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setSoftness(v); get_spine_object()->setSoftness(v);
} }
bool SpineIkConstraint::is_active() { bool SpineIkConstraint::is_active() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->isActive(); return get_spine_object()->isActive();
} }
void SpineIkConstraint::set_active(bool v) { void SpineIkConstraint::set_active(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setActive(v); get_spine_object()->setActive(v);
} }

View File

@ -36,7 +36,7 @@
class SpineBone; class SpineBone;
class SpineSprite; class SpineSprite;
class SpineIkConstraint : public SpineObjectWrapper<SpineSprite, spine::IkConstraint> { class SpineIkConstraint : public SpineSpriteOwnedObject<spine::IkConstraint> {
GDCLASS(SpineIkConstraint, SpineObjectWrapper) GDCLASS(SpineIkConstraint, SpineObjectWrapper)
protected: protected:

View File

@ -50,7 +50,7 @@ void SpineIkConstraintData::_bind_methods() {
Array SpineIkConstraintData::get_bones() { Array SpineIkConstraintData::get_bones() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto bones = get_spine_constraint_data()->getBones(); auto bones = get_spine_constraint_data()->getBones();
result.resize((int)bones.size()); result.resize((int)bones.size());
for (int i = 0; i < bones.size(); ++i) { for (int i = 0; i < bones.size(); ++i) {
@ -62,7 +62,7 @@ Array SpineIkConstraintData::get_bones() {
} }
Ref<SpineBoneData> SpineIkConstraintData::get_target() { Ref<SpineBoneData> SpineIkConstraintData::get_target() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto target = get_spine_constraint_data()->getTarget(); auto target = get_spine_constraint_data()->getTarget();
if (!target) return nullptr; if (!target) return nullptr;
Ref<SpineBoneData> target_ref(memnew(SpineBoneData)); Ref<SpineBoneData> target_ref(memnew(SpineBoneData));
@ -71,66 +71,66 @@ Ref<SpineBoneData> SpineIkConstraintData::get_target() {
} }
void SpineIkConstraintData::set_target(Ref<SpineBoneData> v) { 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); get_spine_constraint_data()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
} }
int SpineIkConstraintData::get_bend_direction() { int SpineIkConstraintData::get_bend_direction() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return get_spine_constraint_data()->getBendDirection(); return get_spine_constraint_data()->getBendDirection();
} }
void SpineIkConstraintData::set_bend_direction(int v) { void SpineIkConstraintData::set_bend_direction(int v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
get_spine_constraint_data()->setBendDirection(v); get_spine_constraint_data()->setBendDirection(v);
} }
bool SpineIkConstraintData::get_compress() { bool SpineIkConstraintData::get_compress() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return get_spine_constraint_data()->getCompress(); return get_spine_constraint_data()->getCompress();
} }
void SpineIkConstraintData::set_compress(bool v) { void SpineIkConstraintData::set_compress(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
get_spine_constraint_data()->setCompress(v); get_spine_constraint_data()->setCompress(v);
} }
bool SpineIkConstraintData::get_stretch() { bool SpineIkConstraintData::get_stretch() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return get_spine_constraint_data()->getStretch(); return get_spine_constraint_data()->getStretch();
} }
void SpineIkConstraintData::set_stretch(bool v) { void SpineIkConstraintData::set_stretch(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
get_spine_constraint_data()->setStretch(v); get_spine_constraint_data()->setStretch(v);
} }
bool SpineIkConstraintData::get_uniform() { bool SpineIkConstraintData::get_uniform() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return get_spine_constraint_data()->getUniform(); return get_spine_constraint_data()->getUniform();
} }
void SpineIkConstraintData::set_uniform(bool v) { void SpineIkConstraintData::set_uniform(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
get_spine_constraint_data()->setUniform(v); get_spine_constraint_data()->setUniform(v);
} }
float SpineIkConstraintData::get_mix() { float SpineIkConstraintData::get_mix() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return get_spine_constraint_data()->getMix(); return get_spine_constraint_data()->getMix();
} }
void SpineIkConstraintData::set_mix(float v) { void SpineIkConstraintData::set_mix(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
get_spine_constraint_data()->setMix(v); get_spine_constraint_data()->setMix(v);
} }
float SpineIkConstraintData::get_softness() { float SpineIkConstraintData::get_softness() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return get_spine_constraint_data()->getSoftness(); return get_spine_constraint_data()->getSoftness();
} }
void SpineIkConstraintData::set_softness(float v) { void SpineIkConstraintData::set_softness(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
get_spine_constraint_data()->setSoftness(v); get_spine_constraint_data()->setSoftness(v);
} }

View File

@ -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"

View File

@ -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

View File

@ -54,69 +54,69 @@ void SpinePathConstraint::_bind_methods() {
} }
void SpinePathConstraint::update() { void SpinePathConstraint::update() {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->update(); get_spine_object()->update();
} }
int SpinePathConstraint::get_order() { int SpinePathConstraint::get_order() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getOrder(); return get_spine_object()->getOrder();
} }
float SpinePathConstraint::get_position() { float SpinePathConstraint::get_position() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getPosition(); return get_spine_object()->getPosition();
} }
void SpinePathConstraint::set_position(float v) { void SpinePathConstraint::set_position(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setPosition(v); get_spine_object()->setPosition(v);
} }
float SpinePathConstraint::get_spacing() { float SpinePathConstraint::get_spacing() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getSpacing(); return get_spine_object()->getSpacing();
} }
void SpinePathConstraint::set_spacing(float v) { void SpinePathConstraint::set_spacing(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setSpacing(v); get_spine_object()->setSpacing(v);
} }
float SpinePathConstraint::get_mix_rotate() { float SpinePathConstraint::get_mix_rotate() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMixRotate(); return get_spine_object()->getMixRotate();
} }
void SpinePathConstraint::set_mix_rotate(float v) { void SpinePathConstraint::set_mix_rotate(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixRotate(v); get_spine_object()->setMixRotate(v);
} }
float SpinePathConstraint::get_mix_x() { float SpinePathConstraint::get_mix_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMixX(); return get_spine_object()->getMixX();
} }
void SpinePathConstraint::set_mix_x(float v) { void SpinePathConstraint::set_mix_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixX(v); get_spine_object()->setMixX(v);
} }
float SpinePathConstraint::get_mix_y() { float SpinePathConstraint::get_mix_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMixY(); return get_spine_object()->getMixY();
} }
void SpinePathConstraint::set_mix_y(float v) { void SpinePathConstraint::set_mix_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixY(v); get_spine_object()->setMixY(v);
} }
Array SpinePathConstraint::get_bones() { Array SpinePathConstraint::get_bones() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto &bones = spine_object->getBones(); auto &bones = get_spine_object()->getBones();
result.resize((int)bones.size()); result.resize((int)bones.size());
for (int i = 0; i < bones.size(); ++i) { for (int i = 0; i < bones.size(); ++i) {
auto bone = bones[i]; auto bone = bones[i];
@ -128,8 +128,8 @@ Array SpinePathConstraint::get_bones() {
} }
Ref<SpineSlot> SpinePathConstraint::get_target() { Ref<SpineSlot> SpinePathConstraint::get_target() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto target = spine_object->getTarget(); auto target = get_spine_object()->getTarget();
if (!target) return nullptr; if (!target) return nullptr;
Ref<SpineSlot> target_ref(memnew(SpineSlot)); Ref<SpineSlot> target_ref(memnew(SpineSlot));
target_ref->set_spine_object(get_spine_owner(), target); 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) { void SpinePathConstraint::set_target(Ref<SpineSlot> v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr); get_spine_object()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
} }
Ref<SpinePathConstraintData> SpinePathConstraint::get_data() { Ref<SpinePathConstraintData> SpinePathConstraint::get_data() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto &data = spine_object->getData(); auto &data = get_spine_object()->getData();
Ref<SpinePathConstraintData> data_ref(memnew(SpinePathConstraintData)); Ref<SpinePathConstraintData> data_ref(memnew(SpinePathConstraintData));
data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &data); data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &data);
return data_ref; return data_ref;
} }
bool SpinePathConstraint::is_active() { bool SpinePathConstraint::is_active() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->isActive(); return get_spine_object()->isActive();
} }
void SpinePathConstraint::set_active(bool v) { void SpinePathConstraint::set_active(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setActive(v); get_spine_object()->setActive(v);
} }

View File

@ -34,7 +34,7 @@
#include "SpineSlot.h" #include "SpineSlot.h"
#include <spine/PathConstraint.h> #include <spine/PathConstraint.h>
class SpinePathConstraint : public SpineObjectWrapper<SpineSprite, spine::PathConstraint> { class SpinePathConstraint : public SpineSpriteOwnedObject<spine::PathConstraint> {
GDCLASS(SpinePathConstraint, SpineObjectWrapper) GDCLASS(SpinePathConstraint, SpineObjectWrapper)
protected: protected:

View File

@ -117,6 +117,7 @@ void SpineSkeletonDataResource::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_fps"), &SpineSkeletonDataResource::get_fps); ClassDB::bind_method(D_METHOD("get_fps"), &SpineSkeletonDataResource::get_fps);
ADD_SIGNAL(MethodInfo("skeleton_data_changed")); 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, "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"); 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; animation_state_data = nullptr;
} }
emit_signal("_internal_spine_objects_invalidated");
if (atlas_res.is_valid() && skeleton_file_res.is_valid()) { 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()); load_resources(atlas_res->get_spine_atlas(), skeleton_file_res->get_json(), skeleton_file_res->get_binary());
} }

View File

@ -51,11 +51,11 @@ SpineSkin::SpineSkin() : owns_skin(false) {
} }
SpineSkin::~SpineSkin() { SpineSkin::~SpineSkin() {
if (owns_skin) delete spine_object; if (owns_skin) delete get_spine_object();
} }
Ref<SpineSkin> SpineSkin::init(const String &name, SpineSprite *sprite) { 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."); ERR_PRINT("Can not initialize an already initialized skin.");
return this; 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) { void SpineSkin::set_attachment(int slot_index, const String &name, Ref<SpineAttachment> attachment) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAttachment(slot_index, SPINE_STRING(name), attachment.is_valid() && attachment->get_spine_object()? attachment->get_spine_object() : nullptr); 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) { Ref<SpineAttachment> SpineSkin::get_attachment(int slot_index, const String &name) {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto attachment = spine_object->getAttachment(slot_index, SPINE_STRING(name)); auto attachment = get_spine_object()->getAttachment(slot_index, SPINE_STRING(name));
if (attachment) return nullptr; if (attachment) return nullptr;
Ref<SpineAttachment> attachment_ref(memnew(SpineAttachment)); Ref<SpineAttachment> attachment_ref(memnew(SpineAttachment));
attachment_ref->set_spine_object(get_spine_owner(), attachment); 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) { void SpineSkin::remove_attachment(int slot_index, const String &name) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->removeAttachment(slot_index, SPINE_STRING(name)); get_spine_object()->removeAttachment(slot_index, SPINE_STRING(name));
} }
Array SpineSkin::find_names_for_slot(int slot_index) { Array SpineSkin::find_names_for_slot(int slot_index) {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
spine::Vector<spine::String> names; spine::Vector<spine::String> names;
spine_object->findNamesForSlot(slot_index, names); get_spine_object()->findNamesForSlot(slot_index, names);
result.resize((int)names.size()); result.resize((int)names.size());
for (int i = 0; i < names.size(); ++i) { for (int i = 0; i < names.size(); ++i) {
result[i] = names[i].buffer(); 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 SpineSkin::find_attachments_for_slot(int slot_index) {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
spine::Vector<spine::Attachment *> attachments; spine::Vector<spine::Attachment *> attachments;
spine_object->findAttachmentsForSlot(slot_index, attachments); get_spine_object()->findAttachmentsForSlot(slot_index, attachments);
result.resize((int)attachments.size()); result.resize((int)attachments.size());
for (int i = 0; i < attachments.size(); ++i) { for (int i = 0; i < attachments.size(); ++i) {
if (!attachments[i]) { if (!attachments[i]) {
@ -122,32 +122,32 @@ Array SpineSkin::find_attachments_for_slot(int slot_index) {
} }
String SpineSkin::get_name() { String SpineSkin::get_name() {
SPINE_CHECK(spine_object, "") SPINE_CHECK(get_spine_object(), "")
return spine_object->getName().buffer(); return get_spine_object()->getName().buffer();
} }
void SpineSkin::add_skin(Ref<SpineSkin> other) { void SpineSkin::add_skin(Ref<SpineSkin> other) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
if (!other.is_valid() || !other->get_spine_object()) { if (!other.is_valid() || !other->get_spine_object()) {
ERR_PRINT("other is not a valid SpineSkin."); ERR_PRINT("other is not a valid SpineSkin.");
return; return;
} }
spine_object->addSkin(other->get_spine_object()); get_spine_object()->addSkin(other->get_spine_object());
} }
void SpineSkin::copy_skin(Ref<SpineSkin> other) { void SpineSkin::copy_skin(Ref<SpineSkin> other) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
if (!other.is_valid() || !other->get_spine_object()) { if (!other.is_valid() || !other->get_spine_object()) {
ERR_PRINT("other is not a valid SpineSkin."); ERR_PRINT("other is not a valid SpineSkin.");
return; return;
} }
spine_object->copySkin(other->get_spine_object()); get_spine_object()->copySkin(other->get_spine_object());
} }
Array SpineSkin::get_attachments() { Array SpineSkin::get_attachments() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto entries = spine_object->getAttachments(); auto entries = get_spine_object()->getAttachments();
while(entries.hasNext()) { while(entries.hasNext()) {
spine::Skin::AttachmentMap::Entry &entry = entries.next(); spine::Skin::AttachmentMap::Entry &entry = entries.next();
Ref<SpineSkinEntry> entry_ref = memnew(SpineSkinEntry); Ref<SpineSkinEntry> entry_ref = memnew(SpineSkinEntry);
@ -164,8 +164,8 @@ Array SpineSkin::get_attachments() {
Array SpineSkin::get_bones() { Array SpineSkin::get_bones() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto bones = spine_object->getBones(); auto bones = get_spine_object()->getBones();
result.resize((int)bones.size()); result.resize((int)bones.size());
for (int i = 0; i < bones.size(); ++i) { for (int i = 0; i < bones.size(); ++i) {
Ref<SpineBoneData> bone_ref(memnew(SpineBoneData)); Ref<SpineBoneData> bone_ref(memnew(SpineBoneData));
@ -177,8 +177,8 @@ Array SpineSkin::get_bones() {
Array SpineSkin::get_constraints() { Array SpineSkin::get_constraints() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto constraints = spine_object->getConstraints(); auto constraints = get_spine_object()->getConstraints();
result.resize((int)constraints.size()); result.resize((int)constraints.size());
for (int i = 0; i < constraints.size(); ++i) { for (int i = 0; i < constraints.size(); ++i) {
Ref<SpineConstraintData> constraint_ref(memnew(SpineConstraintData)); Ref<SpineConstraintData> constraint_ref(memnew(SpineConstraintData));

View File

@ -36,7 +36,7 @@
class SpineSkeletonDataResource; class SpineSkeletonDataResource;
class SpineSprite; class SpineSprite;
class SpineSkin : public SpineObjectWrapper<SpineSkeletonDataResource, spine::Skin> { class SpineSkin : public SpineSkeletonDataResourceOwnedObject<spine::Skin> {
GDCLASS(SpineSkin, SpineObjectWrapper) GDCLASS(SpineSkin, SpineObjectWrapper)
protected: protected:

View File

@ -53,58 +53,58 @@ void SpineSlot::_bind_methods() {
} }
void SpineSlot::set_to_setup_pose() { void SpineSlot::set_to_setup_pose() {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setToSetupPose(); get_spine_object()->setToSetupPose();
} }
Ref<SpineSlotData> SpineSlot::get_data() { Ref<SpineSlotData> SpineSlot::get_data() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto &slot_data = spine_object->getData(); auto &slot_data = get_spine_object()->getData();
Ref<SpineSlotData> slot_data_ref(memnew(SpineSlotData)); Ref<SpineSlotData> slot_data_ref(memnew(SpineSlotData));
slot_data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &slot_data); slot_data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &slot_data);
return slot_data_ref; return slot_data_ref;
} }
Ref<SpineBone> SpineSlot::get_bone() { Ref<SpineBone> SpineSlot::get_bone() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto &bone = spine_object->getBone(); auto &bone = get_spine_object()->getBone();
Ref<SpineBone> bone_ref(memnew(SpineBone)); Ref<SpineBone> bone_ref(memnew(SpineBone));
bone_ref->set_spine_object(get_spine_owner(), &bone); bone_ref->set_spine_object(get_spine_owner(), &bone);
return bone_ref; return bone_ref;
} }
Color SpineSlot::get_color() { Color SpineSlot::get_color() {
SPINE_CHECK(spine_object, Color(0, 0, 0, 0)) SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0))
auto &color = spine_object->getColor(); auto &color = get_spine_object()->getColor();
return Color(color.r, color.g, color.b, color.a); return Color(color.r, color.g, color.b, color.a);
} }
void SpineSlot::set_color(Color v) { void SpineSlot::set_color(Color v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
auto &color = spine_object->getColor(); auto &color = get_spine_object()->getColor();
color.set(v.r, v.g, v.b, v.a); color.set(v.r, v.g, v.b, v.a);
} }
Color SpineSlot::get_dark_color() { Color SpineSlot::get_dark_color() {
SPINE_CHECK(spine_object, Color(0, 0, 0, 0)) SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0))
auto &color = spine_object->getDarkColor(); auto &color = get_spine_object()->getDarkColor();
return Color(color.r, color.g, color.b, color.a); return Color(color.r, color.g, color.b, color.a);
} }
void SpineSlot::set_dark_color(Color v) { void SpineSlot::set_dark_color(Color v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
auto &color = spine_object->getDarkColor(); auto &color = get_spine_object()->getDarkColor();
color.set(v.r, v.g, v.b, v.a); color.set(v.r, v.g, v.b, v.a);
} }
bool SpineSlot::has_dark_color() { bool SpineSlot::has_dark_color() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->hasDarkColor(); return get_spine_object()->hasDarkColor();
} }
Ref<SpineAttachment> SpineSlot::get_attachment() { Ref<SpineAttachment> SpineSlot::get_attachment() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto attachment = spine_object->getAttachment(); auto attachment = get_spine_object()->getAttachment();
if (!attachment) return nullptr; if (!attachment) return nullptr;
Ref<SpineAttachment> attachment_ref(memnew(SpineAttachment)); Ref<SpineAttachment> attachment_ref(memnew(SpineAttachment));
attachment_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), attachment); 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) { void SpineSlot::set_attachment(Ref<SpineAttachment> v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAttachment(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr); get_spine_object()->setAttachment(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
} }
int SpineSlot::get_attachment_state() { int SpineSlot::get_attachment_state() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAttachmentState(); return get_spine_object()->getAttachmentState();
} }
void SpineSlot::set_attachment_state(int v) { void SpineSlot::set_attachment_state(int v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAttachmentState(v); get_spine_object()->setAttachmentState(v);
} }
Array SpineSlot::get_deform() { Array SpineSlot::get_deform() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto &deform = spine_object->getDeform(); auto &deform = get_spine_object()->getDeform();
result.resize((int)deform.size()); result.resize((int)deform.size());
for (int i = 0; i < (int)deform.size(); ++i) { for (int i = 0; i < (int)deform.size(); ++i) {
result[i] = deform[i]; result[i] = deform[i];
@ -138,8 +138,8 @@ Array SpineSlot::get_deform() {
} }
void SpineSlot::set_deform(Array v) { void SpineSlot::set_deform(Array v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
auto &deform = spine_object->getDeform(); auto &deform = get_spine_object()->getDeform();
deform.setSize(v.size(), 0); deform.setSize(v.size(), 0);
for (int i = 0; i < v.size(); ++i) { for (int i = 0; i < v.size(); ++i) {
deform[i] = v[i]; deform[i] = v[i];
@ -147,11 +147,11 @@ void SpineSlot::set_deform(Array v) {
} }
int SpineSlot::get_sequence_index() { int SpineSlot::get_sequence_index() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAttachmentState(); return get_spine_object()->getAttachmentState();
} }
void SpineSlot::set_sequence_index(int v) { void SpineSlot::set_sequence_index(int v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAttachmentState(v); get_spine_object()->setAttachmentState(v);
} }

View File

@ -38,7 +38,7 @@
class SpineSkeleton; class SpineSkeleton;
class SpineSprite; class SpineSprite;
class SpineSlot : public SpineObjectWrapper<SpineSprite, spine::Slot> { class SpineSlot : public SpineSpriteOwnedObject<spine::Slot> {
GDCLASS(SpineSlot, SpineObjectWrapper) GDCLASS(SpineSlot, SpineObjectWrapper)
protected: protected:

View File

@ -48,71 +48,71 @@ void SpineSlotData::_bind_methods() {
} }
int SpineSlotData::get_index() { int SpineSlotData::get_index() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getIndex(); return get_spine_object()->getIndex();
} }
String SpineSlotData::get_name() { String SpineSlotData::get_name() {
SPINE_CHECK(spine_object, String("")) SPINE_CHECK(get_spine_object(), String(""))
return spine_object->getName().buffer(); return get_spine_object()->getName().buffer();
} }
Ref<SpineBoneData> SpineSlotData::get_bone_data() { Ref<SpineBoneData> SpineSlotData::get_bone_data() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto &bone_data = spine_object->getBoneData(); auto &bone_data = get_spine_object()->getBoneData();
Ref<SpineBoneData> bone_data_ref(memnew(SpineBoneData)); Ref<SpineBoneData> bone_data_ref(memnew(SpineBoneData));
bone_data_ref->set_spine_object(get_spine_owner(), &bone_data); bone_data_ref->set_spine_object(get_spine_owner(), &bone_data);
return bone_data_ref; return bone_data_ref;
} }
Color SpineSlotData::get_color() { Color SpineSlotData::get_color() {
SPINE_CHECK(spine_object, Color(0, 0, 0, 0)) SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0))
auto &color = spine_object->getColor(); auto &color = get_spine_object()->getColor();
return Color(color.r, color.g, color.b, color.a); return Color(color.r, color.g, color.b, color.a);
} }
void SpineSlotData::set_color(Color v) { void SpineSlotData::set_color(Color v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
auto &color = spine_object->getColor(); auto &color = get_spine_object()->getColor();
color.set(v.r, v.g, v.b, v.a); color.set(v.r, v.g, v.b, v.a);
} }
Color SpineSlotData::get_dark_color() { Color SpineSlotData::get_dark_color() {
SPINE_CHECK(spine_object, Color(0, 0, 0, 0)) SPINE_CHECK(get_spine_object(), Color(0, 0, 0, 0))
auto &color = spine_object->getDarkColor(); auto &color = get_spine_object()->getDarkColor();
return Color(color.r, color.g, color.b, color.a); return Color(color.r, color.g, color.b, color.a);
} }
void SpineSlotData::set_dark_color(Color v) { void SpineSlotData::set_dark_color(Color v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
auto &color = spine_object->getDarkColor(); auto &color = get_spine_object()->getDarkColor();
color.set(v.r, v.g, v.b, v.a); color.set(v.r, v.g, v.b, v.a);
} }
bool SpineSlotData::has_dark_color() { bool SpineSlotData::has_dark_color() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->hasDarkColor(); return get_spine_object()->hasDarkColor();
} }
void SpineSlotData::set_has_dark_color(bool v) { void SpineSlotData::set_has_dark_color(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setHasDarkColor(v); get_spine_object()->setHasDarkColor(v);
} }
String SpineSlotData::get_attachment_name() { String SpineSlotData::get_attachment_name() {
SPINE_CHECK(spine_object, "") SPINE_CHECK(get_spine_object(), "")
return spine_object->getAttachmentName().buffer(); return get_spine_object()->getAttachmentName().buffer();
} }
void SpineSlotData::set_attachment_name(const String &v) { void SpineSlotData::set_attachment_name(const String &v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAttachmentName(SPINE_STRING(v)); get_spine_object()->setAttachmentName(SPINE_STRING(v));
} }
SpineConstant::BlendMode SpineSlotData::get_blend_mode() { SpineConstant::BlendMode SpineSlotData::get_blend_mode() {
SPINE_CHECK(spine_object, SpineConstant::BlendMode_Normal) SPINE_CHECK(get_spine_object(), SpineConstant::BlendMode_Normal)
return (SpineConstant::BlendMode)spine_object->getBlendMode(); return (SpineConstant::BlendMode)get_spine_object()->getBlendMode();
} }
void SpineSlotData::set_blend_mode(SpineConstant::BlendMode v) { void SpineSlotData::set_blend_mode(SpineConstant::BlendMode v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setBlendMode((spine::BlendMode) v); get_spine_object()->setBlendMode((spine::BlendMode) v);
} }

View File

@ -36,7 +36,7 @@
class SpineSkeletonDataResource; class SpineSkeletonDataResource;
class SpineSlotData : public SpineObjectWrapper<SpineSkeletonDataResource, spine::SlotData> { class SpineSlotData : public SpineSkeletonDataResourceOwnedObject<spine::SlotData> {
GDCLASS(SpineSlotData, SpineObjectWrapper) GDCLASS(SpineSlotData, SpineObjectWrapper)
protected: protected:

View File

@ -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_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("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("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::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"); 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(); skeleton.unref();
animation_state.unref(); animation_state.unref();
emit_signal("_internal_spine_objects_invalidated");
if (skeleton_data_res.is_valid()) { if (skeleton_data_res.is_valid()) {
#if VERSION_MAJOR > 3 #if VERSION_MAJOR > 3
if (!skeleton_data_res->is_connected("skeleton_data_changed", callable_mp(this, &SpineSprite::on_skeleton_data_changed))) if (!skeleton_data_res->is_connected("skeleton_data_changed", callable_mp(this, &SpineSprite::on_skeleton_data_changed)))

View File

@ -46,30 +46,30 @@ void SpineTimeline::_bind_methods() {
void SpineTimeline::apply(Ref<SpineSkeleton> skeleton, float last_time, float time, Array events, float alpha, void SpineTimeline::apply(Ref<SpineSkeleton> skeleton, float last_time, float time, Array events, float alpha,
SpineConstant::MixBlend blend, SpineConstant::MixDirection direction) { SpineConstant::MixBlend blend, SpineConstant::MixDirection direction) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
if (!skeleton->get_spine_object()) return; if (!skeleton->get_spine_object()) return;
spine::Vector<spine::Event *> spine_events; spine::Vector<spine::Event *> spine_events;
spine_events.setSize((int)events.size(), nullptr); spine_events.setSize((int)events.size(), nullptr);
for (int i = 0; i < events.size(); ++i) { for (int i = 0; i < events.size(); ++i) {
events[i] = ((Ref<SpineEvent>) spine_events[i])->get_spine_object(); 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() { int SpineTimeline::get_frame_entries() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return (int)spine_object->getFrameEntries(); return (int)get_spine_object()->getFrameEntries();
} }
int SpineTimeline::get_frame_count() { int SpineTimeline::get_frame_count() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return (int)spine_object->getFrameCount(); return (int)get_spine_object()->getFrameCount();
} }
Array SpineTimeline::get_frames() { Array SpineTimeline::get_frames() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto &frames = spine_object->getFrames(); auto &frames = get_spine_object()->getFrames();
result.resize((int)frames.size()); result.resize((int)frames.size());
for (int i = 0; i < result.size(); ++i) { for (int i = 0; i < result.size(); ++i) {
result[i] = frames[i]; result[i] = frames[i];
@ -78,14 +78,14 @@ Array SpineTimeline::get_frames() {
} }
float SpineTimeline::get_duration() { float SpineTimeline::get_duration() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getDuration(); return get_spine_object()->getDuration();
} }
Array SpineTimeline::get_property_ids() { Array SpineTimeline::get_property_ids() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto &ids = spine_object->getPropertyIds(); auto &ids = get_spine_object()->getPropertyIds();
result.resize((int)ids.size()); result.resize((int)ids.size());
for (int i = 0; i < result.size(); ++i) { for (int i = 0; i < result.size(); ++i) {
result[i] = (spine::PropertyId) ids[i]; result[i] = (spine::PropertyId) ids[i];
@ -94,6 +94,6 @@ Array SpineTimeline::get_property_ids() {
} }
String SpineTimeline::get_type() { String SpineTimeline::get_type() {
SPINE_CHECK(spine_object, "") SPINE_CHECK(get_spine_object(), "")
return spine_object->getRTTI().getClassName(); return get_spine_object()->getRTTI().getClassName();
} }

View File

@ -39,7 +39,7 @@
class SpineSkeleton; class SpineSkeleton;
class SpineEvent; class SpineEvent;
class SpineTimeline : public SpineObjectWrapper<SpineSkeletonDataResource, spine::Timeline> { class SpineTimeline : public SpineSkeletonDataResourceOwnedObject<spine::Timeline> {
GDCLASS(SpineTimeline, SpineObjectWrapper) GDCLASS(SpineTimeline, SpineObjectWrapper)
protected: protected:

View File

@ -80,13 +80,13 @@ void SpineTrackEntry::_bind_methods() {
} }
int SpineTrackEntry::get_track_index() { int SpineTrackEntry::get_track_index() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getTrackIndex(); return get_spine_object()->getTrackIndex();
} }
Ref<SpineAnimation> SpineTrackEntry::get_animation() { Ref<SpineAnimation> SpineTrackEntry::get_animation() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto animation = spine_object->getAnimation(); auto animation = get_spine_object()->getAnimation();
if (!animation) return nullptr; if (!animation) return nullptr;
Ref<SpineAnimation> animation_ref(memnew(SpineAnimation)); Ref<SpineAnimation> animation_ref(memnew(SpineAnimation));
animation_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), animation); 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() { Ref<SpineTrackEntry> SpineTrackEntry::get_previous() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto previous = spine_object->getPrevious(); auto previous = get_spine_object()->getPrevious();
if (!previous) return nullptr; if (!previous) return nullptr;
Ref<SpineTrackEntry> previous_ref(memnew(SpineTrackEntry)); Ref<SpineTrackEntry> previous_ref(memnew(SpineTrackEntry));
previous_ref->set_spine_object(get_spine_owner(), previous); previous_ref->set_spine_object(get_spine_owner(), previous);
@ -103,163 +103,163 @@ Ref<SpineTrackEntry> SpineTrackEntry::get_previous() {
} }
bool SpineTrackEntry::get_loop() { bool SpineTrackEntry::get_loop() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->getLoop(); return get_spine_object()->getLoop();
} }
void SpineTrackEntry::set_loop(bool v) { void SpineTrackEntry::set_loop(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setLoop(v); get_spine_object()->setLoop(v);
} }
bool SpineTrackEntry::get_hold_previous() { bool SpineTrackEntry::get_hold_previous() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->getHoldPrevious(); return get_spine_object()->getHoldPrevious();
} }
void SpineTrackEntry::set_hold_previous(bool v) { void SpineTrackEntry::set_hold_previous(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setHoldPrevious(v); get_spine_object()->setHoldPrevious(v);
} }
bool SpineTrackEntry::get_reverse() { bool SpineTrackEntry::get_reverse() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->getReverse(); return get_spine_object()->getReverse();
} }
void SpineTrackEntry::set_reverse(bool v) { void SpineTrackEntry::set_reverse(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setReverse(v); get_spine_object()->setReverse(v);
} }
bool SpineTrackEntry::get_shortest_rotation() { bool SpineTrackEntry::get_shortest_rotation() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->getShortestRotation(); return get_spine_object()->getShortestRotation();
} }
void SpineTrackEntry::set_shortest_rotation(bool v) { void SpineTrackEntry::set_shortest_rotation(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setShortestRotation(v); get_spine_object()->setShortestRotation(v);
} }
float SpineTrackEntry::get_delay() { float SpineTrackEntry::get_delay() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getDelay(); return get_spine_object()->getDelay();
} }
void SpineTrackEntry::set_delay(float v) { void SpineTrackEntry::set_delay(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setDelay(v); get_spine_object()->setDelay(v);
} }
float SpineTrackEntry::get_track_time() { float SpineTrackEntry::get_track_time() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getTrackTime(); return get_spine_object()->getTrackTime();
} }
void SpineTrackEntry::set_track_time(float v) { void SpineTrackEntry::set_track_time(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setTrackTime(v); get_spine_object()->setTrackTime(v);
} }
float SpineTrackEntry::get_track_end() { float SpineTrackEntry::get_track_end() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getTrackEnd(); return get_spine_object()->getTrackEnd();
} }
void SpineTrackEntry::set_track_end(float v) { void SpineTrackEntry::set_track_end(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setTrackEnd(v); get_spine_object()->setTrackEnd(v);
} }
float SpineTrackEntry::get_animation_start() { float SpineTrackEntry::get_animation_start() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAnimationStart(); return get_spine_object()->getAnimationStart();
} }
void SpineTrackEntry::set_animation_start(float v) { void SpineTrackEntry::set_animation_start(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAnimationStart(v); get_spine_object()->setAnimationStart(v);
} }
float SpineTrackEntry::get_animation_end() { float SpineTrackEntry::get_animation_end() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAnimationEnd(); return get_spine_object()->getAnimationEnd();
} }
void SpineTrackEntry::set_animation_end(float v) { void SpineTrackEntry::set_animation_end(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAnimationEnd(v); get_spine_object()->setAnimationEnd(v);
} }
float SpineTrackEntry::get_animation_last() { float SpineTrackEntry::get_animation_last() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAnimationLast(); return get_spine_object()->getAnimationLast();
} }
void SpineTrackEntry::set_animation_last(float v) { void SpineTrackEntry::set_animation_last(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAnimationLast(v); get_spine_object()->setAnimationLast(v);
} }
float SpineTrackEntry::get_animation_time() { float SpineTrackEntry::get_animation_time() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAnimationTime(); return get_spine_object()->getAnimationTime();
} }
float SpineTrackEntry::get_time_scale() { float SpineTrackEntry::get_time_scale() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getTimeScale(); return get_spine_object()->getTimeScale();
} }
void SpineTrackEntry::set_time_scale(float v) { void SpineTrackEntry::set_time_scale(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setTimeScale(v); get_spine_object()->setTimeScale(v);
} }
float SpineTrackEntry::get_alpha() { float SpineTrackEntry::get_alpha() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAlpha(); return get_spine_object()->getAlpha();
} }
void SpineTrackEntry::set_alpha(float v) { void SpineTrackEntry::set_alpha(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAlpha(v); get_spine_object()->setAlpha(v);
} }
float SpineTrackEntry::get_event_threshold() { float SpineTrackEntry::get_event_threshold() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getEventThreshold(); return get_spine_object()->getEventThreshold();
} }
void SpineTrackEntry::set_event_threshold(float v) { void SpineTrackEntry::set_event_threshold(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setEventThreshold(v); get_spine_object()->setEventThreshold(v);
} }
float SpineTrackEntry::get_attachment_threshold() { float SpineTrackEntry::get_attachment_threshold() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getAttachmentThreshold(); return get_spine_object()->getAttachmentThreshold();
} }
void SpineTrackEntry::set_attachment_threshold(float v) { void SpineTrackEntry::set_attachment_threshold(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setAttachmentThreshold(v); get_spine_object()->setAttachmentThreshold(v);
} }
float SpineTrackEntry::get_draw_order_threshold() { float SpineTrackEntry::get_draw_order_threshold() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getDrawOrderThreshold(); return get_spine_object()->getDrawOrderThreshold();
} }
void SpineTrackEntry::set_draw_order_threshold(float v) { void SpineTrackEntry::set_draw_order_threshold(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setDrawOrderThreshold(v); get_spine_object()->setDrawOrderThreshold(v);
} }
Ref<SpineTrackEntry> SpineTrackEntry::get_next() { Ref<SpineTrackEntry> SpineTrackEntry::get_next() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto next = spine_object->getNext(); auto next = get_spine_object()->getNext();
if (!next) return nullptr; if (!next) return nullptr;
Ref<SpineTrackEntry> next_ref(memnew(SpineTrackEntry)); Ref<SpineTrackEntry> next_ref(memnew(SpineTrackEntry));
next_ref->set_spine_object(get_spine_owner(), next); next_ref->set_spine_object(get_spine_owner(), next);
@ -267,43 +267,43 @@ Ref<SpineTrackEntry> SpineTrackEntry::get_next() {
} }
bool SpineTrackEntry::is_complete() { bool SpineTrackEntry::is_complete() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->isComplete(); return get_spine_object()->isComplete();
} }
float SpineTrackEntry::get_mix_time() { float SpineTrackEntry::get_mix_time() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMixTime(); return get_spine_object()->getMixTime();
} }
void SpineTrackEntry::set_mix_time(float v) { void SpineTrackEntry::set_mix_time(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixTime(v); get_spine_object()->setMixTime(v);
} }
float SpineTrackEntry::get_mix_duration() { float SpineTrackEntry::get_mix_duration() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMixDuration(); return get_spine_object()->getMixDuration();
} }
void SpineTrackEntry::set_mix_duration(float v) { void SpineTrackEntry::set_mix_duration(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixDuration(v); get_spine_object()->setMixDuration(v);
} }
SpineConstant::MixBlend SpineTrackEntry::get_mix_blend() { SpineConstant::MixBlend SpineTrackEntry::get_mix_blend() {
SPINE_CHECK(spine_object, SpineConstant::MixBlend_Setup) SPINE_CHECK(get_spine_object(), SpineConstant::MixBlend_Setup)
return (SpineConstant::MixBlend)spine_object->getMixBlend(); return (SpineConstant::MixBlend)get_spine_object()->getMixBlend();
} }
void SpineTrackEntry::set_mix_blend(SpineConstant::MixBlend v) { void SpineTrackEntry::set_mix_blend(SpineConstant::MixBlend v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixBlend((spine::MixBlend) v); get_spine_object()->setMixBlend((spine::MixBlend) v);
} }
Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_from() { Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_from() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto mixing_from = spine_object->getMixingFrom(); auto mixing_from = get_spine_object()->getMixingFrom();
if (!mixing_from) return nullptr; if (!mixing_from) return nullptr;
Ref<SpineTrackEntry> mixing_from_ref(memnew(SpineTrackEntry)); Ref<SpineTrackEntry> mixing_from_ref(memnew(SpineTrackEntry));
mixing_from_ref->set_spine_object(get_spine_owner(), mixing_from); 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() { Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_to() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto mixing_to = spine_object->getMixingTo(); auto mixing_to = get_spine_object()->getMixingTo();
if (!mixing_to) return nullptr; if (!mixing_to) return nullptr;
Ref<SpineTrackEntry> mixing_to_ref(memnew(SpineTrackEntry)); Ref<SpineTrackEntry> mixing_to_ref(memnew(SpineTrackEntry));
mixing_to_ref->set_spine_object(get_spine_owner(), mixing_to); 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() { void SpineTrackEntry::reset_rotation_directions() {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->resetRotationDirections(); get_spine_object()->resetRotationDirections();
} }
float SpineTrackEntry::get_track_complete() { float SpineTrackEntry::get_track_complete() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getTrackComplete(); return get_spine_object()->getTrackComplete();
} }

View File

@ -37,7 +37,7 @@
#include "SpineSprite.h" #include "SpineSprite.h"
class SpineTrackEntry : public SpineObjectWrapper<SpineSprite, spine::TrackEntry> { class SpineTrackEntry : public SpineSpriteOwnedObject<spine::TrackEntry> {
GDCLASS(SpineTrackEntry, SpineObjectWrapper); GDCLASS(SpineTrackEntry, SpineObjectWrapper);
protected: protected:

View File

@ -54,18 +54,18 @@ void SpineTransformConstraint::_bind_methods() {
} }
void SpineTransformConstraint::update() { void SpineTransformConstraint::update() {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->update(); get_spine_object()->update();
} }
int SpineTransformConstraint::get_order() { int SpineTransformConstraint::get_order() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getOrder(); return get_spine_object()->getOrder();
} }
Ref<SpineTransformConstraintData> SpineTransformConstraint::get_data() { Ref<SpineTransformConstraintData> SpineTransformConstraint::get_data() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto &data = spine_object->getData(); auto &data = get_spine_object()->getData();
Ref<SpineTransformConstraintData> data_ref(memnew(SpineTransformConstraintData)); Ref<SpineTransformConstraintData> data_ref(memnew(SpineTransformConstraintData));
data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &data); data_ref->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), &data);
return data_ref; return data_ref;
@ -73,8 +73,8 @@ Ref<SpineTransformConstraintData> SpineTransformConstraint::get_data() {
Array SpineTransformConstraint::get_bones() { Array SpineTransformConstraint::get_bones() {
Array result; Array result;
SPINE_CHECK(spine_object, result) SPINE_CHECK(get_spine_object(), result)
auto &bones = spine_object->getBones(); auto &bones = get_spine_object()->getBones();
result.resize((int)bones.size()); result.resize((int)bones.size());
for (int i = 0; i < bones.size(); ++i) { for (int i = 0; i < bones.size(); ++i) {
auto bone = bones[i]; auto bone = bones[i];
@ -86,8 +86,8 @@ Array SpineTransformConstraint::get_bones() {
} }
Ref<SpineBone> SpineTransformConstraint::get_target() { Ref<SpineBone> SpineTransformConstraint::get_target() {
SPINE_CHECK(spine_object, nullptr) SPINE_CHECK(get_spine_object(), nullptr)
auto target = spine_object->getTarget(); auto target = get_spine_object()->getTarget();
if (!target) return nullptr; if (!target) return nullptr;
Ref<SpineBone> target_ref(memnew(SpineBone)); Ref<SpineBone> target_ref(memnew(SpineBone));
target_ref->set_spine_object(get_spine_owner(), target); 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) { void SpineTransformConstraint::set_target(Ref<SpineBone> v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr); get_spine_object()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
} }
float SpineTransformConstraint::get_mix_rotate() { float SpineTransformConstraint::get_mix_rotate() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMixRotate(); return get_spine_object()->getMixRotate();
} }
void SpineTransformConstraint::set_mix_rotate(float v) { void SpineTransformConstraint::set_mix_rotate(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixRotate(v); get_spine_object()->setMixRotate(v);
} }
float SpineTransformConstraint::get_mix_x() { float SpineTransformConstraint::get_mix_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMixX(); return get_spine_object()->getMixX();
} }
void SpineTransformConstraint::set_mix_x(float v) { void SpineTransformConstraint::set_mix_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixX(v); get_spine_object()->setMixX(v);
} }
float SpineTransformConstraint::get_mix_y() { float SpineTransformConstraint::get_mix_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMixY(); return get_spine_object()->getMixY();
} }
void SpineTransformConstraint::set_mix_y(float v) { void SpineTransformConstraint::set_mix_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixY(v); get_spine_object()->setMixY(v);
} }
float SpineTransformConstraint::get_mix_scale_x() { float SpineTransformConstraint::get_mix_scale_x() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMixScaleX(); return get_spine_object()->getMixScaleX();
} }
void SpineTransformConstraint::set_mix_scale_x(float v) { void SpineTransformConstraint::set_mix_scale_x(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixScaleX(v); get_spine_object()->setMixScaleX(v);
} }
float SpineTransformConstraint::get_mix_scale_y() { float SpineTransformConstraint::get_mix_scale_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMixScaleY(); return get_spine_object()->getMixScaleY();
} }
void SpineTransformConstraint::set_mix_scale_y(float v) { void SpineTransformConstraint::set_mix_scale_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixScaleY(v); get_spine_object()->setMixScaleY(v);
} }
float SpineTransformConstraint::get_mix_shear_y() { float SpineTransformConstraint::get_mix_shear_y() {
SPINE_CHECK(spine_object, 0) SPINE_CHECK(get_spine_object(), 0)
return spine_object->getMixShearY(); return get_spine_object()->getMixShearY();
} }
void SpineTransformConstraint::set_mix_shear_y(float v) { void SpineTransformConstraint::set_mix_shear_y(float v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setMixShearY(v); get_spine_object()->setMixShearY(v);
} }
bool SpineTransformConstraint::is_active() { bool SpineTransformConstraint::is_active() {
SPINE_CHECK(spine_object, false) SPINE_CHECK(get_spine_object(), false)
return spine_object->isActive(); return get_spine_object()->isActive();
} }
void SpineTransformConstraint::set_active(bool v) { void SpineTransformConstraint::set_active(bool v) {
SPINE_CHECK(spine_object,) SPINE_CHECK(get_spine_object(),)
spine_object->setActive(v); get_spine_object()->setActive(v);
} }

View File

@ -35,7 +35,7 @@
#include "SpineBone.h" #include "SpineBone.h"
#include <spine/TransformConstraint.h> #include <spine/TransformConstraint.h>
class SpineTransformConstraint : public SpineObjectWrapper<SpineSprite, spine::TransformConstraint> { class SpineTransformConstraint : public SpineSpriteOwnedObject<spine::TransformConstraint> {
GDCLASS(SpineTransformConstraint, SpineObjectWrapper) GDCLASS(SpineTransformConstraint, SpineObjectWrapper)
protected: protected: