[godot] Fix all clang-tidy issues.

This commit is contained in:
Mario Zechner 2022-04-20 15:10:00 +02:00
parent e0d4fbc34a
commit 2ec5d44ed3
24 changed files with 120 additions and 143 deletions

View File

@ -36,9 +36,6 @@ spine::SpineExtension *spine::getDefaultExtension() {
return new GodotSpineExtension(); return new GodotSpineExtension();
} }
GodotSpineExtension::GodotSpineExtension() {}
GodotSpineExtension::~GodotSpineExtension() {}
void *GodotSpineExtension::_alloc(size_t size, const char *file, int line) { void *GodotSpineExtension::_alloc(size_t size, const char *file, int line) {
return memalloc(size); return memalloc(size);
} }

View File

@ -33,11 +33,6 @@
#include <spine/Extension.h> #include <spine/Extension.h>
class GodotSpineExtension : public spine::SpineExtension { class GodotSpineExtension : public spine::SpineExtension {
public:
GodotSpineExtension();
virtual ~GodotSpineExtension();
protected: protected:
virtual void *_alloc(size_t size, const char *file, int line); virtual void *_alloc(size_t size, const char *file, int line);

View File

@ -50,7 +50,7 @@ protected:
public: public:
SpineAnimation(); SpineAnimation();
void set_spine_object(spine::Animation *animation) { this->animation = animation; } void set_spine_object(spine::Animation *_animation) { this->animation = _animation; }
spine::Animation *get_spine_object() { return animation; } spine::Animation *get_spine_object() { return animation; }

View File

@ -54,7 +54,7 @@ SpineAnimationState::~SpineAnimationState() {
delete animation_state; delete animation_state;
} }
void SpineAnimationState::set_skeleton_data_res(Ref<SpineSkeletonDataResource> data_res) { void SpineAnimationState::set_skeleton_data_res(const Ref<SpineSkeletonDataResource> &data_res) {
delete animation_state; delete animation_state;
animation_state = nullptr; animation_state = nullptr;
skeleton_data_res = data_res; skeleton_data_res = data_res;
@ -62,10 +62,6 @@ void SpineAnimationState::set_skeleton_data_res(Ref<SpineSkeletonDataResource> d
animation_state = new spine::AnimationState(skeleton_data_res->get_animation_state_data()); animation_state = new spine::AnimationState(skeleton_data_res->get_animation_state_data());
} }
Ref<SpineSkeletonDataResource> SpineAnimationState::get_skeleton_data_res() const {
return skeleton_data_res;
}
void SpineAnimationState::update(float delta) { void SpineAnimationState::update(float delta) {
SPINE_CHECK(animation_state,) SPINE_CHECK(animation_state,)
animation_state->update(delta); animation_state->update(delta);

View File

@ -49,9 +49,7 @@ public:
spine::AnimationState *get_spine_object() { return animation_state; } spine::AnimationState *get_spine_object() { return animation_state; }
void set_skeleton_data_res(Ref<SpineSkeletonDataResource> skeleton_data_res); void set_skeleton_data_res(const Ref<SpineSkeletonDataResource> &skeleton_data_res);
Ref<SpineSkeletonDataResource> get_skeleton_data_res() const;
void update(float delta); void update(float delta);

View File

@ -43,7 +43,7 @@ public:
GodotSpineTextureLoader(Array *_textures, Array *_normal_maps, const String &normal_map_prefix) : textures(_textures), normal_maps(_normal_maps), normal_map_prefix(normal_map_prefix) { GodotSpineTextureLoader(Array *_textures, Array *_normal_maps, const String &normal_map_prefix) : textures(_textures), normal_maps(_normal_maps), normal_map_prefix(normal_map_prefix) {
} }
String fix_path(const String &path) { static String fix_path(const String &path) {
if (path.size() > 5 && path[4] == '/' && path[5] == '/') return path; if (path.size() > 5 && path[4] == '/' && path[5] == '/') return path;
const String prefix = "res:/"; const String prefix = "res:/";
auto i = path.find(prefix); auto i = path.find(prefix);
@ -51,7 +51,7 @@ public:
if (sub_str_pos < 0) return path; if (sub_str_pos < 0) return path;
auto res = path.substr(sub_str_pos); auto res = path.substr(sub_str_pos);
if (res.size() > 0) { if (!res.empty()) {
if (res[0] != '/') { if (res[0] != '/') {
return prefix + "/" + res; return prefix + "/" + res;
} else { } else {
@ -61,7 +61,7 @@ public:
return path; return path;
} }
virtual void load(spine::AtlasPage &page, const spine::String &path) { void load(spine::AtlasPage &page, const spine::String &path) override {
Error error = OK; Error error = OK;
auto fixed_path = fix_path(String(path.buffer())); auto fixed_path = fix_path(String(path.buffer()));
@ -80,8 +80,7 @@ public:
renderer_object->texture = texture; renderer_object->texture = texture;
renderer_object->normal_map = Ref<Texture>(nullptr); renderer_object->normal_map = Ref<Texture>(nullptr);
String temp_path = fixed_path; String new_path = vformat("%s/%s_%s", fixed_path.get_base_dir(), normal_map_prefix, fixed_path.get_file());
String new_path = vformat("%s/%s_%s", temp_path.get_base_dir(), normal_map_prefix, temp_path.get_file());
if (ResourceLoader::exists(new_path)) { if (ResourceLoader::exists(new_path)) {
Ref<Texture> normal_map = ResourceLoader::load(new_path); Ref<Texture> normal_map = ResourceLoader::load(new_path);
normal_maps->append(normal_map); normal_maps->append(normal_map);
@ -93,7 +92,7 @@ public:
page.height = texture->get_height(); page.height = texture->get_height();
} }
virtual void unload(void *data) { void unload(void *data) override {
auto renderer_object = (SpineRendererObject *) data; auto renderer_object = (SpineRendererObject *) data;
Ref<Texture> &texture = renderer_object->texture; Ref<Texture> &texture = renderer_object->texture;
if (texture.is_valid()) texture.unref(); if (texture.is_valid()) texture.unref();
@ -159,16 +158,15 @@ Error SpineAtlasResource::load_from_atlas_file(const String &path) {
} }
Error SpineAtlasResource::load_from_file(const String &path) { Error SpineAtlasResource::load_from_file(const String &path) {
Error err; Error error;
String json_string = FileAccess::get_file_as_string(path, &err); String json_string = FileAccess::get_file_as_string(path, &error);
if (err != OK) return err; if (error != OK) return error;
String error_string; String error_string;
int error_line; int error_line;
JSON json;
Variant result; Variant result;
err = json.parse(json_string, result, error_string, error_line); error = JSON::parse(json_string, result, error_string, error_line);
if (err != OK) return err; if (error != OK) return error;
Dictionary content = Dictionary(result); Dictionary content = Dictionary(result);
source_path = content["source_path"]; source_path = content["source_path"];

View File

@ -57,10 +57,7 @@ protected:
public: public:
SpineAtlasResource(); SpineAtlasResource();
~SpineAtlasResource() override;
virtual ~SpineAtlasResource();
String &get_atlas_data() { return atlas_data; }
spine::Atlas *get_spine_atlas() { return atlas; } spine::Atlas *get_spine_atlas() { return atlas; }
@ -83,20 +80,20 @@ class SpineAtlasResourceFormatLoader : public ResourceFormatLoader {
GDCLASS(SpineAtlasResourceFormatLoader, ResourceFormatLoader) GDCLASS(SpineAtlasResourceFormatLoader, ResourceFormatLoader)
public: public:
virtual RES load(const String &path, const String &original_path, Error *error = nullptr); RES load(const String &path, const String &original_path, Error *error) override;
virtual void get_recognized_extensions(List<String> *extensions) const; void get_recognized_extensions(List<String> *extensions) const override;
virtual bool handles_type(const String &type) const; bool handles_type(const String &type) const override;
virtual String get_resource_type(const String &path) const; String get_resource_type(const String &path) const override;
}; };
class SpineAtlasResourceFormatSaver : public ResourceFormatSaver { class SpineAtlasResourceFormatSaver : public ResourceFormatSaver {
GDCLASS(SpineAtlasResourceFormatSaver, ResourceFormatSaver) GDCLASS(SpineAtlasResourceFormatSaver, ResourceFormatSaver)
public: public:
Error save(const String &path, const RES &resource, uint32_t flags = 0) override; Error save(const String &path, const RES &resource, uint32_t flags) override;
void get_recognized_extensions(const RES &resource, List<String> *extensions) const override; void get_recognized_extensions(const RES &resource, List<String> *extensions) const override;

View File

@ -44,7 +44,7 @@ private:
public: public:
SpineAttachment(); SpineAttachment();
~SpineAttachment(); ~SpineAttachment() override;
void set_spine_object(spine::Attachment *_attachment) { void set_spine_object(spine::Attachment *_attachment) {
attachment = _attachment; attachment = _attachment;

View File

@ -427,7 +427,7 @@ void SpineBone::set_active(bool v) {
} }
// External feature functions // External feature functions
void SpineBone::apply_world_transform_2d(Variant o) { void SpineBone::apply_world_transform_2d(const Variant &o) {
SPINE_CHECK(bone,) SPINE_CHECK(bone,)
if (o.get_type() == Variant::OBJECT) { if (o.get_type() == Variant::OBJECT) {
auto node = (Node *) o; auto node = (Node *) o;

View File

@ -175,7 +175,7 @@ public:
void set_active(bool v); void set_active(bool v);
// External feature functions // External feature functions
void apply_world_transform_2d(Variant o); void apply_world_transform_2d(const Variant &o);
Transform2D get_godot_transform(); Transform2D get_godot_transform();

View File

@ -124,13 +124,13 @@ void SpineEditorPropertyAnimationMixes::delete_mix(int64_t idx) {
if (!skeleton_data.is_valid() || !skeleton_data->is_skeleton_data_loaded() || updating) return; if (!skeleton_data.is_valid() || !skeleton_data->is_skeleton_data_loaded() || updating) return;
auto mixes = skeleton_data->get_animation_mixes().duplicate(); auto mixes = skeleton_data->get_animation_mixes().duplicate();
mixes.remove(idx); mixes.remove((int)idx);
emit_changed(get_edited_property(), mixes); emit_changed(get_edited_property(), mixes);
} }
void SpineEditorPropertyAnimationMixes::update_mix_property(int64_t index) { void SpineEditorPropertyAnimationMixes::update_mix_property(int64_t index) {
if (index < 0 || index > mix_properties.size()) return; if (index < 0 || index > mix_properties.size()) return;
mix_properties[index]->update_property(); mix_properties[(int)index]->update_property();
} }
void SpineEditorPropertyAnimationMixes::update_property() { void SpineEditorPropertyAnimationMixes::update_property() {
@ -191,20 +191,20 @@ void SpineEditorPropertyAnimationMixes::update_property() {
updating = false; updating = false;
} }
SpineEditorPropertyAnimationMix::SpineEditorPropertyAnimationMix(): skeleton_data(nullptr), container(nullptr), updating(false) { SpineEditorPropertyAnimationMix::SpineEditorPropertyAnimationMix(): mixes_property(nullptr), skeleton_data(nullptr), index(0), container(nullptr), updating(false) {
} }
void SpineEditorPropertyAnimationMix::setup(SpineEditorPropertyAnimationMixes *mixes_property, Ref<SpineSkeletonDataResource> skeleton_data, int index) { void SpineEditorPropertyAnimationMix::setup(SpineEditorPropertyAnimationMixes *_mixes_property, const Ref<SpineSkeletonDataResource> &_skeleton_data, int _index) {
this->mixes_property = mixes_property; this->mixes_property = _mixes_property;
this->skeleton_data = skeleton_data; this->skeleton_data = _skeleton_data;
this->index = index; this->index = _index;
} }
void SpineEditorPropertyAnimationMix::_bind_methods() { void SpineEditorPropertyAnimationMix::_bind_methods() {
ClassDB::bind_method(D_METHOD("data_changed"), &SpineEditorPropertyAnimationMix::data_changed); ClassDB::bind_method(D_METHOD("data_changed"), &SpineEditorPropertyAnimationMix::data_changed);
} }
void SpineEditorPropertyAnimationMix::data_changed(const String &property, Variant value, const String &name, bool changing) { void SpineEditorPropertyAnimationMix::data_changed(const String &property, const Variant &value, const String &name, bool changing) {
auto mix = Object::cast_to<SpineAnimationMix>(get_edited_object()->get(get_edited_property())); auto mix = Object::cast_to<SpineAnimationMix>(get_edited_object()->get(get_edited_property()));
UndoRedo *undo_redo = EditorNode::get_undo_redo(); UndoRedo *undo_redo = EditorNode::get_undo_redo();

View File

@ -118,8 +118,6 @@ public:
explicit SpineEditorPlugin(EditorNode *node); explicit SpineEditorPlugin(EditorNode *node);
String get_name() const override { return "SpineEditorPlugin"; } String get_name() const override { return "SpineEditorPlugin"; }
bool has_main_screen() const { return false; }
}; };
class SpineSkeletonDataResourceInspectorPlugin: public EditorInspectorPlugin { class SpineSkeletonDataResourceInspectorPlugin: public EditorInspectorPlugin {
@ -149,8 +147,8 @@ class SpineEditorPropertyAnimationMixes: public EditorProperty {
void update_mix_property(int64_t index); void update_mix_property(int64_t index);
public: public:
SpineEditorPropertyAnimationMixes(); SpineEditorPropertyAnimationMixes();
void setup(Ref<SpineSkeletonDataResource> skeleton_data) { this->skeleton_data = skeleton_data; }; void setup(const Ref<SpineSkeletonDataResource> &_skeleton_data) { this->skeleton_data = _skeleton_data; };
virtual void update_property(); void update_property() override;
}; };
class SpineEditorPropertyAnimationMix: public EditorProperty { class SpineEditorPropertyAnimationMix: public EditorProperty {
@ -163,11 +161,11 @@ class SpineEditorPropertyAnimationMix: public EditorProperty {
bool updating; bool updating;
static void _bind_methods(); static void _bind_methods();
void data_changed(const String &property, Variant value, const String &name, bool changing); void data_changed(const String &property, const Variant &value, const String &name, bool changing);
public: public:
SpineEditorPropertyAnimationMix(); SpineEditorPropertyAnimationMix();
void setup(SpineEditorPropertyAnimationMixes *mixes_property, Ref<SpineSkeletonDataResource> skeleton_data, int index); void setup(SpineEditorPropertyAnimationMixes *mixes_property, const Ref<SpineSkeletonDataResource> &skeleton_data, int index);
virtual void update_property(); void update_property() override;
}; };
#endif #endif

View File

@ -87,8 +87,8 @@ Ref<SpineSkeletonDataResource> SpineSkeleton::get_skeleton_data_res() const {
return skeleton_data_res; return skeleton_data_res;
} }
void SpineSkeleton::set_spine_sprite(SpineSprite* sprite) { void SpineSkeleton::set_spine_sprite(SpineSprite* _sprite) {
this->sprite = sprite; this->sprite = _sprite;
} }
void SpineSkeleton::update_world_transform() { void SpineSkeleton::update_world_transform() {

View File

@ -69,7 +69,7 @@ private:
public: public:
SpineSkeleton(); SpineSkeleton();
~SpineSkeleton(); ~SpineSkeleton() override;
void update_world_transform(); void update_world_transform();

View File

@ -47,24 +47,24 @@ void SpineAnimationMix::_bind_methods() {
SpineAnimationMix::SpineAnimationMix(): from(""), to(""), mix(0) { SpineAnimationMix::SpineAnimationMix(): from(""), to(""), mix(0) {
} }
void SpineAnimationMix::set_from(const StringName &from) { void SpineAnimationMix::set_from(const StringName &_from) {
this->from = from; this->from = _from;
} }
String SpineAnimationMix::get_from() { String SpineAnimationMix::get_from() {
return from; return from;
} }
void SpineAnimationMix::set_to(const StringName &to) { void SpineAnimationMix::set_to(const StringName &_to) {
this->to = to; this->to = _to;
} }
String SpineAnimationMix::get_to() { String SpineAnimationMix::get_to() {
return to; return to;
} }
void SpineAnimationMix::set_mix(float mix) { void SpineAnimationMix::set_mix(float _mix) {
this->mix = mix; this->mix = _mix;
} }
float SpineAnimationMix::get_mix() { float SpineAnimationMix::get_mix() {
@ -215,8 +215,8 @@ void SpineSkeletonDataResource::get_skin_names(Vector<String> &skin_names) const
} }
} }
void SpineSkeletonDataResource::set_default_mix(float default_mix) { void SpineSkeletonDataResource::set_default_mix(float _default_mix) {
this->default_mix = default_mix; this->default_mix = _default_mix;
update_mixes(); update_mixes();
} }
@ -224,16 +224,16 @@ float SpineSkeletonDataResource::get_default_mix() {
return default_mix; return default_mix;
} }
void SpineSkeletonDataResource::set_animation_mixes(Array animation_mixes) { void SpineSkeletonDataResource::set_animation_mixes(Array _animation_mixes) {
for (int i = 0; i < animation_mixes.size(); i++) { for (int i = 0; i < _animation_mixes.size(); i++) {
auto objectId = Object::cast_to<EncodedObjectAsID>(animation_mixes[0]); auto objectId = Object::cast_to<EncodedObjectAsID>(_animation_mixes[0]);
if (objectId) { if (objectId) {
ERR_PRINT("Live-editing of animation mixes is not supported."); ERR_PRINT("Live-editing of animation mixes is not supported.");
return; return;
} }
} }
this->animation_mixes = animation_mixes; this->animation_mixes = _animation_mixes;
update_mixes(); update_mixes();
} }

View File

@ -43,7 +43,7 @@ protected:
Vector<uint8_t> binary; Vector<uint8_t> binary;
public: public:
const bool is_binary() { return !binary.empty(); } bool is_binary() { return !binary.empty(); }
const Vector<uint8_t> &get_binary() { return binary; } const Vector<uint8_t> &get_binary() { return binary; }
@ -58,13 +58,13 @@ class SpineSkeletonFileResourceFormatLoader : public ResourceFormatLoader {
GDCLASS(SpineSkeletonFileResourceFormatLoader, ResourceFormatLoader); GDCLASS(SpineSkeletonFileResourceFormatLoader, ResourceFormatLoader);
public: public:
virtual RES load(const String &path, const String &original_path, Error *error); RES load(const String &path, const String &original_path, Error *error) override;
virtual void get_recognized_extensions(List<String> *extensions) const; void get_recognized_extensions(List<String> *extensions) const override;
virtual bool handles_type(const String &type) const; bool handles_type(const String &type) const override;
virtual String get_resource_type(const String &path) const; String get_resource_type(const String &path) const override;
}; };
class SpineSkeletonFileResourceFormatSaver : public ResourceFormatSaver { class SpineSkeletonFileResourceFormatSaver : public ResourceFormatSaver {

View File

@ -145,7 +145,7 @@ Array SpineSkin::get_attachments() {
Ref<SpineSkinEntry> entry_ref = memnew(SpineSkinEntry); Ref<SpineSkinEntry> entry_ref = memnew(SpineSkinEntry);
Ref<SpineAttachment> attachment_ref = nullptr; Ref<SpineAttachment> attachment_ref = nullptr;
if (entry._attachment) { if (entry._attachment) {
Ref<SpineAttachment> attachment_ref = memnew(SpineAttachment); attachment_ref = Ref<SpineAttachment>(memnew(SpineAttachment));
attachment_ref->set_spine_object(entry._attachment); attachment_ref->set_spine_object(entry._attachment);
} }
entry_ref->init(entry._slotIndex, entry._name.buffer(), attachment_ref); entry_ref->init(entry._slotIndex, entry._name.buffer(), attachment_ref);
@ -189,7 +189,7 @@ void SpineSkinEntry::_bind_methods() {
SpineSkinEntry::SpineSkinEntry() : slot_index(0) { SpineSkinEntry::SpineSkinEntry() : slot_index(0) {
} }
uint64_t SpineSkinEntry::get_slot_index() { int SpineSkinEntry::get_slot_index() {
return slot_index; return slot_index;
} }

View File

@ -44,7 +44,7 @@ private:
public: public:
SpineSkin(); SpineSkin();
~SpineSkin(); ~SpineSkin() override;
void set_spine_object(spine::Skin *s) { skin = s; } void set_spine_object(spine::Skin *s) { skin = s; }
spine::Skin *get_spine_object() { return skin; } spine::Skin *get_spine_object() { return skin; }
@ -82,20 +82,20 @@ GDCLASS(SpineSkinEntry, Reference);
protected: protected:
static void _bind_methods(); static void _bind_methods();
void init(uint64_t slot_index, const String &name, Ref<SpineAttachment> attachment) { void init(int _slot_index, const String &_name, Ref<SpineAttachment> _attachment) {
this->slot_index = slot_index; this->slot_index = _slot_index;
this->name = name; this->name = _name;
this->attachment = attachment; this->attachment = _attachment;
} }
private: private:
uint64_t slot_index; int slot_index;
String name; String name;
Ref<SpineAttachment> attachment; Ref<SpineAttachment> attachment;
public: public:
SpineSkinEntry(); SpineSkinEntry();
uint64_t get_slot_index(); int get_slot_index();
const String &get_name(); const String &get_name();

View File

@ -66,9 +66,9 @@ void SpineSprite::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Process,Physics,Manual"), "set_process_mode", "get_process_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Process,Physics,Manual"), "set_process_mode", "get_process_mode");
BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Process); BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Process)
BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Physics); BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Physics)
BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Manual); BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Manual)
} }
SpineSprite::SpineSprite() : overlap(false), process_mode(ProcessMode_Process), skeleton_clipper(nullptr) { SpineSprite::SpineSprite() : overlap(false), process_mode(ProcessMode_Process), skeleton_clipper(nullptr) {
@ -158,15 +158,20 @@ void SpineSprite::_notification(int p_what) {
case NOTIFICATION_READY: { case NOTIFICATION_READY: {
set_process_internal(process_mode == ProcessMode_Process); set_process_internal(process_mode == ProcessMode_Process);
set_physics_process_internal(process_mode == ProcessMode_Physics); set_physics_process_internal(process_mode == ProcessMode_Physics);
} break; break;
}
case NOTIFICATION_INTERNAL_PROCESS: { case NOTIFICATION_INTERNAL_PROCESS: {
if (process_mode == ProcessMode_Process) if (process_mode == ProcessMode_Process)
_update_all(get_process_delta_time()); _update_all(get_process_delta_time());
} break; break;
}
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (process_mode == ProcessMode_Physics) if (process_mode == ProcessMode_Physics)
_update_all(get_physics_process_delta_time()); _update_all(get_physics_process_delta_time());
} break; break;
}
default:
break;
} }
} }
@ -187,7 +192,7 @@ void SpineSprite::_update_all(float delta) {
void SpineSprite::update_bind_slot_nodes() { void SpineSprite::update_bind_slot_nodes() {
if (animation_state.is_valid() && skeleton.is_valid()) { if (animation_state.is_valid() && skeleton.is_valid()) {
for (size_t i = 0, n = bind_slot_nodes.size(); i < n; ++i) { for (int i = 0, n = bind_slot_nodes.size(); i < n; ++i) {
auto a = bind_slot_nodes[i]; auto a = bind_slot_nodes[i];
if (a.get_type() == Variant::DICTIONARY) { if (a.get_type() == Variant::DICTIONARY) {
auto d = (Dictionary) a; auto d = (Dictionary) a;
@ -195,14 +200,14 @@ void SpineSprite::update_bind_slot_nodes() {
NodePath node_path = d["node_path"]; NodePath node_path = d["node_path"];
Node *node = get_node_or_null(node_path); Node *node = get_node_or_null(node_path);
if (node && node->is_class("Node2D")) { if (node && node->is_class("Node2D")) {
Node2D *node2d = (Node2D *) node; auto *node2d = (Node2D *) node;
String slot_name = d["slot_name"]; String slot_name = d["slot_name"];
auto slot = skeleton->find_slot(slot_name); auto slot = skeleton->find_slot(slot_name);
if (slot.is_valid()) { if (slot.is_valid()) {
auto bone = slot->get_bone(); auto bone = slot->get_bone();
if (bone.is_valid()) { if (bone.is_valid()) {
update_bind_slot_node_transform(bone, node2d); bone->apply_world_transform_2d(node2d);
update_bind_slot_node_draw_order(slot_name, node2d); update_bind_slot_node_draw_order(slot_name, node2d);
} }
} }
@ -214,14 +219,14 @@ void SpineSprite::update_bind_slot_nodes() {
NodePath node_path = as[1]; NodePath node_path = as[1];
Node *node = get_node_or_null(node_path); Node *node = get_node_or_null(node_path);
if (node && node->is_class("Node2D")) { if (node && node->is_class("Node2D")) {
Node2D *node2d = (Node2D *) node; auto *node2d = (Node2D *) node;
String slot_name = as[0]; String slot_name = as[0];
auto slot = skeleton->find_slot(slot_name); auto slot = skeleton->find_slot(slot_name);
if (slot.is_valid()) { if (slot.is_valid()) {
auto bone = slot->get_bone(); auto bone = slot->get_bone();
if (bone.is_valid()) { if (bone.is_valid()) {
update_bind_slot_node_transform(bone, node2d); bone->apply_world_transform_2d(node2d);
update_bind_slot_node_draw_order(slot_name, node2d); update_bind_slot_node_draw_order(slot_name, node2d);
} }
} }
@ -232,10 +237,6 @@ void SpineSprite::update_bind_slot_nodes() {
} }
} }
void SpineSprite::update_bind_slot_node_transform(Ref<SpineBone> bone, Node2D *node2d) {
bone->apply_world_transform_2d(node2d);
}
void SpineSprite::update_bind_slot_node_draw_order(const String &slot_name, Node2D *node2d) { void SpineSprite::update_bind_slot_node_draw_order(const String &slot_name, Node2D *node2d) {
auto mesh_ins = find_node(slot_name); auto mesh_ins = find_node(slot_name);
if (mesh_ins) { if (mesh_ins) {
@ -279,9 +280,9 @@ void SpineSprite::remove_meshes() {
#define TEMP_COPY(t, get_res) \ #define TEMP_COPY(t, get_res) \
do { \ do { \
auto &temp_uvs = get_res; \ auto &temp_uvs = get_res; \
t.setSize(temp_uvs.size(), 0); \ (t).setSize(temp_uvs.size(), 0); \
for (size_t j = 0; j < t.size(); ++j) { \ for (size_t j = 0; j < (t).size(); ++j) { \
t[j] = temp_uvs[j]; \ (t)[j] = temp_uvs[j]; \
} \ } \
} while (false); } while (false);
@ -290,7 +291,7 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> s) {
static unsigned short quad_indices[] = {0, 1, 2, 2, 3, 0}; static unsigned short quad_indices[] = {0, 1, 2, 2, 3, 0};
auto sk = s->get_spine_object(); auto sk = s->get_spine_object();
for (size_t i = 0, n = sk->getSlots().size(); i < n; ++i) { for (int i = 0, n = sk->getSlots().size(); i < n; ++i) {
spine::Vector<float> vertices; spine::Vector<float> vertices;
spine::Vector<float> uvs; spine::Vector<float> uvs;
spine::Vector<unsigned short> indices; spine::Vector<unsigned short> indices;
@ -315,7 +316,7 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> s) {
size_t v_num = 0; size_t v_num = 0;
if (attachment->getRTTI().isExactly(spine::RegionAttachment::rtti)) { if (attachment->getRTTI().isExactly(spine::RegionAttachment::rtti)) {
spine::RegionAttachment *region_attachment = (spine::RegionAttachment *) attachment; auto *region_attachment = (spine::RegionAttachment *) attachment;
auto p_spine_renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) region_attachment->getRendererObject())->page->getRendererObject(); auto p_spine_renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) region_attachment->getRendererObject())->page->getRendererObject();
tex = p_spine_renderer_object->texture; tex = p_spine_renderer_object->texture;
@ -339,7 +340,7 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> s) {
tint.b *= attachment_color.b; tint.b *= attachment_color.b;
tint.a *= attachment_color.a; tint.a *= attachment_color.a;
} else if (attachment->getRTTI().isExactly(spine::MeshAttachment::rtti)) { } else if (attachment->getRTTI().isExactly(spine::MeshAttachment::rtti)) {
spine::MeshAttachment *mesh = (spine::MeshAttachment *) attachment; auto *mesh = (spine::MeshAttachment *) attachment;
auto p_spine_renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) mesh->getRendererObject())->page->getRendererObject(); auto p_spine_renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) mesh->getRendererObject())->page->getRendererObject();
tex = p_spine_renderer_object->texture; tex = p_spine_renderer_object->texture;

View File

@ -89,7 +89,6 @@ public:
void update_meshes(Ref<SpineSkeleton> s); void update_meshes(Ref<SpineSkeleton> s);
void update_bind_slot_nodes(); void update_bind_slot_nodes();
void update_bind_slot_node_transform(Ref<SpineBone> bone, Node2D *node2d);
void update_bind_slot_node_draw_order(const String &slot_name, Node2D *node2d); void update_bind_slot_node_draw_order(const String &slot_name, Node2D *node2d);
Node *find_child_node_by_node(Node *node); Node *find_child_node_by_node(Node *node);

View File

@ -57,14 +57,14 @@ void SpineTimeline::apply(Ref<SpineSkeleton> skeleton, float last_time, float ti
timeline->apply(*(skeleton->get_spine_object()), last_time, time, &spine_events, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction); timeline->apply(*(skeleton->get_spine_object()), last_time, time, &spine_events, alpha, (spine::MixBlend) blend, (spine::MixDirection) direction);
} }
int64_t SpineTimeline::get_frame_entries() { int SpineTimeline::get_frame_entries() {
SPINE_CHECK(timeline, 0) SPINE_CHECK(timeline, 0)
return timeline->getFrameEntries(); return (int)timeline->getFrameEntries();
} }
int64_t SpineTimeline::get_frame_count() { int SpineTimeline::get_frame_count() {
SPINE_CHECK(timeline, 0) SPINE_CHECK(timeline, 0)
return timeline->getFrameCount(); return (int)timeline->getFrameCount();
} }
Array SpineTimeline::get_frames() { Array SpineTimeline::get_frames() {

View File

@ -49,14 +49,14 @@ private:
public: public:
SpineTimeline(); SpineTimeline();
void set_spine_object(spine::Timeline *timeline) { this->timeline = timeline; } void set_spine_object(spine::Timeline *_timeline) { this->timeline = _timeline; }
spine::Timeline *get_spine_object() { return timeline; } spine::Timeline *get_spine_object() { return timeline; }
void apply(Ref<SpineSkeleton> skeleton, float last_time, float time, Array events, float alpha, SpineConstant::MixBlend blend, SpineConstant::MixDirection direction); void apply(Ref<SpineSkeleton> skeleton, float last_time, float time, Array events, float alpha, SpineConstant::MixBlend blend, SpineConstant::MixDirection direction);
int64_t get_frame_entries(); int get_frame_entries();
int64_t get_frame_count(); int get_frame_count();
Array get_frames(); Array get_frames();

View File

@ -72,71 +72,71 @@ Ref<SpineBoneData> SpineTransformConstraintData::get_target() {
} }
float SpineTransformConstraintData::get_mix_rotate() { float SpineTransformConstraintData::get_mix_rotate() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getMixRotate(); return get_spine_constraint_data()->getMixRotate();
} }
float SpineTransformConstraintData::get_mix_x() { float SpineTransformConstraintData::get_mix_x() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getMixX(); return get_spine_constraint_data()->getMixX();
} }
float SpineTransformConstraintData::get_mix_y() { float SpineTransformConstraintData::get_mix_y() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getMixY(); return get_spine_constraint_data()->getMixY();
} }
float SpineTransformConstraintData::get_mix_scale_x() { float SpineTransformConstraintData::get_mix_scale_x() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getMixScaleX(); return get_spine_constraint_data()->getMixScaleX();
} }
float SpineTransformConstraintData::get_mix_scale_y() { float SpineTransformConstraintData::get_mix_scale_y() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getMixScaleY(); return get_spine_constraint_data()->getMixScaleY();
} }
float SpineTransformConstraintData::get_mix_shear_y() { float SpineTransformConstraintData::get_mix_shear_y() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getMixShearY(); return get_spine_constraint_data()->getMixShearY();
} }
float SpineTransformConstraintData::get_offset_rotation() { float SpineTransformConstraintData::get_offset_rotation() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getOffsetRotation(); return get_spine_constraint_data()->getOffsetRotation();
} }
float SpineTransformConstraintData::get_offset_x() { float SpineTransformConstraintData::get_offset_x() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getOffsetX(); return get_spine_constraint_data()->getOffsetX();
} }
float SpineTransformConstraintData::get_offset_y() { float SpineTransformConstraintData::get_offset_y() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getOffsetY(); return get_spine_constraint_data()->getOffsetY();
} }
float SpineTransformConstraintData::get_offset_scale_x() { float SpineTransformConstraintData::get_offset_scale_x() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getOffsetScaleX(); return get_spine_constraint_data()->getOffsetScaleX();
} }
float SpineTransformConstraintData::get_offset_scale_y() { float SpineTransformConstraintData::get_offset_scale_y() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getOffsetScaleY(); return get_spine_constraint_data()->getOffsetScaleY();
} }
float SpineTransformConstraintData::get_offset_shear_y() { float SpineTransformConstraintData::get_offset_shear_y() {
SPINE_CHECK(get_spine_constraint_data(), 0); SPINE_CHECK(get_spine_constraint_data(), 0)
return get_spine_constraint_data()->getOffsetShearY(); return get_spine_constraint_data()->getOffsetShearY();
} }
bool SpineTransformConstraintData::is_relative() { bool SpineTransformConstraintData::is_relative() {
SPINE_CHECK(get_spine_constraint_data(), false); SPINE_CHECK(get_spine_constraint_data(), false)
return get_spine_constraint_data()->isRelative(); return get_spine_constraint_data()->isRelative();
} }
bool SpineTransformConstraintData::is_local() { bool SpineTransformConstraintData::is_local() {
SPINE_CHECK(get_spine_constraint_data(), false); SPINE_CHECK(get_spine_constraint_data(), false)
return get_spine_constraint_data()->isLocal(); return get_spine_constraint_data()->isLocal();
} }

View File

@ -59,8 +59,6 @@ static Ref<SpineSkeletonFileResourceFormatSaver> skeleton_file_saver;
#include "editor/editor_export.h" #include "editor/editor_export.h"
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "SpineEditorPlugin.h" #include "SpineEditorPlugin.h"
#include "SpineSkeletonDataResource.h"
#include "SpineSprite.h"
static void editor_init_callback() { static void editor_init_callback() {
EditorNode::get_singleton()->add_editor_plugin(memnew(SpineEditorPlugin(EditorNode::get_singleton()))); EditorNode::get_singleton()->add_editor_plugin(memnew(SpineEditorPlugin(EditorNode::get_singleton())));