|
|
|
@ -1038,32 +1038,30 @@ namespace MWWorld
|
|
|
|
|
return facedObject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
osg::Vec3f getActorHeadPosition(const MWWorld::Ptr& actor, MWRender::RenderingManager* rendering)
|
|
|
|
|
osg::Matrixf World::getActorHeadTransform(const MWWorld::Ptr& actor) const
|
|
|
|
|
{
|
|
|
|
|
osg::Vec3f origin(actor.getRefData().getPosition().asVec3());
|
|
|
|
|
|
|
|
|
|
MWRender::Animation* anim = rendering->getAnimation(actor);
|
|
|
|
|
if (anim != NULL)
|
|
|
|
|
MWRender::Animation *anim = mRendering->getAnimation(actor);
|
|
|
|
|
if(anim)
|
|
|
|
|
{
|
|
|
|
|
const osg::Node* node = anim->getNode("Head");
|
|
|
|
|
if (node == NULL)
|
|
|
|
|
node = anim->getNode("Bip01 Head");
|
|
|
|
|
if (node != NULL)
|
|
|
|
|
const osg::Node *node = anim->getNode("Head");
|
|
|
|
|
if(!node) node = anim->getNode("Bip01 Head");
|
|
|
|
|
if(node)
|
|
|
|
|
{
|
|
|
|
|
osg::MatrixList mats = node->getWorldMatrices();
|
|
|
|
|
if (mats.size())
|
|
|
|
|
origin = mats[0].getTrans();
|
|
|
|
|
if(!mats.empty())
|
|
|
|
|
return mats[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return origin;
|
|
|
|
|
return osg::Matrixf::translate(actor.getRefData().getPosition().asVec3());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::pair<MWWorld::Ptr,osg::Vec3f> World::getHitContact(const MWWorld::Ptr &ptr, float distance)
|
|
|
|
|
{
|
|
|
|
|
const ESM::Position &posdata = ptr.getRefData().getPosition();
|
|
|
|
|
|
|
|
|
|
osg::Quat rot = osg::Quat(posdata.rot[0], osg::Vec3f(-1,0,0)) * osg::Quat(posdata.rot[2], osg::Vec3f(0,0,-1));
|
|
|
|
|
osg::Vec3f pos = getActorHeadPosition(ptr, mRendering);
|
|
|
|
|
osg::Vec3f pos = getActorHeadTransform(ptr).getTrans();
|
|
|
|
|
|
|
|
|
|
std::pair<MWWorld::Ptr,osg::Vec3f> result = mPhysics->getHitContact(ptr, pos, rot, distance);
|
|
|
|
|
if(result.first.isEmpty())
|
|
|
|
@ -2659,7 +2657,7 @@ namespace MWWorld
|
|
|
|
|
MWWorld::Ptr target;
|
|
|
|
|
float distance = 192.f; // ??
|
|
|
|
|
osg::Vec3f hitPosition = actor.getRefData().getPosition().asVec3();
|
|
|
|
|
osg::Vec3f origin = getActorHeadPosition(actor, mRendering);
|
|
|
|
|
osg::Vec3f origin = getActorHeadTransform(actor).getTrans();
|
|
|
|
|
|
|
|
|
|
osg::Quat orient = osg::Quat(actor.getRefData().getPosition().rot[0], osg::Vec3f(-1,0,0))
|
|
|
|
|
* osg::Quat(actor.getRefData().getPosition().rot[2], osg::Vec3f(0,0,-1));
|
|
|
|
@ -3297,14 +3295,14 @@ namespace MWWorld
|
|
|
|
|
|
|
|
|
|
osg::Vec3f World::aimToTarget(const Ptr &actor, const MWWorld::Ptr& target)
|
|
|
|
|
{
|
|
|
|
|
osg::Vec3f weaponPos = getActorHeadPosition(actor, mRendering);
|
|
|
|
|
osg::Vec3f weaponPos = getActorHeadTransform(actor).getTrans();
|
|
|
|
|
osg::Vec3f targetPos = mPhysics->getPosition(target);
|
|
|
|
|
return (targetPos - weaponPos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float World::getHitDistance(const Ptr &actor, const Ptr &target)
|
|
|
|
|
{
|
|
|
|
|
osg::Vec3f weaponPos = getActorHeadPosition(actor, mRendering);
|
|
|
|
|
osg::Vec3f weaponPos = getActorHeadTransform(actor).getTrans();
|
|
|
|
|
return mPhysics->getHitDistance(weaponPos, target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|