From e39d3de685331a089e0dfa29955a17837c89ce2a Mon Sep 17 00:00:00 2001 From: halx99 Date: Thu, 3 Nov 2022 18:00:48 +0800 Subject: [PATCH] Fix spine RotateTimeline --- extensions/spine/SkeletonRenderer.cpp | 32 +------------------ .../runtime/src/spine/RotateTimeline.cpp | 7 ++-- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/extensions/spine/SkeletonRenderer.cpp b/extensions/spine/SkeletonRenderer.cpp index fb5b2f4478..81a2cfc7f2 100644 --- a/extensions/spine/SkeletonRenderer.cpp +++ b/extensions/spine/SkeletonRenderer.cpp @@ -98,37 +98,7 @@ void SkeletonRenderer::initialize () { _skeleton->updateWorldTransform(); } -void SkeletonRenderer::setupGLProgramState (bool twoColorTintEnabled) { - if (twoColorTintEnabled) { -#if COCOS2D_VERSION < 0x00040000 - setGLProgramState(SkeletonTwoColorBatch::getInstance()->getTwoColorTintProgramState()); -#endif - return; - } - - Texture2D *texture = nullptr; - for (int i = 0, n = _skeleton->getSlots().size(); i < n; i++) { - Slot* slot = _skeleton->getDrawOrder()[i]; - Attachment* const attachment = slot->getAttachment(); - if (!attachment) continue; - if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) { - RegionAttachment* regionAttachment = static_cast(attachment); - texture = static_cast(regionAttachment->getRendererObject())->_texture; - } else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) { - MeshAttachment* meshAttachment = static_cast(attachment); - texture = static_cast(meshAttachment->getRendererObject())->_texture; - } else { - continue; - } - - if (texture != nullptr) { - break; - } - } -#if COCOS2D_VERSION < 0x00040000 - setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, texture)); -#endif -} +void SkeletonRenderer::setupGLProgramState (bool /*twoColorTintEnabled*/) {} void SkeletonRenderer::setSkeletonData (SkeletonData *skeletonData, bool ownsSkeletonData) { _skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData); diff --git a/extensions/spine/runtime/src/spine/RotateTimeline.cpp b/extensions/spine/runtime/src/spine/RotateTimeline.cpp index 0373639174..ef86ee2a5f 100644 --- a/extensions/spine/runtime/src/spine/RotateTimeline.cpp +++ b/extensions/spine/runtime/src/spine/RotateTimeline.cpp @@ -67,7 +67,7 @@ void RotateTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto } case MixBlend_First: { float r = bone->_data._rotation - bone->_rotation; - bone->_rotation += (r - (16384 - (int) (16384.499999999996 - r / 360)) * 360) * alpha; + bone->_rotation += r * alpha; break; } default: { @@ -87,7 +87,6 @@ void RotateTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto case MixBlend_First: case MixBlend_Replace: r += bone->_data._rotation - bone->_rotation; - r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360; // Fall through. case MixBlend_Add: bone->_rotation += r * alpha; @@ -105,14 +104,14 @@ void RotateTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto r = prevRotation + (r - (16384 - (int)(16384.499999999996 - r / 360)) * 360) * percent; switch (blend) { case MixBlend_Setup: - bone->_rotation = bone->_data._rotation + (r - (16384 - (int)(16384.499999999996 - r / 360)) * 360) * alpha; + bone->_rotation = bone->_data._rotation + r * alpha; break; case MixBlend_First: case MixBlend_Replace: r += bone->_data._rotation - bone->_rotation; // Fall through. case MixBlend_Add: - bone->_rotation += (r - (16384 - (int)(16384.499999999996 - r / 360)) * 360) * alpha; + bone->_rotation += r * alpha; // don't needs mod degree again } }