mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[flutter][cpp] Refactor VertexAttachment to use ints for bones instead of size_t, wrap VertexAttachment.
This commit is contained in:
parent
44c589e591
commit
fa4c55067a
@ -147,7 +147,7 @@ namespace spine {
|
||||
Attachment *readAttachment(DataInput *input, Skin *skin, int slotIndex, const String &attachmentName,
|
||||
SkeletonData *skeletonData, bool nonessential);
|
||||
|
||||
void readVertices(DataInput *input, Vector<float> &vertices, Vector<size_t> &bones, int vertexCount);
|
||||
void readVertices(DataInput *input, Vector<float> &vertices, Vector<int> &bones, int vertexCount);
|
||||
|
||||
void readFloatArray(DataInput *input, int n, float scale, Vector<float> &array);
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ namespace spine {
|
||||
/// Gets a unique ID for this attachment.
|
||||
int getId();
|
||||
|
||||
Vector <size_t> &getBones();
|
||||
Vector<int> &getBones();
|
||||
|
||||
Vector<float> &getVertices();
|
||||
|
||||
@ -86,7 +86,7 @@ namespace spine {
|
||||
void copyTo(VertexAttachment *other);
|
||||
|
||||
protected:
|
||||
Vector <size_t> _bones;
|
||||
Vector <int> _bones;
|
||||
Vector<float> _vertices;
|
||||
size_t _worldVerticesLength;
|
||||
Attachment *_timelineAttachment;
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
namespace spine {
|
||||
class SP_API Vertices : public SpineObject {
|
||||
public:
|
||||
Vector <size_t> _bones;
|
||||
Vector <int> _bones;
|
||||
Vector<float> _vertices;
|
||||
};
|
||||
}
|
||||
|
||||
@ -653,7 +653,7 @@ void Skeleton::sortPathConstraintAttachment(Skin *skin, size_t slotIndex, Bone &
|
||||
|
||||
void Skeleton::sortPathConstraintAttachment(Attachment *attachment, Bone &slotBone) {
|
||||
if (attachment == NULL || !attachment->getRTTI().instanceOf(PathAttachment::rtti)) return;
|
||||
Vector<size_t> &pathBones = static_cast<PathAttachment *>(attachment)->getBones();
|
||||
Vector<int> &pathBones = static_cast<PathAttachment *>(attachment)->getBones();
|
||||
if (pathBones.size() == 0)
|
||||
sortBone(&slotBone);
|
||||
else {
|
||||
|
||||
@ -564,7 +564,7 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
||||
Vector<float> uvs;
|
||||
Vector<unsigned short> triangles;
|
||||
Vector<float> vertices;
|
||||
Vector<size_t> bones;
|
||||
Vector<int> bones;
|
||||
int hullLength;
|
||||
Sequence *sequence;
|
||||
float width = 0;
|
||||
@ -702,7 +702,7 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void SkeletonBinary::readVertices(DataInput *input, Vector<float> &vertices, Vector<size_t> &bones, int vertexCount) {
|
||||
void SkeletonBinary::readVertices(DataInput *input, Vector<float> &vertices, Vector<int> &bones, int vertexCount) {
|
||||
float scale = _scale;
|
||||
int verticesLength = vertexCount << 1;
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, size_t start, size_t cou
|
||||
Skeleton &skeleton = slot._bone._skeleton;
|
||||
Vector<float> *deformArray = &slot.getDeform();
|
||||
Vector<float> *vertices = &_vertices;
|
||||
Vector<size_t> &bones = _bones;
|
||||
Vector<int> &bones = _bones;
|
||||
if (bones.size() == 0) {
|
||||
if (deformArray->size() > 0) vertices = deformArray;
|
||||
|
||||
@ -130,7 +130,7 @@ int VertexAttachment::getId() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
Vector<size_t> &VertexAttachment::getBones() {
|
||||
Vector<int> &VertexAttachment::getBones() {
|
||||
return _bones;
|
||||
}
|
||||
|
||||
|
||||
@ -5193,6 +5193,136 @@ class SpineFlutterBindings {
|
||||
_spine_region_attachment_get_uvsPtr.asFunction<
|
||||
ffi.Pointer<ffi.Float> Function(spine_region_attachment)>();
|
||||
|
||||
int spine_vertex_attachment_get_world_vertices_length(
|
||||
spine_vertex_attachment attachment,
|
||||
) {
|
||||
return _spine_vertex_attachment_get_world_vertices_length(
|
||||
attachment,
|
||||
);
|
||||
}
|
||||
|
||||
late final _spine_vertex_attachment_get_world_vertices_lengthPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Int32 Function(spine_vertex_attachment)>>(
|
||||
'spine_vertex_attachment_get_world_vertices_length');
|
||||
late final _spine_vertex_attachment_get_world_vertices_length =
|
||||
_spine_vertex_attachment_get_world_vertices_lengthPtr
|
||||
.asFunction<int Function(spine_vertex_attachment)>();
|
||||
|
||||
void spine_vertex_attachment_compute_world_vertices(
|
||||
spine_vertex_attachment attachment,
|
||||
spine_slot slot,
|
||||
ffi.Pointer<ffi.Float> worldVertices,
|
||||
) {
|
||||
return _spine_vertex_attachment_compute_world_vertices(
|
||||
attachment,
|
||||
slot,
|
||||
worldVertices,
|
||||
);
|
||||
}
|
||||
|
||||
late final _spine_vertex_attachment_compute_world_verticesPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Void Function(spine_vertex_attachment, spine_slot,
|
||||
ffi.Pointer<ffi.Float>)>>(
|
||||
'spine_vertex_attachment_compute_world_vertices');
|
||||
late final _spine_vertex_attachment_compute_world_vertices =
|
||||
_spine_vertex_attachment_compute_world_verticesPtr.asFunction<
|
||||
void Function(
|
||||
spine_vertex_attachment, spine_slot, ffi.Pointer<ffi.Float>)>();
|
||||
|
||||
int spine_vertex_attachment_get_num_bones(
|
||||
spine_vertex_attachment attachment,
|
||||
) {
|
||||
return _spine_vertex_attachment_get_num_bones(
|
||||
attachment,
|
||||
);
|
||||
}
|
||||
|
||||
late final _spine_vertex_attachment_get_num_bonesPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Int32 Function(spine_vertex_attachment)>>(
|
||||
'spine_vertex_attachment_get_num_bones');
|
||||
late final _spine_vertex_attachment_get_num_bones =
|
||||
_spine_vertex_attachment_get_num_bonesPtr
|
||||
.asFunction<int Function(spine_vertex_attachment)>();
|
||||
|
||||
ffi.Pointer<ffi.Int32> spine_region_attachment_get_bones(
|
||||
spine_region_attachment attachment,
|
||||
) {
|
||||
return _spine_region_attachment_get_bones(
|
||||
attachment,
|
||||
);
|
||||
}
|
||||
|
||||
late final _spine_region_attachment_get_bonesPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Pointer<ffi.Int32> Function(
|
||||
spine_region_attachment)>>('spine_region_attachment_get_bones');
|
||||
late final _spine_region_attachment_get_bones =
|
||||
_spine_region_attachment_get_bonesPtr.asFunction<
|
||||
ffi.Pointer<ffi.Int32> Function(spine_region_attachment)>();
|
||||
|
||||
int spine_vertex_attachment_get_num_vertices(
|
||||
spine_vertex_attachment attachment,
|
||||
) {
|
||||
return _spine_vertex_attachment_get_num_vertices(
|
||||
attachment,
|
||||
);
|
||||
}
|
||||
|
||||
late final _spine_vertex_attachment_get_num_verticesPtr =
|
||||
_lookup<ffi.NativeFunction<ffi.Int32 Function(spine_vertex_attachment)>>(
|
||||
'spine_vertex_attachment_get_num_vertices');
|
||||
late final _spine_vertex_attachment_get_num_vertices =
|
||||
_spine_vertex_attachment_get_num_verticesPtr
|
||||
.asFunction<int Function(spine_vertex_attachment)>();
|
||||
|
||||
ffi.Pointer<ffi.Float> spine_region_attachment_get_vertices(
|
||||
spine_region_attachment attachment,
|
||||
) {
|
||||
return _spine_region_attachment_get_vertices(
|
||||
attachment,
|
||||
);
|
||||
}
|
||||
|
||||
late final _spine_region_attachment_get_verticesPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
ffi.Pointer<ffi.Float> Function(spine_region_attachment)>>(
|
||||
'spine_region_attachment_get_vertices');
|
||||
late final _spine_region_attachment_get_vertices =
|
||||
_spine_region_attachment_get_verticesPtr.asFunction<
|
||||
ffi.Pointer<ffi.Float> Function(spine_region_attachment)>();
|
||||
|
||||
spine_attachment spine_vertex_attachment_get_timeline_attachment(
|
||||
spine_vertex_attachment attachment,
|
||||
) {
|
||||
return _spine_vertex_attachment_get_timeline_attachment(
|
||||
attachment,
|
||||
);
|
||||
}
|
||||
|
||||
late final _spine_vertex_attachment_get_timeline_attachmentPtr = _lookup<
|
||||
ffi.NativeFunction<
|
||||
spine_attachment Function(spine_vertex_attachment)>>(
|
||||
'spine_vertex_attachment_get_timeline_attachment');
|
||||
late final _spine_vertex_attachment_get_timeline_attachment =
|
||||
_spine_vertex_attachment_get_timeline_attachmentPtr
|
||||
.asFunction<spine_attachment Function(spine_vertex_attachment)>();
|
||||
|
||||
void spine_vertex_attachment_set_timeline_attachment(
|
||||
spine_vertex_attachment attachment,
|
||||
) {
|
||||
return _spine_vertex_attachment_set_timeline_attachment(
|
||||
attachment,
|
||||
);
|
||||
}
|
||||
|
||||
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_attachment =
|
||||
_spine_vertex_attachment_set_timeline_attachmentPtr
|
||||
.asFunction<void Function(spine_vertex_attachment)>();
|
||||
|
||||
void spine_skin_set_attachment(
|
||||
spine_skin skin,
|
||||
int slotIndex,
|
||||
@ -7735,4 +7865,5 @@ typedef spine_point_attachment = ffi.Pointer<ffi.Void>;
|
||||
typedef spine_region_attachment = ffi.Pointer<ffi.Void>;
|
||||
typedef spine_texture_region = ffi.Pointer<ffi.Void>;
|
||||
typedef spine_sequence = ffi.Pointer<ffi.Void>;
|
||||
typedef spine_vertex_attachment = ffi.Pointer<ffi.Void>;
|
||||
typedef spine_constraint_data = ffi.Pointer<ffi.Void>;
|
||||
|
||||
@ -2219,6 +2219,55 @@ FFI_PLUGIN_EXPORT float *spine_region_attachment_get_uvs(spine_region_attachment
|
||||
return _attachment->getUVs().buffer();
|
||||
}
|
||||
|
||||
// VertexAttachment
|
||||
FFI_PLUGIN_EXPORT int spine_vertex_attachment_get_world_vertices_length(spine_vertex_attachment attachment) {
|
||||
if (attachment == nullptr) return 0;
|
||||
VertexAttachment *_attachment = (VertexAttachment*)attachment;
|
||||
return (int)_attachment->getWorldVerticesLength();
|
||||
}
|
||||
|
||||
FFI_PLUGIN_EXPORT void spine_vertex_attachment_compute_world_vertices(spine_vertex_attachment attachment, spine_slot slot, float *worldVertices) {
|
||||
if (attachment == nullptr) return;
|
||||
VertexAttachment *_attachment = (VertexAttachment*)attachment;
|
||||
_attachment->computeWorldVertices(*(Slot*)slot, worldVertices);
|
||||
}
|
||||
|
||||
FFI_PLUGIN_EXPORT int spine_vertex_attachment_get_num_bones(spine_vertex_attachment attachment) {
|
||||
if (attachment == nullptr) return 0;
|
||||
VertexAttachment *_attachment = (VertexAttachment*)attachment;
|
||||
return (int)_attachment->getBones().size();
|
||||
}
|
||||
|
||||
FFI_PLUGIN_EXPORT int *spine_region_attachment_get_bones(spine_region_attachment attachment) {
|
||||
if (attachment == nullptr) return nullptr;
|
||||
VertexAttachment *_attachment = (VertexAttachment*)attachment;
|
||||
return _attachment->getBones().buffer();
|
||||
}
|
||||
|
||||
FFI_PLUGIN_EXPORT int spine_vertex_attachment_get_num_vertices(spine_vertex_attachment attachment) {
|
||||
if (attachment == nullptr) return 0;
|
||||
VertexAttachment *_attachment = (VertexAttachment*)attachment;
|
||||
return (int)_attachment->getVertices().size();
|
||||
}
|
||||
|
||||
FFI_PLUGIN_EXPORT float *spine_region_attachment_get_vertices(spine_region_attachment attachment) {
|
||||
if (attachment == nullptr) return nullptr;
|
||||
VertexAttachment *_attachment = (VertexAttachment*)attachment;
|
||||
return _attachment->getVertices().buffer();
|
||||
}
|
||||
|
||||
FFI_PLUGIN_EXPORT spine_attachment spine_vertex_attachment_get_timeline_attachment(spine_vertex_attachment attachment) {
|
||||
if (attachment == nullptr) return nullptr;
|
||||
VertexAttachment *_attachment = (VertexAttachment*)attachment;
|
||||
return _attachment->getTimelineAttachment();
|
||||
}
|
||||
|
||||
FFI_PLUGIN_EXPORT void spine_vertex_attachment_set_timeline_attachment(spine_vertex_attachment attachment) {
|
||||
if (attachment == nullptr) return;
|
||||
VertexAttachment *_attachment = (VertexAttachment*)attachment;
|
||||
_attachment->setTimelineAttachment((Attachment*)attachment);
|
||||
}
|
||||
|
||||
// Skin
|
||||
FFI_PLUGIN_EXPORT void spine_skin_set_attachment(spine_skin skin, int slotIndex, const char* name, spine_attachment attachment) {
|
||||
if (skin == nullptr) return;
|
||||
|
||||
@ -31,8 +31,12 @@ typedef void* spine_slot;
|
||||
typedef void* spine_slot_data;
|
||||
typedef void* spine_skin;
|
||||
typedef void* spine_attachment;
|
||||
typedef void* spine_point_attachment;
|
||||
typedef void* spine_region_attachment;
|
||||
typedef void* spine_vertex_attachment;
|
||||
typedef void* spine_mesh_attachment;
|
||||
typedef void* spine_clipping_attachment;
|
||||
typedef void* spine_path_attachment;
|
||||
typedef void* spine_point_attachment;
|
||||
typedef void* spine_texture_region;
|
||||
typedef void* spine_sequence;
|
||||
typedef void* spine_mesh_attachment;
|
||||
@ -515,6 +519,15 @@ FFI_PLUGIN_EXPORT float *spine_region_attachment_get_offset(spine_region_attachm
|
||||
FFI_PLUGIN_EXPORT int spine_region_attachment_get_num_uvs(spine_region_attachment attachment);
|
||||
FFI_PLUGIN_EXPORT float *spine_region_attachment_get_uvs(spine_region_attachment attachment);
|
||||
|
||||
FFI_PLUGIN_EXPORT int spine_vertex_attachment_get_world_vertices_length(spine_vertex_attachment attachment);
|
||||
FFI_PLUGIN_EXPORT void spine_vertex_attachment_compute_world_vertices(spine_vertex_attachment attachment, spine_slot slot, float *worldVertices);
|
||||
FFI_PLUGIN_EXPORT int spine_vertex_attachment_get_num_bones(spine_vertex_attachment attachment);
|
||||
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 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);
|
||||
FFI_PLUGIN_EXPORT void spine_skin_remove_attachment(spine_skin skin, int slotIndex, const char* name);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user