Skip to content

Commit

Permalink
[ios] Provide the ability to convert an Attachment into a BoundingBox…
Browse files Browse the repository at this point in the history
…Attachment. (#2671)

Co-authored-by: liqiang <[email protected]>
  • Loading branch information
kikiloveswift and liqiang authored Nov 14, 2024
1 parent a815fc4 commit 648170f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spine-cpp/spine-cpp-lite/spine-cpp-lite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,16 @@ spine_attachment spine_attachment_copy(spine_attachment attachment) {
return (spine_attachment) _attachment->copy();
}

spine_bounding_box_attachment spine_attachment_cast_to_bounding_box_attachment(spine_attachment attachment) {
if (attachment == nullptr) return nullptr;
Attachment *_attachment = (Attachment *)attachment;
if (_attachment->getRTTI().isExactly(BoundingBoxAttachment::rtti)) {
BoundingBoxAttachment *boundingBox = static_cast<BoundingBoxAttachment *>(_attachment);
return (spine_bounding_box_attachment)boundingBox;
}
return nullptr;
}

void spine_attachment_dispose(spine_attachment attachment) {
if (attachment == nullptr) return;
Attachment *_attachment = (Attachment *) attachment;
Expand Down
2 changes: 2 additions & 0 deletions spine-cpp/spine-cpp-lite/spine-cpp-lite.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,8 @@ SPINE_CPP_LITE_EXPORT const utf8 *spine_attachment_get_name(spine_attachment att
SPINE_CPP_LITE_EXPORT spine_attachment_type spine_attachment_get_type(spine_attachment attachment);
// @ignore
SPINE_CPP_LITE_EXPORT spine_attachment spine_attachment_copy(spine_attachment attachment);
// @optional
SPINE_CPP_LITE_EXPORT spine_bounding_box_attachment spine_attachment_cast_to_bounding_box_attachment(spine_attachment attachment);
SPINE_CPP_LITE_EXPORT void spine_attachment_dispose(spine_attachment attachment);

SPINE_CPP_LITE_EXPORT spine_vector spine_point_attachment_compute_world_position(spine_point_attachment attachment, spine_bone bone);
Expand Down
5 changes: 5 additions & 0 deletions spine-ios/Sources/Spine/Spine.Generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2553,6 +2553,11 @@ public final class Attachment: NSObject {
return spine_attachment_get_type(wrappee)
}

@discardableResult
public func castToBoundingBoxAttachment() -> BoundingBoxAttachment? {
return spine_attachment_cast_to_bounding_box_attachment(wrappee).flatMap { .init($0) }
}

public func dispose() {
if disposed { return }
disposed = true
Expand Down

0 comments on commit 648170f

Please sign in to comment.