From 2ec5d44ed30581df96527629d01b06549ab38d1c Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 20 Apr 2022 15:10:00 +0200 Subject: [PATCH] [godot] Fix all clang-tidy issues. --- .../spine_godot/GodotSpineExtension.cpp | 3 -- spine-godot/spine_godot/GodotSpineExtension.h | 5 --- spine-godot/spine_godot/SpineAnimation.h | 2 +- .../spine_godot/SpineAnimationState.cpp | 6 +-- spine-godot/spine_godot/SpineAnimationState.h | 12 +++--- .../spine_godot/SpineAtlasResource.cpp | 22 +++++----- spine-godot/spine_godot/SpineAtlasResource.h | 33 +++++++------- spine-godot/spine_godot/SpineAttachment.h | 2 +- spine-godot/spine_godot/SpineBone.cpp | 2 +- spine-godot/spine_godot/SpineBone.h | 2 +- spine-godot/spine_godot/SpineEditorPlugin.cpp | 16 +++---- spine-godot/spine_godot/SpineEditorPlugin.h | 12 +++--- spine-godot/spine_godot/SpineSkeleton.cpp | 4 +- spine-godot/spine_godot/SpineSkeleton.h | 2 +- .../spine_godot/SpineSkeletonDataResource.cpp | 24 +++++------ .../spine_godot/SpineSkeletonFileResource.h | 10 ++--- spine-godot/spine_godot/SpineSkin.cpp | 4 +- spine-godot/spine_godot/SpineSkin.h | 14 +++--- spine-godot/spine_godot/SpineSprite.cpp | 43 ++++++++++--------- spine-godot/spine_godot/SpineSprite.h | 1 - spine-godot/spine_godot/SpineTimeline.cpp | 8 ++-- spine-godot/spine_godot/SpineTimeline.h | 6 +-- .../SpineTransformConstraintData.cpp | 28 ++++++------ spine-godot/spine_godot/register_types.cpp | 2 - 24 files changed, 120 insertions(+), 143 deletions(-) diff --git a/spine-godot/spine_godot/GodotSpineExtension.cpp b/spine-godot/spine_godot/GodotSpineExtension.cpp index 16cd4ff26..77f5a2144 100644 --- a/spine-godot/spine_godot/GodotSpineExtension.cpp +++ b/spine-godot/spine_godot/GodotSpineExtension.cpp @@ -36,9 +36,6 @@ spine::SpineExtension *spine::getDefaultExtension() { return new GodotSpineExtension(); } -GodotSpineExtension::GodotSpineExtension() {} -GodotSpineExtension::~GodotSpineExtension() {} - void *GodotSpineExtension::_alloc(size_t size, const char *file, int line) { return memalloc(size); } diff --git a/spine-godot/spine_godot/GodotSpineExtension.h b/spine-godot/spine_godot/GodotSpineExtension.h index 7252f87f1..f314d04e1 100644 --- a/spine-godot/spine_godot/GodotSpineExtension.h +++ b/spine-godot/spine_godot/GodotSpineExtension.h @@ -33,11 +33,6 @@ #include class GodotSpineExtension : public spine::SpineExtension { -public: - GodotSpineExtension(); - - virtual ~GodotSpineExtension(); - protected: virtual void *_alloc(size_t size, const char *file, int line); diff --git a/spine-godot/spine_godot/SpineAnimation.h b/spine-godot/spine_godot/SpineAnimation.h index b5917a432..4f4b4d80b 100644 --- a/spine-godot/spine_godot/SpineAnimation.h +++ b/spine-godot/spine_godot/SpineAnimation.h @@ -50,7 +50,7 @@ protected: public: 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; } diff --git a/spine-godot/spine_godot/SpineAnimationState.cpp b/spine-godot/spine_godot/SpineAnimationState.cpp index d0ee2aafc..4d133cac0 100644 --- a/spine-godot/spine_godot/SpineAnimationState.cpp +++ b/spine-godot/spine_godot/SpineAnimationState.cpp @@ -54,7 +54,7 @@ SpineAnimationState::~SpineAnimationState() { delete animation_state; } -void SpineAnimationState::set_skeleton_data_res(Ref data_res) { +void SpineAnimationState::set_skeleton_data_res(const Ref &data_res) { delete animation_state; animation_state = nullptr; skeleton_data_res = data_res; @@ -62,10 +62,6 @@ void SpineAnimationState::set_skeleton_data_res(Ref d animation_state = new spine::AnimationState(skeleton_data_res->get_animation_state_data()); } -Ref SpineAnimationState::get_skeleton_data_res() const { - return skeleton_data_res; -} - void SpineAnimationState::update(float delta) { SPINE_CHECK(animation_state,) animation_state->update(delta); diff --git a/spine-godot/spine_godot/SpineAnimationState.h b/spine-godot/spine_godot/SpineAnimationState.h index 1dc231b90..d54047551 100644 --- a/spine-godot/spine_godot/SpineAnimationState.h +++ b/spine-godot/spine_godot/SpineAnimationState.h @@ -46,12 +46,10 @@ private: public: SpineAnimationState(); ~SpineAnimationState(); - + spine::AnimationState *get_spine_object() { return animation_state; } - void set_skeleton_data_res(Ref skeleton_data_res); - - Ref get_skeleton_data_res() const; + void set_skeleton_data_res(const Ref &skeleton_data_res); void update(float delta); @@ -68,17 +66,17 @@ public: Ref set_empty_animation(uint64_t track_id, float mix_duration); Ref add_empty_animation(uint64_t track_id, float mix_duration, float delay); - + void set_empty_animations(float mix_duration); Ref get_current(uint64_t track_index); float get_time_scale(); - + void set_time_scale(float time_scale); void disable_queue(); - + void enable_queue(); }; diff --git a/spine-godot/spine_godot/SpineAtlasResource.cpp b/spine-godot/spine_godot/SpineAtlasResource.cpp index 1b760295f..c815d868d 100644 --- a/spine-godot/spine_godot/SpineAtlasResource.cpp +++ b/spine-godot/spine_godot/SpineAtlasResource.cpp @@ -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) { } - String fix_path(const String &path) { + static String fix_path(const String &path) { if (path.size() > 5 && path[4] == '/' && path[5] == '/') return path; const String prefix = "res:/"; auto i = path.find(prefix); @@ -51,7 +51,7 @@ public: if (sub_str_pos < 0) return path; auto res = path.substr(sub_str_pos); - if (res.size() > 0) { + if (!res.empty()) { if (res[0] != '/') { return prefix + "/" + res; } else { @@ -61,7 +61,7 @@ public: 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; auto fixed_path = fix_path(String(path.buffer())); @@ -80,8 +80,7 @@ public: renderer_object->texture = texture; renderer_object->normal_map = Ref(nullptr); - String temp_path = fixed_path; - String new_path = vformat("%s/%s_%s", temp_path.get_base_dir(), normal_map_prefix, temp_path.get_file()); + String new_path = vformat("%s/%s_%s", fixed_path.get_base_dir(), normal_map_prefix, fixed_path.get_file()); if (ResourceLoader::exists(new_path)) { Ref normal_map = ResourceLoader::load(new_path); normal_maps->append(normal_map); @@ -93,7 +92,7 @@ public: page.height = texture->get_height(); } - virtual void unload(void *data) { + void unload(void *data) override { auto renderer_object = (SpineRendererObject *) data; Ref &texture = renderer_object->texture; 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 err; - String json_string = FileAccess::get_file_as_string(path, &err); - if (err != OK) return err; + Error error; + String json_string = FileAccess::get_file_as_string(path, &error); + if (error != OK) return error; String error_string; int error_line; - JSON json; Variant result; - err = json.parse(json_string, result, error_string, error_line); - if (err != OK) return err; + error = JSON::parse(json_string, result, error_string, error_line); + if (error != OK) return error; Dictionary content = Dictionary(result); source_path = content["source_path"]; diff --git a/spine-godot/spine_godot/SpineAtlasResource.h b/spine-godot/spine_godot/SpineAtlasResource.h index abe0dd67f..d6afa9693 100644 --- a/spine-godot/spine_godot/SpineAtlasResource.h +++ b/spine-godot/spine_godot/SpineAtlasResource.h @@ -41,7 +41,7 @@ class SpineAtlasResource : public Resource { GDCLASS(SpineAtlasResource, Resource) void clear(); - + protected: static void _bind_methods(); @@ -57,10 +57,7 @@ protected: public: SpineAtlasResource(); - - virtual ~SpineAtlasResource(); - - String &get_atlas_data() { return atlas_data; } + ~SpineAtlasResource() override; spine::Atlas *get_spine_atlas() { return atlas; } @@ -69,13 +66,13 @@ public: Error load_from_atlas_file(const String &path);// .atlas Error load_from_file(const String &path); // .spatlas - + Error save_to_file(const String &path); // .spatlas String get_source_path(); - + Array get_textures(); - + Array get_normal_maps(); }; @@ -83,23 +80,23 @@ class SpineAtlasResourceFormatLoader : public ResourceFormatLoader { GDCLASS(SpineAtlasResourceFormatLoader, ResourceFormatLoader) public: - virtual RES load(const String &path, const String &original_path, Error *error = nullptr); - - virtual void get_recognized_extensions(List *extensions) const; - - virtual bool handles_type(const String &type) const; - - virtual String get_resource_type(const String &path) const; + RES load(const String &path, const String &original_path, Error *error) override; + + void get_recognized_extensions(List *extensions) const override; + + bool handles_type(const String &type) const override; + + String get_resource_type(const String &path) const override; }; class SpineAtlasResourceFormatSaver : public ResourceFormatSaver { GDCLASS(SpineAtlasResourceFormatSaver, ResourceFormatSaver) 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 *extensions) const override; - + bool recognize(const RES &resource) const override; }; diff --git a/spine-godot/spine_godot/SpineAttachment.h b/spine-godot/spine_godot/SpineAttachment.h index 297fb7467..cfd3e17cd 100644 --- a/spine-godot/spine_godot/SpineAttachment.h +++ b/spine-godot/spine_godot/SpineAttachment.h @@ -44,7 +44,7 @@ private: public: SpineAttachment(); - ~SpineAttachment(); + ~SpineAttachment() override; void set_spine_object(spine::Attachment *_attachment) { attachment = _attachment; diff --git a/spine-godot/spine_godot/SpineBone.cpp b/spine-godot/spine_godot/SpineBone.cpp index d1916f6ea..6f1cc87bb 100644 --- a/spine-godot/spine_godot/SpineBone.cpp +++ b/spine-godot/spine_godot/SpineBone.cpp @@ -427,7 +427,7 @@ void SpineBone::set_active(bool v) { } // External feature functions -void SpineBone::apply_world_transform_2d(Variant o) { +void SpineBone::apply_world_transform_2d(const Variant &o) { SPINE_CHECK(bone,) if (o.get_type() == Variant::OBJECT) { auto node = (Node *) o; diff --git a/spine-godot/spine_godot/SpineBone.h b/spine-godot/spine_godot/SpineBone.h index 9de96b7f7..0a0824ed7 100644 --- a/spine-godot/spine_godot/SpineBone.h +++ b/spine-godot/spine_godot/SpineBone.h @@ -175,7 +175,7 @@ public: void set_active(bool v); // External feature functions - void apply_world_transform_2d(Variant o); + void apply_world_transform_2d(const Variant &o); Transform2D get_godot_transform(); diff --git a/spine-godot/spine_godot/SpineEditorPlugin.cpp b/spine-godot/spine_godot/SpineEditorPlugin.cpp index 3c4621a32..f04a0498c 100644 --- a/spine-godot/spine_godot/SpineEditorPlugin.cpp +++ b/spine-godot/spine_godot/SpineEditorPlugin.cpp @@ -124,13 +124,13 @@ void SpineEditorPropertyAnimationMixes::delete_mix(int64_t idx) { if (!skeleton_data.is_valid() || !skeleton_data->is_skeleton_data_loaded() || updating) return; auto mixes = skeleton_data->get_animation_mixes().duplicate(); - mixes.remove(idx); + mixes.remove((int)idx); emit_changed(get_edited_property(), mixes); } void SpineEditorPropertyAnimationMixes::update_mix_property(int64_t index) { if (index < 0 || index > mix_properties.size()) return; - mix_properties[index]->update_property(); + mix_properties[(int)index]->update_property(); } void SpineEditorPropertyAnimationMixes::update_property() { @@ -191,20 +191,20 @@ void SpineEditorPropertyAnimationMixes::update_property() { 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 skeleton_data, int index) { - this->mixes_property = mixes_property; - this->skeleton_data = skeleton_data; - this->index = index; +void SpineEditorPropertyAnimationMix::setup(SpineEditorPropertyAnimationMixes *_mixes_property, const Ref &_skeleton_data, int _index) { + this->mixes_property = _mixes_property; + this->skeleton_data = _skeleton_data; + this->index = _index; } void SpineEditorPropertyAnimationMix::_bind_methods() { 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(get_edited_object()->get(get_edited_property())); UndoRedo *undo_redo = EditorNode::get_undo_redo(); diff --git a/spine-godot/spine_godot/SpineEditorPlugin.h b/spine-godot/spine_godot/SpineEditorPlugin.h index 1e0384f44..e024b443b 100644 --- a/spine-godot/spine_godot/SpineEditorPlugin.h +++ b/spine-godot/spine_godot/SpineEditorPlugin.h @@ -118,8 +118,6 @@ public: explicit SpineEditorPlugin(EditorNode *node); String get_name() const override { return "SpineEditorPlugin"; } - - bool has_main_screen() const { return false; } }; class SpineSkeletonDataResourceInspectorPlugin: public EditorInspectorPlugin { @@ -149,8 +147,8 @@ class SpineEditorPropertyAnimationMixes: public EditorProperty { void update_mix_property(int64_t index); public: SpineEditorPropertyAnimationMixes(); - void setup(Ref skeleton_data) { this->skeleton_data = skeleton_data; }; - virtual void update_property(); + void setup(const Ref &_skeleton_data) { this->skeleton_data = _skeleton_data; }; + void update_property() override; }; class SpineEditorPropertyAnimationMix: public EditorProperty { @@ -163,11 +161,11 @@ class SpineEditorPropertyAnimationMix: public EditorProperty { bool updating; 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: SpineEditorPropertyAnimationMix(); - void setup(SpineEditorPropertyAnimationMixes *mixes_property, Ref skeleton_data, int index); - virtual void update_property(); + void setup(SpineEditorPropertyAnimationMixes *mixes_property, const Ref &skeleton_data, int index); + void update_property() override; }; #endif diff --git a/spine-godot/spine_godot/SpineSkeleton.cpp b/spine-godot/spine_godot/SpineSkeleton.cpp index f8cbe4f53..e236c1bba 100644 --- a/spine-godot/spine_godot/SpineSkeleton.cpp +++ b/spine-godot/spine_godot/SpineSkeleton.cpp @@ -87,8 +87,8 @@ Ref SpineSkeleton::get_skeleton_data_res() const { return skeleton_data_res; } -void SpineSkeleton::set_spine_sprite(SpineSprite* sprite) { - this->sprite = sprite; +void SpineSkeleton::set_spine_sprite(SpineSprite* _sprite) { + this->sprite = _sprite; } void SpineSkeleton::update_world_transform() { diff --git a/spine-godot/spine_godot/SpineSkeleton.h b/spine-godot/spine_godot/SpineSkeleton.h index 6bdb6dc0d..63d4ff667 100644 --- a/spine-godot/spine_godot/SpineSkeleton.h +++ b/spine-godot/spine_godot/SpineSkeleton.h @@ -69,7 +69,7 @@ private: public: SpineSkeleton(); - ~SpineSkeleton(); + ~SpineSkeleton() override; void update_world_transform(); diff --git a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp index 1226ce329..dcac95100 100644 --- a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp +++ b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp @@ -47,24 +47,24 @@ void SpineAnimationMix::_bind_methods() { SpineAnimationMix::SpineAnimationMix(): from(""), to(""), mix(0) { } -void SpineAnimationMix::set_from(const StringName &from) { - this->from = from; +void SpineAnimationMix::set_from(const StringName &_from) { + this->from = _from; } String SpineAnimationMix::get_from() { return from; } -void SpineAnimationMix::set_to(const StringName &to) { - this->to = to; +void SpineAnimationMix::set_to(const StringName &_to) { + this->to = _to; } String SpineAnimationMix::get_to() { return to; } -void SpineAnimationMix::set_mix(float mix) { - this->mix = mix; +void SpineAnimationMix::set_mix(float _mix) { + this->mix = _mix; } float SpineAnimationMix::get_mix() { @@ -215,8 +215,8 @@ void SpineSkeletonDataResource::get_skin_names(Vector &skin_names) const } } -void SpineSkeletonDataResource::set_default_mix(float default_mix) { - this->default_mix = default_mix; +void SpineSkeletonDataResource::set_default_mix(float _default_mix) { + this->default_mix = _default_mix; update_mixes(); } @@ -224,16 +224,16 @@ float SpineSkeletonDataResource::get_default_mix() { return default_mix; } -void SpineSkeletonDataResource::set_animation_mixes(Array animation_mixes) { - for (int i = 0; i < animation_mixes.size(); i++) { - auto objectId = Object::cast_to(animation_mixes[0]); +void SpineSkeletonDataResource::set_animation_mixes(Array _animation_mixes) { + for (int i = 0; i < _animation_mixes.size(); i++) { + auto objectId = Object::cast_to(_animation_mixes[0]); if (objectId) { ERR_PRINT("Live-editing of animation mixes is not supported."); return; } } - this->animation_mixes = animation_mixes; + this->animation_mixes = _animation_mixes; update_mixes(); } diff --git a/spine-godot/spine_godot/SpineSkeletonFileResource.h b/spine-godot/spine_godot/SpineSkeletonFileResource.h index 7733c06e4..ece2267f5 100644 --- a/spine-godot/spine_godot/SpineSkeletonFileResource.h +++ b/spine-godot/spine_godot/SpineSkeletonFileResource.h @@ -43,7 +43,7 @@ protected: Vector binary; public: - const bool is_binary() { return !binary.empty(); } + bool is_binary() { return !binary.empty(); } const Vector &get_binary() { return binary; } @@ -58,13 +58,13 @@ class SpineSkeletonFileResourceFormatLoader : public ResourceFormatLoader { GDCLASS(SpineSkeletonFileResourceFormatLoader, ResourceFormatLoader); 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 *extensions) const; + void get_recognized_extensions(List *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 { diff --git a/spine-godot/spine_godot/SpineSkin.cpp b/spine-godot/spine_godot/SpineSkin.cpp index fc47c1014..df44fba0c 100644 --- a/spine-godot/spine_godot/SpineSkin.cpp +++ b/spine-godot/spine_godot/SpineSkin.cpp @@ -145,7 +145,7 @@ Array SpineSkin::get_attachments() { Ref entry_ref = memnew(SpineSkinEntry); Ref attachment_ref = nullptr; if (entry._attachment) { - Ref attachment_ref = memnew(SpineAttachment); + attachment_ref = Ref(memnew(SpineAttachment)); attachment_ref->set_spine_object(entry._attachment); } entry_ref->init(entry._slotIndex, entry._name.buffer(), attachment_ref); @@ -189,7 +189,7 @@ void SpineSkinEntry::_bind_methods() { SpineSkinEntry::SpineSkinEntry() : slot_index(0) { } -uint64_t SpineSkinEntry::get_slot_index() { +int SpineSkinEntry::get_slot_index() { return slot_index; } diff --git a/spine-godot/spine_godot/SpineSkin.h b/spine-godot/spine_godot/SpineSkin.h index 07159ff26..e7d32eb1d 100644 --- a/spine-godot/spine_godot/SpineSkin.h +++ b/spine-godot/spine_godot/SpineSkin.h @@ -44,7 +44,7 @@ private: public: SpineSkin(); - ~SpineSkin(); + ~SpineSkin() override; void set_spine_object(spine::Skin *s) { skin = s; } spine::Skin *get_spine_object() { return skin; } @@ -82,20 +82,20 @@ GDCLASS(SpineSkinEntry, Reference); protected: static void _bind_methods(); - void init(uint64_t slot_index, const String &name, Ref attachment) { - this->slot_index = slot_index; - this->name = name; - this->attachment = attachment; + void init(int _slot_index, const String &_name, Ref _attachment) { + this->slot_index = _slot_index; + this->name = _name; + this->attachment = _attachment; } private: - uint64_t slot_index; + int slot_index; String name; Ref attachment; public: SpineSkinEntry(); - uint64_t get_slot_index(); + int get_slot_index(); const String &get_name(); diff --git a/spine-godot/spine_godot/SpineSprite.cpp b/spine-godot/spine_godot/SpineSprite.cpp index fc6732c11..d409777c5 100644 --- a/spine-godot/spine_godot/SpineSprite.cpp +++ b/spine-godot/spine_godot/SpineSprite.cpp @@ -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"); - BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Process); - BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Physics); - BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Manual); + BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Process) + BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Physics) + BIND_ENUM_CONSTANT(ProcessMode::ProcessMode_Manual) } SpineSprite::SpineSprite() : overlap(false), process_mode(ProcessMode_Process), skeleton_clipper(nullptr) { @@ -158,15 +158,20 @@ void SpineSprite::_notification(int p_what) { case NOTIFICATION_READY: { set_process_internal(process_mode == ProcessMode_Process); set_physics_process_internal(process_mode == ProcessMode_Physics); - } break; + break; + } case NOTIFICATION_INTERNAL_PROCESS: { if (process_mode == ProcessMode_Process) _update_all(get_process_delta_time()); - } break; + break; + } case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { if (process_mode == ProcessMode_Physics) _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() { 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]; if (a.get_type() == Variant::DICTIONARY) { auto d = (Dictionary) a; @@ -195,14 +200,14 @@ void SpineSprite::update_bind_slot_nodes() { NodePath node_path = d["node_path"]; Node *node = get_node_or_null(node_path); if (node && node->is_class("Node2D")) { - Node2D *node2d = (Node2D *) node; + auto *node2d = (Node2D *) node; String slot_name = d["slot_name"]; auto slot = skeleton->find_slot(slot_name); if (slot.is_valid()) { auto bone = slot->get_bone(); 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); } } @@ -214,14 +219,14 @@ void SpineSprite::update_bind_slot_nodes() { NodePath node_path = as[1]; Node *node = get_node_or_null(node_path); if (node && node->is_class("Node2D")) { - Node2D *node2d = (Node2D *) node; + auto *node2d = (Node2D *) node; String slot_name = as[0]; auto slot = skeleton->find_slot(slot_name); if (slot.is_valid()) { auto bone = slot->get_bone(); 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); } } @@ -232,10 +237,6 @@ void SpineSprite::update_bind_slot_nodes() { } } -void SpineSprite::update_bind_slot_node_transform(Ref bone, Node2D *node2d) { - bone->apply_world_transform_2d(node2d); -} - void SpineSprite::update_bind_slot_node_draw_order(const String &slot_name, Node2D *node2d) { auto mesh_ins = find_node(slot_name); if (mesh_ins) { @@ -279,9 +280,9 @@ void SpineSprite::remove_meshes() { #define TEMP_COPY(t, get_res) \ do { \ auto &temp_uvs = get_res; \ - t.setSize(temp_uvs.size(), 0); \ - for (size_t j = 0; j < t.size(); ++j) { \ - t[j] = temp_uvs[j]; \ + (t).setSize(temp_uvs.size(), 0); \ + for (size_t j = 0; j < (t).size(); ++j) { \ + (t)[j] = temp_uvs[j]; \ } \ } while (false); @@ -290,7 +291,7 @@ void SpineSprite::update_meshes(Ref s) { static unsigned short quad_indices[] = {0, 1, 2, 2, 3, 0}; 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 vertices; spine::Vector uvs; spine::Vector indices; @@ -315,7 +316,7 @@ void SpineSprite::update_meshes(Ref s) { size_t v_num = 0; 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(); tex = p_spine_renderer_object->texture; @@ -339,7 +340,7 @@ void SpineSprite::update_meshes(Ref s) { tint.b *= attachment_color.b; tint.a *= attachment_color.a; } 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(); tex = p_spine_renderer_object->texture; diff --git a/spine-godot/spine_godot/SpineSprite.h b/spine-godot/spine_godot/SpineSprite.h index cf8ad2130..6a0d53623 100644 --- a/spine-godot/spine_godot/SpineSprite.h +++ b/spine-godot/spine_godot/SpineSprite.h @@ -89,7 +89,6 @@ public: void update_meshes(Ref s); void update_bind_slot_nodes(); - void update_bind_slot_node_transform(Ref bone, Node2D *node2d); void update_bind_slot_node_draw_order(const String &slot_name, Node2D *node2d); Node *find_child_node_by_node(Node *node); diff --git a/spine-godot/spine_godot/SpineTimeline.cpp b/spine-godot/spine_godot/SpineTimeline.cpp index a4b13c908..996080db7 100644 --- a/spine-godot/spine_godot/SpineTimeline.cpp +++ b/spine-godot/spine_godot/SpineTimeline.cpp @@ -57,14 +57,14 @@ void SpineTimeline::apply(Ref skeleton, float last_time, float ti 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) - return timeline->getFrameEntries(); + return (int)timeline->getFrameEntries(); } -int64_t SpineTimeline::get_frame_count() { +int SpineTimeline::get_frame_count() { SPINE_CHECK(timeline, 0) - return timeline->getFrameCount(); + return (int)timeline->getFrameCount(); } Array SpineTimeline::get_frames() { diff --git a/spine-godot/spine_godot/SpineTimeline.h b/spine-godot/spine_godot/SpineTimeline.h index 23a76dafa..056d0e96b 100644 --- a/spine-godot/spine_godot/SpineTimeline.h +++ b/spine-godot/spine_godot/SpineTimeline.h @@ -49,14 +49,14 @@ private: public: 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; } void apply(Ref 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(); diff --git a/spine-godot/spine_godot/SpineTransformConstraintData.cpp b/spine-godot/spine_godot/SpineTransformConstraintData.cpp index 4fb092c25..10220586b 100644 --- a/spine-godot/spine_godot/SpineTransformConstraintData.cpp +++ b/spine-godot/spine_godot/SpineTransformConstraintData.cpp @@ -72,71 +72,71 @@ Ref SpineTransformConstraintData::get_target() { } 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(); } 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(); } 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(); } 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(); } 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(); } 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(); } 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(); } 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(); } 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(); } 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(); } 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(); } 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(); } bool SpineTransformConstraintData::is_relative() { - SPINE_CHECK(get_spine_constraint_data(), false); + SPINE_CHECK(get_spine_constraint_data(), false) return get_spine_constraint_data()->isRelative(); } bool SpineTransformConstraintData::is_local() { - SPINE_CHECK(get_spine_constraint_data(), false); + SPINE_CHECK(get_spine_constraint_data(), false) return get_spine_constraint_data()->isLocal(); } diff --git a/spine-godot/spine_godot/register_types.cpp b/spine-godot/spine_godot/register_types.cpp index ab57a1aea..1e8db6837 100644 --- a/spine-godot/spine_godot/register_types.cpp +++ b/spine-godot/spine_godot/register_types.cpp @@ -59,8 +59,6 @@ static Ref skeleton_file_saver; #include "editor/editor_export.h" #include "editor/editor_node.h" #include "SpineEditorPlugin.h" -#include "SpineSkeletonDataResource.h" -#include "SpineSprite.h" static void editor_init_callback() { EditorNode::get_singleton()->add_editor_plugin(memnew(SpineEditorPlugin(EditorNode::get_singleton())));