mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 12:59:07 -06:00
Keep track of aim from navigations state when creating a camera path (#2981)
This commit is contained in:
@@ -47,6 +47,7 @@ public:
|
||||
glm::dquat rotation() const;
|
||||
SceneGraphNode* node() const;
|
||||
std::string nodeIdentifier() const;
|
||||
std::optional<std::string> aimIdentifier() const;
|
||||
double validBoundingSphere() const;
|
||||
|
||||
private:
|
||||
@@ -54,6 +55,11 @@ private:
|
||||
std::string _nodeIdentifier;
|
||||
// To be able to handle nodes with faulty bounding spheres
|
||||
double _validBoundingSphere = 0.0;
|
||||
|
||||
// Keep track of if there was an aim node, specified in for example the
|
||||
// navigation state used to create this waypoint. It may be required in
|
||||
// certain situations
|
||||
std::optional<std::string> _aimNodeIdentifier;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -236,11 +236,19 @@ void PathNavigator::updateCamera(double deltaTime) {
|
||||
if (_setCameraToEndNextFrame) {
|
||||
LDEBUG("Skipped to end of camera path");
|
||||
_currentPath->quitPath();
|
||||
camera()->setPose(_currentPath->endPoint().pose());
|
||||
|
||||
const interaction::Waypoint endPoint = _currentPath->endPoint();
|
||||
camera()->setPose(endPoint.pose());
|
||||
global::navigationHandler->orbitalNavigator().setFocusNode(
|
||||
_currentPath->endPoint().nodeIdentifier(),
|
||||
endPoint.nodeIdentifier(),
|
||||
false
|
||||
);
|
||||
if (endPoint.aimIdentifier().has_value()) {
|
||||
global::navigationHandler->orbitalNavigator().setAimNode(
|
||||
*endPoint.aimIdentifier()
|
||||
);
|
||||
}
|
||||
|
||||
handlePathEnd();
|
||||
_setCameraToEndNextFrame = false;
|
||||
return;
|
||||
@@ -272,6 +280,14 @@ void PathNavigator::updateCamera(double deltaTime) {
|
||||
|
||||
if (_currentPath->hasReachedEnd()) {
|
||||
LINFO("Reached target");
|
||||
|
||||
// Also set the aim once the path is finished, if one should be set
|
||||
if (_currentPath->endPoint().aimIdentifier().has_value()) {
|
||||
global::navigationHandler->orbitalNavigator().setAimNode(
|
||||
*_currentPath->endPoint().aimIdentifier()
|
||||
);
|
||||
}
|
||||
|
||||
handlePathEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,16 @@ Waypoint::Waypoint(const NavigationState& ns) {
|
||||
}
|
||||
|
||||
_nodeIdentifier = ns.anchor;
|
||||
|
||||
if (!ns.aim.empty()) {
|
||||
const SceneGraphNode* aimNode = sceneGraphNode(ns.aim);
|
||||
if (!aimNode) {
|
||||
LERROR(fmt::format("Could not find node '{}' to use as aim", ns.aim));
|
||||
return;
|
||||
}
|
||||
_aimNodeIdentifier = ns.aim;
|
||||
}
|
||||
|
||||
const PathNavigator& navigator = global::navigationHandler->pathNavigator();
|
||||
_validBoundingSphere = navigator.findValidBoundingSphere(anchorNode);
|
||||
_pose = ns.cameraPose();
|
||||
@@ -92,6 +102,10 @@ std::string Waypoint::nodeIdentifier() const {
|
||||
return _nodeIdentifier;
|
||||
}
|
||||
|
||||
std::optional<std::string> Waypoint::aimIdentifier() const {
|
||||
return _aimNodeIdentifier;
|
||||
}
|
||||
|
||||
double Waypoint::validBoundingSphere() const {
|
||||
return _validBoundingSphere;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user