From ad3df78e1aa291b2e48c6eec1cc1ad05d5f3e13e Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 8 Nov 2017 19:26:28 -0600 Subject: [PATCH 1/3] Add strict coding style check for line length --- support/coding/check_style_guide.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/support/coding/check_style_guide.py b/support/coding/check_style_guide.py index a63e6abf63..a2c6d9705e 100644 --- a/support/coding/check_style_guide.py +++ b/support/coding/check_style_guide.py @@ -295,6 +295,19 @@ def check_empty_only_line(lines): +def check_line_length(lines): + # Disable this check in non-strict mode + if not is_strict_mode: + return '' + + index = [i + 1 for i, s in enumerate(lines) if len(s) > (90 + 1)] + if len(index) > 0: + return index + else: + return '' + + + previousSymbols = {} def check_header_file(file, component): with open(file, 'r+') as f: @@ -375,6 +388,10 @@ def check_header_file(file, component): if empty_only_lines: print(file, '\t', 'Empty only line: ', empty_only_lines) + line_length = check_line_length(lines) + if line_length: + print(file, '\t', 'Line length exceeded: ', line_length) + def check_inline_file(file, component): @@ -413,6 +430,10 @@ def check_inline_file(file, component): if using_namespaces: print(file, '\t', 'Using namespace found in inline file') + line_length = check_line_length(lines) + if line_length: + print(file, '\t', 'Line length exceeded: ', line_length) + def check_source_file(file, component): @@ -444,6 +465,10 @@ def check_source_file(file, component): if empty_only_lines: print(file, '\t', 'Empty only line: ', empty_only_lines) + line_length = check_line_length(lines) + if line_length: + print(file, '\t', 'Line length exceeded: ', line_length) + def check_files(positiveList, negativeList, component, check_function): From 8866a13ff6960c79d0739dc96d000851848f0c07 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 8 Nov 2017 21:36:06 -0600 Subject: [PATCH 2/3] More coding style fixes --- ext/ghoul | 2 +- modules/base/basemodule.cpp | 16 +- modules/base/rendering/modelgeometry.cpp | 22 +- modules/base/rendering/renderablemodel.cpp | 11 +- modules/base/rendering/renderableplane.cpp | 24 +- modules/base/rendering/renderablesphere.cpp | 32 +- .../rendering/renderablesphericalgrid.cpp | 24 +- .../base/rendering/renderabletrailorbit.cpp | 8 +- .../rendering/renderabletrailtrajectory.cpp | 4 +- .../base/rendering/screenspaceimagelocal.cpp | 3 +- .../base/rendering/screenspaceimageonline.cpp | 7 +- modules/base/rendering/wavefrontgeometry.cpp | 17 +- .../rendering/renderabledebugplane.cpp | 9 +- modules/galaxy/rendering/galaxyraycaster.cpp | 23 +- modules/galaxy/rendering/renderablegalaxy.cpp | 38 +- .../galaxy/tasks/milkywayconversiontask.cpp | 24 +- modules/iswa/rendering/datacygnet.cpp | 87 +++-- modules/iswa/rendering/iswacygnet.cpp | 28 +- modules/iswa/rendering/iswakameleongroup.cpp | 28 +- modules/space/rendering/renderableplanet.cpp | 114 ++++-- modules/space/rendering/renderablestars.cpp | 13 +- modules/space/spacemodule.cpp | 10 +- .../space/translation/keplertranslation.cpp | 3 +- .../rendering/renderablecrawlingline.cpp | 12 +- .../rendering/renderablefov.cpp | 353 ++++++++++++++---- .../rendering/renderablemodelprojection.cpp | 13 +- .../rendering/renderableplaneprojection.cpp | 103 +++-- .../rendering/renderableplanetprojection.cpp | 49 +-- .../rendering/renderableshadowcylinder.cpp | 23 +- .../util/hongkangparser.cpp | 58 ++- .../util/instrumenttimesparser.cpp | 30 +- .../util/labelparser.cpp | 85 ++++- .../util/projectioncomponent.cpp | 42 ++- .../util/sequenceparser.cpp | 21 +- modules/volume/rendering/volumeclipplanes.cpp | 3 +- modules/volume/volumemodule.cpp | 6 +- 36 files changed, 981 insertions(+), 364 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 499813d03e..a6244a16f9 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 499813d03ea98ddd08c9142aef0f674ba0b19a5f +Subproject commit a6244a16f98687c9196c4ba8ced11a3d68a88b46 diff --git a/modules/base/basemodule.cpp b/modules/base/basemodule.cpp index c7165bbd5b..a389592e5a 100644 --- a/modules/base/basemodule.cpp +++ b/modules/base/basemodule.cpp @@ -68,12 +68,12 @@ void BaseModule::internalInitialize() { "ScreenSpaceRenderable" ); - auto fScreenSpaceRenderable = FactoryManager::ref().factory(); - ghoul_assert(fScreenSpaceRenderable, "ScreenSpaceRenderable factory was not created"); + auto fSsRenderable = FactoryManager::ref().factory(); + ghoul_assert(fSsRenderable, "ScreenSpaceRenderable factory was not created"); - fScreenSpaceRenderable->registerClass("ScreenSpaceImageLocal"); - fScreenSpaceRenderable->registerClass("ScreenSpaceImageOnline"); - fScreenSpaceRenderable->registerClass("ScreenSpaceFramebuffer"); + fSsRenderable->registerClass("ScreenSpaceImageLocal"); + fSsRenderable->registerClass("ScreenSpaceImageOnline"); + fSsRenderable->registerClass("ScreenSpaceFramebuffer"); auto fRenderable = FactoryManager::ref().factory(); ghoul_assert(fRenderable, "Renderable factory was not created"); @@ -103,9 +103,9 @@ void BaseModule::internalInitialize() { fScale->registerClass("LuaScale"); fScale->registerClass("StaticScale"); - auto fModelGeometry = FactoryManager::ref().factory(); - ghoul_assert(fModelGeometry, "Model geometry factory was not created"); - fModelGeometry->registerClass("MultiModelGeometry"); + auto fGeometry = FactoryManager::ref().factory(); + ghoul_assert(fGeometry, "Model geometry factory was not created"); + fGeometry->registerClass("MultiModelGeometry"); } std::vector BaseModule::documentations() const { diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index b79a659101..05897f1ba7 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -113,7 +113,12 @@ double ModelGeometry::boundingRadius() const { void ModelGeometry::render() { glBindVertexArray(_vaoID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo); - glDrawElements(_mode, static_cast(_indices.size()), GL_UNSIGNED_INT, nullptr); + glDrawElements( + _mode, + static_cast(_indices.size()), + GL_UNSIGNED_INT, + nullptr + ); glBindVertexArray(0); } @@ -245,8 +250,14 @@ bool ModelGeometry::saveCachedFile(const std::string& filename) { int64_t iSize = _indices.size(); fileStream.write(reinterpret_cast(&iSize), sizeof(int64_t)); - fileStream.write(reinterpret_cast(_vertices.data()), sizeof(Vertex) * vSize); - fileStream.write(reinterpret_cast(_indices.data()), sizeof(int) * iSize); + fileStream.write( + reinterpret_cast(_vertices.data()), + sizeof(Vertex) * vSize + ); + fileStream.write( + reinterpret_cast(_indices.data()), + sizeof(int) * iSize + ); return fileStream.good(); } @@ -280,7 +291,10 @@ bool ModelGeometry::loadCachedFile(const std::string& filename) { _vertices.resize(vSize); _indices.resize(iSize); - fileStream.read(reinterpret_cast(_vertices.data()), sizeof(Vertex) * vSize); + fileStream.read( + reinterpret_cast(_vertices.data()), + sizeof(Vertex) * vSize + ); fileStream.read(reinterpret_cast(_indices.data()), sizeof(int) * iSize); return fileStream.good(); diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 1eed0d2ad6..faf34d5477 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -188,11 +188,14 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) { glm::dmat4 modelTransform = glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation glm::dmat4(data.modelTransform.rotation) * // Spice rotation - glm::scale(glm::dmat4(_modelTransform.value()), glm::dvec3(data.modelTransform.scale)); + glm::scale( + glm::dmat4(_modelTransform.value()), glm::dvec3(data.modelTransform.scale) + ); glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; glm::vec3 directionToSun = glm::normalize(_sunPos - data.modelTransform.translation); - glm::vec3 directionToSunViewSpace = glm::mat3(data.camera.combinedViewMatrix()) * directionToSun; + glm::vec3 directionToSunViewSpace = + glm::mat3(data.camera.combinedViewMatrix()) * directionToSun; _programObject->setUniform("directionToSunViewSpace", directionToSunViewSpace); _programObject->setUniform("modelViewTransform", glm::mat4(modelViewTransform)); @@ -223,7 +226,9 @@ void RenderableModel::update(const UpdateData&) { void RenderableModel::loadTexture() { _texture = nullptr; if (_colorTexturePath.value() != "") { - _texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath)); + _texture = ghoul::io::TextureReader::ref().loadTexture( + absPath(_colorTexturePath) + ); if (_texture) { LDEBUGC( "RenderableModel", diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 3475598a79..d867404864 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -211,9 +211,13 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) { _shader->activate(); //if (_projectionListener){ // //get parent node-texture and set with correct dimensions - // SceneGraphNode* textureNode = OsEng.renderEngine().scene()->sceneGraphNode(_nodeName)->parent(); + // SceneGraphNode* textureNode = OsEng.renderEngine().scene()->sceneGraphNode( + // _nodeName + // )->parent(); // if (textureNode != nullptr){ - // RenderablePlanetProjection* t = static_cast(textureNode->renderable()); + // RenderablePlanetProjection* t = static_cast( + // textureNode->renderable() + // ); // _texture = std::unique_ptr(&(t->baseTexture())); // unsigned int h = _texture->height(); // unsigned int w = _texture->width(); @@ -232,7 +236,8 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) { rotationTransform * glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)) * glm::dmat4(1.0); - const glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; + const glm::dmat4 modelViewTransform = + data.camera.combinedViewMatrix() * modelTransform; _shader->setUniform("modelViewProjectionTransform", data.camera.projectionMatrix() * glm::mat4(modelViewTransform)); @@ -243,10 +248,12 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) { _shader->setUniform("texture1", unit); bool usingFramebufferRenderer = - OsEng.renderEngine().rendererImplementation() == RenderEngine::RendererImplementation::Framebuffer; + OsEng.renderEngine().rendererImplementation() == + RenderEngine::RendererImplementation::Framebuffer; bool usingABufferRenderer = - OsEng.renderEngine().rendererImplementation() == RenderEngine::RendererImplementation::ABuffer; + OsEng.renderEngine().rendererImplementation() == + RenderEngine::RendererImplementation::ABuffer; if (usingABufferRenderer) { _shader->setUniform("additiveBlending", _blendMode == BlendModeAdditive); @@ -294,13 +301,16 @@ void RenderablePlane::loadTexture() { ); texture->uploadTexture(); - // Textures of planets looks much smoother with AnisotropicMipMap rather than linear + // Textures of planets looks much smoother with AnisotropicMipMap rather than + // linear texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); _texture = std::move(texture); _textureFile = std::make_unique(_texturePath); - _textureFile->setCallback([&](const ghoul::filesystem::File&) { _textureIsDirty = true; }); + _textureFile->setCallback( + [&](const ghoul::filesystem::File&) { _textureIsDirty = true; } + ); } } } diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index 3999411eb8..3a16b97159 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -209,7 +209,9 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary) _texturePath.onChange([this]() { loadTexture(); }); if (dictionary.hasKey(FadeOutThreshouldInfo.identifier)) { - _fadeOutThreshold = static_cast(dictionary.value(FadeOutThreshouldInfo.identifier)); + _fadeOutThreshold = static_cast( + dictionary.value(FadeOutThreshouldInfo.identifier) + ); } } @@ -257,10 +259,18 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { setPscUniforms(*_shader.get(), data.camera, data.position); if (_fadeOutThreshold > -1.0) { - float distCamera = glm::distance(data.camera.positionVec3(), data.position.dvec3()); - double term = std::exp((-distCamera + _size * _fadeOutThreshold) / (_size * _fadeOutThreshold)); + float distCamera = glm::distance( + data.camera.positionVec3(), + data.position.dvec3() + ); + double term = std::exp( + (-distCamera + _size * _fadeOutThreshold) / (_size * _fadeOutThreshold) + ); - _shader->setUniform("alpha", _transparency * static_cast(term / (term + 1.0))); + _shader->setUniform( + "alpha", + _transparency * static_cast(term / (term + 1.0)) + ); } else { _shader->setUniform("alpha", _transparency); @@ -275,10 +285,12 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { glCullFace(GL_BACK); bool usingFramebufferRenderer = - OsEng.renderEngine().rendererImplementation() == RenderEngine::RendererImplementation::Framebuffer; + OsEng.renderEngine().rendererImplementation() == + RenderEngine::RendererImplementation::Framebuffer; bool usingABufferRenderer = - OsEng.renderEngine().rendererImplementation() == RenderEngine::RendererImplementation::ABuffer; + OsEng.renderEngine().rendererImplementation() == + RenderEngine::RendererImplementation::ABuffer; if (usingABufferRenderer) { _shader->setUniform("additiveBlending", true); @@ -314,7 +326,10 @@ void RenderableSphere::update(const UpdateData&) { void RenderableSphere::loadTexture() { if (_texturePath.value() != "") { - std::unique_ptr texture = ghoul::io::TextureReader::ref().loadTexture(_texturePath); + using TR = ghoul::io::TextureReader; + std::unique_ptr texture = TR::ref().loadTexture( + _texturePath + ); if (texture) { LDEBUGC( "RenderableSphere", @@ -322,7 +337,8 @@ void RenderableSphere::loadTexture() { ); texture->uploadTexture(); - // Textures of planets looks much smoother with AnisotropicMipMap rather than linear + // Textures of planets looks much smoother with AnisotropicMipMap rather than + // linear // TODO: AnisotropicMipMap crashes on ATI cards ---abock //texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); diff --git a/modules/base/rendering/renderablesphericalgrid.cpp b/modules/base/rendering/renderablesphericalgrid.cpp index 0072e000fd..1824fc6d8c 100644 --- a/modules/base/rendering/renderablesphericalgrid.cpp +++ b/modules/base/rendering/renderablesphericalgrid.cpp @@ -111,7 +111,7 @@ documentation::Documentation RenderableSphericalGrid::Documentation() { } -RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictionary) +RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _gridProgram(nullptr) , _gridMatrix(GridMatrixInfo, glm::mat4(1.f)) @@ -254,7 +254,7 @@ void RenderableSphericalGrid::update(const UpdateData&) { // inclination angle (north to south) const float theta = fi * glm::pi() / fsegments * 2.f; // 0 -> PI - // azimuth angle (east to west) + // azimuth angle (east to west) const float phi = fj * glm::pi() * 2.0f / fsegments; // 0 -> 2*PI const float x = r * sin(phi) * sin(theta); // @@ -266,7 +266,11 @@ void RenderableSphericalGrid::update(const UpdateData&) { normal = glm::normalize(normal); glm::vec4 tmp(x, y, z, 1); - glm::mat4 rot = glm::rotate(glm::mat4(1), glm::half_pi(), glm::vec3(1, 0, 0)); + glm::mat4 rot = glm::rotate( + glm::mat4(1), + glm::half_pi(), + glm::vec3(1, 0, 0) + ); tmp = glm::vec4(_gridMatrix.value() * glm::dmat4(rot) * glm::dvec4(tmp)); for (int i = 0; i < 3; i++) { @@ -290,7 +294,12 @@ void RenderableSphericalGrid::update(const UpdateData&) { glBindVertexArray(_vaoID); glBindBuffer(GL_ARRAY_BUFFER, _vBufferID); - glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(Vertex), _varray.data(), GL_STATIC_DRAW); + glBufferData( + GL_ARRAY_BUFFER, + _vsize * sizeof(Vertex), + _varray.data(), + GL_STATIC_DRAW + ); glVertexAttribPointer( 0, @@ -302,7 +311,12 @@ void RenderableSphericalGrid::update(const UpdateData&) { ); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray.data(), GL_STATIC_DRAW); + glBufferData( + GL_ELEMENT_ARRAY_BUFFER, + _isize * sizeof(int), + _iarray.data(), + GL_STATIC_DRAW + ); _gridIsDirty = false; } diff --git a/modules/base/rendering/renderabletrailorbit.cpp b/modules/base/rendering/renderabletrailorbit.cpp index 10011dd912..3818d7f965 100644 --- a/modules/base/rendering/renderabletrailorbit.cpp +++ b/modules/base/rendering/renderabletrailorbit.cpp @@ -229,7 +229,10 @@ void RenderableTrailOrbit::update(const UpdateData& data) { if (_indexBufferDirty) { // We only need to upload the index buffer if it has been invalidated // by changing the number of values we want to represent - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _primaryRenderInformation._iBufferID); + glBindBuffer( + GL_ELEMENT_ARRAY_BUFFER, + _primaryRenderInformation._iBufferID + ); glBufferData( GL_ELEMENT_ARRAY_BUFFER, _indexArray.size() * sizeof(unsigned int), @@ -411,7 +414,8 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails( _primaryRenderInformation.first = 0; } else { - // Move the current pointer fowards one step to be used as the new floating + // Move the current pointer fowards one step to be used as the new + // floating ++_primaryRenderInformation.first; } } diff --git a/modules/base/rendering/renderabletrailtrajectory.cpp b/modules/base/rendering/renderabletrailtrajectory.cpp index b37c5fc894..f8438ccf58 100644 --- a/modules/base/rendering/renderabletrailtrajectory.cpp +++ b/modules/base/rendering/renderabletrailtrajectory.cpp @@ -273,7 +273,9 @@ void RenderableTrailTrajectory::update(const UpdateData& data) { // If we are inside the valid time, we additionally want to draw a line from the last // correct point to the current location of the object - if (data.time.j2000Seconds() >= _start && data.time.j2000Seconds() <= _end && !_renderFullTrail) { + if (data.time.j2000Seconds() >= _start && + data.time.j2000Seconds() <= _end && !_renderFullTrail) + { // Copy the last valid location glm::dvec3 v0( _vertexArray[_primaryRenderInformation.count - 1].x, diff --git a/modules/base/rendering/screenspaceimagelocal.cpp b/modules/base/rendering/screenspaceimagelocal.cpp index 7527cbae99..a9fb5e1cb8 100644 --- a/modules/base/rendering/screenspaceimagelocal.cpp +++ b/modules/base/rendering/screenspaceimagelocal.cpp @@ -113,7 +113,8 @@ void ScreenSpaceImageLocal::update() { texture->uploadTexture(); - // Textures of planets looks much smoother with AnisotropicMipMap rather than linear + // Textures of planets looks much smoother with AnisotropicMipMap rather than + // linear texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); _texture = std::move(texture); diff --git a/modules/base/rendering/screenspaceimageonline.cpp b/modules/base/rendering/screenspaceimageonline.cpp index be8e35a98c..93b2e8f62f 100644 --- a/modules/base/rendering/screenspaceimageonline.cpp +++ b/modules/base/rendering/screenspaceimageonline.cpp @@ -106,7 +106,9 @@ ScreenSpaceImageOnline::ScreenSpaceImageOnline(const ghoul::Dictionary& dictiona void ScreenSpaceImageOnline::update() { if (_textureIsDirty) { if (!_imageFuture.valid()) { - std::future future = downloadImageToMemory(_texturePath); + std::future future = downloadImageToMemory( + _texturePath + ); if (future.valid()) { _imageFuture = std::move(future); } @@ -137,7 +139,8 @@ void ScreenSpaceImageOnline::update() { texture->uploadTexture(); - // Textures of planets looks much smoother with AnisotropicMipMap rather than linear + // Textures of planets looks much smoother with AnisotropicMipMap rather + // than linear texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); _texture = std::move(texture); diff --git a/modules/base/rendering/wavefrontgeometry.cpp b/modules/base/rendering/wavefrontgeometry.cpp index 826005f50d..bbf4f25ba8 100644 --- a/modules/base/rendering/wavefrontgeometry.cpp +++ b/modules/base/rendering/wavefrontgeometry.cpp @@ -53,7 +53,13 @@ bool WavefrontGeometry::loadModel(const std::string& filename) { std::vector shapes; std::vector materials; std::string err; - bool success = tinyobj::LoadObj(shapes, materials, err, filename.c_str(), filename.c_str()); + bool success = tinyobj::LoadObj( + shapes, + materials, + err, + filename.c_str(), + filename.c_str() + ); if (!success) { LERROR(err); @@ -89,10 +95,11 @@ bool WavefrontGeometry::loadModel(const std::string& filename) { psc tmp; for (int i = 0; i < shapes.size(); ++i) { for (int j = 0; j < shapes[i].mesh.positions.size() / 3; ++j) { - tmp = PowerScaledCoordinate::CreatePowerScaledCoordinate(shapes[i].mesh.positions[3 * j + 0], + tmp = PowerScaledCoordinate::CreatePowerScaledCoordinate( + shapes[i].mesh.positions[3 * j + 0], shapes[i].mesh.positions[3 * j + 1], shapes[i].mesh.positions[3 * j + 2] - ); + ); _vertices[j + currentPosition].location[0] = tmp[0]; _vertices[j + currentPosition].location[1] = tmp[1]; @@ -104,8 +111,8 @@ bool WavefrontGeometry::loadModel(const std::string& filename) { _vertices[j + currentPosition].normal[2] = shapes[i].mesh.normals[3 * j + 2]; if (2 * j + 1 < shapes[i].mesh.texcoords.size()) { - _vertices[j + currentPosition].tex[0] = shapes[i].mesh.texcoords[2 * j + 0]; - _vertices[j + currentPosition].tex[1] = shapes[i].mesh.texcoords[2 * j + 1]; + _vertices[j + currentPosition].tex[0] = shapes[i].mesh.texcoords[2*j + 0]; + _vertices[j + currentPosition].tex[1] = shapes[i].mesh.texcoords[2*j + 1]; } } currentPosition += shapes[i].mesh.positions.size() / 3; diff --git a/modules/debugging/rendering/renderabledebugplane.cpp b/modules/debugging/rendering/renderabledebugplane.cpp index 48b79e2f9b..dc381c172a 100644 --- a/modules/debugging/rendering/renderabledebugplane.cpp +++ b/modules/debugging/rendering/renderabledebugplane.cpp @@ -274,7 +274,14 @@ void RenderableDebugPlane::createPlane() { glEnableVertexAttribArray(0); glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, nullptr); glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast(sizeof(GLfloat) * 4)); + glVertexAttribPointer( + 1, + 2, + GL_FLOAT, + GL_FALSE, + sizeof(GLfloat) * 6, + reinterpret_cast(sizeof(GLfloat) * 4) + ); } } // namespace openspace diff --git a/modules/galaxy/rendering/galaxyraycaster.cpp b/modules/galaxy/rendering/galaxyraycaster.cpp index 0d387db5e4..1c3ed1d186 100644 --- a/modules/galaxy/rendering/galaxyraycaster.cpp +++ b/modules/galaxy/rendering/galaxyraycaster.cpp @@ -58,7 +58,9 @@ void GalaxyRaycaster::initialize() { void GalaxyRaycaster::deinitialize() { } -void GalaxyRaycaster::renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) { +void GalaxyRaycaster::renderEntryPoints(const RenderData& data, + ghoul::opengl::ProgramObject& program) +{ program.setUniform("modelTransform", _modelTransform); program.setUniform("viewProjection", data.camera.viewProjectionMatrix()); program.setUniform("blendMode", static_cast(1)); @@ -73,7 +75,9 @@ void GalaxyRaycaster::renderEntryPoints(const RenderData& data, ghoul::opengl::P _boundingBox.render(); } -void GalaxyRaycaster::renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) { +void GalaxyRaycaster::renderExitPoints(const RenderData& data, + ghoul::opengl::ProgramObject& program) +{ // Uniforms program.setUniform("modelTransform", _modelTransform); program.setUniform("viewProjection", data.camera.viewProjectionMatrix()); @@ -91,12 +95,15 @@ void GalaxyRaycaster::renderExitPoints(const RenderData& data, ghoul::opengl::Pr glCullFace(GL_BACK); } -void GalaxyRaycaster::preRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) { +void GalaxyRaycaster::preRaycast(const RaycastData& data, + ghoul::opengl::ProgramObject& program) +{ std::string colorUniformName = "color" + std::to_string(data.id); std::string stepSizeUniformName = "maxStepSize" + std::to_string(data.id); std::string galaxyTextureUniformName = "galaxyTexture" + std::to_string(data.id); std::string volumeAspectUniformName = "aspect" + std::to_string(data.id); - std::string opacityCoefficientUniformName = "opacityCoefficient" + std::to_string(data.id); + std::string opacityCoefficientUniformName = + "opacityCoefficient" + std::to_string(data.id); program.setUniform(volumeAspectUniformName, _aspect); program.setUniform(stepSizeUniformName, _stepSize); @@ -108,7 +115,9 @@ void GalaxyRaycaster::preRaycast(const RaycastData& data, ghoul::opengl::Program program.setUniform(galaxyTextureUniformName, *_textureUnit); } -void GalaxyRaycaster::postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) { +void GalaxyRaycaster::postRaycast(const RaycastData& data, + ghoul::opengl::ProgramObject& program) +{ _textureUnit = nullptr; // release texture unit. } @@ -134,7 +143,9 @@ bool GalaxyRaycaster::cameraIsInside(const RenderData& data, glm::vec3& localPos glm::vec4 modelPos = (glm::inverse(scaledModelTransform) / divisor) * camWorldPos; localPosition = (glm::vec3(modelPos) + glm::vec3(0.5)); - return (localPosition.x > 0 && localPosition.y > 0 && localPosition.z > 0 && localPosition.x < 1 && localPosition.y < 1 && localPosition.z < 1); + return (localPosition.x > 0 && localPosition.y > 0 && + localPosition.z > 0 && localPosition.x < 1 && + localPosition.y < 1 && localPosition.z < 1); } std::string GalaxyRaycaster::getBoundsVsPath() const { diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index 4a52c9b30e..2c62310399 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -158,7 +158,10 @@ void RenderableGalaxy::initialize() { _aspect = static_cast(_volumeDimensions); _aspect = _aspect / std::max(std::max(_aspect.x, _aspect.y), _aspect.z); - volume::RawVolumeReader> reader(_volumeFilename, _volumeDimensions); + volume::RawVolumeReader> reader( + _volumeFilename, + _volumeDimensions + ); _volume = reader.read(); _texture = std::make_unique( @@ -169,7 +172,10 @@ void RenderableGalaxy::initialize() { ghoul::opengl::Texture::FilterMode::Linear, ghoul::opengl::Texture::WrappingMode::Clamp); - _texture->setPixelData(reinterpret_cast(_volume->data()), ghoul::opengl::Texture::TakeOwnership::No); + _texture->setPixelData(reinterpret_cast( + _volume->data()), + ghoul::opengl::Texture::TakeOwnership::No + ); _texture->setDimensions(_volume->dimensions()); _texture->uploadTexture(); @@ -258,7 +264,9 @@ void RenderableGalaxy::initialize() { "${MODULE_GALAXY}/shaders/points.fs", ghoul::Dictionary()); - _pointsProgram->setIgnoreUniformLocationError(ghoul::opengl::ProgramObject::IgnoreError::Yes); + _pointsProgram->setIgnoreUniformLocationError( + ghoul::opengl::ProgramObject::IgnoreError::Yes + ); GLint positionAttrib = _pointsProgram->attributeLocation("inPosition"); GLint colorAttrib = _pointsProgram->attributeLocation("inColor"); @@ -291,12 +299,18 @@ void RenderableGalaxy::update(const UpdateData& data) { //glm::mat4 transform = glm::translate(, static_cast(_translation)); glm::vec3 eulerRotation = static_cast(_rotation); - glm::mat4 transform = glm::rotate(glm::mat4(1.0), eulerRotation.x, glm::vec3(1, 0, 0)); + glm::mat4 transform = glm::rotate( + glm::mat4(1.0), + eulerRotation.x, + glm::vec3(1, 0, 0) + ); transform = glm::rotate(transform, eulerRotation.y, glm::vec3(0, 1, 0)); transform = glm::rotate(transform, eulerRotation.z, glm::vec3(0, 0, 1)); - - glm::mat4 volumeTransform = glm::scale(transform, static_cast(_volumeSize)); + glm::mat4 volumeTransform = glm::scale( + transform, + static_cast(_volumeSize) + ); _pointTransform = glm::scale(transform, static_cast(_pointScaling)); glm::vec4 translation = glm::vec4(static_cast(_translation), 0.0); @@ -339,13 +353,17 @@ void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) { } else if (length < upperRampStart) { opacityCoefficient = 1.0; // sweet spot (max) } else if (length < upperRampEnd) { - opacityCoefficient = 1.0 - (length - upperRampStart) / (upperRampEnd - upperRampStart); //fade out + opacityCoefficient = 1.0 - (length - upperRampStart) / + (upperRampEnd - upperRampStart); //fade out } else { opacityCoefficient = 0; } _opacityCoefficient = opacityCoefficient; - ghoul_assert(_opacityCoefficient >= 0.0 && _opacityCoefficient <= 1.0, "Opacity coefficient was not between 0 and 1"); + ghoul_assert( + _opacityCoefficient >= 0.0 && _opacityCoefficient <= 1.0, + "Opacity coefficient was not between 0 and 1" + ); if (opacityCoefficient > 0) { _raycaster->setOpacityCoefficient(_opacityCoefficient); tasks.raycasterTasks.push_back(task); @@ -353,7 +371,9 @@ void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) { } float RenderableGalaxy::safeLength(const glm::vec3& vector) { - float maxComponent = std::max(std::max(std::abs(vector.x), std::abs(vector.y)), std::abs(vector.z)); + float maxComponent = std::max( + std::max(std::abs(vector.x), std::abs(vector.y)), std::abs(vector.z) + ); return glm::length(vector / maxComponent) * maxComponent; } diff --git a/modules/galaxy/tasks/milkywayconversiontask.cpp b/modules/galaxy/tasks/milkywayconversiontask.cpp index e8ac431538..4002251bb9 100644 --- a/modules/galaxy/tasks/milkywayconversiontask.cpp +++ b/modules/galaxy/tasks/milkywayconversiontask.cpp @@ -86,7 +86,9 @@ void MilkywayConversionTask::perform(const Task::ProgressCallback& progressCallb std::vector filenames; for (int i = 0; i < _inNSlices; i++) { - filenames.push_back(_inFilenamePrefix + std::to_string(i + _inFirstIndex) + _inFilenameSuffix); + filenames.push_back( + _inFilenamePrefix + std::to_string(i + _inFirstIndex) + _inFilenameSuffix + ); } TextureSliceVolumeReader> sliceReader(filenames, _inNSlices, 10); @@ -96,14 +98,20 @@ void MilkywayConversionTask::perform(const Task::ProgressCallback& progressCallb rawWriter.setDimensions(_outDimensions); glm::vec3 resolutionRatio = - static_cast(sliceReader.dimensions()) / static_cast(rawWriter.dimensions()); + static_cast(sliceReader.dimensions()) / + static_cast(rawWriter.dimensions()); - VolumeSampler>> sampler(sliceReader, resolutionRatio); - std::function(glm::ivec3)> sampleFunction = [&](glm::ivec3 outCoord) { - glm::vec3 inCoord = ((glm::vec3(outCoord) + glm::vec3(0.5)) * resolutionRatio) - glm::vec3(0.5); - glm::tvec4 value = sampler.sample(inCoord); - return value; - }; + VolumeSampler>> sampler( + sliceReader, + resolutionRatio + ); + std::function(glm::ivec3)> sampleFunction = + [&](glm::ivec3 outCoord) { + glm::vec3 inCoord = ((glm::vec3(outCoord) + glm::vec3(0.5)) * + resolutionRatio) - glm::vec3(0.5); + glm::tvec4 value = sampler.sample(inCoord); + return value; + }; rawWriter.write(sampleFunction, progressCallback); } diff --git a/modules/iswa/rendering/datacygnet.cpp b/modules/iswa/rendering/datacygnet.cpp index bd85ed442b..4cd2dff370 100644 --- a/modules/iswa/rendering/datacygnet.cpp +++ b/modules/iswa/rendering/datacygnet.cpp @@ -116,27 +116,29 @@ bool DataCygnet::updateTexture(){ bool texturesReady = false; std::vector selectedOptions = _dataOptions.value(); - for(int option: selectedOptions){ + for (int option : selectedOptions) { float* values = data[option]; - if(!values) continue; + if (!values) { + continue; + } - if(!_textures[option]){ - std::unique_ptr texture = std::make_unique( - values, - _textureDimensions, - ghoul::opengl::Texture::Format::Red, - GL_RED, - GL_FLOAT, - ghoul::opengl::Texture::FilterMode::Linear, - ghoul::opengl::Texture::WrappingMode::ClampToEdge - ); + if (!_textures[option]) { + auto texture = std::make_unique( + values, + _textureDimensions, + ghoul::opengl::Texture::Format::Red, + GL_RED, + GL_FLOAT, + ghoul::opengl::Texture::FilterMode::Linear, + ghoul::opengl::Texture::WrappingMode::ClampToEdge + ); - if(texture){ + if (texture) { texture->uploadTexture(); texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); _textures[option] = std::move(texture); } - }else{ + } else { _textures[option]->setPixelData(values); _textures[option]->uploadTexture(); } @@ -149,7 +151,10 @@ bool DataCygnet::downloadTextureResource(double timestamp){ if(_futureObject.valid()) return false; - std::future future = IswaManager::ref().fetchDataCygnet(_data->id, timestamp); + std::future future = IswaManager::ref().fetchDataCygnet( + _data->id, + timestamp + ); if(future.valid()){ _futureObject = std::move(future); @@ -176,14 +181,14 @@ bool DataCygnet::readyToRender() const{ } /** - * Set both transfer function textures and data textures in same function so that they bind to - * the right texture units. If separate in to two functions a list of ghoul::TextureUnit - * needs to be passed as an argument to both. + * Set both transfer function textures and data textures in same function so that they + * bind to the right texture units. If separate in to two functions a list of + * ghoul::TextureUnit needs to be passed as an argument to both. */ void DataCygnet::setTextureUniforms(){ std::vector selectedOptions = _dataOptions.value(); int activeTextures = std::min((int)selectedOptions.size(), MAX_TEXTURES); - int activeTransferfunctions = std::min((int)_transferFunctions.size(), MAX_TEXTURES); + int activeTransferfunctions = std::min((int)_transferFunctions.size(), MAX_TEXTURES); // Set Textures ghoul::opengl::TextureUnit txUnits[MAX_TEXTURES]; @@ -243,10 +248,12 @@ void DataCygnet::readTransferFunctions(std::string tfPath){ std::vector> tfs; - if(tfFile.is_open()){ - while(getline(tfFile, line)){ - std::shared_ptr tf = std::make_shared(absPath(line)); - if(tf){ + if (tfFile.is_open()) { + while (getline(tfFile, line)) { + std::shared_ptr tf = std::make_shared( + absPath(line) + ); + if (tf) { tfs.push_back(tf); } } @@ -254,23 +261,30 @@ void DataCygnet::readTransferFunctions(std::string tfPath){ tfFile.close(); } - if(!tfs.empty()){ + if (!tfs.empty()) { _transferFunctions.clear(); _transferFunctions = tfs; } } -void DataCygnet::fillOptions(std::string& source){ - std::vector options = _dataProcessor->readMetadata(source, _textureDimensions); +void DataCygnet::fillOptions(std::string& source) { + std::vector options = _dataProcessor->readMetadata( + source, + _textureDimensions + ); - for(int i=0; i(_group)->registerOptions(_dataOptions.options()); - _dataOptions.setValue(std::dynamic_pointer_cast(_group)->dataOptionsValue()); + if (_group) { + std::dynamic_pointer_cast(_group)->registerOptions( + _dataOptions.options() + ); + _dataOptions.setValue( + std::dynamic_pointer_cast(_group)->dataOptionsValue() + ); } else { _dataOptions.setValue(std::vector(1,0)); } @@ -326,7 +340,7 @@ void DataCygnet::subscribeToGroup(){ } }); - groupEvent->subscribe(name(), "backgroundValuesChanged", [&](ghoul::Dictionary dict){ + groupEvent->subscribe(name(), "backgroundValuesChanged", [&](ghoul::Dictionary dict) { LDEBUG(name() + " Event backgroundValuesChanged"); glm::vec2 values; bool success = dict.getValue("backgroundValues", values); @@ -335,27 +349,28 @@ void DataCygnet::subscribeToGroup(){ } }); - groupEvent->subscribe(name(), "transferFunctionsChanged", [&](ghoul::Dictionary dict){ + groupEvent->subscribe(name(), "transferFunctionsChanged", [&](ghoul::Dictionary dict) + { LDEBUG(name() + " Event transferFunctionsChanged"); _transferFunctionsFile.setValue(dict.value("transferFunctions")); }); - groupEvent->subscribe(name(), "useLogChanged", [&](const ghoul::Dictionary& dict){ + groupEvent->subscribe(name(), "useLogChanged", [&](const ghoul::Dictionary& dict) { LDEBUG(name() + " Event useLogChanged"); _useLog.setValue(dict.value("useLog")); }); - groupEvent->subscribe(name(), "useHistogramChanged", [&](ghoul::Dictionary dict){ + groupEvent->subscribe(name(), "useHistogramChanged", [&](ghoul::Dictionary dict) { LDEBUG(name() + " Event useHistogramChanged"); _useHistogram.setValue(dict.value("useHistogram")); }); - groupEvent->subscribe(name(), "autoFilterChanged", [&](ghoul::Dictionary dict){ + groupEvent->subscribe(name(), "autoFilterChanged", [&](ghoul::Dictionary dict) { LDEBUG(name() + " Event autoFilterChanged"); _autoFilter.setValue(dict.value("autoFilter")); }); - groupEvent->subscribe(name(), "updateGroup", [&](ghoul::Dictionary dict){ + groupEvent->subscribe(name(), "updateGroup", [&](ghoul::Dictionary dict) { LDEBUG(name() + " Event updateGroup"); if(_autoFilter.value()) _backgroundValues.setValue(_dataProcessor->filterValues()); diff --git a/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index 4cafd3e474..a3fac10b68 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -170,7 +170,10 @@ void IswaCygnet::render(const RenderData& data, RendererTasks&){ } transform = transform*_rotation; - position += transform*glm::vec4(_data->spatialScale.x*_data->offset, _data->spatialScale.w); + position += transform * glm::vec4( + _data->spatialScale.x * _data->offset, + _data->spatialScale.w + ); // Activate shader _shader->activate(); @@ -199,11 +202,18 @@ void IswaCygnet::update(const UpdateData&) { // now if we are going backwards or forwards double clockwiseSign = (OsEng.timeManager().time().deltaTime()>0) ? 1.0 : -1.0; _openSpaceTime = OsEng.timeManager().time().j2000Seconds(); - _realTime = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()); - _stateMatrix = TransformationManager::ref().frameTransformationMatrix(_data->frame, "GALACTIC", _openSpaceTime); + _realTime = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch() + ); + _stateMatrix = TransformationManager::ref().frameTransformationMatrix( + _data->frame, + "GALACTIC", + _openSpaceTime + ); - bool timeToUpdate = (fabs(_openSpaceTime-_lastUpdateOpenSpaceTime) >= _data->updateTime && - (_realTime.count()-_lastUpdateRealTime.count()) > _minRealTimeUpdateInterval); + bool timeToUpdate = + (fabs(_openSpaceTime - _lastUpdateOpenSpaceTime) >= _data->updateTime && + (_realTime.count()-_lastUpdateRealTime.count()) > _minRealTimeUpdateInterval); if (_futureObject.valid() && DownloadManager::futureReady(_futureObject)) { bool success = updateTextureResource(); @@ -245,7 +255,9 @@ void IswaCygnet::initializeTime() { _openSpaceTime = OsEng.timeManager().time().j2000Seconds(); _lastUpdateOpenSpaceTime = 0.0; - _realTime = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()); + _realTime = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch() + ); _lastUpdateRealTime = _realTime; _minRealTimeUpdateInterval = 100; @@ -270,12 +282,12 @@ void IswaCygnet::initializeGroup() { //Subscribe to enable and delete property auto groupEvent = _group->groupEvent(); - groupEvent->subscribe(name(), "enabledChanged", [&](const ghoul::Dictionary& dict){ + groupEvent->subscribe(name(), "enabledChanged", [&](const ghoul::Dictionary& dict) { LDEBUG(name() + " Event enabledChanged"); _enabled.setValue(dict.value("enabled")); }); - groupEvent->subscribe(name(), "alphaChanged", [&](const ghoul::Dictionary& dict){ + groupEvent->subscribe(name(), "alphaChanged", [&](const ghoul::Dictionary& dict) { LDEBUG(name() + " Event alphaChanged"); _alpha.setValue(dict.value("alpha")); }); diff --git a/modules/iswa/rendering/iswakameleongroup.cpp b/modules/iswa/rendering/iswakameleongroup.cpp index 93d0ec3348..b60c826ea6 100644 --- a/modules/iswa/rendering/iswakameleongroup.cpp +++ b/modules/iswa/rendering/iswakameleongroup.cpp @@ -77,13 +77,15 @@ std::vector IswaKameleonGroup::fieldlineValue(){ return _fieldlines.value(); } -void IswaKameleonGroup::setFieldlineInfo(std::string fieldlineIndexFile, std::string kameleonPath){ - if(fieldlineIndexFile != _fieldlineIndexFile){ +void IswaKameleonGroup::setFieldlineInfo(std::string fieldlineIndexFile, + std::string kameleonPath +{ + if (fieldlineIndexFile != _fieldlineIndexFile) { _fieldlineIndexFile = fieldlineIndexFile; readFieldlinePaths(_fieldlineIndexFile); } - if(kameleonPath != _kameleonPath){ + if (kameleonPath != _kameleonPath) { _kameleonPath = kameleonPath; clearFieldlines(); updateFieldlineSeeds(); @@ -91,13 +93,16 @@ void IswaKameleonGroup::setFieldlineInfo(std::string fieldlineIndexFile, std::st } -void IswaKameleonGroup::registerProperties(){ +void IswaKameleonGroup::registerProperties() { //OsEng.gui()._iswa.registerProperty(&_resolution); //OsEng.gui()._iswa.registerProperty(&_fieldlines); _resolution.onChange([this]{ LDEBUG("Group " + name() + " published resolutionChanged"); - _groupEvent->publish("resolutionChanged", ghoul::Dictionary({{"resolution", _resolution.value()}})); + _groupEvent->publish( + "resolutionChanged", + ghoul::Dictionary({{"resolution", _resolution.value()}}) + ); }); _fieldlines.onChange([this]{ @@ -105,7 +110,7 @@ void IswaKameleonGroup::registerProperties(){ }); } -void IswaKameleonGroup::readFieldlinePaths(std::string indexFile){ +void IswaKameleonGroup::readFieldlinePaths(std::string indexFile) { LINFO("Reading seed points paths from file '" << indexFile << "'"); // Read the index file from disk @@ -119,7 +124,7 @@ void IswaKameleonGroup::readFieldlinePaths(std::string indexFile){ fileContent += line; } - try{ + try { //Parse and add each fieldline as an selection json fieldlines = json::parse(fileContent); int i = 0; @@ -134,8 +139,11 @@ void IswaKameleonGroup::readFieldlinePaths(std::string indexFile){ i++; } - } catch(const std::exception& e) { - LERROR("Error when reading json file with paths to seedpoints: " + std::string(e.what())); + } catch (const std::exception& e) { + LERROR( + "Error when reading json file with paths to seedpoints: " + + std::string(e.what()) + ); } } } @@ -146,7 +154,7 @@ void IswaKameleonGroup::updateFieldlineSeeds(){ // SeedPath == map > for (auto& seedPath: _fieldlineState) { // if this option was turned off - if( std::find(selectedOptions.begin(), selectedOptions.end(), seedPath.first)==selectedOptions.end() && std::get<2>(seedPath.second)){ + if (std::find(selectedOptions.begin(), selectedOptions.end(), seedPath.first)==selectedOptions.end() && std::get<2>(seedPath.second)){ LDEBUG("Removed fieldlines: " + std::get<0>(seedPath.second)); OsEng.scriptEngine().queueScript( "openspace.removeSceneGraphNode('" + std::get<0>(seedPath.second) + "')", diff --git a/modules/space/rendering/renderableplanet.cpp b/modules/space/rendering/renderableplanet.cpp index e8b7b5c63c..cad826fb14 100644 --- a/modules/space/rendering/renderableplanet.cpp +++ b/modules/space/rendering/renderableplanet.cpp @@ -413,9 +413,20 @@ void RenderablePlanet::render(const RenderData& data, RendererTasks&) { //glm::mat4 transform = glm::mat4(1); //earth needs to be rotated for that to work. - glm::dmat4 rot = glm::rotate(glm::dmat4(1.0), glm::half_pi(), glm::dvec3(1, 0, 0)); - glm::dmat4 roty = glm::rotate(glm::dmat4(1.0), glm::half_pi(), glm::dvec3(0, -1, 0)); - //glm::dmat4 rotProp = glm::rotate(glm::dmat4(1.0), glm::radians(static_cast(_rotation)), glm::dvec3(0, 1, 0)); + glm::dmat4 rot = glm::rotate( + glm::dmat4(1.0), + glm::half_pi(), + glm::dvec3(1, 0, 0) + ); + glm::dmat4 roty = glm::rotate( + glm::dmat4(1.0), + glm::half_pi(), + glm::dvec3(0, -1, 0) + ); + //glm::dmat4 rotProp = glm::rotate( + // glm::dmat4(1.0), + // glm::radians(static_cast(_rotation)), glm::dvec3(0, 1, 0) + //); modelTransform = modelTransform * rot * roty /** rotProp*/; glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; @@ -429,7 +440,10 @@ void RenderablePlanet::render(const RenderData& data, RendererTasks&) { // Normal Transformation //glm::mat4 translateObjTrans = glm::translate(glm::mat4(1.0), data.position.vec3()); - //glm::mat4 translateCamTrans = glm::translate(glm::mat4(1.0), -data.camera.position().vec3()); + //glm::mat4 translateCamTrans = glm::translate( + // glm::mat4(1.0), + // -data.camera.position().vec3() + //); //float scaleFactor = data.camera.scaling().x * powf(10.0, data.camera.scaling().y); //glm::mat4 scaleCamTrans = glm::scale(glm::mat4(1.0), glm::vec3(scaleFactor)); @@ -477,22 +491,48 @@ void RenderablePlanet::render(const RenderData& data, RendererTasks&) { shadowDataArray.reserve(_shadowConfArray.size()); for (const auto & shadowConf : _shadowConfArray) { - // TO REMEMBER: all distances and lengths in world coordinates are in meters!!! We need to move this to view space... + // TO REMEMBER: all distances and lengths in world coordinates are in meters!! + // We need to move this to view space... // Getting source and caster: - glm::dvec3 sourcePos = SpiceManager::ref().targetPosition(shadowConf.source.first, "SUN", "GALACTIC", {}, _time, lt); + glm::dvec3 sourcePos = SpiceManager::ref().targetPosition( + shadowConf.source.first, + "SUN", + "GALACTIC", + {}, + _time, + lt + ); sourcePos *= 1000.0; // converting to meters - glm::dvec3 casterPos = SpiceManager::ref().targetPosition(shadowConf.caster.first, "SUN", "GALACTIC", {}, _time, lt); + glm::dvec3 casterPos = SpiceManager::ref().targetPosition( + shadowConf.caster.first, + "SUN", + "GALACTIC", + {}, + _time, + lt + ); casterPos *= 1000.0; // converting to meters - psc caster_pos = PowerScaledCoordinate::CreatePowerScaledCoordinate(casterPos.x, casterPos.y, casterPos.z); + psc caster_pos = PowerScaledCoordinate::CreatePowerScaledCoordinate( + casterPos.x, + casterPos.y, + casterPos.z + ); - // First we determine if the caster is shadowing the current planet (all calculations in World Coordinates): - glm::vec3 planetCasterVec = (caster_pos - data.position).vec3(); - glm::vec3 sourceCasterVec = glm::vec3(casterPos - sourcePos); - float sc_length = glm::length(sourceCasterVec); - glm::vec3 planetCaster_proj = (glm::dot(planetCasterVec, sourceCasterVec) / (sc_length*sc_length)) * sourceCasterVec; - float d_test = glm::length(planetCasterVec - planetCaster_proj); - float xp_test = shadowConf.caster.second * sc_length / (shadowConf.source.second + shadowConf.caster.second); - float rp_test = shadowConf.caster.second * (glm::length(planetCaster_proj) + xp_test) / xp_test; + // First we determine if the caster is shadowing the current planet (all + // calculations in World Coordinates): + glm::vec3 planetCasterVec = (caster_pos - data.position).vec3(); + glm::vec3 sourceCasterVec = glm::vec3(casterPos - sourcePos); + float sc_length = glm::length(sourceCasterVec); + glm::vec3 planetCaster_proj = + (glm::dot(planetCasterVec, sourceCasterVec) / + (sc_length*sc_length)) * sourceCasterVec; + float d_test = glm::length(planetCasterVec - planetCaster_proj); + float xp_test = + shadowConf.caster.second * sc_length / + (shadowConf.source.second + shadowConf.caster.second); + float rp_test = + shadowConf.caster.second * (glm::length(planetCaster_proj) + xp_test) / + xp_test; double casterDistSun = glm::length(casterPos); float planetDistSun = glm::length(data.position.vec3()); @@ -503,12 +543,13 @@ void RenderablePlanet::render(const RenderData& data, RendererTasks&) { if (((d_test - rp_test) < _planetRadius) && (casterDistSun < planetDistSun) ) { // The current caster is shadowing the current planet - shadowData.isShadowing = true; - shadowData.rs = shadowConf.source.second; - shadowData.rc = shadowConf.caster.second; - shadowData.sourceCasterVec = sourceCasterVec; - shadowData.xp = xp_test; - shadowData.xu = shadowData.rc * sc_length / (shadowData.rs - shadowData.rc); + shadowData.isShadowing = true; + shadowData.rs = shadowConf.source.second; + shadowData.rc = shadowConf.caster.second; + shadowData.sourceCasterVec = sourceCasterVec; + shadowData.xp = xp_test; + shadowData.xu = + shadowData.rc * sc_length / (shadowData.rs - shadowData.rc); shadowData.casterPositionVec = glm::vec3(casterPos); } shadowDataArray.push_back(shadowData); @@ -555,14 +596,20 @@ void RenderablePlanet::render(const RenderData& data, RendererTasks&) { void RenderablePlanet::update(const UpdateData& data) { // set spice-orientation in accordance to timestamp _stateMatrix = data.modelTransform.rotation; - //_stateMatrix = SpiceManager::ref().positionTransformMatrix(_frame, "GALACTIC", data.time); + //_stateMatrix = SpiceManager::ref().positionTransformMatrix( + // _frame, + // "GALACTIC", + // data.time + //); _time = data.time.j2000Seconds(); } void RenderablePlanet::loadTexture() { _texture = nullptr; if (_colorTexturePath.value() != "") { - _texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath)); + _texture = ghoul::io::TextureReader::ref().loadTexture( + absPath(_colorTexturePath) + ); if (_texture) { if (_texture->numberOfChannels() == 1) { _texture->setSwizzleMask({ GL_RED, GL_RED, GL_RED, GL_RED }); @@ -571,7 +618,8 @@ void RenderablePlanet::loadTexture() { LDEBUG("Loaded texture from '" << _colorTexturePath << "'"); _texture->uploadTexture(); - // Textures of planets looks much smoother with AnisotropicMipMap rather than linear + // Textures of planets looks much smoother with AnisotropicMipMap rather than + // linear // TODO: AnisotropicMipMap crashes on ATI cards ---abock //_texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); _texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); @@ -581,12 +629,16 @@ void RenderablePlanet::loadTexture() { if (_hasNightTexture) { _nightTexture = nullptr; if (_nightTexturePath.value() != "") { - _nightTexture = ghoul::io::TextureReader::ref().loadTexture(absPath(_nightTexturePath)); + _nightTexture = ghoul::io::TextureReader::ref().loadTexture( + absPath(_nightTexturePath) + ); if (_nightTexture) { LDEBUG("Loaded texture from '" << _nightTexturePath << "'"); _nightTexture->uploadTexture(); _nightTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); - //_nightTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + //_nightTexture->setFilter( + // ghoul::opengl::Texture::FilterMode::AnisotropicMipMap + //); } } } @@ -594,12 +646,16 @@ void RenderablePlanet::loadTexture() { if (_hasHeightTexture) { _heightMapTexture = nullptr; if (_heightMapTexturePath.value() != "") { - _heightMapTexture = ghoul::io::TextureReader::ref().loadTexture(absPath(_heightMapTexturePath)); + _heightMapTexture = ghoul::io::TextureReader::ref().loadTexture( + absPath(_heightMapTexturePath) + ); if (_heightMapTexture) { LDEBUG("Loaded texture from '" << _heightMapTexturePath << "'"); _heightMapTexture->uploadTexture(); _heightMapTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear); - //_nightTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + //_nightTexture->setFilter( + // ghoul::opengl::Texture::FilterMode::AnisotropicMipMap + //); } } } diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index d96e47e23c..8912cd6129 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -339,7 +339,10 @@ void RenderableStars::render(const RenderData& data, RendererTasks&) { _program->setUniform("alphaValue", _alphaValue); _program->setUniform("scaleFactor", _scaleFactor); _program->setUniform("minBillboardSize", _minBillboardSize); - _program->setUniform("screenSize", glm::vec2(OsEng.renderEngine().renderingResolution())); + _program->setUniform( + "screenSize", + glm::vec2(OsEng.renderEngine().renderingResolution()) + ); setPscUniforms(*_program.get(), data.camera, data.position); _program->setUniform("scaling", scaling); @@ -507,7 +510,9 @@ void RenderableStars::update(const UpdateData&) { ); _pointSpreadFunctionTexture->uploadTexture(); } - _pointSpreadFunctionTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + _pointSpreadFunctionTexture->setFilter( + ghoul::opengl::Texture::FilterMode::AnisotropicMipMap + ); _pointSpreadFunctionFile = std::make_unique( _pointSpreadFunctionTexturePath @@ -525,7 +530,9 @@ void RenderableStars::update(const UpdateData&) { LDEBUG("Reloading Color Texture"); _colorTexture = nullptr; if (_colorTexturePath.value() != "") { - _colorTexture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath)); + _colorTexture = ghoul::io::TextureReader::ref().loadTexture( + absPath(_colorTexturePath) + ); if (_colorTexture) { LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'"); _colorTexture->uploadTexture(); diff --git a/modules/space/spacemodule.cpp b/modules/space/spacemodule.cpp index 5b2ba60d00..305ebbd1bc 100644 --- a/modules/space/spacemodule.cpp +++ b/modules/space/spacemodule.cpp @@ -56,7 +56,9 @@ void SpaceModule::internalInitialize() { auto fRenderable = FactoryManager::ref().factory(); ghoul_assert(fRenderable, "Renderable factory was not created"); - fRenderable->registerClass("RenderableConstellationBounds"); + fRenderable->registerClass( + "RenderableConstellationBounds" + ); fRenderable->registerClass("RenderablePlanet"); fRenderable->registerClass("RenderableRings"); fRenderable->registerClass("RenderableStars"); @@ -73,9 +75,9 @@ void SpaceModule::internalInitialize() { fRotation->registerClass("SpiceRotation"); - auto fPlanetGeometry = FactoryManager::ref().factory(); - ghoul_assert(fPlanetGeometry, "Planet geometry factory was not created"); - fPlanetGeometry->registerClass("SimpleSphere"); + auto fGeometry = FactoryManager::ref().factory(); + ghoul_assert(fGeometry, "Planet geometry factory was not created"); + fGeometry->registerClass("SimpleSphere"); } std::vector SpaceModule::documentations() const { diff --git a/modules/space/translation/keplertranslation.cpp b/modules/space/translation/keplertranslation.cpp index 90b329a564..b2aa8bb9d3 100644 --- a/modules/space/translation/keplertranslation.cpp +++ b/modules/space/translation/keplertranslation.cpp @@ -280,7 +280,8 @@ double KeplerTranslation::eccentricAnomaly(double meanAnomaly) const { double f = x - s - meanAnomaly; double f1 = 1 - c; double f2 = s; - return x + (-5 * f / (f1 + sign(f1) * sqrt(std::abs(16 * f1 * f1 - 20 * f * f2)))); + return x + (-5 * f / (f1 + sign(f1) * + sqrt(std::abs(16 * f1 * f1 - 20 * f * f2)))); }; return solveIteration(solver, e, 0.0, 8); } diff --git a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp index 1d168caaea..51d4014f91 100644 --- a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp +++ b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp @@ -235,7 +235,11 @@ void RenderableCrawlingLine::update(const UpdateData& data) { // data.time.j2000Seconds() // ); - glm::dmat3 tm = SpiceManager::ref().frameTransformationMatrix(_instrumentName, "ECLIPJ2000", data.time.j2000Seconds()); + glm::dmat3 tm = SpiceManager::ref().frameTransformationMatrix( + _instrumentName, + "ECLIPJ2000", + data.time.j2000Seconds() + ); //_positions[SourcePosition] = { 0.f, 0.f, 0.f, 0.f }; @@ -267,7 +271,11 @@ void RenderableCrawlingLine::update(const UpdateData& data) { { _lineColorBegin.r, _lineColorBegin.g, _lineColorBegin.b, _lineColorBegin.a } }, { - { target.x * powf(10, target.w), target.y * powf(10, target.w), target.z * powf(10, target.w) }, + { + target.x * powf(10, target.w), + target.y * powf(10, target.w), + target.z * powf(10, target.w) + }, { _lineColorEnd.r, _lineColorEnd.g, _lineColorEnd.b, _lineColorEnd.a } } }; diff --git a/modules/spacecraftinstruments/rendering/renderablefov.cpp b/modules/spacecraftinstruments/rendering/renderablefov.cpp index 22d4a1a60b..2612b023fb 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.cpp +++ b/modules/spacecraftinstruments/rendering/renderablefov.cpp @@ -306,7 +306,9 @@ void RenderableFov::initialize() { ); // Fetch information about the specific instrument - SpiceManager::FieldOfViewResult res = SpiceManager::ref().fieldOfView(_instrument.name); + SpiceManager::FieldOfViewResult res = SpiceManager::ref().fieldOfView( + _instrument.name + ); // Right now, we can only deal with rectangles or polygons. Circles and ellipses only // return one or two bound vectors that have to used to construct an approximation @@ -365,7 +367,7 @@ void RenderableFov::initialize() { GL_FLOAT, GL_FALSE, sizeof(RenderInformation::VBOData), - nullptr // = reinterpret_cast(offsetof(RenderInformation::VBOData, position)) + nullptr ); glEnableVertexAttribArray(1); glVertexAttribIPointer( @@ -395,7 +397,7 @@ void RenderableFov::initialize() { GL_FLOAT, GL_FALSE, sizeof(RenderInformation::VBOData), - nullptr // = reinterpret_cast(offsetof(RenderInformation::VBOData, position)) + nullptr ); glEnableVertexAttribArray(1); glVertexAttribIPointer( @@ -425,16 +427,28 @@ bool RenderableFov::isReady() const { } // Orthogonal projection next to planets surface -glm::dvec3 RenderableFov::orthogonalProjection(const glm::dvec3& vecFov, double time, const std::string& target) const { - glm::dvec3 vecToTarget = SpiceManager::ref().targetPosition(target, _instrument.spacecraft, _instrument.referenceFrame, _instrument.aberrationCorrection, time); - glm::dvec3 fov = SpiceManager::ref().frameTransformationMatrix(_instrument.name, _instrument.referenceFrame, time) * vecFov; +glm::dvec3 RenderableFov::orthogonalProjection(const glm::dvec3& vecFov, double time, + const std::string& target) const +{ + glm::dvec3 vecToTarget = SpiceManager::ref().targetPosition( + target, + _instrument.spacecraft, + _instrument.referenceFrame, + _instrument.aberrationCorrection, + time + ); + glm::dvec3 fov = SpiceManager::ref().frameTransformationMatrix( + _instrument.name, + _instrument.referenceFrame, + time + ) * vecFov; glm::dvec3 p = glm::proj(vecToTarget, fov); return p * 1000.0; // km -> m } template double bisect(const glm::dvec3& p1, const glm::dvec3& p2, Func testFunction, - const glm::dvec3& previousHalf = glm::dvec3(std::numeric_limits::max())) + const glm::dvec3& previousHalf = glm::dvec3(std::numeric_limits::max())) { const double Tolerance = 0.00000001; const glm::dvec3 half = glm::mix(p1, p2, 0.5); @@ -450,8 +464,12 @@ double bisect(const glm::dvec3& p1, const glm::dvec3& p2, Func testFunction, } } -void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& target, bool isInFov) { - auto makeBodyFixedReferenceFrame = [&target](std::string ref) -> std::pair { +void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& target, + bool isInFov) +{ + auto makeBodyFixedReferenceFrame = + [&target](std::string ref) -> std::pair + { bool convert = (ref.find("IAU_") == std::string::npos); if (convert) { return { SpiceManager::ref().frameFromBody(target), true }; @@ -487,7 +505,8 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& second = { { o.x, o.y, o.z }, - RenderInformation::VertexColorTypeDefaultEnd // This had a different color (0.4) before ---abock + // This had a different color (0.4) before ---abock + RenderInformation::VertexColorTypeDefaultEnd }; } else { @@ -533,7 +552,11 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& } else { // This point did not intersect the target though others did - glm::vec3 o = orthogonalProjection(bound, data.time.j2000Seconds(), target); + glm::vec3 o = orthogonalProjection( + bound, + data.time.j2000Seconds(), + target + ); second = { { o.x, o.y, o.z }, RenderInformation::VertexColorTypeInFieldOfView @@ -597,15 +620,16 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& // the intercept vector is in meter and contains a standoff distance offset auto interceptVector = [&](const glm::dvec3& probe) -> glm::dvec3 { auto ref = makeBodyFixedReferenceFrame(_instrument.referenceFrame); - SpiceManager::SurfaceInterceptResult r = SpiceManager::ref().surfaceIntercept( - target, - _instrument.spacecraft, - _instrument.name, - ref.first, - _instrument.aberrationCorrection, - data.time.j2000Seconds(), - probe - ); + SpiceManager::SurfaceInterceptResult r = + SpiceManager::ref().surfaceIntercept( + target, + _instrument.spacecraft, + _instrument.name, + ref.first, + _instrument.aberrationCorrection, + data.time.j2000Seconds(), + probe + ); if (ref.second) { r.surfaceVector = SpiceManager::ref().frameTransformationMatrix( @@ -633,7 +657,11 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& }; } else { - const glm::vec3 o = orthogonalProjection(tBound, data.time.j2000Seconds(), target); + const glm::vec3 o = orthogonalProjection( + tBound, + data.time.j2000Seconds(), + target + ); _orthogonalPlane.data[indexForBounds(i) + m] = { { o.x, o.y, o.z }, @@ -698,8 +726,12 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& // OBS: i and j are in bounds-space, p1, p2 are in // _orthogonalPlane-space - const size_t p1 = static_cast(indexForBounds(i) + t1 * InterpolationSteps); - const size_t p2 = static_cast(indexForBounds(i) + t2 * InterpolationSteps); + const size_t p1 = static_cast( + indexForBounds(i) + t1 * InterpolationSteps + ); + const size_t p2 = static_cast( + indexForBounds(i) + t2 * InterpolationSteps + ); // We can copy the non-intersecting parts copyFieldOfViewValues(i, indexForBounds(i), p1); @@ -717,7 +749,11 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& } } else { - copyFieldOfViewValues(i, indexForBounds(i), indexForBounds(i + 1)); + copyFieldOfViewValues( + i, + indexForBounds(i), + indexForBounds(i + 1) + ); } break; } @@ -741,15 +777,24 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& //if (intercepts[i] == false) { // If point is non-interceptive, project it. - // insertPoint(_fovPlane, glm::vec4(orthogonalProjection(current, data.time, target), 0.0), tmp); + // insertPoint( + // _fovPlane, + // glm::vec4( + // orthogonalProjection(current, data.time, target), + // 0.0 + // ), + // tmp + // ); // _rebuild = true; // if (intercepts[i + 1] == false) { - // // IFF incident point is also non-interceptive BUT something is within FOV + // // IFF incident point is also non-interceptive BUT something is + // // within FOV // // we need then to check if this segment makes contact with surface // glm::dvec3 half = interpolate(current, next, 0.5f); // std::string bodyfixed = "IAU_"; - // bool convert = (_instrument.referenceFrame.find(bodyfixed) == std::string::npos); + // bool convert = (_instrument.referenceFrame.find(bodyfixed) == + // std::string::npos); // if (convert) { // bodyfixed = SpiceManager::ref().frameFromBody(target); // } @@ -758,11 +803,23 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& // } // SpiceManager::SurfaceInterceptResult res = - // SpiceManager::ref().surfaceIntercept(target, _instrument.spacecraft, - // _instrument.name, bodyfixed, _instrument.aberrationCorrection, data.time, half); + // SpiceManager::ref().surfaceIntercept( + // target, + // _instrument.spacecraft, + // _instrument.name, + // bodyfixed, + // _instrument.aberrationCorrection, + // data.time, + // half + // ); // if (convert) { - // res.surfaceVector = SpiceManager::ref().frameTransformationMatrix(bodyfixed, _instrument.referenceFrame, data.time) * res.surfaceVector; + // res.surfaceVector = + // SpiceManager::ref().frameTransformationMatrix( + // bodyfixed, + // _instrument.referenceFrame, + // data.time + // ) * res.surfaceVector; // } // bool intercepted = res.interceptFound; @@ -772,43 +829,81 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& // glm::dvec3 root1 = bisection(half, current, data.time, target); // glm::dvec3 root2 = bisection(half, next, data.time, target); - // insertPoint(_fovPlane, glm::vec4(orthogonalProjection(root1, data.time, target), 0.0), squareColor(diffTime)); + // insertPoint( + // _fovPlane, + // glm::vec4( + // orthogonalProjection( + // root1, + // data.time, + // target + // ), + // 0.0 + // ), + // squareColor(diffTime) + // ); // for (int j = 1; j < InterpolationSteps; ++j) { // float t = (static_cast(j) / InterpolationSteps); // interpolated = interpolate(root1, root2, t); - // glm::dvec3 ivec = checkForIntercept(interpolated, data.time, target); - // insertPoint(_fovPlane, glm::vec4(ivec, 0.0), squareColor(diffTime)); + // glm::dvec3 ivec = checkForIntercept( + // interpolated, + // data.time, + // target + // ); + // insertPoint( + // _fovPlane, + // glm::vec4(ivec, 0.0), + // squareColor(diffTime) + // ); // } - // insertPoint(_fovPlane, glm::vec4(orthogonalProjection(root2, data.time, target), 0.0), squareColor(diffTime)); + // insertPoint( + // _fovPlane, + // glm::vec4( + // orthogonalProjection(root2, data.time, target), 0.0 + // ), + // squareColor(diffTime) + // ); // } // } //} - //if (interceptTag[i] == true && interceptTag[i + 1] == false) { // current point is interceptive, next is not - // // find outer most point for interpolation + //if (interceptTag[i] == true && interceptTag[i + 1] == false) { + // // current point is interceptive, next is not + // // find outer most point for interpolation // mid = bisection(current, next, data.time, target); // for (int j = 1; j <= InterpolationSteps; ++j) { // float t = (static_cast(j) / InterpolationSteps); // interpolated = interpolate(current, mid, t); - // glm::dvec3 ivec = (j < InterpolationSteps) ? checkForIntercept(interpolated, data.time, target) : orthogonalProjection(interpolated, data.time, target); + // glm::dvec3 ivec = + // (j < InterpolationSteps) ? + // checkForIntercept(interpolated, data.time, target) : + // orthogonalProjection(interpolated, data.time, target); // insertPoint(_fovPlane, glm::vec4(ivec, 0.0), squareColor(diffTime)); // _rebuild = true; // } //} - //if (interceptTag[i] == false && interceptTag[i + 1] == true) { // current point is non-interceptive, next is + //if (interceptTag[i] == false && interceptTag[i + 1] == true) { + // // current point is non-interceptive, next is // mid = bisection(next, current, data.time, target); // for (int j = 1; j <= InterpolationSteps; ++j) { // float t = (static_cast(j) / InterpolationSteps); // interpolated = interpolate(mid, next, t); - // glm::dvec3 ivec = (j > 1) ? checkForIntercept(interpolated, data.time, target) : orthogonalProjection(interpolated, data.time, target); + // glm::dvec3 ivec = + // (j > 1) ? + // checkForIntercept(interpolated, data.time, target) : + // orthogonalProjection(interpolated, data.time, target); // insertPoint(_fovPlane, glm::vec4(ivec, 0.0), squareColor(diffTime)); // _rebuild = true; // } //} - //if (interceptTag[i] == true && interceptTag[i + 1] == true) { // both points intercept + //if (interceptTag[i] == true && interceptTag[i + 1] == true) { + // // both points intercept // for (int j = 0; j <= InterpolationSteps; ++j) { // float t = (static_cast(j) / InterpolationSteps); // interpolated = interpolate(current, next, t); - // glm::dvec3 ivec = checkForIntercept(interpolated, data.time, target); + // glm::dvec3 ivec = checkForIntercept( + // interpolated, + // data.time, + // target + // ); // insertPoint(_fovPlane, glm::vec4(ivec, 0.0), squareColor(diffTime)); // _rebuild = true; // } @@ -821,7 +916,9 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& } #if 0 -void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& target, bool inFOV) { +void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& target, + bool inFOV) +{ double t2 = (openspace::ImageSequencer::ref().getNextCaptureTime()); double diff = (t2 - data.time); float diffTime = 0.0; @@ -849,11 +946,22 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& } SpiceManager::SurfaceInterceptResult res = - SpiceManager::ref().surfaceIntercept(target, _instrument.spacecraft, - _instrument.name, bodyfixed, _instrument.aberrationCorrection, data.time, _instrument.bounds[r]); + SpiceManager::ref().surfaceIntercept( + target, + _instrument.spacecraft, + _instrument.name, + bodyfixed, + _instrument.aberrationCorrection, + data.time, + _instrument.bounds[r] + ); if (convert) { - res.surfaceVector = SpiceManager::ref().frameTransformationMatrix(bodyfixed, _instrument.referenceFrame, data.time) * res.surfaceVector; + res.surfaceVector = SpiceManager::ref().frameTransformationMatrix( + bodyfixed, + _instrument.referenceFrame, + data.time + ) * res.surfaceVector; } interceptTag[r] = res.interceptFound; @@ -863,13 +971,17 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& if (!interceptTag[r]) { b = orthogonalProjection(_instrument.bounds[r], data.time, target); } - - glm::vec4 fovOrigin = glm::vec4(0); //This will have to be fixed once spacecraft is 1:1! + //This will have to be fixed once spacecraft is 1:1! + glm::vec4 fovOrigin = glm::vec4(0); if (interceptTag[r]) { // INTERCEPTIONS insertPoint(_fovBounds, fovOrigin, _colors.intersectionStart); - insertPoint(_fovBounds, glm::vec4(res.surfaceVector, 0.0), endColor(diffTime)); + insertPoint( + _fovBounds, + glm::vec4(res.surfaceVector, 0.0), + endColor(diffTime) + ); } else if (inFOV) { // OBJECT IN FOV, NO INTERCEPT FOR THIS FOV-RAY @@ -908,15 +1020,21 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& next = bounds[k]; if (interceptTag[i] == false) { // If point is non-interceptive, project it. - insertPoint(_fovPlane, glm::vec4(orthogonalProjection(current, data.time, target), 0.0), tmp); + insertPoint( + _fovPlane, + glm::vec4(orthogonalProjection(current, data.time, target), 0.0), + tmp + ); _rebuild = true; if (interceptTag[i + 1] == false && inFOV) { - // IFF incident point is also non-interceptive BUT something is within FOV + // IFF incident point is also non-interceptive BUT something is within + // FOV // we need then to check if this segment makes contact with surface glm::dvec3 half = interpolate(current, next, 0.5f); std::string bodyfixed = "IAU_"; - bool convert = (_instrument.referenceFrame.find(bodyfixed) == std::string::npos); + bool convert = (_instrument.referenceFrame.find(bodyfixed) == + std::string::npos); if (convert) { bodyfixed = SpiceManager::ref().frameFromBody(target); } @@ -925,11 +1043,22 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& } SpiceManager::SurfaceInterceptResult res = - SpiceManager::ref().surfaceIntercept(target, _instrument.spacecraft, - _instrument.name, bodyfixed, _instrument.aberrationCorrection, data.time, half); + SpiceManager::ref().surfaceIntercept( + target, + _instrument.spacecraft, + _instrument.name, + bodyfixed, + _instrument.aberrationCorrection, + data.time, + half + ); if (convert) { - res.surfaceVector = SpiceManager::ref().frameTransformationMatrix(bodyfixed, _instrument.referenceFrame, data.time) * res.surfaceVector; + res.surfaceVector = SpiceManager::ref().frameTransformationMatrix( + bodyfixed, + _instrument.referenceFrame, + data.time + ) * res.surfaceVector; } bool intercepted = res.interceptFound; @@ -939,39 +1068,70 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& glm::dvec3 root1 = bisection(half, current, data.time, target); glm::dvec3 root2 = bisection(half, next, data.time, target); - insertPoint(_fovPlane, glm::vec4(orthogonalProjection(root1, data.time, target), 0.0), squareColor(diffTime)); + insertPoint( + _fovPlane, + glm::vec4( + orthogonalProjection(root1, data.time, target), + 0.0 + ), + squareColor(diffTime) + ); for (int j = 1; j < InterpolationSteps; ++j) { float t = (static_cast(j) / InterpolationSteps); interpolated = interpolate(root1, root2, t); - glm::dvec3 ivec = checkForIntercept(interpolated, data.time, target); - insertPoint(_fovPlane, glm::vec4(ivec,0.0) , squareColor(diffTime)); + glm::dvec3 ivec = checkForIntercept( + interpolated, + data.time, + target + ); + insertPoint( + _fovPlane, + glm::vec4(ivec,0.0), + squareColor(diffTime) + ); } - insertPoint(_fovPlane, glm::vec4(orthogonalProjection(root2, data.time, target), 0.0), squareColor(diffTime)); + insertPoint( + _fovPlane, + glm::vec4( + orthogonalProjection(root2, data.time, target), + 0.0 + ), + squareColor(diffTime) + ); } } } - if (interceptTag[i] == true && interceptTag[i + 1] == false) { // current point is interceptive, next is not - // find outer most point for interpolation + if (interceptTag[i] == true && interceptTag[i + 1] == false) { + // current point is interceptive, next is not + // find outer most point for interpolation mid = bisection(current, next, data.time, target); for (int j = 1; j <= InterpolationSteps; ++j) { float t = (static_cast(j) / InterpolationSteps); interpolated = interpolate(current, mid, t); - glm::dvec3 ivec = (j < InterpolationSteps) ? checkForIntercept(interpolated, data.time, target) : orthogonalProjection(interpolated, data.time, target); + glm::dvec3 ivec = + (j < InterpolationSteps) ? + checkForIntercept(interpolated, data.time, target) : + orthogonalProjection(interpolated, data.time, target); insertPoint(_fovPlane, glm::vec4(ivec, 0.0), squareColor(diffTime)); _rebuild = true; } } - if (interceptTag[i] == false && interceptTag[i + 1] == true) { // current point is non-interceptive, next is + if (interceptTag[i] == false && interceptTag[i + 1] == true) { + // current point is non-interceptive, next is mid = bisection(next, current, data.time, target); for (int j = 1; j <= InterpolationSteps; ++j) { float t = (static_cast(j) / InterpolationSteps); interpolated = interpolate(mid, next, t); - glm::dvec3 ivec = (j > 1) ? checkForIntercept(interpolated, data.time, target) : orthogonalProjection(interpolated, data.time, target); + glm::dvec3 ivec = + (j > 1) ? + checkForIntercept(interpolated, data.time, target) : + orthogonalProjection(interpolated, data.time, target); insertPoint(_fovPlane, glm::vec4(ivec, 0.0), squareColor(diffTime)); _rebuild = true; } } - if (interceptTag[i] == true && interceptTag[i + 1] == true) { // both points intercept + if (interceptTag[i] == true && interceptTag[i + 1] == true) { + // both points intercept for (int j = 0; j <= InterpolationSteps; ++j) { float t = (static_cast(j) / InterpolationSteps); interpolated = interpolate(current, next, t); @@ -989,7 +1149,11 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& // glm::mat4 spacecraftRotation = glm::mat4( - SpiceManager::ref().positionTransformMatrix(_instrument.name, _instrument.referenceFrame, data.time) + SpiceManager::ref().positionTransformMatrix( + _instrument.name, + _instrument.referenceFrame, + data.time + ) ); glm::vec3 aim = (spacecraftRotation * glm::vec4(_instrument.boresight, 1)); @@ -1003,7 +1167,11 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string& data.time, lt ); - psc p = PowerScaledCoordinate::CreatePowerScaledCoordinate(position.x, position.y, position.z); + psc p = PowerScaledCoordinate::CreatePowerScaledCoordinate( + position.x, + position.y, + position.z + ); pss length = p.length(); if (length[0] < DBL_EPSILON) { _drawFOV = false; @@ -1022,7 +1190,7 @@ void RenderableFov::render(const RenderData& data, RendererTasks&) { // Model transform and view transform needs to be in double precision glm::dmat4 modelTransform = - glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation + glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * glm::dmat4(data.modelTransform.rotation) * glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); @@ -1031,12 +1199,18 @@ void RenderableFov::render(const RenderData& data, RendererTasks&) { glm::mat4(data.camera.combinedViewMatrix() * modelTransform); - _programObject->setUniform("modelViewProjectionTransform", modelViewProjectionTransform); + _programObject->setUniform( + "modelViewProjectionTransform", + modelViewProjectionTransform + ); _programObject->setUniform("defaultColorStart", _colors.defaultStart); _programObject->setUniform("defaultColorEnd", _colors.defaultEnd); _programObject->setUniform("activeColor", _colors.active); - _programObject->setUniform("targetInFieldOfViewColor", _colors.targetInFieldOfView); + _programObject->setUniform( + "targetInFieldOfViewColor", + _colors.targetInFieldOfView + ); _programObject->setUniform("intersectionStartColor", _colors.intersectionStart); _programObject->setUniform("intersectionEndColor", _colors.intersectionEnd); _programObject->setUniform("squareColor", _colors.square); @@ -1118,7 +1292,9 @@ std::pair RenderableFov::determineTarget(double time) { _instrument.potentialTargets.begin(), _instrument.potentialTargets.end(), distances.begin(), - [&o = _instrument.spacecraft, &f = _instrument.referenceFrame, &t = time](const std::string& pt) { + [&o = _instrument.spacecraft, &f = _instrument.referenceFrame, &t = time] + (const std::string& pt) + { double lt; glm::dvec3 p = SpiceManager::ref().targetPosition(pt, o, f, {}, t, lt); return glm::length(p); @@ -1157,27 +1333,54 @@ void RenderableFov::updateGPU() { //glBindBuffer(GL_ARRAY_BUFFER, _bounds.vbo); - //glBufferSubData(GL_ARRAY_BUFFER, 0, _bounds.size * sizeof(GLfloat), _fovBounds.data()); + //glBufferSubData( + // GL_ARRAY_BUFFER, + // 0, + // _bounds.size * sizeof(GLfloat), + // _fovBounds.data() + //); ////LINFOC(_instrument, _boundsV.size); //if (!_rebuild) { // // no new points // glBindBuffer(GL_ARRAY_BUFFER, _orthogonalPlane.vbo); - // glBufferSubData(GL_ARRAY_BUFFER, 0, _orthogonalPlane.size * sizeof(GLfloat), _fovPlane.data()); + // glBufferSubData( + // GL_ARRAY_BUFFER, + // 0, + // _orthogonalPlane.size * sizeof(GLfloat), + // _fovPlane.data() + // ); //} //else { // // new points - memory change // glBindVertexArray(_orthogonalPlane.vao); // glBindBuffer(GL_ARRAY_BUFFER, _orthogonalPlane.vbo); - // glBufferData(GL_ARRAY_BUFFER, _orthogonalPlane.size * sizeof(GLfloat), NULL, GL_STATIC_DRAW); // orphaning the buffer, sending NULL data. - // glBufferSubData(GL_ARRAY_BUFFER, 0, _orthogonalPlane.size * sizeof(GLfloat), _fovPlane.data()); + // glBufferData( + // GL_ARRAY_BUFFER, + // _orthogonalPlane.size * sizeof(GLfloat), + // NULL, + // GL_STATIC_DRAW + // ); // orphaning the buffer, sending NULL data. + // glBufferSubData( + // GL_ARRAY_BUFFER, + // 0, + // _orthogonalPlane.size * sizeof(GLfloat), + // _fovPlane.data() + // ); // GLsizei st = sizeof(GLfloat) * Stride; // glEnableVertexAttribArray(0); // glEnableVertexAttribArray(1); // glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0); - // glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat))); + // glVertexAttribPointer( + // 1, + // 4, + // GL_FLOAT, + // GL_FALSE, + // st, + // (void*)(4 * sizeof(GLfloat)) + // ); //} //glBindVertexArray(0); diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp index 8c00af474e..0f198cfc8e 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp @@ -250,14 +250,21 @@ void RenderableModelProjection::render(const RenderData& data, RendererTasks&) { glm::dmat4(data.modelTransform.rotation) * // Rotation glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); // Scale glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; - glm::vec3 directionToSun = glm::normalize(_sunPosition.vec3() - glm::vec3(bodyPosition)); - glm::vec3 directionToSunViewSpace = glm::mat3(data.camera.combinedViewMatrix()) * directionToSun; + glm::vec3 directionToSun = glm::normalize( + _sunPosition.vec3() - glm::vec3(bodyPosition) + ); + glm::vec3 directionToSunViewSpace = glm::mat3( + data.camera.combinedViewMatrix() + ) * directionToSun; _programObject->setUniform("_performShading", _performShading); _programObject->setUniform("directionToSunViewSpace", directionToSunViewSpace); _programObject->setUniform("modelViewTransform", glm::mat4(modelViewTransform)); _programObject->setUniform("projectionTransform", data.camera.projectionMatrix()); - _programObject->setUniform("_projectionFading", _projectionComponent.projectionFading()); + _programObject->setUniform( + "_projectionFading", + _projectionComponent.projectionFading() + ); _geometry->setUniforms(*_programObject); diff --git a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp index df29049e9e..5f85e63803 100644 --- a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp @@ -155,14 +155,20 @@ void RenderablePlaneProjection::render(const RenderData& data, RendererTasks&) { void RenderablePlaneProjection::update(const UpdateData& data) { double time = data.time.j2000Seconds(); - const Image img = openspace::ImageSequencer::ref().getLatestImageForInstrument(_instrument); + const Image img = openspace::ImageSequencer::ref().getLatestImageForInstrument( + _instrument + ); if (img.path == "") return; else _hasImage = true; - _stateMatrix = SpiceManager::ref().positionTransformMatrix(_target.frame, GalacticFrame, time); + _stateMatrix = SpiceManager::ref().positionTransformMatrix( + _target.frame, + GalacticFrame, + time + ); double timePast = std::abs(img.timeRange.start - _previousTime); @@ -186,7 +192,10 @@ void RenderablePlaneProjection::update(const UpdateData& data) { void RenderablePlaneProjection::loadTexture() { if (_texturePath != "") { - std::unique_ptr texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath)); + using TR = ghoul::io::TextureReader; + std::unique_ptr texture = TR::ref().loadTexture( + absPath(_texturePath) + ); if (texture) { if (texture->format() == ghoul::opengl::Texture::Format::Red) texture->setSwizzleMask({ GL_RED, GL_RED, GL_RED, GL_ONE }); @@ -198,7 +207,9 @@ void RenderablePlaneProjection::loadTexture() { delete _textureFile; _textureFile = new ghoul::filesystem::File(_texturePath); - _textureFile->setCallback([&](const ghoul::filesystem::File&) { _textureIsDirty = true; }); + _textureFile->setCallback( + [&](const ghoul::filesystem::File&) { _textureIsDirty = true; } + ); } } } @@ -221,11 +232,11 @@ void RenderablePlaneProjection::updatePlane(const Image& img, double currentTime setTarget(target); try { - SpiceManager::FieldOfViewResult res = SpiceManager::ref().fieldOfView(_instrument); + SpiceManager::FieldOfViewResult r = SpiceManager::ref().fieldOfView(_instrument); - frame = std::move(res.frameName); - bounds = std::move(res.bounds); - boresight = std::move(res.boresightVector); + frame = std::move(r.frameName); + bounds = std::move(r.bounds); + boresight = std::move(r.boresightVector); } catch (const SpiceManager::SpiceException& e) { LERROR(e.what()); @@ -238,56 +249,66 @@ void RenderablePlaneProjection::updatePlane(const Image& img, double currentTime _target.body, _spacecraft, GalacticFrame, - { SpiceManager::AberrationCorrection::Type::ConvergedNewtonianStellar, SpiceManager::AberrationCorrection::Direction::Reception }, + { + SpiceManager::AberrationCorrection::Type::ConvergedNewtonianStellar, + SpiceManager::AberrationCorrection::Direction::Reception + }, currentTime, lt ); // The apparent position, CN+S, makes image align best with target for (size_t j = 0; j < bounds.size(); ++j) { - bounds[j] = SpiceManager::ref().frameTransformationMatrix(frame, GalacticFrame, currentTime) * bounds[j]; + bounds[j] = SpiceManager::ref().frameTransformationMatrix( + frame, + GalacticFrame, + currentTime + ) * bounds[j]; glm::dvec3 cornerPosition = glm::proj(vecToTarget, bounds[j]); if (!_moving) { cornerPosition -= vecToTarget; } - cornerPosition = SpiceManager::ref().frameTransformationMatrix(GalacticFrame, _target.frame, currentTime) * cornerPosition; + cornerPosition = SpiceManager::ref().frameTransformationMatrix( + GalacticFrame, + _target.frame, + currentTime + ) * cornerPosition; - projection[j] = PowerScaledCoordinate::CreatePowerScaledCoordinate(cornerPosition[0], cornerPosition[1], cornerPosition[2]); + projection[j] = PowerScaledCoordinate::CreatePowerScaledCoordinate( + cornerPosition[0], + cornerPosition[1], + cornerPosition[2] + ); projection[j][3] += 3; } if (!_moving) { SceneGraphNode* thisNode = OsEng.renderEngine().scene()->sceneGraphNode(_name); - SceneGraphNode* newParent = OsEng.renderEngine().scene()->sceneGraphNode(_target.node); + SceneGraphNode* newParent = OsEng.renderEngine().scene()->sceneGraphNode( + _target.node + ); if (thisNode && newParent) { thisNode->setParent(*newParent); } } - const GLfloat vertex_data[] = { // square of two triangles drawn within fov in target coordinates + const GLfloat vertex_data[] = { + // square of two triangles drawn within fov in target coordinates // x y z w s t - projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 0, // Lower left 1 - projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 1, // Upper right 2 - projection[2][0], projection[2][1], projection[2][2], projection[2][3], 0, 1, // Upper left 3 - projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 0, // Lower left 4 = 1 - projection[0][0], projection[0][1], projection[0][2], projection[0][3], 1, 0, // Lower right 5 - projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 1, // Upper left 6 = 2 - //projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 1 - //projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper right 2 - //projection[2][0], projection[2][1], projection[2][2], projection[2][3], 0, 0, // Upper left 3 - //projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 4 = 1 - //projection[0][0], projection[0][1], projection[0][2], projection[0][3], 1, 1, // Lower right 5 - //projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper left 6 = 2 - + // Lower left 1 + projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 0, + // Upper right 2 + projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 1, + // Upper left 3 + projection[2][0], projection[2][1], projection[2][2], projection[2][3], 0, 1, + // Lower left 4 = 1 + projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 0, + // Lower right 5 + projection[0][0], projection[0][1], projection[0][2], projection[0][3], 1, 0, + // Upper left 6 = 2 + projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 1, }; - //projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 1 - // projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper right 2 - // projection[2][0], projection[2][1], projection[2][2], projection[2][3], 0, 0, // Upper left 3 - // projection[1][0], projection[1][1], projection[1][2], projection[1][3], 0, 1, // Lower left 4 = 1 - // projection[0][0], projection[0][1], projection[0][2], projection[0][3], 1, 1, // Lower right 5 - // projection[3][0], projection[3][1], projection[3][2], projection[3][3], 1, 0, // Upper left 6 = 2 - glBindVertexArray(_quad); // bind array glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer @@ -295,7 +316,14 @@ void RenderablePlaneProjection::updatePlane(const Image& img, double currentTime glEnableVertexAttribArray(0); glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, nullptr); glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast(sizeof(GLfloat) * 4)); + glVertexAttribPointer( + 1, + 2, + GL_FLOAT, + GL_FALSE, + sizeof(GLfloat) * 6, + reinterpret_cast(sizeof(GLfloat) * 4) + ); if (!_moving && img.path != "") { _texturePath = img.path; @@ -304,10 +332,9 @@ void RenderablePlaneProjection::updatePlane(const Image& img, double currentTime } void RenderablePlaneProjection::setTarget(std::string body) { - if (body == "") + if (body == "") { return; - - std::vector nodes = OsEng.renderEngine().scene()->allSceneGraphNodes(); + } _target.body = body; _target.frame = openspace::SpiceManager::ref().frameFromBody(body); diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index 1bceb9b0e2..f0b1b6219c 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -147,8 +147,8 @@ documentation::Documentation RenderablePlanetProjection::Documentation() { }; } -RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dictionary) - : Renderable(dictionary) +RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dict) + : Renderable(dict) , _colorTexturePath(ColorTextureInfo) , _heightMapTexturePath(HeightTextureInfo) , _programObject(nullptr) @@ -161,44 +161,44 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& { documentation::testSpecificationAndThrow( Documentation(), - dictionary, + dict, "RenderablePlanetProjection" ); std::string name; - bool success = dictionary.getValue(SceneGraphNode::KeyName, name); + bool success = dict.getValue(SceneGraphNode::KeyName, name); ghoul_assert(success, ""); ghoul::Dictionary geometryDictionary; - success = dictionary.getValue(KeyGeometry, geometryDictionary); + success = dict.getValue(KeyGeometry, geometryDictionary); if (success) { geometryDictionary.setValue(SceneGraphNode::KeyName, name); using planetgeometry::PlanetGeometry; _geometry = PlanetGeometry::createFromDictionary(geometryDictionary); } - _projectionComponent.initialize(dictionary.value(KeyProjection)); + _projectionComponent.initialize(dict.value(KeyProjection)); // TODO: textures need to be replaced by a good system similar to the geometry as soon // as the requirements are fixed (ab) std::string texturePath = ""; - success = dictionary.getValue(ColorTextureInfo.identifier, texturePath); + success = dict.getValue(ColorTextureInfo.identifier, texturePath); if (success) { _colorTexturePath = absPath(texturePath); } std::string heightMapPath = ""; - success = dictionary.getValue(HeightTextureInfo.identifier, heightMapPath); + success = dict.getValue(HeightTextureInfo.identifier, heightMapPath); if (success) { _heightMapTexturePath = absPath(heightMapPath); } - if (dictionary.hasKeyAndValue(MeridianShiftInfo.identifier)) { - _meridianShift = dictionary.value(MeridianShiftInfo.identifier); + if (dict.hasKeyAndValue(MeridianShiftInfo.identifier)) { + _meridianShift = dict.value(MeridianShiftInfo.identifier); } float radius = std::pow(10.f, 9.f); - dictionary.getValue(KeyRadius, radius); + dict.getValue(KeyRadius, radius); setBoundingSphere(radius); addPropertySubOwner(_geometry.get()); @@ -210,9 +210,9 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& addProperty(_heightMapTexturePath); _heightMapTexturePath.onChange([&]() { loadTextures(); }); - if (dictionary.hasKey(HeightExaggerationInfo.identifier)) { + if (dict.hasKey(HeightExaggerationInfo.identifier)) { _heightExaggeration = static_cast( - dictionary.value(HeightExaggerationInfo.identifier) + dict.value(HeightExaggerationInfo.identifier) ); } @@ -355,7 +355,9 @@ void RenderablePlanetProjection::attitudeParameters(double time) { glm::dvec3 bs; try { - SpiceManager::FieldOfViewResult res = SpiceManager::ref().fieldOfView(_projectionComponent.instrumentId()); + SpiceManager::FieldOfViewResult res = SpiceManager::ref().fieldOfView( + _projectionComponent.instrumentId() + ); bs = std::move(res.boresightVector); } catch (const SpiceManager::SpiceException& e) { @@ -417,8 +419,14 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&) _imageTimes.clear(); double lt; - glm::dvec3 p = - SpiceManager::ref().targetPosition("SUN", _projectionComponent.projecteeId(), "GALACTIC", {}, _time, lt); + glm::dvec3 p = SpiceManager::ref().targetPosition( + "SUN", + _projectionComponent.projecteeId(), + "GALACTIC", + {}, + _time, + lt + ); psc sun_pos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z); // Main renderpass @@ -452,11 +460,10 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&) _programObject->setUniform("_hasHeightMap", _heightMapTexture != nullptr); _programObject->setUniform("_heightExaggeration", _heightExaggeration); _programObject->setUniform("_meridianShift", _meridianShift); - _programObject->setUniform("_projectionFading", _projectionComponent.projectionFading()); - - //_programObject->setUniform("debug_projectionTextureRotation", glm::radians(_debugProjectionTextureRotation.value())); - - //setPscUniforms(*_programObject.get(), data.camera, data.position); + _programObject->setUniform( + "_projectionFading", + _projectionComponent.projectionFading() + ); ghoul::opengl::TextureUnit unit[3]; unit[0].activate(); diff --git a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp index 9a45b6665b..85ed4b886c 100644 --- a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp +++ b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp @@ -365,7 +365,8 @@ void RenderableShadowCylinder::createCylinder(double time) { res.terminatorPoints.end(), std::back_inserter(terminatorPoints), [](const glm::dvec3& p) { - PowerScaledCoordinate coord = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z); + PowerScaledCoordinate coord = + PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z); coord[3] += 3; return coord; } @@ -389,7 +390,11 @@ void RenderableShadowCylinder::createCylinder(double time) { vecLightSource *= _shadowLength; _vertices.clear(); - psc endpoint = psc::CreatePowerScaledCoordinate(vecLightSource.x, vecLightSource.y, vecLightSource.z); + psc endpoint = psc::CreatePowerScaledCoordinate( + vecLightSource.x, + vecLightSource.y, + vecLightSource.z + ); for (const auto& v : terminatorPoints) { _vertices.push_back({ v[0], v[1], v[2], v[3] }); glm::vec4 f = psc_addition(v.vec4(), endpoint.vec4()); @@ -400,8 +405,18 @@ void RenderableShadowCylinder::createCylinder(double time) { glBindVertexArray(_vao); glBindBuffer(GL_ARRAY_BUFFER, _vbo); - glBufferData(GL_ARRAY_BUFFER, _vertices.size() * sizeof(CylinderVBOLayout), nullptr, GL_DYNAMIC_DRAW); - glBufferSubData(GL_ARRAY_BUFFER, 0, _vertices.size() * sizeof(CylinderVBOLayout), &_vertices[0]); + glBufferData( + GL_ARRAY_BUFFER, + _vertices.size() * sizeof(CylinderVBOLayout), + nullptr, + GL_DYNAMIC_DRAW + ); + glBufferSubData( + GL_ARRAY_BUFFER, + 0, + _vertices.size() * sizeof(CylinderVBOLayout), + &_vertices[0] + ); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, nullptr); diff --git a/modules/spacecraftinstruments/util/hongkangparser.cpp b/modules/spacecraftinstruments/util/hongkangparser.cpp index a4657eecf3..f2297f734b 100644 --- a/modules/spacecraftinstruments/util/hongkangparser.cpp +++ b/modules/spacecraftinstruments/util/hongkangparser.cpp @@ -45,7 +45,9 @@ HongKangParser::HongKangParser(std::string name, std::string fileName, std::string spacecraft, ghoul::Dictionary translationDictionary, std::vector potentialTargets) - : _defaultCaptureImage(absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder.png")) + : _defaultCaptureImage( + absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder.png") + ) , _name(std::move(name)) , _fileName(std::move(fileName)) , _spacecraft(std::move(spacecraft)) @@ -68,7 +70,10 @@ HongKangParser::HongKangParser(std::string name, std::string fileName, ghoul::Dictionary decoderDictionary; translationDictionary.getValue(currentKey, decoderDictionary); - auto decoder = Decoder::createFromDictionary(decoderDictionary, decoders[i]); + auto decoder = Decoder::createFromDictionary( + decoderDictionary, + decoders[i] + ); //insert decoder to map - this will be used in the parser to determine //behavioral characteristics of each instrument _fileTranslation[keys[j]] = std::move(decoder); @@ -88,7 +93,8 @@ void HongKangParser::findPlaybookSpecifiedTarget(std::string line, std::string& ); std::vector ptarg = _potentialTargets; for (const auto& p : ptarg) { - // loop over all targets and determine from 4th col which target this instrument points to + // loop over all targets and determine from 4th col which target this instrument + // points to if (line.find(p) != std::string::npos) { target = p; break; @@ -186,24 +192,38 @@ bool HongKangParser::create() { image.target = cameraTarget; image.isPlaceholder = true; image.projected = false; - //createImage(image, time, time + shutter, cameraSpiceID, cameraTarget, _defaultCaptureImage); + //createImage( + // image, + // time, + // time + shutter, + // cameraSpiceID, + // cameraTarget, + // _defaultCaptureImage + //); - //IFF spaccraft has decided to switch target, store in target map (used for: 'next observation focus') + //IFF spaccraft has decided to switch target, store in target + //map (used for: 'next observation focus') if (previousTarget != image.target) { previousTarget = image.target; - std::pair v_target = std::make_pair(time, image.target); + std::pair v_target = std::make_pair( + time, + image.target + ); _targetTimes.push_back(v_target); } - //store actual image in map. All targets get _only_ their corresp. subset. + // store actual image in map. All targets get _only_ their + // corresp. subset. _subsetMap[image.target]._subset.push_back(image); - //compute and store the range for each subset + // compute and store the range for each subset _subsetMap[image.target]._range.include(time); } if (it->second->getDecoderType() == "SCANNER") { // SCANNER START scan_start = time; - InstrumentDecoder* scanner = static_cast(it->second.get()); + InstrumentDecoder* scanner = static_cast( + it->second.get() + ); std::string endNominal = scanner->getStopCommand(); // store current position in file @@ -222,8 +242,13 @@ bool HongKangParser::create() { scannerSpiceID = it->second->getTranslation(); scanRange = { scan_start, scan_stop }; - ghoul_assert(scanRange.isDefined(), "Invalid time range!"); - _instrumentTimes.push_back(std::make_pair(it->first, scanRange)); + ghoul_assert( + scanRange.isDefined(), + "Invalid time range!" + ); + _instrumentTimes.push_back( + std::make_pair(it->first, scanRange) + ); //store individual image Image image; @@ -242,13 +267,18 @@ bool HongKangParser::create() { file.seekg(len, std::ios_base::beg); } } - else { // we have reached the end of a scan or consecutive capture sequence! + else { + // we have reached the end of a scan or consecutive capture + // sequence! if (capture_start != -1) { - //end of capture sequence for camera, store end time of this sequence + // end of capture sequence for camera, store end time of this + // sequence capture_stop = time; cameraRange = { capture_start, capture_stop }; ghoul_assert(cameraRange.isDefined(), "Invalid time range!"); - _instrumentTimes.push_back(std::make_pair(previousCamera, cameraRange)); + _instrumentTimes.push_back( + std::make_pair(previousCamera, cameraRange) + ); capture_start = -1; } diff --git a/modules/spacecraftinstruments/util/instrumenttimesparser.cpp b/modules/spacecraftinstruments/util/instrumenttimesparser.cpp index 25a860ced6..703626887f 100644 --- a/modules/spacecraftinstruments/util/instrumenttimesparser.cpp +++ b/modules/spacecraftinstruments/util/instrumenttimesparser.cpp @@ -70,9 +70,16 @@ InstrumentTimesParser::InstrumentTimesParser(const std::string& name, ghoul::Dictionary instruments = inputDict.value(KeyInstruments); for (const auto& instrumentKey : instruments.keys()) { - ghoul::Dictionary instrument = instruments.value(instrumentKey); - ghoul::Dictionary files = instrument.value(KeyInstrumentFiles); - _fileTranslation[instrumentKey] = Decoder::createFromDictionary(instrument, KeyInstrument); + ghoul::Dictionary instrument = instruments.value( + instrumentKey + ); + ghoul::Dictionary files = instrument.value( + KeyInstrumentFiles + ); + _fileTranslation[instrumentKey] = Decoder::createFromDictionary( + instrument, + KeyInstrument + ); for (size_t i = 0; i < files.size(); i++) { std::string filename = files.value(std::to_string(i + 1)); _instrumentFiles[instrumentKey].push_back(filename); @@ -97,7 +104,10 @@ bool InstrumentTimesParser::create() { for (auto it = _instrumentFiles.begin(); it != _instrumentFiles.end(); it++) { std::string instrumentID = it->first; for (std::string filename: it->second) { - std::string filepath = FileSys.pathByAppendingComponent(sequenceDir.path(), filename); + std::string filepath = FileSys.pathByAppendingComponent( + sequenceDir.path(), + filename + ); if (!FileSys.fileExists(filepath)) { LERROR("Unable to read file " << filepath << ". Skipping file."); @@ -113,8 +123,10 @@ bool InstrumentTimesParser::create() { while (std::getline(inFile, line)) { if (std::regex_match(line, matches, _pattern)) { if (matches.size() != 3) { - LERROR("Bad event data formatting. Must \ - have regex 3 matches (source string, start time, stop time)."); + LERROR( + "Bad event data formatting. Must \ + have regex 3 matches (source string, start time, stop time)." + ); successfulRead = false; break; } @@ -123,8 +135,10 @@ bool InstrumentTimesParser::create() { try { // parse date strings std::string start = matches[1].str(); std::string stop = matches[2].str(); - captureTimeRange.start = SpiceManager::ref().ephemerisTimeFromDate(start); - captureTimeRange.end = SpiceManager::ref().ephemerisTimeFromDate(stop); + captureTimeRange.start = + SpiceManager::ref().ephemerisTimeFromDate(start); + captureTimeRange.end = + SpiceManager::ref().ephemerisTimeFromDate(stop); } catch (const SpiceManager::SpiceException& e){ LERROR(e.what()); diff --git a/modules/spacecraftinstruments/util/labelparser.cpp b/modules/spacecraftinstruments/util/labelparser.cpp index a7d860dad0..f5bdcd1446 100644 --- a/modules/spacecraftinstruments/util/labelparser.cpp +++ b/modules/spacecraftinstruments/util/labelparser.cpp @@ -79,7 +79,10 @@ LabelParser::LabelParser(std::string name, std::string fileName, ghoul::Dictionary decoderDictionary = translationDictionary.value(currentKey); - auto decoder = Decoder::createFromDictionary(decoderDictionary, decoders[i]); + auto decoder = Decoder::createFromDictionary( + decoderDictionary, + decoders[i] + ); //insert decoder to map - this will be used in the parser to determine //behavioral characteristics of each instrument _fileTranslation[keys[j]] = std::move(decoder); @@ -124,7 +127,8 @@ std::string LabelParser::decode(std::string line){ // "\nPlease check label files"); // return ""; //} - return _fileTranslation[toTranslate]->getTranslation()[0]; //lbls always 1:1 -> single value return + // //lbls always 1:1 -> single value return + return _fileTranslation[toTranslate]->getTranslation()[0]; } } @@ -170,7 +174,9 @@ bool LabelParser::create() { std::ifstream file(currentFile.path()); if (!file.good()){ - LERROR("Failed to open label file '" << currentFile.path() << "'"); + LERROR( + "Failed to open label file '" << currentFile.path() << "'" + ); return false; } @@ -186,9 +192,17 @@ bool LabelParser::create() { std::getline(file, line); - line.erase(std::remove(line.begin(), line.end(), '"'), line.end()); - line.erase(std::remove(line.begin(), line.end(), ' '), line.end()); - line.erase(std::remove(line.begin(), line.end(), '\r'), line.end()); + line.erase( + std::remove(line.begin(), line.end(), '"'), + line.end() + ); + line.erase( + std::remove(line.begin(), line.end(), ' '), + line.end() + ); + line.erase( + std::remove(line.begin(), line.end(), '\r'), line.end() + ); std::string read = line.substr(0, line.find_first_of("=")); @@ -220,14 +234,26 @@ bool LabelParser::create() { if (read == "START_TIME"){ std::string start = line.substr(line.find("=") + 1); - start.erase(std::remove(start.begin(), start.end(), ' '), start.end()); + start.erase( + std::remove(start.begin(), start.end(), ' '), + start.end() + ); startTime = SpiceManager::ref().ephemerisTimeFromDate(start); count++; getline(file, line); - line.erase(std::remove(line.begin(), line.end(), '"'), line.end()); - line.erase(std::remove(line.begin(), line.end(), ' '), line.end()); - line.erase(std::remove(line.begin(), line.end(), '\r'), line.end()); + line.erase( + std::remove(line.begin(), line.end(), '"'), + line.end() + ); + line.erase( + std::remove(line.begin(), line.end(), ' '), + line.end() + ); + line.erase( + std::remove(line.begin(), line.end(), '\r'), + line.end() + ); read = line.substr(0, line.find_first_of("=")); if (read == "STOP_TIME"){ @@ -244,8 +270,14 @@ bool LabelParser::create() { count++; } else{ - LERROR("Label file " + currentFile.path() + " deviates from generic standard!"); - LINFO("Please make sure input data adheres to format https://pds.jpl.nasa.gov/documents/qs/labels.html"); + LERROR( + "Label file " + currentFile.path() + + " deviates from generic standard!" + ); + LINFO( + "Please make sure input data adheres to format \ + https://pds.jpl.nasa.gov/documents/qs/labels.html" + ); } } if (count == static_cast(_specsOfInterest.size())) { @@ -262,13 +294,23 @@ bool LabelParser::create() { Image image; std::vector spiceInstrument; spiceInstrument.push_back(_instrumentID); - createImage(image, startTime, stopTime, spiceInstrument, _target, path); + createImage( + image, + startTime, + stopTime, + spiceInstrument, + _target, + path + ); _subsetMap[image.target]._subset.push_back(image); _subsetMap[image.target]._range.include(startTime); _captureProgression.push_back(startTime); - std::stable_sort(_captureProgression.begin(), _captureProgression.end()); + std::stable_sort( + _captureProgression.begin(), + _captureProgression.end() + ); break; } @@ -291,14 +333,20 @@ bool LabelParser::create() { for (auto image : tmp){ if (previousTarget != image.target){ previousTarget = image.target; - std::pair v_target = std::make_pair(image.timeRange.start, image.target); + std::pair v_target = std::make_pair( + image.timeRange.start, + image.target + ); _targetTimes.push_back(v_target); std::sort(_targetTimes.begin(), _targetTimes.end(), targetComparer); } } for (auto target : _subsetMap){ - _instrumentTimes.push_back(std::make_pair(lblName, _subsetMap[target.first]._range)); + _instrumentTimes.push_back(std::make_pair( + lblName, + _subsetMap[target.first]._range + )); // std::string min, max; // SpiceManager::ref().getDateFromET(target.second._range._min, min); @@ -326,7 +374,10 @@ bool LabelParser::create() { return true; } -void LabelParser::createImage(Image& image, double startTime, double stopTime, std::vector instr, std::string targ, std::string pot) { +void LabelParser::createImage(Image& image, double startTime, double stopTime, + std::vector instr, std::string targ, + std::string pot) +{ image.timeRange = { startTime , stopTime }; ghoul_assert(image.timeRange.isDefined(), "Invalid time range!"); image.path = pot; diff --git a/modules/spacecraftinstruments/util/projectioncomponent.cpp b/modules/spacecraftinstruments/util/projectioncomponent.cpp index de4cad9853..fbed52475f 100644 --- a/modules/spacecraftinstruments/util/projectioncomponent.cpp +++ b/modules/spacecraftinstruments/util/projectioncomponent.cpp @@ -336,7 +336,10 @@ void ProjectionComponent::initialize(const ghoul::Dictionary& dictionary) { } } else { - LWARNING("No playbook translation provided, please make sure all spice calls match playbook!"); + LWARNING( + "No playbook translation provided, please make sure \ + all spice calls match playbook!" + ); } } } @@ -369,7 +372,9 @@ bool ProjectionComponent::initializeGL() { using ghoul::opengl::Texture; using ghoul::io::TextureReader; - unique_ptr texture = TextureReader::ref().loadTexture(absPath(placeholderFile)); + unique_ptr texture = TextureReader::ref().loadTexture( + absPath(placeholderFile) + ); if (texture) { texture->uploadTexture(); // TODO: AnisotropicMipMap crashes on ATI cards ---abock @@ -814,12 +819,16 @@ glm::mat4 ProjectionComponent::computeProjectorMatrix(const glm::vec3 loc, glm:: glm::vec3 e1 = glm::normalize(glm::cross(uptmp, e3)); glm::vec3 e2 = glm::normalize(glm::cross(e3, e1)); - glm::mat4 projViewMatrix = glm::mat4(e1.x, e2.x, e3.x, 0.f, - e1.y, e2.y, e3.y, 0.f, - e1.z, e2.z, e3.z, 0.f, - glm::dot(e1, -loc), glm::dot(e2, -loc), glm::dot(e3, -loc), 1.f); + glm::mat4 projViewMatrix = glm::mat4( + e1.x, e2.x, e3.x, 0.f, + e1.y, e2.y, e3.y, 0.f, + e1.z, e2.z, e3.z, 0.f, + glm::dot(e1, -loc), glm::dot(e2, -loc), glm::dot(e3, -loc), 1.f + ); // create perspective projection matrix - glm::mat4 projProjectionMatrix = glm::perspective(glm::radians(fieldOfViewY), aspectRatio, nearPlane, farPlane); + glm::mat4 projProjectionMatrix = glm::perspective( + glm::radians(fieldOfViewY), aspectRatio, nearPlane, farPlane + ); return projProjectionMatrix*projViewMatrix; } @@ -877,7 +886,12 @@ void ProjectionComponent::clearAllProjections() { GLint m_viewport[4]; glGetIntegerv(GL_VIEWPORT, m_viewport); //counter = 0; - glViewport(0, 0, static_cast(_projectionTexture->width()), static_cast(_projectionTexture->height())); + glViewport( + 0, + 0, + static_cast(_projectionTexture->width()), + static_cast(_projectionTexture->height()) + ); glBindFramebuffer(GL_FRAMEBUFFER, _fboID); @@ -933,7 +947,9 @@ bool ProjectionComponent::generateProjectionLayerTexture(const ivec2& size) { ); if (_projectionTexture) { _projectionTexture->uploadTexture(); - //_projectionTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + //_projectionTexture->setFilter( + // ghoul::opengl::Texture::FilterMode::AnisotropicMipMap + //); } if (_dilation.isEnabled) { @@ -944,7 +960,9 @@ bool ProjectionComponent::generateProjectionLayerTexture(const ivec2& size) { if (_dilation.texture) { _dilation.texture->uploadTexture(); - //_dilation.texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + //_dilation.texture->setFilter( + // ghoul::opengl::Texture::FilterMode::AnisotropicMipMap + //); } _dilation.stencilTexture = std::make_unique( @@ -956,7 +974,9 @@ bool ProjectionComponent::generateProjectionLayerTexture(const ivec2& size) { if (_dilation.stencilTexture) { _dilation.stencilTexture->uploadTexture(); - //_dilation.texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + //_dilation.texture->setFilter( + // ghoul::opengl::Texture::FilterMode::AnisotropicMipMap + //); } } diff --git a/modules/spacecraftinstruments/util/sequenceparser.cpp b/modules/spacecraftinstruments/util/sequenceparser.cpp index a949906eaf..fce066925b 100644 --- a/modules/spacecraftinstruments/util/sequenceparser.cpp +++ b/modules/spacecraftinstruments/util/sequenceparser.cpp @@ -61,12 +61,18 @@ void writeToBuffer(std::vector& buffer, size_t& currentWriteLocation, T va if ((currentWriteLocation + sizeof(T)) > buffer.size()) buffer.resize(2 * buffer.size()); - std::memmove(buffer.data() + currentWriteLocation, reinterpret_cast(&value), sizeof(T)); + std::memmove( + buffer.data() + currentWriteLocation, + reinterpret_cast(&value), + sizeof(T) + ); currentWriteLocation += sizeof(T); } template <> -void writeToBuffer(std::vector& buffer, size_t& currentWriteLocation, std::string value) { +void writeToBuffer(std::vector& buffer, size_t& currentWriteLocation, + std::string value) +{ if ((currentWriteLocation + sizeof(uint8_t) + value.size()) > buffer.size()) buffer.resize(2 * buffer.size()); @@ -92,7 +98,8 @@ void SequenceParser::sendPlaybookInformation(const std::string& name) { // 1 byte : Number of Instruments (i) // i times: 1 byte (id), 1 byte (length j of name), j bytes (name) // 4 byte: Number (n) of images - // n times: 8 byte (beginning time), 8 byte (ending time), 1 byte (target id), 2 byte (instrument id) + // n times: 8 byte (beginning time), 8 byte (ending time), 1 byte (target id), + // 2 byte (instrument id) std::map targetMap; uint8_t currentTargetId = 0; @@ -136,8 +143,12 @@ void SequenceParser::sendPlaybookInformation(const std::string& name) { writeToBuffer(buffer, currentWriteLocation, image.timeRange.start); writeToBuffer(buffer, currentWriteLocation, image.timeRange.end); - std::string timeBegin = SpiceManager::ref().dateFromEphemerisTime(image.timeRange.start); - std::string timeEnd = SpiceManager::ref().dateFromEphemerisTime(image.timeRange.end); + std::string timeBegin = SpiceManager::ref().dateFromEphemerisTime( + image.timeRange.start + ); + std::string timeEnd = SpiceManager::ref().dateFromEphemerisTime( + image.timeRange.end + ); writeToBuffer(buffer, currentWriteLocation, timeBegin); writeToBuffer(buffer, currentWriteLocation, timeEnd); diff --git a/modules/volume/rendering/volumeclipplanes.cpp b/modules/volume/rendering/volumeclipplanes.cpp index 51042714f6..83219e4e87 100644 --- a/modules/volume/rendering/volumeclipplanes.cpp +++ b/modules/volume/rendering/volumeclipplanes.cpp @@ -32,7 +32,8 @@ namespace volume { VolumeClipPlanes::VolumeClipPlanes(const ghoul::Dictionary& dictionary) : properties::PropertyOwner({ "" }) // @TODO Missing name - , _nClipPlanes({ "nClipPlanes", "Number of clip planes", "" }, 0, 0, 10) // @TODO Missing documentation + // @TODO Missing documentation + , _nClipPlanes({ "nClipPlanes", "Number of clip planes", "" }, 0, 0, 10) { std::vector keys = dictionary.keys(); for (const std::string& key : keys) { diff --git a/modules/volume/volumemodule.cpp b/modules/volume/volumemodule.cpp index 518e2d92b9..ac59aa00dd 100644 --- a/modules/volume/volumemodule.cpp +++ b/modules/volume/volumemodule.cpp @@ -37,9 +37,9 @@ using namespace volume; VolumeModule::VolumeModule() : OpenSpaceModule(Name) {} void VolumeModule::internalInitialize() { - auto fRenderable = FactoryManager::ref().factory(); - ghoul_assert(fRenderable, "No renderable factory existed"); - fRenderable->registerClass("RenderableTimeVaryingVolume"); + auto factory = FactoryManager::ref().factory(); + ghoul_assert(factory, "No renderable factory existed"); + factory->registerClass("RenderableTimeVaryingVolume"); } } // namespace openspace From ca7053d8f2835466ebca13f599680d708c025a90 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 9 Nov 2017 10:20:33 -0500 Subject: [PATCH 3/3] Fix bug with layer support for height maps --- modules/globebrowsing/scripts/layer_support.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/globebrowsing/scripts/layer_support.lua b/modules/globebrowsing/scripts/layer_support.lua index 7bf39408a7..3143d7c980 100644 --- a/modules/globebrowsing/scripts/layer_support.lua +++ b/modules/globebrowsing/scripts/layer_support.lua @@ -174,7 +174,7 @@ openspace.globebrowsing.parseInfoFile = function (file) local height = nil if HeightFile then - local height = { + height = { Name = Name, Description = Description or "", FilePath = dir .. '/' .. HeightFile, @@ -193,9 +193,11 @@ openspace.globebrowsing.addBlendingLayersFromDirectory = function (dir, node_nam c, h = openspace.globebrowsing.parseInfoFile(file) if c then + openspace.printInfo("Adding color layer '" .. c["Name"] .. "'") openspace.globebrowsing.addLayer(node_name, "ColorLayers", c) end if h then + openspace.printInfo("Adding height layer '" .. h["Name"] .. "'") openspace.globebrowsing.addLayer(node_name, "HeightLayers", h) end end