mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 21:49:55 +00:00
Merge branch 'fix_5846' into 'master'
Fix #5846 (headtracking) Closes #5846 See merge request OpenMW/openmw!652
This commit is contained in:
commit
514a55ed4c
1 changed files with 6 additions and 5 deletions
|
@ -2920,8 +2920,8 @@ void CharacterController::updateHeadTracking(float duration)
|
|||
if (!head)
|
||||
return;
|
||||
|
||||
float zAngleRadians = 0.f;
|
||||
float xAngleRadians = 0.f;
|
||||
double zAngleRadians = 0.f;
|
||||
double xAngleRadians = 0.f;
|
||||
|
||||
if (!mHeadTrackTarget.isEmpty())
|
||||
{
|
||||
|
@ -2954,15 +2954,16 @@ void CharacterController::updateHeadTracking(float duration)
|
|||
const osg::Vec3f actorDirection = mPtr.getRefData().getBaseNode()->getAttitude() * osg::Vec3f(0,1,0);
|
||||
|
||||
zAngleRadians = std::atan2(actorDirection.x(), actorDirection.y()) - std::atan2(direction.x(), direction.y());
|
||||
zAngleRadians = Misc::normalizeAngle(zAngleRadians - mAnimation->getHeadYaw()) + mAnimation->getHeadYaw();
|
||||
zAngleRadians *= (1 - direction.z() * direction.z());
|
||||
xAngleRadians = std::asin(direction.z());
|
||||
}
|
||||
|
||||
const double xLimit = osg::DegreesToRadians(40.0);
|
||||
const double zLimit = osg::DegreesToRadians(30.0);
|
||||
double zLimitOffset = mAnimation->getUpperBodyYawRadians();
|
||||
xAngleRadians = osg::clampBetween(Misc::normalizeAngle(xAngleRadians), -xLimit, xLimit);
|
||||
zAngleRadians = osg::clampBetween(Misc::normalizeAngle(zAngleRadians),
|
||||
-zLimit + zLimitOffset, zLimit + zLimitOffset);
|
||||
xAngleRadians = osg::clampBetween(xAngleRadians, -xLimit, xLimit);
|
||||
zAngleRadians = osg::clampBetween(zAngleRadians, -zLimit + zLimitOffset, zLimit + zLimitOffset);
|
||||
|
||||
float factor = duration*5;
|
||||
factor = std::min(factor, 1.f);
|
||||
|
|
Loading…
Reference in a new issue