mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-23 03:47:34 -04:00
Increase hit distance for player by halfExtents
This commit is contained in:
parent
fb3facde54
commit
ab433102a4
@ -1074,6 +1074,7 @@ 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 pos = ptr.getRefData().getPosition().asVec3();
|
||||||
|
osg::Vec3f halfExtents = mPhysics->getHalfExtents(ptr);
|
||||||
|
|
||||||
if (ptr == getPlayerPtr())
|
if (ptr == getPlayerPtr())
|
||||||
pos = getActorHeadTransform(ptr).getTrans(); // special cased for better aiming with the camera
|
pos = getActorHeadTransform(ptr).getTrans(); // special cased for better aiming with the camera
|
||||||
@ -1082,11 +1083,12 @@ namespace MWWorld
|
|||||||
// general case, compatible with all types of different creatures
|
// 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
|
// 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
|
// some flying creatures work that have their collision box offset in the air
|
||||||
osg::Vec3f halfExtents = mPhysics->getHalfExtents(ptr);
|
|
||||||
pos.z() += halfExtents.z() * 2 * 0.75;
|
pos.z() += halfExtents.z() * 2 * 0.75;
|
||||||
distance += halfExtents.y();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the origin of hitbox is an actor's front, not center
|
||||||
|
distance += halfExtents.y();
|
||||||
|
|
||||||
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…
x
Reference in New Issue
Block a user