Feature/globals handling (#1352)

* Cleaner handling of global state
* Prevent Lua memory corruption (closes #982)
* Initialize glfw first thing to prevent weird joystick loading bug during startup
This commit is contained in:
Alexander Bock
2020-10-21 22:30:05 +02:00
committed by GitHub
parent 1525a0490d
commit efffc25ce0
164 changed files with 1484 additions and 1390 deletions
+10 -10
View File
@@ -82,7 +82,7 @@ void ExternInteraction::cameraInteraction(datamessagestructures::CameraKeyframe
pose.scale = std::move(kf._scale);
pose.followFocusNodeRotation = std::move(kf._followNodeRotation);
global::navigationHandler.keyframeNavigator().addKeyframe(kf._timestamp, pose);
global::navigationHandler->keyframeNavigator().addKeyframe(kf._timestamp, pose);
}
void ExternInteraction::timeInteraction(datamessagestructures::TimeKeyframe kf) {
@@ -91,18 +91,18 @@ void ExternInteraction::timeInteraction(datamessagestructures::TimeKeyframe kf)
timeKfData.pause = std::move(kf._paused);
timeKfData.jump = std::move(kf._requiresTimeJump);
global::timeManager.addKeyframe(kf._timestamp, timeKfData);
global::timeManager->addKeyframe(kf._timestamp, timeKfData);
}
void ExternInteraction::scriptInteraction(datamessagestructures::ScriptMessage sm) {
global::scriptEngine.queueScript(
global::scriptEngine->queueScript(
std::move(sm._script),
scripting::ScriptEngine::RemoteScripting::No
);
}
datamessagestructures::CameraKeyframe ExternInteraction::generateCameraKeyframe() {
interaction::NavigationHandler& navHandler = global::navigationHandler;
interaction::NavigationHandler& navHandler = *global::navigationHandler;
datamessagestructures::CameraKeyframe kf;
const SceneGraphNode* focusNode = navHandler.orbitalNavigator().anchorNode();
@@ -126,21 +126,21 @@ datamessagestructures::CameraKeyframe ExternInteraction::generateCameraKeyframe(
kf._scale = navHandler.camera()->scaling();
// Timestamp as current runtime of OpenSpace instance
kf._timestamp = global::windowDelegate.applicationTime();
kf._timestamp = global::windowDelegate->applicationTime();
return kf;
}
datamessagestructures::TimeKeyframe ExternInteraction::generateTimeKeyframe() {
datamessagestructures::TimeKeyframe kf;
const Time& time = global::timeManager.time();
const Time& time = global::timeManager->time();
kf._dt = global::timeManager.deltaTime();
kf._paused = global::timeManager.isPaused();
kf._dt = global::timeManager->deltaTime();
kf._paused = global::timeManager->isPaused();
kf._time = time.j2000Seconds();
// Timestamp as current runtime of OpenSpace instance
kf._timestamp = global::windowDelegate.applicationTime();
kf._timestamp = global::windowDelegate->applicationTime();
return kf;
}
@@ -150,7 +150,7 @@ datamessagestructures::ScriptMessage ExternInteraction::generateScriptMessage(
datamessagestructures::ScriptMessage sm;
sm._script = std::move(script);
// Timestamp as current runtime of OpenSpace instance
sm._timestamp = global::windowDelegate.applicationTime();
sm._timestamp = global::windowDelegate->applicationTime();
return sm;
}
+6 -6
View File
@@ -108,31 +108,31 @@ bool InputState::isMouseButtonPressed(MouseButton mouseButton) const {
}
float InputState::joystickAxis(int i) const {
return global::joystickInputStates.axis(i);
return global::joystickInputStates->axis(i);
}
bool InputState::joystickButton(int i) const {
return global::joystickInputStates.button(i, JoystickAction::Press);
return global::joystickInputStates->button(i, JoystickAction::Press);
}
float InputState::websocketAxis(int i) const {
return global::websocketInputStates.axis(i);
return global::websocketInputStates->axis(i);
}
bool InputState::websocketButton(int i) const {
return global::websocketInputStates.button(i, WebsocketAction::Press);
return global::websocketInputStates->button(i, WebsocketAction::Press);
}
void InputState::resetWebsockets() {
using K = size_t;
using V = WebsocketInputState*;
for (const std::pair<const K, V>& p : global::websocketInputStates) {
for (const std::pair<const K, V>& p : *global::websocketInputStates) {
p.second->isConnected = false;
}
}
bool InputState::hasWebsocketStates() const {
return !global::websocketInputStates.empty();
return !global::websocketInputStates->empty();
}
} // namespace openspace::interaction
+2 -2
View File
@@ -65,7 +65,7 @@ void InteractionMonitor::setIdleTime(float time) {
}
void InteractionMonitor::updateActivityState() {
const double currentApplicationTime = global::windowDelegate.applicationTime();
const double currentApplicationTime = global::windowDelegate->applicationTime();
const double timeDiff = currentApplicationTime - _lastInteractionTime;
if (timeDiff >= _idleTime && _isInActiveState) {
@@ -74,7 +74,7 @@ void InteractionMonitor::updateActivityState() {
}
void InteractionMonitor::markInteraction() {
_lastInteractionTime = global::windowDelegate.applicationTime();
_lastInteractionTime = global::windowDelegate->applicationTime();
_isInActiveState = true;
}
+2 -2
View File
@@ -154,10 +154,10 @@ void JoystickCameraStates::updateStateFromInput(const InputState& inputState,
for (int i = 0; i < JoystickInputState::MaxButtons; ++i) {
auto itRange = _buttonMapping.equal_range(i);
for (auto it = itRange.first; it != itRange.second; ++it) {
bool active = global::joystickInputStates.button(i, it->second.action);
bool active = global::joystickInputStates->button(i, it->second.action);
if (active) {
global::scriptEngine.queueScript(
global::scriptEngine->queueScript(
it->second.command,
scripting::ScriptEngine::RemoteScripting(it->second.synchronization)
);
+1 -1
View File
@@ -53,7 +53,7 @@ void KeybindingManager::keyboardCallback(Key key, KeyModifier modifier, KeyActio
for (auto it = ret.first; it != ret.second; ++it) {
using RS = scripting::ScriptEngine::RemoteScripting;
global::scriptEngine.queueScript(
global::scriptEngine->queueScript(
it->second.command,
it->second.synchronization ? RS::Yes : RS::No
);
+6 -6
View File
@@ -60,7 +60,7 @@ int bindKey(lua_State* L) {
std::string name = (nArguments >= 4) ? ghoul::lua::value<std::string>(L, 4) : "";
std::string guiPath = (nArguments == 5) ? ghoul::lua::value<std::string>(L, 5) : "";
global::keybindingManager.bindKey(
global::keybindingManager->bindKey(
iKey.key,
iKey.modifier,
std::move(command),
@@ -107,7 +107,7 @@ int bindKeyLocal(lua_State* L) {
ghoul::lua::value<std::string>(L, 5) :
"";
global::keybindingManager.bindKeyLocal(
global::keybindingManager->bindKeyLocal(
iKey.key,
iKey.modifier,
std::move(command),
@@ -139,7 +139,7 @@ int getKeyBindings(lua_State* L) {
using K = KeyWithModifier;
using V = interaction::KeybindingManager::KeyInformation;
const std::vector<std::pair<K, V>>& info = global::keybindingManager.keyBinding(key);
const std::vector<std::pair<K, V>>& info = global::keybindingManager->keyBinding(key);
lua_createtable(L, static_cast<int>(info.size()), 0);
int i = 1;
@@ -174,7 +174,7 @@ int clearKey(lua_State* L) {
if (t == LUA_TSTRING) {
// The user provided a single key
const std::string& key = ghoul::lua::value<std::string>(L, 1);
global::keybindingManager.removeKeyBinding(key);
global::keybindingManager->removeKeyBinding(key);
}
else {
// The user provided a list of keys
@@ -182,7 +182,7 @@ int clearKey(lua_State* L) {
ghoul::lua::luaDictionaryFromState(L, d);
for (size_t i = 1; i <= d.size(); ++i) {
const std::string& k = d.value<std::string>(std::to_string(i));
global::keybindingManager.removeKeyBinding(k);
global::keybindingManager->removeKeyBinding(k);
}
lua_pop(L, 1);
}
@@ -200,7 +200,7 @@ int clearKey(lua_State* L) {
int clearKeys(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clearKeys");
global::keybindingManager.resetKeyBindings();
global::keybindingManager->resetKeyBindings();
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
+3 -3
View File
@@ -189,13 +189,13 @@ bool KeyframeNavigator::updateCamera(Camera* camera, const CameraPose prevPose,
double KeyframeNavigator::currentTime() const {
if (_timeframeMode == KeyframeTimeRef::Relative_recordedStart) {
return (global::windowDelegate.applicationTime() - _referenceTimestamp);
return (global::windowDelegate->applicationTime() - _referenceTimestamp);
}
else if (_timeframeMode == KeyframeTimeRef::Absolute_simTimeJ2000) {
return global::timeManager.time().j2000Seconds();
return global::timeManager->time().j2000Seconds();
}
else {
return global::windowDelegate.applicationTime();
return global::windowDelegate->applicationTime();
}
}
+3 -3
View File
@@ -162,11 +162,11 @@ NavigationHandler::~NavigationHandler() {} // NOLINT
void NavigationHandler::initialize() {
ZoneScoped
global::parallelPeer.connectionEvent().subscribe(
global::parallelPeer->connectionEvent().subscribe(
"NavigationHandler",
"statusChanged",
[this]() {
_useKeyFrameInteraction = (global::parallelPeer.status() ==
_useKeyFrameInteraction = (global::parallelPeer->status() ==
ParallelConnection::Status::ClientWithHost);
}
);
@@ -175,7 +175,7 @@ void NavigationHandler::initialize() {
void NavigationHandler::deinitialize() {
ZoneScoped
global::parallelPeer.connectionEvent().unsubscribe("NavigationHandler");
global::parallelPeer->connectionEvent().unsubscribe("NavigationHandler");
}
void NavigationHandler::setFocusNode(SceneGraphNode* node) {
+19 -19
View File
@@ -40,7 +40,7 @@ int loadNavigationState(lua_State* L) {
return ghoul::lua::luaError(L, "filepath string is empty");
}
global::navigationHandler.loadNavigationState(cameraStateFilePath);
global::navigationHandler->loadNavigationState(cameraStateFilePath);
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
@@ -65,10 +65,10 @@ int getNavigationState(lua_State* L) {
lua_settop(L, 0);
return 0;
}
state = global::navigationHandler.navigationState(*referenceFrame);
state = global::navigationHandler->navigationState(*referenceFrame);
}
else {
state = global::navigationHandler.navigationState();
state = global::navigationHandler->navigationState();
}
lua_settop(L, 0);
@@ -135,7 +135,7 @@ int setNavigationState(lua_State* L) {
);
}
global::navigationHandler.setNavigationStateNextFrame(navigationStateDictionary);
global::navigationHandler->setNavigationStateNextFrame(navigationStateDictionary);
// @CLEANUP: When luaDictionaryFromState doesn't leak space anymore, remove the next
// line ---abock(2018-02-15)
@@ -162,7 +162,7 @@ int saveNavigationState(lua_State* L) {
return ghoul::lua::luaError(L, "filepath string is empty");
}
global::navigationHandler.saveNavigationState(cameraStateFilePath, referenceFrame);
global::navigationHandler->saveNavigationState(cameraStateFilePath, referenceFrame);
lua_settop(L, 0);
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
@@ -172,7 +172,7 @@ int saveNavigationState(lua_State* L) {
int retargetAnchor(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::retargetAnchor");
global::navigationHandler.orbitalNavigator().startRetargetAnchor();
global::navigationHandler->orbitalNavigator().startRetargetAnchor();
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
@@ -181,7 +181,7 @@ int retargetAnchor(lua_State* L) {
int retargetAim(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::retargetAim");
global::navigationHandler.orbitalNavigator().startRetargetAim();
global::navigationHandler->orbitalNavigator().startRetargetAim();
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
@@ -200,7 +200,7 @@ int bindJoystickAxis(lua_State* L) {
const bool shouldInvert = n > 2 ? ghoul::lua::value<bool>(L, 3) : false;
const bool shouldNormalize = n > 3 ? ghoul::lua::value<bool>(L, 4) : false;
global::navigationHandler.setJoystickAxisMapping(
global::navigationHandler->setJoystickAxisMapping(
axis,
ghoul::from_string<interaction::JoystickCameraStates::AxisType>(axisType),
interaction::JoystickCameraStates::AxisInvert(shouldInvert),
@@ -218,7 +218,7 @@ int joystickAxis(lua_State* L) {
const int axis = ghoul::lua::value<int>(L, 1);
using AI = interaction::JoystickCameraStates::AxisInformation;
AI info = global::navigationHandler.joystickAxisMapping(axis);
AI info = global::navigationHandler->joystickAxisMapping(axis);
lua_settop(L, 0);
const bool invert = info.invert;
@@ -236,7 +236,7 @@ int setJoystickAxisDeadzone(lua_State* L) {
const float deadzone = ghoul::lua::value<float>(L, 2);
lua_settop(L, 0);
global::navigationHandler.setJoystickAxisDeadzone(axis, deadzone);
global::navigationHandler->setJoystickAxisDeadzone(axis, deadzone);
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
@@ -247,7 +247,7 @@ int joystickAxisDeadzone(lua_State* L) {
const int axis = ghoul::lua::value<int>(L, 1, ghoul::lua::PopValue::Yes);
const float deadzone = global::navigationHandler.joystickAxisDeadzone(axis);
const float deadzone = global::navigationHandler->joystickAxisDeadzone(axis);
ghoul::lua::push(L, deadzone);
ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack");
@@ -274,7 +274,7 @@ int bindJoystickButton(lua_State* L) {
const bool isRemote = n == 5 ? ghoul::lua::value<bool>(L, 5) : true;
lua_settop(L, 0);
global::navigationHandler.bindJoystickButtonCommand(
global::navigationHandler->bindJoystickButtonCommand(
button,
std::move(command),
action,
@@ -291,7 +291,7 @@ int clearJoystickButton(lua_State* L) {
const int button = ghoul::lua::value<int>(L, 1, ghoul::lua::PopValue::Yes);
global::navigationHandler.clearJoystickButtonCommand(button);
global::navigationHandler->clearJoystickButtonCommand(button);
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
@@ -303,7 +303,7 @@ int joystickButton(lua_State* L) {
const int button = ghoul::lua::value<int>(L, 1, ghoul::lua::PopValue::Yes);
const std::vector<std::string>& cmds =
global::navigationHandler.joystickButtonCommand(button);
global::navigationHandler->joystickButtonCommand(button);
std::string cmd = std::accumulate(
cmds.begin(),
@@ -325,7 +325,7 @@ int addGlobalRotation(lua_State* L) {
const double v1 = ghoul::lua::value<double>(L, 1, ghoul::lua::PopValue::No);
const double v2 = ghoul::lua::value<double>(L, 2, ghoul::lua::PopValue::No);
global::navigationHandler.orbitalNavigator().scriptStates().addGlobalRotation(
global::navigationHandler->orbitalNavigator().scriptStates().addGlobalRotation(
glm::dvec2(v1, v2)
);
@@ -339,7 +339,7 @@ int addLocalRotation(lua_State* L) {
const double v1 = ghoul::lua::value<double>(L, 1, ghoul::lua::PopValue::No);
const double v2 = ghoul::lua::value<double>(L, 2, ghoul::lua::PopValue::No);
global::navigationHandler.orbitalNavigator().scriptStates().addLocalRotation(
global::navigationHandler->orbitalNavigator().scriptStates().addLocalRotation(
glm::dvec2(v1, v2)
);
@@ -353,7 +353,7 @@ int addTruckMovement(lua_State* L) {
const double v1 = ghoul::lua::value<double>(L, 1, ghoul::lua::PopValue::No);
const double v2 = ghoul::lua::value<double>(L, 2, ghoul::lua::PopValue::No);
global::navigationHandler.orbitalNavigator().scriptStates().addTruckMovement(
global::navigationHandler->orbitalNavigator().scriptStates().addTruckMovement(
glm::dvec2(v1, v2)
);
@@ -367,7 +367,7 @@ int addLocalRoll(lua_State* L) {
const double v1 = ghoul::lua::value<double>(L, 1, ghoul::lua::PopValue::No);
const double v2 = ghoul::lua::value<double>(L, 2, ghoul::lua::PopValue::No);
global::navigationHandler.orbitalNavigator().scriptStates().addLocalRoll(
global::navigationHandler->orbitalNavigator().scriptStates().addLocalRoll(
glm::dvec2(v1, v2)
);
@@ -381,7 +381,7 @@ int addGlobalRoll(lua_State* L) {
const double v1 = ghoul::lua::value<double>(L, 1, ghoul::lua::PopValue::No);
const double v2 = ghoul::lua::value<double>(L, 2, ghoul::lua::PopValue::No);
global::navigationHandler.orbitalNavigator().scriptStates().addGlobalRoll(
global::navigationHandler->orbitalNavigator().scriptStates().addGlobalRoll(
glm::dvec2(v1, v2)
);
+33 -33
View File
@@ -180,10 +180,10 @@ bool SessionRecording::startRecording(const std::string& filename) {
}
_recordFile << '\n';
_timestampRecordStarted = global::windowDelegate.applicationTime();
_timestampRecordStarted = global::windowDelegate->applicationTime();
//Record the current delta time so this is preserved in recording
double currentDeltaTime = global::timeManager.deltaTime();
double currentDeltaTime = global::timeManager->deltaTime();
std::string scriptCommandForInitializingDeltaTime =
"openspace.time.setDeltaTime(" + std::to_string(currentDeltaTime) + ")";
saveScriptKeyframe(scriptCommandForInitializingDeltaTime);
@@ -277,9 +277,9 @@ bool SessionRecording::startPlayback(const std::string& filename,
return false;
}
//Set time reference mode
double now = global::windowDelegate.applicationTime();
double now = global::windowDelegate->applicationTime();
_timestampPlaybackStarted_application = now;
_timestampPlaybackStarted_simulation = global::timeManager.time().j2000Seconds();
_timestampPlaybackStarted_simulation = global::timeManager->time().j2000Seconds();
_timestampApplicationStarted_simulation = _timestampPlaybackStarted_simulation - now;
_playbackTimeReferenceMode = timeMode;
@@ -290,8 +290,8 @@ bool SessionRecording::startPlayback(const std::string& filename,
_playbackActive_time = true;
}
global::navigationHandler.keyframeNavigator().setTimeReferenceMode(timeMode, now);
global::scriptScheduler.setTimeReferenceMode(timeMode);
global::navigationHandler->keyframeNavigator().setTimeReferenceMode(timeMode, now);
global::scriptScheduler->setTimeReferenceMode(timeMode);
_setSimulationTimeWithNextCameraKeyframe = forceSimTimeAtStart;
if (!playbackAddEntriesToTimeline()) {
@@ -309,9 +309,9 @@ bool SessionRecording::startPlayback(const std::string& filename,
_keyframesTime.size(), _keyframesScript.size(), (forceSimTimeAtStart ? 1 : 0)
));
global::navigationHandler.triggerPlaybackStart();
global::scriptScheduler.triggerPlaybackStart();
global::timeManager.triggerPlaybackStart();
global::navigationHandler->triggerPlaybackStart();
global::scriptScheduler->triggerPlaybackStart();
global::timeManager->triggerPlaybackStart();
_state = SessionState::Playback;
return true;
@@ -375,20 +375,20 @@ void SessionRecording::stopPlayback() {
}
void SessionRecording::cleanUpPlayback() {
global::navigationHandler.stopPlayback();
global::timeManager.stopPlayback();
global::navigationHandler->stopPlayback();
global::timeManager->stopPlayback();
Camera* camera = global::navigationHandler.camera();
Camera* camera = global::navigationHandler->camera();
ghoul_assert(camera != nullptr, "Camera must not be nullptr");
Scene* scene = camera->parent()->scene();
if (!_timeline.empty()) {
unsigned int p = _timeline[_idxTimeline_cameraPtrPrev].idxIntoKeyframeTypeArray;
const SceneGraphNode* node = scene->sceneGraphNode(_keyframesCamera[p].focusNode);
if (node) {
global::navigationHandler.orbitalNavigator().setFocusNode(node->identifier());
const SceneGraphNode* n = scene->sceneGraphNode(_keyframesCamera[p].focusNode);
if (n) {
global::navigationHandler->orbitalNavigator().setFocusNode(n->identifier());
}
}
global::scriptScheduler.stopPlayback();
global::scriptScheduler->stopPlayback();
_playbackFile.close();
@@ -486,7 +486,7 @@ void SessionRecording::saveCameraKeyframe() {
return;
}
const SceneGraphNode* an = global::navigationHandler.orbitalNavigator().anchorNode();
const SceneGraphNode* an = global::navigationHandler->orbitalNavigator().anchorNode();
if (!an) {
return;
}
@@ -498,7 +498,7 @@ void SessionRecording::saveCameraKeyframe() {
Timestamps times = {
kf._timestamp,
kf._timestamp - _timestampRecordStarted,
global::timeManager.time().j2000Seconds()
global::timeManager->time().j2000Seconds()
};
if (_recordingDataMode == DataMode::Binary) {
saveCameraKeyframeBinary(times, kf, _keyframeBuffer, _recordFile);
@@ -565,7 +565,7 @@ void SessionRecording::saveTimeKeyframe() {
Timestamps times = {
kf._timestamp,
kf._timestamp - _timestampRecordStarted,
global::timeManager.time().j2000Seconds()
global::timeManager->time().j2000Seconds()
};
if (_recordingDataMode == DataMode::Binary) {
saveTimeKeyframeBinary(times, kf, _keyframeBuffer, _recordFile);
@@ -608,7 +608,7 @@ void SessionRecording::saveScriptKeyframe(std::string scriptToSave) {
Timestamps times = {
sm._timestamp,
sm._timestamp - _timestampRecordStarted,
global::timeManager.time().j2000Seconds()
global::timeManager->time().j2000Seconds()
};
if (_recordingDataMode == DataMode::Binary) {
@@ -682,9 +682,9 @@ void SessionRecording::render() {
constexpr const char* FontName = "Mono";
constexpr const float FontSizeFrameinfo = 32.f;
std::shared_ptr<ghoul::fontrendering::Font> font =
global::fontManager.font(FontName, FontSizeFrameinfo);
global::fontManager->font(FontName, FontSizeFrameinfo);
glm::vec2 res = global::renderEngine.fontResolution();
glm::vec2 res = global::renderEngine->fontResolution();
glm::vec2 penPosition = glm::vec2(
res.x / 2 - 150.f,
res.y / 4
@@ -842,14 +842,14 @@ double SessionRecording::currentTime() const {
return _saveRenderingCurrentRecordedTime;
}
else if (_playbackTimeReferenceMode == KeyframeTimeRef::Relative_recordedStart) {
return (global::windowDelegate.applicationTime() -
return (global::windowDelegate->applicationTime() -
_timestampPlaybackStarted_application);
}
else if (_playbackTimeReferenceMode == KeyframeTimeRef::Absolute_simTimeJ2000) {
return global::timeManager.time().j2000Seconds();
return global::timeManager->time().j2000Seconds();
}
else {
return global::windowDelegate.applicationTime();
return global::windowDelegate->applicationTime();
}
}
@@ -857,7 +857,7 @@ double SessionRecording::fixedDeltaTimeDuringFrameOutput() const {
// Check if renderable in focus is still resolving tile loading
// do not adjust time while we are doing this
const SceneGraphNode* focusNode =
global::navigationHandler.orbitalNavigator().anchorNode();
global::navigationHandler->orbitalNavigator().anchorNode();
const Renderable* focusRenderable = focusNode->renderable();
if (!focusRenderable || focusRenderable->renderedWithDesiredData()) {
return _saveRenderingDeltaTime;
@@ -879,7 +879,7 @@ bool SessionRecording::playbackCamera() {
}
if (_setSimulationTimeWithNextCameraKeyframe) {
global::timeManager.setTimeNextFrame(Time(times.timeSim));
global::timeManager->setTimeNextFrame(Time(times.timeSim));
_setSimulationTimeWithNextCameraKeyframe = false;
_saveRenderingCurrentRecordedTime = times.timeRec;
}
@@ -1169,11 +1169,11 @@ void SessionRecording::moveAheadInTime() {
// Check if renderable in focus is still resolving tile loading
// do not adjust time while we are doing this, or take screenshot
const SceneGraphNode* focusNode =
global::navigationHandler.orbitalNavigator().anchorNode();
global::navigationHandler->orbitalNavigator().anchorNode();
const Renderable* focusRenderable = focusNode->renderable();
if (!focusRenderable || focusRenderable->renderedWithDesiredData()) {
_saveRenderingCurrentRecordedTime += _saveRenderingDeltaTime;
global::renderEngine.takeScreenshot();
global::renderEngine->takeScreenshot();
}
}
}
@@ -1348,17 +1348,17 @@ bool SessionRecording::processCameraKeyframe(double now) {
// Need to activly update the focusNode position of the camera in relation to
// the rendered objects will be unstable and actually incorrect
Camera* camera = global::navigationHandler.camera();
Camera* camera = global::navigationHandler->camera();
Scene* scene = camera->parent()->scene();
const SceneGraphNode* n = scene->sceneGraphNode(_keyframesCamera[prevIdx].focusNode);
if (n) {
global::navigationHandler.orbitalNavigator().setFocusNode(n->identifier());
global::navigationHandler->orbitalNavigator().setFocusNode(n->identifier());
}
return interaction::KeyframeNavigator::updateCamera(
global::navigationHandler.camera(),
global::navigationHandler->camera(),
prevPose,
nextPose,
t,
@@ -1379,7 +1379,7 @@ bool SessionRecording::processScriptKeyframe() {
_keyframesScript,
([this]() { signalPlaybackFinishedForComponent(RecordedType::Script); })
);
global::scriptEngine.queueScript(
global::scriptEngine->queueScript(
nextScript,
scripting::ScriptEngine::RemoteScripting::Yes
);
+9 -9
View File
@@ -39,10 +39,10 @@ int startRecording(lua_State* L) {
if (recordFilePath.empty()) {
return luaL_error(L, "filepath string is empty");
}
global::sessionRecording.setRecordDataFormat(
global::sessionRecording->setRecordDataFormat(
interaction::SessionRecording::DataMode::Binary
);
global::sessionRecording.startRecording(recordFilePath);
global::sessionRecording->startRecording(recordFilePath);
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
@@ -62,10 +62,10 @@ int startRecordingAscii(lua_State* L) {
if (recordFilePath.empty()) {
return luaL_error(L, "filepath string is empty");
}
global::sessionRecording.setRecordDataFormat(
global::sessionRecording->setRecordDataFormat(
interaction::SessionRecording::DataMode::Ascii
);
global::sessionRecording.startRecording(recordFilePath);
global::sessionRecording->startRecording(recordFilePath);
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
@@ -74,7 +74,7 @@ int startRecordingAscii(lua_State* L) {
int stopRecording(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::stopRecording");
global::sessionRecording.stopRecording();
global::sessionRecording->stopRecording();
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
@@ -95,7 +95,7 @@ int startPlayback(lua_State* L, interaction::KeyframeTimeRef timeMode,
return luaL_error(L, "filepath string is empty");
}
global::sessionRecording.startPlayback(
global::sessionRecording->startPlayback(
playbackFilePath,
timeMode,
forceSimTimeAtStart
@@ -136,7 +136,7 @@ int startPlaybackSimulationTime(lua_State* L) {
int stopPlayback(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::stopPlayback");
global::sessionRecording.stopPlayback();
global::sessionRecording->stopPlayback();
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
@@ -151,7 +151,7 @@ int enableTakeScreenShotDuringPlayback(lua_State* L) {
const int fps = nArguments == 0 ? 60 : ghoul::lua::value<int>(L, 1);
global::sessionRecording.enableTakeScreenShotDuringPlayback(fps);
global::sessionRecording->enableTakeScreenShotDuringPlayback(fps);
lua_settop(L, 0);
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
@@ -161,7 +161,7 @@ int enableTakeScreenShotDuringPlayback(lua_State* L) {
int disableTakeScreenShotDuringPlayback(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::disableTakeScreenShotDuringPlayback");
global::sessionRecording.disableTakeScreenShotDuringPlayback();
global::sessionRecording->disableTakeScreenShotDuringPlayback();
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
+3 -3
View File
@@ -52,7 +52,7 @@ namespace openspace::luascriptfunctions {
int clearShortcuts(lua_State* L) {
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clearShortcuts");
global::shortcutManager.resetShortcuts();
global::shortcutManager->resetShortcuts();
return 0;
}
@@ -60,7 +60,7 @@ int bindShortcut(lua_State* L) {
int n = ghoul::lua::checkArgumentsAndThrow(L, { 2, 4 }, "lua::bindShortcut");
interaction::ShortcutManager::ShortcutInformation info = extractInfo(L, n, true);
global::shortcutManager.addShortcut(std::move(info));
global::shortcutManager->addShortcut(std::move(info));
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;
@@ -70,7 +70,7 @@ int bindShortcutLocal(lua_State* L) {
int n = ghoul::lua::checkArgumentsAndThrow(L, { 2, 4 }, "lua::bindShortcutLocal");
interaction::ShortcutManager::ShortcutInformation info = extractInfo(L, n, false);
global::shortcutManager.addShortcut(std::move(info));
global::shortcutManager->addShortcut(std::move(info));
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
return 0;