[godot] Fix up formatter.

This commit is contained in:
Mario Zechner 2022-05-31 12:29:25 +02:00
parent 934034fce4
commit 4239af0a1a
39 changed files with 635 additions and 609 deletions

View File

@ -26,8 +26,8 @@ spotless {
'spine-sfml/**/*.h',
'spine-ue4/**/*.cpp',
'spine-ue4/**/*.h',
'spine-godot/godot/modules/spine_godot/*.cpp',
'spine-godot/godot/modules/spine_godot/*.h'
'spine-godot/spine_godot/*.cpp',
'spine-godot/spine_godot/*.h'
clangFormat("13.0.1").pathToExe("$System.env.CLANGFORMAT").style('file')
}

View File

@ -455,25 +455,25 @@ Skin *SkeletonBinary::readSkin(DataInput *input, bool defaultSkin, SkeletonData
skin = new (__FILE__, __LINE__) Skin(readStringRef(input, skeletonData));
for (int i = 0, n = readVarint(input, true); i < n; i++) {
int boneIndex = readVarint(input, true);
if (boneIndex >= (int)skeletonData->_bones.size()) return NULL;
if (boneIndex >= (int) skeletonData->_bones.size()) return NULL;
skin->getBones().add(skeletonData->_bones[boneIndex]);
}
for (int i = 0, n = readVarint(input, true); i < n; i++) {
int ikIndex = readVarint(input, true);
if (ikIndex >= (int)skeletonData->_ikConstraints.size()) return NULL;
if (ikIndex >= (int) skeletonData->_ikConstraints.size()) return NULL;
skin->getConstraints().add(skeletonData->_ikConstraints[ikIndex]);
}
for (int i = 0, n = readVarint(input, true); i < n; i++) {
int transformIndex = readVarint(input, true);
if (transformIndex >= (int)skeletonData->_transformConstraints.size()) return NULL;
if (transformIndex >= (int) skeletonData->_transformConstraints.size()) return NULL;
skin->getConstraints().add(skeletonData->_transformConstraints[transformIndex]);
}
for (int i = 0, n = readVarint(input, true); i < n; i++) {
int pathIndex = readVarint(input, true);
if (pathIndex >= (int)skeletonData->_pathConstraints.size()) return NULL;
if (pathIndex >= (int) skeletonData->_pathConstraints.size()) return NULL;
skin->getConstraints().add(skeletonData->_pathConstraints[pathIndex]);
}
slotCount = readVarint(input, true);

View File

@ -56,17 +56,17 @@ float SpineAnimation::get_duration() {
}
void SpineAnimation::set_duration(float duration) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setDuration(duration);
}
void SpineAnimation::apply(Ref<SpineSkeleton> skeleton, float last_time, float time, bool loop,
Array events, float alpha, SpineConstant::MixBlend blend,
SpineConstant::MixDirection direction) {
SPINE_CHECK(get_spine_object(),)
Array events, float alpha, SpineConstant::MixBlend blend,
SpineConstant::MixDirection direction) {
SPINE_CHECK(get_spine_object(), )
spine::Vector<spine::Event *> spineEvents;
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);
event_ref->set_spine_object(skeleton->get_spine_owner(), spineEvents[i]);
events.append(event_ref);
@ -77,9 +77,9 @@ Array SpineAnimation::get_timelines() {
Array result;
SPINE_CHECK(get_spine_object(), result)
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) {
auto timeline_ref = Ref<SpineTimeline>(memnew(SpineTimeline));
timeline_ref->set_spine_object(get_spine_owner(), timelines[i]);
result.set(i, timeline_ref);
@ -92,7 +92,7 @@ bool SpineAnimation::has_timeline(Array ids) {
spine::Vector<spine::PropertyId> property_ids;
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];
}
return get_spine_object()->hasTimeline(property_ids);

View File

@ -63,7 +63,7 @@ void SpineAnimationState::set_spine_sprite(SpineSprite *_sprite) {
}
void SpineAnimationState::update(float delta) {
SPINE_CHECK(animation_state,)
SPINE_CHECK(animation_state, )
animation_state->update(delta);
}
@ -74,12 +74,12 @@ bool SpineAnimationState::apply(Ref<SpineSkeleton> skeleton) {
}
void SpineAnimationState::clear_tracks() {
SPINE_CHECK(animation_state,)
SPINE_CHECK(animation_state, )
animation_state->clearTracks();
}
void SpineAnimationState::clear_track(int track_id) {
SPINE_CHECK(animation_state,)
SPINE_CHECK(animation_state, )
animation_state->clearTrack(track_id);
}
@ -126,7 +126,7 @@ Ref<SpineTrackEntry> SpineAnimationState::add_empty_animation(int track_id, floa
return track_entry_ref;
}
void SpineAnimationState::set_empty_animations(float mix_duration) {
SPINE_CHECK(animation_state,)
SPINE_CHECK(animation_state, )
animation_state->setEmptyAnimations(mix_duration);
}
@ -145,16 +145,16 @@ float SpineAnimationState::get_time_scale() {
}
void SpineAnimationState::set_time_scale(float time_scale) {
SPINE_CHECK(animation_state,)
SPINE_CHECK(animation_state, )
animation_state->setTimeScale(time_scale);
}
void SpineAnimationState::disable_queue() {
SPINE_CHECK(animation_state,)
SPINE_CHECK(animation_state, )
animation_state->disableQueue();
}
void SpineAnimationState::enable_queue() {
SPINE_CHECK(animation_state,)
SPINE_CHECK(animation_state, )
animation_state->enableQueue();
}

View File

@ -17,7 +17,7 @@ void SpineAnimationTrack::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_animation_name"), &SpineAnimationTrack::get_animation_name);
ClassDB::bind_method(D_METHOD("set_loop", "loop"), &SpineAnimationTrack::set_loop);
ClassDB::bind_method(D_METHOD("get_loop"), &SpineAnimationTrack::get_loop);
ClassDB::bind_method(D_METHOD("set_track_index", "track_index"), &SpineAnimationTrack::set_track_index);
ClassDB::bind_method(D_METHOD("get_track_index"), &SpineAnimationTrack::get_track_index);
ClassDB::bind_method(D_METHOD("set_mix_duration", "mix_duration"), &SpineAnimationTrack::set_mix_duration);
@ -40,12 +40,12 @@ void SpineAnimationTrack::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_mix_blend"), &SpineAnimationTrack::get_mix_blend);
ClassDB::bind_method(D_METHOD("set_debug", "debug"), &SpineAnimationTrack::set_debug);
ClassDB::bind_method(D_METHOD("get_debug"), &SpineAnimationTrack::get_debug);
ClassDB::bind_method(D_METHOD("update_animation_state", "spine_sprite"), &SpineAnimationTrack::update_animation_state);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_NOEDITOR), "set_animation_name", "get_animation_name");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_NOEDITOR), "set_loop", "get_loop");
ADD_PROPERTY(PropertyInfo(Variant::INT, "track_index", PROPERTY_HINT_RANGE, "0,256,0"), "set_track_index", "get_track_index");
ADD_PROPERTY(PropertyInfo(VARIANT_FLOAT, "mix_duration"), "set_mix_duration", "get_mix_duration");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hold_previous"), "set_hold_previous", "get_hold_previous");
@ -59,40 +59,39 @@ void SpineAnimationTrack::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug"), "set_debug", "get_debug");
}
SpineAnimationTrack::SpineAnimationTrack():
loop(false),
track_index(-1),
mix_duration(-1),
hold_previous(false),
reverse(false),
shortest_rotation(false),
time_scale(1),
alpha(1),
attachment_threshold(0),
draw_order_threshold(0),
mix_blend(SpineConstant::MixBlend_Replace),
debug(false),
sprite(nullptr) {
SpineAnimationTrack::SpineAnimationTrack() : loop(false),
track_index(-1),
mix_duration(-1),
hold_previous(false),
reverse(false),
shortest_rotation(false),
time_scale(1),
alpha(1),
attachment_threshold(0),
draw_order_threshold(0),
mix_blend(SpineConstant::MixBlend_Replace),
debug(false),
sprite(nullptr) {
}
void SpineAnimationTrack::_notification(int what) {
switch(what) {
case NOTIFICATION_PARENTED: {
switch (what) {
case NOTIFICATION_PARENTED: {
sprite = Object::cast_to<SpineSprite>(get_parent());
if (sprite)
#if VERSION_MAJOR > 3
sprite->connect("before_animation_state_update", callable_mp(this, &SpineAnimationTrack::update_animation_state));
sprite->connect("before_animation_state_update", callable_mp(this, &SpineAnimationTrack::update_animation_state));
#else
sprite->connect("before_animation_state_update", this, "update_animation_state");
#endif
NOTIFY_PROPERTY_LIST_CHANGED();
break;
}
case NOTIFICATION_READY: {
}
case NOTIFICATION_READY: {
setup_animation_player();
break;
}
case NOTIFICATION_UNPARENTED: {
}
case NOTIFICATION_UNPARENTED: {
if (sprite) {
#if VERSION_MAJOR > 3
sprite->disconnect("before_animation_state_update", callable_mp(this, &SpineAnimationTrack::update_animation_state));
@ -102,13 +101,13 @@ void SpineAnimationTrack::_notification(int what) {
sprite = nullptr;
}
break;
}
default:
break;
}
default:
break;
}
}
AnimationPlayer* SpineAnimationTrack::find_animation_player() {
AnimationPlayer *SpineAnimationTrack::find_animation_player() {
AnimationPlayer *animation_player = nullptr;
for (int i = 0; i < get_child_count(); i++) {
animation_player = cast_to<AnimationPlayer>(get_child(i));
@ -132,7 +131,7 @@ void SpineAnimationTrack::setup_animation_player() {
for (int i = 0; i < sprite->get_child_count(); i++) {
auto other_track = cast_to<SpineAnimationTrack>(sprite->get_child(i));
if (other_track) {
if (other_track->track_index > highest_track_number)
if (other_track->track_index > highest_track_number)
highest_track_number = other_track->track_index;
}
}
@ -161,7 +160,7 @@ void SpineAnimationTrack::setup_animation_player() {
}
#endif
}
auto skeleton_data = sprite->get_skeleton_data_res()->get_skeleton_data();
auto &animations = skeleton_data->getAnimations();
#if VERSION_MAJOR > 3
@ -169,7 +168,7 @@ void SpineAnimationTrack::setup_animation_player() {
animation_library.instantiate();
animation_player->add_animation_library("", animation_library);
#endif
for (int i = 0; i < (int)animations.size(); i++) {
for (int i = 0; i < (int) animations.size(); i++) {
auto &animation = animations[i];
Ref<Animation> animation_ref = create_animation(animation, false);
Ref<Animation> animation_looped_ref = create_animation(animation, true);
@ -181,9 +180,9 @@ void SpineAnimationTrack::setup_animation_player() {
animation_player->add_animation(animation_looped_ref->get_name(), animation_looped_ref);
#endif
}
Ref<Animation> reset_animation_ref;
INSTANTIATE(reset_animation_ref);
INSTANTIATE(reset_animation_ref);
reset_animation_ref->set_name("RESET");
#if VERSION_MAJOR > 3
// reset_animation_ref->set_loop(true);
@ -192,10 +191,10 @@ void SpineAnimationTrack::setup_animation_player() {
#endif
reset_animation_ref->set_length(0.5f);
reset_animation_ref->add_track(Animation::TYPE_VALUE);
reset_animation_ref->track_set_path(0, NodePath(".:animation_name"));
reset_animation_ref->track_set_path(0, NodePath(".:animation_name"));
reset_animation_ref->track_insert_key(0, 0, "");
reset_animation_ref->add_track(Animation::TYPE_VALUE);
reset_animation_ref->track_set_path(1, NodePath(".:loop"));
reset_animation_ref->track_set_path(1, NodePath(".:loop"));
reset_animation_ref->track_insert_key(1, 0, false);
#if VERSION_MAJOR > 3
animation_library->add_animation(reset_animation_ref->get_name(), reset_animation_ref);
@ -209,9 +208,9 @@ void SpineAnimationTrack::setup_animation_player() {
Ref<Animation> SpineAnimationTrack::create_animation(spine::Animation *animation, bool loop) {
float duration = animation->getDuration();
if (duration == 0) duration = 0.5;
Ref<Animation> animation_ref;
INSTANTIATE(animation_ref);
INSTANTIATE(animation_ref);
animation_ref->set_name(String(animation->getName().buffer()) + (loop ? "" : "_looped"));
#if VERSION_MAJOR > 3
// animation_ref->set_loop(!loop);
@ -221,9 +220,9 @@ Ref<Animation> SpineAnimationTrack::create_animation(spine::Animation *animation
animation_ref->set_length(duration);
animation_ref->add_track(Animation::TYPE_VALUE);
animation_ref->track_set_path(0, NodePath(".:animation_name"));
animation_ref->track_set_path(0, NodePath(".:animation_name"));
animation_ref->track_insert_key(0, 0, animation->getName().buffer());
animation_ref->add_track(Animation::TYPE_VALUE);
animation_ref->track_set_path(1, NodePath(".:loop"));
animation_ref->track_insert_key(1, 0, !loop);
@ -246,7 +245,7 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
if (Engine::get_singleton()->is_editor_hint()) {
#ifdef TOOLS_ENABLED
// When the animation dock is no longer visible or we aren't being
// When the animation dock is no longer visible or we aren't being
// keyed in the current animation, bail.
#if VERSION_MAJOR > 3
auto player_editor = AnimationPlayerEditor::get_singleton();
@ -259,7 +258,7 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
animation_state->setTimeScale(1);
return;
}
// Check if the player is actually editing an animation for which there is a track
// for us.
Ref<Animation> edited_animation = player_editor->get_track_editor()->get_current_animation();
@ -269,7 +268,7 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
animation_state->setTimeScale(1);
return;
}
int found_track_index = -1;
auto scene_path = EditorNode::get_singleton()->get_edited_scene()->get_path();
auto animation_player_path = scene_path.rel_path_to(animation_player->get_path());
@ -279,9 +278,9 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
if (path == animation_player_path) {
found_track_index = i;
break;
}
}
}
// if we are track 0, set the skeleton to the setup pose
// and the animation state time scale to 0, as we are
// setting track times manually. Also, kill anything
@ -295,10 +294,10 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
// If no animation is set or it's set to "[stop]", we are done.
if (EMPTY(animation_name) || animation_name == "[stop]") return;
// If there's no keys on the timeline for this track, we are done.
if (edited_animation->track_get_key_count(found_track_index) == 0) return;
// Find the key in the track that matches the editor's playback position
auto playback_position = player_editor->get_player()->get_current_animation_position();
int key_index = -1;
@ -338,7 +337,7 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
entry->setAlpha(alpha);
entry->setAttachmentThreshold(attachment_threshold);
entry->setDrawOrderThreshold(draw_order_threshold);
entry->setMixBlend((spine::MixBlend)mix_blend);
entry->setMixBlend((spine::MixBlend) mix_blend);
#endif
} else {
if (animation_player->is_playing()) {
@ -358,14 +357,14 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
entry->setAlpha(alpha);
entry->setAttachmentThreshold(attachment_threshold);
entry->setDrawOrderThreshold(draw_order_threshold);
entry->setMixBlend((spine::MixBlend)mix_blend);
entry->setMixBlend((spine::MixBlend) mix_blend);
if (debug) print_line(String("Setting animation {0} with mix_duration {1} on track {2} on {3}").format(varray(animation_name, mix_duration, track_index, sprite->get_name())).utf8().ptr());
} else {
if (!current_entry || (String("<empty>") != current_entry->getAnimation()->getName().buffer())) {
auto entry = animation_state->setEmptyAnimation(track_index, should_set_mix ? mix_duration : 0);
entry->setTrackEnd(FLT_MAX);
if (debug) print_line(String("Setting empty animation with mix_duration {0} on track {1} on {2}").format(varray(mix_duration, track_index, sprite->get_name())).utf8().ptr());
if (debug) print_line(String("Setting empty animation with mix_duration {0} on track {1} on {2}").format(varray(mix_duration, track_index, sprite->get_name())).utf8().ptr());
}
}
}
@ -373,7 +372,7 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
}
}
void SpineAnimationTrack::set_animation_name(const String& _animation_name) {
void SpineAnimationTrack::set_animation_name(const String &_animation_name) {
animation_name = _animation_name;
}

View File

@ -58,34 +58,34 @@ protected:
SpineSprite *sprite;
static void _bind_methods();
void _notification(int what);
AnimationPlayer *find_animation_player();
void setup_animation_player();
static Ref<Animation> create_animation(spine::Animation *animation, bool loop);
void update_animation_state(const Variant &variant_sprite);
public:
SpineAnimationTrack();
void set_animation_name(const String& _animation_name);
void set_animation_name(const String &_animation_name);
String get_animation_name();
void set_animation_time (float _animation_time);
void set_animation_time(float _animation_time);
float get_animation_time();
void set_loop(bool _loop);
bool get_loop();
void set_track_index(int _track_index);
int get_track_index();
void set_mix_duration(float _mix_duration);

View File

@ -65,9 +65,9 @@ public:
Error load_from_atlas_file(const String &path);// .atlas
Error load_from_file(const String &path); // .spatlas
Error load_from_file(const String &path);// .spatlas
Error save_to_file(const String &path); // .spatlas
Error save_to_file(const String &path);// .spatlas
String get_source_path();

View File

@ -99,12 +99,12 @@ void SpineBone::_bind_methods() {
}
void SpineBone::update_world_transform() {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->updateWorldTransform();
}
void SpineBone::set_to_setup_pose() {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setToSetupPose();
}
@ -133,7 +133,7 @@ float SpineBone::local_to_world_rotation(float local_rotation) {
}
void SpineBone::rotate_world(float degrees) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->rotateWorld(degrees);
}
@ -168,7 +168,7 @@ Array SpineBone::get_children() {
Array result;
SPINE_CHECK(get_spine_object(), result)
auto children = get_spine_object()->getChildren();
result.resize((int)children.size());
result.resize((int) children.size());
for (int i = 0; i < children.size(); ++i) {
auto child = children[i];
Ref<SpineBone> bone_ref(memnew(SpineBone));
@ -184,7 +184,7 @@ float SpineBone::get_x() {
}
void SpineBone::set_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setX(v);
}
@ -194,7 +194,7 @@ float SpineBone::get_y() {
}
void SpineBone::set_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setY(v);
}
@ -204,7 +204,7 @@ float SpineBone::get_rotation() {
}
void SpineBone::set_rotation(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setRotation(v);
}
@ -214,7 +214,7 @@ float SpineBone::get_scale_x() {
}
void SpineBone::set_scale_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setScaleX(v);
}
@ -224,7 +224,7 @@ float SpineBone::get_scale_y() {
}
void SpineBone::set_scale_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setScaleY(v);
}
@ -234,7 +234,7 @@ float SpineBone::get_shear_x() {
}
void SpineBone::set_shear_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setShearX(v);
}
@ -244,7 +244,7 @@ float SpineBone::get_shear_y() {
}
void SpineBone::set_shear_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setShearY(v);
}
@ -254,7 +254,7 @@ float SpineBone::get_applied_rotation() {
}
void SpineBone::set_applied_rotation(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAppliedRotation(v);
}
@ -264,7 +264,7 @@ float SpineBone::get_a_x() {
}
void SpineBone::set_a_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAX(v);
}
@ -274,7 +274,7 @@ float SpineBone::get_a_y() {
}
void SpineBone::set_a_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAY(v);
}
@ -284,7 +284,7 @@ float SpineBone::get_a_scale_x() {
}
void SpineBone::set_a_scale_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAScaleX(v);
}
@ -294,7 +294,7 @@ float SpineBone::get_a_scale_y() {
}
void SpineBone::set_a_scale_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAScaleY(v);
}
@ -304,7 +304,7 @@ float SpineBone::get_a_shear_x() {
}
void SpineBone::set_a_shear_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAShearX(v);
}
@ -314,7 +314,7 @@ float SpineBone::get_a_shear_y() {
}
void SpineBone::set_a_shear_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAShearY(v);
}
@ -324,7 +324,7 @@ float SpineBone::get_a() {
}
void SpineBone::set_a(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setA(v);
}
@ -334,7 +334,7 @@ float SpineBone::get_b() {
}
void SpineBone::set_b(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setB(v);
}
@ -344,7 +344,7 @@ float SpineBone::get_c() {
}
void SpineBone::set_c(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setC(v);
}
@ -354,7 +354,7 @@ float SpineBone::get_d() {
}
void SpineBone::set_d(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setD(v);
}
@ -364,7 +364,7 @@ float SpineBone::get_world_x() {
}
void SpineBone::set_world_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setWorldX(v);
}
@ -374,7 +374,7 @@ float SpineBone::get_world_y() {
}
void SpineBone::set_world_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setWorldY(v);
}
@ -404,16 +404,16 @@ bool SpineBone::is_active() {
return get_spine_object()->isActive();
}
void SpineBone::set_active(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setActive(v);
}
// External feature functions
void SpineBone::apply_world_transform_2d(const Variant &o) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
if (o.get_type() == Variant::OBJECT) {
auto node2d = Object::cast_to<Node2D>(o.operator Object*());
if (node2d) {
auto node2d = Object::cast_to<Node2D>(o.operator Object *());
if (node2d) {
// In godot the y-axis is nag to spine
node2d->set_transform(Transform2D(
get_a(), get_c(),
@ -438,7 +438,7 @@ Transform2D SpineBone::get_transform() {
}
void SpineBone::set_transform(Transform2D transform) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
Vector2 position = transform.get_origin();
float rotation = Math::rad2deg(transform.get_rotation());
Vector2 scale = transform.get_scale();
@ -464,12 +464,12 @@ Transform2D SpineBone::get_global_transform() {
}
void SpineBone::set_global_transform(Transform2D transform) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
if (!get_spine_owner()) set_transform(transform);
if (!get_spine_owner()->is_visible_in_tree()) return;
auto bone = get_spine_object();
Transform2D inverse_sprite_transform = get_spine_owner()->get_global_transform().affine_inverse();
transform = inverse_sprite_transform * transform;
Vector2 position = transform.get_origin();
@ -480,7 +480,7 @@ void SpineBone::set_global_transform(Transform2D transform) {
Vector2 local_scale = scale;
spine::Bone *parent = bone->getParent();
if (parent) {
parent->worldToLocal(local_position.x, local_position.y, local_position.x, local_position.y);
parent->worldToLocal(local_position.x, local_position.y, local_position.x, local_position.y);
}
bone->setX(local_position.x);
bone->setY(local_position.y);

View File

@ -83,7 +83,7 @@ float SpineBoneData::get_length() {
}
void SpineBoneData::set_length(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setLength(v);
}
@ -93,7 +93,7 @@ float SpineBoneData::get_x() {
}
void SpineBoneData::set_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setX(v);
}
@ -103,7 +103,7 @@ float SpineBoneData::get_y() {
}
void SpineBoneData::set_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setY(v);
}
@ -113,7 +113,7 @@ float SpineBoneData::get_rotation() {
}
void SpineBoneData::set_rotation(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setRotation(v);
}
@ -123,7 +123,7 @@ float SpineBoneData::get_scale_x() {
}
void SpineBoneData::set_scale_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setScaleX(v);
}
@ -133,7 +133,7 @@ float SpineBoneData::get_scale_y() {
}
void SpineBoneData::set_scale_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setScaleY(v);
}
@ -143,7 +143,7 @@ float SpineBoneData::get_shear_x() {
}
void SpineBoneData::set_shear_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setShearX(v);
}
@ -153,7 +153,7 @@ float SpineBoneData::get_shear_y() {
}
void SpineBoneData::set_shear_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setShearY(v);
}
@ -163,7 +163,7 @@ SpineConstant::TransformMode SpineBoneData::get_transform_mode() {
}
void SpineBoneData::set_transform_mode(SpineConstant::TransformMode v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setTransformMode((spine::TransformMode) v);
}
@ -173,7 +173,7 @@ bool SpineBoneData::is_skin_required() {
}
void SpineBoneData::set_skin_required(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setSkinRequired(v);
}
@ -184,6 +184,6 @@ Color SpineBoneData::get_color() {
}
void SpineBoneData::set_color(Color color) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->getColor().set(color.r, color.g, color.b, color.a);
}

View File

@ -54,8 +54,8 @@ void SpineBoneNode::_bind_methods() {
}
void SpineBoneNode::_notification(int what) {
switch(what) {
case NOTIFICATION_PARENTED: {
switch (what) {
case NOTIFICATION_PARENTED: {
SpineSprite *sprite = find_parent_sprite();
if (sprite) {
#if VERSION_MAJOR > 3
@ -78,8 +78,8 @@ void SpineBoneNode::_notification(int what) {
}
NOTIFY_PROPERTY_LIST_CHANGED();
break;
}
case NOTIFICATION_UNPARENTED: {
}
case NOTIFICATION_UNPARENTED: {
SpineSprite *sprite = find_parent_sprite();
if (sprite) {
#if VERSION_MAJOR > 3
@ -89,21 +89,22 @@ void SpineBoneNode::_notification(int what) {
#endif
}
break;
}
case NOTIFICATION_DRAW: {
}
case NOTIFICATION_DRAW: {
draw();
break;
}
default:
break;
}
default:
break;
}
}
void SpineBoneNode::_get_property_list(List<PropertyInfo>* list) const {
void SpineBoneNode::_get_property_list(List<PropertyInfo> *list) const {
Vector<String> bone_names;
SpineSprite *sprite = find_parent_sprite();
if (sprite) sprite->get_skeleton_data_res()->get_bone_names(bone_names);
else bone_names.push_back(bone_name);
else
bone_names.push_back(bone_name);
auto element = list->front();
while (element) {
auto property_info = element->get();
@ -119,7 +120,7 @@ void SpineBoneNode::_get_property_list(List<PropertyInfo>* list) const {
list->insert_after(element, slot_name_property);
}
bool SpineBoneNode::_get(const StringName& property, Variant& value) const {
bool SpineBoneNode::_get(const StringName &property, Variant &value) const {
if (property == "bone_name") {
value = bone_name;
return true;
@ -127,7 +128,7 @@ bool SpineBoneNode::_get(const StringName& property, Variant& value) const {
return false;
}
bool SpineBoneNode::_set(const StringName& property, const Variant& value) {
bool SpineBoneNode::_set(const StringName &property, const Variant &value) {
if (property == "bone_name") {
bone_name = value;
SpineSprite *sprite = find_parent_sprite();
@ -137,20 +138,20 @@ bool SpineBoneNode::_set(const StringName& property, const Variant& value) {
return false;
}
void SpineBoneNode::on_world_transforms_changed(const Variant& _sprite) {
SpineSprite* sprite = cast_to<SpineSprite>(_sprite.operator Object*());
void SpineBoneNode::on_world_transforms_changed(const Variant &_sprite) {
SpineSprite *sprite = cast_to<SpineSprite>(_sprite.operator Object *());
update_transform(sprite);
update();
}
void SpineBoneNode::update_transform(SpineSprite* sprite) {
void SpineBoneNode::update_transform(SpineSprite *sprite) {
if (!enabled) return;
Ref<SpineBone> bone = find_bone();
if (!bone.is_valid()) return;
Transform2D bone_transform = bone->get_global_transform();
Transform2D this_transform = get_global_transform();
if (bone_mode == SpineConstant::BoneMode_Drive) {
bone->set_global_transform(this_transform);
} else {
@ -170,7 +171,7 @@ void SpineBoneNode::update_transform(SpineSprite* sprite) {
}
}
void SpineBoneNode::init_transform(SpineSprite* sprite) {
void SpineBoneNode::init_transform(SpineSprite *sprite) {
if (!sprite) return;
if (bone_mode == SpineConstant::BoneMode_Drive) return;
sprite->get_skeleton()->set_to_setup_pose();

View File

@ -33,7 +33,7 @@
#include "SpineSprite.h"
#include "scene/2d/node_2d.h"
class SpineBoneNode: public Node2D {
class SpineBoneNode : public Node2D {
GDCLASS(SpineBoneNode, Node2D)
protected:
@ -42,7 +42,7 @@ protected:
bool enabled;
Color debug_color;
float debug_thickness;
static void _bind_methods();
void _notification(int what);
void _get_property_list(List<PropertyInfo> *list) const;
@ -54,9 +54,9 @@ protected:
SpineSprite *find_parent_sprite() const;
Ref<SpineBone> find_bone() const;
void draw();
public:
SpineBoneNode(): bone_mode(SpineConstant::BoneMode_Follow), enabled(true), debug_color(Color::hex(0xff000077)), debug_thickness(5) {}
SpineBoneNode() : bone_mode(SpineConstant::BoneMode_Follow), enabled(true), debug_color(Color::hex(0xff000077)), debug_thickness(5) {}
SpineConstant::BoneMode get_bone_mode();

View File

@ -58,20 +58,20 @@
#define GEOMETRY2D Geometry
#endif
#define SPINE_CHECK(obj, ret) \
if (!(obj)) { \
ERR_PRINT("Native Spine object not set."); \
return ret; \
}
#define SPINE_CHECK(obj, ret) \
if (!(obj)) { \
ERR_PRINT("Native Spine object not set."); \
return ret; \
}
#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;
Object *spine_owner;
void *spine_object;
protected:
static void _bind_methods() {
@ -86,11 +86,12 @@ protected:
spine_owner->disconnect("_internal_spine_objects_invalidated", this, "_internal_spine_objects_invalidated");
#endif
}
SpineObjectWrapper(): spine_owner(nullptr), spine_object(nullptr) {
SpineObjectWrapper() : spine_owner(nullptr), spine_object(nullptr) {
}
template <typename OWNER, typename OBJECT> void _set_spine_object_internal(const OWNER* _owner, OBJECT* _object) {
template<typename OWNER, typename OBJECT>
void _set_spine_object_internal(const OWNER *_owner, OBJECT *_object) {
if (spine_owner) {
ERR_PRINT("Owner already set.");
return;
@ -104,7 +105,7 @@ protected:
return;
}
spine_owner = (Object*)_owner;
spine_owner = (Object *) _owner;
spine_object = _object;
#if VERSION_MAJOR > 3
spine_owner->connect("_internal_spine_objects_invalidated", callable_mp(this, &SpineObjectWrapper::spine_objects_invalidated));
@ -119,35 +120,37 @@ protected:
class SpineSprite;
template <typename OBJECT> class SpineSpriteOwnedObject: public SpineObjectWrapper {
template<typename OBJECT>
class SpineSpriteOwnedObject : public SpineObjectWrapper {
public:
void set_spine_object(const SpineSprite* _owner, OBJECT* _object) {
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();
return (OBJECT *) _get_spine_object_internal();
}
SpineSprite *get_spine_owner() {
return (SpineSprite*)_get_spine_owner_internal();
return (SpineSprite *) _get_spine_owner_internal();
}
};
class SpineSkeletonDataResource;
template <typename OBJECT> class SpineSkeletonDataResourceOwnedObject: public SpineObjectWrapper {
template<typename OBJECT>
class SpineSkeletonDataResourceOwnedObject : public SpineObjectWrapper {
public:
void set_spine_object(const SpineSkeletonDataResource* _owner, OBJECT* _object) {
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();
return (OBJECT *) _get_spine_object_internal();
}
SpineSkeletonDataResource *get_spine_owner() {
return (SpineSkeletonDataResource*)_get_spine_owner_internal();
return (SpineSkeletonDataResource *) _get_spine_owner_internal();
}
};

View File

@ -46,11 +46,11 @@ String SpineConstraintData::get_constraint_name() {
int SpineConstraintData::get_order() {
SPINE_CHECK(get_spine_object(), 0)
return (int)get_spine_object()->getOrder();
return (int) get_spine_object()->getOrder();
}
void SpineConstraintData::set_order(int v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setOrder(v);
}
@ -60,6 +60,6 @@ bool SpineConstraintData::is_skin_required() {
}
void SpineConstraintData::set_skin_required(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setSkinRequired(v);
}

View File

@ -100,10 +100,10 @@ bool SpineSkeletonDataResourceInspectorPlugin::can_handle(Object *object) {
}
#if VERSION_MAJOR > 3
bool SpineSkeletonDataResourceInspectorPlugin:: parse_property(Object *object, const Variant::Type type, const String &path, const PropertyHint hint, const String &hint_text, const uint32_t usage, const bool wide) {
bool SpineSkeletonDataResourceInspectorPlugin::parse_property(Object *object, const Variant::Type type, const String &path, const PropertyHint hint, const String &hint_text, const uint32_t usage, const bool wide) {
#else
bool SpineSkeletonDataResourceInspectorPlugin::parse_property(Object *object, Variant::Type type, const String &path,
PropertyHint hint, const String &hint_text, int usage) {
PropertyHint hint, const String &hint_text, int usage) {
#endif
if (path == "animation_mixes") {
Ref<SpineSkeletonDataResource> skeleton_data = Object::cast_to<SpineSkeletonDataResource>(object);
@ -116,7 +116,7 @@ bool SpineSkeletonDataResourceInspectorPlugin::parse_property(Object *object, Va
return false;
}
SpineEditorPropertyAnimationMixes::SpineEditorPropertyAnimationMixes(): skeleton_data(nullptr), container(nullptr), updating(false) {
SpineEditorPropertyAnimationMixes::SpineEditorPropertyAnimationMixes() : skeleton_data(nullptr), container(nullptr), updating(false) {
INSTANTIATE(array_object);
}
@ -146,9 +146,9 @@ void SpineEditorPropertyAnimationMixes::delete_mix(int idx) {
auto mixes = skeleton_data->get_animation_mixes().duplicate();
#if VERSION_MAJOR > 3
mixes.remove_at((int)idx);
mixes.remove_at((int) idx);
#else
mixes.remove((int)idx);
mixes.remove((int) idx);
#endif
emit_changed(get_edited_property(), mixes);
}
@ -224,7 +224,7 @@ void SpineEditorPropertyAnimationMixes::update_property() {
updating = false;
}
SpineEditorPropertyAnimationMix::SpineEditorPropertyAnimationMix(): mixes_property(nullptr), skeleton_data(nullptr), index(0), container(nullptr), updating(false) {
SpineEditorPropertyAnimationMix::SpineEditorPropertyAnimationMix() : mixes_property(nullptr), skeleton_data(nullptr), index(0), container(nullptr), updating(false) {
}
void SpineEditorPropertyAnimationMix::setup(SpineEditorPropertyAnimationMixes *_mixes_property, const Ref<SpineSkeletonDataResource> &_skeleton_data, int _index) {
@ -331,14 +331,14 @@ void SpineSpriteInspectorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("button_clicked"), &SpineSpriteInspectorPlugin::button_clicked);
}
void SpineSpriteInspectorPlugin::button_clicked(const String& button_name) {
void SpineSpriteInspectorPlugin::button_clicked(const String &button_name) {
}
bool SpineSpriteInspectorPlugin::can_handle(Object* object) {
bool SpineSpriteInspectorPlugin::can_handle(Object *object) {
return Object::cast_to<SpineSprite>(object) != nullptr;
}
void SpineSpriteInspectorPlugin::parse_begin(Object* object) {
void SpineSpriteInspectorPlugin::parse_begin(Object *object) {
sprite = Object::cast_to<SpineSprite>(object);
if (!sprite) return;
if (!sprite->get_skeleton_data_res().is_valid() || !sprite->get_skeleton_data_res()->is_skeleton_data_loaded()) return;

View File

@ -68,7 +68,7 @@ public:
bool get_option_visibility(const String &option, const Map<StringName, Variant> &options) const override { return true; }
Error import(const String &source_file, const String &save_path, const Map<StringName, Variant> &options, List<String> *platform_variants, List<String> *gen_files, Variant *metadata) override;
#endif
#endif
};
class SpineJsonResourceImportPlugin : public EditorImportPlugin {
@ -92,18 +92,18 @@ public:
#if VERSION_MAJOR > 3
int get_import_order() const override { return IMPORT_ORDER_DEFAULT; }
void get_import_options(const String &path, List<ImportOption> *options, int preset) const override { }
void get_import_options(const String &path, List<ImportOption> *options, int preset) const override {}
bool get_option_visibility(const String &path, const String &option, const HashMap<StringName, Variant> &options) const override { return true; }
Error import(const String &source_file, const String &save_path, const HashMap<StringName, Variant> &options, List<String> *platform_variants, List<String> *gen_files, Variant *metadata) override;
#else
void get_import_options(List<ImportOption> *options, int preset) const override { }
void get_import_options(List<ImportOption> *options, int preset) const override {}
bool get_option_visibility(const String &option, const Map<StringName, Variant> &options) const override { return true; }
Error import(const String &source_file, const String &save_path, const Map<StringName, Variant> &options, List<String> *platform_variants, List<String> *gen_files, Variant *metadata) override;
#endif
#endif
};
class SpineBinaryResourceImportPlugin : public EditorImportPlugin {
@ -127,18 +127,18 @@ public:
#if VERSION_MAJOR > 3
int get_import_order() const override { return IMPORT_ORDER_DEFAULT; }
void get_import_options(const String &path, List<ImportOption> *options, int preset) const override { }
void get_import_options(const String &path, List<ImportOption> *options, int preset) const override {}
bool get_option_visibility(const String &path, const String &option, const HashMap<StringName, Variant> &options) const override { return true; }
Error import(const String &source_file, const String &save_path, const HashMap<StringName, Variant> &options, List<String> *platform_variants, List<String> *gen_files, Variant *metadata) override;
#else
void get_import_options(List<ImportOption> *options, int preset) const override { }
void get_import_options(List<ImportOption> *options, int preset) const override {}
bool get_option_visibility(const String &option, const Map<StringName, Variant> &options) const override { return true; }
Error import(const String &source_file, const String &save_path, const Map<StringName, Variant> &options, List<String> *platform_variants, List<String> *gen_files, Variant *metadata) override;
#endif
#endif
};
class SpineEditorPlugin : public EditorPlugin {
@ -150,7 +150,7 @@ public:
String get_name() const override { return "SpineEditorPlugin"; }
};
class SpineSkeletonDataResourceInspectorPlugin: public EditorInspectorPlugin {
class SpineSkeletonDataResourceInspectorPlugin : public EditorInspectorPlugin {
GDCLASS(SpineSkeletonDataResourceInspectorPlugin, EditorInspectorPlugin)
public:
@ -164,26 +164,27 @@ public:
class SpineEditorPropertyAnimationMix;
class SpineEditorPropertyAnimationMixes: public EditorProperty {
class SpineEditorPropertyAnimationMixes : public EditorProperty {
GDCLASS(SpineEditorPropertyAnimationMixes, EditorProperty)
Ref<EditorPropertyArrayObject> array_object;
Ref<SpineSkeletonDataResource> skeleton_data;
VBoxContainer *container;
Vector<SpineEditorPropertyAnimationMix*> mix_properties;
Vector<SpineEditorPropertyAnimationMix *> mix_properties;
bool updating;
static void _bind_methods();
void add_mix();
void delete_mix(int idx);
void update_mix_property(int index);
public:
SpineEditorPropertyAnimationMixes();
void setup(const Ref<SpineSkeletonDataResource> &_skeleton_data) { this->skeleton_data = _skeleton_data; };
void update_property() override;
};
class SpineEditorPropertyAnimationMix: public EditorProperty {
class SpineEditorPropertyAnimationMix : public EditorProperty {
GDCLASS(SpineEditorPropertyAnimationMix, EditorProperty)
SpineEditorPropertyAnimationMixes *mixes_property;
@ -194,19 +195,21 @@ class SpineEditorPropertyAnimationMix: public EditorProperty {
static void _bind_methods();
void data_changed(const String &property, const Variant &value, const String &name, bool changing);
public:
SpineEditorPropertyAnimationMix();
void setup(SpineEditorPropertyAnimationMixes *mixes_property, const Ref<SpineSkeletonDataResource> &skeleton_data, int index);
void update_property() override;
};
class SpineSpriteInspectorPlugin: public EditorInspectorPlugin {
class SpineSpriteInspectorPlugin : public EditorInspectorPlugin {
GDCLASS(SpineSpriteInspectorPlugin, EditorInspectorPlugin)
SpineSprite *sprite;
static void _bind_methods();
void button_clicked(const String &button_name);
public:
bool can_handle(Object *object) override;
void parse_begin(Object *object) override;

View File

@ -49,7 +49,7 @@ void SpineEvent::_bind_methods() {
Ref<SpineEventData> SpineEvent::get_data() {
SPINE_CHECK(get_spine_object(), nullptr)
Ref<SpineEventData> event_data(memnew(SpineEventData));
event_data->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), (spine::EventData*)&get_spine_object()->getData());
event_data->set_spine_object(*get_spine_owner()->get_skeleton_data_res(), (spine::EventData *) &get_spine_object()->getData());
return event_data;
}
@ -64,7 +64,7 @@ int SpineEvent::get_int_value() {
}
void SpineEvent::set_int_value(int v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setIntValue(v);
}
@ -74,7 +74,7 @@ float SpineEvent::get_float_value() {
}
void SpineEvent::set_float_value(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setFloatValue(v);
}
@ -84,7 +84,7 @@ String SpineEvent::get_string_value() {
}
void SpineEvent::set_string_value(const String &v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setStringValue(spine::String(v.utf8()));
}
@ -94,7 +94,7 @@ float SpineEvent::get_volume() {
}
void SpineEvent::set_volume(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setVolume(v);
}
@ -104,6 +104,6 @@ float SpineEvent::get_balance() {
}
void SpineEvent::set_balance(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setBalance(v);
}

View File

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

View File

@ -54,7 +54,7 @@ void SpineIkConstraint::_bind_methods() {
}
void SpineIkConstraint::update() {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->update();
}
@ -75,7 +75,7 @@ Array SpineIkConstraint::get_bones() {
Array result;
SPINE_CHECK(get_spine_object(), result)
auto &bones = get_spine_object()->getBones();
result.resize((int)bones.size());
result.resize((int) bones.size());
for (int i = 0; i < bones.size(); ++i) {
auto bone = bones[i];
Ref<SpineBone> bone_ref(memnew(SpineBone));
@ -95,7 +95,7 @@ Ref<SpineBone> SpineIkConstraint::get_target() {
}
void SpineIkConstraint::set_target(Ref<SpineBone> v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
}
@ -105,7 +105,7 @@ int SpineIkConstraint::get_bend_direction() {
}
void SpineIkConstraint::set_bend_direction(int v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setBendDirection(v);
}
@ -115,7 +115,7 @@ bool SpineIkConstraint::get_compress() {
}
void SpineIkConstraint::set_compress(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setCompress(v);
}
@ -125,7 +125,7 @@ bool SpineIkConstraint::get_stretch() {
}
void SpineIkConstraint::set_stretch(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setStretch(v);
}
@ -134,7 +134,7 @@ float SpineIkConstraint::get_mix() {
return get_spine_object()->getMix();
}
void SpineIkConstraint::set_mix(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMix(v);
}
@ -144,7 +144,7 @@ float SpineIkConstraint::get_softness() {
}
void SpineIkConstraint::set_softness(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setSoftness(v);
}
@ -154,6 +154,6 @@ bool SpineIkConstraint::is_active() {
}
void SpineIkConstraint::set_active(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setActive(v);
}

View File

@ -52,7 +52,7 @@ Array SpineIkConstraintData::get_bones() {
Array result;
SPINE_CHECK(get_spine_object(), result)
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) {
Ref<SpineBoneData> bone_ref(memnew(SpineBoneData));
bone_ref->set_spine_object(get_spine_owner(), bones[i]);
@ -71,7 +71,7 @@ Ref<SpineBoneData> SpineIkConstraintData::get_target() {
}
void SpineIkConstraintData::set_target(Ref<SpineBoneData> v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_constraint_data()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
}
@ -81,7 +81,7 @@ int SpineIkConstraintData::get_bend_direction() {
}
void SpineIkConstraintData::set_bend_direction(int v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_constraint_data()->setBendDirection(v);
}
@ -91,7 +91,7 @@ bool SpineIkConstraintData::get_compress() {
}
void SpineIkConstraintData::set_compress(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_constraint_data()->setCompress(v);
}
@ -101,7 +101,7 @@ bool SpineIkConstraintData::get_stretch() {
}
void SpineIkConstraintData::set_stretch(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_constraint_data()->setStretch(v);
}
@ -111,7 +111,7 @@ bool SpineIkConstraintData::get_uniform() {
}
void SpineIkConstraintData::set_uniform(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_constraint_data()->setUniform(v);
}
@ -121,7 +121,7 @@ float SpineIkConstraintData::get_mix() {
}
void SpineIkConstraintData::set_mix(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_constraint_data()->setMix(v);
}
@ -131,6 +131,6 @@ float SpineIkConstraintData::get_softness() {
}
void SpineIkConstraintData::set_softness(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_constraint_data()->setSoftness(v);
}

View File

@ -36,7 +36,7 @@
class SpineIkConstraintData : public SpineConstraintData {
GDCLASS(SpineIkConstraintData, SpineConstraintData)
spine::IkConstraintData *get_spine_constraint_data() { return (spine::IkConstraintData *)get_spine_object(); }
spine::IkConstraintData *get_spine_constraint_data() { return (spine::IkConstraintData *) get_spine_object(); }
protected:
static void _bind_methods();

View File

@ -54,7 +54,7 @@ void SpinePathConstraint::_bind_methods() {
}
void SpinePathConstraint::update() {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->update();
}
@ -69,7 +69,7 @@ float SpinePathConstraint::get_position() {
}
void SpinePathConstraint::set_position(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setPosition(v);
}
@ -79,7 +79,7 @@ float SpinePathConstraint::get_spacing() {
}
void SpinePathConstraint::set_spacing(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setSpacing(v);
}
@ -89,7 +89,7 @@ float SpinePathConstraint::get_mix_rotate() {
}
void SpinePathConstraint::set_mix_rotate(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixRotate(v);
}
@ -99,7 +99,7 @@ float SpinePathConstraint::get_mix_x() {
}
void SpinePathConstraint::set_mix_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixX(v);
}
@ -109,7 +109,7 @@ float SpinePathConstraint::get_mix_y() {
}
void SpinePathConstraint::set_mix_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixY(v);
}
@ -117,7 +117,7 @@ Array SpinePathConstraint::get_bones() {
Array result;
SPINE_CHECK(get_spine_object(), result)
auto &bones = get_spine_object()->getBones();
result.resize((int)bones.size());
result.resize((int) bones.size());
for (int i = 0; i < bones.size(); ++i) {
auto bone = bones[i];
Ref<SpineBone> bone_ref(memnew(SpineBone));
@ -137,7 +137,7 @@ Ref<SpineSlot> SpinePathConstraint::get_target() {
}
void SpinePathConstraint::set_target(Ref<SpineSlot> v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
}
@ -155,6 +155,6 @@ bool SpinePathConstraint::is_active() {
}
void SpinePathConstraint::set_active(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setActive(v);
}

View File

@ -59,7 +59,7 @@ Array SpinePathConstraintData::get_bones() {
Array result;
SPINE_CHECK(get_spine_constraint_data(), result)
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) {
Ref<SpineBoneData> bone_ref(memnew(SpineBoneData));
bone_ref->set_spine_object(get_spine_owner(), bones[i]);
@ -78,8 +78,8 @@ Ref<SpineSlotData> SpinePathConstraintData::get_target() {
}
void SpinePathConstraintData::set_target(Ref<SpineSlotData> v) {
SPINE_CHECK(get_spine_constraint_data(),)
get_spine_constraint_data()->setTarget(v.is_valid() && v->get_spine_object()? v->get_spine_object() : nullptr);
SPINE_CHECK(get_spine_constraint_data(), )
get_spine_constraint_data()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
}
SpineConstant::PositionMode SpinePathConstraintData::get_position_mode() {
@ -88,27 +88,27 @@ SpineConstant::PositionMode SpinePathConstraintData::get_position_mode() {
}
void SpinePathConstraintData::set_position_mode(SpineConstant::PositionMode v) {
SPINE_CHECK(get_spine_constraint_data(),)
get_spine_constraint_data()->setPositionMode((spine::PositionMode)v);
SPINE_CHECK(get_spine_constraint_data(), )
get_spine_constraint_data()->setPositionMode((spine::PositionMode) v);
}
SpineConstant::SpacingMode SpinePathConstraintData::get_spacing_mode() {
SPINE_CHECK(get_spine_constraint_data(),SpineConstant::SpacingMode_Fixed)
SPINE_CHECK(get_spine_constraint_data(), SpineConstant::SpacingMode_Fixed)
return (SpineConstant::SpacingMode) get_spine_constraint_data()->getSpacingMode();
}
void SpinePathConstraintData::set_spacing_mode(SpineConstant::SpacingMode v) {
SPINE_CHECK(get_spine_constraint_data(),)
SPINE_CHECK(get_spine_constraint_data(), )
get_spine_constraint_data()->setSpacingMode((spine::SpacingMode) v);
}
SpineConstant::RotateMode SpinePathConstraintData::get_rotate_mode() {
SPINE_CHECK(get_spine_constraint_data(),SpineConstant::RotateMode_Tangent)
return (SpineConstant::RotateMode)get_spine_constraint_data()->getRotateMode();
SPINE_CHECK(get_spine_constraint_data(), SpineConstant::RotateMode_Tangent)
return (SpineConstant::RotateMode) get_spine_constraint_data()->getRotateMode();
}
void SpinePathConstraintData::set_rotate_mode(SpineConstant::RotateMode v) {
SPINE_CHECK(get_spine_constraint_data(),)
SPINE_CHECK(get_spine_constraint_data(), )
get_spine_constraint_data()->setRotateMode((spine::RotateMode) v);
}
@ -118,7 +118,7 @@ float SpinePathConstraintData::get_offset_rotation() {
}
void SpinePathConstraintData::set_offset_rotation(float v) {
SPINE_CHECK(get_spine_constraint_data(),)
SPINE_CHECK(get_spine_constraint_data(), )
get_spine_constraint_data()->setOffsetRotation(v);
}
@ -128,7 +128,7 @@ float SpinePathConstraintData::get_position() {
}
void SpinePathConstraintData::set_position(float v) {
SPINE_CHECK(get_spine_constraint_data(),)
SPINE_CHECK(get_spine_constraint_data(), )
get_spine_constraint_data()->setPosition(v);
}
@ -138,7 +138,7 @@ float SpinePathConstraintData::get_spacing() {
}
void SpinePathConstraintData::set_spacing(float v) {
SPINE_CHECK(get_spine_constraint_data(),)
SPINE_CHECK(get_spine_constraint_data(), )
get_spine_constraint_data()->setSpacing(v);
}
@ -148,7 +148,7 @@ float SpinePathConstraintData::get_mix_rotate() {
}
void SpinePathConstraintData::set_mix_rotate(float v) {
SPINE_CHECK(get_spine_constraint_data(),)
SPINE_CHECK(get_spine_constraint_data(), )
get_spine_constraint_data()->setMixRotate(v);
}
@ -158,7 +158,7 @@ float SpinePathConstraintData::get_mix_x() {
}
void SpinePathConstraintData::set_mix_x(float v) {
SPINE_CHECK(get_spine_constraint_data(),)
SPINE_CHECK(get_spine_constraint_data(), )
get_spine_constraint_data()->setMixX(v);
}
@ -168,6 +168,6 @@ float SpinePathConstraintData::get_mix_y() {
}
void SpinePathConstraintData::set_mix_y(float v) {
SPINE_CHECK(get_spine_constraint_data(),)
SPINE_CHECK(get_spine_constraint_data(), )
get_spine_constraint_data()->setMixY(v);
}

View File

@ -38,7 +38,7 @@
class SpinePathConstraintData : public SpineConstraintData {
GDCLASS(SpinePathConstraintData, SpineConstraintData)
spine::PathConstraintData *get_spine_constraint_data() { return (spine::PathConstraintData *)get_spine_object(); }
spine::PathConstraintData *get_spine_constraint_data() { return (spine::PathConstraintData *) get_spine_object(); }
protected:
static void _bind_methods();

View File

@ -90,22 +90,22 @@ Ref<SpineSkeletonDataResource> SpineSkeleton::get_skeleton_data_res() const {
}
void SpineSkeleton::update_world_transform() {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->updateWorldTransform();
}
void SpineSkeleton::set_to_setup_pose() {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->setToSetupPose();
}
void SpineSkeleton::set_bones_to_setup_pose() {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->setBonesToSetupPose();
}
void SpineSkeleton::set_slots_to_setup_pose() {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->setSlotsToSetupPose();
}
@ -130,12 +130,12 @@ Ref<SpineSlot> SpineSkeleton::find_slot(const String &name) {
}
void SpineSkeleton::set_skin_by_name(const String &skin_name) {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->setSkin(SPINE_STRING(skin_name));
}
void SpineSkeleton::set_skin(Ref<SpineSkin> new_skin) {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->setSkin(new_skin.is_valid() && new_skin->get_spine_object() ? new_skin->get_spine_object() : nullptr);
}
@ -158,7 +158,7 @@ Ref<SpineAttachment> SpineSkeleton::get_attachment_by_slot_index(int slot_index,
}
void SpineSkeleton::set_attachment(const String &slot_name, const String &attachment_name) {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->setAttachment(SPINE_STRING(slot_name), SPINE_STRING(attachment_name));
}
@ -212,7 +212,7 @@ Array SpineSkeleton::get_bones() {
Array result;
SPINE_CHECK(skeleton, result)
auto &bones = skeleton->getBones();
result.resize((int)bones.size());
result.resize((int) bones.size());
for (int i = 0; i < result.size(); ++i) {
auto bone = bones[i];
Ref<SpineBone> bone_ref(memnew(SpineBone));
@ -226,7 +226,7 @@ Array SpineSkeleton::get_slots() {
Array result;
SPINE_CHECK(skeleton, result)
auto &slots = skeleton->getSlots();
result.resize((int)slots.size());
result.resize((int) slots.size());
for (int i = 0; i < result.size(); ++i) {
auto slot = slots[i];
Ref<SpineSlot> slot_ref(memnew(SpineSlot));
@ -240,7 +240,7 @@ Array SpineSkeleton::get_draw_order() {
Array result;
SPINE_CHECK(skeleton, result)
auto &slots = skeleton->getDrawOrder();
result.resize((int)slots.size());
result.resize((int) slots.size());
for (int i = 0; i < result.size(); ++i) {
auto slot = slots[i];
Ref<SpineSlot> slot_ref(memnew(SpineSlot));
@ -254,7 +254,7 @@ Array SpineSkeleton::get_ik_constraints() {
Array result;
SPINE_CHECK(skeleton, result)
auto &constraints = skeleton->getIkConstraints();
result.resize((int)constraints.size());
result.resize((int) constraints.size());
for (int i = 0; i < result.size(); ++i) {
auto constraint = constraints[i];
Ref<SpineIkConstraint> constraint_ref(memnew(SpineIkConstraint));
@ -268,7 +268,7 @@ Array SpineSkeleton::get_path_constraints() {
Array result;
SPINE_CHECK(skeleton, result)
auto &constraints = skeleton->getPathConstraints();
result.resize((int)constraints.size());
result.resize((int) constraints.size());
for (int i = 0; i < result.size(); ++i) {
auto constraint = constraints[i];
Ref<SpinePathConstraint> constraint_ref(memnew(SpinePathConstraint));
@ -281,7 +281,7 @@ Array SpineSkeleton::get_transform_constraints() {
Array result;
SPINE_CHECK(skeleton, result)
auto &constraints = skeleton->getTransformConstraints();
result.resize((int)constraints.size());
result.resize((int) constraints.size());
for (int i = 0; i < result.size(); ++i) {
auto constraint = constraints[i];
Ref<SpineTransformConstraint> constraint_ref(memnew(SpineTransformConstraint));
@ -307,13 +307,13 @@ Color SpineSkeleton::get_color() {
}
void SpineSkeleton::set_color(Color v) {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
auto &color = skeleton->getColor();
color.set(v.r, v.g, v.b, v.a);
}
void SpineSkeleton::set_position(Vector2 position) {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->setPosition(position.x, position.y);
}
@ -323,7 +323,7 @@ float SpineSkeleton::get_x() {
}
void SpineSkeleton::set_x(float v) {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->setX(v);
}
@ -333,7 +333,7 @@ float SpineSkeleton::get_y() {
}
void SpineSkeleton::set_y(float v) {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->setY(v);
}
@ -343,7 +343,7 @@ float SpineSkeleton::get_scale_x() {
}
void SpineSkeleton::set_scale_x(float v) {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->setScaleX(v);
}
@ -353,6 +353,6 @@ float SpineSkeleton::get_scale_y() {
}
void SpineSkeleton::set_scale_y(float v) {
SPINE_CHECK(skeleton,)
SPINE_CHECK(skeleton, )
skeleton->setScaleY(v);
}

View File

@ -48,7 +48,7 @@ void SpineAnimationMix::_bind_methods() {
#endif
}
SpineAnimationMix::SpineAnimationMix(): from(""), to(""), mix(0) {
SpineAnimationMix::SpineAnimationMix() : from(""), to(""), mix(0) {
}
void SpineAnimationMix::set_from(const StringName &_from) {
@ -226,7 +226,7 @@ void SpineSkeletonDataResource::get_skin_names(Vector<String> &skin_names) const
}
}
void SpineSkeletonDataResource::get_slot_names(Vector<String>& slot_names) {
void SpineSkeletonDataResource::get_slot_names(Vector<String> &slot_names) {
slot_names.clear();
if (!is_skeleton_data_loaded()) return;
auto slots = skeleton_data->getSlots();
@ -236,7 +236,7 @@ void SpineSkeletonDataResource::get_slot_names(Vector<String>& slot_names) {
}
}
void SpineSkeletonDataResource::get_bone_names(Vector<String>& bone_names) {
void SpineSkeletonDataResource::get_bone_names(Vector<String> &bone_names) {
bone_names.clear();
if (!is_skeleton_data_loaded()) return;
auto bones = skeleton_data->getBones();
@ -371,7 +371,7 @@ Ref<SpinePathConstraintData> SpineSkeletonDataResource::find_path_constraint(con
return constraint_ref;
}
String SpineSkeletonDataResource::get_skeleton_name() const{
String SpineSkeletonDataResource::get_skeleton_name() const {
SPINE_CHECK(skeleton_data, "")
return skeleton_data->getName().buffer();
}
@ -380,7 +380,7 @@ Array SpineSkeletonDataResource::get_bones() const {
Array result;
SPINE_CHECK(skeleton_data, result)
auto bones = skeleton_data->getBones();
result.resize((int)bones.size());
result.resize((int) bones.size());
for (int i = 0; i < bones.size(); ++i) {
Ref<SpineBoneData> bone_ref(memnew(SpineBoneData));
bone_ref->set_spine_object(this, bones[i]);
@ -393,7 +393,7 @@ Array SpineSkeletonDataResource::get_slots() const {
Array result;
SPINE_CHECK(skeleton_data, result)
auto slots = skeleton_data->getSlots();
result.resize((int)slots.size());
result.resize((int) slots.size());
for (int i = 0; i < slots.size(); ++i) {
Ref<SpineSlotData> slot_ref(memnew(SpineSlotData));
slot_ref->set_spine_object(this, slots[i]);
@ -406,7 +406,7 @@ Array SpineSkeletonDataResource::get_skins() const {
Array result;
SPINE_CHECK(skeleton_data, result)
auto skins = skeleton_data->getSkins();
result.resize((int)skins.size());
result.resize((int) skins.size());
for (int i = 0; i < skins.size(); ++i) {
Ref<SpineSkin> skin_ref(memnew(SpineSkin));
skin_ref->set_spine_object(this, skins[i]);
@ -425,7 +425,7 @@ Ref<SpineSkin> SpineSkeletonDataResource::get_default_skin() const {
}
void SpineSkeletonDataResource::set_default_skin(Ref<SpineSkin> skin) {
SPINE_CHECK(skeleton_data,)
SPINE_CHECK(skeleton_data, )
skeleton_data->setDefaultSkin(skin.is_valid() && skin->get_spine_object() ? skin->get_spine_object() : nullptr);
}
@ -433,7 +433,7 @@ Array SpineSkeletonDataResource::get_events() const {
Array result;
SPINE_CHECK(skeleton_data, result)
auto events = skeleton_data->getEvents();
result.resize((int)events.size());
result.resize((int) events.size());
for (int i = 0; i < events.size(); ++i) {
Ref<SpineEventData> event_ref(memnew(SpineEventData));
event_ref->set_spine_object(this, events[i]);
@ -446,7 +446,7 @@ Array SpineSkeletonDataResource::get_animations() const {
Array result;
SPINE_CHECK(skeleton_data, result)
auto animations = skeleton_data->getAnimations();
result.resize((int)animations.size());
result.resize((int) animations.size());
for (int i = 0; i < animations.size(); ++i) {
Ref<SpineAnimation> animation_ref(memnew(SpineAnimation));
animation_ref->set_spine_object(this, animations[i]);
@ -459,7 +459,7 @@ Array SpineSkeletonDataResource::get_ik_constraints() const {
Array result;
SPINE_CHECK(skeleton_data, result)
auto constraints = skeleton_data->getIkConstraints();
result.resize((int)constraints.size());
result.resize((int) constraints.size());
for (int i = 0; i < constraints.size(); ++i) {
Ref<SpineIkConstraintData> constraint_ref(memnew(SpineIkConstraintData));
constraint_ref->set_spine_object(this, constraints[i]);
@ -472,7 +472,7 @@ Array SpineSkeletonDataResource::get_transform_constraints() const {
Array result;
SPINE_CHECK(skeleton_data, result)
auto constraints = skeleton_data->getTransformConstraints();
result.resize((int)constraints.size());
result.resize((int) constraints.size());
for (int i = 0; i < constraints.size(); ++i) {
Ref<SpineTransformConstraintData> constraint_ref(memnew(SpineTransformConstraintData));
constraint_ref->set_spine_object(this, constraints[i]);
@ -485,7 +485,7 @@ Array SpineSkeletonDataResource::get_path_constraints() const {
Array result;
SPINE_CHECK(skeleton_data, result)
auto constraints = skeleton_data->getPathConstraints();
result.resize((int)constraints.size());
result.resize((int) constraints.size());
for (int i = 0; i < constraints.size(); ++i) {
Ref<SpinePathConstraintData> constraint_ref(memnew(SpinePathConstraintData));
constraint_ref->set_spine_object(this, constraints[i]);
@ -494,7 +494,7 @@ Array SpineSkeletonDataResource::get_path_constraints() const {
return result;
}
float SpineSkeletonDataResource::get_x() const{
float SpineSkeletonDataResource::get_x() const {
SPINE_CHECK(skeleton_data, 0)
return skeleton_data->getX();
}
@ -504,7 +504,7 @@ float SpineSkeletonDataResource::get_y() const {
return skeleton_data->getY();
}
float SpineSkeletonDataResource::get_width() const{
float SpineSkeletonDataResource::get_width() const {
SPINE_CHECK(skeleton_data, 0)
return skeleton_data->getWidth();
}

View File

@ -20,6 +20,7 @@ protected:
String from;
String to;
float mix;
public:
SpineAnimationMix();

View File

@ -73,8 +73,8 @@ Ref<SpineSkin> SpineSkin::init(const String &name, SpineSprite *sprite) {
}
void SpineSkin::set_attachment(int slot_index, const String &name, Ref<SpineAttachment> attachment) {
SPINE_CHECK(get_spine_object(),)
get_spine_object()->setAttachment(slot_index, SPINE_STRING(name), attachment.is_valid() && attachment->get_spine_owner()? attachment->get_spine_object() : nullptr);
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAttachment(slot_index, SPINE_STRING(name), attachment.is_valid() && attachment->get_spine_owner() ? attachment->get_spine_object() : nullptr);
}
Ref<SpineAttachment> SpineSkin::get_attachment(int slot_index, const String &name) {
@ -87,7 +87,7 @@ Ref<SpineAttachment> SpineSkin::get_attachment(int slot_index, const String &nam
}
void SpineSkin::remove_attachment(int slot_index, const String &name) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->removeAttachment(slot_index, SPINE_STRING(name));
}
@ -96,7 +96,7 @@ Array SpineSkin::find_names_for_slot(int slot_index) {
SPINE_CHECK(get_spine_object(), result)
spine::Vector<spine::String> 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) {
result[i] = names[i].buffer();
}
@ -108,7 +108,7 @@ Array SpineSkin::find_attachments_for_slot(int slot_index) {
SPINE_CHECK(get_spine_object(), result)
spine::Vector<spine::Attachment *> 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) {
if (!attachments[i]) {
result[i] = Ref<SpineAttachment>(nullptr);
@ -127,7 +127,7 @@ String SpineSkin::get_name() {
}
void SpineSkin::add_skin(Ref<SpineSkin> other) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
if (!other.is_valid() || !other->get_spine_object()) {
ERR_PRINT("other is not a valid SpineSkin.");
return;
@ -136,7 +136,7 @@ void SpineSkin::add_skin(Ref<SpineSkin> other) {
}
void SpineSkin::copy_skin(Ref<SpineSkin> other) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
if (!other.is_valid() || !other->get_spine_object()) {
ERR_PRINT("other is not a valid SpineSkin.");
return;
@ -148,7 +148,7 @@ Array SpineSkin::get_attachments() {
Array result;
SPINE_CHECK(get_spine_object(), result)
auto entries = get_spine_object()->getAttachments();
while(entries.hasNext()) {
while (entries.hasNext()) {
spine::Skin::AttachmentMap::Entry &entry = entries.next();
Ref<SpineSkinEntry> entry_ref = memnew(SpineSkinEntry);
Ref<SpineAttachment> attachment_ref = nullptr;
@ -166,7 +166,7 @@ Array SpineSkin::get_bones() {
Array result;
SPINE_CHECK(get_spine_object(), result)
auto bones = get_spine_object()->getBones();
result.resize((int)bones.size());
result.resize((int) bones.size());
for (int i = 0; i < bones.size(); ++i) {
Ref<SpineBoneData> bone_ref(memnew(SpineBoneData));
bone_ref->set_spine_object(get_spine_owner(), bones[i]);
@ -179,7 +179,7 @@ Array SpineSkin::get_constraints() {
Array result;
SPINE_CHECK(get_spine_object(), result)
auto constraints = get_spine_object()->getConstraints();
result.resize((int)constraints.size());
result.resize((int) constraints.size());
for (int i = 0; i < constraints.size(); ++i) {
Ref<SpineConstraintData> constraint_ref(memnew(SpineConstraintData));
constraint_ref->set_spine_object(get_spine_owner(), constraints[i]);

View File

@ -74,7 +74,7 @@ public:
};
class SpineSkinEntry : public REFCOUNTED {
GDCLASS(SpineSkinEntry, REFCOUNTED);
GDCLASS(SpineSkinEntry, REFCOUNTED);
friend class SpineSkin;
@ -86,6 +86,7 @@ protected:
this->name = _name;
this->attachment = _attachment;
}
private:
int slot_index;
String name;

View File

@ -53,7 +53,7 @@ void SpineSlot::_bind_methods() {
}
void SpineSlot::set_to_setup_pose() {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setToSetupPose();
}
@ -80,7 +80,7 @@ Color SpineSlot::get_color() {
}
void SpineSlot::set_color(Color v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
auto &color = get_spine_object()->getColor();
color.set(v.r, v.g, v.b, v.a);
}
@ -92,7 +92,7 @@ Color SpineSlot::get_dark_color() {
}
void SpineSlot::set_dark_color(Color v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
auto &color = get_spine_object()->getDarkColor();
color.set(v.r, v.g, v.b, v.a);
}
@ -112,7 +112,7 @@ Ref<SpineAttachment> SpineSlot::get_attachment() {
}
void SpineSlot::set_attachment(Ref<SpineAttachment> v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAttachment(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
}
@ -122,7 +122,7 @@ int SpineSlot::get_attachment_state() {
}
void SpineSlot::set_attachment_state(int v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAttachmentState(v);
}
@ -130,15 +130,15 @@ Array SpineSlot::get_deform() {
Array result;
SPINE_CHECK(get_spine_object(), result)
auto &deform = get_spine_object()->getDeform();
result.resize((int)deform.size());
for (int i = 0; i < (int)deform.size(); ++i) {
result.resize((int) deform.size());
for (int i = 0; i < (int) deform.size(); ++i) {
result[i] = deform[i];
}
return result;
}
void SpineSlot::set_deform(Array v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
auto &deform = get_spine_object()->getDeform();
deform.setSize(v.size(), 0);
for (int i = 0; i < v.size(); ++i) {
@ -152,6 +152,6 @@ int SpineSlot::get_sequence_index() {
}
void SpineSlot::set_sequence_index(int v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAttachmentState(v);
}

View File

@ -44,7 +44,6 @@ void SpineSlotData::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_attachment_name", "v"), &SpineSlotData::set_attachment_name);
ClassDB::bind_method(D_METHOD("get_blend_mode"), &SpineSlotData::get_blend_mode);
ClassDB::bind_method(D_METHOD("set_blend_mode", "v"), &SpineSlotData::set_blend_mode);
}
int SpineSlotData::get_index() {
@ -72,7 +71,7 @@ Color SpineSlotData::get_color() {
}
void SpineSlotData::set_color(Color v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
auto &color = get_spine_object()->getColor();
color.set(v.r, v.g, v.b, v.a);
}
@ -84,7 +83,7 @@ Color SpineSlotData::get_dark_color() {
}
void SpineSlotData::set_dark_color(Color v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
auto &color = get_spine_object()->getDarkColor();
color.set(v.r, v.g, v.b, v.a);
}
@ -95,7 +94,7 @@ bool SpineSlotData::has_dark_color() {
}
void SpineSlotData::set_has_dark_color(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setHasDarkColor(v);
}
@ -104,15 +103,15 @@ String SpineSlotData::get_attachment_name() {
return get_spine_object()->getAttachmentName().buffer();
}
void SpineSlotData::set_attachment_name(const String &v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAttachmentName(SPINE_STRING(v));
}
SpineConstant::BlendMode SpineSlotData::get_blend_mode() {
SPINE_CHECK(get_spine_object(), SpineConstant::BlendMode_Normal)
return (SpineConstant::BlendMode)get_spine_object()->getBlendMode();
return (SpineConstant::BlendMode) get_spine_object()->getBlendMode();
}
void SpineSlotData::set_blend_mode(SpineConstant::BlendMode v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setBlendMode((spine::BlendMode) v);
}

View File

@ -33,173 +33,174 @@
#include "scene/main/viewport.h"
void SpineSlotNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_on_world_transforms_changed", "spine_sprite"), &SpineSlotNode::on_world_transforms_changed);
ClassDB::bind_method(D_METHOD("_on_world_transforms_changed", "spine_sprite"), &SpineSlotNode::on_world_transforms_changed);
ClassDB::bind_method(D_METHOD("set_normal_material", "material"), &SpineSlotNode::set_normal_material);
ClassDB::bind_method(D_METHOD("get_normal_material"), &SpineSlotNode::get_normal_material);
ClassDB::bind_method(D_METHOD("set_additive_material", "material"), &SpineSlotNode::set_additive_material);
ClassDB::bind_method(D_METHOD("get_additive_material"), &SpineSlotNode::get_additive_material);
ClassDB::bind_method(D_METHOD("set_multiply_material", "material"), &SpineSlotNode::set_multiply_material);
ClassDB::bind_method(D_METHOD("get_multiply_material"), &SpineSlotNode::get_multiply_material);
ClassDB::bind_method(D_METHOD("set_screen_material", "material"), &SpineSlotNode::set_screen_material);
ClassDB::bind_method(D_METHOD("get_screen_material"), &SpineSlotNode::get_screen_material);
ClassDB::bind_method(D_METHOD("set_normal_material", "material"), &SpineSlotNode::set_normal_material);
ClassDB::bind_method(D_METHOD("get_normal_material"), &SpineSlotNode::get_normal_material);
ClassDB::bind_method(D_METHOD("set_additive_material", "material"), &SpineSlotNode::set_additive_material);
ClassDB::bind_method(D_METHOD("get_additive_material"), &SpineSlotNode::get_additive_material);
ClassDB::bind_method(D_METHOD("set_multiply_material", "material"), &SpineSlotNode::set_multiply_material);
ClassDB::bind_method(D_METHOD("get_multiply_material"), &SpineSlotNode::get_multiply_material);
ClassDB::bind_method(D_METHOD("set_screen_material", "material"), &SpineSlotNode::set_screen_material);
ClassDB::bind_method(D_METHOD("get_screen_material"), &SpineSlotNode::get_screen_material);
ADD_GROUP("Materials", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_normal_material", "get_normal_material");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "additive_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_additive_material", "get_additive_material");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiply_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_multiply_material", "get_multiply_material");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "screen_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_screen_material", "get_screen_material");
ADD_GROUP("Materials", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_normal_material", "get_normal_material");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "additive_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_additive_material", "get_additive_material");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiply_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_multiply_material", "get_multiply_material");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "screen_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_screen_material", "get_screen_material");
}
SpineSlotNode::SpineSlotNode(): slot_index(-1) {
SpineSlotNode::SpineSlotNode() : slot_index(-1) {
}
void SpineSlotNode::_notification(int what) {
switch(what) {
case NOTIFICATION_PARENTED: {
SpineSprite *sprite = cast_to<SpineSprite>(get_parent());
if (sprite) {
switch (what) {
case NOTIFICATION_PARENTED: {
SpineSprite *sprite = cast_to<SpineSprite>(get_parent());
if (sprite) {
#if VERSION_MAJOR > 3
sprite->connect("world_transforms_changed", callable_mp(this, &SpineSlotNode::on_world_transforms_changed));
sprite->connect("world_transforms_changed", callable_mp(this, &SpineSlotNode::on_world_transforms_changed));
#else
sprite->connect("world_transforms_changed", this, "_on_world_transforms_changed");
sprite->connect("world_transforms_changed", this, "_on_world_transforms_changed");
#endif
update_transform(sprite);
update_transform(sprite);
#if VERSION_MAJOR == 3
_change_notify("transform/translation");
_change_notify("transform/rotation");
_change_notify("transform/scale");
_change_notify("translation");
_change_notify("rotation");
_change_notify("rotation_deg");
_change_notify("scale");
_change_notify("transform/translation");
_change_notify("transform/rotation");
_change_notify("transform/scale");
_change_notify("translation");
_change_notify("rotation");
_change_notify("rotation_deg");
_change_notify("scale");
#endif
} else {
WARN_PRINT("SpineSlotNode parent is not a SpineSprite.");
}
NOTIFY_PROPERTY_LIST_CHANGED();
break;
}
case NOTIFICATION_UNPARENTED: {
SpineSprite *sprite = cast_to<SpineSprite>(get_parent());
if (sprite) {
} else {
WARN_PRINT("SpineSlotNode parent is not a SpineSprite.");
}
NOTIFY_PROPERTY_LIST_CHANGED();
break;
}
case NOTIFICATION_UNPARENTED: {
SpineSprite *sprite = cast_to<SpineSprite>(get_parent());
if (sprite) {
#if VERSION_MAJOR > 3
sprite->disconnect("world_transforms_changed", callable_mp(this, &SpineSlotNode::on_world_transforms_changed));
sprite->disconnect("world_transforms_changed", callable_mp(this, &SpineSlotNode::on_world_transforms_changed));
#else
sprite->disconnect("world_transforms_changed", this, "_on_world_transforms_changed");
sprite->disconnect("world_transforms_changed", this, "_on_world_transforms_changed");
#endif
}
break;
}
default:
break;
}
}
break;
}
default:
break;
}
}
void SpineSlotNode::_get_property_list(List<PropertyInfo>* list) const {
Vector<String> slot_names;
SpineSprite *sprite = cast_to<SpineSprite>(get_parent());
if (sprite) sprite->get_skeleton_data_res()->get_slot_names(slot_names);
else slot_names.push_back(slot_name);
auto element = list->front();
while (element) {
auto property_info = element->get();
if (property_info.name == "SpineSlotNode") break;
element = element->next();
}
PropertyInfo slot_name_property;
slot_name_property.name = "slot_name";
slot_name_property.type = Variant::STRING;
slot_name_property.hint_string = String(",").join(slot_names);
slot_name_property.hint = PROPERTY_HINT_ENUM;
slot_name_property.usage = PROPERTY_USAGE_DEFAULT;
list->insert_after(element, slot_name_property);
void SpineSlotNode::_get_property_list(List<PropertyInfo> *list) const {
Vector<String> slot_names;
SpineSprite *sprite = cast_to<SpineSprite>(get_parent());
if (sprite) sprite->get_skeleton_data_res()->get_slot_names(slot_names);
else
slot_names.push_back(slot_name);
auto element = list->front();
while (element) {
auto property_info = element->get();
if (property_info.name == "SpineSlotNode") break;
element = element->next();
}
PropertyInfo slot_name_property;
slot_name_property.name = "slot_name";
slot_name_property.type = Variant::STRING;
slot_name_property.hint_string = String(",").join(slot_names);
slot_name_property.hint = PROPERTY_HINT_ENUM;
slot_name_property.usage = PROPERTY_USAGE_DEFAULT;
list->insert_after(element, slot_name_property);
}
bool SpineSlotNode::_get(const StringName& property, Variant& value) const {
if (property == "slot_name") {
value = slot_name;
return true;
}
return false;
bool SpineSlotNode::_get(const StringName &property, Variant &value) const {
if (property == "slot_name") {
value = slot_name;
return true;
}
return false;
}
bool SpineSlotNode::_set(const StringName& property, const Variant& value) {
if (property == "slot_name") {
slot_name = value;
SpineSprite *sprite = cast_to<SpineSprite>(get_parent());
update_transform(sprite);
bool SpineSlotNode::_set(const StringName &property, const Variant &value) {
if (property == "slot_name") {
slot_name = value;
SpineSprite *sprite = cast_to<SpineSprite>(get_parent());
update_transform(sprite);
#if VERSION_MAJOR == 3
_change_notify("transform/translation");
_change_notify("transform/rotation");
_change_notify("transform/scale");
_change_notify("translation");
_change_notify("rotation");
_change_notify("rotation_deg");
_change_notify("scale");
_change_notify("transform/translation");
_change_notify("transform/rotation");
_change_notify("transform/scale");
_change_notify("translation");
_change_notify("rotation");
_change_notify("rotation_deg");
_change_notify("scale");
#endif
return true;
}
return false;
return true;
}
return false;
}
void SpineSlotNode::on_world_transforms_changed(const Variant& _sprite) {
SpineSprite* sprite = cast_to<SpineSprite>(_sprite.operator Object*());
update_transform(sprite);
void SpineSlotNode::on_world_transforms_changed(const Variant &_sprite) {
SpineSprite *sprite = cast_to<SpineSprite>(_sprite.operator Object *());
update_transform(sprite);
}
void SpineSlotNode::update_transform(SpineSprite *sprite) {
if (!is_visible_in_tree()) return;
if (!sprite) return;
if (!sprite->get_skeleton().is_valid() || !sprite->get_skeleton()->get_spine_object()) return;
auto slot = sprite->get_skeleton()->find_slot(slot_name);
if (!slot.is_valid()) {
slot_index = -1;
return;
} else {
slot_index = slot->get_data()->get_index();
}
auto bone = slot->get_bone();
if (!bone.is_valid()) return;
this->set_global_transform(bone->get_global_transform());
if (!is_visible_in_tree()) return;
if (!sprite) return;
if (!sprite->get_skeleton().is_valid() || !sprite->get_skeleton()->get_spine_object()) return;
auto slot = sprite->get_skeleton()->find_slot(slot_name);
if (!slot.is_valid()) {
slot_index = -1;
return;
} else {
slot_index = slot->get_data()->get_index();
}
auto bone = slot->get_bone();
if (!bone.is_valid()) return;
this->set_global_transform(bone->get_global_transform());
}
void SpineSlotNode::set_slot_name(const String& _slot_name) {
slot_name = _slot_name;
void SpineSlotNode::set_slot_name(const String &_slot_name) {
slot_name = _slot_name;
}
String SpineSlotNode::get_slot_name() {
return slot_name;
return slot_name;
}
Ref<Material> SpineSlotNode::get_normal_material() {
return normal_material;
return normal_material;
}
void SpineSlotNode::set_normal_material(Ref<Material> material) {
normal_material = material;
normal_material = material;
}
Ref<Material> SpineSlotNode::get_additive_material() {
return additive_material;
return additive_material;
}
void SpineSlotNode::set_additive_material(Ref<Material> material) {
additive_material = material;
additive_material = material;
}
Ref<Material> SpineSlotNode::get_multiply_material() {
return multiply_material;
return multiply_material;
}
void SpineSlotNode::set_multiply_material(Ref<Material> material) {
multiply_material = material;
multiply_material = material;
}
Ref<Material> SpineSlotNode::get_screen_material() {
return screen_material;
return screen_material;
}
void SpineSlotNode::set_screen_material(Ref<Material> material) {
screen_material = material;
screen_material = material;
}

View File

@ -33,46 +33,47 @@
#include "SpineSprite.h"
#include "scene/2d/node_2d.h"
class SpineSlotNode: public Node2D {
GDCLASS(SpineSlotNode, Node2D)
class SpineSlotNode : public Node2D {
GDCLASS(SpineSlotNode, Node2D)
protected:
String slot_name;
int slot_index;
Ref<Material> normal_material;
Ref<Material> additive_material;
Ref<Material> multiply_material;
Ref<Material> screen_material;
String slot_name;
int slot_index;
Ref<Material> normal_material;
Ref<Material> additive_material;
Ref<Material> multiply_material;
Ref<Material> screen_material;
static void _bind_methods();
void _notification(int what);
void _get_property_list(List<PropertyInfo> *list) const;
bool _get(const StringName &property, Variant &value) const;
bool _set(const StringName &property, const Variant &value);
void on_world_transforms_changed(const Variant &_sprite);
void update_transform(SpineSprite *sprite);
static void _bind_methods();
void _notification(int what);
void _get_property_list(List<PropertyInfo> *list) const;
bool _get(const StringName &property, Variant &value) const;
bool _set(const StringName &property, const Variant &value);
void on_world_transforms_changed(const Variant &_sprite);
void update_transform(SpineSprite *sprite);
public:
SpineSlotNode();
SpineSlotNode();
void set_slot_name(const String &_slot_name);
void set_slot_name(const String &_slot_name);
String get_slot_name();
String get_slot_name();
int get_slot_index() { return slot_index; }
int get_slot_index() { return slot_index; }
Ref<Material> get_normal_material();
Ref<Material> get_normal_material();
void set_normal_material(Ref<Material> material);
void set_normal_material(Ref<Material> material);
Ref<Material> get_additive_material();
Ref<Material> get_additive_material();
void set_additive_material(Ref<Material> material);
void set_additive_material(Ref<Material> material);
Ref<Material> get_multiply_material();
Ref<Material> get_multiply_material();
void set_multiply_material(Ref<Material> material);
void set_multiply_material(Ref<Material> material);
Ref<Material> get_screen_material();
Ref<Material> get_screen_material();
void set_screen_material(Ref<Material> material);
void set_screen_material(Ref<Material> material);
};

View File

@ -105,7 +105,7 @@ void SpineSprite::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_debug_clipping"), &SpineSprite::get_debug_clipping);
ClassDB::bind_method(D_METHOD("set_debug_clipping_color", "v"), &SpineSprite::set_debug_clipping_color);
ClassDB::bind_method(D_METHOD("get_debug_clipping_color"), &SpineSprite::get_debug_clipping_color);
ClassDB::bind_method(D_METHOD("update_skeleton", "delta"), &SpineSprite::update_skeleton);
ClassDB::bind_method(D_METHOD("new_skin", "name"), &SpineSprite::new_skin);
@ -128,7 +128,7 @@ void SpineSprite::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "additive_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_additive_material", "get_additive_material");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiply_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_multiply_material", "get_multiply_material");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "screen_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_screen_material", "get_screen_material");
ADD_GROUP("Debug", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bones"), "set_debug_bones", "get_debug_bones");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "bones_color"), "set_debug_bones_color", "get_debug_bones_color");
@ -196,7 +196,7 @@ SpineSprite::SpineSprite() : update_mode(SpineConstant::UpdateMode_Process), pre
debug_paths_color = Color::hex(0xff7f0077);
debug_clipping = false;
debug_clipping_color = Color(0.8, 0, 0, 0.8);
sprite_count++;
}
@ -258,7 +258,7 @@ void SpineSprite::on_skeleton_data_changed() {
void SpineSprite::generate_meshes_for_slots(Ref<SpineSkeleton> skeleton_ref) {
auto skeleton = skeleton_ref->get_spine_object();
for (int i = 0, n = (int)skeleton->getSlots().size(); i < n; i++) {
for (int i = 0, n = (int) skeleton->getSlots().size(); i < n; i++) {
auto mesh_instance = memnew(MeshInstance2D);
mesh_instance->set_position(Vector2(0, 0));
mesh_instance->set_material(default_materials[spine::BlendMode_Normal]);
@ -266,7 +266,7 @@ void SpineSprite::generate_meshes_for_slots(Ref<SpineSkeleton> skeleton_ref) {
mesh_instance->set_draw_behind_parent(true);
add_child(mesh_instance);
mesh_instances.push_back(mesh_instance);
slot_nodes.add(spine::Vector<SpineSlotNode*>());
slot_nodes.add(spine::Vector<SpineSlotNode *>());
}
}
@ -280,10 +280,10 @@ void SpineSprite::remove_meshes() {
}
void SpineSprite::sort_slot_nodes() {
for (int i = 0; i < (int)slot_nodes.size(); i++) {
for (int i = 0; i < (int) slot_nodes.size(); i++) {
slot_nodes[i].setSize(0, nullptr);
}
auto draw_order = skeleton->get_spine_object()->getDrawOrder();
for (int i = 0; i < get_child_count(); i++) {
auto child = cast_to<Node2D>(get_child(i));
@ -292,17 +292,17 @@ void SpineSprite::sort_slot_nodes() {
child->set_draw_behind_parent(true);
auto slot_node = Object::cast_to<SpineSlotNode>(get_child(i));
if (!slot_node) continue;
if (slot_node->get_slot_index() == -1 || slot_node->get_slot_index() >= (int)draw_order.size()) {
if (slot_node->get_slot_index() == -1 || slot_node->get_slot_index() >= (int) draw_order.size()) {
continue;
}
slot_nodes[slot_node->get_slot_index()].add(slot_node);
}
for (int i = 0; i < (int)draw_order.size(); i++) {
for (int i = 0; i < (int) draw_order.size(); i++) {
int slot_index = draw_order[i]->getData().getIndex();
int mesh_index = mesh_instances[i]->get_index();
spine::Vector<SpineSlotNode*> &nodes = slot_nodes[slot_index];
for (int j = 0; j < (int)nodes.size(); j++) {
spine::Vector<SpineSlotNode *> &nodes = slot_nodes[slot_index];
for (int j = 0; j < (int) nodes.size(); j++) {
auto node = nodes[j];
move_child(node, mesh_index + 1);
}
@ -343,13 +343,13 @@ void SpineSprite::_notification(int what) {
}
}
void SpineSprite::_get_property_list(List<PropertyInfo>* list) const {
void SpineSprite::_get_property_list(List<PropertyInfo> *list) const {
if (!skeleton_data_res.is_valid() || !skeleton_data_res->is_skeleton_data_loaded()) return;
Vector<String> animation_names;
skeleton_data_res->get_animation_names(animation_names);
animation_names.insert(0, "-- Empty --");
PropertyInfo preview_anim_property;
PropertyInfo preview_anim_property;
preview_anim_property.name = "preview_animation";
preview_anim_property.type = Variant::STRING;
preview_anim_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE;
@ -357,13 +357,13 @@ void SpineSprite::_get_property_list(List<PropertyInfo>* list) const {
preview_anim_property.hint = PROPERTY_HINT_ENUM;
list->push_back(preview_anim_property);
PropertyInfo preview_frame_property;
PropertyInfo preview_frame_property;
preview_frame_property.name = "preview_frame";
preview_frame_property.type = Variant::BOOL;
preview_frame_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE;
list->push_back(preview_frame_property);
PropertyInfo preview_time_property;
PropertyInfo preview_time_property;
preview_time_property.name = "preview_time";
preview_time_property.type = VARIANT_FLOAT;
preview_time_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE;
@ -377,7 +377,7 @@ void SpineSprite::_get_property_list(List<PropertyInfo>* list) const {
list->push_back(preview_time_property);
}
bool SpineSprite::_get(const StringName& property, Variant& value) const {
bool SpineSprite::_get(const StringName &property, Variant &value) const {
if (property == "preview_animation") {
value = preview_animation;
return true;
@ -410,7 +410,7 @@ static void update_preview_animation(SpineSprite *sprite, const String &animatio
}
}
bool SpineSprite::_set(const StringName& property, const Variant& value) {
bool SpineSprite::_set(const StringName &property, const Variant &value) {
if (property == "preview_animation") {
preview_animation = value;
update_preview_animation(this, preview_animation, preview_frame, preview_time);
@ -429,7 +429,7 @@ bool SpineSprite::_set(const StringName& property, const Variant& value) {
update_preview_animation(this, preview_animation, preview_frame, preview_time);
return true;
}
return false;
}
@ -466,22 +466,22 @@ static void clear_mesh_instance(MeshInstance2D *mesh_instance) {
}
static void add_triangles(MeshInstance2D *mesh_instance,
const Vector<Point2> &vertices,
const Vector<Point2> &uvs,
const Vector<Color> &colors,
const Vector<int> &indices,
Ref<Texture> texture,
Ref<Texture> normal_map) {
const Vector<Point2> &vertices,
const Vector<Point2> &uvs,
const Vector<Color> &colors,
const Vector<int> &indices,
Ref<Texture> texture,
Ref<Texture> normal_map) {
#if VERSION_MAJOR > 3
RenderingServer::get_singleton()->canvas_item_add_triangle_array(mesh_instance->get_canvas_item(),
indices,
vertices,
colors,
uvs,
Vector<int>(),
Vector<float>(),
texture.is_null() ? RID() : texture->get_rid(),
-1);
indices,
vertices,
colors,
uvs,
Vector<int>(),
Vector<float>(),
texture.is_null() ? RID() : texture->get_rid(),
-1);
#else
VisualServer::get_singleton()->canvas_item_add_triangle_array(mesh_instance->get_canvas_item(),
indices,
@ -498,7 +498,7 @@ static void add_triangles(MeshInstance2D *mesh_instance,
void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
spine::Skeleton *skeleton = skeleton_ref->get_spine_object();
for (int i = 0, n = (int)skeleton->getSlots().size(); i < n; ++i) {
for (int i = 0, n = (int) skeleton->getSlots().size(); i < n; ++i) {
spine::Slot *slot = skeleton->getDrawOrder()[i];
spine::Attachment *attachment = slot->getAttachment();
MeshInstance2D *mesh_instance = mesh_instances[i];
@ -524,7 +524,7 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
auto renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) region->getRendererObject())->page->getRendererObject();
texture = renderer_object->texture;
normal_map = renderer_object->normal_map;
vertices->setSize(8, 0);
region->computeWorldVertices(*slot, *vertices, 0);
uvs = &region->getUVs();
@ -540,7 +540,7 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
auto renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) mesh->getRendererObject())->page->getRendererObject();
texture = renderer_object->texture;
normal_map = renderer_object->normal_map;
vertices->setSize(mesh->getWorldVerticesLength(), 0);
mesh->computeWorldVertices(*slot, *vertices);
uvs = &mesh->getUVs();
@ -571,19 +571,19 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
uvs = &skeleton_clipper->getClippedUVs();
indices = &skeleton_clipper->getClippedTriangles();
}
if (indices->size() > 0) {
size_t num_vertices = vertices->size() / 2;
scratch_points.resize((int)num_vertices);
scratch_points.resize((int) num_vertices);
memcpy(scratch_points.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float));
scratch_uvs.resize((int)num_vertices);
scratch_uvs.resize((int) num_vertices);
memcpy(scratch_uvs.ptrw(), uvs->buffer(), num_vertices * 2 * sizeof(float));
scratch_colors.resize((int)num_vertices);
for (int j = 0; j < (int)num_vertices; j++) {
scratch_colors.resize((int) num_vertices);
for (int j = 0; j < (int) num_vertices; j++) {
scratch_colors.set(j, Color(tint.r, tint.g, tint.b, tint.a));
}
scratch_indices.resize((int)indices->size());
for (int j = 0; j < (int)indices->size(); ++j) {
scratch_indices.resize((int) indices->size());
for (int j = 0; j < (int) indices->size(); ++j) {
scratch_indices.set(j, indices->buffer()[j]);
}
@ -598,10 +598,18 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
auto slot_node = nodes[0];
if (slot_node) {
switch (blend_mode) {
case spine::BlendMode_Normal: custom_material = slot_node->get_normal_material(); break;
case spine::BlendMode_Additive: custom_material = slot_node->get_additive_material(); break;
case spine::BlendMode_Multiply: custom_material = slot_node->get_multiply_material(); break;
case spine::BlendMode_Screen: custom_material = slot_node->get_screen_material(); break;
case spine::BlendMode_Normal:
custom_material = slot_node->get_normal_material();
break;
case spine::BlendMode_Additive:
custom_material = slot_node->get_additive_material();
break;
case spine::BlendMode_Multiply:
custom_material = slot_node->get_multiply_material();
break;
case spine::BlendMode_Screen:
custom_material = slot_node->get_screen_material();
break;
}
}
}
@ -609,16 +617,25 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
// Else, check if we have a material on the sprite itself
if (!custom_material.is_valid()) {
switch (blend_mode) {
case spine::BlendMode_Normal: custom_material = normal_material; break;
case spine::BlendMode_Additive: custom_material = additive_material; break;
case spine::BlendMode_Multiply: custom_material = multiply_material; break;
case spine::BlendMode_Screen: custom_material = screen_material; break;
case spine::BlendMode_Normal:
custom_material = normal_material;
break;
case spine::BlendMode_Additive:
custom_material = additive_material;
break;
case spine::BlendMode_Multiply:
custom_material = multiply_material;
break;
case spine::BlendMode_Screen:
custom_material = screen_material;
break;
}
}
// Set the custom material, or the default material
if (custom_material.is_valid()) mesh_instance->set_material(custom_material);
else mesh_instance->set_material(default_materials[slot->getData().getBlendMode()]);
else
mesh_instance->set_material(default_materials[slot->getData().getBlendMode()]);
}
skeleton_clipper->clipEnd(*slot);
}
@ -631,17 +648,17 @@ void SpineSprite::draw() {
auto mouse_position = get_local_mouse_position();
spine::Slot *hovered_slot = nullptr;
if (debug_regions) {
draw_set_transform(Vector2(0, 0), 0, Vector2(1, 1));
auto &draw_order = skeleton->get_spine_object()->getDrawOrder();
for (int i = 0; i < (int)draw_order.size(); i++) {
for (int i = 0; i < (int) draw_order.size(); i++) {
auto *slot = draw_order[i];
if (!slot->getBone().isActive()) continue;
auto *attachment = slot->getAttachment();
if (!attachment) continue;
if (!attachment->getRTTI().isExactly(spine::RegionAttachment::rtti)) continue;
auto *region = (spine::RegionAttachment*)attachment;
auto *region = (spine::RegionAttachment *) attachment;
auto *vertices = &scratch_vertices;
vertices->setSize(8, 0);
region->computeWorldVertices(*slot, *vertices, 0);
@ -666,13 +683,13 @@ void SpineSprite::draw() {
if (debug_meshes) {
draw_set_transform(Vector2(0, 0), 0, Vector2(1, 1));
auto &draw_order = skeleton->get_spine_object()->getDrawOrder();
for (int i = 0; i < (int)draw_order.size(); i++) {
for (int i = 0; i < (int) draw_order.size(); i++) {
auto *slot = draw_order[i];
if (!slot->getBone().isActive()) continue;
auto *attachment = slot->getAttachment();
if (!attachment) continue;
if (!attachment->getRTTI().isExactly(spine::MeshAttachment::rtti)) continue;
auto *mesh = (spine::MeshAttachment*)attachment;
auto *mesh = (spine::MeshAttachment *) attachment;
auto *vertices = &scratch_vertices;
vertices->setSize(mesh->getWorldVerticesLength(), 0);
mesh->computeWorldVertices(*slot, *vertices);
@ -682,7 +699,7 @@ void SpineSprite::draw() {
float y = vertices->buffer()[j + 1];
scratch_points.push_back(Vector2(x, y));
}
Color color = debug_meshes_color;
if (GEOMETRY2D::is_point_in_polygon(mouse_position, scratch_points)) {
hovered_slot = slot;
@ -696,18 +713,18 @@ void SpineSprite::draw() {
if (debug_bounding_boxes) {
draw_set_transform(Vector2(0, 0), 0, Vector2(1, 1));
auto &draw_order = skeleton->get_spine_object()->getDrawOrder();
for (int i = 0; i < (int)draw_order.size(); i++) {
for (int i = 0; i < (int) draw_order.size(); i++) {
auto *slot = draw_order[i];
if (!slot->getBone().isActive()) continue;
auto *attachment = slot->getAttachment();
if (!attachment) continue;
if (!attachment->getRTTI().isExactly(spine::BoundingBoxAttachment::rtti)) continue;
auto *bounding_box = (spine::BoundingBoxAttachment*)attachment;
auto *bounding_box = (spine::BoundingBoxAttachment *) attachment;
auto *vertices = &scratch_vertices;
vertices->setSize(bounding_box->getWorldVerticesLength(), 0);
bounding_box->computeWorldVertices(*slot, *vertices);
size_t num_vertices = vertices->size() / 2;
scratch_points.resize((int)num_vertices);
scratch_points.resize((int) num_vertices);
memcpy(scratch_points.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float));
scratch_points.push_back(Vector2(vertices->buffer()[0], vertices->buffer()[1]));
draw_polyline(scratch_points, debug_bounding_boxes_color, 2);
@ -717,18 +734,18 @@ void SpineSprite::draw() {
if (debug_clipping) {
draw_set_transform(Vector2(0, 0), 0, Vector2(1, 1));
auto &draw_order = skeleton->get_spine_object()->getDrawOrder();
for (int i = 0; i < (int)draw_order.size(); i++) {
for (int i = 0; i < (int) draw_order.size(); i++) {
auto *slot = draw_order[i];
if (!slot->getBone().isActive()) continue;
auto *attachment = slot->getAttachment();
if (!attachment) continue;
if (!attachment->getRTTI().isExactly(spine::ClippingAttachment::rtti)) continue;
auto *clipping = (spine::ClippingAttachment*)attachment;
auto *clipping = (spine::ClippingAttachment *) attachment;
auto *vertices = &scratch_vertices;
vertices->setSize(clipping->getWorldVerticesLength(), 0);
clipping->computeWorldVertices(*slot, *vertices);
size_t num_vertices = vertices->size() / 2;
scratch_points.resize((int)num_vertices);
scratch_points.resize((int) num_vertices);
memcpy(scratch_points.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float));
scratch_points.push_back(Vector2(vertices->buffer()[0], vertices->buffer()[1]));
draw_polyline(scratch_points, debug_clipping_color, 2);
@ -739,14 +756,14 @@ void SpineSprite::draw() {
spine::Bone *hovered_bone = nullptr;
if (debug_bones) {
auto &bones = skeleton->get_spine_object()->getBones();
for (int i = 0; i < (int)bones.size(); i++) {
for (int i = 0; i < (int) bones.size(); i++) {
auto *bone = bones[i];
if (!bone->isActive()) continue;
draw_bone(bone, debug_bones_color);
float bone_length = bone->getData().getLength();
if (bone_length == 0) bone_length = debug_bones_thickness * 2;
scratch_points.resize(5);
scratch_points.set(0, Vector2(-debug_bones_thickness, 0));
scratch_points.set(1, Vector2(0, debug_bones_thickness));
@ -778,7 +795,7 @@ void SpineSprite::draw() {
if (hovered_slot) {
hover_text_lines.push_back(String("Slot: ") + hovered_slot->getData().getName().buffer());
}
if (hovered_bone) {
float thickness = debug_bones_thickness;
debug_bones_thickness *= 1.1;
@ -786,7 +803,7 @@ void SpineSprite::draw() {
debug_bones_thickness = thickness;
hover_text_lines.push_back(String("Bone: ") + hovered_bone->getData().getName().buffer());
}
auto global_scale = get_global_scale();
draw_set_transform(mouse_position + Vector2(20, 0), -get_global_rotation(), Vector2(inverse_zoom * (1 / global_scale.x), inverse_zoom * (1 / global_scale.y)));
@ -796,18 +813,18 @@ void SpineSprite::draw() {
rect_width = MAX(rect_width, default_font->get_string_size(hover_text_lines[i]).x);
}
Rect2 background_rect(0, -default_font->get_height() - 5, rect_width + 20, line_height * hover_text_lines.size() + 10);
if (hover_text_lines.size() > 0) draw_rect(background_rect, Color(0, 0, 0 ,0.8));
if (hover_text_lines.size() > 0) draw_rect(background_rect, Color(0, 0, 0, 0.8));
for (int i = 0; i < hover_text_lines.size(); i++) {
#if VERSION_MAJOR > 3
draw_string(default_font, Vector2(10, 0 + i * default_font->get_height()), hover_text_lines[i], HORIZONTAL_ALIGNMENT_LEFT, -1, Font::DEFAULT_FONT_SIZE, Color (1, 1, 1, 1));
draw_string(default_font, Vector2(10, 0 + i * default_font->get_height()), hover_text_lines[i], HORIZONTAL_ALIGNMENT_LEFT, -1, Font::DEFAULT_FONT_SIZE, Color(1, 1, 1, 1));
#else
draw_string(default_font, Vector2(10, 0 + i * default_font->get_height()), hover_text_lines[i], Color (1, 1, 1, 1));
draw_string(default_font, Vector2(10, 0 + i * default_font->get_height()), hover_text_lines[i], Color(1, 1, 1, 1));
#endif
}
#endif
}
void SpineSprite::draw_bone(spine::Bone* bone, const Color &color) {
void SpineSprite::draw_bone(spine::Bone *bone, const Color &color) {
draw_set_transform(Vector2(bone->getWorldX(), bone->getWorldY()), Math::deg2rad(bone->getWorldRotationX()), Vector2(bone->getWorldScaleX(), bone->getWorldScaleY()));
float bone_length = bone->getData().getLength();
if (bone_length == 0) bone_length = debug_bones_thickness * 2;
@ -821,8 +838,8 @@ void SpineSprite::draw_bone(spine::Bone* bone, const Color &color) {
void SpineSprite::callback(spine::AnimationState *state, spine::EventType type, spine::TrackEntry *entry, spine::Event *event) {
Ref<SpineTrackEntry> entry_ref = Ref<SpineTrackEntry>(memnew(SpineTrackEntry));
entry_ref->set_spine_object(this, entry);
entry_ref->set_spine_object(this, entry);
Ref<SpineEvent> event_ref(nullptr);
if (event) {
event_ref = Ref<SpineEvent>(memnew(SpineEvent));
@ -878,7 +895,7 @@ void SpineSprite::set_update_mode(SpineConstant::UpdateMode v) {
set_physics_process_internal(update_mode == SpineConstant::UpdateMode_Physics);
}
Ref<SpineSkin> SpineSprite::new_skin(const String& name) {
Ref<SpineSkin> SpineSprite::new_skin(const String &name) {
Ref<SpineSkin> skin = memnew(SpineSkin);
skin->init(name, this);
return skin;

View File

@ -40,13 +40,13 @@ class SpineSprite : public Node2D, public spine::AnimationStateListenerObject {
GDCLASS(SpineSprite, Node2D)
friend class SpineBone;
protected:
Ref<SpineSkeletonDataResource> skeleton_data_res;
Ref<SpineSkeleton> skeleton;
Ref<SpineAnimationState> animation_state;
SpineConstant::UpdateMode update_mode;
String preview_animation;
bool preview_frame;
float preview_time;
@ -65,7 +65,7 @@ protected:
bool debug_clipping;
Color debug_clipping_color;
spine::Vector<spine::Vector<SpineSlotNode*> > slot_nodes;
spine::Vector<spine::Vector<SpineSlotNode *>> slot_nodes;
Vector<MeshInstance2D *> mesh_instances;
static Ref<CanvasItemMaterial> default_materials[4];
Ref<Material> normal_material;
@ -74,7 +74,7 @@ protected:
Ref<Material> screen_material;
spine::SkeletonClipping *skeleton_clipper;
bool modified_bones;
static void _bind_methods();
void _notification(int what);
void _get_property_list(List<PropertyInfo> *list) const;
@ -96,11 +96,11 @@ public:
~SpineSprite();
void set_skeleton_data_res(const Ref<SpineSkeletonDataResource> &_spine_skeleton_data_resource);
Ref<SpineSkeletonDataResource> get_skeleton_data_res();
Ref<SpineSkeleton> get_skeleton();
Ref<SpineAnimationState> get_animation_state();
void on_skeleton_data_changed();
@ -110,7 +110,7 @@ public:
Transform2D get_global_bone_transform(const String &bone_name);
void set_global_bone_transform(const String &bone_name, Transform2D transform);
SpineConstant::UpdateMode get_update_mode();
void set_update_mode(SpineConstant::UpdateMode v);
@ -135,7 +135,7 @@ public:
bool get_debug_bones() { return debug_bones; }
void set_debug_bones (bool bones) { debug_bones = bones; }
void set_debug_bones(bool bones) { debug_bones = bones; }
Color get_debug_bones_color() { return debug_bones_color; }
@ -168,7 +168,7 @@ public:
Color get_debug_paths_color() { return debug_paths_color; }
void set_debug_paths_color(const Color &color) { debug_paths_color = color; }
bool get_debug_bounding_boxes() { return debug_bounding_boxes; }
void set_debug_bounding_boxes(bool paths) { debug_bounding_boxes = paths; }

View File

@ -46,10 +46,10 @@ void SpineTimeline::_bind_methods() {
void SpineTimeline::apply(Ref<SpineSkeleton> skeleton, float last_time, float time, Array events, float alpha,
SpineConstant::MixBlend blend, SpineConstant::MixDirection direction) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
if (!skeleton->get_spine_object()) return;
spine::Vector<spine::Event *> spine_events;
spine_events.setSize((int)events.size(), nullptr);
spine_events.setSize((int) events.size(), nullptr);
for (int i = 0; i < events.size(); ++i) {
events[i] = ((Ref<SpineEvent>) spine_events[i])->get_spine_object();
}
@ -58,19 +58,19 @@ void SpineTimeline::apply(Ref<SpineSkeleton> skeleton, float last_time, float ti
int SpineTimeline::get_frame_entries() {
SPINE_CHECK(get_spine_object(), 0)
return (int)get_spine_object()->getFrameEntries();
return (int) get_spine_object()->getFrameEntries();
}
int SpineTimeline::get_frame_count() {
SPINE_CHECK(get_spine_object(), 0)
return (int)get_spine_object()->getFrameCount();
return (int) get_spine_object()->getFrameCount();
}
Array SpineTimeline::get_frames() {
Array result;
SPINE_CHECK(get_spine_object(), result)
auto &frames = get_spine_object()->getFrames();
result.resize((int)frames.size());
result.resize((int) frames.size());
for (int i = 0; i < result.size(); ++i) {
result[i] = frames[i];
}
@ -86,7 +86,7 @@ Array SpineTimeline::get_property_ids() {
Array result;
SPINE_CHECK(get_spine_object(), result)
auto &ids = get_spine_object()->getPropertyIds();
result.resize((int)ids.size());
result.resize((int) ids.size());
for (int i = 0; i < result.size(); ++i) {
result[i] = (spine::PropertyId) ids[i];
}

View File

@ -108,7 +108,7 @@ bool SpineTrackEntry::get_loop() {
}
void SpineTrackEntry::set_loop(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setLoop(v);
}
@ -118,7 +118,7 @@ bool SpineTrackEntry::get_hold_previous() {
}
void SpineTrackEntry::set_hold_previous(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setHoldPrevious(v);
}
@ -128,17 +128,17 @@ bool SpineTrackEntry::get_reverse() {
}
void SpineTrackEntry::set_reverse(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setReverse(v);
}
bool SpineTrackEntry::get_shortest_rotation() {
bool SpineTrackEntry::get_shortest_rotation() {
SPINE_CHECK(get_spine_object(), false)
return get_spine_object()->getShortestRotation();
}
void SpineTrackEntry::set_shortest_rotation(bool v) {
SPINE_CHECK(get_spine_object(),)
void SpineTrackEntry::set_shortest_rotation(bool v) {
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setShortestRotation(v);
}
@ -148,7 +148,7 @@ float SpineTrackEntry::get_delay() {
}
void SpineTrackEntry::set_delay(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setDelay(v);
}
@ -158,7 +158,7 @@ float SpineTrackEntry::get_track_time() {
}
void SpineTrackEntry::set_track_time(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setTrackTime(v);
}
@ -168,7 +168,7 @@ float SpineTrackEntry::get_track_end() {
}
void SpineTrackEntry::set_track_end(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setTrackEnd(v);
}
@ -178,7 +178,7 @@ float SpineTrackEntry::get_animation_start() {
}
void SpineTrackEntry::set_animation_start(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAnimationStart(v);
}
@ -188,7 +188,7 @@ float SpineTrackEntry::get_animation_end() {
}
void SpineTrackEntry::set_animation_end(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAnimationEnd(v);
}
@ -198,7 +198,7 @@ float SpineTrackEntry::get_animation_last() {
}
void SpineTrackEntry::set_animation_last(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAnimationLast(v);
}
@ -213,7 +213,7 @@ float SpineTrackEntry::get_time_scale() {
}
void SpineTrackEntry::set_time_scale(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setTimeScale(v);
}
@ -223,7 +223,7 @@ float SpineTrackEntry::get_alpha() {
}
void SpineTrackEntry::set_alpha(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAlpha(v);
}
@ -233,7 +233,7 @@ float SpineTrackEntry::get_event_threshold() {
}
void SpineTrackEntry::set_event_threshold(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setEventThreshold(v);
}
@ -243,7 +243,7 @@ float SpineTrackEntry::get_attachment_threshold() {
}
void SpineTrackEntry::set_attachment_threshold(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setAttachmentThreshold(v);
}
@ -253,7 +253,7 @@ float SpineTrackEntry::get_draw_order_threshold() {
}
void SpineTrackEntry::set_draw_order_threshold(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setDrawOrderThreshold(v);
}
@ -277,7 +277,7 @@ float SpineTrackEntry::get_mix_time() {
}
void SpineTrackEntry::set_mix_time(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixTime(v);
}
@ -287,17 +287,17 @@ float SpineTrackEntry::get_mix_duration() {
}
void SpineTrackEntry::set_mix_duration(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixDuration(v);
}
SpineConstant::MixBlend SpineTrackEntry::get_mix_blend() {
SPINE_CHECK(get_spine_object(), SpineConstant::MixBlend_Setup)
return (SpineConstant::MixBlend)get_spine_object()->getMixBlend();
return (SpineConstant::MixBlend) get_spine_object()->getMixBlend();
}
void SpineTrackEntry::set_mix_blend(SpineConstant::MixBlend v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixBlend((spine::MixBlend) v);
}
@ -320,7 +320,7 @@ Ref<SpineTrackEntry> SpineTrackEntry::get_mixing_to() {
}
void SpineTrackEntry::reset_rotation_directions() {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->resetRotationDirections();
}

View File

@ -54,7 +54,7 @@ void SpineTransformConstraint::_bind_methods() {
}
void SpineTransformConstraint::update() {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->update();
}
@ -75,7 +75,7 @@ Array SpineTransformConstraint::get_bones() {
Array result;
SPINE_CHECK(get_spine_object(), result)
auto &bones = get_spine_object()->getBones();
result.resize((int)bones.size());
result.resize((int) bones.size());
for (int i = 0; i < bones.size(); ++i) {
auto bone = bones[i];
Ref<SpineBone> bone_ref(memnew(SpineBone));
@ -95,7 +95,7 @@ Ref<SpineBone> SpineTransformConstraint::get_target() {
}
void SpineTransformConstraint::set_target(Ref<SpineBone> v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setTarget(v.is_valid() && v->get_spine_object() ? v->get_spine_object() : nullptr);
}
@ -105,7 +105,7 @@ float SpineTransformConstraint::get_mix_rotate() {
}
void SpineTransformConstraint::set_mix_rotate(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixRotate(v);
}
@ -115,7 +115,7 @@ float SpineTransformConstraint::get_mix_x() {
}
void SpineTransformConstraint::set_mix_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixX(v);
}
@ -125,7 +125,7 @@ float SpineTransformConstraint::get_mix_y() {
}
void SpineTransformConstraint::set_mix_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixY(v);
}
@ -135,7 +135,7 @@ float SpineTransformConstraint::get_mix_scale_x() {
}
void SpineTransformConstraint::set_mix_scale_x(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixScaleX(v);
}
@ -145,7 +145,7 @@ float SpineTransformConstraint::get_mix_scale_y() {
}
void SpineTransformConstraint::set_mix_scale_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixScaleY(v);
}
@ -155,7 +155,7 @@ float SpineTransformConstraint::get_mix_shear_y() {
}
void SpineTransformConstraint::set_mix_shear_y(float v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setMixShearY(v);
}
@ -165,6 +165,6 @@ bool SpineTransformConstraint::is_active() {
}
void SpineTransformConstraint::set_active(bool v) {
SPINE_CHECK(get_spine_object(),)
SPINE_CHECK(get_spine_object(), )
get_spine_object()->setActive(v);
}

View File

@ -53,8 +53,8 @@ Array SpineTransformConstraintData::get_bones() {
Array result;
SPINE_CHECK(get_spine_constraint_data(), result)
auto bones = get_spine_constraint_data()->getBones();
result.resize((int)bones.size());
for (int i = 0; i < (int)bones.size(); ++i) {
result.resize((int) bones.size());
for (int i = 0; i < (int) bones.size(); ++i) {
Ref<SpineBoneData> bone_ref(memnew(SpineBoneData));
bone_ref->set_spine_object(get_spine_owner(), bones[i]);
result[i] = bone_ref;

View File

@ -78,7 +78,7 @@ void register_spine_godot_types() {
GDREGISTER_CLASS(SpineEditorPropertyAnimationMixes);
#endif
spine::Bone::setYDown(true);
GDREGISTER_CLASS(SpineAtlasResource);
GDREGISTER_CLASS(SpineSkeletonFileResource);
GDREGISTER_CLASS(SpineSkeletonDataResource);
@ -106,7 +106,7 @@ void register_spine_godot_types() {
GDREGISTER_CLASS(SpineTransformConstraint);
GDREGISTER_CLASS(SpineTimeline);
GDREGISTER_CLASS(SpineConstant);
GDREGISTER_CLASS(SpineSlotNode);
GDREGISTER_CLASS(SpineBoneNode);
GDREGISTER_CLASS(SpineAnimationTrack);