create constant and use constant in other parts of the code base

pull/3058/head
Max 4 years ago
parent e56efdd562
commit 2cd96e56d5

@ -131,6 +131,7 @@ Programmers
Martin Otto (MAtahualpa)
Mateusz Kołaczek (PL_kolek)
Mateusz Malisz (malice)
Max Henzerling (SaintMercury)
megaton
Michael Hogan (Xethik)
Michael Mc Donnell

@ -88,6 +88,7 @@
Bug #5656: Sneaking characters block hits while standing
Bug #5661: Region sounds don't play at the right interval
Bug #5675: OpenMW-cs. FRMR subrecords are saved with the wrong MastIdx
Bug #5680: Enemy AI incorrectly aims projectiles
Bug #5681: Player character can clip or pass through bridges instead of colliding against them
Bug #5687: Bound items covering the same inventory slot expiring at the same time freezes the game
Bug #5688: Water shader broken indoors with enable indoor shadows = false

@ -1,5 +1,7 @@
#include "aicast.hpp"
#include <components/misc/constants.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/world.hpp"
@ -54,12 +56,12 @@ bool MWMechanics::AiCast::execute(const MWWorld::Ptr& actor, MWMechanics::Charac
if (target != actor && target.getClass().isActor())
{
osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getHalfExtents(target);
targetPos.z() += halfExtents.z() * 2 * 0.75f;
targetPos.z() += halfExtents.z() * 2 * Constants::TorsoHeight;
}
osg::Vec3f actorPos = actor.getRefData().getPosition().asVec3();
osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getHalfExtents(actor);
actorPos.z() += halfExtents.z() * 2 * 0.75f;
actorPos.z() += halfExtents.z() * 2 * Constants::TorsoHeight;
osg::Vec3f dir = targetPos - actorPos;

@ -265,9 +265,8 @@ namespace MWWorld
osg::Vec3f pos = caster.getRefData().getPosition().asVec3();
if (caster.getClass().isActor())
{
// Spawn at 0.75 * ActorHeight
// Note: we ignore the collision box offset, this is required to make some flying creatures work as intended.
pos.z() += mPhysics->getRenderingHalfExtents(caster).z() * 2 * 0.75;
pos.z() += mPhysics->getRenderingHalfExtents(caster).z() * 2 * Constants::TorsoHeight;
}
if (MWBase::Environment::get().getWorld()->isUnderwater(caster.getCell(), pos)) // Underwater casting not possible

@ -3873,7 +3873,7 @@ namespace MWWorld
osg::Vec3f weaponHalfExtents = mPhysics->getHalfExtents(actor);
osg::Vec3f targetPos = target.getRefData().getPosition().asVec3();
osg::Vec3f targetHalfExtents = mPhysics->getHalfExtents(target);
weaponPos.z() += weaponHalfExtents.z() * 2 * 0.75; // projectilemanager.cpp spawns bolts at 0.75 actor height
weaponPos.z() += weaponHalfExtents.z() * 2 * Constants::TorsoHeight;
targetPos.z() += targetHalfExtents.z();
return (targetPos - weaponPos);
}

@ -33,6 +33,9 @@ const std::string NightDayLabel = "NightDaySwitch";
// A label to mark visual switches for herbalism feature
const std::string HerbalismLabel = "HerbalismSwitch";
// Percentage height at which projectiles are spawned from an actor
const float TorsoHeight = 0.75f;
}
#endif

Loading…
Cancel
Save