mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[cpp] Fix DeformTimeline, Slot::setAttachment
DeformTimeline had a misplaced return, Slot::setAttachment was not exactly matching the reference implementation if _attachment or inValue where NULL.
This commit is contained in:
parent
c41cc94008
commit
eedaccc418
@ -100,23 +100,23 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
deformArray.setSize(vertexCount, 0);
|
deformArray.setSize(vertexCount, 0);
|
||||||
Vector<float> &deformInner = deformArray;
|
Vector<float> &deform = deformArray;
|
||||||
if (attachment->getBones().size() == 0) {
|
if (attachment->getBones().size() == 0) {
|
||||||
// Unweighted vertex positions.
|
// Unweighted vertex positions.
|
||||||
Vector<float> &setupVertices = attachment->getVertices();
|
Vector<float> &setupVertices = attachment->getVertices();
|
||||||
for (size_t i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
deformInner[i] += (setupVertices[i] - deformInner[i]) * alpha;
|
deform[i] += (setupVertices[i] - deform[i]) * alpha;
|
||||||
} else {
|
} else {
|
||||||
// Weighted deform offsets.
|
// Weighted deform offsets.
|
||||||
alpha = 1 - alpha;
|
alpha = 1 - alpha;
|
||||||
for (size_t i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
deformInner[i] *= alpha;
|
deform[i] *= alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case MixBlend_Replace:
|
case MixBlend_Replace:
|
||||||
case MixBlend_Add:
|
case MixBlend_Add: {}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
deformArray.setSize(vertexCount, 0);
|
deformArray.setSize(vertexCount, 0);
|
||||||
|
|||||||
@ -99,7 +99,9 @@ void Slot::setAttachment(Attachment *inValue) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inValue && _attachment) {
|
if (!inValue || !_attachment) {
|
||||||
|
_deform.clear();
|
||||||
|
} else {
|
||||||
if (!(inValue->getRTTI().instanceOf(VertexAttachment::rtti)) ||
|
if (!(inValue->getRTTI().instanceOf(VertexAttachment::rtti)) ||
|
||||||
!(_attachment->getRTTI().instanceOf(VertexAttachment::rtti)) ||
|
!(_attachment->getRTTI().instanceOf(VertexAttachment::rtti)) ||
|
||||||
(static_cast<VertexAttachment *>(inValue)->getDeformAttachment() !=
|
(static_cast<VertexAttachment *>(inValue)->getDeformAttachment() !=
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user