mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-10 09:08:42 +08:00
[godot] Fix all clang-tidy issues.
This commit is contained in:
parent
e0d4fbc34a
commit
2ec5d44ed3
@ -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);
|
||||
}
|
||||
|
||||
@ -33,11 +33,6 @@
|
||||
#include <spine/Extension.h>
|
||||
|
||||
class GodotSpineExtension : public spine::SpineExtension {
|
||||
public:
|
||||
GodotSpineExtension();
|
||||
|
||||
virtual ~GodotSpineExtension();
|
||||
|
||||
protected:
|
||||
virtual void *_alloc(size_t size, const char *file, int line);
|
||||
|
||||
|
||||
@ -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; }
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ SpineAnimationState::~SpineAnimationState() {
|
||||
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;
|
||||
animation_state = nullptr;
|
||||
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());
|
||||
}
|
||||
|
||||
Ref<SpineSkeletonDataResource> SpineAnimationState::get_skeleton_data_res() const {
|
||||
return skeleton_data_res;
|
||||
}
|
||||
|
||||
void SpineAnimationState::update(float delta) {
|
||||
SPINE_CHECK(animation_state,)
|
||||
animation_state->update(delta);
|
||||
|
||||
@ -46,12 +46,10 @@ private:
|
||||
public:
|
||||
SpineAnimationState();
|
||||
~SpineAnimationState();
|
||||
|
||||
|
||||
spine::AnimationState *get_spine_object() { return animation_state; }
|
||||
|
||||
void set_skeleton_data_res(Ref<SpineSkeletonDataResource> skeleton_data_res);
|
||||
|
||||
Ref<SpineSkeletonDataResource> get_skeleton_data_res() const;
|
||||
void set_skeleton_data_res(const Ref<SpineSkeletonDataResource> &skeleton_data_res);
|
||||
|
||||
void update(float delta);
|
||||
|
||||
@ -68,17 +66,17 @@ public:
|
||||
Ref<SpineTrackEntry> set_empty_animation(uint64_t track_id, float mix_duration);
|
||||
|
||||
Ref<SpineTrackEntry> add_empty_animation(uint64_t track_id, float mix_duration, float delay);
|
||||
|
||||
|
||||
void set_empty_animations(float mix_duration);
|
||||
|
||||
Ref<SpineTrackEntry> get_current(uint64_t track_index);
|
||||
|
||||
float get_time_scale();
|
||||
|
||||
|
||||
void set_time_scale(float time_scale);
|
||||
|
||||
void disable_queue();
|
||||
|
||||
|
||||
void enable_queue();
|
||||
};
|
||||
|
||||
|
||||
@ -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<Texture>(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<Texture> 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> &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"];
|
||||
|
||||
@ -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<String> *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<String> *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<String> *extensions) const override;
|
||||
|
||||
|
||||
bool recognize(const RES &resource) const override;
|
||||
};
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ private:
|
||||
|
||||
public:
|
||||
SpineAttachment();
|
||||
~SpineAttachment();
|
||||
~SpineAttachment() override;
|
||||
|
||||
void set_spine_object(spine::Attachment *_attachment) {
|
||||
attachment = _attachment;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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<SpineSkeletonDataResource> 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<SpineSkeletonDataResource> &_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<SpineAnimationMix>(get_edited_object()->get(get_edited_property()));
|
||||
|
||||
UndoRedo *undo_redo = EditorNode::get_undo_redo();
|
||||
|
||||
@ -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<SpineSkeletonDataResource> skeleton_data) { this->skeleton_data = skeleton_data; };
|
||||
virtual void update_property();
|
||||
void setup(const Ref<SpineSkeletonDataResource> &_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<SpineSkeletonDataResource> skeleton_data, int index);
|
||||
virtual void update_property();
|
||||
void setup(SpineEditorPropertyAnimationMixes *mixes_property, const Ref<SpineSkeletonDataResource> &skeleton_data, int index);
|
||||
void update_property() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -87,8 +87,8 @@ Ref<SpineSkeletonDataResource> 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() {
|
||||
|
||||
@ -69,7 +69,7 @@ private:
|
||||
|
||||
public:
|
||||
SpineSkeleton();
|
||||
~SpineSkeleton();
|
||||
~SpineSkeleton() override;
|
||||
|
||||
void update_world_transform();
|
||||
|
||||
|
||||
@ -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<String> &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<EncodedObjectAsID>(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<EncodedObjectAsID>(_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();
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ protected:
|
||||
Vector<uint8_t> binary;
|
||||
|
||||
public:
|
||||
const bool is_binary() { return !binary.empty(); }
|
||||
bool is_binary() { return !binary.empty(); }
|
||||
|
||||
const Vector<uint8_t> &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<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 {
|
||||
|
||||
@ -145,7 +145,7 @@ Array SpineSkin::get_attachments() {
|
||||
Ref<SpineSkinEntry> entry_ref = memnew(SpineSkinEntry);
|
||||
Ref<SpineAttachment> attachment_ref = nullptr;
|
||||
if (entry._attachment) {
|
||||
Ref<SpineAttachment> attachment_ref = memnew(SpineAttachment);
|
||||
attachment_ref = Ref<SpineAttachment>(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;
|
||||
}
|
||||
|
||||
|
||||
@ -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<SpineAttachment> attachment) {
|
||||
this->slot_index = slot_index;
|
||||
this->name = name;
|
||||
this->attachment = attachment;
|
||||
void init(int _slot_index, const String &_name, Ref<SpineAttachment> _attachment) {
|
||||
this->slot_index = _slot_index;
|
||||
this->name = _name;
|
||||
this->attachment = _attachment;
|
||||
}
|
||||
private:
|
||||
uint64_t slot_index;
|
||||
int slot_index;
|
||||
String name;
|
||||
Ref<SpineAttachment> attachment;
|
||||
|
||||
public:
|
||||
SpineSkinEntry();
|
||||
|
||||
uint64_t get_slot_index();
|
||||
int get_slot_index();
|
||||
|
||||
const String &get_name();
|
||||
|
||||
|
||||
@ -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<SpineBone> 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<SpineSkeleton> 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<float> vertices;
|
||||
spine::Vector<float> uvs;
|
||||
spine::Vector<unsigned short> indices;
|
||||
@ -315,7 +316,7 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> 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<SpineSkeleton> 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;
|
||||
|
||||
@ -89,7 +89,6 @@ public:
|
||||
void update_meshes(Ref<SpineSkeleton> s);
|
||||
|
||||
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);
|
||||
Node *find_child_node_by_node(Node *node);
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
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() {
|
||||
|
||||
@ -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<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();
|
||||
|
||||
|
||||
@ -72,71 +72,71 @@ Ref<SpineBoneData> 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();
|
||||
}
|
||||
|
||||
@ -59,8 +59,6 @@ static Ref<SpineSkeletonFileResourceFormatSaver> 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())));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user