mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-02 13:36:42 +00:00
Use default hit formula as fallback
This commit is contained in:
parent
9e5d577a71
commit
4666a6a0ab
1 changed files with 18 additions and 11 deletions
|
@ -1073,22 +1073,29 @@ namespace MWWorld
|
||||||
|
|
||||||
osg::Quat rot = osg::Quat(posdata.rot[0], osg::Vec3f(-1,0,0)) * osg::Quat(posdata.rot[2], osg::Vec3f(0,0,-1));
|
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 = ptr.getRefData().getPosition().asVec3();
|
|
||||||
osg::Vec3f halfExtents = mPhysics->getHalfExtents(ptr);
|
osg::Vec3f halfExtents = mPhysics->getHalfExtents(ptr);
|
||||||
|
|
||||||
if (ptr == getPlayerPtr())
|
|
||||||
pos = getActorHeadTransform(ptr).getTrans(); // special cased for better aiming with the camera
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// general case, compatible with all types of different creatures
|
|
||||||
// note: we intentionally do *not* use the collision box offset here, this is required to make
|
|
||||||
// some flying creatures work that have their collision box offset in the air
|
|
||||||
pos.z() += halfExtents.z();
|
|
||||||
}
|
|
||||||
|
|
||||||
// the origin of hitbox is an actor's front, not center
|
// the origin of hitbox is an actor's front, not center
|
||||||
distance += halfExtents.y();
|
distance += halfExtents.y();
|
||||||
|
|
||||||
|
// special cased for better aiming with the camera
|
||||||
|
// if we do not hit anything, will use the default approach as fallback
|
||||||
|
if (ptr == getPlayerPtr())
|
||||||
|
{
|
||||||
|
osg::Vec3f pos = getActorHeadTransform(ptr).getTrans();
|
||||||
|
|
||||||
|
std::pair<MWWorld::Ptr,osg::Vec3f> result = mPhysics->getHitContact(ptr, pos, rot, distance, targets);
|
||||||
|
if(!result.first.isEmpty())
|
||||||
|
return std::make_pair(result.first, result.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::Vec3f pos = ptr.getRefData().getPosition().asVec3();
|
||||||
|
|
||||||
|
// general case, compatible with all types of different creatures
|
||||||
|
// note: we intentionally do *not* use the collision box offset here, this is required to make
|
||||||
|
// some flying creatures work that have their collision box offset in the air
|
||||||
|
pos.z() += halfExtents.z();
|
||||||
|
|
||||||
std::pair<MWWorld::Ptr,osg::Vec3f> result = mPhysics->getHitContact(ptr, pos, rot, distance, targets);
|
std::pair<MWWorld::Ptr,osg::Vec3f> result = mPhysics->getHitContact(ptr, pos, rot, distance, targets);
|
||||||
if(result.first.isEmpty())
|
if(result.first.isEmpty())
|
||||||
return std::make_pair(MWWorld::Ptr(), osg::Vec3f());
|
return std::make_pair(MWWorld::Ptr(), osg::Vec3f());
|
||||||
|
|
Loading…
Reference in a new issue