1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 07:53:53 +00:00

Normalize fixes

This commit is contained in:
scrawl 2015-06-05 03:41:10 +02:00
parent 1fd48e6f81
commit 4c09ecef72
3 changed files with 6 additions and 3 deletions

View file

@ -855,7 +855,8 @@ void CharacterController::updateIdleStormState()
{
osg::Vec3f stormDirection = MWBase::Environment::get().getWorld()->getStormDirection();
osg::Vec3f characterDirection = mPtr.getRefData().getBaseNode()->getAttitude() * osg::Vec3f(0,1,0);
inStormDirection = std::acos(stormDirection * characterDirection) > osg::DegreesToRadians(120.f);
inStormDirection = std::acos(stormDirection * characterDirection / (stormDirection.length() * characterDirection.length()))
> osg::DegreesToRadians(120.f);
}
if (inStormDirection && mUpperBodyState == UpperCharState_Nothing && mAnimation->hasAnimation("idlestorm"))
{

View file

@ -1388,7 +1388,9 @@ namespace MWMechanics
osg::Vec3f vec = pos1 - pos2;
if (observer.getRefData().getBaseNode())
{
float angleRadians = std::acos((observer.getRefData().getBaseNode()->getAttitude() * osg::Vec3f(0,1,0)) * vec);
osg::Vec3f observerDir = (observer.getRefData().getBaseNode()->getAttitude() * osg::Vec3f(0,1,0));
float angleRadians = std::acos(observerDir * vec / (observerDir.length() * vec.length()));
if (angleRadians < osg::DegreesToRadians(90.f))
y = obsTerm * observerStats.getFatigueTerm() * fSneakNoViewMult;
else

View file

@ -1827,7 +1827,7 @@ namespace MWWorld
if (result.mHit)
{
// check if the wanted position is on a flat surface, and not e.g. against a vertical wall
if (std::acos(result.mHitNormalWorld * osg::Vec3f(0,0,1)) >= osg::DegreesToRadians(30.f))
if (std::acos((result.mHitNormalWorld/result.mHitNormalWorld.length()) * osg::Vec3f(0,0,1)) >= osg::DegreesToRadians(30.f))
return false;
return true;