Move camera and time serialization and deserialization to cpp-files

This commit is contained in:
Erik Broberg
2016-09-12 14:05:26 -04:00
parent 9c5deaba82
commit 5cb6d2cb05
4 changed files with 30 additions and 22 deletions
+2 -11
View File
@@ -29,7 +29,6 @@
// open space includes
#include <openspace/util/powerscaledcoordinate.h>
#include <openspace/util/syncbuffer.h>
#include <openspace/rendering/renderengine.h>
// 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;
+2 -11
View File
@@ -26,7 +26,6 @@
#define __TIME_H__
#include <openspace/scripting/scriptengine.h>
#include <openspace/util/syncbuffer.h>
#include <mutex>
#include <string>
@@ -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;
+12
View File
@@ -299,6 +299,18 @@ namespace openspace {
}
void Camera::updateDoubleBuffer(){
std::lock_guard<std::mutex> _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
+14
View File
@@ -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);
}