diff --git a/spine-c/CMakeLists.txt b/spine-c/CMakeLists.txt index 1cd18ffca..0e568171b 100644 --- a/spine-c/CMakeLists.txt +++ b/spine-c/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(spine-c-new C CXX) +project(spine-c C CXX) set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 11) @@ -11,7 +11,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../flags.cmake) add_subdirectory(../spine-cpp ${CMAKE_CURRENT_BINARY_DIR}/spine-cpp) # Collect all source files -file(GLOB SOURCES +file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" ) @@ -21,26 +21,28 @@ file(GLOB GENERATED_SOURCES list(APPEND SOURCES ${GENERATED_SOURCES}) # Create the library -add_library(spine-c-new STATIC ${SOURCES}) +add_library(spine-c STATIC ${SOURCES}) # Include directories -target_include_directories(spine-c-new PUBLIC +target_include_directories(spine-c PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src ) # Link with spine-cpp -target_link_libraries(spine-c-new PRIVATE spine-cpp) +target_link_libraries(spine-c PUBLIC spine-cpp) # Add spine-cpp include directories -target_include_directories(spine-c-new PRIVATE +target_include_directories(spine-c PUBLIC ../spine-cpp/spine-cpp/include ) # Export compile commands for better IDE support set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# Create test executable -add_executable(spine-c-test test/test.c) -target_link_libraries(spine-c-test spine-c-new) -target_include_directories(spine-c-test PRIVATE include) \ No newline at end of file +# Create test executable only if this is the top-level project +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + add_executable(spine-c-test test/test.c) + target_link_libraries(spine-c-test spine-c) + target_include_directories(spine-c-test PRIVATE include) +endif() \ No newline at end of file diff --git a/spine-c/codegen/spine-cpp-types.json b/spine-c/codegen/spine-cpp-types.json index 7886c3930..4fa56b08c 100644 --- a/spine-c/codegen/spine-cpp-types.json +++ b/spine-c/codegen/spine-cpp-types.json @@ -3047,7 +3047,8 @@ }, "superTypes": [ "PosedGeneric", - "PosedActive" + "PosedActive", + "Update" ], "members": [ { @@ -3133,6 +3134,25 @@ "isPure": false, "isConst": false }, + { + "kind": "method", + "name": "update", + "returnType": "void", + "parameters": [ + { + "name": "skeleton", + "type": "Skeleton &" + }, + { + "name": "physics", + "type": "Physics" + } + ], + "isStatic": false, + "isVirtual": true, + "isPure": false, + "isConst": false + }, { "kind": "method", "name": "getData", @@ -8296,7 +8316,7 @@ "name": "ConstraintGeneric", "kind": "class", "loc": { - "line": 70, + "line": 71, "col": 15 }, "superTypes": [ @@ -10253,11 +10273,136 @@ } ], "spine/Debug.h": [ + { + "name": "DebugHashMap", + "kind": "class", + "loc": { + "line": 41, + "col": 8 + }, + "members": [ + { + "kind": "constructor", + "name": "DebugHashMap", + "parameters": [] + }, + { + "kind": "destructor", + "name": "~DebugHashMap", + "isVirtual": false, + "isPure": false + }, + { + "kind": "method", + "name": "clear", + "returnType": "void", + "parameters": [], + "isStatic": false, + "isVirtual": false, + "isPure": false, + "isConst": false + }, + { + "kind": "method", + "name": "size", + "returnType": "size_t", + "parameters": [], + "isStatic": false, + "isVirtual": false, + "isPure": false, + "isConst": false + }, + { + "kind": "method", + "name": "put", + "returnType": "void", + "parameters": [ + { + "name": "key", + "type": "const K &" + }, + { + "name": "value", + "type": "const V &" + } + ], + "isStatic": false, + "isVirtual": false, + "isPure": false, + "isConst": false + }, + { + "kind": "method", + "name": "addAll", + "returnType": "bool", + "parameters": [ + { + "name": "keys", + "type": "Array &" + }, + { + "name": "value", + "type": "const V &" + } + ], + "isStatic": false, + "isVirtual": false, + "isPure": false, + "isConst": false + }, + { + "kind": "method", + "name": "containsKey", + "returnType": "bool", + "parameters": [ + { + "name": "key", + "type": "const K &" + } + ], + "isStatic": false, + "isVirtual": false, + "isPure": false, + "isConst": false + }, + { + "kind": "method", + "name": "remove", + "returnType": "bool", + "parameters": [ + { + "name": "key", + "type": "const K &" + } + ], + "isStatic": false, + "isVirtual": false, + "isPure": false, + "isConst": false + }, + { + "kind": "method", + "name": "getEntries", + "returnType": "DebugEntries", + "parameters": [], + "isStatic": false, + "isVirtual": false, + "isPure": false, + "isConst": false + } + ], + "isAbstract": false, + "isTemplate": true, + "templateParams": [ + "K", + "V" + ] + }, { "name": "DebugExtension", "kind": "class", "loc": { - "line": 39, + "line": 194, "col": 15 }, "superTypes": [ @@ -30838,7 +30983,7 @@ "name": "Slot", "kind": "class", "loc": { - "line": 47, + "line": 48, "col": 15 }, "superTypes": [ diff --git a/spine-c/codegen/src/ir-generator.ts b/spine-c/codegen/src/ir-generator.ts index 4bcffce01..f100bdbd1 100644 --- a/spine-c/codegen/src/ir-generator.ts +++ b/spine-c/codegen/src/ir-generator.ts @@ -581,6 +581,11 @@ function convertArgumentToCpp(cppType: string, cParamName: string, isOutput: boo return `String(${cParamName})`; } + // Handle const String* parameters + if (cppType === 'const String*') { + return `(const String*)${cParamName}`; + } + // Handle pointer parameters (need to cast from opaque type) if (cppType.endsWith('*')) { const baseType = cppType.slice(0, -1).trim(); @@ -611,6 +616,11 @@ function convertArgumentToCpp(cppType: string, cParamName: string, isOutput: boo } } + // Handle String& and const String& in reference context + if (baseType === 'String' || baseType === 'const String') { + return `String(${cParamName})`; + } + // Class references need to dereference the pointer if (!isPrimitive(baseType)) { return `*((${baseType}*)${cParamName})`; diff --git a/spine-c/src/generated/animation.cpp b/spine-c/src/generated/animation.cpp index 3fb52999d..0ed8eea2a 100644 --- a/spine-c/src/generated/animation.cpp +++ b/spine-c/src/generated/animation.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_animation spine_animation_create(const char* name, spine_array_timeline timelines, float duration) { - return (spine_animation) new (__FILE__, __LINE__) Animation(*((const String*)name), *((Array*)timelines), duration); + return (spine_animation) new (__FILE__, __LINE__) Animation(String(name), *((Array*)timelines), duration); } void spine_animation_dispose(spine_animation self) { diff --git a/spine-c/src/generated/animation_state.cpp b/spine-c/src/generated/animation_state.cpp index d9d3f7369..880c35606 100644 --- a/spine-c/src/generated/animation_state.cpp +++ b/spine-c/src/generated/animation_state.cpp @@ -28,7 +28,7 @@ void spine_animation_state_clear_track(spine_animation_state self, size_t trackI } spine_track_entry spine_animation_state_set_animation_1(spine_animation_state self, size_t trackIndex, const char* animationName, bool loop) { - return (spine_track_entry)((AnimationState*)self)->setAnimation(trackIndex, *((const String*)animationName), loop); + return (spine_track_entry)((AnimationState*)self)->setAnimation(trackIndex, String(animationName), loop); } spine_track_entry spine_animation_state_set_animation_2(spine_animation_state self, size_t trackIndex, spine_animation animation, bool loop) { @@ -36,7 +36,7 @@ spine_track_entry spine_animation_state_set_animation_2(spine_animation_state se } spine_track_entry spine_animation_state_add_animation_1(spine_animation_state self, size_t trackIndex, const char* animationName, bool loop, float delay) { - return (spine_track_entry)((AnimationState*)self)->addAnimation(trackIndex, *((const String*)animationName), loop, delay); + return (spine_track_entry)((AnimationState*)self)->addAnimation(trackIndex, String(animationName), loop, delay); } spine_track_entry spine_animation_state_add_animation_2(spine_animation_state self, size_t trackIndex, spine_animation animation, bool loop, float delay) { diff --git a/spine-c/src/generated/animation_state_data.cpp b/spine-c/src/generated/animation_state_data.cpp index 29404e33a..2c16eebe0 100644 --- a/spine-c/src/generated/animation_state_data.cpp +++ b/spine-c/src/generated/animation_state_data.cpp @@ -24,7 +24,7 @@ void spine_animation_state_data_set_default_mix(spine_animation_state_data self, } void spine_animation_state_data_set_mix_1(spine_animation_state_data self, const char* fromName, const char* toName, float duration) { - ((AnimationStateData*)self)->setMix(*((const String*)fromName), *((const String*)toName), duration); + ((AnimationStateData*)self)->setMix(String(fromName), String(toName), duration); } void spine_animation_state_data_set_mix_2(spine_animation_state_data self, spine_animation from, spine_animation to, float duration) { diff --git a/spine-c/src/generated/atlas.cpp b/spine-c/src/generated/atlas.cpp index b58663174..dc43a1170 100644 --- a/spine-c/src/generated/atlas.cpp +++ b/spine-c/src/generated/atlas.cpp @@ -12,7 +12,7 @@ void spine_atlas_flip_v(spine_atlas self) { } spine_atlas_region spine_atlas_find_region(spine_atlas self, const char* name) { - return (spine_atlas_region)((Atlas*)self)->findRegion(*((const String*)name)); + return (spine_atlas_region)((Atlas*)self)->findRegion(String(name)); } spine_array_atlas_page spine_atlas_get_pages(spine_atlas self) { diff --git a/spine-c/src/generated/atlas_attachment_loader.cpp b/spine-c/src/generated/atlas_attachment_loader.cpp index 8658ad38b..f3ca81276 100644 --- a/spine-c/src/generated/atlas_attachment_loader.cpp +++ b/spine-c/src/generated/atlas_attachment_loader.cpp @@ -12,29 +12,29 @@ void spine_atlas_attachment_loader_dispose(spine_atlas_attachment_loader self) { } spine_region_attachment spine_atlas_attachment_loader_new_region_attachment(spine_atlas_attachment_loader self, spine_skin skin, const char* name, const char* path, spine_sequence sequence) { - return (spine_region_attachment)((AtlasAttachmentLoader*)self)->newRegionAttachment(*((Skin*)skin), *((const String*)name), *((const String*)path), (Sequence *)sequence); + return (spine_region_attachment)((AtlasAttachmentLoader*)self)->newRegionAttachment(*((Skin*)skin), String(name), String(path), (Sequence *)sequence); } spine_mesh_attachment spine_atlas_attachment_loader_new_mesh_attachment(spine_atlas_attachment_loader self, spine_skin skin, const char* name, const char* path, spine_sequence sequence) { - return (spine_mesh_attachment)((AtlasAttachmentLoader*)self)->newMeshAttachment(*((Skin*)skin), *((const String*)name), *((const String*)path), (Sequence *)sequence); + return (spine_mesh_attachment)((AtlasAttachmentLoader*)self)->newMeshAttachment(*((Skin*)skin), String(name), String(path), (Sequence *)sequence); } spine_bounding_box_attachment spine_atlas_attachment_loader_new_bounding_box_attachment(spine_atlas_attachment_loader self, spine_skin skin, const char* name) { - return (spine_bounding_box_attachment)((AtlasAttachmentLoader*)self)->newBoundingBoxAttachment(*((Skin*)skin), *((const String*)name)); + return (spine_bounding_box_attachment)((AtlasAttachmentLoader*)self)->newBoundingBoxAttachment(*((Skin*)skin), String(name)); } spine_path_attachment spine_atlas_attachment_loader_new_path_attachment(spine_atlas_attachment_loader self, spine_skin skin, const char* name) { - return (spine_path_attachment)((AtlasAttachmentLoader*)self)->newPathAttachment(*((Skin*)skin), *((const String*)name)); + return (spine_path_attachment)((AtlasAttachmentLoader*)self)->newPathAttachment(*((Skin*)skin), String(name)); } spine_point_attachment spine_atlas_attachment_loader_new_point_attachment(spine_atlas_attachment_loader self, spine_skin skin, const char* name) { - return (spine_point_attachment)((AtlasAttachmentLoader*)self)->newPointAttachment(*((Skin*)skin), *((const String*)name)); + return (spine_point_attachment)((AtlasAttachmentLoader*)self)->newPointAttachment(*((Skin*)skin), String(name)); } spine_clipping_attachment spine_atlas_attachment_loader_new_clipping_attachment(spine_atlas_attachment_loader self, spine_skin skin, const char* name) { - return (spine_clipping_attachment)((AtlasAttachmentLoader*)self)->newClippingAttachment(*((Skin*)skin), *((const String*)name)); + return (spine_clipping_attachment)((AtlasAttachmentLoader*)self)->newClippingAttachment(*((Skin*)skin), String(name)); } spine_atlas_region spine_atlas_attachment_loader_find_region(spine_atlas_attachment_loader self, const char* name) { - return (spine_atlas_region)((AtlasAttachmentLoader*)self)->findRegion(*((const String*)name)); + return (spine_atlas_region)((AtlasAttachmentLoader*)self)->findRegion(String(name)); } diff --git a/spine-c/src/generated/atlas_page.cpp b/spine-c/src/generated/atlas_page.cpp index 78eb7c77a..934542aec 100644 --- a/spine-c/src/generated/atlas_page.cpp +++ b/spine-c/src/generated/atlas_page.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_atlas_page spine_atlas_page_create(const char* inName) { - return (spine_atlas_page) new (__FILE__, __LINE__) AtlasPage(*((const String*)inName)); + return (spine_atlas_page) new (__FILE__, __LINE__) AtlasPage(String(inName)); } void spine_atlas_page_dispose(spine_atlas_page self) { diff --git a/spine-c/src/generated/attachment_loader.cpp b/spine-c/src/generated/attachment_loader.cpp index eb5994757..ec9c40f65 100644 --- a/spine-c/src/generated/attachment_loader.cpp +++ b/spine-c/src/generated/attachment_loader.cpp @@ -8,25 +8,25 @@ void spine_attachment_loader_dispose(spine_attachment_loader self) { } spine_region_attachment spine_attachment_loader_new_region_attachment(spine_attachment_loader self, spine_skin skin, const char* name, const char* path, spine_sequence sequence) { - return (spine_region_attachment)((AttachmentLoader*)self)->newRegionAttachment(*((Skin*)skin), *((const String*)name), *((const String*)path), (Sequence *)sequence); + return (spine_region_attachment)((AttachmentLoader*)self)->newRegionAttachment(*((Skin*)skin), String(name), String(path), (Sequence *)sequence); } spine_mesh_attachment spine_attachment_loader_new_mesh_attachment(spine_attachment_loader self, spine_skin skin, const char* name, const char* path, spine_sequence sequence) { - return (spine_mesh_attachment)((AttachmentLoader*)self)->newMeshAttachment(*((Skin*)skin), *((const String*)name), *((const String*)path), (Sequence *)sequence); + return (spine_mesh_attachment)((AttachmentLoader*)self)->newMeshAttachment(*((Skin*)skin), String(name), String(path), (Sequence *)sequence); } spine_bounding_box_attachment spine_attachment_loader_new_bounding_box_attachment(spine_attachment_loader self, spine_skin skin, const char* name) { - return (spine_bounding_box_attachment)((AttachmentLoader*)self)->newBoundingBoxAttachment(*((Skin*)skin), *((const String*)name)); + return (spine_bounding_box_attachment)((AttachmentLoader*)self)->newBoundingBoxAttachment(*((Skin*)skin), String(name)); } spine_path_attachment spine_attachment_loader_new_path_attachment(spine_attachment_loader self, spine_skin skin, const char* name) { - return (spine_path_attachment)((AttachmentLoader*)self)->newPathAttachment(*((Skin*)skin), *((const String*)name)); + return (spine_path_attachment)((AttachmentLoader*)self)->newPathAttachment(*((Skin*)skin), String(name)); } spine_point_attachment spine_attachment_loader_new_point_attachment(spine_attachment_loader self, spine_skin skin, const char* name) { - return (spine_point_attachment)((AttachmentLoader*)self)->newPointAttachment(*((Skin*)skin), *((const String*)name)); + return (spine_point_attachment)((AttachmentLoader*)self)->newPointAttachment(*((Skin*)skin), String(name)); } spine_clipping_attachment spine_attachment_loader_new_clipping_attachment(spine_attachment_loader self, spine_skin skin, const char* name) { - return (spine_clipping_attachment)((AttachmentLoader*)self)->newClippingAttachment(*((Skin*)skin), *((const String*)name)); + return (spine_clipping_attachment)((AttachmentLoader*)self)->newClippingAttachment(*((Skin*)skin), String(name)); } diff --git a/spine-c/src/generated/attachment_timeline.cpp b/spine-c/src/generated/attachment_timeline.cpp index acdb6c325..5f805a0dd 100644 --- a/spine-c/src/generated/attachment_timeline.cpp +++ b/spine-c/src/generated/attachment_timeline.cpp @@ -20,7 +20,7 @@ void spine_attachment_timeline_apply(spine_attachment_timeline self, spine_skele } void spine_attachment_timeline_set_frame(spine_attachment_timeline self, int frame, float time, const char* attachmentName) { - ((AttachmentTimeline*)self)->setFrame(frame, time, *((const String*)attachmentName)); + ((AttachmentTimeline*)self)->setFrame(frame, time, String(attachmentName)); } size_t spine_attachment_timeline_get_frame_entries(spine_attachment_timeline self) { diff --git a/spine-c/src/generated/bone.cpp b/spine-c/src/generated/bone.cpp index fa18fa09e..4d6c6eeee 100644 --- a/spine-c/src/generated/bone.cpp +++ b/spine-c/src/generated/bone.cpp @@ -35,6 +35,10 @@ void spine_bone_set_y_down(bool value) { Bone::setYDown(value); } +void spine_bone_update(spine_bone self, spine_skeleton skeleton, spine_physics physics) { + ((Bone*)self)->update(*((Skeleton*)skeleton), (Physics)physics); +} + spine_bone_data spine_bone_get_data(spine_bone self) { return (spine_bone_data)&((PosedGeneric*)(Bone*)self)->getData(); } diff --git a/spine-c/src/generated/bone.h b/spine-c/src/generated/bone.h index 818f0eb9a..347974661 100644 --- a/spine-c/src/generated/bone.h +++ b/spine-c/src/generated/bone.h @@ -18,6 +18,7 @@ SPINE_C_API spine_bone spine_bone_get_parent(spine_bone self); SPINE_C_API spine_array_bone spine_bone_get_children(spine_bone self); SPINE_C_API bool spine_bone_is_y_down(void); SPINE_C_API void spine_bone_set_y_down(bool value); +SPINE_C_API void spine_bone_update(spine_bone self, spine_skeleton skeleton, spine_physics physics); SPINE_C_API spine_bone_data spine_bone_get_data(spine_bone self); SPINE_C_API spine_bone_local spine_bone_get_pose(spine_bone self); SPINE_C_API spine_bone_pose spine_bone_get_applied_pose(spine_bone self); diff --git a/spine-c/src/generated/bone_data.cpp b/spine-c/src/generated/bone_data.cpp index e3b45e6db..839281b6f 100644 --- a/spine-c/src/generated/bone_data.cpp +++ b/spine-c/src/generated/bone_data.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_bone_data spine_bone_data_create(int index, const char* name, spine_bone_data parent) { - return (spine_bone_data) new (__FILE__, __LINE__) BoneData(index, *((const String*)name), (BoneData *)parent); + return (spine_bone_data) new (__FILE__, __LINE__) BoneData(index, String(name), (BoneData *)parent); } void spine_bone_data_dispose(spine_bone_data self) { @@ -36,7 +36,7 @@ const char* spine_bone_data_get_icon(spine_bone_data self) { } void spine_bone_data_set_icon(spine_bone_data self, const char* icon) { - ((BoneData*)self)->setIcon(*((const String*)icon)); + ((BoneData*)self)->setIcon(String(icon)); } bool spine_bone_data_get_visible(spine_bone_data self) { diff --git a/spine-c/src/generated/bounding_box_attachment.cpp b/spine-c/src/generated/bounding_box_attachment.cpp index 29523f744..915a74c6b 100644 --- a/spine-c/src/generated/bounding_box_attachment.cpp +++ b/spine-c/src/generated/bounding_box_attachment.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_bounding_box_attachment spine_bounding_box_attachment_create(const char* name) { - return (spine_bounding_box_attachment) new (__FILE__, __LINE__) BoundingBoxAttachment(*((const String*)name)); + return (spine_bounding_box_attachment) new (__FILE__, __LINE__) BoundingBoxAttachment(String(name)); } void spine_bounding_box_attachment_dispose(spine_bounding_box_attachment self) { diff --git a/spine-c/src/generated/clipping_attachment.cpp b/spine-c/src/generated/clipping_attachment.cpp index 404369713..cde2f0e04 100644 --- a/spine-c/src/generated/clipping_attachment.cpp +++ b/spine-c/src/generated/clipping_attachment.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_clipping_attachment spine_clipping_attachment_create(const char* name) { - return (spine_clipping_attachment) new (__FILE__, __LINE__) ClippingAttachment(*((const String*)name)); + return (spine_clipping_attachment) new (__FILE__, __LINE__) ClippingAttachment(String(name)); } void spine_clipping_attachment_dispose(spine_clipping_attachment self) { diff --git a/spine-c/src/generated/event.cpp b/spine-c/src/generated/event.cpp index fa8d45a82..0f1c619f6 100644 --- a/spine-c/src/generated/event.cpp +++ b/spine-c/src/generated/event.cpp @@ -40,7 +40,7 @@ const char* spine_event_get_string(spine_event self) { } void spine_event_set_string(spine_event self, const char* inValue) { - ((Event*)self)->setString(*((const String*)inValue)); + ((Event*)self)->setString(String(inValue)); } float spine_event_get_volume(spine_event self) { diff --git a/spine-c/src/generated/event_data.cpp b/spine-c/src/generated/event_data.cpp index 52a9d0673..3866e698c 100644 --- a/spine-c/src/generated/event_data.cpp +++ b/spine-c/src/generated/event_data.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_event_data spine_event_data_create(const char* name) { - return (spine_event_data) new (__FILE__, __LINE__) EventData(*((const String*)name)); + return (spine_event_data) new (__FILE__, __LINE__) EventData(String(name)); } void spine_event_data_dispose(spine_event_data self) { @@ -36,7 +36,7 @@ const char* spine_event_data_get_string_value(spine_event_data self) { } void spine_event_data_set_string_value(spine_event_data self, const char* inValue) { - ((EventData*)self)->setStringValue(*((const String*)inValue)); + ((EventData*)self)->setStringValue(String(inValue)); } const char* spine_event_data_get_audio_path(spine_event_data self) { @@ -44,7 +44,7 @@ const char* spine_event_data_get_audio_path(spine_event_data self) { } void spine_event_data_set_audio_path(spine_event_data self, const char* inValue) { - ((EventData*)self)->setAudioPath(*((const String*)inValue)); + ((EventData*)self)->setAudioPath(String(inValue)); } float spine_event_data_get_volume(spine_event_data self) { diff --git a/spine-c/src/generated/ik_constraint_data.cpp b/spine-c/src/generated/ik_constraint_data.cpp index 39c5c563b..b53b9296c 100644 --- a/spine-c/src/generated/ik_constraint_data.cpp +++ b/spine-c/src/generated/ik_constraint_data.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_ik_constraint_data spine_ik_constraint_data_create(const char* name) { - return (spine_ik_constraint_data) new (__FILE__, __LINE__) IkConstraintData(*((const String*)name)); + return (spine_ik_constraint_data) new (__FILE__, __LINE__) IkConstraintData(String(name)); } void spine_ik_constraint_data_dispose(spine_ik_constraint_data self) { diff --git a/spine-c/src/generated/linked_mesh.cpp b/spine-c/src/generated/linked_mesh.cpp index c83bfd90d..eaec53b47 100644 --- a/spine-c/src/generated/linked_mesh.cpp +++ b/spine-c/src/generated/linked_mesh.cpp @@ -4,11 +4,11 @@ using namespace spine; spine_linked_mesh spine_linked_mesh_create(spine_mesh_attachment mesh, const int skinIndex, size_t slotIndex, const char* parent, bool inheritTimelines) { - return (spine_linked_mesh) new (__FILE__, __LINE__) LinkedMesh((MeshAttachment *)mesh, skinIndex, slotIndex, *((const String*)parent), inheritTimelines); + return (spine_linked_mesh) new (__FILE__, __LINE__) LinkedMesh((MeshAttachment *)mesh, skinIndex, slotIndex, String(parent), inheritTimelines); } spine_linked_mesh spine_linked_mesh_create2(spine_mesh_attachment mesh, const char* skin, size_t slotIndex, const char* parent, bool inheritTimelines) { - return (spine_linked_mesh) new (__FILE__, __LINE__) LinkedMesh((MeshAttachment *)mesh, *((const String*)skin), slotIndex, *((const String*)parent), inheritTimelines); + return (spine_linked_mesh) new (__FILE__, __LINE__) LinkedMesh((MeshAttachment *)mesh, String(skin), slotIndex, String(parent), inheritTimelines); } void spine_linked_mesh_dispose(spine_linked_mesh self) { diff --git a/spine-c/src/generated/mesh_attachment.cpp b/spine-c/src/generated/mesh_attachment.cpp index b06b190ca..450b40582 100644 --- a/spine-c/src/generated/mesh_attachment.cpp +++ b/spine-c/src/generated/mesh_attachment.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_mesh_attachment spine_mesh_attachment_create(const char* name) { - return (spine_mesh_attachment) new (__FILE__, __LINE__) MeshAttachment(*((const String*)name)); + return (spine_mesh_attachment) new (__FILE__, __LINE__) MeshAttachment(String(name)); } void spine_mesh_attachment_dispose(spine_mesh_attachment self) { @@ -64,7 +64,7 @@ const char* spine_mesh_attachment_get_path(spine_mesh_attachment self) { } void spine_mesh_attachment_set_path(spine_mesh_attachment self, const char* inValue) { - ((MeshAttachment*)self)->setPath(*((const String*)inValue)); + ((MeshAttachment*)self)->setPath(String(inValue)); } spine_texture_region spine_mesh_attachment_get_region(spine_mesh_attachment self) { diff --git a/spine-c/src/generated/path_attachment.cpp b/spine-c/src/generated/path_attachment.cpp index 85a4cf40a..419513b54 100644 --- a/spine-c/src/generated/path_attachment.cpp +++ b/spine-c/src/generated/path_attachment.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_path_attachment spine_path_attachment_create(const char* name) { - return (spine_path_attachment) new (__FILE__, __LINE__) PathAttachment(*((const String*)name)); + return (spine_path_attachment) new (__FILE__, __LINE__) PathAttachment(String(name)); } void spine_path_attachment_dispose(spine_path_attachment self) { diff --git a/spine-c/src/generated/path_constraint_data.cpp b/spine-c/src/generated/path_constraint_data.cpp index 23cdfca57..dccd2301e 100644 --- a/spine-c/src/generated/path_constraint_data.cpp +++ b/spine-c/src/generated/path_constraint_data.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_path_constraint_data spine_path_constraint_data_create(const char* name) { - return (spine_path_constraint_data) new (__FILE__, __LINE__) PathConstraintData(*((const String*)name)); + return (spine_path_constraint_data) new (__FILE__, __LINE__) PathConstraintData(String(name)); } void spine_path_constraint_data_dispose(spine_path_constraint_data self) { diff --git a/spine-c/src/generated/physics_constraint_data.cpp b/spine-c/src/generated/physics_constraint_data.cpp index fa540aad9..ca2a8307d 100644 --- a/spine-c/src/generated/physics_constraint_data.cpp +++ b/spine-c/src/generated/physics_constraint_data.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_physics_constraint_data spine_physics_constraint_data_create(const char* name) { - return (spine_physics_constraint_data) new (__FILE__, __LINE__) PhysicsConstraintData(*((const String*)name)); + return (spine_physics_constraint_data) new (__FILE__, __LINE__) PhysicsConstraintData(String(name)); } void spine_physics_constraint_data_dispose(spine_physics_constraint_data self) { diff --git a/spine-c/src/generated/point_attachment.cpp b/spine-c/src/generated/point_attachment.cpp index 89bce2505..9177d00f6 100644 --- a/spine-c/src/generated/point_attachment.cpp +++ b/spine-c/src/generated/point_attachment.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_point_attachment spine_point_attachment_create(const char* name) { - return (spine_point_attachment) new (__FILE__, __LINE__) PointAttachment(*((const String*)name)); + return (spine_point_attachment) new (__FILE__, __LINE__) PointAttachment(String(name)); } void spine_point_attachment_dispose(spine_point_attachment self) { diff --git a/spine-c/src/generated/posed_data.cpp b/spine-c/src/generated/posed_data.cpp index 7f0519d54..6e58004a2 100644 --- a/spine-c/src/generated/posed_data.cpp +++ b/spine-c/src/generated/posed_data.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_posed_data spine_posed_data_create(const char* name) { - return (spine_posed_data) new (__FILE__, __LINE__) PosedData(*((const String*)name)); + return (spine_posed_data) new (__FILE__, __LINE__) PosedData(String(name)); } void spine_posed_data_dispose(spine_posed_data self) { diff --git a/spine-c/src/generated/region_attachment.cpp b/spine-c/src/generated/region_attachment.cpp index 007ea3024..f1c89b86c 100644 --- a/spine-c/src/generated/region_attachment.cpp +++ b/spine-c/src/generated/region_attachment.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_region_attachment spine_region_attachment_create(const char* name) { - return (spine_region_attachment) new (__FILE__, __LINE__) RegionAttachment(*((const String*)name)); + return (spine_region_attachment) new (__FILE__, __LINE__) RegionAttachment(String(name)); } void spine_region_attachment_dispose(spine_region_attachment self) { @@ -92,7 +92,7 @@ const char* spine_region_attachment_get_path(spine_region_attachment self) { } void spine_region_attachment_set_path(spine_region_attachment self, const char* inValue) { - ((RegionAttachment*)self)->setPath(*((const String*)inValue)); + ((RegionAttachment*)self)->setPath(String(inValue)); } spine_texture_region spine_region_attachment_get_region(spine_region_attachment self) { diff --git a/spine-c/src/generated/sequence.cpp b/spine-c/src/generated/sequence.cpp index 40c3ee851..56315ca41 100644 --- a/spine-c/src/generated/sequence.cpp +++ b/spine-c/src/generated/sequence.cpp @@ -20,7 +20,7 @@ void spine_sequence_apply(spine_sequence self, spine_slot_pose slot, spine_attac } const char* spine_sequence_get_path(spine_sequence self, const char* basePath, int index) { - return ((Sequence*)self)->getPath(*((const String*)basePath), index).buffer(); + return ((Sequence*)self)->getPath(String(basePath), index).buffer(); } int spine_sequence_get_id(spine_sequence self) { diff --git a/spine-c/src/generated/skeleton.cpp b/spine-c/src/generated/skeleton.cpp index 6f8503d03..8a6552177 100644 --- a/spine-c/src/generated/skeleton.cpp +++ b/spine-c/src/generated/skeleton.cpp @@ -68,7 +68,7 @@ spine_bone spine_skeleton_get_root_bone(spine_skeleton self) { } spine_bone spine_skeleton_find_bone(spine_skeleton self, const char* boneName) { - return (spine_bone)((Skeleton*)self)->findBone(*((const String*)boneName)); + return (spine_bone)((Skeleton*)self)->findBone(String(boneName)); } spine_array_slot spine_skeleton_get_slots(spine_skeleton self) { @@ -76,7 +76,7 @@ spine_array_slot spine_skeleton_get_slots(spine_skeleton self) { } spine_slot spine_skeleton_find_slot(spine_skeleton self, const char* slotName) { - return (spine_slot)((Skeleton*)self)->findSlot(*((const String*)slotName)); + return (spine_slot)((Skeleton*)self)->findSlot(String(slotName)); } spine_array_slot spine_skeleton_get_draw_order(spine_skeleton self) { @@ -88,7 +88,7 @@ spine_skin spine_skeleton_get_skin(spine_skeleton self) { } void spine_skeleton_set_skin_1(spine_skeleton self, const char* skinName) { - ((Skeleton*)self)->setSkin(*((const String*)skinName)); + ((Skeleton*)self)->setSkin(String(skinName)); } void spine_skeleton_set_skin_2(spine_skeleton self, spine_skin newSkin) { @@ -96,15 +96,15 @@ void spine_skeleton_set_skin_2(spine_skeleton self, spine_skin newSkin) { } spine_attachment spine_skeleton_get_attachment_1(spine_skeleton self, const char* slotName, const char* attachmentName) { - return (spine_attachment)((Skeleton*)self)->getAttachment(*((const String*)slotName), *((const String*)attachmentName)); + return (spine_attachment)((Skeleton*)self)->getAttachment(String(slotName), String(attachmentName)); } spine_attachment spine_skeleton_get_attachment_2(spine_skeleton self, int slotIndex, const char* attachmentName) { - return (spine_attachment)((Skeleton*)self)->getAttachment(slotIndex, *((const String*)attachmentName)); + return (spine_attachment)((Skeleton*)self)->getAttachment(slotIndex, String(attachmentName)); } void spine_skeleton_set_attachment(spine_skeleton self, const char* slotName, const char* attachmentName) { - ((Skeleton*)self)->setAttachment(*((const String*)slotName), *((const String*)attachmentName)); + ((Skeleton*)self)->setAttachment(String(slotName), String(attachmentName)); } spine_array_constraint spine_skeleton_get_constraints(spine_skeleton self) { diff --git a/spine-c/src/generated/skeleton_binary.cpp b/spine-c/src/generated/skeleton_binary.cpp index d7f49ed5e..def39595e 100644 --- a/spine-c/src/generated/skeleton_binary.cpp +++ b/spine-c/src/generated/skeleton_binary.cpp @@ -20,7 +20,7 @@ spine_skeleton_data spine_skeleton_binary_read_skeleton_data(spine_skeleton_bina } spine_skeleton_data spine_skeleton_binary_read_skeleton_data_file(spine_skeleton_binary self, const char* path) { - return (spine_skeleton_data)((SkeletonBinary*)self)->readSkeletonDataFile(*((const String*)path)); + return (spine_skeleton_data)((SkeletonBinary*)self)->readSkeletonDataFile(String(path)); } void spine_skeleton_binary_set_scale(spine_skeleton_binary self, float scale) { diff --git a/spine-c/src/generated/skeleton_data.cpp b/spine-c/src/generated/skeleton_data.cpp index 5b248ecec..9319b87e7 100644 --- a/spine-c/src/generated/skeleton_data.cpp +++ b/spine-c/src/generated/skeleton_data.cpp @@ -12,39 +12,39 @@ void spine_skeleton_data_dispose(spine_skeleton_data self) { } spine_bone_data spine_skeleton_data_find_bone(spine_skeleton_data self, const char* boneName) { - return (spine_bone_data)((SkeletonData*)self)->findBone(*((const String*)boneName)); + return (spine_bone_data)((SkeletonData*)self)->findBone(String(boneName)); } spine_slot_data spine_skeleton_data_find_slot(spine_skeleton_data self, const char* slotName) { - return (spine_slot_data)((SkeletonData*)self)->findSlot(*((const String*)slotName)); + return (spine_slot_data)((SkeletonData*)self)->findSlot(String(slotName)); } spine_skin spine_skeleton_data_find_skin(spine_skeleton_data self, const char* skinName) { - return (spine_skin)((SkeletonData*)self)->findSkin(*((const String*)skinName)); + return (spine_skin)((SkeletonData*)self)->findSkin(String(skinName)); } spine_event_data spine_skeleton_data_find_event(spine_skeleton_data self, const char* eventDataName) { - return (spine_event_data)((SkeletonData*)self)->findEvent(*((const String*)eventDataName)); + return (spine_event_data)((SkeletonData*)self)->findEvent(String(eventDataName)); } spine_animation spine_skeleton_data_find_animation(spine_skeleton_data self, const char* animationName) { - return (spine_animation)((SkeletonData*)self)->findAnimation(*((const String*)animationName)); + return (spine_animation)((SkeletonData*)self)->findAnimation(String(animationName)); } spine_ik_constraint_data spine_skeleton_data_find_ik_constraint(spine_skeleton_data self, const char* constraintName) { - return (spine_ik_constraint_data)((SkeletonData*)self)->findIkConstraint(*((const String*)constraintName)); + return (spine_ik_constraint_data)((SkeletonData*)self)->findIkConstraint(String(constraintName)); } spine_transform_constraint_data spine_skeleton_data_find_transform_constraint(spine_skeleton_data self, const char* constraintName) { - return (spine_transform_constraint_data)((SkeletonData*)self)->findTransformConstraint(*((const String*)constraintName)); + return (spine_transform_constraint_data)((SkeletonData*)self)->findTransformConstraint(String(constraintName)); } spine_path_constraint_data spine_skeleton_data_find_path_constraint(spine_skeleton_data self, const char* constraintName) { - return (spine_path_constraint_data)((SkeletonData*)self)->findPathConstraint(*((const String*)constraintName)); + return (spine_path_constraint_data)((SkeletonData*)self)->findPathConstraint(String(constraintName)); } spine_physics_constraint_data spine_skeleton_data_find_physics_constraint(spine_skeleton_data self, const char* constraintName) { - return (spine_physics_constraint_data)((SkeletonData*)self)->findPhysicsConstraint(*((const String*)constraintName)); + return (spine_physics_constraint_data)((SkeletonData*)self)->findPhysicsConstraint(String(constraintName)); } const char* spine_skeleton_data_get_name(spine_skeleton_data self) { @@ -52,7 +52,7 @@ const char* spine_skeleton_data_get_name(spine_skeleton_data self) { } void spine_skeleton_data_set_name(spine_skeleton_data self, const char* inValue) { - ((SkeletonData*)self)->setName(*((const String*)inValue)); + ((SkeletonData*)self)->setName(String(inValue)); } spine_array_bone_data spine_skeleton_data_get_bones(spine_skeleton_data self) { @@ -148,7 +148,7 @@ const char* spine_skeleton_data_get_version(spine_skeleton_data self) { } void spine_skeleton_data_set_version(spine_skeleton_data self, const char* inValue) { - ((SkeletonData*)self)->setVersion(*((const String*)inValue)); + ((SkeletonData*)self)->setVersion(String(inValue)); } const char* spine_skeleton_data_get_hash(spine_skeleton_data self) { @@ -156,7 +156,7 @@ const char* spine_skeleton_data_get_hash(spine_skeleton_data self) { } void spine_skeleton_data_set_hash(spine_skeleton_data self, const char* inValue) { - ((SkeletonData*)self)->setHash(*((const String*)inValue)); + ((SkeletonData*)self)->setHash(String(inValue)); } const char* spine_skeleton_data_get_images_path(spine_skeleton_data self) { @@ -164,7 +164,7 @@ const char* spine_skeleton_data_get_images_path(spine_skeleton_data self) { } void spine_skeleton_data_set_images_path(spine_skeleton_data self, const char* inValue) { - ((SkeletonData*)self)->setImagesPath(*((const String*)inValue)); + ((SkeletonData*)self)->setImagesPath(String(inValue)); } const char* spine_skeleton_data_get_audio_path(spine_skeleton_data self) { @@ -172,7 +172,7 @@ const char* spine_skeleton_data_get_audio_path(spine_skeleton_data self) { } void spine_skeleton_data_set_audio_path(spine_skeleton_data self, const char* inValue) { - ((SkeletonData*)self)->setAudioPath(*((const String*)inValue)); + ((SkeletonData*)self)->setAudioPath(String(inValue)); } float spine_skeleton_data_get_fps(spine_skeleton_data self) { diff --git a/spine-c/src/generated/skeleton_json.cpp b/spine-c/src/generated/skeleton_json.cpp index 2d2a5c34e..2116a79d2 100644 --- a/spine-c/src/generated/skeleton_json.cpp +++ b/spine-c/src/generated/skeleton_json.cpp @@ -16,7 +16,7 @@ void spine_skeleton_json_dispose(spine_skeleton_json self) { } spine_skeleton_data spine_skeleton_json_read_skeleton_data_file(spine_skeleton_json self, const char* path) { - return (spine_skeleton_data)((SkeletonJson*)self)->readSkeletonDataFile(*((const String*)path)); + return (spine_skeleton_data)((SkeletonJson*)self)->readSkeletonDataFile(String(path)); } spine_skeleton_data spine_skeleton_json_read_skeleton_data(spine_skeleton_json self, const char * json) { diff --git a/spine-c/src/generated/skin.cpp b/spine-c/src/generated/skin.cpp index a995ec3a1..468b64634 100644 --- a/spine-c/src/generated/skin.cpp +++ b/spine-c/src/generated/skin.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_skin spine_skin_create(const char* name) { - return (spine_skin) new (__FILE__, __LINE__) Skin(*((const String*)name)); + return (spine_skin) new (__FILE__, __LINE__) Skin(String(name)); } void spine_skin_dispose(spine_skin self) { @@ -12,15 +12,15 @@ void spine_skin_dispose(spine_skin self) { } void spine_skin_set_attachment(spine_skin self, size_t slotIndex, const char* name, spine_attachment attachment) { - ((Skin*)self)->setAttachment(slotIndex, *((const String*)name), (Attachment *)attachment); + ((Skin*)self)->setAttachment(slotIndex, String(name), (Attachment *)attachment); } spine_attachment spine_skin_get_attachment(spine_skin self, size_t slotIndex, const char* name) { - return (spine_attachment)((Skin*)self)->getAttachment(slotIndex, *((const String*)name)); + return (spine_attachment)((Skin*)self)->getAttachment(slotIndex, String(name)); } void spine_skin_remove_attachment(spine_skin self, size_t slotIndex, const char* name) { - ((Skin*)self)->removeAttachment(slotIndex, *((const String*)name)); + ((Skin*)self)->removeAttachment(slotIndex, String(name)); } void spine_skin_find_attachments_for_slot(spine_skin self, size_t slotIndex, spine_array_attachment attachments) { diff --git a/spine-c/src/generated/slider_data.cpp b/spine-c/src/generated/slider_data.cpp index 70aa53f4b..94a255c52 100644 --- a/spine-c/src/generated/slider_data.cpp +++ b/spine-c/src/generated/slider_data.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_slider_data spine_slider_data_create(const char* name) { - return (spine_slider_data) new (__FILE__, __LINE__) SliderData(*((const String*)name)); + return (spine_slider_data) new (__FILE__, __LINE__) SliderData(String(name)); } void spine_slider_data_dispose(spine_slider_data self) { diff --git a/spine-c/src/generated/slot_data.cpp b/spine-c/src/generated/slot_data.cpp index 14bd9e29a..587732497 100644 --- a/spine-c/src/generated/slot_data.cpp +++ b/spine-c/src/generated/slot_data.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_slot_data spine_slot_data_create(int index, const char* name, spine_bone_data boneData) { - return (spine_slot_data) new (__FILE__, __LINE__) SlotData(index, *((const String*)name), *((BoneData*)boneData)); + return (spine_slot_data) new (__FILE__, __LINE__) SlotData(index, String(name), *((BoneData*)boneData)); } void spine_slot_data_dispose(spine_slot_data self) { @@ -20,7 +20,7 @@ spine_bone_data spine_slot_data_get_bone_data(spine_slot_data self) { } void spine_slot_data_set_attachment_name(spine_slot_data self, const char* attachmentName) { - ((SlotData*)self)->setAttachmentName(*((const String*)attachmentName)); + ((SlotData*)self)->setAttachmentName(String(attachmentName)); } const char* spine_slot_data_get_attachment_name(spine_slot_data self) { diff --git a/spine-c/src/generated/transform_constraint_data.cpp b/spine-c/src/generated/transform_constraint_data.cpp index 40a2434e3..0c57ce26b 100644 --- a/spine-c/src/generated/transform_constraint_data.cpp +++ b/spine-c/src/generated/transform_constraint_data.cpp @@ -4,7 +4,7 @@ using namespace spine; spine_transform_constraint_data spine_transform_constraint_data_create(const char* name) { - return (spine_transform_constraint_data) new (__FILE__, __LINE__) TransformConstraintData(*((const String*)name)); + return (spine_transform_constraint_data) new (__FILE__, __LINE__) TransformConstraintData(String(name)); } void spine_transform_constraint_data_dispose(spine_transform_constraint_data self) { diff --git a/spine-cpp/CMakeLists.txt b/spine-cpp/CMakeLists.txt index f3a3aeaff..9ce22941d 100644 --- a/spine-cpp/CMakeLists.txt +++ b/spine-cpp/CMakeLists.txt @@ -10,10 +10,6 @@ file(GLOB SOURCES "spine-cpp/src/**/*.cpp") add_library(spine-cpp STATIC ${SOURCES} ${INCLUDES}) target_include_directories(spine-cpp PUBLIC spine-cpp/include) -# Commented out spine-cpp-lite build as it's not compatible with 4.3-beta API -# add_library(spine-cpp-lite STATIC ${SOURCES} ${INCLUDES} spine-cpp-lite/spine-cpp-lite.cpp) -# target_include_directories(spine-cpp-lite PUBLIC spine-cpp/include spine-cpp-lite) - # Install target install(TARGETS spine-cpp EXPORT spine-cpp_TARGETS DESTINATION dist/lib) install(FILES ${INCLUDES} DESTINATION dist/include) diff --git a/spine-cpp/spine-cpp/include/spine/Bone.h b/spine-cpp/spine-cpp/include/spine/Bone.h index a58220637..b8db1518e 100644 --- a/spine-cpp/spine-cpp/include/spine/Bone.h +++ b/spine-cpp/spine-cpp/include/spine/Bone.h @@ -43,7 +43,7 @@ namespace spine { /// A bone has a local transform which is used to compute its world transform. A bone also has an applied transform, which is a /// local transform that can be applied to compute the world transform. The local transform and applied transform may differ if a /// constraint or application code modifies the world transform after it was computed from the local transform. - class SP_API Bone : public PosedGeneric, public PosedActive { + class SP_API Bone : public PosedGeneric, public PosedActive, public Update { friend class AnimationState; friend class RotateTimeline; friend class IkConstraint; @@ -72,7 +72,7 @@ namespace spine { friend class TranslateYTimeline; friend class InheritTimeline; - RTTI_DECL_NOPARENT + RTTI_DECL public: /// @param parent May be NULL. @@ -90,6 +90,11 @@ namespace spine { static bool isYDown() { return yDown; } static void setYDown(bool value) { yDown = value; } + virtual void update(Skeleton& skeleton, Physics physics) override { + // No-op, need to extend Update so we can stuff Bone into Skeleton.updateCache temporarily. + // See Skeleton::updateCache(). + } + private: static bool yDown; Bone* const _parent; diff --git a/spine-cpp/spine-cpp/include/spine/Constraint.h b/spine-cpp/spine-cpp/include/spine/Constraint.h index 300d6ced1..5246789e9 100644 --- a/spine-cpp/spine-cpp/include/spine/Constraint.h +++ b/spine-cpp/spine-cpp/include/spine/Constraint.h @@ -40,10 +40,11 @@ namespace spine { class Skeleton; class SP_API Constraint : public Update { - RTTI_DECL friend class Skeleton; public: + RTTI_DECL + Constraint(); virtual ~Constraint(); diff --git a/spine-cpp/spine-cpp/include/spine/Slot.h b/spine-cpp/spine-cpp/include/spine/Slot.h index 8127ff5c2..edb90e2a5 100644 --- a/spine-cpp/spine-cpp/include/spine/Slot.h +++ b/spine-cpp/spine-cpp/include/spine/Slot.h @@ -35,6 +35,7 @@ #include #include #include +#include namespace spine { class Bone; diff --git a/spine-cpp/spine-cpp/src/spine/Bone.cpp b/spine-cpp/spine-cpp/src/spine/Bone.cpp index b79cd8994..d5f18befe 100644 --- a/spine-cpp/spine-cpp/src/spine/Bone.cpp +++ b/spine-cpp/spine-cpp/src/spine/Bone.cpp @@ -34,7 +34,7 @@ using namespace spine; -RTTI_IMPL_NOPARENT(Bone) +RTTI_IMPL(Bone, Update) bool Bone::yDown = true; diff --git a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp index 57f767995..c727eb299 100644 --- a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp +++ b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -155,7 +156,8 @@ void Skeleton::updateCache() { Update **updateCache = _updateCache.buffer(); n = _updateCache.size(); for (size_t i = 0; i < n; i++) { - if (updateCache[i]->getRTTI().instanceOf(Bone::rtti)) { + const RTTI &rtti = updateCache[i]->getRTTI(); + if (rtti.instanceOf(Bone::rtti)) { Bone *bone = (Bone*)(updateCache[i]); updateCache[i] = bone->_applied; } @@ -179,6 +181,9 @@ void Skeleton::printUpdateCache() { } else if (updatable->getRTTI().isExactly(PhysicsConstraint::rtti)) { printf("physics constraint %s\n", ((PhysicsConstraint *) updatable)->getData().getName().buffer()); + } else if (updatable->getRTTI().isExactly(Slider::rtti)) { + printf("slider %s\n", + ((Slider *) updatable)->getData().getName().buffer()); } } } diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp index 5c52f946f..d5e099031 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp @@ -277,6 +277,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) { Json *entry = Json::getItem(constraintMap, "bones"); data->_bones.setSize(entry->_size, 0); + entry = entry->_child; for (int boneCount = 0; entry; entry = entry->_next, ++boneCount) { data->_bones[boneCount] = skeletonData->findBone(entry->_valueString); if (!data->_bones[boneCount]) SKELETON_JSON_ERROR(root, "IK bone not found: ", entry->_valueString); @@ -302,6 +303,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) { Json *entry = Json::getItem(constraintMap, "bones"); data->_bones.setSize(entry->_size, 0); + entry = entry->_child; for (int boneCount = 0; entry; entry = entry->_next, ++boneCount) { data->_bones[boneCount] = skeletonData->findBone(entry->_valueString); if (!data->_bones[boneCount]) SKELETON_JSON_ERROR(root, "Transform constraint bone not found: ", entry->_valueString); @@ -390,6 +392,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) { Json *entry = Json::getItem(constraintMap, "bones"); data->_bones.setSize(entry->_size, 0); + entry = entry->_child; for (int boneCount = 0; entry; entry = entry->_next, ++boneCount) { data->_bones[boneCount] = skeletonData->findBone(entry->_valueString); if (!data->_bones[boneCount]) SKELETON_JSON_ERROR(root, "Path bone not found: ", entry->_valueString); diff --git a/spine-glfw/CMakeLists.txt b/spine-glfw/CMakeLists.txt index 8ff02a105..9196d97d6 100644 --- a/spine-glfw/CMakeLists.txt +++ b/spine-glfw/CMakeLists.txt @@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.10) project(spine-glfw) include(FetchContent) +# Set GLFW options before fetching +set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE) +set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE) +set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE) +set(GLFW_INSTALL OFF CACHE BOOL " " FORCE) + # Fetch GLFW FetchContent_Declare( glfw @@ -10,23 +16,25 @@ FetchContent_Declare( GIT_SHALLOW 1 ) FetchContent_MakeAvailable(glfw) -set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE) -set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE) -set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE) -set(GLFW_INSTALL OFF CACHE BOOL " " FORCE) + +# Set glbinding options before fetching +set(OPTION_BUILD_DOCS OFF CACHE BOOL " " FORCE) +set(OPTION_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE) +set(OPTION_BUILD_TESTS OFF CACHE BOOL " " FORCE) +set(OPTION_BUILD_TOOLS OFF CACHE BOOL " " FORCE) +set(OPTION_BUILD_WITH_BOOST_THREAD OFF CACHE BOOL " " FORCE) +set(OPTION_BUILD_GPU_TESTS OFF CACHE BOOL " " FORCE) +set(OPTION_BUILD_PYTHON_BINDINGS OFF CACHE BOOL " " FORCE) +set(OPTION_SELF_CONTAINED OFF CACHE BOOL " " FORCE) # Fetch glbinding FetchContent_Declare( glbinding GIT_REPOSITORY https://github.com/cginternals/glbinding.git - GIT_TAG v3.4.0 + GIT_TAG master GIT_SHALLOW 1 ) FetchContent_MakeAvailable(glbinding) -set(OPTION_BUILD_DOCS OFF CACHE BOOL " " FORCE) -set(OPTION_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE) -set(OPTION_BUILD_TEST OFF CACHE BOOL " " FORCE) -set(OPTION_BUILD_TOOLS OFF CACHE BOOL " " FORCE) include_directories(${glbinding_SOURCE_DIR}/include) include_directories(src) @@ -37,13 +45,13 @@ find_package(OpenGL REQUIRED) # Default flags include(${CMAKE_SOURCE_DIR}/../flags.cmake) -# Add spine-cpp -add_subdirectory(${CMAKE_SOURCE_DIR}/../spine-cpp ${CMAKE_BINARY_DIR}/spine-cpp-build) +# Add spine-c (which includes spine-cpp) +add_subdirectory(${CMAKE_SOURCE_DIR}/../spine-c ${CMAKE_BINARY_DIR}/spine-c-build) # spine-glfw library add_library(spine-glfw STATIC src/spine-glfw.cpp src/spine-glfw.h src/stb_image.h) target_link_libraries(spine-glfw PRIVATE glbinding::glbinding) -target_link_libraries(spine-glfw LINK_PUBLIC spine-cpp-lite) +target_link_libraries(spine-glfw LINK_PUBLIC spine-c) # Example add_executable(spine-glfw-example example/main.cpp) @@ -53,13 +61,13 @@ target_link_libraries(spine-glfw-example LINK_PUBLIC spine-glfw) target_link_libraries(spine-glfw-example PRIVATE glbinding::glbinding) set_property(TARGET spine-glfw-example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/spine-glfw") -# spine-cpp-lite Example -add_executable(spine-glfw-example-cpp-lite example/main-cpp-lite.cpp) -target_link_libraries(spine-glfw-example-cpp-lite PRIVATE glfw) -target_link_libraries(spine-glfw-example-cpp-lite PRIVATE OpenGL::GL) -target_link_libraries(spine-glfw-example-cpp-lite LINK_PUBLIC spine-glfw) -target_link_libraries(spine-glfw-example-cpp-lite PRIVATE glbinding::glbinding) -set_property(TARGET spine-glfw-example-cpp-lite PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/spine-glfw") +# spine-c Example +add_executable(spine-glfw-example-c example/main-c.cpp) +target_link_libraries(spine-glfw-example-c PRIVATE glfw) +target_link_libraries(spine-glfw-example-c PRIVATE OpenGL::GL) +target_link_libraries(spine-glfw-example-c LINK_PUBLIC spine-glfw) +target_link_libraries(spine-glfw-example-c PRIVATE glbinding::glbinding) +set_property(TARGET spine-glfw-example-c PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/spine-glfw") # copy data to build directory diff --git a/spine-glfw/example/main-cpp-lite.cpp b/spine-glfw/example/main-c.cpp similarity index 88% rename from spine-glfw/example/main-cpp-lite.cpp rename to spine-glfw/example/main-c.cpp index dbdd5b94b..ab205a122 100644 --- a/spine-glfw/example/main-cpp-lite.cpp +++ b/spine-glfw/example/main-c.cpp @@ -91,11 +91,14 @@ int main() { // Load the atlas and the skeleton data int atlas_length = 0; uint8_t *atlas_bytes = read_file("data/spineboy-pma.atlas", &atlas_length); - spine_atlas atlas = spine_atlas_load_callback((utf8 *) atlas_bytes, "data/", load_texture, unload_texture); + spine_atlas atlas = spine_atlas_load_callback((const char *) atlas_bytes, "data/", load_texture, unload_texture); int skeleton_length = 0; - uint8_t *skeleton_bytes = read_file("data/spineboy-pro.skel", &skeleton_length); - spine_skeleton_data_result result = spine_skeleton_data_load_binary(atlas, skeleton_bytes, skeleton_length); - spine_skeleton_data skeleton_data = spine_skeleton_data_result_get_data(result); + // uint8_t *skeleton_bytes = read_file("data/spineboy-pro.skel", &skeleton_length); + // spine_skeleton_data_result result = spine_skeleton_data_load_binary(atlas, skeleton_bytes, skeleton_length); + + uint8_t *skeleton_bytes = read_file("data/spineboy-pro.json", &skeleton_length); + spine_skeleton_data_result result2 = spine_skeleton_data_load_json(atlas, (const char *) skeleton_bytes); + spine_skeleton_data skeleton_data = spine_skeleton_data_result_get_data(result2); // Create a skeleton from the data, set the skeleton's position to the bottom center of // the screen and scale it to make it smaller. @@ -109,8 +112,8 @@ int main() { spine_animation_state animation_state = spine_skeleton_drawable_get_animation_state(drawable); spine_animation_state_data animation_state_data = spine_animation_state_get_data(animation_state); spine_animation_state_data_set_default_mix(animation_state_data, 0.2f); - spine_animation_state_set_animation_by_name(animation_state, 0, "portal", true); - spine_animation_state_add_animation_by_name(animation_state, 0, "run", true, 0); + spine_animation_state_set_animation_1(animation_state, 0, "portal", true); + spine_animation_state_add_animation_1(animation_state, 0, "run", true, 0); // Create the renderer and set the viewport size to match the window size. This sets up a // pixel perfect orthogonal projection for 2D rendering. @@ -133,7 +136,7 @@ int main() { spine_skeleton_update(skeleton, delta); // Calculate the new pose - spine_skeleton_update_world_transform(skeleton, SPINE_PHYSICS_UPDATE); + spine_skeleton_update_world_transform_1(skeleton, SPINE_PHYSICS_UPDATE); // Clear the screen gl::glClear(gl::GL_COLOR_BUFFER_BIT); diff --git a/spine-glfw/example/main.cpp b/spine-glfw/example/main.cpp index c3a2943d4..0cbf8a88b 100644 --- a/spine-glfw/example/main.cpp +++ b/spine-glfw/example/main.cpp @@ -69,11 +69,14 @@ int main() { GlTextureLoader textureLoader; Atlas *atlas = new Atlas("data/spineboy-pma.atlas", &textureLoader); SkeletonBinary binary(atlas); - SkeletonData *skeletonData = binary.readSkeletonDataFile("data/spineboy-pro.skel"); + // SkeletonData *skeletonData = binary.readSkeletonDataFile("data/spineboy-pro.skel"); + + SkeletonJson json(atlas); + SkeletonData *skeletonData = json.readSkeletonDataFile("data/spineboy-pro.json"); // Create a skeleton from the data, set the skeleton's position to the bottom center of // the screen and scale it to make it smaller. - Skeleton skeleton(skeletonData); + Skeleton skeleton(*skeletonData); skeleton.setPosition(width / 2, height - 100); skeleton.setScaleX(0.3); skeleton.setScaleY(0.3); diff --git a/spine-glfw/src/spine-glfw.h b/spine-glfw/src/spine-glfw.h index 159b5bd93..5567415f4 100644 --- a/spine-glfw/src/spine-glfw.h +++ b/spine-glfw/src/spine-glfw.h @@ -31,7 +31,7 @@ #include #include -#include +#include /// A vertex of a mesh generated from a Spine skeleton struct vertex_t {