Sync out the anchor node, issue 2854 (#3398)

* Sync out anchor node to all connected clients

* Remove warning in case anchor node is nullptr

* Always sync out the anchor node to nodes
This commit is contained in:
Malin E
2024-10-09 10:39:13 +02:00
committed by GitHub
parent 2d6e2d891b
commit 9582d81fb6
3 changed files with 23 additions and 1 deletions

View File

@@ -38,6 +38,7 @@
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/triggerproperty.h>
#include <openspace/util/syncdata.h>
#include <ghoul/glm.h>
#include <glm/gtx/quaternion.hpp>
#include <optional>
@@ -148,6 +149,9 @@ public:
*/
glm::dvec3 pushToSurfaceOfAnchor(const glm::dvec3& cameraPosition) const;
void updateAnchor();
std::vector<Syncable*> syncables();
/**
* \return The Lua library that contains all Lua functions available to affect the
* OrbitalNavigator
@@ -244,6 +248,7 @@ private:
WebsocketCameraStates _websocketStates;
ScriptCameraStates _scriptStates;
SyncData<std::string> _syncedAnchorNode;
const SceneGraphNode* _anchorNode = nullptr;
const SceneGraphNode* _aimNode = nullptr;

View File

@@ -831,6 +831,9 @@ void OpenSpaceEngine::loadAssets() {
global::renderEngine->updateScene();
global::syncEngine->addSyncables(global::timeManager->syncables());
global::syncEngine->addSyncables(
global::navigationHandler->orbitalNavigator().syncables()
);
if (_scene && _scene->camera()) {
global::syncEngine->addSyncables(_scene->camera()->syncables());
}
@@ -1173,6 +1176,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
global::luaConsole->update();
if (!master) {
global::navigationHandler->orbitalNavigator().updateAnchor();
_scene->camera()->invalidateCache();
}
@@ -1309,7 +1313,6 @@ void OpenSpaceEngine::postDraw() {
global::eventEngine->triggerActions();
global::eventEngine->triggerTopics();
global::eventEngine->postFrameCleanup();
global::memoryManager->PersistentMemory.housekeeping();

View File

@@ -1109,6 +1109,7 @@ void OrbitalNavigator::setAnchorNode(const SceneGraphNode* anchorNode,
const bool changedAnchor = _anchorNode != anchorNode;
_anchorNode = anchorNode;
_syncedAnchorNode = anchorNode ? anchorNode->identifier() : "";
// Need to reset velocities after the actual switch in anchor node,
// since the reset behavior depends on the anchor node.
@@ -2084,6 +2085,19 @@ double OrbitalNavigator::rotationSpeedScaleFromCameraHeight(
1.0;
}
// This should only be run on nodes and not on master
void OrbitalNavigator::updateAnchor() {
ghoul_assert(!global::windowDelegate->isMaster());
if (!_syncedAnchorNode.data().empty()) {
setAnchorNode(_syncedAnchorNode);
}
}
std::vector<Syncable*> OrbitalNavigator::syncables() {
return { &_syncedAnchorNode };
}
scripting::LuaLibrary OrbitalNavigator::luaLibrary() {
return {
"orbitalnavigation",