From 904b245d30df0a7895af913ac79a656703274f24 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Fri, 22 May 2020 14:26:02 +0300 Subject: [PATCH] Re-enable non-biped creature headtracking (bug #5424) --- CHANGELOG.md | 1 + apps/openmw/mwrender/animation.cpp | 43 ++++++++++++++---------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 138ef1707..3fc9e827c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Bug #5400: Editor: Verifier checks race of non-skin bodyparts Bug #5415: Environment maps in ebony cuirass and HiRez Armors Indoril cuirass don't work Bug #5416: Junk non-node records before the root node are not handled gracefully + Bug #5424: Creatures do not headtrack player Feature #5362: Show the soul gems' trapped soul in count dialog 0.46.0 diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index df2000221..8f8e8c233 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -1815,33 +1815,30 @@ namespace MWRender { mHeadController = nullptr; - if (mPtr.getClass().isBipedal(mPtr)) - { - NodeMap::const_iterator found = getNodeMap().find("bip01 head"); - if (found != getNodeMap().end()) - { - osg::MatrixTransform* node = found->second; + NodeMap::const_iterator found = getNodeMap().find("bip01 head"); + if (found == getNodeMap().end()) + return; - bool foundKeyframeCtrl = false; - osg::Callback* cb = node->getUpdateCallback(); - while (cb) - { - if (dynamic_cast(cb)) - { - foundKeyframeCtrl = true; - break; - } - cb = cb->getNestedCallback(); - } + osg::MatrixTransform* node = found->second; - if (foundKeyframeCtrl) - { - mHeadController = new RotateController(mObjectRoot.get()); - node->addUpdateCallback(mHeadController); - mActiveControllers.emplace_back(node, mHeadController); - } + bool foundKeyframeCtrl = false; + osg::Callback* cb = node->getUpdateCallback(); + while (cb) + { + if (dynamic_cast(cb)) + { + foundKeyframeCtrl = true; + break; } + cb = cb->getNestedCallback(); } + + if (!foundKeyframeCtrl) + return; + + mHeadController = new RotateController(mObjectRoot.get()); + node->addUpdateCallback(mHeadController); + mActiveControllers.emplace_back(node, mHeadController); } void Animation::setHeadPitch(float pitchRadians)