mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Tune algorithm of "auto switch shoulder"
This commit is contained in:
parent
c72fda7ecc
commit
ca4330f753
@ -89,17 +89,21 @@ namespace MWRender
|
|||||||
MWBase::World* world = MWBase::Environment::get().getWorld();
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||||
osg::Vec3d sideOffset = orient * osg::Vec3d(world->getHalfExtents(mCamera->getTrackingPtr()).x() - 1, 0, 0);
|
osg::Vec3d sideOffset = orient * osg::Vec3d(world->getHalfExtents(mCamera->getTrackingPtr()).x() - 1, 0, 0);
|
||||||
float rayRight = world->getDistToNearestRayHit(
|
float rayRight = world->getDistToNearestRayHit(
|
||||||
playerPos + sideOffset, orient * osg::Vec3d(1, 1, 0), limitToSwitchBack + 1);
|
playerPos + sideOffset, orient * osg::Vec3d(1, 0, 0), limitToSwitchBack + 1);
|
||||||
float rayLeft = world->getDistToNearestRayHit(
|
float rayLeft = world->getDistToNearestRayHit(
|
||||||
playerPos - sideOffset, orient * osg::Vec3d(-1, 1, 0), limitToSwitchBack + 1);
|
playerPos - sideOffset, orient * osg::Vec3d(-1, 0, 0), limitToSwitchBack + 1);
|
||||||
float rayForward = world->getDistToNearestRayHit(
|
float rayRightForward = world->getDistToNearestRayHit(
|
||||||
playerPos, orient * osg::Vec3d(0, 1, 0), limitToSwitchBack + 1);
|
playerPos + sideOffset, orient * osg::Vec3d(1, 3, 0), limitToSwitchBack + 1);
|
||||||
|
float rayLeftForward = world->getDistToNearestRayHit(
|
||||||
|
playerPos - sideOffset, orient * osg::Vec3d(-1, 3, 0), limitToSwitchBack + 1);
|
||||||
|
float distRight = std::min(rayRight, rayRightForward);
|
||||||
|
float distLeft = std::min(rayLeft, rayLeftForward);
|
||||||
|
|
||||||
if (rayLeft < limitToSwitch && rayRight > limitToSwitchBack)
|
if (distLeft < limitToSwitch && distRight > limitToSwitchBack)
|
||||||
mMode = Mode::RightShoulder;
|
mMode = Mode::RightShoulder;
|
||||||
else if (rayRight < limitToSwitch && rayLeft > limitToSwitchBack)
|
else if (distRight < limitToSwitch && distLeft > limitToSwitchBack)
|
||||||
mMode = Mode::LeftShoulder;
|
mMode = Mode::LeftShoulder;
|
||||||
else if (rayLeft > limitToSwitchBack && rayRight > limitToSwitchBack && rayForward > limitToSwitchBack)
|
else if (distRight > limitToSwitchBack && distLeft > limitToSwitchBack)
|
||||||
mMode = mDefaultShoulderIsRight ? Mode::RightShoulder : Mode::LeftShoulder;
|
mMode = mDefaultShoulderIsRight ? Mode::RightShoulder : Mode::LeftShoulder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user