[c] spine_skeleton_get_bounds extension returning spine_bounds struct

This commit is contained in:
Mario Zechner 2025-07-30 00:43:01 +02:00
parent 65f01fefb9
commit 09969f5649
4 changed files with 24 additions and 5 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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<float> *) 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,

View File

@ -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);