mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[c] extension methods for bounds, worldToLocal etc. SPINE_OPAQUE_TYPE is now fully opaque.
This commit is contained in:
parent
f9fefee0c8
commit
eaa4d5dd54
@ -58,28 +58,22 @@
|
|||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
/* Clang needs to suppress both pedantic and C/C++ compatibility warnings */
|
/* Clang needs to suppress both pedantic and C/C++ compatibility warnings */
|
||||||
#define SPINE_OPAQUE_TYPE(name) \
|
#define SPINE_OPAQUE_TYPE(name) \
|
||||||
_Pragma("clang diagnostic push") \
|
_Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wpedantic\"") \
|
||||||
_Pragma("clang diagnostic ignored \"-Wpedantic\"") \
|
_Pragma("clang diagnostic ignored \"-Wextern-c-compat\"") typedef struct name##_wrapper { \
|
||||||
_Pragma("clang diagnostic ignored \"-Wextern-c-compat\"") \
|
} name##_wrapper; \
|
||||||
typedef struct name##_wrapper { \
|
_Pragma("clang diagnostic pop") typedef name##_wrapper *name;
|
||||||
} name##_wrapper; \
|
|
||||||
_Pragma("clang diagnostic pop") \
|
|
||||||
typedef name##_wrapper *name;
|
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
/* GCC only needs to suppress pedantic warning */
|
/* GCC only needs to suppress pedantic warning */
|
||||||
#define SPINE_OPAQUE_TYPE(name) \
|
#define SPINE_OPAQUE_TYPE(name) \
|
||||||
_Pragma("GCC diagnostic push") \
|
_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wpedantic\"") typedef struct name##_wrapper { \
|
||||||
_Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
|
} name##_wrapper; \
|
||||||
typedef struct name##_wrapper { \
|
_Pragma("GCC diagnostic pop") typedef name##_wrapper *name;
|
||||||
} name##_wrapper; \
|
|
||||||
_Pragma("GCC diagnostic pop") \
|
|
||||||
typedef name##_wrapper *name;
|
|
||||||
#else
|
#else
|
||||||
/* Other compilers - generic version */
|
/* Other compilers - generic version */
|
||||||
#define SPINE_OPAQUE_TYPE(name) \
|
#define SPINE_OPAQUE_TYPE(name) \
|
||||||
typedef struct name##_wrapper { \
|
typedef struct name##_wrapper { \
|
||||||
} name##_wrapper; \
|
} name##_wrapper; \
|
||||||
typedef name##_wrapper *name;
|
typedef name##_wrapper *name;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -495,51 +495,70 @@ spine_skin_entries spine_skin_get_entries(spine_skin skin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skeleton bounds function
|
// Skeleton bounds function
|
||||||
spine_bounds spine_skeleton_get_bounds(spine_skeleton skeleton) {
|
void spine_skeleton_get_bounds(spine_skeleton self, spine_array_float output) {
|
||||||
spine_bounds bounds = {0, 0, 0, 0};
|
spine_array_float_clear(output);
|
||||||
if (!skeleton) return bounds;
|
if (!self) return;
|
||||||
|
|
||||||
Skeleton *_skeleton = (Skeleton *) skeleton;
|
Skeleton *_skeleton = (Skeleton *) self;
|
||||||
_skeleton->getBounds(bounds.x, bounds.y, bounds.width, bounds.height);
|
float x, y, width, height;
|
||||||
return bounds;
|
_skeleton->getBounds(x, y, width, height);
|
||||||
|
spine_array_float_add(output, x);
|
||||||
|
spine_array_float_add(output, y);
|
||||||
|
spine_array_float_add(output, width);
|
||||||
|
spine_array_float_add(output, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
spine_vector spine_skeleton_get_position_v(spine_skeleton skeleton) {
|
void spine_skeleton_get_position_v(spine_skeleton self, spine_array_float output) {
|
||||||
if (!skeleton) return {0, 0};
|
spine_array_float_clear(output);
|
||||||
Skeleton *_skeleton = (Skeleton *) skeleton;
|
if (!self) return;
|
||||||
|
|
||||||
|
Skeleton *_skeleton = (Skeleton *) self;
|
||||||
float x, y;
|
float x, y;
|
||||||
_skeleton->getPosition(x, y);
|
_skeleton->getPosition(x, y);
|
||||||
return {x, y};
|
spine_array_float_add(output, x);
|
||||||
|
spine_array_float_add(output, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
spine_vector spine_bone_pose_world_to_local_v(spine_bone_pose self, float world_x, float world_y) {
|
void spine_bone_pose_world_to_local_v(spine_bone_pose self, float world_x, float world_y, spine_array_float output) {
|
||||||
if (!self) return {0, 0};
|
spine_array_float_clear(output);
|
||||||
|
if (!self) return;
|
||||||
|
|
||||||
BonePose *_self = (BonePose *) self;
|
BonePose *_self = (BonePose *) self;
|
||||||
float localX, localY;
|
float localX, localY;
|
||||||
_self->worldToLocal(world_x, world_y, localX, localY);
|
_self->worldToLocal(world_x, world_y, localX, localY);
|
||||||
return {localX, localY};
|
spine_array_float_add(output, localX);
|
||||||
|
spine_array_float_add(output, localY);
|
||||||
}
|
}
|
||||||
|
|
||||||
spine_vector spine_bone_pose_local_to_world_v(spine_bone_pose self, float local_x, float local_y) {
|
void spine_bone_pose_local_to_world_v(spine_bone_pose self, float local_x, float local_y, spine_array_float output) {
|
||||||
if (!self) return {0, 0};
|
spine_array_float_clear(output);
|
||||||
|
if (!self) return;
|
||||||
|
|
||||||
BonePose *_self = (BonePose *) self;
|
BonePose *_self = (BonePose *) self;
|
||||||
float worldX, worldY;
|
float worldX, worldY;
|
||||||
_self->localToWorld(local_x, local_y, worldX, worldY);
|
_self->localToWorld(local_x, local_y, worldX, worldY);
|
||||||
return {worldX, worldY};
|
spine_array_float_add(output, worldX);
|
||||||
|
spine_array_float_add(output, worldY);
|
||||||
}
|
}
|
||||||
|
|
||||||
spine_vector spine_bone_pose_world_to_parent_v(spine_bone_pose self, float world_x, float world_y) {
|
void spine_bone_pose_world_to_parent_v(spine_bone_pose self, float world_x, float world_y, spine_array_float output) {
|
||||||
if (!self) return {0, 0};
|
spine_array_float_clear(output);
|
||||||
|
if (!self) return;
|
||||||
|
|
||||||
BonePose *_self = (BonePose *) self;
|
BonePose *_self = (BonePose *) self;
|
||||||
float parentX, parentY;
|
float parentX, parentY;
|
||||||
_self->worldToParent(world_x, world_y, parentX, parentY);
|
_self->worldToParent(world_x, world_y, parentX, parentY);
|
||||||
return {parentX, parentY};
|
spine_array_float_add(output, parentX);
|
||||||
|
spine_array_float_add(output, parentY);
|
||||||
}
|
}
|
||||||
|
|
||||||
spine_vector spine_bone_pose_parent_to_world_v(spine_bone_pose self, float parent_x, float parent_y) {
|
void spine_bone_pose_parent_to_world_v(spine_bone_pose self, float parent_x, float parent_y, spine_array_float output) {
|
||||||
if (!self) return {0, 0};
|
spine_array_float_clear(output);
|
||||||
|
if (!self) return;
|
||||||
|
|
||||||
BonePose *_self = (BonePose *) self;
|
BonePose *_self = (BonePose *) self;
|
||||||
float worldX, worldY;
|
float worldX, worldY;
|
||||||
_self->parentToWorld(parent_x, parent_y, worldX, worldY);
|
_self->parentToWorld(parent_x, parent_y, worldX, worldY);
|
||||||
return {worldX, worldY};
|
spine_array_float_add(output, worldX);
|
||||||
|
spine_array_float_add(output, worldY);
|
||||||
}
|
}
|
||||||
@ -48,20 +48,6 @@ SPINE_OPAQUE_TYPE(spine_skin_entry)
|
|||||||
SPINE_OPAQUE_TYPE(spine_skin_entries)
|
SPINE_OPAQUE_TYPE(spine_skin_entries)
|
||||||
SPINE_OPAQUE_TYPE(spine_texture_loader)
|
SPINE_OPAQUE_TYPE(spine_texture_loader)
|
||||||
|
|
||||||
// Bounds struct
|
|
||||||
typedef struct spine_bounds {
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float width;
|
|
||||||
float height;
|
|
||||||
} spine_bounds;
|
|
||||||
|
|
||||||
// Vector struct
|
|
||||||
typedef struct spine_vector {
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
} spine_vector;
|
|
||||||
|
|
||||||
// Additional types
|
// Additional types
|
||||||
typedef void *spine_void;
|
typedef void *spine_void;
|
||||||
typedef void (*spine_dispose_renderer_object)(void *);
|
typedef void (*spine_dispose_renderer_object)(void *);
|
||||||
@ -122,14 +108,14 @@ 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);
|
SPINE_C_API spine_attachment spine_skin_entry_get_attachment(spine_skin_entry entry);
|
||||||
|
|
||||||
// Skeleton functions
|
// Skeleton functions
|
||||||
SPINE_C_API spine_bounds spine_skeleton_get_bounds(spine_skeleton skeleton);
|
SPINE_C_API void spine_skeleton_get_bounds(spine_skeleton skeleton, spine_array_float output);
|
||||||
SPINE_C_API spine_vector spine_skeleton_get_position_v(spine_skeleton skeleton);
|
SPINE_C_API void spine_skeleton_get_position_v(spine_skeleton skeleton, spine_array_float output);
|
||||||
|
|
||||||
// BonePose functions
|
// BonePose functions
|
||||||
SPINE_C_API spine_vector spine_bone_pose_world_to_local_v(spine_bone_pose self, float world_x, float world_y);
|
SPINE_C_API void spine_bone_pose_world_to_local_v(spine_bone_pose self, float world_x, float world_y, spine_array_float output);
|
||||||
SPINE_C_API spine_vector spine_bone_pose_local_to_world_v(spine_bone_pose self, float local_x, float local_y);
|
SPINE_C_API void spine_bone_pose_local_to_world_v(spine_bone_pose self, float local_x, float local_y, spine_array_float output);
|
||||||
SPINE_C_API spine_vector spine_bone_pose_world_to_parent_v(spine_bone_pose self, float world_x, float world_y);
|
SPINE_C_API void spine_bone_pose_world_to_parent_v(spine_bone_pose self, float world_x, float world_y, spine_array_float output);
|
||||||
SPINE_C_API spine_vector spine_bone_pose_parent_to_world_v(spine_bone_pose self, float parent_x, float parent_y);
|
SPINE_C_API void spine_bone_pose_parent_to_world_v(spine_bone_pose self, float parent_x, float parent_y, spine_array_float output);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user