mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-22 11:18:22 -05:00
Merge pull request #1290 from OpenSpace/feature/more-cleanup
Feature/more cleanup
This commit is contained in:
+1
-1
Submodule apps/OpenSpace/ext/sgct updated: b712e64848...3d3835c38c
@@ -678,22 +678,21 @@ void mainDecodeFun(const std::vector<std::byte>& data, unsigned int) {
|
||||
|
||||
|
||||
|
||||
void mainLogCallback(Log::Level level, const char* message) {
|
||||
void mainLogCallback(Log::Level level, std::string_view message) {
|
||||
ZoneScoped
|
||||
|
||||
std::string msg = message;
|
||||
switch (level) {
|
||||
case Log::Level::Debug:
|
||||
LDEBUGC("SGCT", msg);
|
||||
LDEBUGC("SGCT", message);
|
||||
break;
|
||||
case Log::Level::Info:
|
||||
LINFOC("SGCT", msg);
|
||||
LINFOC("SGCT", message);
|
||||
break;
|
||||
case Log::Level::Warning:
|
||||
LWARNINGC("SGCT", msg);
|
||||
LWARNINGC("SGCT", message);
|
||||
break;
|
||||
case Log::Level::Error:
|
||||
LERRORC("SGCT", msg);
|
||||
LERRORC("SGCT", message);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
Submodule ext/ghoul updated: bd812defd7...d18c7bb1fb
@@ -40,18 +40,18 @@ enum class Type : uint32_t {
|
||||
};
|
||||
|
||||
struct CameraKeyframe {
|
||||
CameraKeyframe() {}
|
||||
CameraKeyframe(const std::vector<char> &buffer) {
|
||||
CameraKeyframe() = default;
|
||||
CameraKeyframe(const std::vector<char>& buffer) {
|
||||
deserialize(buffer);
|
||||
}
|
||||
|
||||
glm::dvec3 _position = glm::dvec3(0.0);
|
||||
glm::dquat _rotation = glm::dquat(1.0, 0.0, 0.0, 0.0);
|
||||
bool _followNodeRotation;
|
||||
bool _followNodeRotation = false;
|
||||
std::string _focusNode;
|
||||
float _scale;
|
||||
float _scale = 0.f;
|
||||
|
||||
double _timestamp;
|
||||
double _timestamp = 0.0;
|
||||
|
||||
void serialize(std::vector<char> &buffer) const {
|
||||
// Add position
|
||||
@@ -104,28 +104,28 @@ struct CameraKeyframe {
|
||||
);
|
||||
};
|
||||
|
||||
size_t deserialize(const std::vector<char> &buffer, size_t offset = 0) {
|
||||
size_t deserialize(const std::vector<char>& buffer, size_t offset = 0) {
|
||||
int size = 0;
|
||||
|
||||
// Position
|
||||
size = sizeof(_position);
|
||||
memcpy(&_position, buffer.data() + offset, size);
|
||||
std::memcpy(&_position, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
// Orientation
|
||||
size = sizeof(_rotation);
|
||||
memcpy(&_rotation, buffer.data() + offset, size);
|
||||
std::memcpy(&_rotation, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
// Follow focus node rotation?
|
||||
size = sizeof(_followNodeRotation);
|
||||
memcpy(&_followNodeRotation, buffer.data() + offset, size);
|
||||
std::memcpy(&_followNodeRotation, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
// Focus node
|
||||
int nodeNameLength;
|
||||
size = sizeof(int);
|
||||
memcpy(&nodeNameLength, buffer.data() + offset, size);
|
||||
std::memcpy(&nodeNameLength, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
size = nodeNameLength;
|
||||
_focusNode = std::string(buffer.data() + offset, buffer.data() + offset + size);
|
||||
@@ -133,29 +133,20 @@ struct CameraKeyframe {
|
||||
|
||||
// Scale
|
||||
size = sizeof(_scale);
|
||||
memcpy(&_scale, buffer.data() + offset, size);
|
||||
std::memcpy(&_scale, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
// Timestamp
|
||||
size = sizeof(_timestamp);
|
||||
memcpy(&_timestamp, buffer.data() + offset, size);
|
||||
std::memcpy(&_timestamp, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
return offset;
|
||||
};
|
||||
|
||||
void write(std::ostream& out) const {
|
||||
// Write position
|
||||
out.write(
|
||||
reinterpret_cast<const char*>(&_position),
|
||||
sizeof(_position)
|
||||
);
|
||||
|
||||
// Write orientation
|
||||
out.write(
|
||||
reinterpret_cast<const char*>(&_rotation),
|
||||
sizeof(_rotation)
|
||||
);
|
||||
out.write(reinterpret_cast<const char*>(&_position), sizeof(_position));
|
||||
out.write(reinterpret_cast<const char*>(&_rotation), sizeof(_rotation));
|
||||
|
||||
// Write follow focus node rotation?
|
||||
out.write(
|
||||
@@ -166,88 +157,58 @@ struct CameraKeyframe {
|
||||
int nodeNameLength = static_cast<int>(_focusNode.size());
|
||||
|
||||
// Write focus node
|
||||
out.write(
|
||||
reinterpret_cast<const char*>(&nodeNameLength),
|
||||
sizeof(nodeNameLength)
|
||||
);
|
||||
out.write(
|
||||
_focusNode.c_str(),
|
||||
_focusNode.size()
|
||||
);
|
||||
out.write(reinterpret_cast<const char*>(&nodeNameLength), sizeof(nodeNameLength));
|
||||
out.write(_focusNode.c_str(), _focusNode.size());
|
||||
|
||||
//Write scale
|
||||
out.write(
|
||||
reinterpret_cast<const char*>(&_scale),
|
||||
sizeof(_scale)
|
||||
);
|
||||
// Write scale
|
||||
out.write(reinterpret_cast<const char*>(&_scale), sizeof(_scale));
|
||||
|
||||
// Write timestamp
|
||||
out.write(
|
||||
reinterpret_cast<const char*>(&_timestamp),
|
||||
sizeof(_timestamp)
|
||||
);
|
||||
out.write(reinterpret_cast<const char*>(&_timestamp), sizeof(_timestamp));
|
||||
};
|
||||
|
||||
void read(std::istream* in) {
|
||||
// Read position
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&_position),
|
||||
sizeof(_position)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&_position), sizeof(_position));
|
||||
|
||||
// Read orientation
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&_rotation),
|
||||
sizeof(_rotation)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&_rotation), sizeof(_rotation));
|
||||
|
||||
// Read follow focus node rotation
|
||||
unsigned char b;
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&b),
|
||||
sizeof(unsigned char)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&b), sizeof(unsigned char));
|
||||
_followNodeRotation = (b == 1);
|
||||
|
||||
// Read focus node
|
||||
int nodeNameLength = static_cast<int>(_focusNode.size());
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&nodeNameLength),
|
||||
sizeof(nodeNameLength)
|
||||
);
|
||||
std::vector<char> temp(nodeNameLength + 1);
|
||||
in->read(reinterpret_cast<char*>(&nodeNameLength), sizeof(nodeNameLength));
|
||||
std::vector<char> temp(static_cast<size_t>(nodeNameLength) + 1);
|
||||
in->read(temp.data(), nodeNameLength);
|
||||
|
||||
temp[nodeNameLength] = '\0';
|
||||
_focusNode = temp.data();
|
||||
|
||||
// Read scale
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&_scale),
|
||||
sizeof(_scale)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&_scale), sizeof(_scale));
|
||||
|
||||
// Read timestamp
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&_timestamp),
|
||||
sizeof(_timestamp)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&_timestamp), sizeof(_timestamp));
|
||||
};
|
||||
};
|
||||
|
||||
struct TimeKeyframe {
|
||||
TimeKeyframe() {}
|
||||
TimeKeyframe(const std::vector<char> &buffer) {
|
||||
TimeKeyframe() = default;
|
||||
TimeKeyframe(const std::vector<char>& buffer) {
|
||||
deserialize(buffer);
|
||||
}
|
||||
|
||||
double _time;
|
||||
double _dt;
|
||||
bool _paused;
|
||||
bool _requiresTimeJump;
|
||||
double _timestamp;
|
||||
double _time = 0.0;
|
||||
double _dt = 0.0;
|
||||
bool _paused = false;
|
||||
bool _requiresTimeJump = false;
|
||||
double _timestamp = 0.0;
|
||||
|
||||
void serialize(std::vector<char> &buffer) const {
|
||||
void serialize(std::vector<char>& buffer) const {
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<const char*>(this),
|
||||
@@ -255,37 +216,31 @@ struct TimeKeyframe {
|
||||
);
|
||||
};
|
||||
|
||||
size_t deserialize(const std::vector<char> &buffer, size_t offset = 0){
|
||||
size_t deserialize(const std::vector<char>& buffer, size_t offset = 0) {
|
||||
*this = *reinterpret_cast<const TimeKeyframe*>(buffer.data() + offset);
|
||||
offset += sizeof(TimeKeyframe);
|
||||
return offset;
|
||||
};
|
||||
|
||||
void write(std::ostream* out) const {
|
||||
out->write(
|
||||
reinterpret_cast<const char*>(this),
|
||||
sizeof(TimeKeyframe)
|
||||
);
|
||||
out->write(reinterpret_cast<const char*>(this), sizeof(TimeKeyframe));
|
||||
};
|
||||
|
||||
void read(std::istream* in) {
|
||||
in->read(
|
||||
reinterpret_cast<char*>(this),
|
||||
sizeof(TimeKeyframe)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(this), sizeof(TimeKeyframe));
|
||||
};
|
||||
};
|
||||
|
||||
struct TimeTimeline {
|
||||
TimeTimeline() {}
|
||||
TimeTimeline(const std::vector<char> &buffer) {
|
||||
TimeTimeline() = default;
|
||||
TimeTimeline(const std::vector<char>& buffer) {
|
||||
deserialize(buffer);
|
||||
}
|
||||
|
||||
bool _clear = true;
|
||||
std::vector<TimeKeyframe> _keyframes;
|
||||
|
||||
void serialize(std::vector<char> &buffer) const {
|
||||
void serialize(std::vector<char>& buffer) const {
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<const char*>(&_clear),
|
||||
@@ -298,77 +253,65 @@ struct TimeTimeline {
|
||||
reinterpret_cast<const char*>(&nKeyframes),
|
||||
reinterpret_cast<const char*>(&nKeyframes) + sizeof(int64_t)
|
||||
);
|
||||
for (const auto& k : _keyframes) {
|
||||
for (const TimeKeyframe& k : _keyframes) {
|
||||
k.serialize(buffer);
|
||||
}
|
||||
};
|
||||
|
||||
size_t deserialize(const std::vector<char> &buffer, size_t offset = 0) {
|
||||
size_t deserialize(const std::vector<char>& buffer, size_t offset = 0) {
|
||||
int size = 0;
|
||||
|
||||
size = sizeof(_clear);
|
||||
memcpy(&_clear, buffer.data() + offset, size);
|
||||
std::memcpy(&_clear, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
int64_t nKeyframes = _keyframes.size();
|
||||
size = sizeof(nKeyframes);
|
||||
memcpy(&nKeyframes, buffer.data() + offset, size);
|
||||
std::memcpy(&nKeyframes, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
_keyframes.resize(nKeyframes);
|
||||
for (auto& k : _keyframes) {
|
||||
for (TimeKeyframe& k : _keyframes) {
|
||||
offset = k.deserialize(buffer, offset);
|
||||
}
|
||||
return offset;
|
||||
};
|
||||
|
||||
void write(std::ostream* out) const {
|
||||
out->write(
|
||||
reinterpret_cast<const char*>(&_clear),
|
||||
sizeof(bool)
|
||||
);
|
||||
out->write(reinterpret_cast<const char*>(&_clear), sizeof(bool));
|
||||
|
||||
int64_t nKeyframes = _keyframes.size();
|
||||
out->write(
|
||||
reinterpret_cast<const char*>(&nKeyframes),
|
||||
sizeof(int64_t)
|
||||
);
|
||||
for (const auto& k : _keyframes) {
|
||||
out->write(reinterpret_cast<const char*>(&nKeyframes), sizeof(int64_t));
|
||||
for (const TimeKeyframe& k : _keyframes) {
|
||||
k.write(out);
|
||||
}
|
||||
};
|
||||
|
||||
void read(std::istream* in) {
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&_clear),
|
||||
sizeof(bool)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&_clear), sizeof(bool));
|
||||
|
||||
int64_t nKeyframes = _keyframes.size();
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&nKeyframes),
|
||||
sizeof(int64_t)
|
||||
);
|
||||
for (auto& k : _keyframes) {
|
||||
in->read(reinterpret_cast<char*>(&nKeyframes), sizeof(int64_t));
|
||||
for (TimeKeyframe& k : _keyframes) {
|
||||
k.read(in);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
struct ScriptMessage {
|
||||
ScriptMessage() {}
|
||||
ScriptMessage(const std::vector<char> &buffer) {
|
||||
ScriptMessage() = default;
|
||||
ScriptMessage(const std::vector<char>& buffer) {
|
||||
deserialize(buffer);
|
||||
}
|
||||
|
||||
std::string _script;
|
||||
double _timestamp;
|
||||
double _timestamp = 0.0;
|
||||
|
||||
void serialize(std::vector<char> &buffer) const {
|
||||
void serialize(std::vector<char>& buffer) const {
|
||||
buffer.insert(buffer.end(), _script.begin(), _script.end());
|
||||
};
|
||||
|
||||
void deserialize(const std::vector<char> &buffer) {
|
||||
void deserialize(const std::vector<char>& buffer) {
|
||||
_script.assign(buffer.begin(), buffer.end());
|
||||
};
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ public:
|
||||
* \param category The category of the log message
|
||||
* \param message The actual log message that was transmitted
|
||||
*/
|
||||
void log(ghoul::logging::LogLevel level, const std::string& category,
|
||||
const std::string& message) override;
|
||||
void log(ghoul::logging::LogLevel level, std::string_view category,
|
||||
std::string_view message) override;
|
||||
|
||||
/**
|
||||
* This method removes all the stored LogEntry%s that have expired, calculated by
|
||||
|
||||
@@ -85,7 +85,7 @@ Connection::Connection(std::unique_ptr<ghoul::io::Socket> s,
|
||||
AuthenticationTopicKey,
|
||||
[password](bool, const ghoul::Dictionary&, ghoul::MemoryPoolBase* pool) {
|
||||
if (pool) {
|
||||
void* ptr = pool->alloc(sizeof(AuthorizationTopic));
|
||||
void* ptr = pool->allocate(sizeof(AuthorizationTopic));
|
||||
return new (ptr) AuthorizationTopic(password);
|
||||
}
|
||||
else {
|
||||
@@ -139,7 +139,7 @@ void Connection::handleMessage(const std::string& message) {
|
||||
message.end(),
|
||||
sanitizedString.begin(),
|
||||
[](wchar_t c) {
|
||||
return std::isprint(c, std::locale("")) ? c : ' ';
|
||||
return std::isprint(c, std::locale("")) ? char(c) : ' ';
|
||||
}
|
||||
);
|
||||
LERROR(fmt::format("Could not parse JSON: '{}'", sanitizedString));
|
||||
|
||||
@@ -303,12 +303,10 @@ void FlightControllerTopic::changeFocus(const nlohmann::json& json) const {
|
||||
fmt::format("Could not find {} key in JSON. JSON was:\n{}", FocusKey, j)
|
||||
);
|
||||
if (json.find(AimKey) == json.end()) {
|
||||
const std::string j = json;
|
||||
LWARNING(
|
||||
fmt::format("Could not find {} key in JSON. JSON was:\n{}", AimKey, j)
|
||||
);
|
||||
if (json.find(AnchorKey) == json.end()) {
|
||||
const std::string j = json;
|
||||
LWARNING(fmt::format(
|
||||
"Could not find {} key in JSON. JSON was:\n{}", AnchorKey, j
|
||||
));
|
||||
|
||||
@@ -332,7 +332,6 @@ glm::vec2 DashboardItemInstruments::size() const {
|
||||
|
||||
if (remaining > 0) {
|
||||
using FR = ghoul::fontrendering::FontRenderer;
|
||||
FR& renderer = FR::defaultRenderer();
|
||||
std::string progress = progressToStr(25, t);
|
||||
|
||||
size = addToBoundingbox(
|
||||
|
||||
@@ -80,7 +80,7 @@ void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) {
|
||||
"HttpSynchronization",
|
||||
[this](bool, const ghoul::Dictionary& dictionary, ghoul::MemoryPoolBase* pool) {
|
||||
if (pool) {
|
||||
void* ptr = pool->alloc(sizeof(HttpSynchronization));
|
||||
void* ptr = pool->allocate(sizeof(HttpSynchronization));
|
||||
return new (ptr) HttpSynchronization(
|
||||
dictionary,
|
||||
_synchronizationRoot,
|
||||
@@ -101,7 +101,7 @@ void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) {
|
||||
"UrlSynchronization",
|
||||
[this](bool, const ghoul::Dictionary& dictionary, ghoul::MemoryPoolBase* pool) {
|
||||
if (pool) {
|
||||
void* ptr = pool->alloc(sizeof(UrlSynchronization));
|
||||
void* ptr = pool->allocate(sizeof(UrlSynchronization));
|
||||
return new (ptr) UrlSynchronization(
|
||||
dictionary,
|
||||
_synchronizationRoot
|
||||
|
||||
@@ -25,7 +25,16 @@
|
||||
#ifndef __OPENSPACE_MODULE_WEBBROWSER___CEF_HOST___H__
|
||||
#define __OPENSPACE_MODULE_WEBBROWSER___CEF_HOST___H__
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4100)
|
||||
#endif // WIN32
|
||||
|
||||
#include <include/wrapper/cef_helpers.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(pop)
|
||||
#endif // WIN32
|
||||
#include <string>
|
||||
|
||||
struct CefSettingsTraits;
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <fmt/format.h>
|
||||
#include <include/wrapper/cef_helpers.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <include/wrapper/cef_library_loader.h>
|
||||
|
||||
@@ -994,10 +994,7 @@ void OpenSpaceEngine::loadFonts() {
|
||||
}
|
||||
|
||||
try {
|
||||
bool initSuccess = ghoul::fontrendering::FontRenderer::initialize();
|
||||
if (!initSuccess) {
|
||||
LERROR("Error initializing default font renderer");
|
||||
}
|
||||
ghoul::fontrendering::FontRenderer::initialize();
|
||||
}
|
||||
catch (const ghoul::RuntimeError& err) {
|
||||
LERRORC(err.component, err.message);
|
||||
|
||||
@@ -687,7 +687,7 @@ void LuaConsole::render() {
|
||||
|
||||
// Since the overflow is positive, at least one character needs to be removed.
|
||||
const size_t nCharsOverflow = static_cast<size_t>(std::min(
|
||||
std::max(1.f, overflow / _font->glyph('m')->width()),
|
||||
std::max(1.f, overflow / _font->glyph('m')->width),
|
||||
static_cast<float>(currentCommand.size())
|
||||
));
|
||||
|
||||
|
||||
@@ -48,15 +48,15 @@ void ScreenLog::removeExpiredEntries() {
|
||||
_entries.erase(rit, _entries.end() );
|
||||
}
|
||||
|
||||
void ScreenLog::log(LogLevel level, const string& category, const string& message) {
|
||||
void ScreenLog::log(LogLevel level, std::string_view category, std::string_view message) {
|
||||
std::lock_guard<std::mutex> guard(_mutex);
|
||||
if (level >= _logLevel) {
|
||||
_entries.push_back({
|
||||
level,
|
||||
std::chrono::steady_clock::now(),
|
||||
Log::timeString(),
|
||||
category,
|
||||
message
|
||||
std::string(category),
|
||||
std::string(message)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user