mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Merge branch '4.3-beta-luke-godot-fix' into 4.3-beta
# Conflicts: # CHANGELOG.md
This commit is contained in:
commit
c4a9b49ef3
@ -49,7 +49,11 @@ void SpineAnimation::_bind_methods() {
|
|||||||
String SpineAnimation::get_name() {
|
String SpineAnimation::get_name() {
|
||||||
SPINE_CHECK(get_spine_object(), "")
|
SPINE_CHECK(get_spine_object(), "")
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(get_spine_object()->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||||
|
#endif
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,9 +40,14 @@
|
|||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
#include "editor/animation/animation_player_editor_plugin.h"
|
||||||
|
#include "editor/animation/animation_tree_editor_plugin.h"
|
||||||
|
#else
|
||||||
#include "editor/plugins/animation_player_editor_plugin.h"
|
#include "editor/plugins/animation_player_editor_plugin.h"
|
||||||
#include "editor/plugins/animation_tree_editor_plugin.h"
|
#include "editor/plugins/animation_tree_editor_plugin.h"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
void SpineAnimationTrack::_bind_methods() {
|
void SpineAnimationTrack::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_animation_name", "animation_name"), &SpineAnimationTrack::set_animation_name);
|
ClassDB::bind_method(D_METHOD("set_animation_name", "animation_name"), &SpineAnimationTrack::set_animation_name);
|
||||||
@ -243,7 +248,11 @@ Ref<Animation> SpineAnimationTrack::create_animation(spine::Animation *animation
|
|||||||
Ref<Animation> animation_ref;
|
Ref<Animation> animation_ref;
|
||||||
INSTANTIATE(animation_ref);
|
INSTANTIATE(animation_ref);
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(animation->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(animation->getName().buffer());
|
name.parse_utf8(animation->getName().buffer());
|
||||||
|
#endif
|
||||||
animation_ref->set_name(name + (loop ? "" : "_looped"));
|
animation_ref->set_name(name + (loop ? "" : "_looped"));
|
||||||
#if VERSION_MAJOR > 3
|
#if VERSION_MAJOR > 3
|
||||||
// animation_ref->set_loop(!loop);
|
// animation_ref->set_loop(!loop);
|
||||||
@ -293,7 +302,11 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
|
|||||||
auto current_entry = animation_state->getCurrent(track_index);
|
auto current_entry = animation_state->getCurrent(track_index);
|
||||||
bool should_set_mix = mix_duration >= 0;
|
bool should_set_mix = mix_duration >= 0;
|
||||||
String other_name;
|
String other_name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
if (current_entry) other_name = String::utf8(current_entry->getAnimation().getName().buffer());
|
||||||
|
#else
|
||||||
if (current_entry) other_name.parse_utf8(current_entry->getAnimation().getName().buffer());
|
if (current_entry) other_name.parse_utf8(current_entry->getAnimation().getName().buffer());
|
||||||
|
#endif
|
||||||
bool should_set_animation = !current_entry || (animation_name != other_name || current_entry->getLoop() != loop);
|
bool should_set_animation = !current_entry || (animation_name != other_name || current_entry->getLoop() != loop);
|
||||||
|
|
||||||
if (should_set_animation) {
|
if (should_set_animation) {
|
||||||
@ -428,7 +441,11 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
|
|||||||
auto current_entry = animation_state->getCurrent(track_index);
|
auto current_entry = animation_state->getCurrent(track_index);
|
||||||
bool should_set_mix = mix_duration >= 0;
|
bool should_set_mix = mix_duration >= 0;
|
||||||
String other_name;
|
String other_name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
if (current_entry) other_name = String::utf8(current_entry->getAnimation().getName().buffer());
|
||||||
|
#else
|
||||||
if (current_entry) other_name.parse_utf8(current_entry->getAnimation().getName().buffer());
|
if (current_entry) other_name.parse_utf8(current_entry->getAnimation().getName().buffer());
|
||||||
|
#endif
|
||||||
bool should_set_animation = !current_entry || (animation_name != other_name || current_entry->getLoop() != loop) || animation_changed;
|
bool should_set_animation = !current_entry || (animation_name != other_name || current_entry->getLoop() != loop) || animation_changed;
|
||||||
animation_changed = false;
|
animation_changed = false;
|
||||||
|
|
||||||
|
|||||||
@ -51,9 +51,13 @@
|
|||||||
#ifdef SPINE_GODOT_EXTENSION
|
#ifdef SPINE_GODOT_EXTENSION
|
||||||
#include <godot_cpp/classes/editor_file_system.hpp>
|
#include <godot_cpp/classes/editor_file_system.hpp>
|
||||||
#else
|
#else
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
#include "editor/file_system/editor_file_system.h"
|
||||||
|
#else
|
||||||
#include "editor/editor_file_system.h"
|
#include "editor/editor_file_system.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <spine/TextureLoader.h>
|
#include <spine/TextureLoader.h>
|
||||||
|
|
||||||
@ -146,7 +150,11 @@ public:
|
|||||||
|
|
||||||
void load(spine::AtlasPage &page, const spine::String &path) override {
|
void load(spine::AtlasPage &page, const spine::String &path) override {
|
||||||
String fixed_path;
|
String fixed_path;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
fixed_path = String::utf8(path.buffer());
|
||||||
|
#else
|
||||||
fixed_path.parse_utf8(path.buffer());
|
fixed_path.parse_utf8(path.buffer());
|
||||||
|
#endif
|
||||||
bool is_resource = fix_path(fixed_path);
|
bool is_resource = fix_path(fixed_path);
|
||||||
|
|
||||||
import_image_resource(fixed_path);
|
import_image_resource(fixed_path);
|
||||||
@ -295,7 +303,9 @@ Error SpineAtlasResource::load_from_atlas_file_internal(const String &path, bool
|
|||||||
clear();
|
clear();
|
||||||
texture_loader = new GodotSpineTextureLoader(&textures, &normal_maps, &specular_maps, normal_map_prefix, specular_map_prefix, is_importing);
|
texture_loader = new GodotSpineTextureLoader(&textures, &normal_maps, &specular_maps, normal_map_prefix, specular_map_prefix, is_importing);
|
||||||
auto atlas_utf8 = atlas_data.utf8();
|
auto atlas_utf8 = atlas_data.utf8();
|
||||||
atlas = new spine::Atlas(atlas_utf8, atlas_utf8.length(), source_path.get_base_dir().utf8(), texture_loader);
|
auto dir_utf8 = source_path.get_base_dir().utf8();
|
||||||
|
atlas = new spine::Atlas(atlas_utf8.ptr(), atlas_utf8.length(), dir_utf8.ptr(), texture_loader);
|
||||||
|
//atlas = new spine::Atlas(atlas_utf8, atlas_utf8.length(), source_path.get_base_dir().utf8(), texture_loader);
|
||||||
if (atlas) return OK;
|
if (atlas) return OK;
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
@ -338,7 +348,8 @@ Error SpineAtlasResource::load_from_file(const String &path) {
|
|||||||
clear();
|
clear();
|
||||||
texture_loader = new GodotSpineTextureLoader(&textures, &normal_maps, &specular_maps, normal_map_prefix, specular_map_prefix, false);
|
texture_loader = new GodotSpineTextureLoader(&textures, &normal_maps, &specular_maps, normal_map_prefix, specular_map_prefix, false);
|
||||||
auto utf8 = atlas_data.utf8();
|
auto utf8 = atlas_data.utf8();
|
||||||
atlas = new spine::Atlas(utf8.ptr(), utf8.size(), source_path.get_base_dir().utf8(), texture_loader);
|
auto dir_utf8 = source_path.get_base_dir().utf8();
|
||||||
|
atlas = new spine::Atlas(utf8.ptr(), utf8.size(), dir_utf8.ptr(), texture_loader);
|
||||||
if (atlas) return OK;
|
if (atlas) return OK;
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|||||||
@ -42,7 +42,11 @@ SpineAttachment::~SpineAttachment() {
|
|||||||
String SpineAttachment::get_attachment_name() {
|
String SpineAttachment::get_attachment_name() {
|
||||||
SPINE_CHECK(get_spine_object(), "")
|
SPINE_CHECK(get_spine_object(), "")
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(get_spine_object()->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||||
|
#endif
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,11 @@ int SpineBoneData::get_index() {
|
|||||||
String SpineBoneData::get_bone_name() {
|
String SpineBoneData::get_bone_name() {
|
||||||
SPINE_CHECK(get_spine_object(), "")
|
SPINE_CHECK(get_spine_object(), "")
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(get_spine_object()->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||||
|
#endif
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -100,8 +100,8 @@ using namespace godot;
|
|||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SPINE_STRING(x) spine::String((x).utf8())
|
#define SPINE_STRING(x) spine::String((x).utf8().ptr())
|
||||||
#define SPINE_STRING_TMP(x) spine::String((x).utf8(), true, false)
|
#define SPINE_STRING_TMP(x) spine::String((x).utf8().ptr(), true, false)
|
||||||
|
|
||||||
// Can't do template classes with Godot's object model :(
|
// Can't do template classes with Godot's object model :(
|
||||||
class SpineObjectWrapper : public REFCOUNTED {
|
class SpineObjectWrapper : public REFCOUNTED {
|
||||||
|
|||||||
@ -39,7 +39,11 @@ void SpineConstraintData::_bind_methods() {
|
|||||||
String SpineConstraintData::get_constraint_name() {
|
String SpineConstraintData::get_constraint_name() {
|
||||||
SPINE_CHECK(get_spine_object(), "")
|
SPINE_CHECK(get_spine_object(), "")
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(get_spine_object()->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||||
|
#endif
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,9 +44,14 @@
|
|||||||
#include <godot_cpp/classes/editor_property.hpp>
|
#include <godot_cpp/classes/editor_property.hpp>
|
||||||
#else
|
#else
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
#include "editor/inspector/editor_properties.h"
|
||||||
|
#include "editor/inspector/editor_properties_array_dict.h"
|
||||||
|
#else
|
||||||
#include "editor/editor_properties.h"
|
#include "editor/editor_properties.h"
|
||||||
#include "editor/editor_properties_array_dict.h"
|
#include "editor/editor_properties_array_dict.h"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
class SpineAtlasResourceImportPlugin : public EditorImportPlugin {
|
class SpineAtlasResourceImportPlugin : public EditorImportPlugin {
|
||||||
GDCLASS(SpineAtlasResourceImportPlugin, EditorImportPlugin)
|
GDCLASS(SpineAtlasResourceImportPlugin, EditorImportPlugin)
|
||||||
|
|||||||
@ -85,7 +85,7 @@ String SpineEvent::get_string_value() {
|
|||||||
|
|
||||||
void SpineEvent::set_string_value(const String &v) {
|
void SpineEvent::set_string_value(const String &v) {
|
||||||
SPINE_CHECK(get_spine_object(), )
|
SPINE_CHECK(get_spine_object(), )
|
||||||
get_spine_object()->setString(spine::String(v.utf8()));
|
get_spine_object()->setString(spine::String(v.utf8().ptr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineEvent::get_volume() {
|
float SpineEvent::get_volume() {
|
||||||
|
|||||||
@ -49,7 +49,11 @@ void SpineEventData::_bind_methods() {
|
|||||||
String SpineEventData::get_event_name() {
|
String SpineEventData::get_event_name() {
|
||||||
SPINE_CHECK(get_spine_object(), "")
|
SPINE_CHECK(get_spine_object(), "")
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(get_spine_object()->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||||
|
#endif
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +84,7 @@ String SpineEventData::get_string_value() {
|
|||||||
|
|
||||||
void SpineEventData::set_string_value(const String &v) {
|
void SpineEventData::set_string_value(const String &v) {
|
||||||
SPINE_CHECK(get_spine_object(), )
|
SPINE_CHECK(get_spine_object(), )
|
||||||
get_spine_object()->setString(spine::String(v.utf8()));
|
get_spine_object()->setString(spine::String(v.utf8().ptr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
String SpineEventData::get_audio_path() {
|
String SpineEventData::get_audio_path() {
|
||||||
@ -90,7 +94,7 @@ String SpineEventData::get_audio_path() {
|
|||||||
|
|
||||||
void SpineEventData::set_audio_path(const String &v) {
|
void SpineEventData::set_audio_path(const String &v) {
|
||||||
SPINE_CHECK(get_spine_object(), )
|
SPINE_CHECK(get_spine_object(), )
|
||||||
get_spine_object()->setAudioPath(spine::String(v.utf8()));
|
get_spine_object()->setAudioPath(spine::String(v.utf8().ptr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
float SpineEventData::get_volume() {
|
float SpineEventData::get_volume() {
|
||||||
|
|||||||
@ -33,11 +33,15 @@
|
|||||||
#ifdef SPINE_GODOT_EXTENSION
|
#ifdef SPINE_GODOT_EXTENSION
|
||||||
#include <godot_cpp/classes/encoded_object_as_id.hpp>
|
#include <godot_cpp/classes/encoded_object_as_id.hpp>
|
||||||
#include <godot_cpp/classes/engine.hpp>
|
#include <godot_cpp/classes/engine.hpp>
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
#include <godot_cpp/classes/editor_interface.hpp>
|
#include <godot_cpp/classes/editor_interface.hpp>
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#if VERSION_MAJOR > 3
|
#if VERSION_MAJOR > 3
|
||||||
#include "core/config/engine.h"
|
#include "core/config/engine.h"
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
#include "editor/editor_interface.h"
|
#include "editor/editor_interface.h"
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include "core/engine.h"
|
#include "core/engine.h"
|
||||||
#endif
|
#endif
|
||||||
@ -48,9 +52,13 @@
|
|||||||
#ifdef SPINE_GODOT_EXTENSION
|
#ifdef SPINE_GODOT_EXTENSION
|
||||||
#include <godot_cpp/classes/editor_file_system.hpp>
|
#include <godot_cpp/classes/editor_file_system.hpp>
|
||||||
#else
|
#else
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
#include "editor/file_system/editor_file_system.h"
|
||||||
|
#else
|
||||||
#include "editor/editor_file_system.h"
|
#include "editor/editor_file_system.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
void SpineAnimationMix::_bind_methods() {
|
void SpineAnimationMix::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_from", "from"), &SpineAnimationMix::set_from);
|
ClassDB::bind_method(D_METHOD("set_from", "from"), &SpineAnimationMix::set_from);
|
||||||
@ -290,7 +298,7 @@ void SpineSkeletonDataResource::load_resources(spine::Atlas *atlas, const String
|
|||||||
spine::SkeletonData *data;
|
spine::SkeletonData *data;
|
||||||
if (!EMPTY(json)) {
|
if (!EMPTY(json)) {
|
||||||
spine::SkeletonJson skeletonJson(*atlas);
|
spine::SkeletonJson skeletonJson(*atlas);
|
||||||
data = skeletonJson.readSkeletonData(json.utf8());
|
data = skeletonJson.readSkeletonData(json.utf8().ptr());
|
||||||
if (!data) {
|
if (!data) {
|
||||||
ERR_PRINT(String("Error while loading skeleton data: ") + get_path());
|
ERR_PRINT(String("Error while loading skeleton data: ") + get_path());
|
||||||
ERR_PRINT(String("Error message: ") + skeletonJson.getError().buffer());
|
ERR_PRINT(String("Error message: ") + skeletonJson.getError().buffer());
|
||||||
@ -343,7 +351,11 @@ void SpineSkeletonDataResource::get_animation_names(Vector<String> &animation_na
|
|||||||
for (size_t i = 0; i < animations.size(); ++i) {
|
for (size_t i = 0; i < animations.size(); ++i) {
|
||||||
auto animation = animations[i];
|
auto animation = animations[i];
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(animation->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(animation->getName().buffer());
|
name.parse_utf8(animation->getName().buffer());
|
||||||
|
#endif
|
||||||
animation_names.push_back(name);
|
animation_names.push_back(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -359,7 +371,11 @@ void SpineSkeletonDataResource::get_skin_names(Vector<String> &skin_names) const
|
|||||||
for (size_t i = 0; i < skins.size(); ++i) {
|
for (size_t i = 0; i < skins.size(); ++i) {
|
||||||
auto skin = skins[i];
|
auto skin = skins[i];
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(skin->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(skin->getName().buffer());
|
name.parse_utf8(skin->getName().buffer());
|
||||||
|
#endif
|
||||||
skin_names.push_back(name);
|
skin_names.push_back(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -375,7 +391,11 @@ void SpineSkeletonDataResource::get_slot_names(Vector<String> &slot_names) {
|
|||||||
for (size_t i = 0; i < slots.size(); ++i) {
|
for (size_t i = 0; i < slots.size(); ++i) {
|
||||||
auto slot = slots[i];
|
auto slot = slots[i];
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(slot->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(slot->getName().buffer());
|
name.parse_utf8(slot->getName().buffer());
|
||||||
|
#endif
|
||||||
slot_names.push_back(name);
|
slot_names.push_back(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,7 +411,11 @@ void SpineSkeletonDataResource::get_bone_names(Vector<String> &bone_names) {
|
|||||||
for (size_t i = 0; i < bones.size(); ++i) {
|
for (size_t i = 0; i < bones.size(); ++i) {
|
||||||
auto bone = bones[i];
|
auto bone = bones[i];
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(bone->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(bone->getName().buffer());
|
name.parse_utf8(bone->getName().buffer());
|
||||||
|
#endif
|
||||||
bone_names.push_back(name);
|
bone_names.push_back(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,7 +563,11 @@ Ref<SpinePhysicsConstraintData> SpineSkeletonDataResource::find_physics_constrai
|
|||||||
String SpineSkeletonDataResource::get_skeleton_name() const {
|
String SpineSkeletonDataResource::get_skeleton_name() const {
|
||||||
SPINE_CHECK(skeleton_data, "")
|
SPINE_CHECK(skeleton_data, "")
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(skeleton_data->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(skeleton_data->getName().buffer());
|
name.parse_utf8(skeleton_data->getName().buffer());
|
||||||
|
#endif
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -135,7 +135,7 @@ Error SpineSkeletonFileResource::load_from_file(const String &path) {
|
|||||||
json = FileAccess::get_file_as_string(path, &error);
|
json = FileAccess::get_file_as_string(path, &error);
|
||||||
if (error != OK) return error;
|
if (error != OK) return error;
|
||||||
#endif
|
#endif
|
||||||
if (!checkJson(json.utf8())) return ERR_INVALID_DATA;
|
if (!checkJson(json.utf8().ptr())) return ERR_INVALID_DATA;
|
||||||
} else {
|
} else {
|
||||||
#ifdef SPINE_GODOT_EXTENSION
|
#ifdef SPINE_GODOT_EXTENSION
|
||||||
binary = FileAccess::get_file_as_bytes(path);
|
binary = FileAccess::get_file_as_bytes(path);
|
||||||
|
|||||||
@ -125,7 +125,11 @@ Array SpineSkin::find_attachments_for_slot(int slot_index) {
|
|||||||
String SpineSkin::get_name() {
|
String SpineSkin::get_name() {
|
||||||
SPINE_CHECK(get_spine_object(), "")
|
SPINE_CHECK(get_spine_object(), "")
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(get_spine_object()->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||||
|
#endif
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,11 @@ int SpineSlotData::get_index() {
|
|||||||
String SpineSlotData::get_name() {
|
String SpineSlotData::get_name() {
|
||||||
SPINE_CHECK(get_spine_object(), String(""))
|
SPINE_CHECK(get_spine_object(), String(""))
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(get_spine_object()->getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||||
|
#endif
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,9 @@
|
|||||||
#include <godot_cpp/variant/array.hpp>
|
#include <godot_cpp/variant/array.hpp>
|
||||||
#include <godot_cpp/classes/mesh.hpp>
|
#include <godot_cpp/classes/mesh.hpp>
|
||||||
#include <godot_cpp/classes/rendering_server.hpp>
|
#include <godot_cpp/classes/rendering_server.hpp>
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
#include <godot_cpp/classes/editor_interface.hpp>
|
#include <godot_cpp/classes/editor_interface.hpp>
|
||||||
|
#endif
|
||||||
#include <godot_cpp/classes/control.hpp>
|
#include <godot_cpp/classes/control.hpp>
|
||||||
#include <godot_cpp/classes/viewport.hpp>
|
#include <godot_cpp/classes/viewport.hpp>
|
||||||
#include <godot_cpp/classes/scene_tree.hpp>
|
#include <godot_cpp/classes/scene_tree.hpp>
|
||||||
@ -60,7 +62,7 @@
|
|||||||
#include "scene/resources/mesh.h"
|
#include "scene/resources/mesh.h"
|
||||||
#include "servers/rendering_server.h"
|
#include "servers/rendering_server.h"
|
||||||
#include "scene/resources/canvas_item_material.h"
|
#include "scene/resources/canvas_item_material.h"
|
||||||
#if VERSION_MINOR > 0
|
#if VERSION_MINOR > 0 && defined(TOOLS_ENABLED)
|
||||||
#include "editor/editor_interface.h"
|
#include "editor/editor_interface.h"
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
@ -171,10 +173,16 @@ static void add_triangles(SpineMesh2D *mesh_instance, const Vector<Point2> &vert
|
|||||||
auto texture = renderer_object->texture;
|
auto texture = renderer_object->texture;
|
||||||
auto normal_map = renderer_object->normal_map;
|
auto normal_map = renderer_object->normal_map;
|
||||||
auto specular_map = renderer_object->specular_map;
|
auto specular_map = renderer_object->specular_map;
|
||||||
|
#if VERSION_MAJOR > 3
|
||||||
VisualServer::get_singleton()->canvas_item_add_triangle_array(mesh_instance->get_canvas_item(), indices, vertices, colors, uvs, Vector<int>(),
|
VisualServer::get_singleton()->canvas_item_add_triangle_array(mesh_instance->get_canvas_item(), indices, vertices, colors, uvs, Vector<int>(),
|
||||||
Vector<float>(), texture.is_null() ? RID() : texture->get_rid(), -1,
|
Vector<float>(), texture.is_null() ? RID() : texture->get_rid(), -1,
|
||||||
normal_map.is_null() ? RID() : normal_map->get_rid(),
|
normal_map.is_null() ? RID() : normal_map->get_rid(),
|
||||||
specular_map.is_null() ? RID() : specular_map->get_rid());
|
specular_map.is_null() ? RID() : specular_map->get_rid());
|
||||||
|
#else
|
||||||
|
VisualServer::get_singleton()->canvas_item_add_triangle_array(mesh_instance->get_canvas_item(), indices, vertices, colors, uvs, Vector<int>(),
|
||||||
|
Vector<float>(), texture.is_null() ? RID() : texture->get_rid(), -1,
|
||||||
|
normal_map.is_null() ? RID() : normal_map->get_rid());
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -374,11 +382,16 @@ void SpineMesh2D::update_mesh(const Vector<Point2> &vertices, const Vector<Point
|
|||||||
VS::get_singleton()->mesh_surface_update_region(mesh, 0, 0, mesh_buffer);
|
VS::get_singleton()->mesh_surface_update_region(mesh, 0, 0, mesh_buffer);
|
||||||
VS::get_singleton()->mesh_set_custom_aabb(mesh, aabb_new);
|
VS::get_singleton()->mesh_set_custom_aabb(mesh, aabb_new);
|
||||||
}
|
}
|
||||||
|
#if VERSION_MAJOR > 3
|
||||||
VS::get_singleton()->canvas_item_add_mesh(this->get_canvas_item(), mesh, Transform2D(), Color(1, 1, 1, 1),
|
VS::get_singleton()->canvas_item_add_mesh(this->get_canvas_item(), mesh, Transform2D(), Color(1, 1, 1, 1),
|
||||||
renderer_object->texture.is_null() ? RID() : renderer_object->texture->get_rid(),
|
renderer_object->texture.is_null() ? RID() : renderer_object->texture->get_rid(),
|
||||||
renderer_object->normal_map.is_null() ? RID() : renderer_object->normal_map->get_rid(),
|
renderer_object->normal_map.is_null() ? RID() : renderer_object->normal_map->get_rid(),
|
||||||
renderer_object->specular_map.is_null() ? RID() : renderer_object->specular_map->get_rid());
|
renderer_object->specular_map.is_null() ? RID() : renderer_object->specular_map->get_rid());
|
||||||
|
#else
|
||||||
|
VS::get_singleton()->canvas_item_add_mesh(this->get_canvas_item(), mesh, Transform2D(), Color(1, 1, 1, 1),
|
||||||
|
renderer_object->texture.is_null() ? RID() : renderer_object->texture->get_rid(),
|
||||||
|
renderer_object->normal_map.is_null() ? RID() : renderer_object->normal_map->get_rid());
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1124,7 +1137,8 @@ void SpineSprite::draw() {
|
|||||||
auto bounding_box = (spine::BoundingBoxAttachment *) attachment;
|
auto bounding_box = (spine::BoundingBoxAttachment *) attachment;
|
||||||
auto vertices = &statics.scratch_vertices;
|
auto vertices = &statics.scratch_vertices;
|
||||||
vertices->setSize(bounding_box->getWorldVerticesLength(), 0);
|
vertices->setSize(bounding_box->getWorldVerticesLength(), 0);
|
||||||
bounding_box->computeWorldVertices(*skeleton->get_spine_object(), *slot, 0, bounding_box->getWorldVerticesLength(), vertices->buffer(), 0, 2);
|
bounding_box->computeWorldVertices(*skeleton->get_spine_object(), *slot, 0, bounding_box->getWorldVerticesLength(), vertices->buffer(), 0,
|
||||||
|
2);
|
||||||
size_t num_vertices = vertices->size() / 2;
|
size_t num_vertices = vertices->size() / 2;
|
||||||
statics.scratch_points.resize((int) num_vertices);
|
statics.scratch_points.resize((int) num_vertices);
|
||||||
memcpy(statics.scratch_points.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float));
|
memcpy(statics.scratch_points.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float));
|
||||||
@ -1220,7 +1234,11 @@ void SpineSprite::draw() {
|
|||||||
Vector<String> hover_text_lines;
|
Vector<String> hover_text_lines;
|
||||||
if (hovered_slot) {
|
if (hovered_slot) {
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(hovered_slot->getData().getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(hovered_slot->getData().getName().buffer());
|
name.parse_utf8(hovered_slot->getData().getName().buffer());
|
||||||
|
#endif
|
||||||
hover_text_lines.push_back(String("Slot: ") + name);
|
hover_text_lines.push_back(String("Slot: ") + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1230,7 +1248,11 @@ void SpineSprite::draw() {
|
|||||||
draw_bone(hovered_bone, Color(debug_bones_color.r, debug_bones_color.g, debug_bones_color.b, 1));
|
draw_bone(hovered_bone, Color(debug_bones_color.r, debug_bones_color.g, debug_bones_color.b, 1));
|
||||||
debug_bones_thickness = thickness;
|
debug_bones_thickness = thickness;
|
||||||
String name;
|
String name;
|
||||||
|
#if (VERSION_MAJOR >= 4 && VERSION_MINOR >= 5)
|
||||||
|
name = String::utf8(hovered_bone->getData().getName().buffer());
|
||||||
|
#else
|
||||||
name.parse_utf8(hovered_bone->getData().getName().buffer());
|
name.parse_utf8(hovered_bone->getData().getName().buffer());
|
||||||
|
#endif
|
||||||
hover_text_lines.push_back(String("Bone: ") + name);
|
hover_text_lines.push_back(String("Bone: ") + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1289,7 +1311,8 @@ void SpineSprite::draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpineSprite::draw_bone(spine::Bone *bone, const Color &color) {
|
void SpineSprite::draw_bone(spine::Bone *bone, const Color &color) {
|
||||||
draw_set_transform(Vector2(bone->getAppliedPose().getWorldX(), bone->getAppliedPose().getWorldY()), spine::MathUtil::Deg_Rad * bone->getAppliedPose().getWorldRotationX(),
|
draw_set_transform(Vector2(bone->getAppliedPose().getWorldX(), bone->getAppliedPose().getWorldY()),
|
||||||
|
spine::MathUtil::Deg_Rad * bone->getAppliedPose().getWorldRotationX(),
|
||||||
Vector2(bone->getAppliedPose().getWorldScaleX(), bone->getAppliedPose().getWorldScaleY()));
|
Vector2(bone->getAppliedPose().getWorldScaleX(), bone->getAppliedPose().getWorldScaleY()));
|
||||||
float bone_length = bone->getData().getLength();
|
float bone_length = bone->getData().getLength();
|
||||||
if (bone_length == 0) bone_length = debug_bones_thickness * 2;
|
if (bone_length == 0) bone_length = debug_bones_thickness * 2;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user