mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-12 10:08:44 +08:00
[flutter] Wrap VertexAttachment.
This commit is contained in:
parent
fa4c55067a
commit
5c5c3e2ec7
@ -1029,7 +1029,7 @@ class RegionAttachment extends Attachment {
|
||||
RegionAttachment._(spine_attachment attachment): super._(attachment);
|
||||
|
||||
List<double> computeWorldVertices(Slot slot) {
|
||||
Pointer<Float> vertices = malloc.allocate(4 * 9).cast();
|
||||
Pointer<Float> vertices = malloc.allocate(4 * 8).cast();
|
||||
_bindings.spine_region_attachment_compute_world_vertices(_attachment, slot._slot, vertices);
|
||||
final result = vertices.asTypedList(8).toList();
|
||||
malloc.free(vertices);
|
||||
@ -1133,6 +1133,37 @@ class RegionAttachment extends Attachment {
|
||||
|
||||
class VertexAttachment extends Attachment {
|
||||
VertexAttachment._(spine_attachment attachment): super._(attachment);
|
||||
|
||||
List<double> computeWorldVertices(Slot slot) {
|
||||
final worldVerticesLength = _bindings.spine_vertex_attachment_get_world_vertices_length(_attachment);
|
||||
Pointer<Float> vertices = malloc.allocate(4 * worldVerticesLength).cast();
|
||||
_bindings.spine_vertex_attachment_compute_world_vertices(_attachment, slot._slot, vertices);
|
||||
final result = vertices.asTypedList(worldVerticesLength).toList();
|
||||
malloc.free(vertices);
|
||||
return result;
|
||||
}
|
||||
|
||||
Int32List getBones() {
|
||||
final num = _bindings.spine_vertex_attachment_get_num_bones(_attachment);
|
||||
final bones = _bindings.spine_region_attachment_get_bones(_attachment);
|
||||
return bones.asTypedList(num);
|
||||
}
|
||||
|
||||
Float32List getVertices() {
|
||||
final num = _bindings.spine_vertex_attachment_get_num_vertices(_attachment);
|
||||
final vertices = _bindings.spine_region_attachment_get_vertices(_attachment);
|
||||
return vertices.asTypedList(num);
|
||||
}
|
||||
|
||||
Attachment? getTimelineAttachment() {
|
||||
final attachment = _bindings.spine_vertex_attachment_get_timeline_attachment(_attachment);
|
||||
if (_attachment.address == nullptr.address) return null;
|
||||
return Attachment._toSubclass(attachment);
|
||||
}
|
||||
|
||||
void setTimelineAttachment(Attachment? attachment) {
|
||||
_bindings.spine_vertex_attachment_set_timeline_attachment(_attachment, attachment == null ? nullptr : attachment._attachment);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME
|
||||
|
||||
@ -5293,10 +5293,10 @@ class SpineFlutterBindings {
|
||||
ffi.Pointer<ffi.Float> Function(spine_region_attachment)>();
|
||||
|
||||
spine_attachment spine_vertex_attachment_get_timeline_attachment(
|
||||
spine_vertex_attachment attachment,
|
||||
spine_vertex_attachment timelineAttachment,
|
||||
) {
|
||||
return _spine_vertex_attachment_get_timeline_attachment(
|
||||
attachment,
|
||||
timelineAttachment,
|
||||
);
|
||||
}
|
||||
|
||||
@ -5310,18 +5310,21 @@ class SpineFlutterBindings {
|
||||
|
||||
void spine_vertex_attachment_set_timeline_attachment(
|
||||
spine_vertex_attachment attachment,
|
||||
spine_attachment timelineAttachment,
|
||||
) {
|
||||
return _spine_vertex_attachment_set_timeline_attachment(
|
||||
attachment,
|
||||
timelineAttachment,
|
||||
);
|
||||
}
|
||||
|
||||
late final _spine_vertex_attachment_set_timeline_attachmentPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Void Function(spine_vertex_attachment)>>(
|
||||
'spine_vertex_attachment_set_timeline_attachment');
|
||||
late final _spine_vertex_attachment_set_timeline_attachmentPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Void Function(spine_vertex_attachment, spine_attachment)>>(
|
||||
'spine_vertex_attachment_set_timeline_attachment');
|
||||
late final _spine_vertex_attachment_set_timeline_attachment =
|
||||
_spine_vertex_attachment_set_timeline_attachmentPtr
|
||||
.asFunction<void Function(spine_vertex_attachment)>();
|
||||
_spine_vertex_attachment_set_timeline_attachmentPtr.asFunction<
|
||||
void Function(spine_vertex_attachment, spine_attachment)>();
|
||||
|
||||
void spine_skin_set_attachment(
|
||||
spine_skin skin,
|
||||
|
||||
@ -2262,10 +2262,10 @@ FFI_PLUGIN_EXPORT spine_attachment spine_vertex_attachment_get_timeline_attachme
|
||||
return _attachment->getTimelineAttachment();
|
||||
}
|
||||
|
||||
FFI_PLUGIN_EXPORT void spine_vertex_attachment_set_timeline_attachment(spine_vertex_attachment attachment) {
|
||||
FFI_PLUGIN_EXPORT void spine_vertex_attachment_set_timeline_attachment(spine_vertex_attachment attachment, spine_attachment timelineAttachment) {
|
||||
if (attachment == nullptr) return;
|
||||
VertexAttachment *_attachment = (VertexAttachment*)attachment;
|
||||
_attachment->setTimelineAttachment((Attachment*)attachment);
|
||||
_attachment->setTimelineAttachment((Attachment*)timelineAttachment);
|
||||
}
|
||||
|
||||
// Skin
|
||||
|
||||
@ -525,8 +525,8 @@ FFI_PLUGIN_EXPORT int spine_vertex_attachment_get_num_bones(spine_vertex_attachm
|
||||
FFI_PLUGIN_EXPORT int *spine_region_attachment_get_bones(spine_region_attachment attachment);
|
||||
FFI_PLUGIN_EXPORT int spine_vertex_attachment_get_num_vertices(spine_vertex_attachment attachment);
|
||||
FFI_PLUGIN_EXPORT float *spine_region_attachment_get_vertices(spine_region_attachment attachment);
|
||||
FFI_PLUGIN_EXPORT spine_attachment spine_vertex_attachment_get_timeline_attachment(spine_vertex_attachment attachment);
|
||||
FFI_PLUGIN_EXPORT void spine_vertex_attachment_set_timeline_attachment(spine_vertex_attachment attachment);
|
||||
FFI_PLUGIN_EXPORT spine_attachment spine_vertex_attachment_get_timeline_attachment(spine_vertex_attachment timelineAttachment);
|
||||
FFI_PLUGIN_EXPORT void spine_vertex_attachment_set_timeline_attachment(spine_vertex_attachment attachment, spine_attachment timelineAttachment);
|
||||
|
||||
FFI_PLUGIN_EXPORT void spine_skin_set_attachment(spine_skin skin, int slotIndex, const char* name, spine_attachment attachment);
|
||||
FFI_PLUGIN_EXPORT spine_attachment spine_skin_get_attachment(spine_skin skin, int slotIndex, const char* name);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user