[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:
Mario Zechner 2021-09-14 01:57:24 +02:00
parent c41cc94008
commit eedaccc418
2 changed files with 8 additions and 6 deletions

View File

@ -100,23 +100,23 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
return;
}
deformArray.setSize(vertexCount, 0);
Vector<float> &deformInner = deformArray;
Vector<float> &deform = deformArray;
if (attachment->getBones().size() == 0) {
// Unweighted vertex positions.
Vector<float> &setupVertices = attachment->getVertices();
for (size_t i = 0; i < vertexCount; i++)
deformInner[i] += (setupVertices[i] - deformInner[i]) * alpha;
deform[i] += (setupVertices[i] - deform[i]) * alpha;
} else {
// Weighted deform offsets.
alpha = 1 - alpha;
for (size_t i = 0; i < vertexCount; i++)
deformInner[i] *= alpha;
deform[i] *= alpha;
}
}
case MixBlend_Replace:
case MixBlend_Add:
return;
case MixBlend_Add: {}
}
return;
}
deformArray.setSize(vertexCount, 0);

View File

@ -99,7 +99,9 @@ void Slot::setAttachment(Attachment *inValue) {
return;
}
if (inValue && _attachment) {
if (!inValue || !_attachment) {
_deform.clear();
} else {
if (!(inValue->getRTTI().instanceOf(VertexAttachment::rtti)) ||
!(_attachment->getRTTI().instanceOf(VertexAttachment::rtti)) ||
(static_cast<VertexAttachment *>(inValue)->getDeformAttachment() !=