[cpp] Fix sequence timeline not setting renderer object correctly., formatting

This commit is contained in:
Mario Zechner 2021-12-22 15:30:21 +01:00
parent 1cba329685
commit 1976a3e6ca
3 changed files with 9 additions and 6 deletions

View File

@ -66,6 +66,7 @@ void Sequence::apply(Slot *slot, Attachment *attachment) {
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) { if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
RegionAttachment *regionAttachment = static_cast<RegionAttachment *>(attachment); RegionAttachment *regionAttachment = static_cast<RegionAttachment *>(attachment);
if (regionAttachment->getRegion() != region) { if (regionAttachment->getRegion() != region) {
regionAttachment->setRendererObject(region);
regionAttachment->setRegion(region); regionAttachment->setRegion(region);
regionAttachment->updateRegion(); regionAttachment->updateRegion();
} }
@ -74,6 +75,7 @@ void Sequence::apply(Slot *slot, Attachment *attachment) {
if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) { if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
MeshAttachment *meshAttachment = static_cast<MeshAttachment *>(attachment); MeshAttachment *meshAttachment = static_cast<MeshAttachment *>(attachment);
if (meshAttachment->getRegion() != region) { if (meshAttachment->getRegion() != region) {
meshAttachment->setRendererObject(region);
meshAttachment->setRegion(region); meshAttachment->setRegion(region);
meshAttachment->updateRegion(); meshAttachment->updateRegion();
} }

View File

@ -728,7 +728,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
return NULL; return NULL;
} }
linkedMesh->_mesh->_timelineAttachment = linkedMesh->_inheritTimeline ? static_cast<VertexAttachment *>(parent) linkedMesh->_mesh->_timelineAttachment = linkedMesh->_inheritTimeline ? static_cast<VertexAttachment *>(parent)
: linkedMesh->_mesh; : linkedMesh->_mesh;
linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent)); linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent));
if (linkedMesh->_mesh->_region != NULL) linkedMesh->_mesh->updateRegion(); if (linkedMesh->_mesh->_region != NULL) linkedMesh->_mesh->updateRegion();
_attachmentLoader->configureAttachment(linkedMesh->_mesh); _attachmentLoader->configureAttachment(linkedMesh->_mesh);
@ -1279,8 +1279,8 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
Vector<float> &verts = vertexAttachment->_vertices; Vector<float> &verts = vertexAttachment->_vertices;
int deformLength = weighted ? verts.size() / 3 * 2 : verts.size(); int deformLength = weighted ? verts.size() / 3 * 2 : verts.size();
DeformTimeline *timeline = new(__FILE__, __LINE__) DeformTimeline(frames, DeformTimeline *timeline = new (__FILE__, __LINE__) DeformTimeline(frames,
frames, slotIndex,vertexAttachment); frames, slotIndex, vertexAttachment);
float time = Json::getFloat(keyMap, "time", 0); float time = Json::getFloat(keyMap, "time", 0);
for (frame = 0, bezier = 0;; frame++) { for (frame = 0, bezier = 0;; frame++) {
Json *vertices = Json::getItem(keyMap, "vertices"); Json *vertices = Json::getItem(keyMap, "vertices");
@ -1331,7 +1331,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
float lastDelay = 0; float lastDelay = 0;
for (frame = 0; keyMap != NULL; keyMap = keyMap->_next, frame++) { for (frame = 0; keyMap != NULL; keyMap = keyMap->_next, frame++) {
float delay = Json::getFloat(keyMap, "delay", lastDelay); float delay = Json::getFloat(keyMap, "delay", lastDelay);
float time = Json::getFloat(keyMap, "time", 0); float time = Json::getFloat(keyMap, "time", 0);
String modeString = Json::getString(keyMap, "mode", "hold"); String modeString = Json::getString(keyMap, "mode", "hold");
int index = Json::getInt(keyMap, "index", 0); int index = Json::getInt(keyMap, "index", 0);
SequenceMode mode = SequenceMode::hold; SequenceMode mode = SequenceMode::hold;
@ -1343,6 +1343,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
if (modeString == "pingpongReverse") mode = SequenceMode::pingpongReverse; if (modeString == "pingpongReverse") mode = SequenceMode::pingpongReverse;
timeline->setFrame(frame, time, mode, index, delay); timeline->setFrame(frame, time, mode, index, delay);
} }
timelines.add(timeline);
} }
} }
} }

View File

@ -645,13 +645,13 @@ int main() {
SpineExtension::setInstance(&dbgExtension); SpineExtension::setInstance(&dbgExtension);
testcase(dragon, "data/dragon-ess.json", "data/dragon-ess.skel", "data/dragon-pma.atlas", 0.6f); testcase(dragon, "data/dragon-ess.json", "data/dragon-ess.skel", "data/dragon-pma.atlas", 0.6f);
testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine-pma.atlas", 0.5f);
testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl-pma.atlas", 0.5f);
testcase(ikDemo, "data/spineboy-pro.json", "data/spineboy-pro.skel", "data/spineboy-pma.atlas", 0.6f); testcase(ikDemo, "data/spineboy-pro.json", "data/spineboy-pro.skel", "data/spineboy-pma.atlas", 0.6f);
testcase(mixAndMatch, "data/mix-and-match-pro.json", "data/mix-and-match-pro.skel", "data/mix-and-match-pma.atlas", 0.5f); testcase(mixAndMatch, "data/mix-and-match-pro.json", "data/mix-and-match-pro.skel", "data/mix-and-match-pma.atlas", 0.5f);
testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin-pma.atlas", 0.5f); testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin-pma.atlas", 0.5f);
testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl-pma.atlas", 0.5f);
testcase(spineboy, "data/spineboy-pro.json", "data/spineboy-pro.skel", "data/spineboy-pma.atlas", 0.6f); testcase(spineboy, "data/spineboy-pro.json", "data/spineboy-pro.skel", "data/spineboy-pma.atlas", 0.6f);
testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor-pma.atlas", 0.5f); testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor-pma.atlas", 0.5f);
testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine-pma.atlas", 0.5f);
testcase(tank, "data/tank-pro.json", "data/tank-pro.skel", "data/tank-pma.atlas", 0.2f); testcase(tank, "data/tank-pro.json", "data/tank-pro.skel", "data/tank-pma.atlas", 0.2f);
testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor-pma.atlas", 0.5f); testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor-pma.atlas", 0.5f);
testcase(goblins, "data/goblins-pro.json", "data/goblins-pro.skel", "data/goblins-pma.atlas", 1.4f); testcase(goblins, "data/goblins-pro.json", "data/goblins-pro.skel", "data/goblins-pma.atlas", 1.4f);