diff --git a/include/openspace/util/camera.h b/include/openspace/util/camera.h index 7747bd8f38..255b2a0247 100644 --- a/include/openspace/util/camera.h +++ b/include/openspace/util/camera.h @@ -29,7 +29,6 @@ // open space includes #include -#include #include // glm includes @@ -181,16 +180,8 @@ namespace openspace { private: struct SyncData { - void serialize(SyncBuffer* syncBuffer) { - syncBuffer->encode(position); - syncBuffer->encode(rotation); - syncBuffer->encode(scaling); - } - void deserialize(SyncBuffer* syncBuffer) { - syncBuffer->decode(position); - syncBuffer->decode(rotation); - syncBuffer->decode(scaling); - } + void serialize(SyncBuffer* syncBuffer); + void deserialize(SyncBuffer* syncBuffer); Vec3 position; Quat rotation; diff --git a/include/openspace/util/time.h b/include/openspace/util/time.h index b38e96a852..ac458b31ea 100644 --- a/include/openspace/util/time.h +++ b/include/openspace/util/time.h @@ -26,7 +26,6 @@ #define __TIME_H__ #include -#include #include #include @@ -209,17 +208,9 @@ private: static Time* _instance; ///< The singleton instance struct SyncData { - void serialize(SyncBuffer* syncBuffer) { - syncBuffer->encode(time); - syncBuffer->encode(dt); - syncBuffer->encode(timeJumped); - }; + void serialize(SyncBuffer* syncBuffer); - void deserialize(SyncBuffer* syncBuffer) { - syncBuffer->decode(time); - syncBuffer->decode(dt); - syncBuffer->decode(timeJumped); - } + void deserialize(SyncBuffer* syncBuffer); double time = -1.0; double dt = 1.0; diff --git a/src/util/camera.cpp b/src/util/camera.cpp index 64ad26c593..2760df853e 100644 --- a/src/util/camera.cpp +++ b/src/util/camera.cpp @@ -299,6 +299,18 @@ namespace openspace { } void Camera::updateDoubleBuffer(){ + std::lock_guard _lock(_mutex); local = synced; } + + void Camera::SyncData::serialize(SyncBuffer* syncBuffer) { + syncBuffer->encode(position); + syncBuffer->encode(rotation); + syncBuffer->encode(scaling); + } + void Camera::SyncData::deserialize(SyncBuffer* syncBuffer) { + syncBuffer->decode(position); + syncBuffer->decode(rotation); + syncBuffer->decode(scaling); + } } // namespace openspace diff --git a/src/util/time.cpp b/src/util/time.cpp index 46469dc8fa..da8def29d5 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -174,7 +174,21 @@ bool Time::paused() const { return _timePaused; } void Time::updateDoubleBuffer() { + _syncMutex.lock(); local = synced; + _syncMutex.unlock(); +} + +void Time::SyncData::serialize(SyncBuffer* syncBuffer) { + syncBuffer->encode(time); + syncBuffer->encode(dt); + syncBuffer->encode(timeJumped); +}; + +void Time::SyncData::deserialize(SyncBuffer* syncBuffer) { + syncBuffer->decode(time); + syncBuffer->decode(dt); + syncBuffer->decode(timeJumped); }