mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Address clang tidy complaints
Update Ghoul repository Update SGCT repository
This commit is contained in:
@@ -84,7 +84,7 @@
|
||||
#ifdef WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif // WIN32
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -1218,8 +1218,9 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
|
||||
}
|
||||
|
||||
// Restores OpenGL blending state
|
||||
if (blendEnabled)
|
||||
if (blendEnabled) {
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha);
|
||||
glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha);
|
||||
|
||||
@@ -186,7 +186,7 @@ private:
|
||||
int _nu_samples;
|
||||
|
||||
glm::dmat4 _modelTransform;
|
||||
double _time;
|
||||
double _time = 0.0;
|
||||
|
||||
// Eclipse Shadows
|
||||
std::vector<ShadowConfiguration> _shadowConfArray;
|
||||
|
||||
@@ -61,8 +61,7 @@ documentation::Documentation CameraLightSource::Documentation() {
|
||||
}
|
||||
|
||||
CameraLightSource::CameraLightSource()
|
||||
: LightSource()
|
||||
, _intensity(IntensityInfo, 1.f, 0.f, 1.f)
|
||||
: _intensity(IntensityInfo, 1.f, 0.f, 1.f)
|
||||
{
|
||||
addProperty(_intensity);
|
||||
}
|
||||
|
||||
@@ -76,8 +76,7 @@ documentation::Documentation SceneGraphLightSource::Documentation() {
|
||||
}
|
||||
|
||||
SceneGraphLightSource::SceneGraphLightSource()
|
||||
: LightSource()
|
||||
, _intensity(IntensityInfo, 1.f, 0.f, 1.f)
|
||||
: _intensity(IntensityInfo, 1.f, 0.f, 1.f)
|
||||
, _sceneGraphNodeReference(NodeInfo, "")
|
||||
{
|
||||
addProperty(_intensity);
|
||||
|
||||
@@ -240,8 +240,6 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_performShading);
|
||||
}
|
||||
|
||||
RenderableModel::~RenderableModel() {}
|
||||
|
||||
bool RenderableModel::isReady() const {
|
||||
return _program && _texture;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace modelgeometry { class ModelGeometry; }
|
||||
class RenderableModel : public Renderable {
|
||||
public:
|
||||
RenderableModel(const ghoul::Dictionary& dictionary);
|
||||
~RenderableModel();
|
||||
~RenderableModel() = default;
|
||||
|
||||
void initialize() override;
|
||||
void initializeGL() override;
|
||||
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
void loadTexture();
|
||||
|
||||
properties::StringProperty _texturePath;
|
||||
ghoul::opengl::Texture* _texture;
|
||||
ghoul::opengl::Texture* _texture = nullptr;
|
||||
std::unique_ptr<ghoul::filesystem::File> _textureFile;
|
||||
|
||||
bool _textureIsDirty = false;
|
||||
|
||||
@@ -114,8 +114,7 @@ TimeFrameInterval::TimeFrameInterval()
|
||||
}
|
||||
|
||||
TimeFrameInterval::TimeFrameInterval(const ghoul::Dictionary& dictionary)
|
||||
: TimeFrame()
|
||||
, _hasStart(HasStartInfo, false)
|
||||
: _hasStart(HasStartInfo, false)
|
||||
, _start(StartInfo, 0, 0, 1E9)
|
||||
, _hasEnd(HasEndInfo, false)
|
||||
, _end(EndInfo, 0, 0, 1E9)
|
||||
|
||||
@@ -73,8 +73,6 @@ bool TimeFrameUnion::isActive(const Time& time) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
TimeFrameUnion::TimeFrameUnion() {}
|
||||
|
||||
TimeFrameUnion::TimeFrameUnion(const ghoul::Dictionary& dictionary)
|
||||
: TimeFrame()
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace documentation { struct Documentation; }
|
||||
|
||||
class TimeFrameUnion : public TimeFrame {
|
||||
public:
|
||||
TimeFrameUnion();
|
||||
TimeFrameUnion() = default;
|
||||
TimeFrameUnion(const ghoul::Dictionary& dictionary);
|
||||
bool isActive(const Time&) const override;
|
||||
|
||||
|
||||
@@ -139,11 +139,11 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration)
|
||||
_visible = configuration.hasValue<bool>(VisibleInfo.identifier) &&
|
||||
configuration.value<bool>(VisibleInfo.identifier);
|
||||
|
||||
global::callback::initializeGL.push_back([this]() {
|
||||
global::callback::initializeGL.emplace_back([this]() {
|
||||
startOrStopGui();
|
||||
});
|
||||
|
||||
global::callback::draw2D.push_back([this](){
|
||||
global::callback::draw2D.emplace_back([this](){
|
||||
const bool isGuiWindow =
|
||||
global::windowDelegate.hasGuiWindow() ?
|
||||
global::windowDelegate.isGuiWindow() :
|
||||
@@ -160,7 +160,7 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration)
|
||||
}
|
||||
});
|
||||
|
||||
global::callback::deinitializeGL.push_back([this]() {
|
||||
global::callback::deinitializeGL.emplace_back([this]() {
|
||||
_enabled = false;
|
||||
startOrStopGui();
|
||||
});
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace openspace {
|
||||
GUIKeyboardHandler::GUIKeyboardHandler() {
|
||||
_keyConsumed = false;
|
||||
|
||||
global::callback::keyboard.push_back(
|
||||
global::callback::keyboard.emplace_back(
|
||||
[&](Key, KeyModifier, KeyAction) -> bool {
|
||||
const bool previous = _keyConsumed;
|
||||
_keyConsumed = false;
|
||||
|
||||
@@ -57,7 +57,7 @@ GUIRenderHandler::GUIRenderHandler() {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), 0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), nullptr);
|
||||
glBindVertexArray(0);
|
||||
LDEBUG("Initializing CEF GL environment... done!");
|
||||
}
|
||||
|
||||
@@ -55,8 +55,6 @@ DebugRenderer::DebugRenderer(std::unique_ptr<ghoul::opengl::ProgramObject> progr
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
DebugRenderer::~DebugRenderer() { }
|
||||
|
||||
const DebugRenderer& DebugRenderer::ref() {
|
||||
if (!_reference) {
|
||||
try {
|
||||
@@ -70,7 +68,7 @@ const DebugRenderer& DebugRenderer::ref() {
|
||||
}
|
||||
|
||||
void DebugRenderer::renderVertices(const Vertices& clippingSpacePoints, GLenum mode,
|
||||
const glm::vec4& rgba) const
|
||||
const glm::vec4& color) const
|
||||
{
|
||||
if (clippingSpacePoints.empty()) {
|
||||
return;
|
||||
@@ -88,7 +86,7 @@ void DebugRenderer::renderVertices(const Vertices& clippingSpacePoints, GLenum m
|
||||
|
||||
// Activate the shader program and set the uniform color within the shader
|
||||
_programObject->activate();
|
||||
_programObject->setUniform("color", rgba);
|
||||
_programObject->setUniform("color", color);
|
||||
|
||||
glBindVertexArray(_vaoID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferID);
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
* Instantiate a new DebugRenderer with a custom shader program
|
||||
*/
|
||||
DebugRenderer(std::unique_ptr<ghoul::opengl::ProgramObject> programObject);
|
||||
~DebugRenderer();
|
||||
~DebugRenderer() = default;
|
||||
|
||||
/**
|
||||
* Access the static reference
|
||||
|
||||
@@ -173,8 +173,6 @@ RenderableDebugPlane::RenderableDebugPlane(const ghoul::Dictionary& dictionary)
|
||||
setBoundingSphere(_size);
|
||||
}
|
||||
|
||||
RenderableDebugPlane::~RenderableDebugPlane() {}
|
||||
|
||||
bool RenderableDebugPlane::isReady() const {
|
||||
bool ready = true;
|
||||
if (!_shader) {
|
||||
@@ -220,7 +218,7 @@ void RenderableDebugPlane::render(const RenderData& data, RendererTasks&) {
|
||||
|
||||
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_shader->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(*_shader.get(), data.camera, data.position);
|
||||
setPscUniforms(*_shader, data.camera, data.position);
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
|
||||
@@ -48,7 +48,7 @@ struct UpdateStructure;
|
||||
class RenderableDebugPlane : public Renderable {
|
||||
public:
|
||||
RenderableDebugPlane(const ghoul::Dictionary& dictionary);
|
||||
~RenderableDebugPlane();
|
||||
~RenderableDebugPlane() = default;
|
||||
|
||||
void initializeGL() override;
|
||||
void deinitializeGL() override;
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
#include <array>
|
||||
#include <fstream>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include <locale>
|
||||
#include <string>
|
||||
|
||||
@@ -423,8 +423,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
|
||||
if (dictionary.hasKey(KeyFile)) {
|
||||
_speckFile = absPath(dictionary.value<std::string>(KeyFile));
|
||||
_hasSpeckFile = true;
|
||||
_drawElements.onChange([&]() {
|
||||
_hasSpeckFile = _hasSpeckFile == true? false : true; });
|
||||
_drawElements.onChange([&]() { _hasSpeckFile = !_hasSpeckFile; });
|
||||
addProperty(_drawElements);
|
||||
}
|
||||
|
||||
@@ -1163,7 +1162,7 @@ bool RenderableBillboardsCloud::readSpeckFile() {
|
||||
// The beginning of the speck file has a header that either contains comments
|
||||
// (signaled by a preceding '#') or information about the structure of the file
|
||||
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
|
||||
std::string line = "";
|
||||
std::string line;
|
||||
while (true) {
|
||||
std::streampos position = file.tellg();
|
||||
std::getline(file, line);
|
||||
@@ -1253,7 +1252,7 @@ bool RenderableBillboardsCloud::readColorMapFile() {
|
||||
// The beginning of the speck file has a header that either contains comments
|
||||
// (signaled by a preceding '#') or information about the structure of the file
|
||||
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
|
||||
std::string line = "";
|
||||
std::string line;
|
||||
while (true) {
|
||||
// std::streampos position = file.tellg();
|
||||
std::getline(file, line);
|
||||
@@ -1300,7 +1299,7 @@ bool RenderableBillboardsCloud::readLabelFile() {
|
||||
// The beginning of the speck file has a header that either contains comments
|
||||
// (signaled by a preceding '#') or information about the structure of the file
|
||||
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
|
||||
std::string line = "";
|
||||
std::string line;
|
||||
while (true) {
|
||||
std::streampos position = file.tellg();
|
||||
std::getline(file, line);
|
||||
@@ -1375,7 +1374,7 @@ bool RenderableBillboardsCloud::readLabelFile() {
|
||||
glm::vec3 transformedPos = glm::vec3(
|
||||
_transformationMatrix * glm::dvec4(position, 1.0)
|
||||
);
|
||||
_labelData.push_back(std::make_pair(transformedPos, label));
|
||||
_labelData.emplace_back(std::make_pair(transformedPos, label));
|
||||
} while (!file.eof());
|
||||
|
||||
return true;
|
||||
@@ -1411,12 +1410,10 @@ bool RenderableBillboardsCloud::loadCachedFile(const std::string& file) {
|
||||
for (int i = 0; i < nItems; ++i) {
|
||||
int32_t keySize = 0;
|
||||
fileStream.read(reinterpret_cast<char*>(&keySize), sizeof(int32_t));
|
||||
std::string key;
|
||||
for (int c = 0; c < keySize; ++c) {
|
||||
char t;
|
||||
fileStream.read(&t, sizeof(char));
|
||||
key.append(1, t);
|
||||
}
|
||||
std::vector<char> buffer(keySize);
|
||||
fileStream.read(buffer.data(), keySize);
|
||||
|
||||
std::string key(buffer.begin(), buffer.end());
|
||||
int32_t value = 0;
|
||||
fileStream.read(reinterpret_cast<char*>(&value), sizeof(int32_t));
|
||||
|
||||
@@ -1461,23 +1458,21 @@ bool RenderableBillboardsCloud::saveCachedFile(const std::string& file) const {
|
||||
int32_t nItems = static_cast<int32_t>(_variableDataPositionMap.size());
|
||||
fileStream.write(reinterpret_cast<const char*>(&nItems), sizeof(int32_t));
|
||||
|
||||
for (auto pair : _variableDataPositionMap) {
|
||||
for (const std::pair<const std::string, int>& pair :
|
||||
_variableDataPositionMap)
|
||||
{
|
||||
int32_t keySize = static_cast<int32_t>(pair.first.size());
|
||||
fileStream.write(
|
||||
reinterpret_cast<const char*>(&keySize),
|
||||
sizeof(int32_t)
|
||||
);
|
||||
for (size_t c = 0; c < pair.first.size(); ++c) {
|
||||
char keyChar = static_cast<int32_t>(pair.first[c]);
|
||||
fileStream.write(&keyChar, sizeof(char));
|
||||
}
|
||||
fileStream.write(pair.first.data(), keySize);
|
||||
int32_t value = static_cast<int32_t>(pair.second);
|
||||
fileStream.write(reinterpret_cast<const char*>(&value), sizeof(int32_t));
|
||||
}
|
||||
}
|
||||
|
||||
bool success = fileStream.good();
|
||||
return success;
|
||||
return fileStream.good();
|
||||
}
|
||||
else {
|
||||
LERROR(fmt::format("Error opening file '{}' for save cache file", file));
|
||||
@@ -1532,8 +1527,9 @@ void RenderableBillboardsCloud::createDataSlice() {
|
||||
int c = static_cast<int>(colorBins.size() - 1);
|
||||
while (variableColor < colorBins[c]) {
|
||||
--c;
|
||||
if (c == 0)
|
||||
if (c == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int colorIndex =
|
||||
|
||||
@@ -131,8 +131,8 @@ private:
|
||||
// DEBUG:
|
||||
properties::OptionProperty _renderOption;
|
||||
|
||||
ghoul::opengl::Texture* _polygonTexture;
|
||||
ghoul::opengl::Texture* _spriteTexture;
|
||||
ghoul::opengl::Texture* _polygonTexture = nullptr;
|
||||
ghoul::opengl::Texture* _spriteTexture = nullptr;
|
||||
ghoul::opengl::ProgramObject* _program = nullptr;
|
||||
ghoul::opengl::ProgramObject* _renderToPolygonProgram = nullptr;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <array>
|
||||
#include <fstream>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "RenderableDUMeshes";
|
||||
@@ -268,8 +268,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary)
|
||||
if (dictionary.hasKey(KeyFile)) {
|
||||
_speckFile = absPath(dictionary.value<std::string>(KeyFile));
|
||||
_hasSpeckFile = true;
|
||||
_drawElements.onChange([&]() {
|
||||
_hasSpeckFile = _hasSpeckFile == true ? false : true; });
|
||||
_drawElements.onChange([&]() { _hasSpeckFile = !_hasSpeckFile; });
|
||||
addProperty(_drawElements);
|
||||
}
|
||||
|
||||
@@ -706,7 +705,7 @@ bool RenderableDUMeshes::readSpeckFile() {
|
||||
// The beginning of the speck file has a header that either contains comments
|
||||
// (signaled by a preceding '#') or information about the structure of the file
|
||||
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
|
||||
std::string line = "";
|
||||
std::string line;
|
||||
while (true) {
|
||||
std::streampos position = file.tellg();
|
||||
std::getline(file, line);
|
||||
@@ -827,7 +826,7 @@ bool RenderableDUMeshes::readLabelFile() {
|
||||
// The beginning of the speck file has a header that either contains comments
|
||||
// (signaled by a preceding '#') or information about the structure of the file
|
||||
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
|
||||
std::string line = "";
|
||||
std::string line;
|
||||
while (true) {
|
||||
std::streampos position = file.tellg();
|
||||
std::getline(file, line);
|
||||
@@ -899,7 +898,7 @@ bool RenderableDUMeshes::readLabelFile() {
|
||||
glm::vec3 transformedPos = glm::vec3(
|
||||
_transformationMatrix * glm::dvec4(position, 1.0)
|
||||
);
|
||||
_labelData.push_back(std::make_pair(transformedPos, label));
|
||||
_labelData.emplace_back(std::make_pair(transformedPos, label));
|
||||
|
||||
} while (!file.eof());
|
||||
|
||||
|
||||
@@ -873,7 +873,7 @@ bool RenderablePlanesCloud::readSpeckFile() {
|
||||
// The beginning of the speck file has a header that either contains comments
|
||||
// (signaled by a preceding '#') or information about the structure of the file
|
||||
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
|
||||
std::string line = "";
|
||||
std::string line;
|
||||
while (true) {
|
||||
std::streampos position = file.tellg();
|
||||
std::getline(file, line);
|
||||
@@ -950,7 +950,7 @@ bool RenderablePlanesCloud::readSpeckFile() {
|
||||
if (line.substr(0, 8) == "texture ") {
|
||||
std::stringstream str(line);
|
||||
|
||||
std::size_t found = line.find("-");
|
||||
std::size_t found = line.find('-');
|
||||
|
||||
int textureIndex = 0;
|
||||
|
||||
@@ -1055,7 +1055,7 @@ bool RenderablePlanesCloud::readLabelFile() {
|
||||
// The beginning of the speck file has a header that either contains comments
|
||||
// (signaled by a preceding '#') or information about the structure of the file
|
||||
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
|
||||
std::string line = "";
|
||||
std::string line;
|
||||
while (true) {
|
||||
std::streampos position = file.tellg();
|
||||
std::getline(file, line);
|
||||
@@ -1125,7 +1125,7 @@ bool RenderablePlanesCloud::readLabelFile() {
|
||||
glm::vec3 transformedPos = glm::vec3(
|
||||
_transformationMatrix * glm::dvec4(position, 1.0)
|
||||
);
|
||||
_labelData.push_back(std::make_pair(transformedPos, label));
|
||||
_labelData.emplace_back(std::make_pair(transformedPos, label));
|
||||
|
||||
} while (!file.eof());
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ private:
|
||||
const glm::dmat4& projectionMatrix, float fadeInVariable);
|
||||
void renderLabels(const RenderData& data,
|
||||
const glm::dmat4& modelViewProjectionMatrix, const glm::dvec3& orthoRight,
|
||||
const glm::dvec3& orthoUp, float fadeInVarible);
|
||||
const glm::dvec3& orthoUp, float fadeInVariable);
|
||||
|
||||
bool loadData();
|
||||
bool loadTextures();
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <array>
|
||||
#include <fstream>
|
||||
#include <locale>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
@@ -406,7 +406,7 @@ void RenderablePoints::update(const UpdateData&) {
|
||||
if (_hasSpriteTexture && _spriteTextureIsDirty) {
|
||||
LDEBUG("Reloading Sprite Texture");
|
||||
_spriteTexture = nullptr;
|
||||
if (_spriteTexturePath.value() != "") {
|
||||
if (!_spriteTexturePath.value().empty()) {
|
||||
_spriteTexture = ghoul::io::TextureReader::ref().loadTexture(
|
||||
absPath(_spriteTexturePath)
|
||||
);
|
||||
@@ -489,7 +489,7 @@ bool RenderablePoints::readSpeckFile() {
|
||||
// The beginning of the speck file has a header that either contains comments
|
||||
// (signaled by a preceding '#') or information about the structure of the file
|
||||
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
|
||||
std::string line = "";
|
||||
std::string line;
|
||||
while (true) {
|
||||
std::streampos position = file.tellg();
|
||||
std::getline(file, line);
|
||||
@@ -556,7 +556,7 @@ bool RenderablePoints::readColorMapFile() {
|
||||
// The beginning of the speck file has a header that either contains comments
|
||||
// (signaled by a preceding '#') or information about the structure of the file
|
||||
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
|
||||
std::string line = "";
|
||||
std::string line;
|
||||
while (true) {
|
||||
// std::streampos position = file.tellg();
|
||||
std::getline(file, line);
|
||||
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
* Reads a single SPECK file and returns a vector with <code>nRenderValues</code>
|
||||
* per star. Reads data in pre-defined order based on AMNH's star data files.
|
||||
*/
|
||||
std::vector<float> readSpeckFile(std::string filePath, int& nRenderValues);
|
||||
std::vector<float> readSpeckFile(const std::string& filePath, int& nRenderValues);
|
||||
|
||||
private:
|
||||
std::unique_ptr<CCfits::FITS> _infile;
|
||||
|
||||
@@ -52,7 +52,7 @@ FitsFileReader::~FitsFileReader() {
|
||||
}
|
||||
|
||||
bool FitsFileReader::isPrimaryHDU() {
|
||||
return _infile->extension().size() == 0;
|
||||
return _infile->extension().empty();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -507,9 +507,10 @@ std::vector<float> FitsFileReader::readFitsFile(std::string filePath, int& nValu
|
||||
return fullData;
|
||||
}
|
||||
|
||||
std::vector<float> FitsFileReader::readSpeckFile(std::string filePath, int& nRenderValues)
|
||||
std::vector<float> FitsFileReader::readSpeckFile(const std::string& filePath,
|
||||
int& nRenderValues)
|
||||
{
|
||||
auto fullData = std::vector<float>();
|
||||
std::vector<float> fullData;
|
||||
|
||||
std::ifstream fileStream(filePath);
|
||||
|
||||
@@ -525,7 +526,7 @@ std::vector<float> FitsFileReader::readSpeckFile(std::string filePath, int& nRen
|
||||
// The beginning of the speck file has a header that either contains comments
|
||||
// (signaled by a preceding '#') or information about the structure of the file
|
||||
// (signaled by the keywords 'datavar', 'texturevar', 'texture' and 'maxcomment')
|
||||
std::string line = "";
|
||||
std::string line;
|
||||
while (true) {
|
||||
std::streampos position = fileStream.tellg();
|
||||
std::getline(fileStream, line);
|
||||
@@ -591,8 +592,8 @@ std::vector<float> FitsFileReader::readSpeckFile(std::string filePath, int& nRen
|
||||
|
||||
// Check if star is a nullArray.
|
||||
bool nullArray = true;
|
||||
for (size_t i = 0; i < readValues.size(); ++i) {
|
||||
if (readValues[i] != 0.0) {
|
||||
for (float f : readValues) {
|
||||
if (f != 0.0) {
|
||||
nullArray = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
OctreeManager::~OctreeManager() {}
|
||||
|
||||
void OctreeManager::initOctree(long long cpuRamBudget, int maxDist, int maxStarsPerNode) {
|
||||
if (_root) {
|
||||
LDEBUG("Clear existing Octree");
|
||||
@@ -121,16 +119,16 @@ void OctreeManager::initBufferIndexStack(long long maxNodes, bool useVBO,
|
||||
void OctreeManager::insert(const std::vector<float>& starValues) {
|
||||
size_t index = getChildIndex(starValues[0], starValues[1], starValues[2]);
|
||||
|
||||
insertInNode(_root->Children[index], starValues);
|
||||
insertInNode(*_root->Children[index], starValues);
|
||||
}
|
||||
|
||||
void OctreeManager::sliceLodData(size_t branchIndex) {
|
||||
if (branchIndex != 8) {
|
||||
sliceNodeLodCache(_root->Children[branchIndex]);
|
||||
sliceNodeLodCache(*_root->Children[branchIndex]);
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
sliceNodeLodCache(_root->Children[i]);
|
||||
sliceNodeLodCache(*_root->Children[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,7 +138,7 @@ void OctreeManager::printStarsPerNode() const {
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
std::string prefix = "{" + std::to_string(i);
|
||||
accumulatedString += printStarsPerNode(_root->Children[i], prefix);
|
||||
accumulatedString += printStarsPerNode(*_root->Children[i], prefix);
|
||||
}
|
||||
LINFO(fmt::format("Number of stars per node: \n{}", accumulatedString));
|
||||
LINFO(fmt::format("Number of leaf nodes: {}", std::to_string(_numLeafNodes)));
|
||||
@@ -159,7 +157,7 @@ void OctreeManager::fetchSurroundingNodes(const glm::dvec3& cameraPos,
|
||||
// Only traverse Octree once!
|
||||
if (_parentNodeOfCamera == 8) {
|
||||
// Fetch first layer of children
|
||||
fetchChildrenNodes(_root, 0);
|
||||
fetchChildrenNodes(*_root, 0);
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
// Check so branch doesn't have a single layer.
|
||||
@@ -170,12 +168,9 @@ void OctreeManager::fetchSurroundingNodes(const glm::dvec3& cameraPos,
|
||||
// Use multithreading to load files and detach thread from main execution
|
||||
// so it can execute independently. Thread will be destroyed when
|
||||
// finished!
|
||||
std::thread(
|
||||
&OctreeManager::fetchChildrenNodes,
|
||||
this,
|
||||
_root->Children[i],
|
||||
-1
|
||||
).detach();
|
||||
std::thread([this, n = _root->Children[i]]() {
|
||||
fetchChildrenNodes(*n, -1);
|
||||
}).detach();
|
||||
}
|
||||
_parentNodeOfCamera = 0;
|
||||
}
|
||||
@@ -187,7 +182,7 @@ void OctreeManager::fetchSurroundingNodes(const glm::dvec3& cameraPos,
|
||||
cameraPos / (1000.0 * distanceconstants::Parsec)
|
||||
);
|
||||
size_t idx = getChildIndex(fCameraPos.x, fCameraPos.y, fCameraPos.z);
|
||||
std::shared_ptr<OctreeManager::OctreeNode> node = _root->Children[idx];
|
||||
std::shared_ptr<OctreeNode> node = _root->Children[idx];
|
||||
|
||||
while (!node->isLeaf) {
|
||||
idx = getChildIndex(
|
||||
@@ -306,7 +301,7 @@ void OctreeManager::findAndFetchNeighborNode(unsigned long long firstParentId, i
|
||||
|
||||
// Fetch first layer children if we're already at root.
|
||||
if (parentId == 8) {
|
||||
fetchChildrenNodes(_root, 0);
|
||||
fetchChildrenNodes(*_root, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -382,7 +377,7 @@ void OctreeManager::findAndFetchNeighborNode(unsigned long long firstParentId, i
|
||||
}
|
||||
|
||||
// Traverse to that parent node (as long as such a child exists!).
|
||||
std::shared_ptr<OctreeManager::OctreeNode> node = _root;
|
||||
std::shared_ptr<OctreeNode> node = _root;
|
||||
while (!indexStack.empty() && !node->Children[indexStack.top()]->isLeaf) {
|
||||
node = node->Children[indexStack.top()];
|
||||
node->hasLoadedDescendant = true;
|
||||
@@ -392,12 +387,9 @@ void OctreeManager::findAndFetchNeighborNode(unsigned long long firstParentId, i
|
||||
// Fetch all children nodes from found parent. Use multithreading to load files
|
||||
// asynchronously! Detach thread from main execution so it can execute independently.
|
||||
// Thread will then be destroyed when it has finished!
|
||||
std::thread(
|
||||
&OctreeManager::fetchChildrenNodes,
|
||||
this,
|
||||
node,
|
||||
additionalLevelsToFetch
|
||||
).detach();
|
||||
std::thread([this, node, additionalLevelsToFetch]() {
|
||||
fetchChildrenNodes(*node, additionalLevelsToFetch);
|
||||
}).detach();
|
||||
}
|
||||
|
||||
std::map<int, std::vector<float>> OctreeManager::traverseData(const glm::dmat4& mvp,
|
||||
@@ -452,14 +444,16 @@ std::map<int, std::vector<float>> OctreeManager::traverseData(const glm::dmat4&
|
||||
glm::dvec3 pos = glm::dvec3(x, y, z) * 1000.0 * distanceconstants::Parsec;
|
||||
corners[i] = glm::dvec4(pos, 1.0);
|
||||
}
|
||||
if (!_culler->isVisible(corners, mvp)) return renderData;
|
||||
if (!_culler->isVisible(corners, mvp)) {
|
||||
return renderData;
|
||||
}
|
||||
glm::vec2 nodeSize = _culler->getNodeSizeInPixels(corners, mvp, screenSize);
|
||||
float totalPixels = nodeSize.x * nodeSize.y;
|
||||
if (totalPixels < _minTotalPixelsLod * 2) {
|
||||
// Remove LOD from first layer of children.
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
std::map<int, std::vector<float>> tmpData = removeNodeFromCache(
|
||||
_root->Children[i],
|
||||
*_root->Children[i],
|
||||
deltaStars
|
||||
);
|
||||
renderData.insert(tmpData.begin(), tmpData.end());
|
||||
@@ -473,7 +467,7 @@ std::map<int, std::vector<float>> OctreeManager::traverseData(const glm::dmat4&
|
||||
}
|
||||
|
||||
std::map<int, std::vector<float>> tmpData = checkNodeIntersection(
|
||||
_root->Children[i],
|
||||
*_root->Children[i],
|
||||
mvp,
|
||||
screenSize,
|
||||
deltaStars,
|
||||
@@ -531,7 +525,7 @@ std::vector<float> OctreeManager::getAllData(gaia::RenderOption option) {
|
||||
std::vector<float> fullData;
|
||||
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
auto tmpData = getNodeData(_root->Children[i], option);
|
||||
std::vector<float> tmpData = getNodeData(*_root->Children[i], option);
|
||||
fullData.insert(fullData.end(), tmpData.begin(), tmpData.end());
|
||||
}
|
||||
return fullData;
|
||||
@@ -540,11 +534,11 @@ std::vector<float> OctreeManager::getAllData(gaia::RenderOption option) {
|
||||
void OctreeManager::clearAllData(int branchIndex) {
|
||||
// Don't clear everything if not needed.
|
||||
if (branchIndex != -1) {
|
||||
clearNodeData(_root->Children[branchIndex]);
|
||||
clearNodeData(*_root->Children[branchIndex]);
|
||||
}
|
||||
else {
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
clearNodeData(_root->Children[i]);
|
||||
clearNodeData(*_root->Children[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -559,24 +553,24 @@ void OctreeManager::writeToFile(std::ofstream& outFileStream, bool writeData) {
|
||||
|
||||
// Use pre-traversal (Morton code / Z-order).
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
writeNodeToFile(outFileStream, _root->Children[i], writeData);
|
||||
writeNodeToFile(outFileStream, *_root->Children[i], writeData);
|
||||
}
|
||||
}
|
||||
|
||||
void OctreeManager::writeNodeToFile(std::ofstream& outFileStream,
|
||||
std::shared_ptr<OctreeNode> node, bool writeData)
|
||||
void OctreeManager::writeNodeToFile(std::ofstream& outFileStream, const OctreeNode& node,
|
||||
bool writeData)
|
||||
{
|
||||
// Write node structure.
|
||||
bool isLeaf = node->isLeaf;
|
||||
int32_t numStars = static_cast<int32_t>(node->numStars);
|
||||
bool isLeaf = node.isLeaf;
|
||||
int32_t numStars = static_cast<int32_t>(node.numStars);
|
||||
outFileStream.write(reinterpret_cast<const char*>(&isLeaf), sizeof(bool));
|
||||
outFileStream.write(reinterpret_cast<const char*>(&numStars), sizeof(int32_t));
|
||||
|
||||
// Write node data if specified
|
||||
if (writeData) {
|
||||
std::vector<float> nodeData = node->posData;
|
||||
nodeData.insert(nodeData.end(), node->colData.begin(), node->colData.end());
|
||||
nodeData.insert(nodeData.end(), node->velData.begin(), node->velData.end());
|
||||
std::vector<float> nodeData = node.posData;
|
||||
nodeData.insert(nodeData.end(), node.colData.begin(), node.colData.end());
|
||||
nodeData.insert(nodeData.end(), node.velData.begin(), node.velData.end());
|
||||
int32_t nDataSize = static_cast<int32_t>(nodeData.size());
|
||||
size_t nBytes = nDataSize * sizeof(nodeData[0]);
|
||||
|
||||
@@ -587,9 +581,9 @@ void OctreeManager::writeNodeToFile(std::ofstream& outFileStream,
|
||||
}
|
||||
|
||||
// Write children to file (in Morton order) if we're in an inner node.
|
||||
if (!node->isLeaf) {
|
||||
if (!node.isLeaf) {
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
writeNodeToFile(outFileStream, node->Children[i], writeData);
|
||||
writeNodeToFile(outFileStream, *node.Children[i], writeData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -638,13 +632,13 @@ int OctreeManager::readFromFile(std::ifstream& inFileStream, bool readData,
|
||||
|
||||
// Use the same technique to construct octree from file.
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
nStarsRead += readNodeFromFile(inFileStream, _root->Children[i], readData);
|
||||
nStarsRead += readNodeFromFile(inFileStream, *_root->Children[i], readData);
|
||||
}
|
||||
return nStarsRead;
|
||||
}
|
||||
|
||||
int OctreeManager::readNodeFromFile(std::ifstream& inFileStream,
|
||||
std::shared_ptr<OctreeNode> node, bool readData)
|
||||
int OctreeManager::readNodeFromFile(std::ifstream& inFileStream, OctreeNode& node,
|
||||
bool readData)
|
||||
{
|
||||
// Read node structure.
|
||||
bool isLeaf;
|
||||
@@ -653,8 +647,8 @@ int OctreeManager::readNodeFromFile(std::ifstream& inFileStream,
|
||||
inFileStream.read(reinterpret_cast<char*>(&isLeaf), sizeof(bool));
|
||||
inFileStream.read(reinterpret_cast<char*>(&numStars), sizeof(int32_t));
|
||||
|
||||
node->isLeaf = isLeaf;
|
||||
node->numStars = numStars;
|
||||
node.isLeaf = isLeaf;
|
||||
node.numStars = numStars;
|
||||
|
||||
// Read node data if specified.
|
||||
if (readData) {
|
||||
@@ -671,18 +665,18 @@ int OctreeManager::readNodeFromFile(std::ifstream& inFileStream,
|
||||
auto posEnd = fetchedData.begin() + (starsInNode * POS_SIZE);
|
||||
auto colEnd = posEnd + (starsInNode * COL_SIZE);
|
||||
auto velEnd = colEnd + (starsInNode * VEL_SIZE);
|
||||
node->posData = std::vector<float>(fetchedData.begin(), posEnd);
|
||||
node->colData = std::vector<float>(posEnd, colEnd);
|
||||
node->velData = std::vector<float>(colEnd, velEnd);
|
||||
node.posData = std::vector<float>(fetchedData.begin(), posEnd);
|
||||
node.colData = std::vector<float>(posEnd, colEnd);
|
||||
node.velData = std::vector<float>(colEnd, velEnd);
|
||||
}
|
||||
}
|
||||
|
||||
// Create children if we're in an inner node and read from the corresponding nodes.
|
||||
if (!node->isLeaf) {
|
||||
if (!node.isLeaf) {
|
||||
numStars = 0;
|
||||
createNodeChildren(node);
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
numStars += readNodeFromFile(inFileStream, node->Children[i], readData);
|
||||
numStars += readNodeFromFile(inFileStream, *node.Children[i], readData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,21 +690,20 @@ void OctreeManager::writeToMultipleFiles(const std::string& outFolderPath,
|
||||
// Write entire branch to disc, with one file per node.
|
||||
std::string outFilePrefix = outFolderPath + std::to_string(branchIndex);
|
||||
// More threads doesn't make it much faster, disk speed still the limiter.
|
||||
writeNodeToMultipleFiles(outFilePrefix, _root->Children[branchIndex], false);
|
||||
writeNodeToMultipleFiles(outFilePrefix, *_root->Children[branchIndex], false);
|
||||
|
||||
// Clear all data in branch.
|
||||
LINFO(fmt::format("Clear all data from branch {} in octree", branchIndex));
|
||||
clearNodeData(_root->Children[branchIndex]);
|
||||
clearNodeData(*_root->Children[branchIndex]);
|
||||
}
|
||||
|
||||
void OctreeManager::writeNodeToMultipleFiles(const std::string& outFilePrefix,
|
||||
std::shared_ptr<OctreeNode> node,
|
||||
bool threadWrites)
|
||||
OctreeNode& node, bool threadWrites)
|
||||
{
|
||||
// Prepare node data, save nothing else.
|
||||
std::vector<float> nodeData = node->posData;
|
||||
nodeData.insert(nodeData.end(), node->colData.begin(), node->colData.end());
|
||||
nodeData.insert(nodeData.end(), node->velData.begin(), node->velData.end());
|
||||
std::vector<float> nodeData = node.posData;
|
||||
nodeData.insert(nodeData.end(), node.colData.begin(), node.colData.end());
|
||||
nodeData.insert(nodeData.end(), node.velData.begin(), node.velData.end());
|
||||
int32_t nDataSize = static_cast<int32_t>(nodeData.size());
|
||||
size_t nBytes = nDataSize * sizeof(nodeData[0]);
|
||||
|
||||
@@ -735,23 +728,21 @@ void OctreeManager::writeNodeToMultipleFiles(const std::string& outFilePrefix,
|
||||
}
|
||||
|
||||
// Recursively write children to file (in Morton order) if we're in an inner node.
|
||||
if (!node->isLeaf) {
|
||||
if (!node.isLeaf) {
|
||||
std::vector<std::thread> writeThreads(8);
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
std::string newOutFilePrefix = outFilePrefix + std::to_string(i);
|
||||
if (threadWrites) {
|
||||
// Divide writing to new threads to speed up the process.
|
||||
std::thread t(
|
||||
&OctreeManager::writeNodeToMultipleFiles,
|
||||
this,
|
||||
newOutFilePrefix,
|
||||
node->Children[i],
|
||||
false
|
||||
[this, newOutFilePrefix, n = node.Children[i]]() {
|
||||
writeNodeToMultipleFiles(newOutFilePrefix, *n, false);
|
||||
}
|
||||
);
|
||||
writeThreads[i] = std::move(t);
|
||||
}
|
||||
else {
|
||||
writeNodeToMultipleFiles(newOutFilePrefix, node->Children[i], false);
|
||||
writeNodeToMultipleFiles(newOutFilePrefix, *node.Children[i], false);
|
||||
}
|
||||
}
|
||||
if (threadWrites) {
|
||||
@@ -763,34 +754,33 @@ void OctreeManager::writeNodeToMultipleFiles(const std::string& outFilePrefix,
|
||||
}
|
||||
}
|
||||
|
||||
void OctreeManager::fetchChildrenNodes(
|
||||
std::shared_ptr<OctreeManager::OctreeNode> parentNode,
|
||||
int additionalLevelsToFetch)
|
||||
void OctreeManager::fetchChildrenNodes(OctreeNode& parentNode,
|
||||
int additionalLevelsToFetch)
|
||||
{
|
||||
// Lock node to make sure nobody else are trying to load the same children.
|
||||
std::lock_guard<std::mutex> lock(parentNode->loadingLock);
|
||||
std::lock_guard lock(parentNode.loadingLock);
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
// Fetch node data if we're streaming and it doesn't exist in RAM yet.
|
||||
// (As long as there is any RAM budget left and node actually has any data!)
|
||||
if (!parentNode->Children[i]->isLoaded &&
|
||||
(parentNode->Children[i]->numStars > 0) &&
|
||||
_cpuRamBudget > static_cast<long long>(parentNode->Children[i]->numStars
|
||||
if (!parentNode.Children[i]->isLoaded &&
|
||||
(parentNode.Children[i]->numStars > 0) &&
|
||||
_cpuRamBudget > static_cast<long long>(parentNode.Children[i]->numStars
|
||||
* (POS_SIZE + COL_SIZE + VEL_SIZE) * 4))
|
||||
{
|
||||
fetchNodeDataFromFile(parentNode->Children[i]);
|
||||
fetchNodeDataFromFile(*parentNode.Children[i]);
|
||||
}
|
||||
|
||||
// Fetch all Children's Children if recursive is set to true!
|
||||
if (additionalLevelsToFetch != 0 && !parentNode->Children[i]->isLeaf) {
|
||||
fetchChildrenNodes(parentNode->Children[i], --additionalLevelsToFetch);
|
||||
if (additionalLevelsToFetch != 0 && !parentNode.Children[i]->isLeaf) {
|
||||
fetchChildrenNodes(*parentNode.Children[i], --additionalLevelsToFetch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OctreeManager::fetchNodeDataFromFile(std::shared_ptr<OctreeNode> node) {
|
||||
void OctreeManager::fetchNodeDataFromFile(OctreeNode& node) {
|
||||
// Remove root ID ("8") from index before loading file.
|
||||
std::string posId = std::to_string(node->octreePositionIndex);
|
||||
std::string posId = std::to_string(node.octreePositionIndex);
|
||||
posId.erase(posId.begin());
|
||||
|
||||
std::string inFilePath = _streamFolderPath + posId + BINARY_SUFFIX;
|
||||
@@ -815,15 +805,15 @@ void OctreeManager::fetchNodeDataFromFile(std::shared_ptr<OctreeNode> node) {
|
||||
auto posEnd = readData.begin() + (starsInNode * POS_SIZE);
|
||||
auto colEnd = posEnd + (starsInNode * COL_SIZE);
|
||||
auto velEnd = colEnd + (starsInNode * VEL_SIZE);
|
||||
node->posData = std::vector<float>(readData.begin(), posEnd);
|
||||
node->colData = std::vector<float>(posEnd, colEnd);
|
||||
node->velData = std::vector<float>(colEnd, velEnd);
|
||||
node.posData = std::vector<float>(readData.begin(), posEnd);
|
||||
node.colData = std::vector<float>(posEnd, colEnd);
|
||||
node.velData = std::vector<float>(colEnd, velEnd);
|
||||
|
||||
// Keep track of nodes that are loaded and update CPU RAM budget.
|
||||
node->isLoaded = true;
|
||||
node.isLoaded = true;
|
||||
if (!_datasetFitInMemory) {
|
||||
std::lock_guard g(_leastRecentlyFetchedNodesMutex);
|
||||
_leastRecentlyFetchedNodes.push(node->octreePositionIndex);
|
||||
_leastRecentlyFetchedNodes.push(node.octreePositionIndex);
|
||||
}
|
||||
_cpuRamBudget -= nBytes;
|
||||
}
|
||||
@@ -846,37 +836,37 @@ void OctreeManager::removeNodesFromRam(
|
||||
}
|
||||
|
||||
// Traverse to node and remove it.
|
||||
std::shared_ptr<OctreeManager::OctreeNode> node = _root;
|
||||
std::shared_ptr<OctreeNode> node = _root;
|
||||
std::vector<std::shared_ptr<OctreeNode>> ancestors;
|
||||
while (!indexStack.empty()) {
|
||||
ancestors.push_back(node);
|
||||
node = node->Children[indexStack.top()];
|
||||
indexStack.pop();
|
||||
}
|
||||
removeNode(node);
|
||||
removeNode(*node);
|
||||
|
||||
propagateUnloadedNodes(ancestors);
|
||||
}
|
||||
}
|
||||
|
||||
void OctreeManager::removeNode(std::shared_ptr<OctreeManager::OctreeNode> node) {
|
||||
void OctreeManager::removeNode(OctreeNode& node) {
|
||||
// Lock node to make sure nobody else is trying to access it while removing.
|
||||
std::lock_guard lock(node->loadingLock);
|
||||
std::lock_guard lock(node.loadingLock);
|
||||
|
||||
int nBytes = static_cast<int>(
|
||||
node->numStars * _valuesPerStar * sizeof(node->posData[0])
|
||||
node.numStars * _valuesPerStar * sizeof(node.posData[0])
|
||||
);
|
||||
// Keep track of which nodes that are loaded and update CPU RAM budget.
|
||||
node->isLoaded = false;
|
||||
node.isLoaded = false;
|
||||
_cpuRamBudget += nBytes;
|
||||
|
||||
// Clear data
|
||||
node->posData.clear();
|
||||
node->posData.shrink_to_fit();
|
||||
node->colData.clear();
|
||||
node->colData.shrink_to_fit();
|
||||
node->velData.clear();
|
||||
node->velData.shrink_to_fit();
|
||||
node.posData.clear();
|
||||
node.posData.shrink_to_fit();
|
||||
node.colData.clear();
|
||||
node.colData.shrink_to_fit();
|
||||
node.velData.clear();
|
||||
node.velData.shrink_to_fit();
|
||||
}
|
||||
|
||||
void OctreeManager::propagateUnloadedNodes(
|
||||
@@ -966,10 +956,10 @@ size_t OctreeManager::getChildIndex(float posX, float posY, float posZ, float or
|
||||
return index;
|
||||
}
|
||||
|
||||
bool OctreeManager::insertInNode(std::shared_ptr<OctreeNode> node,
|
||||
const std::vector<float>& starValues, int depth)
|
||||
bool OctreeManager::insertInNode(OctreeNode& node, const std::vector<float>& starValues,
|
||||
int depth)
|
||||
{
|
||||
if (node->isLeaf && node->numStars < MAX_STARS_PER_NODE) {
|
||||
if (node.isLeaf && node.numStars < MAX_STARS_PER_NODE) {
|
||||
// Node is a leaf and it's not yet full -> insert star.
|
||||
storeStarData(node, starValues);
|
||||
|
||||
@@ -978,7 +968,7 @@ bool OctreeManager::insertInNode(std::shared_ptr<OctreeNode> node,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (node->isLeaf) {
|
||||
else if (node.isLeaf) {
|
||||
// Too many stars in leaf node, subdivide into 8 new nodes.
|
||||
// Create children and clean up parent.
|
||||
createNodeChildren(node);
|
||||
@@ -986,15 +976,15 @@ bool OctreeManager::insertInNode(std::shared_ptr<OctreeNode> node,
|
||||
// Distribute stars from parent node into children.
|
||||
for (size_t n = 0; n < MAX_STARS_PER_NODE; ++n) {
|
||||
// Position data.
|
||||
auto posBegin = node->posData.begin() + n * POS_SIZE;
|
||||
auto posBegin = node.posData.begin() + n * POS_SIZE;
|
||||
auto posEnd = posBegin + POS_SIZE;
|
||||
std::vector<float> tmpValues(posBegin, posEnd);
|
||||
// Color data.
|
||||
auto colBegin = node->colData.begin() + n * COL_SIZE;
|
||||
auto colBegin = node.colData.begin() + n * COL_SIZE;
|
||||
auto colEnd = colBegin + COL_SIZE;
|
||||
tmpValues.insert(tmpValues.end(), colBegin, colEnd);
|
||||
// Velocity data.
|
||||
auto velBegin = node->velData.begin() + n * VEL_SIZE;
|
||||
auto velBegin = node.velData.begin() + n * VEL_SIZE;
|
||||
auto velEnd = velBegin + VEL_SIZE;
|
||||
tmpValues.insert(tmpValues.end(), velBegin, velEnd);
|
||||
|
||||
@@ -1003,16 +993,16 @@ bool OctreeManager::insertInNode(std::shared_ptr<OctreeNode> node,
|
||||
tmpValues[0],
|
||||
tmpValues[1],
|
||||
tmpValues[2],
|
||||
node->originX,
|
||||
node->originY,
|
||||
node->originZ
|
||||
node.originX,
|
||||
node.originY,
|
||||
node.originZ
|
||||
);
|
||||
insertInNode(node->Children[index], tmpValues, depth);
|
||||
insertInNode(*node.Children[index], tmpValues, depth);
|
||||
}
|
||||
|
||||
// Sort magnitudes in inner node.
|
||||
// (The last value will be used as comparison for what to store in LOD cache.)
|
||||
std::sort(node->magOrder.begin(), node->magOrder.end());
|
||||
std::sort(node.magOrder.begin(), node.magOrder.end());
|
||||
}
|
||||
|
||||
// Node is an inner node, keep recursion going.
|
||||
@@ -1021,96 +1011,94 @@ bool OctreeManager::insertInNode(std::shared_ptr<OctreeNode> node,
|
||||
starValues[0],
|
||||
starValues[1],
|
||||
starValues[2],
|
||||
node->originX,
|
||||
node->originY,
|
||||
node->originZ
|
||||
node.originX,
|
||||
node.originY,
|
||||
node.originZ
|
||||
);
|
||||
|
||||
// Determine if new star should be kept in our LOD cache.
|
||||
// Keeps track of the brightest nodes in children.
|
||||
if (starValues[POS_SIZE] < node->magOrder[MAX_STARS_PER_NODE - 1].first) {
|
||||
if (starValues[POS_SIZE] < node.magOrder[MAX_STARS_PER_NODE - 1].first) {
|
||||
storeStarData(node, starValues);
|
||||
}
|
||||
|
||||
return insertInNode(node->Children[index], starValues, ++depth);
|
||||
return insertInNode(*node.Children[index], starValues, ++depth);
|
||||
}
|
||||
|
||||
void OctreeManager::sliceNodeLodCache(std::shared_ptr<OctreeNode> node) {
|
||||
void OctreeManager::sliceNodeLodCache(OctreeNode& node) {
|
||||
// Slice stored LOD data in inner nodes.
|
||||
if (!node->isLeaf) {
|
||||
if (!node.isLeaf) {
|
||||
// Sort by magnitude. Inverse relation (i.e. a lower magnitude means a brighter
|
||||
// star!)
|
||||
std::sort(node->magOrder.begin(), node->magOrder.end());
|
||||
node->magOrder.resize(MAX_STARS_PER_NODE);
|
||||
std::sort(node.magOrder.begin(), node.magOrder.end());
|
||||
node.magOrder.resize(MAX_STARS_PER_NODE);
|
||||
|
||||
std::vector<float> tmpPos;
|
||||
std::vector<float> tmpCol;
|
||||
std::vector<float> tmpVel;
|
||||
// Ordered map contain the MAX_STARS_PER_NODE brightest stars in all children!
|
||||
for (auto const &[absMag, placement] : node->magOrder) {
|
||||
auto posBegin = node->posData.begin() + placement * POS_SIZE;
|
||||
auto colBegin = node->colData.begin() + placement * COL_SIZE;
|
||||
auto velBegin = node->velData.begin() + placement * VEL_SIZE;
|
||||
for (auto const &[absMag, placement] : node.magOrder) {
|
||||
auto posBegin = node.posData.begin() + placement * POS_SIZE;
|
||||
auto colBegin = node.colData.begin() + placement * COL_SIZE;
|
||||
auto velBegin = node.velData.begin() + placement * VEL_SIZE;
|
||||
tmpPos.insert(tmpPos.end(), posBegin, posBegin + POS_SIZE);
|
||||
tmpCol.insert(tmpCol.end(), colBegin, colBegin + COL_SIZE);
|
||||
tmpVel.insert(tmpVel.end(), velBegin, velBegin + VEL_SIZE);
|
||||
}
|
||||
node->posData = std::move(tmpPos);
|
||||
node->colData = std::move(tmpCol);
|
||||
node->velData = std::move(tmpVel);
|
||||
node->numStars = node->magOrder.size(); // = MAX_STARS_PER_NODE
|
||||
node.posData = std::move(tmpPos);
|
||||
node.colData = std::move(tmpCol);
|
||||
node.velData = std::move(tmpVel);
|
||||
node.numStars = node.magOrder.size(); // = MAX_STARS_PER_NODE
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
sliceNodeLodCache(node->Children[i]);
|
||||
sliceNodeLodCache(*node.Children[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OctreeManager::storeStarData(std::shared_ptr<OctreeNode> node,
|
||||
const std::vector<float>& starValues)
|
||||
void OctreeManager::storeStarData(OctreeNode& node, const std::vector<float>& starValues)
|
||||
{
|
||||
// Insert star data at the back of vectors and store a vector with pairs consisting of
|
||||
// star magnitude and insert index for later sorting and slicing of LOD cache.
|
||||
float mag = starValues[POS_SIZE];
|
||||
node->magOrder.insert(node->magOrder.end(), std::make_pair(mag, node->numStars));
|
||||
node->numStars++;
|
||||
node.magOrder.insert(node.magOrder.end(), std::make_pair(mag, node.numStars));
|
||||
node.numStars++;
|
||||
|
||||
// If LOD is growing too large then sort it and resize to [chunk size] to avoid too
|
||||
// much RAM usage and increase threshold for adding new stars.
|
||||
if (node->magOrder.size() > MAX_STARS_PER_NODE * 2) {
|
||||
std::sort(node->magOrder.begin(), node->magOrder.end());
|
||||
node->magOrder.resize(MAX_STARS_PER_NODE);
|
||||
if (node.magOrder.size() > MAX_STARS_PER_NODE * 2) {
|
||||
std::sort(node.magOrder.begin(), node.magOrder.end());
|
||||
node.magOrder.resize(MAX_STARS_PER_NODE);
|
||||
}
|
||||
|
||||
auto posEnd = starValues.begin() + POS_SIZE;
|
||||
auto colEnd = posEnd + COL_SIZE;
|
||||
node->posData.insert(node->posData.end(), starValues.begin(), posEnd);
|
||||
node->colData.insert(node->colData.end(), posEnd, colEnd);
|
||||
node->velData.insert(node->velData.end(), colEnd, starValues.end());
|
||||
node.posData.insert(node.posData.end(), starValues.begin(), posEnd);
|
||||
node.colData.insert(node.colData.end(), posEnd, colEnd);
|
||||
node.velData.insert(node.velData.end(), colEnd, starValues.end());
|
||||
}
|
||||
|
||||
std::string OctreeManager::printStarsPerNode(std::shared_ptr<OctreeNode> node,
|
||||
std::string OctreeManager::printStarsPerNode(const OctreeNode& node,
|
||||
const std::string& prefix) const
|
||||
{
|
||||
|
||||
// Print both inner and leaf nodes.
|
||||
auto str = prefix + "} : " + std::to_string(node->numStars);
|
||||
auto str = prefix + "} : " + std::to_string(node.numStars);
|
||||
|
||||
if (node->isLeaf) {
|
||||
if (node.isLeaf) {
|
||||
return str + " - [Leaf] \n";
|
||||
}
|
||||
else {
|
||||
str += fmt::format("LOD: {} - [Parent]\n", node->posData.size() / POS_SIZE);
|
||||
str += fmt::format("LOD: {} - [Parent]\n", node.posData.size() / POS_SIZE);
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
auto pref = prefix + "->" + std::to_string(i);
|
||||
str += printStarsPerNode(node->Children[i], pref);
|
||||
str += printStarsPerNode(*node.Children[i], pref);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
std::map<int, std::vector<float>> OctreeManager::checkNodeIntersection(
|
||||
std::shared_ptr<OctreeNode> node,
|
||||
std::map<int, std::vector<float>> OctreeManager::checkNodeIntersection(OctreeNode& node,
|
||||
const glm::dmat4& mvp,
|
||||
const glm::vec2& screenSize,
|
||||
int& deltaStars,
|
||||
@@ -1123,14 +1111,14 @@ std::map<int, std::vector<float>> OctreeManager::checkNodeIntersection(
|
||||
std::vector<glm::dvec4> corners(8);
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
const float x = (i % 2 == 0) ?
|
||||
node->originX + node->halfDimension :
|
||||
node->originX - node->halfDimension;
|
||||
node.originX + node.halfDimension :
|
||||
node.originX - node.halfDimension;
|
||||
const float y = (i % 4 < 2) ?
|
||||
node->originY + node->halfDimension :
|
||||
node->originY - node->halfDimension;
|
||||
node.originY + node.halfDimension :
|
||||
node.originY - node.halfDimension;
|
||||
const float z = (i < 4) ?
|
||||
node->originZ + node->halfDimension :
|
||||
node->originZ - node->halfDimension;
|
||||
node.originZ + node.halfDimension :
|
||||
node.originZ - node.halfDimension;
|
||||
glm::dvec3 pos = glm::dvec3(x, y, z) * 1000.0 * distanceconstants::Parsec;
|
||||
corners[i] = glm::dvec4(pos, 1.0);
|
||||
}
|
||||
@@ -1145,7 +1133,7 @@ std::map<int, std::vector<float>> OctreeManager::checkNodeIntersection(
|
||||
|
||||
// Remove node if it has been unloaded while still in view.
|
||||
// (While streaming big datasets.)
|
||||
if (node->bufferIndex != DEFAULT_INDEX && !node->isLoaded && _streamOctree &&
|
||||
if (node.bufferIndex != DEFAULT_INDEX && !node.isLoaded && _streamOctree &&
|
||||
!_datasetFitInMemory)
|
||||
{
|
||||
fetchedData = removeNodeFromCache(node, deltaStars);
|
||||
@@ -1153,7 +1141,7 @@ std::map<int, std::vector<float>> OctreeManager::checkNodeIntersection(
|
||||
}
|
||||
|
||||
// Take care of inner nodes.
|
||||
if (!(node->isLeaf)) {
|
||||
if (!(node.isLeaf)) {
|
||||
glm::vec2 nodeSize = _culler->getNodeSizeInPixels(corners, mvp, screenSize);
|
||||
float totalPixels = nodeSize.x * nodeSize.y;
|
||||
|
||||
@@ -1162,11 +1150,11 @@ std::map<int, std::vector<float>> OctreeManager::checkNodeIntersection(
|
||||
// (as long as it doesn't have loaded children because then we should traverse to
|
||||
// lowest loaded level and render it instead)!
|
||||
if ((totalPixels < _minTotalPixelsLod) || (_streamOctree &&
|
||||
!_datasetFitInMemory && node->isLoaded && !node->hasLoadedDescendant))
|
||||
!_datasetFitInMemory && node.isLoaded && !node.hasLoadedDescendant))
|
||||
{
|
||||
// Get correct insert index from stack if node didn't exist already. Otherwise
|
||||
// we will overwrite the old data. Key merging is not a problem here.
|
||||
if ((node->bufferIndex == DEFAULT_INDEX) || _rebuildBuffer) {
|
||||
if ((node.bufferIndex == DEFAULT_INDEX) || _rebuildBuffer) {
|
||||
// Return empty if we couldn't claim a buffer stream index.
|
||||
if (!updateBufferIndex(node)) {
|
||||
return fetchedData;
|
||||
@@ -1175,14 +1163,14 @@ std::map<int, std::vector<float>> OctreeManager::checkNodeIntersection(
|
||||
// We're in an inner node, remove indices from potential children in cache
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
std::map<int, std::vector<float>> tmpData = removeNodeFromCache(
|
||||
node->Children[i],
|
||||
*node.Children[i],
|
||||
deltaStars
|
||||
);
|
||||
fetchedData.insert(tmpData.begin(), tmpData.end());
|
||||
}
|
||||
|
||||
// Insert data and adjust stars added in this frame.
|
||||
fetchedData[node->bufferIndex] = constructInsertData(
|
||||
fetchedData[node.bufferIndex] = constructInsertData(
|
||||
node,
|
||||
option,
|
||||
deltaStars
|
||||
@@ -1194,14 +1182,14 @@ std::map<int, std::vector<float>> OctreeManager::checkNodeIntersection(
|
||||
// Return node data if node is a leaf.
|
||||
else {
|
||||
// If node already is in cache then skip it, otherwise store it.
|
||||
if ((node->bufferIndex == DEFAULT_INDEX) || _rebuildBuffer) {
|
||||
if ((node.bufferIndex == DEFAULT_INDEX) || _rebuildBuffer) {
|
||||
// Return empty if we couldn't claim a buffer stream index.
|
||||
if (!updateBufferIndex(node)) {
|
||||
return fetchedData;
|
||||
}
|
||||
|
||||
// Insert data and adjust stars added in this frame.
|
||||
fetchedData[node->bufferIndex] = constructInsertData(
|
||||
fetchedData[node.bufferIndex] = constructInsertData(
|
||||
node,
|
||||
option,
|
||||
deltaStars
|
||||
@@ -1219,7 +1207,7 @@ std::map<int, std::vector<float>> OctreeManager::checkNodeIntersection(
|
||||
// Observe that if there exists identical keys in fetchedData then those values in
|
||||
// tmpData will be ignored! Thus we store the removed keys until next render call!
|
||||
std::map<int, std::vector<float>> tmpData = checkNodeIntersection(
|
||||
node->Children[i],
|
||||
*node.Children[i],
|
||||
mvp,
|
||||
screenSize,
|
||||
deltaStars,
|
||||
@@ -1230,10 +1218,9 @@ std::map<int, std::vector<float>> OctreeManager::checkNodeIntersection(
|
||||
return fetchedData;
|
||||
}
|
||||
|
||||
std::map<int, std::vector<float>> OctreeManager::removeNodeFromCache(
|
||||
std::shared_ptr<OctreeNode> node,
|
||||
int& deltaStars,
|
||||
bool recursive)
|
||||
std::map<int, std::vector<float>> OctreeManager::removeNodeFromCache(OctreeNode& node,
|
||||
int& deltaStars,
|
||||
bool recursive)
|
||||
{
|
||||
std::map<int, std::vector<float>> keysToRemove;
|
||||
|
||||
@@ -1241,24 +1228,24 @@ std::map<int, std::vector<float>> OctreeManager::removeNodeFromCache(
|
||||
//if (_rebuildBuffer) return keysToRemove;
|
||||
|
||||
// Check if this node was rendered == had a specified index.
|
||||
if (node->bufferIndex != DEFAULT_INDEX) {
|
||||
if (node.bufferIndex != DEFAULT_INDEX) {
|
||||
|
||||
// Reclaim that index. We need to wait until next render call to use it again!
|
||||
_removedKeysInPrevCall.insert(node->bufferIndex);
|
||||
_removedKeysInPrevCall.insert(node.bufferIndex);
|
||||
|
||||
// Insert dummy node at offset index that should be removed from render.
|
||||
keysToRemove[node->bufferIndex] = std::vector<float>();
|
||||
keysToRemove[node.bufferIndex] = std::vector<float>();
|
||||
|
||||
// Reset index and adjust stars removed this frame.
|
||||
node->bufferIndex = DEFAULT_INDEX;
|
||||
deltaStars -= static_cast<int>(node->numStars);
|
||||
node.bufferIndex = DEFAULT_INDEX;
|
||||
deltaStars -= static_cast<int>(node.numStars);
|
||||
}
|
||||
|
||||
// Check children recursively if we're in an inner node.
|
||||
if (!(node->isLeaf) && recursive) {
|
||||
if (!(node.isLeaf) && recursive) {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
std::map<int, std::vector<float>> tmpData = removeNodeFromCache(
|
||||
node->Children[i],
|
||||
*node.Children[i],
|
||||
deltaStars
|
||||
);
|
||||
keysToRemove.insert(tmpData.begin(), tmpData.end());
|
||||
@@ -1267,11 +1254,11 @@ std::map<int, std::vector<float>> OctreeManager::removeNodeFromCache(
|
||||
return keysToRemove;
|
||||
}
|
||||
|
||||
std::vector<float> OctreeManager::getNodeData(std::shared_ptr<OctreeNode> node,
|
||||
std::vector<float> OctreeManager::getNodeData(const OctreeNode& node,
|
||||
gaia::RenderOption option)
|
||||
{
|
||||
// Return node data if node is a leaf.
|
||||
if (node->isLeaf) {
|
||||
if (node.isLeaf) {
|
||||
int dStars = 0;
|
||||
return constructInsertData(node, option, dStars);
|
||||
}
|
||||
@@ -1279,88 +1266,89 @@ std::vector<float> OctreeManager::getNodeData(std::shared_ptr<OctreeNode> node,
|
||||
// If we're not in a leaf, get data from all children recursively.
|
||||
auto nodeData = std::vector<float>();
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
std::vector<float> tmpData = getNodeData(node->Children[i], option);
|
||||
std::vector<float> tmpData = getNodeData(*node.Children[i], option);
|
||||
nodeData.insert(nodeData.end(), tmpData.begin(), tmpData.end());
|
||||
}
|
||||
return nodeData;
|
||||
}
|
||||
|
||||
void OctreeManager::clearNodeData(std::shared_ptr<OctreeNode> node) {
|
||||
void OctreeManager::clearNodeData(OctreeNode& node) {
|
||||
// Clear data and its allocated memory.
|
||||
node->posData.clear();
|
||||
node->posData.shrink_to_fit();
|
||||
node->colData.clear();
|
||||
node->colData.shrink_to_fit();
|
||||
node->velData.clear();
|
||||
node->velData.shrink_to_fit();
|
||||
node.posData.clear();
|
||||
node.posData.shrink_to_fit();
|
||||
node.colData.clear();
|
||||
node.colData.shrink_to_fit();
|
||||
node.velData.clear();
|
||||
node.velData.shrink_to_fit();
|
||||
|
||||
// Clear magnitudes as well!
|
||||
//std::vector<std::pair<float, size_t>>().swap(node->magOrder);
|
||||
node->magOrder.clear();
|
||||
node.magOrder.clear();
|
||||
|
||||
if (!node->isLeaf) {
|
||||
if (!node.isLeaf) {
|
||||
// Remove data from all children recursively.
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
clearNodeData(node->Children[i]);
|
||||
clearNodeData(*node.Children[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OctreeManager::createNodeChildren(std::shared_ptr<OctreeNode> node) {
|
||||
void OctreeManager::createNodeChildren(OctreeNode& node) {
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
_numLeafNodes++;
|
||||
node->Children[i] = std::make_shared<OctreeNode>();
|
||||
node->Children[i]->isLeaf = true;
|
||||
node->Children[i]->isLoaded = false;
|
||||
node->Children[i]->hasLoadedDescendant = false;
|
||||
node->Children[i]->bufferIndex = DEFAULT_INDEX;
|
||||
node->Children[i]->octreePositionIndex = (node->octreePositionIndex * 10) + i;
|
||||
node->Children[i]->numStars = 0;
|
||||
node->Children[i]->posData = std::vector<float>();
|
||||
node->Children[i]->colData = std::vector<float>();
|
||||
node->Children[i]->velData = std::vector<float>();
|
||||
node->Children[i]->magOrder = std::vector<std::pair<float, size_t>>();
|
||||
node->Children[i]->halfDimension = node->halfDimension / 2.f;
|
||||
node.Children[i] = std::make_shared<OctreeNode>();
|
||||
node.Children[i]->isLeaf = true;
|
||||
node.Children[i]->isLoaded = false;
|
||||
node.Children[i]->hasLoadedDescendant = false;
|
||||
node.Children[i]->bufferIndex = DEFAULT_INDEX;
|
||||
node.Children[i]->octreePositionIndex = (node.octreePositionIndex * 10) + i;
|
||||
node.Children[i]->numStars = 0;
|
||||
node.Children[i]->posData = std::vector<float>();
|
||||
node.Children[i]->colData = std::vector<float>();
|
||||
node.Children[i]->velData = std::vector<float>();
|
||||
node.Children[i]->magOrder = std::vector<std::pair<float, size_t>>();
|
||||
node.Children[i]->halfDimension = node.halfDimension / 2.f;
|
||||
|
||||
// Calculate new origin.
|
||||
node->Children[i]->originX = node->originX;
|
||||
node->Children[i]->originX += (i % 2 == 0) ?
|
||||
node->Children[i]->halfDimension :
|
||||
-node->Children[i]->halfDimension;
|
||||
node->Children[i]->originY = node->originY;
|
||||
node->Children[i]->originY += (i % 4 < 2) ?
|
||||
node->Children[i]->halfDimension :
|
||||
-node->Children[i]->halfDimension;
|
||||
node->Children[i]->originZ = node->originZ;
|
||||
node->Children[i]->originZ += (i < 4) ?
|
||||
node->Children[i]->halfDimension :
|
||||
-node->Children[i]->halfDimension;
|
||||
node.Children[i]->originX = node.originX;
|
||||
node.Children[i]->originX += (i % 2 == 0) ?
|
||||
node.Children[i]->halfDimension :
|
||||
-node.Children[i]->halfDimension;
|
||||
node.Children[i]->originY = node.originY;
|
||||
node.Children[i]->originY += (i % 4 < 2) ?
|
||||
node.Children[i]->halfDimension :
|
||||
-node.Children[i]->halfDimension;
|
||||
node.Children[i]->originZ = node.originZ;
|
||||
node.Children[i]->originZ += (i < 4) ?
|
||||
node.Children[i]->halfDimension :
|
||||
-node.Children[i]->halfDimension;
|
||||
}
|
||||
|
||||
// Clean up parent.
|
||||
node->isLeaf = false;
|
||||
node.isLeaf = false;
|
||||
_numLeafNodes--;
|
||||
_numInnerNodes++;
|
||||
}
|
||||
|
||||
bool OctreeManager::updateBufferIndex(std::shared_ptr<OctreeNode> node) {
|
||||
if (node->bufferIndex != DEFAULT_INDEX) {
|
||||
bool OctreeManager::updateBufferIndex(OctreeNode& node) {
|
||||
if (node.bufferIndex != DEFAULT_INDEX) {
|
||||
// If we're rebuilding Buffer Index Cache then store indices to overwrite later.
|
||||
_removedKeysInPrevCall.insert(node->bufferIndex);
|
||||
_removedKeysInPrevCall.insert(node.bufferIndex);
|
||||
}
|
||||
|
||||
// Make sure node isn't loading/unloading as we're checking isLoaded flag.
|
||||
std::lock_guard lock(node->loadingLock);
|
||||
std::lock_guard lock(node.loadingLock);
|
||||
|
||||
// Return false if there are no more spots in our buffer, or if we're streaming and
|
||||
// node isn't loaded yet, or if node doesn't have any stars.
|
||||
if (_freeSpotsInBuffer.empty() || (_streamOctree && !node->isLoaded) ||
|
||||
node->numStars == 0) {
|
||||
if (_freeSpotsInBuffer.empty() || (_streamOctree && !node.isLoaded) ||
|
||||
node.numStars == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get correct insert index from stack.
|
||||
node->bufferIndex = _freeSpotsInBuffer.top();
|
||||
node.bufferIndex = _freeSpotsInBuffer.top();
|
||||
_freeSpotsInBuffer.pop();
|
||||
|
||||
// Keep track of how many chunks are in use (ceiling).
|
||||
@@ -1373,32 +1361,28 @@ bool OctreeManager::updateBufferIndex(std::shared_ptr<OctreeNode> node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<float> OctreeManager::constructInsertData(std::shared_ptr<OctreeNode> node,
|
||||
std::vector<float> OctreeManager::constructInsertData(const OctreeNode& node,
|
||||
gaia::RenderOption option,
|
||||
int& deltaStars)
|
||||
{
|
||||
// Return early if node doesn't contain any stars!
|
||||
if (node->numStars == 0) {
|
||||
if (node.numStars == 0) {
|
||||
return std::vector<float>();
|
||||
}
|
||||
|
||||
// Fill chunk by appending zeroes to data so we overwrite possible earlier values.
|
||||
// And more importantly so our attribute pointers knows where to read!
|
||||
auto insertData = std::vector<float>(node->posData.begin(), node->posData.end());
|
||||
auto insertData = std::vector<float>(node.posData.begin(), node.posData.end());
|
||||
if (_useVBO) {
|
||||
insertData.resize(POS_SIZE * MAX_STARS_PER_NODE, 0.f);
|
||||
}
|
||||
if (option != gaia::RenderOption::Static) {
|
||||
insertData.insert(insertData.end(), node->colData.begin(), node->colData.end());
|
||||
insertData.insert(insertData.end(), node.colData.begin(), node.colData.end());
|
||||
if (_useVBO) {
|
||||
insertData.resize((POS_SIZE + COL_SIZE) * MAX_STARS_PER_NODE, 0.f);
|
||||
}
|
||||
if (option == gaia::RenderOption::Motion) {
|
||||
insertData.insert(
|
||||
insertData.end(),
|
||||
node->velData.begin(),
|
||||
node->velData.end()
|
||||
);
|
||||
insertData.insert(insertData.end(), node.velData.begin(), node.velData.end());
|
||||
if (_useVBO) {
|
||||
insertData.resize(
|
||||
(POS_SIZE + COL_SIZE + VEL_SIZE) * MAX_STARS_PER_NODE, 0.f
|
||||
@@ -1408,7 +1392,7 @@ std::vector<float> OctreeManager::constructInsertData(std::shared_ptr<OctreeNode
|
||||
}
|
||||
|
||||
// Update deltaStars.
|
||||
deltaStars += static_cast<int>(node->numStars);
|
||||
deltaStars += static_cast<int>(node.numStars);
|
||||
return insertData;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
};
|
||||
|
||||
OctreeManager() = default;
|
||||
~OctreeManager();
|
||||
~OctreeManager() = default;
|
||||
|
||||
/**
|
||||
* Initializes a one layer Octree with root and 8 children that covers all stars.
|
||||
@@ -212,28 +212,27 @@ private:
|
||||
* If node is an inner node, then star is stores in LOD cache if it is among the
|
||||
* brightest stars in all children.
|
||||
*/
|
||||
bool insertInNode(std::shared_ptr<OctreeNode> node,
|
||||
const std::vector<float>& starValues, int depth = 1);
|
||||
bool insertInNode(OctreeNode& node, const std::vector<float>& starValues,
|
||||
int depth = 1);
|
||||
|
||||
/**
|
||||
* Slices LOD cache data in node to the MAX_STARS_PER_NODE brightest stars. This needs
|
||||
* to be called after the last star has been inserted into Octree but before it is
|
||||
* saved to file(s). Slices all descendants recursively.
|
||||
*/
|
||||
void sliceNodeLodCache(std::shared_ptr<OctreeNode> node);
|
||||
void sliceNodeLodCache(OctreeNode& node);
|
||||
|
||||
/**
|
||||
* Private help function for <code>insertInNode()</code>. Stores star data in node and
|
||||
* keeps track of the brightest stars all children.
|
||||
*/
|
||||
void storeStarData(std::shared_ptr<OctreeNode> node,
|
||||
const std::vector<float>& starValues);
|
||||
void storeStarData(OctreeNode& node, const std::vector<float>& starValues);
|
||||
|
||||
/**
|
||||
* Private help function for <code>printStarsPerNode()</code>. \returns an accumulated
|
||||
* string containing all descendant nodes.
|
||||
*/
|
||||
std::string printStarsPerNode(std::shared_ptr<OctreeNode> node,
|
||||
std::string printStarsPerNode(const OctreeNode& node,
|
||||
const std::string& prefix) const;
|
||||
|
||||
/**
|
||||
@@ -243,9 +242,9 @@ private:
|
||||
* loaded (if streaming). \param deltaStars keeps track of how many stars that were
|
||||
* added/removed this render call.
|
||||
*/
|
||||
std::map<int, std::vector<float>> checkNodeIntersection(
|
||||
std::shared_ptr<OctreeNode> node, const glm::dmat4& mvp,
|
||||
const glm::vec2& screenSize, int& deltaStars, gaia::RenderOption option);
|
||||
std::map<int, std::vector<float>> checkNodeIntersection(OctreeNode& node,
|
||||
const glm::dmat4& mvp, const glm::vec2& screenSize, int& deltaStars,
|
||||
gaia::RenderOption option);
|
||||
|
||||
/**
|
||||
* Checks if specified node existed in cache, and removes it if that's the case.
|
||||
@@ -253,31 +252,30 @@ private:
|
||||
* long as \param recursive is not set to false. \param deltaStars keeps track of how
|
||||
* many stars that were removed.
|
||||
*/
|
||||
std::map<int, std::vector<float>> removeNodeFromCache(
|
||||
std::shared_ptr<OctreeNode> node, int& deltaStars, bool recursive = true);
|
||||
std::map<int, std::vector<float>> removeNodeFromCache(OctreeNode& node,
|
||||
int& deltaStars, bool recursive = true);
|
||||
|
||||
/**
|
||||
* Get data in node and its descendants regardless if they are visible or not.
|
||||
*/
|
||||
std::vector<float> getNodeData(std::shared_ptr<OctreeNode> node,
|
||||
gaia::RenderOption option);
|
||||
std::vector<float> getNodeData(const OctreeNode& node, gaia::RenderOption option);
|
||||
|
||||
/**
|
||||
* Clear data from node and its descendants and shrink vectors to deallocate memory.
|
||||
*/
|
||||
void clearNodeData(std::shared_ptr<OctreeNode> node);
|
||||
void clearNodeData(OctreeNode& node);
|
||||
|
||||
/**
|
||||
* Contruct default children nodes for specified node.
|
||||
*/
|
||||
void createNodeChildren(std::shared_ptr<OctreeNode> node);
|
||||
void createNodeChildren(OctreeNode& node);
|
||||
|
||||
/**
|
||||
* Checks if node should be inserted into stream or not. \returns true if it should,
|
||||
* (i.e. it doesn't already exists, there is room for it in the buffer and node data
|
||||
* is loaded if streaming). \returns false otherwise.
|
||||
*/
|
||||
bool updateBufferIndex(std::shared_ptr<OctreeNode> node);
|
||||
bool updateBufferIndex(OctreeNode& node);
|
||||
|
||||
/**
|
||||
* Node should be inserted into stream. This function \returns the data to be
|
||||
@@ -286,14 +284,14 @@ private:
|
||||
*
|
||||
* \param deltaStars keeps track of how many stars that were added.
|
||||
*/
|
||||
std::vector<float> constructInsertData(std::shared_ptr<OctreeNode> node,
|
||||
std::vector<float> constructInsertData(const OctreeNode& node,
|
||||
gaia::RenderOption option, int& deltaStars);
|
||||
|
||||
/**
|
||||
* Write a node to outFileStream. \param writeData defines if data should be included
|
||||
* or if only structure should be written.
|
||||
*/
|
||||
void writeNodeToFile(std::ofstream& outFileStream, std::shared_ptr<OctreeNode> node,
|
||||
void writeNodeToFile(std::ofstream& outFileStream, const OctreeNode& node,
|
||||
bool writeData);
|
||||
|
||||
/**
|
||||
@@ -301,16 +299,15 @@ private:
|
||||
* data or only structure should be read.
|
||||
* \returns accumulated sum of all read stars in node and its descendants.
|
||||
*/
|
||||
int readNodeFromFile(std::ifstream& inFileStream, std::shared_ptr<OctreeNode> node,
|
||||
bool readData);
|
||||
int readNodeFromFile(std::ifstream& inFileStream, OctreeNode& node, bool readData);
|
||||
|
||||
/**
|
||||
* Write node data to a file. \param outFilePrefix specifies the accumulated path
|
||||
* and name of the file. If \param threadWrites is set to true then one new thread
|
||||
* will be created for each child to write its descendents.
|
||||
*/
|
||||
void writeNodeToMultipleFiles(const std::string& outFilePrefix,
|
||||
std::shared_ptr<OctreeNode> node, bool threadWrites);
|
||||
void writeNodeToMultipleFiles(const std::string& outFilePrefix, OctreeNode& node,
|
||||
bool threadWrites);
|
||||
|
||||
/**
|
||||
* Finds the neighboring node on the same level (or a higher level if there is no
|
||||
@@ -329,15 +326,14 @@ private:
|
||||
* If it is set to a negative value then all descendants will be fetched recursively.
|
||||
* Calls <code>fetchNodeDataFromFile()</code> for every child that passes the tests.
|
||||
*/
|
||||
void fetchChildrenNodes(std::shared_ptr<OctreeManager::OctreeNode> parentNode,
|
||||
int additionalLevelsToFetch);
|
||||
void fetchChildrenNodes(OctreeNode& parentNode, int additionalLevelsToFetch);
|
||||
|
||||
/**
|
||||
* Fetches data for specified node from file.
|
||||
* OBS! Only call if node file exists (i.e. node has any data, node->numStars > 0)
|
||||
* and is not already loaded.
|
||||
*/
|
||||
void fetchNodeDataFromFile(std::shared_ptr<OctreeNode> node);
|
||||
void fetchNodeDataFromFile(OctreeNode& node);
|
||||
|
||||
/**
|
||||
* Loops though all nodes in \param nodesToRemove and clears them from RAM.
|
||||
@@ -350,7 +346,7 @@ private:
|
||||
* Removes data in specified node from main memory and updates RAM budget and flags
|
||||
* accordingly.
|
||||
*/
|
||||
void removeNode(std::shared_ptr<OctreeManager::OctreeNode> node);
|
||||
void removeNode(OctreeNode& node);
|
||||
|
||||
/**
|
||||
* Loops through \param ancestorNodes backwards and checks if parent node has any
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include <ghoul/systemcapabilities/generalcapabilitiescomponent.h>
|
||||
#include <array>
|
||||
#include <fstream>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "RenderableGaiaStars";
|
||||
@@ -856,8 +856,6 @@ RenderableGaiaStars::RenderableGaiaStars(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_gpuStreamBudgetProperty);
|
||||
}
|
||||
|
||||
RenderableGaiaStars::~RenderableGaiaStars() {}
|
||||
|
||||
bool RenderableGaiaStars::isReady() const {
|
||||
return _program && _programTM;
|
||||
}
|
||||
@@ -1157,7 +1155,9 @@ void RenderableGaiaStars::render(const RenderData& data, RendererTasks&) {
|
||||
_previousCameraRotation = data.camera.rotationQuaternion();
|
||||
return;
|
||||
}
|
||||
else _firstDrawCalls = false;
|
||||
else {
|
||||
_firstDrawCalls = false;
|
||||
}
|
||||
|
||||
// Update which nodes that are stored in memory as the camera moves around
|
||||
// (if streaming)
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace documentation { struct Documentation; }
|
||||
class RenderableGaiaStars : public Renderable {
|
||||
public:
|
||||
explicit RenderableGaiaStars(const ghoul::Dictionary& dictionary);
|
||||
virtual ~RenderableGaiaStars();
|
||||
virtual ~RenderableGaiaStars() = default;
|
||||
|
||||
void initializeGL() override;
|
||||
void deinitializeGL() override;
|
||||
|
||||
@@ -195,28 +195,27 @@ ConstructOctreeTask::ConstructOctreeTask(const ghoul::Dictionary& dictionary) {
|
||||
}
|
||||
}
|
||||
|
||||
ConstructOctreeTask::~ConstructOctreeTask() {}
|
||||
|
||||
std::string ConstructOctreeTask::description() {
|
||||
return "Read bin file (or files in folder): " + _inFileOrFolderPath + "\n "
|
||||
"and write octree data file (or files) into: " + _outFileOrFolderPath + "\n";
|
||||
}
|
||||
|
||||
void ConstructOctreeTask::perform(const Task::ProgressCallback& progressCallback) {
|
||||
progressCallback(0.0f);
|
||||
void ConstructOctreeTask::perform(const Task::ProgressCallback& onProgress) {
|
||||
onProgress(0.0f);
|
||||
|
||||
if (_singleFileInput) {
|
||||
constructOctreeFromSingleFile(progressCallback);
|
||||
constructOctreeFromSingleFile(onProgress);
|
||||
}
|
||||
else {
|
||||
constructOctreeFromFolder(progressCallback);
|
||||
constructOctreeFromFolder(onProgress);
|
||||
}
|
||||
|
||||
progressCallback(1.0f);
|
||||
onProgress(1.0f);
|
||||
}
|
||||
|
||||
void ConstructOctreeTask::constructOctreeFromSingleFile(
|
||||
const Task::ProgressCallback& progressCallback) {
|
||||
const Task::ProgressCallback& progressCallback)
|
||||
{
|
||||
std::vector<float> fullData;
|
||||
int32_t nValues = 0;
|
||||
int32_t nValuesPerStar = 0;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace documentation { struct Documentation; }
|
||||
class ConstructOctreeTask : public Task {
|
||||
public:
|
||||
ConstructOctreeTask(const ghoul::Dictionary& dictionary);
|
||||
virtual ~ConstructOctreeTask();
|
||||
virtual ~ConstructOctreeTask() = default;
|
||||
|
||||
std::string description() override;
|
||||
void perform(const Task::ProgressCallback& onProgress) override;
|
||||
|
||||
@@ -35,17 +35,16 @@ namespace {
|
||||
|
||||
namespace openspace::gaia {
|
||||
|
||||
ReadFileJob::ReadFileJob(const std::string& filePath,
|
||||
const std::vector<std::string>& allColumns, int firstRow,
|
||||
int lastRow, size_t nDefaultCols, int nValuesPerStar,
|
||||
std::shared_ptr<FitsFileReader> fitsReader)
|
||||
: _inFilePath(filePath)
|
||||
, _allColumns(allColumns)
|
||||
ReadFileJob::ReadFileJob(std::string filePath, std::vector<std::string> allColumns,
|
||||
int firstRow, int lastRow, size_t nDefaultCols,
|
||||
int nValuesPerStar, std::shared_ptr<FitsFileReader> fitsReader)
|
||||
: _inFilePath(std::move(filePath))
|
||||
, _allColumns(std::move(allColumns))
|
||||
, _firstRow(firstRow)
|
||||
, _lastRow(lastRow)
|
||||
, _nDefaultCols(nDefaultCols)
|
||||
, _nValuesPerStar(nValuesPerStar)
|
||||
, _fitsFileReader(fitsReader)
|
||||
, _fitsFileReader(std::move(fitsReader))
|
||||
, _octants(8)
|
||||
{}
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ struct ReadFileJob : public Job<std::vector<std::vector<float>>> {
|
||||
* If \param lastRow < firstRow then entire table will be read.
|
||||
* \param nValuesPerStar defines how many values that will be stored per star.
|
||||
*/
|
||||
ReadFileJob(const std::string& filePath, const std::vector<std::string>& allColumns,
|
||||
int firstRow, int lastRow, size_t nDefaultCols, int nValuesPerStar,
|
||||
ReadFileJob(std::string filePath, std::vector<std::string> allColumns, int firstRow,
|
||||
int lastRow, size_t nDefaultCols, int nValuesPerStar,
|
||||
std::shared_ptr<FitsFileReader> fitsReader);
|
||||
|
||||
~ReadFileJob() = default;
|
||||
|
||||
@@ -108,17 +108,17 @@ std::string ReadFitsTask::description() {
|
||||
);
|
||||
}
|
||||
|
||||
void ReadFitsTask::perform(const Task::ProgressCallback& progressCallback) {
|
||||
progressCallback(0.f);
|
||||
void ReadFitsTask::perform(const Task::ProgressCallback& onProgress) {
|
||||
onProgress(0.f);
|
||||
|
||||
if (_singleFileProcess) {
|
||||
readSingleFitsFile(progressCallback);
|
||||
readSingleFitsFile(onProgress);
|
||||
}
|
||||
else {
|
||||
readAllFitsFilesFromFolder(progressCallback);
|
||||
readAllFitsFilesFromFolder(onProgress);
|
||||
}
|
||||
|
||||
progressCallback(1.f);
|
||||
onProgress(1.f);
|
||||
}
|
||||
|
||||
void ReadFitsTask::readSingleFitsFile(const Task::ProgressCallback& progressCallback) {
|
||||
|
||||
@@ -59,15 +59,15 @@ std::string ReadSpeckTask::description() {
|
||||
);
|
||||
}
|
||||
|
||||
void ReadSpeckTask::perform(const Task::ProgressCallback& progressCallback) {
|
||||
progressCallback(0.f);
|
||||
void ReadSpeckTask::perform(const Task::ProgressCallback& onProgress) {
|
||||
onProgress(0.f);
|
||||
|
||||
int32_t nRenderValues = 0;
|
||||
|
||||
FitsFileReader fileReader(false);
|
||||
std::vector<float> fullData = fileReader.readSpeckFile(_inFilePath, nRenderValues);
|
||||
|
||||
progressCallback(0.9f);
|
||||
onProgress(0.9f);
|
||||
|
||||
std::ofstream fileStream(_outFilePath, std::ofstream::binary);
|
||||
if (fileStream.good()) {
|
||||
@@ -89,7 +89,7 @@ void ReadSpeckTask::perform(const Task::ProgressCallback& progressCallback) {
|
||||
LERROR(fmt::format("Error opening file: {} as output data file.", _outFilePath));
|
||||
}
|
||||
|
||||
progressCallback(1.f);
|
||||
onProgress(1.f);
|
||||
}
|
||||
|
||||
documentation::Documentation ReadSpeckTask::Documentation() {
|
||||
|
||||
@@ -48,8 +48,6 @@ GalaxyRaycaster::GalaxyRaycaster(ghoul::opengl::Texture& texture)
|
||||
, _textureUnit(nullptr)
|
||||
{}
|
||||
|
||||
GalaxyRaycaster::~GalaxyRaycaster() {}
|
||||
|
||||
void GalaxyRaycaster::initialize() {
|
||||
_boundingBox.initialize();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class GalaxyRaycaster : public VolumeRaycaster {
|
||||
public:
|
||||
GalaxyRaycaster(ghoul::opengl::Texture& texture);
|
||||
|
||||
virtual ~GalaxyRaycaster();
|
||||
virtual ~GalaxyRaycaster() = default;
|
||||
void initialize();
|
||||
|
||||
void renderEntryPoints(const RenderData& data,
|
||||
|
||||
@@ -135,8 +135,6 @@ namespace openspace {
|
||||
pointsDictionary.getValue("Scaling", _pointScaling);
|
||||
}
|
||||
|
||||
RenderableGalaxy::~RenderableGalaxy() {}
|
||||
|
||||
void RenderableGalaxy::initializeGL() {
|
||||
// Aspect is currently hardcoded to cubic voxels.
|
||||
_aspect = static_cast<glm::vec3>(_volumeDimensions);
|
||||
@@ -167,14 +165,14 @@ void RenderableGalaxy::initializeGL() {
|
||||
_raycaster = std::make_unique<GalaxyRaycaster>(*_texture);
|
||||
_raycaster->initialize();
|
||||
|
||||
global::raycasterManager.attachRaycaster(*_raycaster.get());
|
||||
global::raycasterManager.attachRaycaster(*_raycaster);
|
||||
|
||||
auto onChange = [&](bool enabled) {
|
||||
if (enabled) {
|
||||
global::raycasterManager.attachRaycaster(*_raycaster.get());
|
||||
global::raycasterManager.attachRaycaster(*_raycaster);
|
||||
}
|
||||
else {
|
||||
global::raycasterManager.detachRaycaster(*_raycaster.get());
|
||||
global::raycasterManager.detachRaycaster(*_raycaster);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -217,8 +215,8 @@ void RenderableGalaxy::initializeGL() {
|
||||
maxdist = std::max(maxdist, glm::length(glm::vec3(x, y, z)));
|
||||
//float a = pointData[i * 7 + 6]; alpha is not used.
|
||||
|
||||
pointPositions.push_back(glm::vec3(x, y, z));
|
||||
pointColors.push_back(glm::vec3(r, g, b));
|
||||
pointPositions.emplace_back(x, y, z);
|
||||
pointColors.emplace_back(r, g, b);
|
||||
}
|
||||
|
||||
std::cout << maxdist << std::endl;
|
||||
@@ -269,7 +267,7 @@ void RenderableGalaxy::initializeGL() {
|
||||
|
||||
void RenderableGalaxy::deinitializeGL() {
|
||||
if (_raycaster) {
|
||||
global::raycasterManager.detachRaycaster(*_raycaster.get());
|
||||
global::raycasterManager.detachRaycaster(*_raycaster);
|
||||
_raycaster = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ struct RenderData;
|
||||
class RenderableGalaxy : public Renderable {
|
||||
public:
|
||||
RenderableGalaxy(const ghoul::Dictionary& dictionary);
|
||||
~RenderableGalaxy();
|
||||
virtual ~RenderableGalaxy() = default;
|
||||
|
||||
void initializeGL() override;
|
||||
void deinitializeGL() override;
|
||||
|
||||
@@ -45,7 +45,10 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
MilkywayConversionTask::MilkywayConversionTask(const ghoul::Dictionary& dictionary) {
|
||||
MilkywayConversionTask::MilkywayConversionTask(const ghoul::Dictionary& dictionary)
|
||||
: _inFirstIndex(0)
|
||||
, _inNSlices(0)
|
||||
{
|
||||
dictionary.getValue(KeyInFilenamePrefix, _inFilenamePrefix);
|
||||
dictionary.getValue(KeyInFilenameSuffix, _inFilenameSuffix);
|
||||
dictionary.getValue(KeyInFirstIndex, _inFirstIndex);
|
||||
@@ -54,13 +57,11 @@ MilkywayConversionTask::MilkywayConversionTask(const ghoul::Dictionary& dictiona
|
||||
dictionary.getValue(KeyOutDimensions, _outDimensions);
|
||||
}
|
||||
|
||||
MilkywayConversionTask::~MilkywayConversionTask() {}
|
||||
|
||||
std::string MilkywayConversionTask::description() {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
void MilkywayConversionTask::perform(const Task::ProgressCallback& progressCallback) {
|
||||
void MilkywayConversionTask::perform(const Task::ProgressCallback& onProgress) {
|
||||
using namespace openspace::volume;
|
||||
|
||||
std::vector<std::string> filenames;
|
||||
@@ -91,7 +92,7 @@ void MilkywayConversionTask::perform(const Task::ProgressCallback& progressCallb
|
||||
return value;
|
||||
};
|
||||
|
||||
rawWriter.write(sampleFunction, progressCallback);
|
||||
rawWriter.write(sampleFunction, onProgress);
|
||||
}
|
||||
|
||||
documentation::Documentation MilkywayConversionTask::documentation() {
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace documentation { struct Documentation; }
|
||||
class MilkywayConversionTask : public Task {
|
||||
public:
|
||||
MilkywayConversionTask(const ghoul::Dictionary& dictionary);
|
||||
virtual ~MilkywayConversionTask();
|
||||
virtual ~MilkywayConversionTask() = default;
|
||||
std::string description() override;
|
||||
void perform(const Task::ProgressCallback& onProgress) override;
|
||||
|
||||
|
||||
@@ -40,8 +40,6 @@ namespace openspace {
|
||||
|
||||
MilkywayPointsConversionTask::MilkywayPointsConversionTask(const ghoul::Dictionary&) {}
|
||||
|
||||
MilkywayPointsConversionTask::~MilkywayPointsConversionTask() {}
|
||||
|
||||
std::string MilkywayPointsConversionTask::description() {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace documentation { struct Documentation; }
|
||||
class MilkywayPointsConversionTask : public Task {
|
||||
public:
|
||||
MilkywayPointsConversionTask(const ghoul::Dictionary& dictionary);
|
||||
virtual ~MilkywayPointsConversionTask();
|
||||
virtual ~MilkywayPointsConversionTask() = default;
|
||||
|
||||
std::string description() override;
|
||||
void perform(const Task::ProgressCallback& progressCallback) override;
|
||||
|
||||
@@ -191,7 +191,7 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) {
|
||||
|
||||
|
||||
// Initialize
|
||||
global::callback::initializeGL.push_back([&]() {
|
||||
global::callback::initializeGL.emplace_back([&]() {
|
||||
_tileCache = std::make_unique<globebrowsing::cache::MemoryAwareTileCache>();
|
||||
addPropertySubOwner(*_tileCache);
|
||||
|
||||
@@ -205,16 +205,16 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) {
|
||||
addPropertySubOwner(GdalWrapper::ref());
|
||||
});
|
||||
|
||||
global::callback::deinitializeGL.push_back([]() {
|
||||
global::callback::deinitializeGL.emplace_back([]() {
|
||||
tileprovider::deinitializeDefaultTile();
|
||||
});
|
||||
|
||||
|
||||
// Render
|
||||
global::callback::render.push_back([&]() { _tileCache->update(); });
|
||||
global::callback::render.emplace_back([&]() { _tileCache->update(); });
|
||||
|
||||
// Deinitialize
|
||||
global::callback::deinitialize.push_back([&]() { GdalWrapper::ref().destroy(); });
|
||||
global::callback::deinitialize.emplace_back([&]() { GdalWrapper::destroy(); });
|
||||
|
||||
// Get factories
|
||||
auto fRenderable = FactoryManager::ref().factory<Renderable>();
|
||||
|
||||
@@ -42,15 +42,15 @@ struct AABB3 {
|
||||
|
||||
|
||||
struct Geodetic2 {
|
||||
double lat;
|
||||
double lon;
|
||||
double lat = 0.0;
|
||||
double lon = 0.0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct Geodetic3 {
|
||||
Geodetic2 geodetic2;
|
||||
double height;
|
||||
double height = 0.0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -143,10 +143,10 @@ double Ellipsoid::greatCircleDistance(const Geodetic2& p1, const Geodetic2& p2)
|
||||
|
||||
Geodetic2 Ellipsoid::cartesianToGeodetic2(const glm::dvec3& p) const {
|
||||
const glm::dvec3 normal = geodeticSurfaceNormalForGeocentricallyProjectedPoint(p);
|
||||
Geodetic2 res;
|
||||
res.lat = asin(normal.z / length(normal));
|
||||
res.lon = atan2(normal.y, normal.x);
|
||||
return res;
|
||||
return {
|
||||
asin(normal.z / length(normal)),
|
||||
atan2(normal.y, normal.x)
|
||||
};
|
||||
}
|
||||
|
||||
glm::dvec3 Ellipsoid::cartesianSurfacePosition(const Geodetic2& geodetic2) const {
|
||||
|
||||
@@ -157,10 +157,10 @@ Geodetic2 GeodeticPatch::clamp(const Geodetic2& p) const {
|
||||
double pointLat = normalizedAngleAround(p.lat, _center.lat);
|
||||
double pointLon = normalizedAngleAround(p.lon, _center.lon);
|
||||
|
||||
Geodetic2 res;
|
||||
res.lat = glm::clamp(pointLat, minLat(), maxLat());
|
||||
res.lon = glm::clamp(pointLon, minLon(), maxLon());
|
||||
return res;
|
||||
return {
|
||||
glm::clamp(pointLat, minLat(), maxLat()),
|
||||
glm::clamp(pointLon, minLon(), maxLon())
|
||||
};
|
||||
}
|
||||
|
||||
Geodetic2 GeodeticPatch::closestCorner(const Geodetic2& p) const {
|
||||
|
||||
@@ -75,7 +75,6 @@ void LayerGroup::setLayersFromDict(const ghoul::Dictionary& dict) {
|
||||
LERRORC(except.component, except.message);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ bool LayerManager::hasAnyBlendingLayersEnabled() const {
|
||||
|
||||
std::array<LayerGroup*, LayerManager::NumLayerGroups> LayerManager::layerGroups() const
|
||||
{
|
||||
std::array<LayerGroup*, NumLayerGroups> res;
|
||||
std::array<LayerGroup*, NumLayerGroups> res = {};
|
||||
for (int i = 0; i < NumLayerGroups; ++i) {
|
||||
res[i] = _layerGroups[i].get();
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ namespace openspace::globebrowsing {
|
||||
|
||||
RawTile createDefaultTile(TileTextureInitData initData) {
|
||||
RawTile defaultRes;
|
||||
defaultRes.textureInitData = std::move(initData);
|
||||
std::byte* data = new std::byte[initData.totalNumBytes];
|
||||
defaultRes.imageData = std::unique_ptr<std::byte[]>(data);
|
||||
std::fill_n(defaultRes.imageData.get(), initData.totalNumBytes, std::byte(0));
|
||||
defaultRes.textureInitData = std::move(initData);
|
||||
return defaultRes;
|
||||
}
|
||||
|
||||
|
||||
@@ -331,14 +331,14 @@ std::array<double, 6> geoTransform(int rasterX, int rasterY) {
|
||||
Geodetic2{ 0.0, 0.0 },
|
||||
Geodetic2{ glm::half_pi<double>(), glm::pi<double>() }
|
||||
);
|
||||
std::array<double, 6> res;
|
||||
res[0] = glm::degrees(cov.corner(Quad::NORTH_WEST).lon);
|
||||
res[1] = glm::degrees(cov.size().lon) / rasterX;
|
||||
res[2] = 0.0;
|
||||
res[3] = glm::degrees(cov.corner(Quad::NORTH_WEST).lat);
|
||||
res[4] = 0.0;
|
||||
res[5] = glm::degrees(-cov.size().lat) / rasterY;
|
||||
return res;
|
||||
return {
|
||||
glm::degrees(cov.corner(Quad::NORTH_WEST).lon),
|
||||
glm::degrees(cov.size().lon) / rasterX,
|
||||
0.0,
|
||||
glm::degrees(cov.corner(Quad::NORTH_WEST).lat),
|
||||
0.0,
|
||||
glm::degrees(-cov.size().lat) / rasterY
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
void initialize();
|
||||
|
||||
RawTile::ReadError rasterRead(int rasterBand, const IODescription& io,
|
||||
char* dst) const;
|
||||
char* dataDestination) const;
|
||||
|
||||
void readImageData(IODescription& io, RawTile::ReadError& worstError,
|
||||
char* imageDataDest) const;
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace {
|
||||
// them at a cutoff level, and I think this might still be the best solution for the
|
||||
// time being. --abock 2018-10-30
|
||||
constexpr const int DefaultSkirtedGridSegments = 64;
|
||||
constexpr static const int UnknownDesiredLevel = -1;
|
||||
constexpr const int UnknownDesiredLevel = -1;
|
||||
|
||||
const openspace::globebrowsing::GeodeticPatch Coverage =
|
||||
openspace::globebrowsing::GeodeticPatch(0, 0, 90, 180);
|
||||
@@ -385,6 +385,7 @@ bool intersects(const AABB3& bb, const AABB3& o) {
|
||||
Chunk::Chunk(const TileIndex& ti)
|
||||
: tileIndex(ti)
|
||||
, surfacePatch(ti)
|
||||
, status(Status::DoNothing)
|
||||
{}
|
||||
|
||||
RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
|
||||
|
||||
@@ -292,7 +292,7 @@ std::string timeStringify(TemporalTileProvider::TimeFormatType type, const Time&
|
||||
}
|
||||
|
||||
std::unique_ptr<TileProvider> initTileProvider(TemporalTileProvider& t,
|
||||
TemporalTileProvider::TimeKey timekey)
|
||||
const TemporalTileProvider::TimeKey& timekey)
|
||||
{
|
||||
static const std::vector<std::string> IgnoredTokens = {
|
||||
// From: http://www.gdal.org/frmt_wms.html
|
||||
@@ -569,8 +569,8 @@ SingleImageProvider::SingleImageProvider(const ghoul::Dictionary& dictionary)
|
||||
|
||||
|
||||
|
||||
TextTileProvider::TextTileProvider(const TileTextureInitData& initData, size_t fontSize)
|
||||
: initData(initData)
|
||||
TextTileProvider::TextTileProvider(TileTextureInitData initData, size_t fontSize)
|
||||
: initData(std::move(initData))
|
||||
, fontSize(fontSize)
|
||||
{
|
||||
tileCache = global::moduleEngine.module<GlobeBrowsingModule>()->tileCache();
|
||||
@@ -771,9 +771,9 @@ TemporalTileProvider::TemporalTileProvider(const ghoul::Dictionary& dictionary)
|
||||
bool initialize(TileProvider& tp) {
|
||||
ghoul_assert(!tp.isInitialized, "TileProvider can only be initialized once.");
|
||||
|
||||
tp.uniqueIdentifier = tp.NumTileProviders++;
|
||||
if (tp.NumTileProviders == std::numeric_limits<unsigned int>::max()) {
|
||||
--tp.NumTileProviders;
|
||||
tp.uniqueIdentifier = TileProvider::NumTileProviders++;
|
||||
if (TileProvider::NumTileProviders == std::numeric_limits<unsigned int>::max()) {
|
||||
--TileProvider::NumTileProviders;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ struct SingleImageProvider : public TileProvider {
|
||||
};
|
||||
|
||||
struct TextTileProvider : public TileProvider {
|
||||
TextTileProvider(const TileTextureInitData& initData, size_t fontSize = 48);
|
||||
TextTileProvider(TileTextureInitData initData, size_t fontSize = 48);
|
||||
|
||||
const TileTextureInitData initData;
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ public:
|
||||
BooleanType(ShouldAllocateDataOnCPU);
|
||||
BooleanType(PadTiles);
|
||||
|
||||
TileTextureInitData(size_t width, size_t height, GLenum glType,
|
||||
ghoul::opengl::Texture::Format textureFormat, PadTiles padTiles,
|
||||
ShouldAllocateDataOnCPU cpuAlloc = ShouldAllocateDataOnCPU::No);
|
||||
TileTextureInitData(size_t width, size_t height, GLenum type,
|
||||
ghoul::opengl::Texture::Format textureFormat, PadTiles pad,
|
||||
ShouldAllocateDataOnCPU allocCpu = ShouldAllocateDataOnCPU::No);
|
||||
|
||||
TileTextureInitData(const TileTextureInitData& original) = default;
|
||||
TileTextureInitData(TileTextureInitData&& original) = default;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace openspace {
|
||||
ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
addPropertySubOwner(gui);
|
||||
|
||||
global::callback::initialize.push_back([&]() {
|
||||
global::callback::initialize.emplace_back([&]() {
|
||||
LDEBUGC("ImGUIModule", "Initializing GUI");
|
||||
gui.initialize();
|
||||
|
||||
@@ -129,22 +129,22 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
);
|
||||
});
|
||||
|
||||
global::callback::deinitialize.push_back([&]() {
|
||||
global::callback::deinitialize.emplace_back([&]() {
|
||||
LDEBUGC("ImGui", "Deinitialize GUI");
|
||||
gui.deinitialize();
|
||||
});
|
||||
|
||||
global::callback::initializeGL.push_back([&]() {
|
||||
global::callback::initializeGL.emplace_back([&]() {
|
||||
LDEBUGC("ImGui", "Initializing GUI OpenGL");
|
||||
gui.initializeGL();
|
||||
});
|
||||
|
||||
global::callback::deinitializeGL.push_back([&]() {
|
||||
global::callback::deinitializeGL.emplace_back([&]() {
|
||||
LDEBUGC("ImGui", "Deinitialize GUI OpenGL");
|
||||
gui.deinitializeGL();
|
||||
});
|
||||
|
||||
global::callback::draw2D.push_back([&]() {
|
||||
global::callback::draw2D.emplace_back([&]() {
|
||||
// TODO emiax: Make sure this is only called for one of the eyes, in the case
|
||||
// of side-by-side / top-bottom stereo.
|
||||
|
||||
@@ -176,7 +176,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
}
|
||||
});
|
||||
|
||||
global::callback::keyboard.push_back(
|
||||
global::callback::keyboard.emplace_back(
|
||||
[&](Key key, KeyModifier mod, KeyAction action) -> bool {
|
||||
// A list of all the windows that can show up by themselves
|
||||
if (gui.isEnabled() || gui._performance.isEnabled() ||
|
||||
@@ -190,7 +190,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
}
|
||||
);
|
||||
|
||||
global::callback::character.push_back(
|
||||
global::callback::character.emplace_back(
|
||||
[&](unsigned int codepoint, KeyModifier modifier) -> bool {
|
||||
// A list of all the windows that can show up by themselves
|
||||
if (gui.isEnabled() || gui._performance.isEnabled() ||
|
||||
@@ -204,7 +204,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
}
|
||||
);
|
||||
|
||||
global::callback::mouseButton.push_back(
|
||||
global::callback::mouseButton.emplace_back(
|
||||
[&](MouseButton button, MouseAction action) -> bool {
|
||||
// A list of all the windows that can show up by themselves
|
||||
if (gui.isEnabled() || gui._performance.isEnabled() ||
|
||||
@@ -218,7 +218,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
}
|
||||
);
|
||||
|
||||
global::callback::mouseScrollWheel.push_back(
|
||||
global::callback::mouseScrollWheel.emplace_back(
|
||||
[&](double, double posY) -> bool {
|
||||
// A list of all the windows that can show up by themselves
|
||||
if (gui.isEnabled() || gui._performance.isEnabled() ||
|
||||
|
||||
@@ -33,7 +33,7 @@ class ShortcutTopic : public Topic {
|
||||
public:
|
||||
virtual ~ShortcutTopic() = default;
|
||||
|
||||
void handleJson(const nlohmann::json& json) override;
|
||||
void handleJson(const nlohmann::json& input) override;
|
||||
bool isDone() const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -68,7 +68,7 @@ void ServerModule::internalInitialize(const ghoul::Dictionary&) {
|
||||
_servers.push_back(std::move(tcpServer));
|
||||
_servers.push_back(std::move(wsServer));
|
||||
|
||||
global::callback::preSync.push_back([this]() { preSync(); });
|
||||
global::callback::preSync.emplace_back([this]() { preSync(); });
|
||||
}
|
||||
|
||||
void ServerModule::preSync() {
|
||||
|
||||
@@ -453,7 +453,7 @@ void RenderableStars::render(const RenderData& data, RendererTasks&) {
|
||||
glm::vec2(global::renderEngine.renderingResolution())
|
||||
);
|
||||
|
||||
setPscUniforms(*_program.get(), data.camera, data.position);
|
||||
setPscUniforms(*_program, data.camera, data.position);
|
||||
_program->setUniform(_uniformCache.scaling, scaling);
|
||||
|
||||
ghoul::opengl::TextureUnit psfUnit;
|
||||
@@ -650,7 +650,7 @@ void RenderableStars::update(const UpdateData&) {
|
||||
if (_pointSpreadFunctionTextureIsDirty) {
|
||||
LDEBUG("Reloading Point Spread Function texture");
|
||||
_pointSpreadFunctionTexture = nullptr;
|
||||
if (_pointSpreadFunctionTexturePath.value() != "") {
|
||||
if (!_pointSpreadFunctionTexturePath.value().empty()) {
|
||||
_pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture(
|
||||
absPath(_pointSpreadFunctionTexturePath)
|
||||
);
|
||||
@@ -706,7 +706,7 @@ void RenderableStars::update(const UpdateData&) {
|
||||
if (_otherDataColorMapIsDirty) {
|
||||
LDEBUG("Reloading Color Texture");
|
||||
_otherDataColorMapTexture = nullptr;
|
||||
if (_otherDataColorMapPath.value() != "") {
|
||||
if (!_otherDataColorMapPath.value().empty()) {
|
||||
_otherDataColorMapTexture = ghoul::io::TextureReader::ref().loadTexture(
|
||||
absPath(_otherDataColorMapPath)
|
||||
);
|
||||
@@ -837,8 +837,8 @@ void RenderableStars::readSpeckFile() {
|
||||
str >> values[i];
|
||||
}
|
||||
bool nullArray = true;
|
||||
for (size_t i = 0; i < values.size(); ++i) {
|
||||
if (values[i] != 0.0) {
|
||||
for (float v : values) {
|
||||
if (v != 0.0) {
|
||||
nullArray = false;
|
||||
break;
|
||||
}
|
||||
@@ -949,7 +949,7 @@ void RenderableStars::createDataSlice(ColorOption option) {
|
||||
union {
|
||||
ColorVBOLayout value;
|
||||
std::array<float, sizeof(ColorVBOLayout)> data;
|
||||
} layout;
|
||||
} layout = {};
|
||||
|
||||
layout.value.position = { {
|
||||
position[0], position[1], position[2], position[3]
|
||||
@@ -976,7 +976,7 @@ void RenderableStars::createDataSlice(ColorOption option) {
|
||||
union {
|
||||
VelocityVBOLayout value;
|
||||
std::array<float, sizeof(VelocityVBOLayout)> data;
|
||||
} layout;
|
||||
} layout = {};
|
||||
|
||||
layout.value.position = { {
|
||||
position[0], position[1], position[2], position[3]
|
||||
@@ -1000,7 +1000,7 @@ void RenderableStars::createDataSlice(ColorOption option) {
|
||||
union {
|
||||
SpeedVBOLayout value;
|
||||
std::array<float, sizeof(SpeedVBOLayout)> data;
|
||||
} layout;
|
||||
} layout = {};
|
||||
|
||||
layout.value.position = { {
|
||||
position[0], position[1], position[2], position[3]
|
||||
@@ -1022,7 +1022,7 @@ void RenderableStars::createDataSlice(ColorOption option) {
|
||||
union {
|
||||
OtherDataLayout value;
|
||||
std::array<float, sizeof(OtherDataLayout)> data;
|
||||
} layout;
|
||||
} layout = {};
|
||||
|
||||
layout.value.position = {
|
||||
{ position[0], position[1], position[2], position[3] }
|
||||
|
||||
@@ -143,7 +143,7 @@ void HorizonsTranslation::readHorizonsTextFile(const std::string& horizonsTextFi
|
||||
// The beginning of a Horizons file has a header with a lot of information about the
|
||||
// query that we do not care about. Ignore everything until data starts, including
|
||||
// the row marked by $$SOE (i.e. Start Of Ephemerides).
|
||||
std::string line = "";
|
||||
std::string line;
|
||||
while (line[0] != '$') {
|
||||
std::getline(fileStream, line);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
HorizonsTranslation();
|
||||
HorizonsTranslation(const ghoul::Dictionary& dictionary);
|
||||
|
||||
glm::dvec3 position(const UpdateData& time) const override;
|
||||
glm::dvec3 position(const UpdateData& data) const override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
|
||||
@@ -382,7 +382,7 @@ void RenderableModelProjection::update(const UpdateData& data) {
|
||||
}
|
||||
|
||||
void RenderableModelProjection::imageProjectGPU(
|
||||
std::shared_ptr<ghoul::opengl::Texture> projectionTexture)
|
||||
const ghoul::opengl::Texture& projectionTexture)
|
||||
{
|
||||
if (_projectionComponent.needsShadowMap()) {
|
||||
_projectionComponent.depthMapRenderBegin();
|
||||
@@ -408,7 +408,7 @@ void RenderableModelProjection::imageProjectGPU(
|
||||
|
||||
ghoul::opengl::TextureUnit unitFbo;
|
||||
unitFbo.activate();
|
||||
projectionTexture->bind();
|
||||
projectionTexture.bind();
|
||||
_fboProgramObject->setUniform(_fboUniformCache.projectionTexture, unitFbo);
|
||||
|
||||
_fboProgramObject->setUniform(
|
||||
@@ -489,7 +489,7 @@ void RenderableModelProjection::project() {
|
||||
attitudeParameters(img.timeRange.start);
|
||||
std::shared_ptr<ghoul::opengl::Texture> projTexture =
|
||||
_projectionComponent.loadProjectionTexture(img.path, img.isPlaceholder);
|
||||
imageProjectGPU(projTexture);
|
||||
imageProjectGPU(*projTexture);
|
||||
}
|
||||
_shouldCapture = false;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
private:
|
||||
bool loadTextures();
|
||||
void attitudeParameters(double time);
|
||||
void imageProjectGPU(std::shared_ptr<ghoul::opengl::Texture> projectionTexture);
|
||||
void imageProjectGPU(const ghoul::opengl::Texture& projectionTexture);
|
||||
|
||||
void project();
|
||||
|
||||
|
||||
@@ -466,7 +466,7 @@ bool RenderablePlanetProjection::isReady() const {
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::imageProjectGPU(
|
||||
std::shared_ptr<ghoul::opengl::Texture> projectionTexture)
|
||||
const ghoul::opengl::Texture& projectionTexture)
|
||||
{
|
||||
_projectionComponent.imageProjectBegin();
|
||||
|
||||
@@ -474,7 +474,7 @@ void RenderablePlanetProjection::imageProjectGPU(
|
||||
|
||||
ghoul::opengl::TextureUnit unitFbo;
|
||||
unitFbo.activate();
|
||||
projectionTexture->bind();
|
||||
projectionTexture.bind();
|
||||
_fboProgramObject->setUniform(_fboUniformCache.projectionTexture, unitFbo);
|
||||
|
||||
_fboProgramObject->setUniform(_fboUniformCache.projectorMatrix, _projectorMatrix);
|
||||
@@ -596,7 +596,9 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&)
|
||||
break;
|
||||
}
|
||||
RenderablePlanetProjection::attitudeParameters(img.timeRange.start);
|
||||
imageProjectGPU(_projectionComponent.loadProjectionTexture(img.path));
|
||||
std::shared_ptr<ghoul::opengl::Texture> t =
|
||||
_projectionComponent.loadProjectionTexture(img.path);
|
||||
imageProjectGPU(*t);
|
||||
++nPerformedProjections;
|
||||
}
|
||||
_imageTimes.erase(
|
||||
|
||||
@@ -63,7 +63,7 @@ protected:
|
||||
void attitudeParameters(double time);
|
||||
|
||||
private:
|
||||
void imageProjectGPU(std::shared_ptr<ghoul::opengl::Texture> projectionTexture);
|
||||
void imageProjectGPU(const ghoul::opengl::Texture& projectionTexture);
|
||||
|
||||
void clearProjectionBufferAfterTime(double time);
|
||||
void insertImageProjections(const std::vector<Image>& images);
|
||||
|
||||
@@ -111,7 +111,7 @@ void SequenceParser::sendPlaybookInformation(const std::string& name) {
|
||||
|
||||
std::map<std::string, uint8_t> targetMap;
|
||||
uint8_t currentTargetId = 0;
|
||||
for (auto target : _subsetMap) {
|
||||
for (const std::pair<const std::string, ImageSubset>& target : _subsetMap) {
|
||||
if (targetMap.find(target.first) == targetMap.end()) {
|
||||
targetMap[target.first] = currentTargetId++;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ void SequenceParser::sendPlaybookInformation(const std::string& name) {
|
||||
union {
|
||||
uint32_t value;
|
||||
std::array<char, sizeof(uint32_t)> data;
|
||||
} sizeBuffer;
|
||||
} sizeBuffer = {};
|
||||
sizeBuffer.value = static_cast<uint32_t>(currentWriteLocation);
|
||||
buffer.insert(buffer.begin(), sizeBuffer.data.begin(), sizeBuffer.data.end());
|
||||
currentWriteLocation += sizeof(uint32_t);
|
||||
|
||||
@@ -114,7 +114,7 @@ void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) {
|
||||
|
||||
_torrentClient.initialize();
|
||||
|
||||
global::callback::deinitialize.push_back([&]() { _torrentClient.deinitialize(); });
|
||||
global::callback::deinitialize.emplace_back([&]() { _torrentClient.deinitialize(); });
|
||||
}
|
||||
|
||||
void SyncModule::internalDeinitialize() {
|
||||
|
||||
@@ -74,12 +74,12 @@ documentation::Documentation HttpSynchronization::Documentation() {
|
||||
}
|
||||
|
||||
HttpSynchronization::HttpSynchronization(const ghoul::Dictionary& dict,
|
||||
const std::string& synchronizationRoot,
|
||||
const std::vector<std::string>& synchronizationRepositories
|
||||
std::string synchronizationRoot,
|
||||
std::vector<std::string> synchronizationRepositories
|
||||
)
|
||||
: openspace::ResourceSynchronization(dict)
|
||||
, _synchronizationRoot(synchronizationRoot)
|
||||
, _synchronizationRepositories(synchronizationRepositories)
|
||||
, _synchronizationRoot(std::move(synchronizationRoot))
|
||||
, _synchronizationRepositories(std::move(synchronizationRepositories))
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
@@ -184,7 +184,7 @@ bool HttpSynchronization::hasSyncFile() {
|
||||
}
|
||||
|
||||
bool HttpSynchronization::trySyncFromUrl(std::string listUrl) {
|
||||
HttpRequest::RequestOptions opt;
|
||||
HttpRequest::RequestOptions opt = {};
|
||||
opt.requestTimeoutSeconds = 0;
|
||||
|
||||
SyncHttpMemoryDownload fileListDownload(std::move(listUrl));
|
||||
|
||||
@@ -34,9 +34,8 @@ namespace openspace {
|
||||
|
||||
class HttpSynchronization : public ResourceSynchronization {
|
||||
public:
|
||||
HttpSynchronization(const ghoul::Dictionary& dict,
|
||||
const std::string& synchronizationRoot,
|
||||
const std::vector<std::string>& synchronizationRepositories);
|
||||
HttpSynchronization(const ghoul::Dictionary& dict, std::string synchronizationRoot,
|
||||
std::vector<std::string> synchronizationRepositories);
|
||||
|
||||
virtual ~HttpSynchronization();
|
||||
|
||||
|
||||
@@ -61,10 +61,10 @@ documentation::Documentation TorrentSynchronization::Documentation() {
|
||||
}
|
||||
|
||||
TorrentSynchronization::TorrentSynchronization(const ghoul::Dictionary& dict,
|
||||
const std::string& synchronizationRoot,
|
||||
std::string synchronizationRoot,
|
||||
TorrentClient& torrentClient)
|
||||
: ResourceSynchronization(dict)
|
||||
, _synchronizationRoot(synchronizationRoot)
|
||||
, _synchronizationRoot(std::move(synchronizationRoot))
|
||||
, _torrentClient(torrentClient)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
|
||||
@@ -35,8 +35,8 @@ class TorrentSynchronizationJob;
|
||||
|
||||
class TorrentSynchronization : public ResourceSynchronization {
|
||||
public:
|
||||
TorrentSynchronization(const ghoul::Dictionary& dict,
|
||||
const std::string& synchronizationRoot, TorrentClient& client);
|
||||
TorrentSynchronization(const ghoul::Dictionary& dict, std::string synchronizationRoot,
|
||||
TorrentClient& client);
|
||||
|
||||
virtual ~TorrentSynchronization();
|
||||
|
||||
@@ -59,7 +59,7 @@ private:
|
||||
|
||||
std::atomic_bool _enabled = false;
|
||||
|
||||
TorrentClient::TorrentId _torrentId;
|
||||
TorrentClient::TorrentId _torrentId = 0;
|
||||
TorrentClient::TorrentProgress _progress;
|
||||
std::mutex _progressMutex;
|
||||
std::string _identifier;
|
||||
|
||||
@@ -96,9 +96,9 @@ documentation::Documentation UrlSynchronization::Documentation() {
|
||||
}
|
||||
|
||||
UrlSynchronization::UrlSynchronization(const ghoul::Dictionary& dict,
|
||||
const std::string& synchronizationRoot)
|
||||
std::string synchronizationRoot)
|
||||
: ResourceSynchronization(dict)
|
||||
, _synchronizationRoot(synchronizationRoot)
|
||||
, _synchronizationRoot(std::move(synchronizationRoot))
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
@@ -225,7 +225,7 @@ void UrlSynchronization::start() {
|
||||
return !_shouldCancel;
|
||||
});
|
||||
|
||||
HttpRequest::RequestOptions opt;
|
||||
HttpRequest::RequestOptions opt = {};
|
||||
opt.requestTimeoutSeconds = 0;
|
||||
fileDownload->start(opt);
|
||||
}
|
||||
|
||||
@@ -35,8 +35,7 @@ namespace openspace {
|
||||
|
||||
class UrlSynchronization : public ResourceSynchronization {
|
||||
public:
|
||||
UrlSynchronization(const ghoul::Dictionary& dict,
|
||||
const std::string& synchronizationRoot);
|
||||
UrlSynchronization(const ghoul::Dictionary& dict, std::string synchronizationRoot);
|
||||
|
||||
virtual ~UrlSynchronization();
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace openspace {
|
||||
|
||||
class CefHost {
|
||||
public:
|
||||
CefHost(std::string helperLocation);
|
||||
CefHost(const std::string& helperLocation);
|
||||
~CefHost();
|
||||
void doMessageLoopWork();
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
CefHost::CefHost(std::string helperLocation) {
|
||||
CefHost::CefHost(const std::string& helperLocation) {
|
||||
LDEBUG("Initializing CEF...");
|
||||
|
||||
CefSettings settings;
|
||||
@@ -50,7 +50,7 @@ CefHost::CefHost(std::string helperLocation) {
|
||||
CefRefPtr<WebBrowserApp> app(new WebBrowserApp);
|
||||
|
||||
CefMainArgs args;
|
||||
CefInitialize(args, settings, app.get(), NULL);
|
||||
CefInitialize(args, settings, app.get(), nullptr);
|
||||
LDEBUG("Initializing CEF... done!");
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace {
|
||||
void launchBrowser(const std::string& url) {
|
||||
LDEBUGC("DefaultBrowserLauncher", "Launching default browser: " + url);
|
||||
#ifdef WIN32
|
||||
ShellExecute(0, 0, url.c_str(), 0, 0, SW_SHOW);
|
||||
ShellExecute(nullptr, nullptr, url.c_str(), nullptr, nullptr, SW_SHOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace {
|
||||
namespace openspace {
|
||||
|
||||
void EventHandler::initialize() {
|
||||
global::callback::character.push_back(
|
||||
global::callback::character.emplace_back(
|
||||
[this](unsigned int charCode, KeyModifier mod) -> bool {
|
||||
if (_browserInstance) {
|
||||
return charCallback(charCode, mod);
|
||||
@@ -108,7 +108,7 @@ void EventHandler::initialize() {
|
||||
return false;
|
||||
}
|
||||
);
|
||||
global::callback::keyboard.push_back(
|
||||
global::callback::keyboard.emplace_back(
|
||||
[this](Key key, KeyModifier mod, KeyAction action) -> bool {
|
||||
if (_browserInstance) {
|
||||
return keyboardCallback(key, mod, action);
|
||||
@@ -116,7 +116,7 @@ void EventHandler::initialize() {
|
||||
return false;
|
||||
}
|
||||
);
|
||||
global::callback::mousePosition.push_back(
|
||||
global::callback::mousePosition.emplace_back(
|
||||
[this](double x, double y) -> bool {
|
||||
if (_browserInstance) {
|
||||
return mousePositionCallback(x, y);
|
||||
@@ -124,7 +124,7 @@ void EventHandler::initialize() {
|
||||
return false;
|
||||
}
|
||||
);
|
||||
global::callback::mouseButton.push_back(
|
||||
global::callback::mouseButton.emplace_back(
|
||||
[this](MouseButton button, MouseAction action) -> bool {
|
||||
if (_browserInstance) {
|
||||
return mouseButtonCallback(button, action);
|
||||
@@ -132,7 +132,7 @@ void EventHandler::initialize() {
|
||||
return false;
|
||||
}
|
||||
);
|
||||
global::callback::mouseScrollWheel.push_back(
|
||||
global::callback::mouseScrollWheel.emplace_back(
|
||||
[this](double x, double y) -> bool {
|
||||
if (_browserInstance) {
|
||||
const glm::ivec2 delta(x, y);
|
||||
|
||||
@@ -38,13 +38,12 @@ void WebRenderHandler::reshape(int w, int h) {
|
||||
_needsRepaint = true;
|
||||
}
|
||||
|
||||
bool WebRenderHandler::GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) {
|
||||
bool WebRenderHandler::GetViewRect(CefRefPtr<CefBrowser>, CefRect& rect) {
|
||||
rect = CefRect(0, 0, _windowSize.x, _windowSize.y);
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebRenderHandler::OnPaint(CefRefPtr<CefBrowser> browser,
|
||||
CefRenderHandler::PaintElementType,
|
||||
void WebRenderHandler::OnPaint(CefRefPtr<CefBrowser>, CefRenderHandler::PaintElementType,
|
||||
const CefRenderHandler::RectList& dirtyRects,
|
||||
const void* buffer, int w, int h)
|
||||
{
|
||||
@@ -61,16 +60,15 @@ void WebRenderHandler::OnPaint(CefRefPtr<CefBrowser> browser,
|
||||
_lowerDirtyRectBound = lowerUpdatingRectBound = glm::ivec2(0, 0);
|
||||
}
|
||||
|
||||
for (auto it = dirtyRects.begin(); it != dirtyRects.end(); ++it) {
|
||||
lowerUpdatingRectBound = glm::min(
|
||||
lowerUpdatingRectBound,
|
||||
glm::ivec2(it->x, it->y)
|
||||
);
|
||||
for (const CefRect& r : dirtyRects) {
|
||||
lowerUpdatingRectBound = glm::min(lowerUpdatingRectBound, glm::ivec2(r.x, r.y));
|
||||
upperUpdatingRectBound = glm::max(
|
||||
upperUpdatingRectBound,
|
||||
glm::ivec2(it->x + it->width, it->y + it->height)
|
||||
glm::ivec2(r.x + r.width, r.y + r.height)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
const glm::ivec2 rectSize = upperUpdatingRectBound - lowerUpdatingRectBound;
|
||||
if (rectSize.x > 0 && rectSize.y > 0) {
|
||||
_textureIsDirty = true;
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace {
|
||||
namespace openspace {
|
||||
|
||||
WebBrowserModule::WebBrowserModule() : OpenSpaceModule(WebBrowserModule::Name) {
|
||||
global::callback::deinitialize.push_back([this]() { deinitialize(); });
|
||||
global::callback::deinitialize.emplace_back([this]() { deinitialize(); });
|
||||
}
|
||||
|
||||
void WebBrowserModule::internalDeinitialize() {
|
||||
@@ -100,7 +100,7 @@ void WebBrowserModule::internalInitialize(const ghoul::Dictionary& dictionary) {
|
||||
_cefHost = std::make_unique<CefHost>(std::move(helperLocation));
|
||||
LDEBUG("Starting CEF... done!");
|
||||
|
||||
global::callback::preSync.push_back([this]() {
|
||||
global::callback::preSync.emplace_back([this]() {
|
||||
if (_cefHost && !_browsers.empty()) {
|
||||
_cefHost->doMessageLoopWork();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
bool isEnabled() const;
|
||||
|
||||
protected:
|
||||
void internalInitialize(const ghoul::Dictionary& configuration) override;
|
||||
void internalInitialize(const ghoul::Dictionary& dictionary) override;
|
||||
void internalDeinitialize() override;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user