mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-07 00:45:34 +00:00
Merge branch 'minor_aicombat' into 'master'
Minor optimization in aicombat.cpp See merge request OpenMW/openmw!737 (cherry picked from commit f1d19035cccfff2523faad0d4e4d96cd3ddae2e6) bbbfc520 Minor optimization in aicombat.cpp 237b34a6 Fix style a14911cb Fix indentation
This commit is contained in:
parent
add04a4ea0
commit
dca628de0f
1 changed files with 10 additions and 8 deletions
|
@ -715,16 +715,18 @@ osg::Vec3f AimDirToMovingTarget(const MWWorld::Ptr& actor, const MWWorld::Ptr& t
|
|||
float t_collision;
|
||||
|
||||
float projVelDirSquared = projSpeed * projSpeed - velPerp * velPerp;
|
||||
|
||||
osg::Vec3f vTargetMoveDirNormalized = vTargetMoveDir;
|
||||
vTargetMoveDirNormalized.normalize();
|
||||
|
||||
float projDistDiff = vDirToTarget * vTargetMoveDirNormalized; // dot product
|
||||
projDistDiff = std::sqrt(distToTarget * distToTarget - projDistDiff * projDistDiff);
|
||||
|
||||
if (projVelDirSquared > 0)
|
||||
{
|
||||
osg::Vec3f vTargetMoveDirNormalized = vTargetMoveDir;
|
||||
vTargetMoveDirNormalized.normalize();
|
||||
|
||||
float projDistDiff = vDirToTarget * vTargetMoveDirNormalized; // dot product
|
||||
projDistDiff = std::sqrt(distToTarget * distToTarget - projDistDiff * projDistDiff);
|
||||
|
||||
t_collision = projDistDiff / (std::sqrt(projVelDirSquared) - velDir);
|
||||
else t_collision = 0; // speed of projectile is not enough to reach moving target
|
||||
}
|
||||
else
|
||||
t_collision = 0; // speed of projectile is not enough to reach moving target
|
||||
|
||||
return vDirToTarget + vTargetMoveDir * t_collision;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue