[c][cpp] Port of additive blending fix, see #1322.

This commit is contained in:
badlogic 2019-04-04 14:33:41 +02:00
parent 8f80ceec7c
commit 0e0ed6ef3a
4 changed files with 10 additions and 12 deletions

View File

@ -377,7 +377,7 @@ int spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) {
animationLast = current->animationLast; animationTime = spTrackEntry_getAnimationTime(current);
timelineCount = current->animation->timelinesCount;
timelines = current->animation->timelines;
if (i == 0 && (mix == 1 || blend == SP_MIX_BLEND_ADD)) {
if ((i == 0 && mix == 1) || blend == SP_MIX_BLEND_ADD) {
for (ii = 0; ii < timelineCount; ii++)
spTimeline_apply(timelines[ii], skeleton, animationLast, animationTime, internal->events, &internal->eventsCount, mix, blend, SP_MIX_DIRECTION_IN);
} else {

View File

@ -400,7 +400,7 @@ bool AnimationState::apply(Skeleton &skeleton) {
float animationLast = current._animationLast, animationTime = current.getAnimationTime();
size_t timelineCount = current._animation->_timelines.size();
Vector<Timeline *> &timelines = current._animation->_timelines;
if (i == 0 && (mix == 1 || blend == MixBlend_Add)) {
if ((i == 0 && mix == 1) || blend == MixBlend_Add) {
for (size_t ii = 0; ii < timelineCount; ++ii) {
timelines[ii]->apply(skeleton, animationLast, animationTime, &_events, mix, blend,
MixDirection_In);

View File

@ -384,7 +384,6 @@ void owl (SkeletonData* skeletonData, Atlas* atlas) {
spTrackEntry* down = AnimationState_setAnimationByName(drawable->state, 5, "down", true);
left->alpha = 0;
left->mixBlend = SP_MIX_BLEND_ADD;
right->alpha = 0;
right->mixBlend = SP_MIX_BLEND_ADD;
up->alpha = 0;

View File

@ -398,15 +398,12 @@ void owl (SkeletonData* skeletonData, Atlas* atlas) {
skeleton->setPosition(320, 400);
skeleton->updateWorldTransform();
drawable.state->setAnimation(0, "idle", true);
drawable.state->setAnimation(1, "blink", true);
TrackEntry* left = drawable.state->setAnimation(2, "left", true);
TrackEntry* right = drawable.state->setAnimation(3, "right", true);
TrackEntry* up = drawable.state->setAnimation(4, "up", true);
TrackEntry* down = drawable.state->setAnimation(5, "down", true);
TrackEntry* left = drawable.state->setAnimation(0, "left", true);
TrackEntry* right = drawable.state->setAnimation(1, "right", true);
TrackEntry* up = drawable.state->setAnimation(2, "up", true);
TrackEntry* down = drawable.state->setAnimation(3, "down", true);
left->setAlpha(0);
left->setMixBlend(MixBlend_Add);
right->setAlpha(0);
right->setMixBlend(MixBlend_Add);
up->setAlpha(0);
@ -414,6 +411,9 @@ void owl (SkeletonData* skeletonData, Atlas* atlas) {
down->setAlpha(0);
down->setMixBlend(MixBlend_Add);
drawable.state->setAnimation(4, "idle", true);
drawable.state->setAnimation(5, "blink", true);
sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - owl");
window.setFramerateLimit(60);
sf::Event event;
@ -465,12 +465,11 @@ int main () {
DebugExtension dbgExtension(SpineExtension::getInstance());
SpineExtension::setInstance(&dbgExtension);
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(stretchymanStrechyIk, "data/stretchyman-stretchy-ik-pro.json", "data/stretchyman-stretchy-ik-pro.skel", "data/stretchyman-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(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(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(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor-pma.atlas", 0.5f);