mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[godot] Non-working but compiling state. Crashes when registering various inspectors/editor plugins
This commit is contained in:
parent
e9b43f9c73
commit
887f20435f
1
.gitignore
vendored
1
.gitignore
vendored
@ -212,3 +212,4 @@ spine-godot/example-v4-extension/.godot
|
||||
spine-godot/src
|
||||
spine-godot/compile_commands.json
|
||||
spine-godot/bin
|
||||
spine-godot/example-v4-extension/bin/macos/macos.framework/libspine_godot.macos.editor
|
||||
|
||||
20
spine-godot/.vscode/launch.json
vendored
20
spine-godot/.vscode/launch.json
vendored
@ -29,6 +29,26 @@
|
||||
"program": "${workspaceFolder}/godot/bin/godot.macos.editor.dev.arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"name": "debug editor extension",
|
||||
"program": "godot/bin/godot.windows.editor.dev.x86_64.exe",
|
||||
"args": ["-e", "--path", "example-v4-extension"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"linux": {
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "debug editor extension",
|
||||
"program": "${workspaceFolder}/godot/bin/godot.linux.editor.dev.x86_64"
|
||||
},
|
||||
"osx": {
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "debug editor extension",
|
||||
"program": "/Applications/Godot 4.3 Debug.app/Contents/MacOS/Godot"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
|
||||
@ -67,9 +67,43 @@ Run the following command to download godot-cpp:
|
||||
env = SConscript("godot-cpp/SConstruct", {"env": env, "customs": customs})
|
||||
|
||||
env.Append(CPPDEFINES=["SPINE_GODOT_EXTENSION"])
|
||||
env.Append(CPPPATH=["spine_godot/", "spine_godot/spine-cpp/include"])
|
||||
env.Append(CPPPATH=["spine_godot", "spine_godot/spine-cpp/include"])
|
||||
|
||||
sources = Glob("spine_godot/*.cpp") + Glob("spine_godot/spine-cpp/src/spine/*.cpp")
|
||||
# sources = Glob("spine_godot/*.cpp") + Glob("spine_godot/spine-cpp/src/spine/*.cpp")
|
||||
sources = Glob("spine_godot/spine-cpp/src/spine/*.cpp")
|
||||
sources.append("spine_godot/GodotSpineExtension.cpp")
|
||||
sources.append("spine_godot/SpineAnimation.cpp")
|
||||
sources.append("spine_godot/SpineAnimationState.cpp")
|
||||
sources.append("spine_godot/SpineAnimationTrack.cpp")
|
||||
sources.append("spine_godot/SpineAtlasResource.cpp")
|
||||
sources.append("spine_godot/SpineAttachment.cpp")
|
||||
sources.append("spine_godot/SpineBone.cpp")
|
||||
sources.append("spine_godot/SpineBoneData.cpp")
|
||||
sources.append("spine_godot/SpineBoneNode.cpp")
|
||||
sources.append("spine_godot/SpineConstant.cpp")
|
||||
sources.append("spine_godot/SpineConstraintData.cpp")
|
||||
sources.append("spine_godot/SpineEditorPlugin.cpp")
|
||||
sources.append("spine_godot/SpineEvent.cpp")
|
||||
sources.append("spine_godot/SpineEventData.cpp")
|
||||
sources.append("spine_godot/SpineIkConstraint.cpp")
|
||||
sources.append("spine_godot/SpineIkConstraintData.cpp")
|
||||
sources.append("spine_godot/SpinePathConstraint.cpp")
|
||||
sources.append("spine_godot/SpinePathConstraintData.cpp")
|
||||
sources.append("spine_godot/SpinePhysicsConstraint.cpp")
|
||||
sources.append("spine_godot/SpinePhysicsConstraintData.cpp")
|
||||
sources.append("spine_godot/SpineSkeleton.cpp")
|
||||
sources.append("spine_godot/SpineSkeletonDataResource.cpp")
|
||||
sources.append("spine_godot/SpineSkeletonFileResource.cpp")
|
||||
sources.append("spine_godot/SpineSkin.cpp")
|
||||
sources.append("spine_godot/SpineSlot.cpp")
|
||||
sources.append("spine_godot/SpineSlotData.cpp")
|
||||
sources.append("spine_godot/SpineSlotNode.cpp")
|
||||
sources.append("spine_godot/SpineSprite.cpp")
|
||||
sources.append("spine_godot/SpineTimeline.cpp")
|
||||
sources.append("spine_godot/SpineTrackEntry.cpp")
|
||||
sources.append("spine_godot/SpineTransformConstraint.cpp")
|
||||
sources.append("spine_godot/SpineTransformConstraintData.cpp")
|
||||
sources.append("spine_godot/register_types.cpp")
|
||||
|
||||
if env["target"] in ["editor", "template_debug"]:
|
||||
try:
|
||||
|
||||
Binary file not shown.
@ -5,7 +5,7 @@ compatibility_minimum = "4.1"
|
||||
|
||||
[libraries]
|
||||
|
||||
macos.debug = "res://bin/macos/macos.framework/libspine_godot.macos.template_debug"
|
||||
macos.debug = "res://bin/macos/macos.framework/libspine_godot.macos.editor"
|
||||
macos.release = "res://bin/macos/macos.framework/libspine_godot.macos.template_release"
|
||||
ios.debug = "res://bin/ios/ios.framework/libspine_godot.ios.template_debug"
|
||||
ios.release = "res://bin/ios/ios.framework/libspine_godot.ios.template_release"
|
||||
|
||||
@ -5,7 +5,7 @@ compatibility_minimum = "4.1"
|
||||
|
||||
[libraries]
|
||||
|
||||
macos.debug = "res://bin/macos/macos.framework/libspine_godot.macos.template_debug"
|
||||
macos.debug = "res://bin/macos/macos.framework/libspine_godot.macos.editor"
|
||||
macos.release = "res://bin/macos/macos.framework/libspine_godot.macos.template_release"
|
||||
ios.debug = "res://bin/ios/ios.framework/libspine_godot.ios.template_debug"
|
||||
ios.release = "res://bin/ios/ios.framework/libspine_godot.ios.template_release"
|
||||
|
||||
@ -103,6 +103,8 @@ class SpineAtlasResourceFormatLoader : public ResourceFormatLoader {
|
||||
|
||||
public:
|
||||
#ifdef SPINE_GODOT_EXTENSION
|
||||
static void _bind_methods() {};
|
||||
|
||||
PackedStringArray _get_recognized_extensions();
|
||||
|
||||
bool _handles_type(const StringName &type);
|
||||
@ -134,8 +136,12 @@ class SpineAtlasResourceFormatSaver : public ResourceFormatSaver {
|
||||
|
||||
public:
|
||||
#ifdef SPINE_GODOT_EXTENSION
|
||||
static void _bind_methods() {};
|
||||
|
||||
Error _save(const Ref<Resource> &resource, const String &path, uint32_t flags) override;
|
||||
|
||||
bool _recognize(const Ref<Resource> &resource);
|
||||
|
||||
PackedStringArray _get_recognized_extensions(const Ref<Resource> &resource);
|
||||
#else
|
||||
#if VERSION_MAJOR > 3
|
||||
|
||||
@ -144,7 +144,7 @@ SpineEditorPlugin::SpineEditorPlugin() {
|
||||
add_import_plugin(memnew(SpineJsonResourceImportPlugin));
|
||||
add_import_plugin(memnew(SpineBinaryResourceImportPlugin));
|
||||
add_inspector_plugin(memnew(SpineSkeletonDataResourceInspectorPlugin));
|
||||
add_inspector_plugin(memnew(SpineSpriteInspectorPlugin));
|
||||
// add_inspector_plugin(memnew(SpineSpriteInspectorPlugin));
|
||||
}
|
||||
#else
|
||||
SpineEditorPlugin::SpineEditorPlugin(EditorNode *node) {
|
||||
|
||||
@ -53,6 +53,8 @@ class SpineAtlasResourceImportPlugin : public EditorImportPlugin {
|
||||
|
||||
public:
|
||||
#ifdef SPINE_GODOT_EXTENSION
|
||||
static void _bind_methods() {};
|
||||
|
||||
String _get_importer_name() const override { return "spine.atlas"; }
|
||||
|
||||
String _get_visible_name() const override { return "Spine Runtime Atlas"; }
|
||||
@ -120,6 +122,8 @@ class SpineJsonResourceImportPlugin : public EditorImportPlugin {
|
||||
|
||||
public:
|
||||
#ifdef SPINE_GODOT_EXTENSION
|
||||
static void _bind_methods() {};
|
||||
|
||||
String _get_importer_name() const override { return "spine.json"; }
|
||||
|
||||
String _get_visible_name() const override { return "Spine Skeleton Json"; }
|
||||
@ -187,6 +191,8 @@ class SpineBinaryResourceImportPlugin : public EditorImportPlugin {
|
||||
|
||||
public:
|
||||
#ifdef SPINE_GODOT_EXTENSION
|
||||
static void _bind_methods() {};
|
||||
|
||||
String _get_importer_name() const override { return "spine.skel"; }
|
||||
|
||||
String _get_visible_name() const override { return "Spine Skeleton Binary"; }
|
||||
@ -271,6 +277,8 @@ class SpineSkeletonDataResourceInspectorPlugin : public EditorInspectorPlugin {
|
||||
|
||||
public:
|
||||
#ifdef SPINE_GODOT_EXTENSION
|
||||
static void _bind_methods() {}
|
||||
|
||||
bool _can_handle(Object *p_object) const override;
|
||||
bool _parse_property(Object *object, Variant::Type type, const String &path, PropertyHint hint, const String &hint_text, const BitField<PropertyUsageFlags> p_usage, bool wide) override;
|
||||
#else
|
||||
|
||||
@ -83,6 +83,8 @@ class SpineSkeletonFileResourceFormatLoader : public ResourceFormatLoader {
|
||||
|
||||
public:
|
||||
#ifdef SPINE_GODOT_EXTENSION
|
||||
static void _bind_methods() {};
|
||||
|
||||
PackedStringArray _get_recognized_extensions();
|
||||
|
||||
bool _handles_type(const StringName &type);
|
||||
@ -114,8 +116,12 @@ class SpineSkeletonFileResourceFormatSaver : public ResourceFormatSaver {
|
||||
|
||||
public:
|
||||
#ifdef SPINE_GODOT_EXTENSION
|
||||
static void _bind_methods() {};
|
||||
|
||||
Error _save(const Ref<Resource> &resource, const String &path, uint32_t flags) override;
|
||||
|
||||
bool _recognize(const Ref<Resource> &resource);
|
||||
|
||||
PackedStringArray _get_recognized_extensions(const Ref<Resource> &resource);
|
||||
#else
|
||||
#if VERSION_MAJOR > 3
|
||||
|
||||
@ -84,7 +84,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Ref<CanvasItemMaterial>
|
||||
/*Ref<CanvasItemMaterial>
|
||||
SpineSprite::default_materials[4] = {};
|
||||
static int sprite_count = 0;
|
||||
static spine::Vector<unsigned short> quad_indices;
|
||||
@ -93,7 +93,7 @@ static spine::Vector<float> scratch_vertices;
|
||||
static PackedVector2Array scratch_points;
|
||||
#else
|
||||
static Vector<Vector2> scratch_points;
|
||||
#endif
|
||||
#endif*/
|
||||
|
||||
|
||||
static void clear_triangles(SpineMesh2D *mesh_instance) {
|
||||
@ -403,7 +403,7 @@ void SpineSprite::_bind_methods() {
|
||||
}
|
||||
|
||||
SpineSprite::SpineSprite() : update_mode(SpineConstant::UpdateMode_Process), preview_skin("Default"), preview_animation("-- Empty --"), preview_frame(false), preview_time(0), skeleton_clipper(nullptr), modified_bones(false) {
|
||||
skeleton_clipper = new spine::SkeletonClipping();
|
||||
/*skeleton_clipper = new spine::SkeletonClipping();
|
||||
|
||||
// One material per blend mode, shared across all sprites.
|
||||
if (!default_materials[0].is_valid()) {
|
||||
@ -453,16 +453,16 @@ SpineSprite::SpineSprite() : update_mode(SpineConstant::UpdateMode_Process), pre
|
||||
debug_clipping = false;
|
||||
debug_clipping_color = Color(0.8, 0, 0, 0.8);
|
||||
|
||||
sprite_count++;
|
||||
sprite_count++;*/
|
||||
}
|
||||
|
||||
SpineSprite::~SpineSprite() {
|
||||
delete skeleton_clipper;
|
||||
sprite_count--;
|
||||
/*sprite_count--;
|
||||
if (!sprite_count) {
|
||||
for (int i = 0; i < 4; i++)
|
||||
default_materials[i].unref();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void SpineSprite::set_skeleton_data_res(const Ref<SpineSkeletonDataResource> &_skeleton_data) {
|
||||
@ -513,7 +513,7 @@ void SpineSprite::on_skeleton_data_changed() {
|
||||
}
|
||||
|
||||
void SpineSprite::generate_meshes_for_slots(Ref<SpineSkeleton> skeleton_ref) {
|
||||
auto skeleton = skeleton_ref->get_spine_object();
|
||||
/*auto skeleton = skeleton_ref->get_spine_object();
|
||||
for (int i = 0, n = (int) skeleton->getSlots().size(); i < n; i++) {
|
||||
auto mesh_instance = memnew(SpineMesh2D);
|
||||
mesh_instance->set_position(Vector2(0, 0));
|
||||
@ -523,7 +523,7 @@ void SpineSprite::generate_meshes_for_slots(Ref<SpineSkeleton> skeleton_ref) {
|
||||
add_child(mesh_instance);
|
||||
mesh_instances.push_back(mesh_instance);
|
||||
slot_nodes.add(spine::Vector<SpineSlotNode *>());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void SpineSprite::remove_meshes() {
|
||||
@ -758,7 +758,7 @@ void SpineSprite::update_skeleton(float delta) {
|
||||
}
|
||||
|
||||
void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
|
||||
spine::Skeleton *skeleton = skeleton_ref->get_spine_object();
|
||||
/*spine::Skeleton *skeleton = skeleton_ref->get_spine_object();
|
||||
for (int i = 0, n = (int) skeleton->getSlots().size(); i < n; ++i) {
|
||||
spine::Slot *slot = skeleton->getDrawOrder()[i];
|
||||
spine::Attachment *attachment = slot->getAttachment();
|
||||
@ -917,7 +917,7 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
|
||||
}
|
||||
skeleton_clipper->clipEnd(*slot);
|
||||
}
|
||||
skeleton_clipper->clipEnd();
|
||||
skeleton_clipper->clipEnd();*/
|
||||
}
|
||||
|
||||
#ifdef SPINE_GODOT_EXTENSION
|
||||
@ -943,7 +943,7 @@ void createLinesFromMesh(Vector<Vector2> &scratch_points, spine::Vector<unsigned
|
||||
}
|
||||
|
||||
void SpineSprite::draw() {
|
||||
if (!animation_state.is_valid() && !skeleton.is_valid()) return;
|
||||
/*if (!animation_state.is_valid() && !skeleton.is_valid()) return;
|
||||
if (!Engine::get_singleton()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) return;
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
@ -1199,7 +1199,7 @@ void SpineSprite::draw() {
|
||||
draw_string(default_font, Vector2(10, 0 + i * default_font->get_height()), hover_text_lines[i], Color(1, 1, 1, 1));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif*/
|
||||
}
|
||||
|
||||
void SpineSprite::draw_bone(spine::Bone *bone, const Color &color) {
|
||||
|
||||
@ -165,7 +165,7 @@ protected:
|
||||
|
||||
spine::Vector<spine::Vector<SpineSlotNode *>> slot_nodes;
|
||||
Vector<SpineMesh2D *> mesh_instances;
|
||||
static Ref<CanvasItemMaterial> default_materials[4];
|
||||
// static Ref<CanvasItemMaterial> default_materials[4];
|
||||
Ref<Material> normal_material;
|
||||
Ref<Material> additive_material;
|
||||
Ref<Material> multiply_material;
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#include "SpineCommon.h"
|
||||
#ifdef SPINE_GODOT_EXTENSION
|
||||
#else
|
||||
@ -79,10 +80,17 @@ static void editor_init_callback() {
|
||||
|
||||
#ifdef SPINE_GODOT_EXTENSION
|
||||
void initialize_spine_godot_module(ModuleInitializationLevel level) {
|
||||
printf(">>>>>>>>>>>> level: %i\n", level);
|
||||
if (level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
||||
GDREGISTER_CLASS(SpineAtlasResourceImportPlugin);
|
||||
GDREGISTER_CLASS(SpineJsonResourceImportPlugin);
|
||||
GDREGISTER_CLASS(SpineBinaryResourceImportPlugin);
|
||||
GDREGISTER_CLASS(SpineSkeletonDataResourceInspectorPlugin);
|
||||
GDREGISTER_CLASS(SpineEditorPlugin);
|
||||
EditorPlugins::add_plugin_class(StringName("SpineEditorPlugin"));
|
||||
printf(">>>>>>>>>>>> registered editor plugin");
|
||||
}
|
||||
if (level != MODULE_INITIALIZATION_LEVEL_SCENE) return;
|
||||
#else
|
||||
#if VERSION_MAJOR > 3
|
||||
void initialize_spine_godot_module(ModuleInitializationLevel level) {
|
||||
@ -103,6 +111,12 @@ void register_spine_godot_types() {
|
||||
#endif
|
||||
#endif
|
||||
spine::Bone::setYDown(true);
|
||||
|
||||
GDREGISTER_CLASS(SpineAtlasResourceFormatLoader);
|
||||
GDREGISTER_CLASS(SpineAtlasResourceFormatSaver);
|
||||
GDREGISTER_CLASS(SpineSkeletonFileResourceFormatLoader);
|
||||
GDREGISTER_CLASS(SpineSkeletonFileResourceFormatSaver);
|
||||
|
||||
GDREGISTER_CLASS(SpineObjectWrapper);
|
||||
GDREGISTER_CLASS(SpineAtlasResource);
|
||||
GDREGISTER_CLASS(SpineSkeletonFileResource);
|
||||
@ -180,10 +194,12 @@ void register_spine_godot_types() {
|
||||
ResourceSaver::add_resource_format_saver(skeleton_file_saver);
|
||||
#endif
|
||||
#endif
|
||||
printf(">>>>>>>>>>>>>>>>>>>> fuck\n");
|
||||
}
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
void uninitialize_spine_godot_module(ModuleInitializationLevel level) {
|
||||
return;
|
||||
if (level != MODULE_INITIALIZATION_LEVEL_CORE) return;
|
||||
#else
|
||||
void unregister_spine_godot_types() {
|
||||
@ -208,7 +224,6 @@ extern "C" GDExtensionBool GDE_EXPORT spine_godot_library_init(GDExtensionInterf
|
||||
init_obj.register_initializer(initialize_spine_godot_module);
|
||||
init_obj.register_terminator(uninitialize_spine_godot_module);
|
||||
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_CORE);
|
||||
|
||||
return init_obj.init();
|
||||
}
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user