From 1b9b61b60b715d3991bbfabbf83dc5ad4cfac71a Mon Sep 17 00:00:00 2001 From: elsid Date: Tue, 27 Sep 2022 00:46:34 +0200 Subject: [PATCH 1/2] Format navmesh water vertices and indices --- components/detournavigator/makenavmesh.cpp | 24 ++++++---------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/components/detournavigator/makenavmesh.cpp b/components/detournavigator/makenavmesh.cpp index b9cd9b26d3..30fdb21ef3 100644 --- a/components/detournavigator/makenavmesh.cpp +++ b/components/detournavigator/makenavmesh.cpp @@ -188,27 +188,15 @@ namespace DetourNavigator const RecastParams& params, rcHeightfield& solid) { const std::array vertices{ - rectangle.mBounds.mMin.x(), - rectangle.mHeight, - rectangle.mBounds.mMin.y(), - rectangle.mBounds.mMin.x(), - rectangle.mHeight, - rectangle.mBounds.mMax.y(), - rectangle.mBounds.mMax.x(), - rectangle.mHeight, - rectangle.mBounds.mMax.y(), - rectangle.mBounds.mMax.x(), - rectangle.mHeight, - rectangle.mBounds.mMin.y(), + rectangle.mBounds.mMin.x(), rectangle.mHeight, rectangle.mBounds.mMin.y(), // vertex 0 + rectangle.mBounds.mMin.x(), rectangle.mHeight, rectangle.mBounds.mMax.y(), // vertex 1 + rectangle.mBounds.mMax.x(), rectangle.mHeight, rectangle.mBounds.mMax.y(), // vertex 2 + rectangle.mBounds.mMax.x(), rectangle.mHeight, rectangle.mBounds.mMin.y(), // vertex 3 }; const std::array indices{ - 0, - 1, - 2, - 0, - 2, - 3, + 0, 1, 2, // triangle 0 + 0, 2, 3, // triangle 1 }; const std::array areas{ areaType, areaType }; From b92d80249edaf7e45a19564f7ecea55856c44160 Mon Sep 17 00:00:00 2001 From: elsid Date: Tue, 27 Sep 2022 01:01:42 +0200 Subject: [PATCH 2/2] Adjust initial distance when destination is changed for obstacle check Changed destination may create a situation when the distance actor moved between 2 update calls is less than initial distance because destination has been changed. This forces actor to take evasive action when there is no actual obstacle. --- CHANGELOG.md | 1 + apps/openmw/mwmechanics/obstacle.cpp | 7 +++++++ apps/openmw/mwmechanics/obstacle.hpp | 1 + 3 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d3d2988ad..1276a449f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -170,6 +170,7 @@ Bug #6794: Light sources are attached to mesh bounds centers instead of mesh origins when AttachLight NiNode is missing Bug #6799: Game crashes if an NPC has no Class attached Bug #6849: ImageButton texture is not scaled properly + Bug #6860: Sinnammu randomly strafes while running on water Bug #6869: Hits queue stagger during swing animation Bug #6890: SDL_PeepEvents errors are not handled Bug #6895: Removing a negative number of items from a script, makes the script terminate with an error diff --git a/apps/openmw/mwmechanics/obstacle.cpp b/apps/openmw/mwmechanics/obstacle.cpp index 0b59782992..a17703a642 100644 --- a/apps/openmw/mwmechanics/obstacle.cpp +++ b/apps/openmw/mwmechanics/obstacle.cpp @@ -139,11 +139,18 @@ namespace MWMechanics mStateDuration = 0; mPrev = position; mInitialDistance = (destination - position).length(); + mDestination = destination; return; } if (mWalkState != WalkState::Evade) { + if (mDestination != destination) + { + mInitialDistance = (destination - mPrev).length(); + mDestination = destination; + } + const float distSameSpot = DIST_SAME_SPOT * actor.getClass().getCurrentSpeed(actor) * duration; const float prevDistance = (destination - mPrev).length(); const float currentDistance = (destination - position).length(); diff --git a/apps/openmw/mwmechanics/obstacle.hpp b/apps/openmw/mwmechanics/obstacle.hpp index bb11a9d611..be9680f527 100644 --- a/apps/openmw/mwmechanics/obstacle.hpp +++ b/apps/openmw/mwmechanics/obstacle.hpp @@ -45,6 +45,7 @@ namespace MWMechanics private: osg::Vec3f mPrev; + osg::Vec3f mDestination; // directions to try moving in when get stuck static const float evadeDirections[NUM_EVADE_DIRECTIONS][2];