From 4ccc47161c8cf66d553dbe190fe7b3ae9df05d47 Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Fri, 13 Aug 2021 15:55:06 +0200 Subject: [PATCH] Add an AvoidCollisionWithLookAt curve Same path as AvoidCollision, but with lookat rotation instead of slerp. Useful (needed) for some cases in the interactive installations, but should be replaced later on as it leads to fast rotations --- include/openspace/navigation/path.h | 8 +++++++- src/navigation/path.cpp | 2 ++ src/navigation/pathnavigator.cpp | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/openspace/navigation/path.h b/include/openspace/navigation/path.h index 015b77a966..d3060e5c09 100644 --- a/include/openspace/navigation/path.h +++ b/include/openspace/navigation/path.h @@ -42,7 +42,13 @@ public: enum CurveType { AvoidCollision, Linear, - ZoomOutOverview + ZoomOutOverview, + AvoidCollisionWithLookAt // @TODO (2021-08-13, emmbr) This type right now leads + // to rapid rotations, but is useful in specific + // scenarios, e.g. close to surfaces. Later we want to + // remove it, and create a curve type that looks nicely + // at the targets when moving, avoids collisions and + // doesn't introduce sudden large changes in rotation }; Path(Waypoint start, Waypoint end, CurveType type, diff --git a/src/navigation/path.cpp b/src/navigation/path.cpp index 57e762077a..ffe3ddc8a2 100644 --- a/src/navigation/path.cpp +++ b/src/navigation/path.cpp @@ -93,6 +93,7 @@ Path::Path(Waypoint start, Waypoint end, CurveType type, { switch (_curveType) { case CurveType::AvoidCollision: + case CurveType::AvoidCollisionWithLookAt: _curve = std::make_unique(_start, _end); break; case CurveType::Linear: @@ -174,6 +175,7 @@ glm::dquat Path::interpolateRotation(double t) const { case CurveType::Linear: return easedSlerpRotation(t); case CurveType::ZoomOutOverview: + case CurveType::AvoidCollisionWithLookAt: return lookAtTargetsRotation(t); default: throw ghoul::MissingCaseException(); diff --git a/src/navigation/pathnavigator.cpp b/src/navigation/pathnavigator.cpp index 44be9d153b..faa1ef0793 100644 --- a/src/navigation/pathnavigator.cpp +++ b/src/navigation/pathnavigator.cpp @@ -105,7 +105,8 @@ PathNavigator::PathNavigator() _defaultCurveOption.addOptions({ { Path::CurveType::AvoidCollision, "AvoidCollision" }, { Path::CurveType::Linear, "Linear" }, - { Path::CurveType::ZoomOutOverview, "ZoomOutOverview"} + { Path::CurveType::ZoomOutOverview, "ZoomOutOverview"}, + { Path::CurveType::AvoidCollisionWithLookAt, "AvoidCollisionWithLookAt"} }); addProperty(_defaultCurveOption);