mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-25 22:23:42 +08:00
[godot] Update to new Sequence API
- Use sequence.resolveIndex(pose) to get current frame index - Use sequence.getOffsets(index) for RegionAttachment computeWorldVertices - Use sequence.getRegion(index) for texture lookup - Use sequence.getUVs(index) for UV data
This commit is contained in:
parent
04d81a4fe3
commit
3afca98bbb
@ -873,11 +873,13 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
|
|||||||
|
|
||||||
if (attachment->getRTTI().isExactly(spine::RegionAttachment::rtti)) {
|
if (attachment->getRTTI().isExactly(spine::RegionAttachment::rtti)) {
|
||||||
auto region = (spine::RegionAttachment *) attachment;
|
auto region = (spine::RegionAttachment *) attachment;
|
||||||
|
auto &sequence = region->getSequence();
|
||||||
|
int sequenceIndex = sequence.resolveIndex(slot->getAppliedPose());
|
||||||
|
|
||||||
vertices->setSize(8, 0);
|
vertices->setSize(8, 0);
|
||||||
region->computeWorldVertices(*slot, *vertices, 0);
|
region->computeWorldVertices(*slot, sequence.getOffsets(sequenceIndex).buffer(), vertices->buffer(), 0);
|
||||||
renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) region->getRegion())->getPage()->texture;
|
renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) sequence.getRegion(sequenceIndex))->getPage()->texture;
|
||||||
uvs = ®ion->getUVs();
|
uvs = &sequence.getUVs(sequenceIndex);
|
||||||
indices = &statics.quad_indices;
|
indices = &statics.quad_indices;
|
||||||
|
|
||||||
auto &attachment_color = region->getColor();
|
auto &attachment_color = region->getColor();
|
||||||
@ -887,12 +889,14 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
|
|||||||
tint.a *= attachment_color.a;
|
tint.a *= attachment_color.a;
|
||||||
} else if (attachment->getRTTI().isExactly(spine::MeshAttachment::rtti)) {
|
} else if (attachment->getRTTI().isExactly(spine::MeshAttachment::rtti)) {
|
||||||
auto mesh = (spine::MeshAttachment *) attachment;
|
auto mesh = (spine::MeshAttachment *) attachment;
|
||||||
|
auto &sequence = mesh->getSequence();
|
||||||
|
int sequenceIndex = sequence.resolveIndex(slot->getAppliedPose());
|
||||||
|
|
||||||
vertices->setSize(mesh->getWorldVerticesLength(), 0);
|
vertices->setSize(mesh->getWorldVerticesLength(), 0);
|
||||||
mesh->computeWorldVertices(*skeleton, *slot, 0, mesh->getWorldVerticesLength(), vertices->buffer(), 0, 2);
|
mesh->computeWorldVertices(*skeleton, *slot, 0, mesh->getWorldVerticesLength(), vertices->buffer(), 0, 2);
|
||||||
|
|
||||||
renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) mesh->getRegion())->getPage()->texture;
|
renderer_object = (SpineRendererObject *) ((spine::AtlasRegion *) sequence.getRegion(sequenceIndex))->getPage()->texture;
|
||||||
uvs = &mesh->getUVs();
|
uvs = &sequence.getUVs(sequenceIndex);
|
||||||
indices = &mesh->getTriangles();
|
indices = &mesh->getTriangles();
|
||||||
|
|
||||||
auto &attachment_color = mesh->getColor();
|
auto &attachment_color = mesh->getColor();
|
||||||
@ -1058,9 +1062,11 @@ void SpineSprite::draw() {
|
|||||||
if (!attachment) continue;
|
if (!attachment) continue;
|
||||||
if (!attachment->getRTTI().isExactly(spine::RegionAttachment::rtti)) continue;
|
if (!attachment->getRTTI().isExactly(spine::RegionAttachment::rtti)) continue;
|
||||||
auto region = (spine::RegionAttachment *) attachment;
|
auto region = (spine::RegionAttachment *) attachment;
|
||||||
|
auto &sequence = region->getSequence();
|
||||||
|
int sequenceIndex = sequence.resolveIndex(slot->getAppliedPose());
|
||||||
auto vertices = &statics.scratch_vertices;
|
auto vertices = &statics.scratch_vertices;
|
||||||
vertices->setSize(8, 0);
|
vertices->setSize(8, 0);
|
||||||
region->computeWorldVertices(*slot, *vertices, 0);
|
region->computeWorldVertices(*slot, sequence.getOffsets(sequenceIndex).buffer(), vertices->buffer(), 0);
|
||||||
|
|
||||||
// Render triangles.
|
// Render triangles.
|
||||||
createLinesFromMesh(statics.scratch_points, statics.quad_indices, vertices);
|
createLinesFromMesh(statics.scratch_points, statics.quad_indices, vertices);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user