mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-14 09:30:50 -05:00
Merge branch 'develop' of github.com:OpenSpace/OpenSpace into pr/scenegraph-refactor
Conflicts: include/openspace/engine/openspaceengine.h src/engine/openspaceengine.cpp src/engine/settingsengine.cpp src/engine/syncengine.cpp src/interaction/interactionhandler.cpp src/rendering/renderengine.cpp src/scene/scene.cpp src/scene/scenegraph.cpp src/scene/scenegraphnode.cpp tests/test_scenegraphloader.inl
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
@@ -23,76 +23,73 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/engine/syncengine.h>
|
||||
|
||||
#include <openspace/util/syncdata.h>
|
||||
#include <openspace/util/syncbuffer.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "SyncEngine";
|
||||
}
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
SyncEngine::SyncEngine(SyncBuffer* syncBuffer)
|
||||
: _syncBuffer(syncBuffer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SyncEngine::presync(bool isMaster) {
|
||||
for (const auto& syncable : _syncables) {
|
||||
syncable->presync(isMaster);
|
||||
}
|
||||
}
|
||||
|
||||
// should be called on sgct master
|
||||
void SyncEngine::encodeSyncables() {
|
||||
for (const auto& syncable : _syncables) {
|
||||
syncable->encode(_syncBuffer.get());
|
||||
}
|
||||
_syncBuffer->write();
|
||||
}
|
||||
|
||||
//should be called on sgct slaves
|
||||
void SyncEngine::decodeSyncables() {
|
||||
_syncBuffer->read();
|
||||
for (const auto& syncable : _syncables) {
|
||||
syncable->decode(_syncBuffer.get());
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::postsync(bool isMaster) {
|
||||
for (const auto& syncable : _syncables) {
|
||||
syncable->postsync(isMaster);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::addSyncable(Syncable* syncable) {
|
||||
_syncables.push_back(syncable);
|
||||
}
|
||||
|
||||
void SyncEngine::addSyncables(const std::vector<Syncable*>& syncables) {
|
||||
for (const auto& syncable : syncables) {
|
||||
addSyncable(syncable);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::removeSyncable(Syncable* syncable) {
|
||||
_syncables.erase(
|
||||
std::remove(_syncables.begin(), _syncables.end(), syncable),
|
||||
_syncables.end()
|
||||
);
|
||||
}
|
||||
|
||||
void SyncEngine::removeSyncables(const std::vector<Syncable*>& syncables) {
|
||||
for (const auto& syncable : syncables) {
|
||||
removeSyncable(syncable);
|
||||
}
|
||||
}
|
||||
|
||||
SyncEngine::SyncEngine(unsigned int syncBufferSize)
|
||||
: _syncBuffer(syncBufferSize)
|
||||
{
|
||||
ghoul_assert(syncBufferSize > 0, "syncBufferSize must be bigger than 0");
|
||||
}
|
||||
|
||||
// should be called on sgct master
|
||||
void SyncEngine::encodeSyncables() {
|
||||
for (Syncable* syncable : _syncables) {
|
||||
syncable->encode(&_syncBuffer);
|
||||
}
|
||||
_syncBuffer.write();
|
||||
}
|
||||
|
||||
//should be called on sgct slaves
|
||||
void SyncEngine::decodeSyncables() {
|
||||
_syncBuffer.read();
|
||||
for (Syncable* syncable : _syncables) {
|
||||
syncable->decode(&_syncBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::preSynchronization(IsMaster isMaster) {
|
||||
for (Syncable* syncable : _syncables) {
|
||||
syncable->presync(isMaster);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::postSynchronization(IsMaster isMaster) {
|
||||
for (Syncable* syncable : _syncables) {
|
||||
syncable->postsync(isMaster);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::addSyncable(Syncable* syncable) {
|
||||
ghoul_assert(syncable, "synable must not be nullptr");
|
||||
|
||||
_syncables.push_back(syncable);
|
||||
}
|
||||
|
||||
void SyncEngine::addSyncables(const std::vector<Syncable*>& syncables) {
|
||||
for (Syncable* syncable : syncables) {
|
||||
ghoul_assert(syncable, "syncables must not contain any nullptr");
|
||||
addSyncable(syncable);
|
||||
}
|
||||
}
|
||||
|
||||
void SyncEngine::removeSyncable(Syncable* syncable) {
|
||||
_syncables.erase(
|
||||
std::remove(_syncables.begin(), _syncables.end(), syncable),
|
||||
_syncables.end()
|
||||
);
|
||||
}
|
||||
|
||||
void SyncEngine::removeSyncables(const std::vector<Syncable*>& syncables) {
|
||||
for (const auto& syncable : syncables) {
|
||||
removeSyncable(syncable);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user