Fix spine RotateTimeline

This commit is contained in:
halx99 2022-11-03 18:00:48 +08:00
parent a657ba7585
commit e39d3de685
2 changed files with 4 additions and 35 deletions

View File

@ -98,37 +98,7 @@ void SkeletonRenderer::initialize () {
_skeleton->updateWorldTransform(); _skeleton->updateWorldTransform();
} }
void SkeletonRenderer::setupGLProgramState (bool twoColorTintEnabled) { 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<RegionAttachment*>(attachment);
texture = static_cast<AttachmentVertices*>(regionAttachment->getRendererObject())->_texture;
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
MeshAttachment* meshAttachment = static_cast<MeshAttachment*>(attachment);
texture = static_cast<AttachmentVertices*>(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::setSkeletonData (SkeletonData *skeletonData, bool ownsSkeletonData) { void SkeletonRenderer::setSkeletonData (SkeletonData *skeletonData, bool ownsSkeletonData) {
_skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData); _skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData);

View File

@ -67,7 +67,7 @@ void RotateTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
} }
case MixBlend_First: { case MixBlend_First: {
float r = bone->_data._rotation - bone->_rotation; float r = bone->_data._rotation - bone->_rotation;
bone->_rotation += (r - (16384 - (int) (16384.499999999996 - r / 360)) * 360) * alpha; bone->_rotation += r * alpha;
break; break;
} }
default: { default: {
@ -87,7 +87,6 @@ void RotateTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
case MixBlend_First: case MixBlend_First:
case MixBlend_Replace: case MixBlend_Replace:
r += bone->_data._rotation - bone->_rotation; r += bone->_data._rotation - bone->_rotation;
r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360;
// Fall through. // Fall through.
case MixBlend_Add: case MixBlend_Add:
bone->_rotation += r * alpha; 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; r = prevRotation + (r - (16384 - (int)(16384.499999999996 - r / 360)) * 360) * percent;
switch (blend) { switch (blend) {
case MixBlend_Setup: 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; break;
case MixBlend_First: case MixBlend_First:
case MixBlend_Replace: case MixBlend_Replace:
r += bone->_data._rotation - bone->_rotation; r += bone->_data._rotation - bone->_rotation;
// Fall through. // Fall through.
case MixBlend_Add: case MixBlend_Add:
bone->_rotation += (r - (16384 - (int)(16384.499999999996 - r / 360)) * 360) * alpha; bone->_rotation += r * alpha; // don't needs mod degree again
} }
} }