修复 moc3 (Cubism 3/4/5) 模型姿势抽搐:拖拽平滑化 + SDK 式参数快照 + 动作淡入缺省对齐 SDK - #6
Closed
thomasjjjjkooo-ops wants to merge 2 commits into
Closed
修复 moc3 (Cubism 3/4/5) 模型姿势抽搐:拖拽平滑化 + SDK 式参数快照 + 动作淡入缺省对齐 SDK#6thomasjjjjkooo-ops wants to merge 2 commits into
thomasjjjjkooo-ops wants to merge 2 commits into
Conversation
# Conflicts: # live2d_moc3_embed.lua # live2d_moc3_pet_embed.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
宿主应用中使用 Cubism 3/4/5 (moc3) 模型时,头部跟踪目标一旦变化(看向鼠标/注视点切换),整个模型(头、身体、裙摆、腿部)会在两个姿势之间瞬间跳变("抽搐");循环播放的 idle 动作在每次循环回绕时也会从结尾关键帧硬切回开头关键帧。Cubism 2 路径没有此问题。
根因(三处,相互叠加)
live2d_moc3_pet_embed.lua的drag()把 ParamAngleX/Y、ParamEyeBallX/Y 瞬时写成持久 parameter override —— 目标一变就是单帧硬切;且 override 永久压住动作曲线,idle 动作的头部摆动被完全冻结。Cubism 2 框架的拖拽管理器是平滑趋近的,所以只有 moc3 会抽。MotionPlayer在 motion3.json 缺省 Fade 时把淡入/淡出当 0(Cubism SDK 默认是 1.0s),且忽略 model3.json 动作引用级的 FadeInTime/FadeOutTime —— 循环回绕时没有重新淡入,直接硬切。修改
live2d_moc3_pet_embed.lua:drag 改为记录目标 + 按 0.1s 半衰期平滑趋近,经新增的pre_override_hook以叠加方式作用在动作数值之上(标准 Cubism 更新顺序);宿主set_parameter(口型同步等)改为每帧瞬态写入,不再用持久 override;内联compute_delta_seconds。live2d_moc3_embed.lua:update()增加参数快照 保存/恢复(对应 SDK SaveParameters/LoadParameters);start_motion支持 model3.json 引用级 Fade 覆盖;新增可选pre_override_hook(默认 nil,行为不变)。live2d/cubism3/motion.lua:Fade 在构造时解析,缺省 1.0s(对齐 SDK)。live2d/cubism3/runtime.lua:新增save_parameter_snapshot/load_parameter_snapshot。验证
无头测试(Hiyori,120fps,跟踪目标每 250ms 在左右极值间交替——实际抽搐场景的最坏情况):
tests/live2d_moc3_embed_test.lua:28/28 通过🤖 Generated with Claude Code