From 09969f5649b90f6e29cb3b5e6f627a3d07417509 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 30 Jul 2025 00:43:01 +0200 Subject: [PATCH] [c] spine_skeleton_get_bounds extension returning spine_bounds struct --- spine-c/src/extensions.cpp | 10 ++++++++++ spine-c/src/extensions.h | 11 +++++++++++ spine-c/src/generated/skeleton.cpp | 5 ++--- spine-c/src/generated/skeleton.h | 3 +-- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/spine-c/src/extensions.cpp b/spine-c/src/extensions.cpp index 8c9263bc7..7f548b4ea 100644 --- a/spine-c/src/extensions.cpp +++ b/spine-c/src/extensions.cpp @@ -492,4 +492,14 @@ spine_skin_entries spine_skin_get_entries(spine_skin skin) { } return (spine_skin_entries) result; +} + +// Skeleton bounds function +spine_bounds spine_skeleton_get_bounds(spine_skeleton skeleton) { + spine_bounds bounds = {0, 0, 0, 0}; + if (!skeleton) return bounds; + + Skeleton *_skeleton = (Skeleton *) skeleton; + _skeleton->getBounds(bounds.x, bounds.y, bounds.width, bounds.height); + return bounds; } \ No newline at end of file diff --git a/spine-c/src/extensions.h b/spine-c/src/extensions.h index 1f9923f56..8cb9126e7 100644 --- a/spine-c/src/extensions.h +++ b/spine-c/src/extensions.h @@ -106,6 +106,17 @@ SPINE_C_API int32_t spine_skin_entry_get_slot_index(spine_skin_entry entry); SPINE_C_API const char *spine_skin_entry_get_name(spine_skin_entry entry); SPINE_C_API spine_attachment spine_skin_entry_get_attachment(spine_skin_entry entry); +// Bounds struct +typedef struct spine_bounds { + float x; + float y; + float width; + float height; +} spine_bounds; + +// Skeleton bounds function +SPINE_C_API spine_bounds spine_skeleton_get_bounds(spine_skeleton skeleton); + #ifdef __cplusplus } #endif diff --git a/spine-c/src/generated/skeleton.cpp b/spine-c/src/generated/skeleton.cpp index a48eefffe..2e9717dc1 100644 --- a/spine-c/src/generated/skeleton.cpp +++ b/spine-c/src/generated/skeleton.cpp @@ -135,10 +135,9 @@ spine_array_physics_constraint spine_skeleton_get_physics_constraints(spine_skel return (spine_array_physics_constraint) &_self->getPhysicsConstraints(); } -void spine_skeleton_get_bounds_1(spine_skeleton self, float *outX, float *outY, float *outWidth, float *outHeight, - spine_array_float outVertexBuffer) { +void spine_skeleton_get_bounds_1(spine_skeleton self, float *outX, float *outY, float *outWidth, float *outHeight) { Skeleton *_self = (Skeleton *) self; - _self->getBounds(*outX, *outY, *outWidth, *outHeight, *((Array *) outVertexBuffer)); + _self->getBounds(*outX, *outY, *outWidth, *outHeight); } void spine_skeleton_get_bounds_2(spine_skeleton self, float *outX, float *outY, float *outWidth, float *outHeight, spine_array_float outVertexBuffer, diff --git a/spine-c/src/generated/skeleton.h b/spine-c/src/generated/skeleton.h index ba6d52c98..ba4ba1639 100644 --- a/spine-c/src/generated/skeleton.h +++ b/spine-c/src/generated/skeleton.h @@ -38,8 +38,7 @@ SPINE_C_API /*@null*/ spine_attachment spine_skeleton_get_attachment_2(spine_ske SPINE_C_API void spine_skeleton_set_attachment(spine_skeleton self, const char *slotName, const char *attachmentName); SPINE_C_API spine_array_constraint spine_skeleton_get_constraints(spine_skeleton self); SPINE_C_API spine_array_physics_constraint spine_skeleton_get_physics_constraints(spine_skeleton self); -SPINE_C_API void spine_skeleton_get_bounds_1(spine_skeleton self, float *outX, float *outY, float *outWidth, float *outHeight, - spine_array_float outVertexBuffer); +SPINE_C_API void spine_skeleton_get_bounds_1(spine_skeleton self, float *outX, float *outY, float *outWidth, float *outHeight); SPINE_C_API void spine_skeleton_get_bounds_2(spine_skeleton self, float *outX, float *outY, float *outWidth, float *outHeight, spine_array_float outVertexBuffer, /*@null*/ spine_skeleton_clipping clipper); SPINE_C_API spine_color spine_skeleton_get_color(spine_skeleton self);