mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-20 19:39:17 -05:00
Merge commit 'f55828198f0ba93da0c1258bb73fcca8adf66e00' into feature/websocketnavigation
* commit 'f55828198f0ba93da0c1258bb73fcca8adf66e00': Adapt to UniformCache changes when updating uniform locations (closes #648) General cleanup Adapt to changes in Ghoul Make use of TextureManager Jenkins compile fix Fix setting of FixedRotation values through assets (closes #647) Enable OrVerifier and AndVerifier to have an arbritrary (>=2) number of verifiers Make specifying the line number in TLETranslation optional Add warning when targets are not registered in the convert-table for image projections
This commit is contained in:
@@ -88,6 +88,9 @@ local Comet67P = {
|
||||
CHURYUMOVGERASIMENKO11969R1 = { "CHURYUMOV-GERASIMENKO" },
|
||||
CHURYUMOVGERASIMENKO = { "CHURYUMOV-GERASIMENKO" },
|
||||
["CHURYUMOV-GERASIMENKO1(1969R1)"] = { "CHURYUMOV-GERASIMENKO" },
|
||||
CALIBRATION = { "CALIBRATION" },
|
||||
ALPHALYR = { "ALPHALYR" },
|
||||
ZETACAS = { "ZETACAS" }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+1
-1
Submodule ext/ghoul updated: a611066775...01b1f2fd8a
@@ -939,27 +939,25 @@ struct ReferencingVerifier : public TableVerifier {
|
||||
*/
|
||||
struct AndVerifier : public Verifier {
|
||||
/**
|
||||
* Constructs an AndVerifier with two Verifiers which must be cleared by incoming
|
||||
* values in order to pass this Verifier.
|
||||
* Constructs an AndVerifier with Verifiers that must be cleared by incoming values in
|
||||
* order to pass this Verifier.
|
||||
*
|
||||
* \param l The first Verifier that is to be tested
|
||||
* \param r The second Verifier that is to be tested
|
||||
* \param values The list of Verifiers that are to be tested
|
||||
*
|
||||
* \pre l must not be nullptr
|
||||
* \pre r must not be nullptr
|
||||
* \pre values must contain at least two values
|
||||
*/
|
||||
AndVerifier(Verifier* l, Verifier* r);
|
||||
AndVerifier(const std::vector<Verifier*> values);
|
||||
|
||||
/**
|
||||
* Checks whether the \p dictionary contains the \p key and whether this key passes
|
||||
* both Verifier%'s that were passed in the constructor. If the value fails either
|
||||
* of the two Verifiers, it is only added once to the TestResult::offenses list with
|
||||
* a reason of TestResult::Offense::Reason::Verification.
|
||||
* all Verifier%s that were passed in the constructor. If the value fails at least
|
||||
* one Verifiers, it is only added once to the TestResult::offenses list with a reason
|
||||
* of TestResult::Offense::Reason::Verification.
|
||||
*
|
||||
* \param dictionary The ghoul::Dictionary that is to be tested
|
||||
* \param key The key contained in \p dictionary that is to be tested
|
||||
* \return A TestResult object that contains the test results. If the value fails
|
||||
* either of the two Verifiers, TestResult::success is \c false and the
|
||||
* any passed Verifiers, TestResult::success is \c false and the
|
||||
* TestResult::offenses list contains \p with a reason of
|
||||
* TestResult::Offense::Reason::Verification. If \p key%'s value passes both
|
||||
* Verifier%s, the result's TestResult::success is \c true and the
|
||||
@@ -971,10 +969,7 @@ struct AndVerifier : public Verifier {
|
||||
std::string type() const override;
|
||||
std::string documentation() const override;
|
||||
|
||||
/// The first Verifier that incoming values are tested against
|
||||
std::shared_ptr<Verifier> lhs;
|
||||
/// The second Verifier that incoming values are tested against
|
||||
std::shared_ptr<Verifier> rhs;
|
||||
std::vector<std::shared_ptr<Verifier>> values;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -985,27 +980,25 @@ struct AndVerifier : public Verifier {
|
||||
*/
|
||||
struct OrVerifier : public Verifier {
|
||||
/**
|
||||
* Constructs an OrVerifier with two Verifiers, either of which must be cleared by
|
||||
* incoming values in order to pass this Verifier.
|
||||
* Constructs an OrVerifier with Verifiers that must be cleared by incoming values in
|
||||
* order to pass this Verifier.
|
||||
*
|
||||
* \param l The first Verifier that is to be tested
|
||||
* \param r The second Verifier that is to be tested
|
||||
* \param values The list of Verifiers that are to be tested
|
||||
*
|
||||
* \pre l must not be nullptr
|
||||
* \pre r must not be nullptr
|
||||
* \pre values must contain at least two values
|
||||
*/
|
||||
OrVerifier(Verifier* l, Verifier* r);
|
||||
OrVerifier(const std::vector<Verifier*> values);
|
||||
|
||||
/**
|
||||
* Checks whether the \p dictionary contains the \p key and whether this key passes
|
||||
* either of the two Verifier%'s that were passed in the constructor. If the value
|
||||
* fails both Verifiers, it is added to the TestResult::offenses list with a reason of
|
||||
* any of the Verifier%s that were passed in the constructor. If the value fails all
|
||||
* Verifiers, it is added to the TestResult::offenses list with a reason of
|
||||
* TestResult::Offense::Reason::Verification.
|
||||
*
|
||||
* \param dictionary The ghoul::Dictionary that is to be tested
|
||||
* \param key The key contained in \p dictionary that is to be tested
|
||||
* \return A TestResult object that contains the test results. If the value fails
|
||||
* both Verifiers, TestResult::success is \c false and the
|
||||
* all Verifiers, TestResult::success is \c false and the
|
||||
* TestResult::offenses list contains \p with a reason of
|
||||
* TestResult::Offense::Reason::Verification. If \p key%'s value passes either
|
||||
* of the two Verifier%s, the result's TestResult::success is \c true and the
|
||||
@@ -1017,10 +1010,7 @@ struct OrVerifier : public Verifier {
|
||||
std::string type() const override;
|
||||
std::string documentation() const override;
|
||||
|
||||
/// The first Verifier that incoming values are tested against
|
||||
std::shared_ptr<Verifier> lhs;
|
||||
/// The second Verifier that incoming values are tested against
|
||||
std::shared_ptr<Verifier> rhs;
|
||||
std::vector<std::shared_ptr<Verifier>> values;
|
||||
};
|
||||
|
||||
/// A short-hand definition for a Verifier checking for <code>glm::bvec2</code>
|
||||
|
||||
@@ -90,6 +90,20 @@
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "AtmosphereDeferredcaster";
|
||||
|
||||
constexpr const std::array<const char*, 17> UniformNames1 = {
|
||||
"cullAtmosphere", "Rg", "Rt", "groundRadianceEmittion", "HR", "betaRayleigh",
|
||||
"HM", "betaMieExtinction", "mieG", "sunRadiance", "ozoneLayerEnabled", "HO",
|
||||
"betaOzoneExtinction", "SAMPLES_R", "SAMPLES_MU", "SAMPLES_MU_S", "SAMPLES_NU"
|
||||
};
|
||||
|
||||
constexpr const std::array<const char*, 10> UniformNames2 = {
|
||||
"dInverseModelTransformMatrix", "dModelTransformMatrix",
|
||||
"dSgctProjectionToModelTransformMatrix", "dSGCTViewToWorldMatrix", "dCamPosObj",
|
||||
"sunDirectionObj", "hardShadows", "transmittanceTexture", "irradianceTexture",
|
||||
"inscatterTexture"
|
||||
};
|
||||
|
||||
constexpr const char* GlslDeferredcastPath =
|
||||
"${MODULES}/atmosphere/shaders/atmosphere_deferred_fs.glsl";
|
||||
constexpr const char* GlslDeferredcastFSPath =
|
||||
@@ -464,48 +478,11 @@ std::string AtmosphereDeferredcaster::helperPath() const {
|
||||
void AtmosphereDeferredcaster::initializeCachedVariables(
|
||||
ghoul::opengl::ProgramObject& program)
|
||||
{
|
||||
_uniformCache.cullAtmosphere = program.uniformLocation("cullAtmosphere");
|
||||
_uniformCache.Rg = program.uniformLocation("Rg");
|
||||
_uniformCache.Rt = program.uniformLocation("Rt");
|
||||
_uniformCache.groundRadianceEmittion = program.uniformLocation(
|
||||
"groundRadianceEmittion"
|
||||
);
|
||||
_uniformCache.HR = program.uniformLocation("HR");
|
||||
_uniformCache.betaRayleigh = program.uniformLocation("betaRayleigh");
|
||||
_uniformCache.HM = program.uniformLocation("HM");
|
||||
_uniformCache.betaMieExtinction = program.uniformLocation("betaMieExtinction");
|
||||
_uniformCache.mieG = program.uniformLocation("mieG");
|
||||
_uniformCache.sunRadiance = program.uniformLocation("sunRadiance");
|
||||
_uniformCache.ozoneLayerEnabled = program.uniformLocation("ozoneLayerEnabled");
|
||||
_uniformCache.HO = program.uniformLocation("HO");
|
||||
_uniformCache.betaOzoneExtinction = program.uniformLocation("betaOzoneExtinction");
|
||||
_uniformCache.SAMPLES_R = program.uniformLocation("SAMPLES_R");
|
||||
_uniformCache.SAMPLES_MU = program.uniformLocation("SAMPLES_MU");
|
||||
_uniformCache.SAMPLES_MU_S = program.uniformLocation("SAMPLES_MU_S");
|
||||
_uniformCache.SAMPLES_NU = program.uniformLocation("SAMPLES_NU");
|
||||
_uniformCache2.dInverseModelTransformMatrix = program.uniformLocation(
|
||||
"dInverseModelTransformMatrix"
|
||||
);
|
||||
_uniformCache2.dModelTransformMatrix = program.uniformLocation(
|
||||
"dModelTransformMatrix"
|
||||
);
|
||||
_uniformCache2.dSgctProjectionToModelTransformMatrix = program.uniformLocation(
|
||||
"dSgctProjectionToModelTransformMatrix"
|
||||
);
|
||||
_uniformCache2.dSGCTViewToWorldMatrix = program.uniformLocation(
|
||||
"dSGCTViewToWorldMatrix"
|
||||
);
|
||||
_uniformCache2.dCamPosObj = program.uniformLocation("dCamPosObj");
|
||||
_uniformCache2.sunDirectionObj = program.uniformLocation("sunDirectionObj");
|
||||
_uniformCache2.hardShadows = program.uniformLocation("hardShadows");
|
||||
_uniformCache2.transmittanceTexture = program.uniformLocation("transmittanceTexture");
|
||||
_uniformCache2.irradianceTexture = program.uniformLocation("irradianceTexture");
|
||||
_uniformCache2.inscatterTexture = program.uniformLocation("inscatterTexture");
|
||||
ghoul::opengl::updateUniformLocations(program, _uniformCache, UniformNames1);
|
||||
ghoul::opengl::updateUniformLocations(program, _uniformCache2, UniformNames2);
|
||||
}
|
||||
|
||||
void AtmosphereDeferredcaster::update(const UpdateData&) {
|
||||
|
||||
}
|
||||
void AtmosphereDeferredcaster::update(const UpdateData&) {}
|
||||
|
||||
void AtmosphereDeferredcaster::setModelTransform(const glm::dmat4& transform) {
|
||||
_modelTransform = transform;
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
namespace openspace {
|
||||
|
||||
ghoul::opengl::ProgramObjectManager BaseModule::ProgramObjectManager;
|
||||
ghoul::opengl::TextureManager BaseModule::TextureManager;
|
||||
|
||||
BaseModule::BaseModule() : OpenSpaceModule(BaseModule::Name) {}
|
||||
|
||||
@@ -159,6 +160,7 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) {
|
||||
|
||||
void BaseModule::internalDeinitializeGL() {
|
||||
ProgramObjectManager.releaseAll(ghoul::opengl::ProgramObjectManager::Warnings::Yes);
|
||||
TextureManager.releaseAll(ghoul::opengl::TextureManager::Warnings::Yes);
|
||||
}
|
||||
|
||||
std::vector<documentation::Documentation> BaseModule::documentations() const {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <openspace/util/openspacemodule.h>
|
||||
|
||||
#include <ghoul/opengl/programobjectmanager.h>
|
||||
#include <ghoul/opengl/texturemanager.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -42,6 +43,7 @@ public:
|
||||
std::vector<scripting::LuaLibrary> luaLibraries() const override;
|
||||
|
||||
static ghoul::opengl::ProgramObjectManager ProgramObjectManager;
|
||||
static ghoul::opengl::TextureManager TextureManager;
|
||||
|
||||
protected:
|
||||
void internalInitialize(const ghoul::Dictionary&) override;
|
||||
|
||||
@@ -47,6 +47,12 @@ namespace {
|
||||
constexpr const char* ProgramName = "ModelProgram";
|
||||
constexpr const char* KeyGeometry = "Geometry";
|
||||
|
||||
constexpr const std::array<const char*, 11> UniformNames = {
|
||||
"opacity", "nLightSources", "lightDirectionsViewSpace", "lightIntensities",
|
||||
"modelViewTransform", "projectionTransform", "performShading", "texture1",
|
||||
"ambientIntensity", "diffuseIntensity", "specularIntensity"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
"ColorTexture",
|
||||
"Color Texture",
|
||||
@@ -237,7 +243,7 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
RenderableModel::~RenderableModel() {}
|
||||
|
||||
bool RenderableModel::isReady() const {
|
||||
return _programObject && _texture;
|
||||
return _program && _texture;
|
||||
}
|
||||
|
||||
void RenderableModel::initialize() {
|
||||
@@ -247,7 +253,7 @@ void RenderableModel::initialize() {
|
||||
}
|
||||
|
||||
void RenderableModel::initializeGL() {
|
||||
_programObject = BaseModule::ProgramObjectManager.requestProgramObject(
|
||||
_program = BaseModule::ProgramObjectManager.request(
|
||||
ProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -257,7 +263,8 @@ void RenderableModel::initializeGL() {
|
||||
);
|
||||
}
|
||||
);
|
||||
updateUniformCache();
|
||||
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
|
||||
loadTexture();
|
||||
|
||||
@@ -271,19 +278,19 @@ void RenderableModel::deinitializeGL() {
|
||||
}
|
||||
_texture = nullptr;
|
||||
|
||||
BaseModule::ProgramObjectManager.releaseProgramObject(
|
||||
BaseModule::ProgramObjectManager.release(
|
||||
ProgramName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
}
|
||||
);
|
||||
_programObject = nullptr;
|
||||
_program = nullptr;
|
||||
}
|
||||
|
||||
void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
_programObject->activate();
|
||||
_program->activate();
|
||||
|
||||
_programObject->setUniform(_uniformCache.opacity, _opacity);
|
||||
_program->setUniform(_uniformCache.opacity, _opacity);
|
||||
|
||||
// Model transform and view transform needs to be in double precision
|
||||
const glm::dmat4 modelTransform =
|
||||
@@ -309,98 +316,65 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
++nLightSources;
|
||||
}
|
||||
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.nLightSources,
|
||||
nLightSources
|
||||
);
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.lightIntensities,
|
||||
_lightIntensitiesBuffer.data(),
|
||||
nLightSources
|
||||
);
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.lightDirectionsViewSpace,
|
||||
_lightDirectionsViewSpaceBuffer.data(),
|
||||
nLightSources
|
||||
);
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.modelViewTransform,
|
||||
glm::mat4(modelViewTransform)
|
||||
);
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.projectionTransform,
|
||||
data.camera.projectionMatrix()
|
||||
);
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.ambientIntensity,
|
||||
_ambientIntensity
|
||||
);
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.diffuseIntensity,
|
||||
_diffuseIntensity
|
||||
);
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.specularIntensity,
|
||||
_specularIntensity
|
||||
);
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.performShading,
|
||||
_performShading
|
||||
);
|
||||
|
||||
_geometry->setUniforms(*_programObject);
|
||||
_geometry->setUniforms(*_program);
|
||||
|
||||
// Bind texture
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
_texture->bind();
|
||||
_programObject->setUniform(_uniformCache.texture, unit);
|
||||
_program->setUniform(_uniformCache.texture, unit);
|
||||
|
||||
_geometry->render();
|
||||
|
||||
_programObject->deactivate();
|
||||
_program->deactivate();
|
||||
}
|
||||
|
||||
void RenderableModel::update(const UpdateData&) {
|
||||
if (_programObject->isDirty()) {
|
||||
_programObject->rebuildFromFile();
|
||||
updateUniformCache();
|
||||
if (_program->isDirty()) {
|
||||
_program->rebuildFromFile();
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RenderableModel::updateUniformCache() {
|
||||
_uniformCache.opacity = _programObject->uniformLocation("opacity");
|
||||
_uniformCache.nLightSources = _programObject->uniformLocation(
|
||||
"nLightSources"
|
||||
);
|
||||
_uniformCache.lightDirectionsViewSpace = _programObject->uniformLocation(
|
||||
"lightDirectionsViewSpace"
|
||||
);
|
||||
_uniformCache.lightIntensities = _programObject->uniformLocation(
|
||||
"lightIntensities"
|
||||
);
|
||||
_uniformCache.modelViewTransform = _programObject->uniformLocation(
|
||||
"modelViewTransform"
|
||||
);
|
||||
_uniformCache.projectionTransform = _programObject->uniformLocation(
|
||||
"projectionTransform"
|
||||
);
|
||||
_uniformCache.performShading = _programObject->uniformLocation(
|
||||
"performShading"
|
||||
);
|
||||
_uniformCache.ambientIntensity = _programObject->uniformLocation(
|
||||
"ambientIntensity"
|
||||
);
|
||||
_uniformCache.diffuseIntensity = _programObject->uniformLocation(
|
||||
"diffuseIntensity"
|
||||
);
|
||||
_uniformCache.specularIntensity = _programObject->uniformLocation(
|
||||
"specularIntensity"
|
||||
);
|
||||
_uniformCache.texture = _programObject->uniformLocation("texture1");
|
||||
}
|
||||
|
||||
void RenderableModel::loadTexture() {
|
||||
_texture = nullptr;
|
||||
if (!_colorTexturePath.value().empty()) {
|
||||
|
||||
@@ -68,8 +68,6 @@ protected:
|
||||
void loadTexture();
|
||||
|
||||
private:
|
||||
void updateUniformCache();
|
||||
|
||||
std::unique_ptr<modelgeometry::ModelGeometry> _geometry;
|
||||
|
||||
properties::StringProperty _colorTexturePath;
|
||||
@@ -81,7 +79,7 @@ private:
|
||||
properties::BoolProperty _performShading;
|
||||
properties::Mat3Property _modelTransform;
|
||||
|
||||
ghoul::opengl::ProgramObject* _programObject = nullptr;
|
||||
ghoul::opengl::ProgramObject* _program = nullptr;
|
||||
UniformCache(opacity, nLightSources, lightDirectionsViewSpace, lightIntensities,
|
||||
modelViewTransform, projectionTransform, performShading, texture,
|
||||
ambientIntensity, diffuseIntensity, specularIntensity) _uniformCache;
|
||||
|
||||
@@ -165,7 +165,7 @@ void RenderablePlane::initializeGL() {
|
||||
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
|
||||
createPlane();
|
||||
|
||||
_shader = BaseModule::ProgramObjectManager.requestProgramObject(
|
||||
_shader = BaseModule::ProgramObjectManager.request(
|
||||
ProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -184,7 +184,7 @@ void RenderablePlane::deinitializeGL() {
|
||||
glDeleteBuffers(1, &_vertexPositionBuffer);
|
||||
_vertexPositionBuffer = 0;
|
||||
|
||||
BaseModule::ProgramObjectManager.releaseProgramObject(
|
||||
BaseModule::ProgramObjectManager.release(
|
||||
ProgramName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
|
||||
@@ -24,13 +24,16 @@
|
||||
|
||||
#include <modules/base/rendering/renderableplaneimagelocal.h>
|
||||
|
||||
#include <modules/base/basemodule.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/crc32.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <fstream>
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
@@ -91,7 +94,8 @@ void RenderablePlaneImageLocal::initializeGL() {
|
||||
|
||||
void RenderablePlaneImageLocal::deinitializeGL() {
|
||||
_textureFile = nullptr;
|
||||
_texture = nullptr;
|
||||
|
||||
BaseModule::TextureManager.release(_texture);
|
||||
RenderablePlane::deinitializeGL();
|
||||
}
|
||||
|
||||
@@ -110,27 +114,36 @@ void RenderablePlaneImageLocal::update(const UpdateData& data) {
|
||||
|
||||
void RenderablePlaneImageLocal::loadTexture() {
|
||||
if (!_texturePath.value().empty()) {
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture =
|
||||
ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath));
|
||||
ghoul::opengl::Texture* t = _texture;
|
||||
|
||||
if (texture) {
|
||||
LDEBUGC(
|
||||
"RenderablePlane",
|
||||
fmt::format("Loaded texture from '{}'", absPath(_texturePath))
|
||||
);
|
||||
texture->uploadTexture();
|
||||
unsigned int hash = ghoul::hashCRC32File(_texturePath);
|
||||
|
||||
_texture = BaseModule::TextureManager.request(
|
||||
std::to_string(hash),
|
||||
[path = _texturePath]() -> std::unique_ptr<ghoul::opengl::Texture> {
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture =
|
||||
ghoul::io::TextureReader::ref().loadTexture(absPath(path));
|
||||
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than
|
||||
// linear
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
|
||||
if (texture) {
|
||||
LDEBUGC(
|
||||
"RenderablePlaneImageLocal",
|
||||
fmt::format("Loaded texture from '{}'", absPath(path))
|
||||
);
|
||||
texture->uploadTexture();
|
||||
|
||||
_texture = std::move(texture);
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
|
||||
|
||||
_textureFile = std::make_unique<ghoul::filesystem::File>(_texturePath);
|
||||
_textureFile->setCallback(
|
||||
[&](const ghoul::filesystem::File&) { _textureIsDirty = true; }
|
||||
);
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
BaseModule::TextureManager.release(t);
|
||||
|
||||
_textureFile = std::make_unique<ghoul::filesystem::File>(_texturePath);
|
||||
_textureFile->setCallback(
|
||||
[&](const ghoul::filesystem::File&) { _textureIsDirty = true; }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
void loadTexture();
|
||||
|
||||
properties::StringProperty _texturePath;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
ghoul::opengl::Texture* _texture;
|
||||
std::unique_ptr<ghoul::filesystem::File> _textureFile;
|
||||
|
||||
bool _textureIsDirty = false;
|
||||
|
||||
@@ -43,6 +43,10 @@
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "Sphere";
|
||||
|
||||
constexpr const std::array<const char*, 4> UniformNames = {
|
||||
"opacity", "ViewProjection", "ModelTransform", "texture1"
|
||||
};
|
||||
|
||||
enum Orientation {
|
||||
Outside = 1,
|
||||
Inside = 2
|
||||
@@ -237,7 +241,7 @@ void RenderableSphere::initializeGL() {
|
||||
);
|
||||
_sphere->initialize();
|
||||
|
||||
_shader = BaseModule::ProgramObjectManager.requestProgramObject(
|
||||
_shader = BaseModule::ProgramObjectManager.request(
|
||||
ProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -248,10 +252,7 @@ void RenderableSphere::initializeGL() {
|
||||
}
|
||||
);
|
||||
|
||||
_uniformCache.opacity = _shader->uniformLocation("opacity");
|
||||
_uniformCache.viewProjection = _shader->uniformLocation("ViewProjection");
|
||||
_uniformCache.modelTransform = _shader->uniformLocation("ModelTransform");
|
||||
_uniformCache.texture = _shader->uniformLocation("texture1");
|
||||
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
|
||||
|
||||
loadTexture();
|
||||
}
|
||||
@@ -259,7 +260,7 @@ void RenderableSphere::initializeGL() {
|
||||
void RenderableSphere::deinitializeGL() {
|
||||
_texture = nullptr;
|
||||
|
||||
BaseModule::ProgramObjectManager.releaseProgramObject(
|
||||
BaseModule::ProgramObjectManager.release(
|
||||
ProgramName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
@@ -348,11 +349,7 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) {
|
||||
void RenderableSphere::update(const UpdateData&) {
|
||||
if (_shader->isDirty()) {
|
||||
_shader->rebuildFromFile();
|
||||
|
||||
_uniformCache.opacity = _shader->uniformLocation("opacity");
|
||||
_uniformCache.viewProjection = _shader->uniformLocation("ViewProjection");
|
||||
_uniformCache.modelTransform = _shader->uniformLocation("ModelTransform");
|
||||
_uniformCache.texture = _shader->uniformLocation("texture1");
|
||||
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
|
||||
}
|
||||
|
||||
if (_sphereIsDirty) {
|
||||
|
||||
@@ -176,7 +176,7 @@ bool RenderableSphericalGrid::isReady() const {
|
||||
}
|
||||
|
||||
void RenderableSphericalGrid::initializeGL() {
|
||||
_gridProgram = BaseModule::ProgramObjectManager.requestProgramObject(
|
||||
_gridProgram = BaseModule::ProgramObjectManager.request(
|
||||
ProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -208,7 +208,7 @@ void RenderableSphericalGrid::deinitializeGL() {
|
||||
glDeleteBuffers(1, &_iBufferID);
|
||||
_iBufferID = 0;
|
||||
|
||||
BaseModule::ProgramObjectManager.releaseProgramObject(
|
||||
BaseModule::ProgramObjectManager.release(
|
||||
ProgramName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
|
||||
@@ -38,6 +38,12 @@ namespace {
|
||||
constexpr const char* ProgramName = "EphemerisProgram";
|
||||
constexpr const char* KeyTranslation = "Translation";
|
||||
|
||||
constexpr const std::array<const char*, 12> UniformNames = {
|
||||
"opacity", "modelViewTransform", "projectionTransform", "color", "useLineFade",
|
||||
"lineFade", "vertexSortingMethod", "idOffset", "nVertices", "stride", "pointSize",
|
||||
"renderPhase"
|
||||
};
|
||||
|
||||
// The possible values for the _renderingModes property
|
||||
enum RenderingMode {
|
||||
RenderingModeLines = 0,
|
||||
@@ -225,7 +231,7 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
|
||||
void RenderableTrail::initializeGL() {
|
||||
_programObject = BaseModule::ProgramObjectManager.requestProgramObject(
|
||||
_programObject = BaseModule::ProgramObjectManager.request(
|
||||
ProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -236,24 +242,13 @@ void RenderableTrail::initializeGL() {
|
||||
}
|
||||
);
|
||||
|
||||
_uniformCache.opacity = _programObject->uniformLocation("opacity");
|
||||
_uniformCache.modelView = _programObject->uniformLocation("modelViewTransform");
|
||||
_uniformCache.projection = _programObject->uniformLocation("projectionTransform");
|
||||
_uniformCache.color = _programObject->uniformLocation("color");
|
||||
_uniformCache.useLineFade = _programObject->uniformLocation("useLineFade");
|
||||
_uniformCache.lineFade = _programObject->uniformLocation("lineFade");
|
||||
_uniformCache.vertexSorting = _programObject->uniformLocation("vertexSortingMethod");
|
||||
_uniformCache.idOffset = _programObject->uniformLocation("idOffset");
|
||||
_uniformCache.nVertices = _programObject->uniformLocation("nVertices");
|
||||
_uniformCache.stride = _programObject->uniformLocation("stride");
|
||||
_uniformCache.pointSize = _programObject->uniformLocation("pointSize");
|
||||
_uniformCache.renderPhase = _programObject->uniformLocation("renderPhase");
|
||||
ghoul::opengl::updateUniformLocations(*_programObject, _uniformCache, UniformNames);
|
||||
|
||||
setRenderBin(Renderable::RenderBin::Overlay);
|
||||
}
|
||||
|
||||
void RenderableTrail::deinitializeGL() {
|
||||
BaseModule::ProgramObjectManager.releaseProgramObject(
|
||||
BaseModule::ProgramObjectManager.release(
|
||||
ProgramName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
|
||||
@@ -202,15 +202,14 @@ documentation::Documentation FixedRotation::Documentation() {
|
||||
},
|
||||
{
|
||||
KeyXAxis,
|
||||
new OrVerifier(
|
||||
new StringVerifier,
|
||||
new DoubleVector3Verifier
|
||||
),
|
||||
new OrVerifier({ new StringVerifier, new DoubleVector3Verifier, }),
|
||||
Optional::Yes,
|
||||
"This value specifies the direction of the new X axis. If this value is "
|
||||
"not specified, it will be computed by completing a right handed "
|
||||
"coordinate system from the Y and Z axis, which must be specified "
|
||||
"instead."
|
||||
"instead. If this value is a string, it is interpreted as the identifier "
|
||||
"of another scenegraph node. If this value is a 3-vector, it is "
|
||||
"interpreted as a direction vector."
|
||||
},
|
||||
{
|
||||
KeyXAxisOrthogonal,
|
||||
@@ -220,15 +219,14 @@ documentation::Documentation FixedRotation::Documentation() {
|
||||
},
|
||||
{
|
||||
KeyYAxis,
|
||||
new OrVerifier(
|
||||
new StringVerifier,
|
||||
new DoubleVector3Verifier
|
||||
),
|
||||
new OrVerifier({ new StringVerifier, new DoubleVector3Verifier, }),
|
||||
Optional::Yes,
|
||||
"This value specifies the direction of the new Y axis. If this value is "
|
||||
"not specified, it will be computed by completing a right handed "
|
||||
"coordinate system from the X and Z axis, which must be specified "
|
||||
"instead."
|
||||
"instead. If this value is a string, it is interpreted as the identifier "
|
||||
"of another scenegraph node. If this value is a 3-vector, it is "
|
||||
"interpreted as a direction vector."
|
||||
},
|
||||
{
|
||||
KeyYAxisOrthogonal,
|
||||
@@ -238,15 +236,14 @@ documentation::Documentation FixedRotation::Documentation() {
|
||||
},
|
||||
{
|
||||
KeyZAxis,
|
||||
new OrVerifier(
|
||||
new StringVerifier,
|
||||
new DoubleVector3Verifier
|
||||
),
|
||||
new OrVerifier({ new StringVerifier, new DoubleVector3Verifier, }),
|
||||
Optional::Yes,
|
||||
"This value specifies the direction of the new Z axis. If this value is "
|
||||
"not specified, it will be computed by completing a right handed "
|
||||
"coordinate system from the X and Y axis, which must be specified "
|
||||
"instead."
|
||||
"instead. If this value is a string, it is interpreted as the identifier "
|
||||
"of another scenegraph node. If this value is a 3-vector, it is "
|
||||
"interpreted as a direction vector."
|
||||
},
|
||||
{
|
||||
KeyZAxisOrthogonal,
|
||||
@@ -276,7 +273,7 @@ FixedRotation::FixedRotation(const ghoul::Dictionary& dictionary)
|
||||
properties::Vec3Property(
|
||||
XAxisVectorInfo,
|
||||
glm::vec3(1.f, 0.f, 0.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(-1.f),
|
||||
glm::vec3(1.f)
|
||||
),
|
||||
properties::BoolProperty(XAxisOrthogonalVectorInfo, false),
|
||||
@@ -292,7 +289,7 @@ FixedRotation::FixedRotation(const ghoul::Dictionary& dictionary)
|
||||
properties::Vec3Property(
|
||||
YAxisVectorInfo,
|
||||
glm::vec3(0.f, 1.f, 0.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(-1.f),
|
||||
glm::vec3(1.f)
|
||||
),
|
||||
properties::BoolProperty(YAxisOrthogonalVectorInfo, false),
|
||||
@@ -308,7 +305,7 @@ FixedRotation::FixedRotation(const ghoul::Dictionary& dictionary)
|
||||
properties::Vec3Property(
|
||||
ZAxisVectorInfo,
|
||||
glm::vec3(0.f, 0.f, 1.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(-1.f),
|
||||
glm::vec3(1.f)
|
||||
),
|
||||
properties::BoolProperty(ZAxisOrthogonalVectorInfo, false),
|
||||
@@ -454,10 +451,8 @@ bool FixedRotation::initialize() {
|
||||
}
|
||||
}
|
||||
|
||||
if (_constructorDictionary.hasKey(XAxisOrthogonalVectorInfo.identifier)) {
|
||||
_xAxis.isOrthogonal = _constructorDictionary.value<bool>(
|
||||
XAxisOrthogonalVectorInfo.identifier
|
||||
);
|
||||
if (_constructorDictionary.hasKey(KeyXAxisOrthogonal)) {
|
||||
_xAxis.isOrthogonal = _constructorDictionary.value<bool>(KeyXAxisOrthogonal);
|
||||
}
|
||||
if (_xAxis.isOrthogonal) {
|
||||
_xAxis.type = Axis::Type::OrthogonalVector;
|
||||
@@ -476,10 +471,8 @@ bool FixedRotation::initialize() {
|
||||
}
|
||||
}
|
||||
|
||||
if (_constructorDictionary.hasKey(YAxisOrthogonalVectorInfo.identifier)) {
|
||||
_yAxis.isOrthogonal = _constructorDictionary.value<bool>(
|
||||
YAxisOrthogonalVectorInfo.identifier
|
||||
);
|
||||
if (_constructorDictionary.hasKey(KeyYAxisOrthogonal)) {
|
||||
_yAxis.isOrthogonal = _constructorDictionary.value<bool>(KeyYAxisOrthogonal);
|
||||
}
|
||||
if (_yAxis.isOrthogonal) {
|
||||
_yAxis.type = Axis::Type::OrthogonalVector;
|
||||
@@ -498,10 +491,8 @@ bool FixedRotation::initialize() {
|
||||
}
|
||||
}
|
||||
|
||||
if (_constructorDictionary.hasKey(ZAxisOrthogonalVectorInfo.identifier)) {
|
||||
_zAxis.isOrthogonal = _constructorDictionary.value<bool>(
|
||||
ZAxisOrthogonalVectorInfo.identifier
|
||||
);
|
||||
if (_constructorDictionary.hasKey(KeyZAxisOrthogonal)) {
|
||||
_zAxis.isOrthogonal = _constructorDictionary.value<bool>(KeyZAxisOrthogonal);
|
||||
}
|
||||
if (_zAxis.isOrthogonal) {
|
||||
_zAxis.type = Axis::Type::OrthogonalVector;
|
||||
@@ -543,7 +534,7 @@ glm::dmat3 FixedRotation::matrix(const UpdateData&) const {
|
||||
{
|
||||
LWARNINGC(
|
||||
"FixedRotation",
|
||||
fmt::format("Near-ollinear vectors detected: x ({}) y ({}) z ({})", x, y, z)
|
||||
fmt::format("Near-collinear vectors detected: x ({}) y ({}) z ({})", x, y, z)
|
||||
);
|
||||
return glm::dmat3();
|
||||
}
|
||||
@@ -619,6 +610,8 @@ glm::vec3 FixedRotation::yAxis() const {
|
||||
case Axis::Type::Object:
|
||||
if (_yAxis.node && _attachedNode) {
|
||||
glm::vec3 dir = glm::vec3(glm::normalize(
|
||||
// @TODO(abock): This should be changed to be in the coordinate system
|
||||
// of the attached node // same with xAxis and zAxis ofc
|
||||
_yAxis.node->worldPosition() - _attachedNode->worldPosition()
|
||||
));
|
||||
return _yAxis.invertObject ? -dir : dir;
|
||||
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
|
||||
struct Axis {
|
||||
enum Type {
|
||||
Unspecified = 0,
|
||||
Unspecified = -1,
|
||||
Object,
|
||||
Vector,
|
||||
OrthogonalVector,
|
||||
|
||||
@@ -51,10 +51,10 @@ documentation::Documentation StaticRotation::Documentation() {
|
||||
},
|
||||
{
|
||||
RotationInfo.identifier,
|
||||
new OrVerifier(
|
||||
new OrVerifier({
|
||||
new DoubleVector3Verifier(),
|
||||
new DoubleMatrix3Verifier()
|
||||
),
|
||||
}),
|
||||
Optional::No,
|
||||
"Stores the static rotation as either a vector containing Euler angles "
|
||||
"or by specifiying the 3x3 rotation matrix directly"
|
||||
|
||||
@@ -71,10 +71,7 @@ documentation::Documentation TimeFrameInterval::Documentation() {
|
||||
},
|
||||
{
|
||||
StartInfo.identifier,
|
||||
new OrVerifier{
|
||||
new DoubleVerifier,
|
||||
new StringVerifier,
|
||||
},
|
||||
new OrVerifier({ new DoubleVerifier, new StringVerifier }),
|
||||
Optional::Yes,
|
||||
StartInfo.description
|
||||
},
|
||||
@@ -86,10 +83,7 @@ documentation::Documentation TimeFrameInterval::Documentation() {
|
||||
},
|
||||
{
|
||||
EndInfo.identifier,
|
||||
new OrVerifier{
|
||||
new DoubleVerifier,
|
||||
new StringVerifier,
|
||||
},
|
||||
new OrVerifier({ new DoubleVerifier, new StringVerifier }),
|
||||
Optional::Yes,
|
||||
EndInfo.description
|
||||
},
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
namespace openspace {
|
||||
|
||||
ghoul::opengl::ProgramObjectManager DigitalUniverseModule::ProgramObjectManager;
|
||||
ghoul::opengl::TextureManager DigitalUniverseModule::TextureManager;
|
||||
|
||||
DigitalUniverseModule::DigitalUniverseModule()
|
||||
: OpenSpaceModule(DigitalUniverseModule::Name)
|
||||
@@ -54,6 +55,7 @@ void DigitalUniverseModule::internalInitialize(const ghoul::Dictionary&) {
|
||||
|
||||
void DigitalUniverseModule::internalDeinitializeGL() {
|
||||
ProgramObjectManager.releaseAll(ghoul::opengl::ProgramObjectManager::Warnings::Yes);
|
||||
TextureManager.releaseAll(ghoul::opengl::TextureManager::Warnings::Yes);
|
||||
}
|
||||
|
||||
std::vector<documentation::Documentation> DigitalUniverseModule::documentations() const {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <openspace/util/openspacemodule.h>
|
||||
|
||||
#include <ghoul/opengl/programobjectmanager.h>
|
||||
#include <ghoul/opengl/texturemanager.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -40,6 +41,7 @@ public:
|
||||
std::vector<documentation::Documentation> documentations() const override;
|
||||
|
||||
static ghoul::opengl::ProgramObjectManager ProgramObjectManager;
|
||||
static ghoul::opengl::TextureManager TextureManager;
|
||||
|
||||
protected:
|
||||
void internalInitialize(const ghoul::Dictionary&) override;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <ghoul/filesystem/cachemanager.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/misc/crc32.h>
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
@@ -51,19 +52,27 @@
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "RenderableBillboardsCloud";
|
||||
constexpr const char* ProgramObjectName = "RenderableBillboardsCloud";
|
||||
constexpr const char* _loggerCat = "RenderableBillboardsCloud";
|
||||
constexpr const char* ProgramObjectName = "RenderableBillboardsCloud";
|
||||
constexpr const char* RenderToPolygonProgram = "RenderableBillboardsCloud_Polygon";
|
||||
|
||||
constexpr const char* KeyFile = "File";
|
||||
constexpr const char* keyColor = "Color";
|
||||
constexpr const char* keyUnit = "Unit";
|
||||
constexpr const char* MeterUnit = "m";
|
||||
constexpr const char* KilometerUnit = "Km";
|
||||
constexpr const char* ParsecUnit = "pc";
|
||||
constexpr const char* KiloparsecUnit = "Kpc";
|
||||
constexpr const char* MegaparsecUnit = "Mpc";
|
||||
constexpr const char* GigaparsecUnit = "Gpc";
|
||||
constexpr const std::array<const char*, 19> UniformNames = {
|
||||
"cameraViewProjectionMatrix", "modelMatrix", "cameraPosition", "cameraLookUp",
|
||||
"renderOption", "minBillboardSize", "maxBillboardSize",
|
||||
"correctionSizeEndDistance", "correctionSizeFactor", "color", "alphaValue",
|
||||
"scaleFactor", "up", "right", "fadeInValue", "screenSize", "spriteTexture",
|
||||
"hasColorMap", "enabledRectSizeControl"
|
||||
};
|
||||
|
||||
constexpr const char* KeyFile = "File";
|
||||
constexpr const char* keyColor = "Color";
|
||||
constexpr const char* keyUnit = "Unit";
|
||||
constexpr const char* MeterUnit = "m";
|
||||
constexpr const char* KilometerUnit = "Km";
|
||||
constexpr const char* ParsecUnit = "pc";
|
||||
constexpr const char* KiloparsecUnit = "Kpc";
|
||||
constexpr const char* MegaparsecUnit = "Mpc";
|
||||
constexpr const char* GigaparsecUnit = "Gpc";
|
||||
constexpr const char* GigalightyearUnit = "Gly";
|
||||
|
||||
constexpr int8_t CurrentCacheVersion = 1;
|
||||
@@ -480,14 +489,8 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
|
||||
_spriteTexturePath = absPath(dictionary.value<std::string>(
|
||||
SpriteTextureInfo.identifier
|
||||
));
|
||||
_spriteTextureFile = std::make_unique<ghoul::filesystem::File>(
|
||||
_spriteTexturePath
|
||||
);
|
||||
|
||||
_spriteTexturePath.onChange([&] { _spriteTextureIsDirty = true; });
|
||||
_spriteTextureFile->setCallback(
|
||||
[&](const ghoul::filesystem::File&) { _spriteTextureIsDirty = true; }
|
||||
);
|
||||
_spriteTexturePath.onChange([&]() { _spriteTextureIsDirty = true; });
|
||||
addProperty(_spriteTexturePath);
|
||||
|
||||
_hasSpriteTexture = true;
|
||||
@@ -658,62 +661,31 @@ void RenderableBillboardsCloud::initialize() {
|
||||
}
|
||||
|
||||
void RenderableBillboardsCloud::initializeGL() {
|
||||
_program = DigitalUniverseModule::ProgramObjectManager.requestProgramObject(
|
||||
_program = DigitalUniverseModule::ProgramObjectManager.request(
|
||||
ProgramObjectName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
ProgramObjectName,
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_vs.glsl"),
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_fs.glsl"),
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_gs.glsl")
|
||||
);
|
||||
}
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
ProgramObjectName,
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_vs.glsl"),
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_fs.glsl"),
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_gs.glsl")
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
_renderToPolygonProgram =
|
||||
DigitalUniverseModule::ProgramObjectManager.requestProgramObject(
|
||||
RenderToPolygonProgram,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return ghoul::opengl::ProgramObject::Build(
|
||||
RenderToPolygonProgram,
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_vs.glsl"),
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_fs.glsl"),
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_gs.glsl")
|
||||
);
|
||||
}
|
||||
_renderToPolygonProgram = DigitalUniverseModule::ProgramObjectManager.request(
|
||||
RenderToPolygonProgram,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return ghoul::opengl::ProgramObject::Build(
|
||||
RenderToPolygonProgram,
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_vs.glsl"),
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_fs.glsl"),
|
||||
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_gs.glsl")
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
_uniformCache.cameraViewProjectionMatrix = _program->uniformLocation(
|
||||
"cameraViewProjectionMatrix"
|
||||
);
|
||||
|
||||
_uniformCache.modelMatrix = _program->uniformLocation(
|
||||
"modelMatrix"
|
||||
);
|
||||
|
||||
_uniformCache.cameraPos = _program->uniformLocation("cameraPosition");
|
||||
_uniformCache.cameraLookup = _program->uniformLocation("cameraLookUp");
|
||||
_uniformCache.renderOption = _program->uniformLocation("renderOption");
|
||||
_uniformCache.minBillboardSize = _program->uniformLocation("minBillboardSize");
|
||||
_uniformCache.maxBillboardSize = _program->uniformLocation("maxBillboardSize");
|
||||
_uniformCache.correctionSizeEndDistance = _program->uniformLocation(
|
||||
"correctionSizeEndDistance"
|
||||
);
|
||||
_uniformCache.correctionSizeFactor = _program->uniformLocation(
|
||||
"correctionSizeFactor"
|
||||
);
|
||||
_uniformCache.color = _program->uniformLocation("color");
|
||||
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
|
||||
_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
|
||||
_uniformCache.up = _program->uniformLocation("up");
|
||||
_uniformCache.right = _program->uniformLocation("right");
|
||||
_uniformCache.fadeInValue = _program->uniformLocation("fadeInValue");
|
||||
_uniformCache.screenSize = _program->uniformLocation("screenSize");
|
||||
_uniformCache.spriteTexture = _program->uniformLocation("spriteTexture");
|
||||
_uniformCache.hasColormap = _program->uniformLocation("hasColorMap");
|
||||
_uniformCache.enabledRectSizeControl = _program->uniformLocation(
|
||||
"enabledRectSizeControl"
|
||||
);
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
|
||||
if (_hasPolygon) {
|
||||
createPolygonTexture();
|
||||
@@ -738,22 +710,19 @@ void RenderableBillboardsCloud::deinitializeGL() {
|
||||
glDeleteVertexArrays(1, &_vao);
|
||||
_vao = 0;
|
||||
|
||||
DigitalUniverseModule::ProgramObjectManager.releaseProgramObject(
|
||||
DigitalUniverseModule::ProgramObjectManager.release(
|
||||
ProgramObjectName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
}
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
}
|
||||
);
|
||||
_program = nullptr;
|
||||
|
||||
DigitalUniverseModule::ProgramObjectManager.releaseProgramObject(
|
||||
RenderToPolygonProgram
|
||||
);
|
||||
DigitalUniverseModule::ProgramObjectManager.release(RenderToPolygonProgram);
|
||||
_renderToPolygonProgram = nullptr;
|
||||
|
||||
if (_hasSpriteTexture) {
|
||||
_spriteTexture = nullptr;
|
||||
}
|
||||
DigitalUniverseModule::TextureManager.release(_spriteTexture);
|
||||
_spriteTexture = nullptr;
|
||||
|
||||
if (_hasPolygon) {
|
||||
_polygonTexture = nullptr;
|
||||
@@ -1077,37 +1046,30 @@ void RenderableBillboardsCloud::update(const UpdateData&) {
|
||||
_dataIsDirty = false;
|
||||
}
|
||||
|
||||
if (_hasSpriteTexture && _spriteTextureIsDirty) {
|
||||
LDEBUG("Reloading Sprite Texture");
|
||||
_spriteTexture = nullptr;
|
||||
if (_spriteTexturePath.value() != "") {
|
||||
_spriteTexture = ghoul::io::TextureReader::ref().loadTexture(
|
||||
absPath(_spriteTexturePath)
|
||||
);
|
||||
if (_spriteTexture) {
|
||||
LINFO(fmt::format(
|
||||
"Loaded texture from '{}'",
|
||||
absPath(_spriteTexturePath)
|
||||
));
|
||||
_spriteTexture->uploadTexture();
|
||||
if (_hasSpriteTexture && _spriteTextureIsDirty && !_spriteTexturePath.value().empty())
|
||||
{
|
||||
ghoul::opengl::Texture* t = _spriteTexture;
|
||||
|
||||
unsigned int hash = ghoul::hashCRC32File(_spriteTexturePath);
|
||||
|
||||
_spriteTexture = DigitalUniverseModule::TextureManager.request(
|
||||
std::to_string(hash),
|
||||
[path = _spriteTexturePath]() -> std::unique_ptr<ghoul::opengl::Texture> {
|
||||
LINFO(fmt::format("Loaded texture from '{}'", absPath(path)));
|
||||
std::unique_ptr<ghoul::opengl::Texture> t =
|
||||
ghoul::io::TextureReader::ref().loadTexture(
|
||||
absPath(path)
|
||||
);
|
||||
|
||||
t->uploadTexture();
|
||||
t->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
|
||||
return t;
|
||||
}
|
||||
_spriteTexture->setFilter(
|
||||
ghoul::opengl::Texture::FilterMode::AnisotropicMipMap
|
||||
);
|
||||
);
|
||||
|
||||
_spriteTextureFile = std::make_unique<ghoul::filesystem::File>(
|
||||
_spriteTexturePath);
|
||||
_spriteTextureFile->setCallback(
|
||||
[&](const ghoul::filesystem::File&) { _spriteTextureIsDirty = true; }
|
||||
);
|
||||
}
|
||||
DigitalUniverseModule::TextureManager.release(t);
|
||||
_spriteTextureIsDirty = false;
|
||||
}
|
||||
|
||||
if (_hasLabel && _labelDataIsDirty) {
|
||||
|
||||
_labelDataIsDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderableBillboardsCloud::loadData() {
|
||||
|
||||
@@ -105,7 +105,6 @@ private:
|
||||
bool _hasColorMapFile = false;
|
||||
bool _hasPolygon = false;
|
||||
bool _hasLabel = false;
|
||||
bool _labelDataIsDirty = true;
|
||||
|
||||
int _polygonSides = 0;
|
||||
|
||||
@@ -133,17 +132,15 @@ private:
|
||||
// DEBUG:
|
||||
properties::OptionProperty _renderOption;
|
||||
|
||||
|
||||
std::unique_ptr<ghoul::opengl::Texture> _polygonTexture;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _spriteTexture;
|
||||
std::unique_ptr<ghoul::filesystem::File> _spriteTextureFile;
|
||||
ghoul::opengl::Texture* _polygonTexture;
|
||||
ghoul::opengl::Texture* _spriteTexture;
|
||||
ghoul::opengl::ProgramObject* _program = nullptr;
|
||||
ghoul::opengl::ProgramObject* _renderToPolygonProgram = nullptr;
|
||||
|
||||
UniformCache(cameraViewProjectionMatrix, modelMatrix, cameraPos, cameraLookup,
|
||||
renderOption, minBillboardSize, maxBillboardSize, correctionSizeEndDistance,
|
||||
correctionSizeFactor, color, sides, alphaValue, scaleFactor, up, right,
|
||||
fadeInValue, screenSize, spriteTexture, hasColormap, enabledRectSizeControl
|
||||
correctionSizeFactor, color, alphaValue, scaleFactor, up, right, fadeInValue,
|
||||
screenSize, spriteTexture, hasColormap, enabledRectSizeControl
|
||||
) _uniformCache;
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
|
||||
|
||||
@@ -46,18 +46,22 @@
|
||||
#include <stdint.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "RenderableDUMeshes";
|
||||
constexpr const char* _loggerCat = "RenderableDUMeshes";
|
||||
constexpr const char* ProgramObjectName = "RenderableDUMeshes";
|
||||
|
||||
constexpr const char* KeyFile = "File";
|
||||
constexpr const char* keyColor = "Color";
|
||||
constexpr const char* keyUnit = "Unit";
|
||||
constexpr const char* MeterUnit = "m";
|
||||
constexpr const char* KilometerUnit = "Km";
|
||||
constexpr const char* ParsecUnit = "pc";
|
||||
constexpr const char* KiloparsecUnit = "Kpc";
|
||||
constexpr const char* MegaparsecUnit = "Mpc";
|
||||
constexpr const char* GigaparsecUnit = "Gpc";
|
||||
constexpr const std::array<const char*, 4> UniformNames = {
|
||||
"modelViewTransform", "projectionTransform", "alphaValue", "color"
|
||||
};
|
||||
|
||||
constexpr const char* KeyFile = "File";
|
||||
constexpr const char* keyColor = "Color";
|
||||
constexpr const char* keyUnit = "Unit";
|
||||
constexpr const char* MeterUnit = "m";
|
||||
constexpr const char* KilometerUnit = "Km";
|
||||
constexpr const char* ParsecUnit = "pc";
|
||||
constexpr const char* KiloparsecUnit = "Kpc";
|
||||
constexpr const char* MegaparsecUnit = "Mpc";
|
||||
constexpr const char* GigaparsecUnit = "Gpc";
|
||||
constexpr const char* GigalightyearUnit = "Gly";
|
||||
|
||||
constexpr const int8_t CurrentCacheVersion = 1;
|
||||
@@ -392,7 +396,7 @@ bool RenderableDUMeshes::isReady() const {
|
||||
}
|
||||
|
||||
void RenderableDUMeshes::initializeGL() {
|
||||
_program = DigitalUniverseModule::ProgramObjectManager.requestProgramObject(
|
||||
_program = DigitalUniverseModule::ProgramObjectManager.request(
|
||||
ProgramObjectName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -403,11 +407,7 @@ void RenderableDUMeshes::initializeGL() {
|
||||
}
|
||||
);
|
||||
|
||||
_uniformCache.modelViewTransform = _program->uniformLocation("modelViewTransform");
|
||||
_uniformCache.projectionTransform = _program->uniformLocation("projectionTransform");
|
||||
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
|
||||
//_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
|
||||
_uniformCache.color = _program->uniformLocation("color");
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
|
||||
bool success = loadData();
|
||||
if (!success) {
|
||||
@@ -437,7 +437,7 @@ void RenderableDUMeshes::deinitializeGL() {
|
||||
}
|
||||
}
|
||||
|
||||
DigitalUniverseModule::ProgramObjectManager.releaseProgramObject(
|
||||
DigitalUniverseModule::ProgramObjectManager.release(
|
||||
ProgramObjectName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
@@ -616,16 +616,7 @@ void RenderableDUMeshes::render(const RenderData& data, RendererTasks&) {
|
||||
void RenderableDUMeshes::update(const UpdateData&) {
|
||||
if (_program->isDirty()) {
|
||||
_program->rebuildFromFile();
|
||||
|
||||
_uniformCache.modelViewTransform = _program->uniformLocation(
|
||||
"modelViewTransform"
|
||||
);
|
||||
_uniformCache.projectionTransform = _program->uniformLocation(
|
||||
"projectionTransform"
|
||||
);
|
||||
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
|
||||
//_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
|
||||
_uniformCache.color = _program->uniformLocation("color");
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ private:
|
||||
|
||||
ghoul::opengl::ProgramObject* _program = nullptr;
|
||||
UniformCache(modelViewTransform, projectionTransform, alphaValue,
|
||||
/*scaleFactor,*/ color) _uniformCache;
|
||||
color) _uniformCache;
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font = nullptr;
|
||||
|
||||
std::string _speckFile;
|
||||
|
||||
@@ -43,18 +43,21 @@
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "RenderablePlanesCloud";
|
||||
constexpr const char* _loggerCat = "RenderablePlanesCloud";
|
||||
constexpr const char* ProgramObjectName = "RenderablePlanesCloud";
|
||||
|
||||
constexpr std::array<const char*, 4> UniformNames = {
|
||||
"modelViewProjectionTransform", "alphaValue", "fadeInValue", "galaxyTexture"
|
||||
};
|
||||
|
||||
constexpr const char* KeyFile = "File";
|
||||
constexpr const char* keyUnit = "Unit";
|
||||
constexpr const char* MeterUnit = "m";
|
||||
constexpr const char* KilometerUnit = "Km";
|
||||
constexpr const char* ParsecUnit = "pc";
|
||||
constexpr const char* KiloparsecUnit = "Kpc";
|
||||
constexpr const char* MegaparsecUnit = "Mpc";
|
||||
constexpr const char* GigaparsecUnit = "Gpc";
|
||||
constexpr const char* KeyFile = "File";
|
||||
constexpr const char* keyUnit = "Unit";
|
||||
constexpr const char* MeterUnit = "m";
|
||||
constexpr const char* KilometerUnit = "Km";
|
||||
constexpr const char* ParsecUnit = "pc";
|
||||
constexpr const char* KiloparsecUnit = "Kpc";
|
||||
constexpr const char* MegaparsecUnit = "Mpc";
|
||||
constexpr const char* GigaparsecUnit = "Gpc";
|
||||
constexpr const char* GigalightyearUnit = "Gly";
|
||||
|
||||
constexpr int8_t CurrentCacheVersion = 2;
|
||||
@@ -488,7 +491,7 @@ void RenderablePlanesCloud::initialize() {
|
||||
}
|
||||
|
||||
void RenderablePlanesCloud::initializeGL() {
|
||||
_program = DigitalUniverseModule::ProgramObjectManager.requestProgramObject(
|
||||
_program = DigitalUniverseModule::ProgramObjectManager.request(
|
||||
ProgramObjectName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -499,12 +502,7 @@ void RenderablePlanesCloud::initializeGL() {
|
||||
}
|
||||
);
|
||||
|
||||
_uniformCache.modelViewProjectionTransform = _program->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
);
|
||||
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
|
||||
_uniformCache.fadeInValue = _program->uniformLocation("fadeInValue");
|
||||
_uniformCache.galaxyTexture = _program->uniformLocation("galaxyTexture");
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
|
||||
createPlanes();
|
||||
|
||||
@@ -534,7 +532,7 @@ void RenderablePlanesCloud::deleteDataGPU() {
|
||||
void RenderablePlanesCloud::deinitializeGL() {
|
||||
deleteDataGPU();
|
||||
|
||||
DigitalUniverseModule::ProgramObjectManager.releaseProgramObject(
|
||||
DigitalUniverseModule::ProgramObjectManager.release(
|
||||
ProgramObjectName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
@@ -817,13 +815,7 @@ void RenderablePlanesCloud::update(const UpdateData&) {
|
||||
|
||||
if (_program->isDirty()) {
|
||||
_program->rebuildFromFile();
|
||||
|
||||
_uniformCache.modelViewProjectionTransform = _program->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
);
|
||||
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
|
||||
_uniformCache.fadeInValue = _program->uniformLocation("fadeInValue");
|
||||
_uniformCache.galaxyTexture = _program->uniformLocation("galaxyTexture");
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ private:
|
||||
properties::OptionProperty _renderOption;
|
||||
|
||||
ghoul::opengl::ProgramObject* _program = nullptr;
|
||||
UniformCache(modelViewProjectionTransform, alphaValue, scaleFactor, fadeInValue,
|
||||
UniformCache(modelViewProjectionTransform, alphaValue, fadeInValue,
|
||||
galaxyTexture) _uniformCache;
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font = nullptr;
|
||||
std::unordered_map<int, std::unique_ptr<ghoul::opengl::Texture>> _textureMap;
|
||||
|
||||
@@ -45,17 +45,22 @@
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "RenderablePoints";
|
||||
constexpr const char* _loggerCat = "RenderablePoints";
|
||||
|
||||
constexpr const char* KeyFile = "File";
|
||||
constexpr const char* keyColor = "Color";
|
||||
constexpr const char* keyUnit = "Unit";
|
||||
constexpr const char* MeterUnit = "m";
|
||||
constexpr const char* KilometerUnit = "Km";
|
||||
constexpr const char* ParsecUnit = "pc";
|
||||
constexpr const char* KiloparsecUnit = "Kpc";
|
||||
constexpr const char* MegaparsecUnit = "Mpc";
|
||||
constexpr const char* GigaparsecUnit = "Gpc";
|
||||
constexpr const std::array<const char*, 7> UniformNames = {
|
||||
"modelViewProjectionTransform", "color", "sides", "alphaValue", "scaleFactor",
|
||||
"spriteTexture", "hasColorMap"
|
||||
};
|
||||
|
||||
constexpr const char* KeyFile = "File";
|
||||
constexpr const char* keyColor = "Color";
|
||||
constexpr const char* keyUnit = "Unit";
|
||||
constexpr const char* MeterUnit = "m";
|
||||
constexpr const char* KilometerUnit = "Km";
|
||||
constexpr const char* ParsecUnit = "pc";
|
||||
constexpr const char* KiloparsecUnit = "Kpc";
|
||||
constexpr const char* MegaparsecUnit = "Mpc";
|
||||
constexpr const char* GigaparsecUnit = "Gpc";
|
||||
constexpr const char* GigalightyearUnit = "Gly";
|
||||
|
||||
constexpr int8_t CurrentCacheVersion = 1;
|
||||
@@ -261,7 +266,7 @@ void RenderablePoints::initializeGL() {
|
||||
// end of the program.
|
||||
|
||||
if (_hasSpriteTexture) {
|
||||
_program = DigitalUniverseModule::ProgramObjectManager.requestProgramObject(
|
||||
_program = DigitalUniverseModule::ProgramObjectManager.request(
|
||||
"RenderablePoints Sprite",
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -271,19 +276,9 @@ void RenderablePoints::initializeGL() {
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
_uniformCache.modelViewProjectionTransform = _program->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
);
|
||||
_uniformCache.color = _program->uniformLocation("color");
|
||||
_uniformCache.sides = _program->uniformLocation("sides");
|
||||
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
|
||||
_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
|
||||
_uniformCache.spriteTexture = _program->uniformLocation("spriteTexture");
|
||||
_uniformCache.hasColorMap = _program->uniformLocation("hasColorMap");
|
||||
}
|
||||
else {
|
||||
_program = DigitalUniverseModule::ProgramObjectManager.requestProgramObject(
|
||||
_program = DigitalUniverseModule::ProgramObjectManager.request(
|
||||
"RenderablePoints",
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -293,16 +288,8 @@ void RenderablePoints::initializeGL() {
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
_uniformCache.modelViewProjectionTransform = _program->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
);
|
||||
_uniformCache.color = _program->uniformLocation("color");
|
||||
_uniformCache.sides = _program->uniformLocation("sides");
|
||||
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
|
||||
_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
|
||||
_uniformCache.hasColorMap = _program->uniformLocation("hasColorMap");
|
||||
}
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
}
|
||||
|
||||
void RenderablePoints::deinitializeGL() {
|
||||
@@ -311,7 +298,7 @@ void RenderablePoints::deinitializeGL() {
|
||||
glDeleteVertexArrays(1, &_vao);
|
||||
_vao = 0;
|
||||
|
||||
DigitalUniverseModule::ProgramObjectManager.releaseProgramObject(
|
||||
DigitalUniverseModule::ProgramObjectManager.release(
|
||||
_program->name(),
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
namespace {
|
||||
constexpr const std::array<const char*, 3> UniformNames = {
|
||||
"lightIntensityClamped", "modelViewTransform", "projectionTransform"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo IntensityClampInfo = {
|
||||
"IntensityClamp",
|
||||
"Intensity clamp",
|
||||
@@ -69,15 +73,7 @@ void PointGlobe::initialize() {
|
||||
absPath("${MODULE_GLOBEBROWSING}/shaders/pointglobe_fs.glsl")
|
||||
);
|
||||
|
||||
_uniformCache.lightIntensityClamped = _programObject->uniformLocation(
|
||||
"lightIntensityClamped"
|
||||
);
|
||||
_uniformCache.modelView = _programObject->uniformLocation(
|
||||
"modelViewTransform"
|
||||
);
|
||||
_uniformCache.projection = _programObject->uniformLocation(
|
||||
"projectionTransform"
|
||||
);
|
||||
ghoul::opengl::updateUniformLocations(*_programObject, _uniformCache, UniformNames);
|
||||
|
||||
glGenVertexArrays(1, &_vaoID);
|
||||
glGenBuffers(1, &_vertexBufferID);
|
||||
@@ -159,8 +155,8 @@ void PointGlobe::render(const RenderData& data, RendererTasks&) {
|
||||
_uniformCache.lightIntensityClamped,
|
||||
lightIntensityClamped
|
||||
);
|
||||
//_programObject->setUniform("lightOverflow", lightOverflow);
|
||||
//_programObject->setUniform("directionToSunViewSpace", directionToSunViewSpace);
|
||||
//_program->setUniform("lightOverflow", lightOverflow);
|
||||
//_program->setUniform("directionToSunViewSpace", directionToSunViewSpace);
|
||||
_programObject->setUniform(
|
||||
_uniformCache.modelView,
|
||||
glm::mat4(modelViewTransform)
|
||||
|
||||
@@ -53,6 +53,8 @@ namespace {
|
||||
|
||||
ImFont* captionFont = nullptr;
|
||||
|
||||
constexpr const std::array<const char*, 2> UniformNames = { "tex", "ortho" };
|
||||
|
||||
void addScreenSpaceRenderableLocal(std::string texturePath) {
|
||||
if (!FileSys.fileExists(absPath(texturePath))) {
|
||||
LWARNING(fmt::format("Could not find image '{}'", texturePath));
|
||||
@@ -172,6 +174,8 @@ void GUI::initialize() {
|
||||
ghoul::filesystem::CacheManager::Persistent::Yes
|
||||
);
|
||||
|
||||
LDEBUG(fmt::format("Using {} as ImGUI cache location", cachedFile));
|
||||
|
||||
iniFileBuffer = new char[cachedFile.size() + 1];
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -304,9 +308,8 @@ void GUI::initializeGL() {
|
||||
absPath("${MODULE_IMGUI}/shaders/gui_vs.glsl"),
|
||||
absPath("${MODULE_IMGUI}/shaders/gui_fs.glsl")
|
||||
);
|
||||
|
||||
_uniformCache.tex = _program->uniformLocation("tex");
|
||||
_uniformCache.ortho = _program->uniformLocation("ortho");
|
||||
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
|
||||
int nWindows = OsEng.windowWrapper().nWindows();
|
||||
{
|
||||
@@ -416,9 +419,7 @@ void GUI::startFrame(float deltaTime, const glm::vec2& windowSize,
|
||||
void GUI::endFrame() {
|
||||
if (_program->isDirty()) {
|
||||
_program->rebuildFromFile();
|
||||
|
||||
_uniformCache.tex = _program->uniformLocation("tex");
|
||||
_uniformCache.ortho = _program->uniformLocation("ortho");
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
}
|
||||
|
||||
_performance.setEnabled(OsEng.renderEngine().doesPerformanceMeasurements());
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <modules/multiresvolume/rendering/tsp.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <cstring>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ void RenderablePlanet::initializeGL() {
|
||||
// correct one.
|
||||
|
||||
if (!_programObject && _shadowEnabled && _hasNightTexture) {
|
||||
_programObject = SpaceModule::ProgramObjectManager.requestProgramObject(
|
||||
_programObject = SpaceModule::ProgramObjectManager.request(
|
||||
ShadowNightProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -361,7 +361,7 @@ void RenderablePlanet::initializeGL() {
|
||||
);
|
||||
}
|
||||
else if (!_programObject && _shadowEnabled) {
|
||||
_programObject = SpaceModule::ProgramObjectManager.requestProgramObject(
|
||||
_programObject = SpaceModule::ProgramObjectManager.request(
|
||||
ShadowProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -373,7 +373,7 @@ void RenderablePlanet::initializeGL() {
|
||||
);
|
||||
}
|
||||
else if (!_programObject && _hasNightTexture) {
|
||||
_programObject = SpaceModule::ProgramObjectManager.requestProgramObject(
|
||||
_programObject = SpaceModule::ProgramObjectManager.request(
|
||||
NightProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -385,7 +385,7 @@ void RenderablePlanet::initializeGL() {
|
||||
);
|
||||
}
|
||||
else if (!_programObject) {
|
||||
_programObject = SpaceModule::ProgramObjectManager.requestProgramObject(
|
||||
_programObject = SpaceModule::ProgramObjectManager.request(
|
||||
PlainProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -416,7 +416,7 @@ void RenderablePlanet::deinitializeGL() {
|
||||
_geometry = nullptr;
|
||||
}
|
||||
|
||||
SpaceModule::ProgramObjectManager.releaseProgramObject(
|
||||
SpaceModule::ProgramObjectManager.release(
|
||||
_programObject->name(),
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
|
||||
@@ -38,6 +38,11 @@
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
|
||||
namespace {
|
||||
constexpr const std::array<const char*, 6> UniformNames = {
|
||||
"modelViewProjectionTransform", "textureOffset", "transparency", "_nightFactor",
|
||||
"sunPosition", "texture1"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
"Texture",
|
||||
"Texture",
|
||||
@@ -183,14 +188,7 @@ void RenderableRings::initializeGL() {
|
||||
absPath("${MODULE_SPACE}/shaders/rings_fs.glsl")
|
||||
);
|
||||
|
||||
_uniformCache.modelViewProjection = _shader->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
);
|
||||
_uniformCache.textureOffset = _shader->uniformLocation("textureOffset");
|
||||
_uniformCache.transparency = _shader->uniformLocation("transparency");
|
||||
_uniformCache.nightFactor = _shader->uniformLocation("_nightFactor");
|
||||
_uniformCache.sunPosition = _shader->uniformLocation("sunPosition");
|
||||
_uniformCache.texture = _shader->uniformLocation("texture1");
|
||||
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
|
||||
|
||||
glGenVertexArrays(1, &_quad);
|
||||
glGenBuffers(1, &_vertexPositionBuffer);
|
||||
@@ -250,15 +248,7 @@ void RenderableRings::render(const RenderData& data, RendererTasks&) {
|
||||
void RenderableRings::update(const UpdateData& data) {
|
||||
if (_shader->isDirty()) {
|
||||
_shader->rebuildFromFile();
|
||||
|
||||
_uniformCache.modelViewProjection = _shader->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
);
|
||||
_uniformCache.textureOffset = _shader->uniformLocation("textureOffset");
|
||||
_uniformCache.transparency = _shader->uniformLocation("transparency");
|
||||
_uniformCache.nightFactor = _shader->uniformLocation("_nightFactor");
|
||||
_uniformCache.sunPosition = _shader->uniformLocation("sunPosition");
|
||||
_uniformCache.texture = _shader->uniformLocation("texture1");
|
||||
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
|
||||
}
|
||||
|
||||
if (_planeIsDirty) {
|
||||
|
||||
@@ -48,6 +48,11 @@ namespace {
|
||||
|
||||
constexpr const char* KeyFile = "File";
|
||||
|
||||
constexpr const std::array<const char*, 10> UniformNames = {
|
||||
"view", "projection", "colorOption", "alphaValue", "scaleFactor",
|
||||
"minBillboardSize", "screenSize", "scaling", "psfTexture", "colorTexture"
|
||||
};
|
||||
|
||||
constexpr int8_t CurrentCacheVersion = 1;
|
||||
|
||||
struct ColorVBOLayout {
|
||||
@@ -296,16 +301,7 @@ void RenderableStars::initializeGL() {
|
||||
absPath("${MODULE_SPACE}/shaders/star_ge.glsl")
|
||||
);
|
||||
|
||||
_uniformCache.view = _program->uniformLocation("view");
|
||||
_uniformCache.projection = _program->uniformLocation("projection");
|
||||
_uniformCache.colorOption = _program->uniformLocation("colorOption");
|
||||
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
|
||||
_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
|
||||
_uniformCache.minBillboardSize = _program->uniformLocation("minBillboardSize");
|
||||
_uniformCache.screenSize = _program->uniformLocation("screenSize");
|
||||
_uniformCache.scaling = _program->uniformLocation("scaling");
|
||||
_uniformCache.psfTexture = _program->uniformLocation("psfTexture");
|
||||
_uniformCache.colorTexture = _program->uniformLocation("colorTexture");
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
|
||||
bool success = loadData();
|
||||
if (!success) {
|
||||
@@ -555,17 +551,7 @@ void RenderableStars::update(const UpdateData&) {
|
||||
|
||||
if (_program->isDirty()) {
|
||||
_program->rebuildFromFile();
|
||||
|
||||
_uniformCache.view = _program->uniformLocation("view");
|
||||
_uniformCache.projection = _program->uniformLocation("projection");
|
||||
_uniformCache.colorOption = _program->uniformLocation("colorOption");
|
||||
_uniformCache.alphaValue = _program->uniformLocation("alphaValue");
|
||||
_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor");
|
||||
_uniformCache.minBillboardSize = _program->uniformLocation("minBillboardSize");
|
||||
_uniformCache.screenSize = _program->uniformLocation("screenSize");
|
||||
_uniformCache.scaling = _program->uniformLocation("scaling");
|
||||
_uniformCache.psfTexture = _program->uniformLocation("psfTexture");
|
||||
_uniformCache.colorTexture = _program->uniformLocation("colorTexture");
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,7 @@ documentation::Documentation SimpleSphereGeometry::Documentation() {
|
||||
{
|
||||
{
|
||||
RadiusInfo.identifier,
|
||||
new OrVerifier(
|
||||
new DoubleVerifier,
|
||||
new DoubleVector3Verifier
|
||||
),
|
||||
new OrVerifier({ new DoubleVerifier, new DoubleVector3Verifier }),
|
||||
Optional::No,
|
||||
RadiusInfo.description
|
||||
},
|
||||
|
||||
@@ -75,10 +75,7 @@ documentation::Documentation SpiceRotation::Documentation() {
|
||||
},
|
||||
{
|
||||
KeyKernels,
|
||||
new OrVerifier(
|
||||
new StringListVerifier,
|
||||
new StringVerifier
|
||||
),
|
||||
new OrVerifier({ new StringListVerifier, new StringVerifier }),
|
||||
Optional::Yes,
|
||||
"A single kernel or list of kernels that this SpiceTranslation depends "
|
||||
"on. All provided kernels will be loaded before any other operation is "
|
||||
|
||||
@@ -100,10 +100,7 @@ documentation::Documentation SpiceTranslation::Documentation() {
|
||||
},
|
||||
{
|
||||
KeyKernels,
|
||||
new OrVerifier(
|
||||
new StringListVerifier,
|
||||
new StringVerifier
|
||||
),
|
||||
new OrVerifier({ new StringListVerifier, new StringVerifier }),
|
||||
Optional::Yes,
|
||||
"A single kernel or list of kernels that this SpiceTranslation depends "
|
||||
"on. All provided kernels will be loaded before any other operation is "
|
||||
|
||||
@@ -251,9 +251,9 @@ documentation::Documentation TLETranslation::Documentation() {
|
||||
{
|
||||
KeyLineNumber,
|
||||
new DoubleGreaterVerifier(0),
|
||||
Optional::No,
|
||||
Optional::Yes,
|
||||
"Specifies the line number within the file where the group of 3 TLE "
|
||||
"lines begins (1-based)."
|
||||
"lines begins (1-based). Defaults to 1."
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -267,7 +267,10 @@ TLETranslation::TLETranslation(const ghoul::Dictionary& dictionary) {
|
||||
);
|
||||
|
||||
const std::string& file = dictionary.value<std::string>(KeyFile);
|
||||
int lineNum = static_cast<int>(dictionary.value<double>(KeyLineNumber));
|
||||
int lineNum = 1;
|
||||
if (dictionary.hasKeyAndValue<double>(KeyLineNumber)) {
|
||||
lineNum = static_cast<int>(dictionary.value<double>(KeyLineNumber));
|
||||
}
|
||||
readTLEFile(file, lineNum);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,20 +36,22 @@
|
||||
#include <glm/gtx/projection.hpp>
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "FovProgram";
|
||||
constexpr const char* KeyBody = "Body";
|
||||
constexpr const char* KeyFrame = "Frame";
|
||||
// const char* KeyColor = "RGB";
|
||||
|
||||
constexpr const char* KeyInstrument = "Instrument";
|
||||
constexpr const char* KeyInstrumentName = "Name";
|
||||
constexpr const char* ProgramName = "FovProgram";
|
||||
constexpr const char* KeyBody = "Body";
|
||||
constexpr const char* KeyFrame = "Frame";
|
||||
constexpr const char* KeyInstrument = "Instrument";
|
||||
constexpr const char* KeyInstrumentName = "Name";
|
||||
constexpr const char* KeyInstrumentAberration = "Aberration";
|
||||
|
||||
constexpr const char* KeyPotentialTargets = "PotentialTargets";
|
||||
constexpr const char* KeyFrameConversions = "FrameConversions";
|
||||
|
||||
constexpr const char* KeyPotentialTargets = "PotentialTargets";
|
||||
constexpr const char* KeyFrameConversions = "FrameConversions";
|
||||
constexpr const char* KeyBoundsSimplification = "SimplifyBounds";
|
||||
|
||||
constexpr const std::array<const char*, 9> UniformNames = {
|
||||
"modelViewProjectionTransform", "defaultColorStart", "defaultColorEnd",
|
||||
"activeColor", "targetInFieldOfViewColor", "intersectionStartColor",
|
||||
"intersectionEndColor", "squareColor", "interpolation"
|
||||
};
|
||||
|
||||
constexpr const int InterpolationSteps = 5;
|
||||
|
||||
constexpr const double Epsilon = 1e-4;
|
||||
@@ -326,8 +328,8 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
|
||||
void RenderableFov::initializeGL() {
|
||||
_programObject =
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.requestProgramObject(
|
||||
_program =
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.request(
|
||||
ProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -338,25 +340,7 @@ void RenderableFov::initializeGL() {
|
||||
}
|
||||
);
|
||||
|
||||
_uniformCache.modelViewProjection = _programObject->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
);
|
||||
_uniformCache.defaultColorStart = _programObject->uniformLocation(
|
||||
"defaultColorStart"
|
||||
);
|
||||
_uniformCache.defaultColorEnd = _programObject->uniformLocation("defaultColorEnd");
|
||||
_uniformCache.activeColor = _programObject->uniformLocation("activeColor");
|
||||
_uniformCache.targetInFieldOfViewColor = _programObject->uniformLocation(
|
||||
"targetInFieldOfViewColor"
|
||||
);
|
||||
_uniformCache.intersectionStartColor = _programObject->uniformLocation(
|
||||
"intersectionStartColor"
|
||||
);
|
||||
_uniformCache.intersectionEndColor = _programObject->uniformLocation(
|
||||
"intersectionEndColor"
|
||||
);
|
||||
_uniformCache.squareColor = _programObject->uniformLocation("squareColor");
|
||||
_uniformCache.interpolation = _programObject->uniformLocation("interpolation");
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
|
||||
// Fetch information about the specific instrument
|
||||
SpiceManager::FieldOfViewResult res = SpiceManager::ref().fieldOfView(
|
||||
@@ -493,13 +477,13 @@ void RenderableFov::initializeGL() {
|
||||
}
|
||||
|
||||
void RenderableFov::deinitializeGL() {
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.releaseProgramObject(
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.release(
|
||||
ProgramName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
}
|
||||
);
|
||||
_programObject = nullptr;
|
||||
_program = nullptr;
|
||||
|
||||
glDeleteBuffers(1, &_orthogonalPlane.vbo);
|
||||
glDeleteVertexArrays(1, &_orthogonalPlane.vao);
|
||||
@@ -509,7 +493,7 @@ void RenderableFov::deinitializeGL() {
|
||||
}
|
||||
|
||||
bool RenderableFov::isReady() const {
|
||||
return _programObject != nullptr && !_instrument.bounds.empty();
|
||||
return _program != nullptr && !_instrument.bounds.empty();
|
||||
}
|
||||
|
||||
// Orthogonal projection next to planets surface
|
||||
@@ -838,7 +822,7 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string&
|
||||
|
||||
void RenderableFov::render(const RenderData& data, RendererTasks&) {
|
||||
if (_drawFOV) {
|
||||
_programObject->activate();
|
||||
_program->activate();
|
||||
|
||||
// Model transform and view transform needs to be in double precision
|
||||
glm::dmat4 modelTransform =
|
||||
@@ -850,28 +834,28 @@ void RenderableFov::render(const RenderData& data, RendererTasks&) {
|
||||
data.camera.projectionMatrix() *
|
||||
glm::mat4(data.camera.combinedViewMatrix() * modelTransform);
|
||||
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.modelViewProjection,
|
||||
modelViewProjectionTransform
|
||||
);
|
||||
|
||||
_programObject->setUniform(_uniformCache.defaultColorStart, _colors.defaultStart);
|
||||
_programObject->setUniform(_uniformCache.defaultColorEnd, _colors.defaultEnd);
|
||||
_programObject->setUniform(_uniformCache.activeColor, _colors.active);
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(_uniformCache.defaultColorStart, _colors.defaultStart);
|
||||
_program->setUniform(_uniformCache.defaultColorEnd, _colors.defaultEnd);
|
||||
_program->setUniform(_uniformCache.activeColor, _colors.active);
|
||||
_program->setUniform(
|
||||
_uniformCache.targetInFieldOfViewColor,
|
||||
_colors.targetInFieldOfView
|
||||
);
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.intersectionStartColor,
|
||||
_colors.intersectionStart
|
||||
);
|
||||
_programObject->setUniform(
|
||||
_program->setUniform(
|
||||
_uniformCache.intersectionEndColor,
|
||||
_colors.intersectionEnd
|
||||
);
|
||||
_programObject->setUniform(_uniformCache.squareColor, _colors.square);
|
||||
_programObject->setUniform(_uniformCache.interpolation, _interpolationTime);
|
||||
_program->setUniform(_uniformCache.squareColor, _colors.square);
|
||||
_program->setUniform(_uniformCache.interpolation, _interpolationTime);
|
||||
|
||||
GLenum mode = _drawSolid ? GL_TRIANGLE_STRIP : GL_LINES;
|
||||
|
||||
@@ -885,7 +869,7 @@ void RenderableFov::render(const RenderData& data, RendererTasks&) {
|
||||
glBindVertexArray(0);
|
||||
glLineWidth(1.f);
|
||||
|
||||
_programObject->deactivate();
|
||||
_program->deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -918,30 +902,9 @@ void RenderableFov::update(const UpdateData& data) {
|
||||
}
|
||||
}
|
||||
|
||||
if (_programObject->isDirty()) {
|
||||
_programObject->rebuildFromFile();
|
||||
|
||||
_uniformCache.modelViewProjection = _programObject->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
);
|
||||
_uniformCache.defaultColorStart = _programObject->uniformLocation(
|
||||
"defaultColorStart"
|
||||
);
|
||||
_uniformCache.defaultColorEnd = _programObject->uniformLocation(
|
||||
"defaultColorEnd"
|
||||
);
|
||||
_uniformCache.activeColor = _programObject->uniformLocation("activeColor");
|
||||
_uniformCache.targetInFieldOfViewColor = _programObject->uniformLocation(
|
||||
"targetInFieldOfViewColor"
|
||||
);
|
||||
_uniformCache.intersectionStartColor = _programObject->uniformLocation(
|
||||
"intersectionStartColor"
|
||||
);
|
||||
_uniformCache.intersectionEndColor = _programObject->uniformLocation(
|
||||
"intersectionEndColor"
|
||||
);
|
||||
_uniformCache.squareColor = _programObject->uniformLocation("squareColor");
|
||||
_uniformCache.interpolation = _programObject->uniformLocation("interpolation");
|
||||
if (_program->isDirty()) {
|
||||
_program->rebuildFromFile();
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ private:
|
||||
properties::FloatProperty _lineWidth;
|
||||
properties::BoolProperty _drawSolid;
|
||||
properties::DoubleProperty _standOffDistance;
|
||||
ghoul::opengl::ProgramObject* _programObject = nullptr;
|
||||
ghoul::opengl::ProgramObject* _program = nullptr;
|
||||
UniformCache(modelViewProjection, defaultColorStart, defaultColorEnd, activeColor,
|
||||
targetInFieldOfViewColor, intersectionStartColor, intersectionEndColor,
|
||||
squareColor, interpolation) _uniformCache;
|
||||
|
||||
@@ -53,6 +53,20 @@ namespace {
|
||||
|
||||
constexpr const char* DestinationFrame = "GALACTIC";
|
||||
|
||||
constexpr const std::array<const char*, 7> MainUniformNames = {
|
||||
"_performShading", "directionToSunViewSpace", "modelViewTransform",
|
||||
"projectionTransform", "_projectionFading", "baseTexture", "projectionTexture"
|
||||
};
|
||||
|
||||
constexpr const std::array<const char*, 5> FboUniformNames = {
|
||||
"projectionTexture", "needShadowMap", "ProjectorMatrix", "ModelTransform",
|
||||
"boresight"
|
||||
};
|
||||
|
||||
constexpr const std::array<const char*, 2> DepthFboUniformNames = {
|
||||
"ProjectorMatrix", "ModelTransform"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo ColorTextureInfo = {
|
||||
"ColorTexture",
|
||||
"Color Base Texture",
|
||||
@@ -175,24 +189,10 @@ void RenderableModelProjection::initializeGL() {
|
||||
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_fs.glsl")
|
||||
);
|
||||
|
||||
_mainUniformCache.performShading = _programObject->uniformLocation("_performShading");
|
||||
_mainUniformCache.directionToSunViewSpace = _programObject->uniformLocation(
|
||||
"directionToSunViewSpace"
|
||||
);
|
||||
_mainUniformCache.modelViewTransform = _programObject->uniformLocation(
|
||||
"modelViewTransform"
|
||||
);
|
||||
_mainUniformCache.projectionTransform = _programObject->uniformLocation(
|
||||
"projectionTransform"
|
||||
);
|
||||
_mainUniformCache.projectionFading = _programObject->uniformLocation(
|
||||
"_projectionFading"
|
||||
);
|
||||
_mainUniformCache.baseTexture = _programObject->uniformLocation(
|
||||
"baseTexture"
|
||||
);
|
||||
_mainUniformCache.projectionTexture = _programObject->uniformLocation(
|
||||
"projectionTexture"
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_programObject,
|
||||
_mainUniformCache,
|
||||
MainUniformNames
|
||||
);
|
||||
|
||||
_fboProgramObject = ghoul::opengl::ProgramObject::Build(
|
||||
@@ -205,18 +205,11 @@ void RenderableModelProjection::initializeGL() {
|
||||
)
|
||||
);
|
||||
|
||||
_fboUniformCache.projectionTexture = _fboProgramObject->uniformLocation(
|
||||
"projectionTexture"
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_fboProgramObject,
|
||||
_fboUniformCache,
|
||||
FboUniformNames
|
||||
);
|
||||
_fboUniformCache.needShadowMap = _fboProgramObject->uniformLocation("needShadowMap");
|
||||
_fboUniformCache.ProjectorMatrix = _fboProgramObject->uniformLocation(
|
||||
"ProjectorMatrix"
|
||||
);
|
||||
_fboUniformCache.ModelTransform = _fboProgramObject->uniformLocation(
|
||||
"ModelTransform"
|
||||
);
|
||||
_fboUniformCache.boresight = _fboProgramObject->uniformLocation("boresight");
|
||||
|
||||
|
||||
_depthFboProgramObject = ghoul::opengl::ProgramObject::Build(
|
||||
"DepthPass",
|
||||
@@ -224,13 +217,11 @@ void RenderableModelProjection::initializeGL() {
|
||||
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelDepth_fs.glsl")
|
||||
);
|
||||
|
||||
_depthFboUniformCache.ProjectorMatrix = _depthFboProgramObject->uniformLocation(
|
||||
"ProjectorMatrix"
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_depthFboProgramObject,
|
||||
_depthFboUniformCache,
|
||||
DepthFboUniformNames
|
||||
);
|
||||
_depthFboUniformCache.ModelTransform = _depthFboProgramObject->uniformLocation(
|
||||
"ModelTransform"
|
||||
);
|
||||
|
||||
|
||||
loadTextures();
|
||||
_projectionComponent.initializeGL();
|
||||
@@ -330,45 +321,21 @@ void RenderableModelProjection::update(const UpdateData& data) {
|
||||
if (_programObject->isDirty()) {
|
||||
_programObject->rebuildFromFile();
|
||||
|
||||
_mainUniformCache.performShading = _programObject->uniformLocation(
|
||||
"_performShading"
|
||||
);
|
||||
_mainUniformCache.directionToSunViewSpace = _programObject->uniformLocation(
|
||||
"directionToSunViewSpace"
|
||||
);
|
||||
_mainUniformCache.modelViewTransform = _programObject->uniformLocation(
|
||||
"modelViewTransform"
|
||||
);
|
||||
_mainUniformCache.projectionTransform = _programObject->uniformLocation(
|
||||
"projectionTransform"
|
||||
);
|
||||
_mainUniformCache.projectionFading = _programObject->uniformLocation(
|
||||
"_projectionFading"
|
||||
);
|
||||
_mainUniformCache.baseTexture = _programObject->uniformLocation(
|
||||
"baseTexture"
|
||||
);
|
||||
_mainUniformCache.projectionTexture = _programObject->uniformLocation(
|
||||
"projectionTexture"
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_programObject,
|
||||
_mainUniformCache,
|
||||
MainUniformNames
|
||||
);
|
||||
}
|
||||
|
||||
if (_fboProgramObject->isDirty()) {
|
||||
_fboProgramObject->rebuildFromFile();
|
||||
|
||||
_fboUniformCache.projectionTexture = _fboProgramObject->uniformLocation(
|
||||
"projectionTexture"
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_fboProgramObject,
|
||||
_fboUniformCache,
|
||||
FboUniformNames
|
||||
);
|
||||
_fboUniformCache.needShadowMap = _fboProgramObject->uniformLocation(
|
||||
"needShadowMap"
|
||||
);
|
||||
_fboUniformCache.ProjectorMatrix = _fboProgramObject->uniformLocation(
|
||||
"ProjectorMatrix"
|
||||
);
|
||||
_fboUniformCache.ModelTransform = _fboProgramObject->uniformLocation(
|
||||
"ModelTransform"
|
||||
);
|
||||
_fboUniformCache.boresight = _fboProgramObject->uniformLocation("boresight");
|
||||
}
|
||||
|
||||
_projectionComponent.update();
|
||||
@@ -376,11 +343,10 @@ void RenderableModelProjection::update(const UpdateData& data) {
|
||||
if (_depthFboProgramObject->isDirty()) {
|
||||
_depthFboProgramObject->rebuildFromFile();
|
||||
|
||||
_depthFboUniformCache.ProjectorMatrix = _depthFboProgramObject->uniformLocation(
|
||||
"ProjectorMatrix"
|
||||
);
|
||||
_depthFboUniformCache.ModelTransform = _depthFboProgramObject->uniformLocation(
|
||||
"ModelTransform"
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_depthFboProgramObject,
|
||||
_depthFboUniformCache,
|
||||
DepthFboUniformNames
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,12 +45,20 @@ namespace {
|
||||
constexpr const char* ProjectiveProgramName = "ProjectiveProgram";
|
||||
constexpr const char* FBOPassProgramName = "FBOPassProgram";
|
||||
|
||||
constexpr const std::array<const char*, 12> MainUniformNames = {
|
||||
"sun_pos", "modelTransform", "modelViewProjectionTransform", "_hasBaseMap",
|
||||
"_hasHeightMap", "_heightExaggeration", "_meridianShift", "_ambientBrightness",
|
||||
"_projectionFading", "baseTexture", "projectionTexture", "heightTexture"
|
||||
};
|
||||
|
||||
constexpr const std::array<const char*, 7> FboUniformNames = {
|
||||
"projectionTexture", "ProjectorMatrix", "ModelTransform", "_scaling",
|
||||
"boresight", "_radius", "_segments"
|
||||
};
|
||||
|
||||
constexpr const char* KeyGeometry = "Geometry";
|
||||
constexpr const char* KeyProjection = "Projection";
|
||||
|
||||
constexpr const char* KeyRadius = "Geometry.Radius";
|
||||
// const char* keyShading = "PerformShading";
|
||||
constexpr const char* _mainFrame = "GALACTIC";
|
||||
|
||||
constexpr const char* NoImageText = "No Image";
|
||||
@@ -349,7 +357,7 @@ RenderablePlanetProjection::~RenderablePlanetProjection() {} // NOLINT
|
||||
|
||||
void RenderablePlanetProjection::initializeGL() {
|
||||
_programObject =
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.requestProgramObject(
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.request(
|
||||
ProjectiveProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -364,31 +372,14 @@ void RenderablePlanetProjection::initializeGL() {
|
||||
}
|
||||
);
|
||||
|
||||
_mainUniformCache.sunPos = _programObject->uniformLocation("sun_pos");
|
||||
_mainUniformCache.modelTransform = _programObject->uniformLocation("modelTransform");
|
||||
_mainUniformCache.modelViewProjectionTransform = _programObject->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_programObject,
|
||||
_mainUniformCache,
|
||||
MainUniformNames
|
||||
);
|
||||
_mainUniformCache.hasBaseMap = _programObject->uniformLocation("_hasBaseMap");
|
||||
_mainUniformCache.hasHeightMap = _programObject->uniformLocation("_hasHeightMap");
|
||||
_mainUniformCache.heightExaggeration = _programObject->uniformLocation(
|
||||
"_heightExaggeration"
|
||||
);
|
||||
_mainUniformCache.meridianShift = _programObject->uniformLocation("_meridianShift");
|
||||
_mainUniformCache.ambientBrightness = _programObject->uniformLocation(
|
||||
"_ambientBrightness"
|
||||
);
|
||||
_mainUniformCache.projectionFading = _programObject->uniformLocation(
|
||||
"_projectionFading"
|
||||
);
|
||||
_mainUniformCache.baseTexture = _programObject->uniformLocation("baseTexture");
|
||||
_mainUniformCache.projectionTexture = _programObject->uniformLocation(
|
||||
"projectionTexture"
|
||||
);
|
||||
_mainUniformCache.heightTexture = _programObject->uniformLocation("heightTexture");
|
||||
|
||||
_fboProgramObject =
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.requestProgramObject(
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.request(
|
||||
FBOPassProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return ghoul::opengl::ProgramObject::Build(
|
||||
@@ -405,19 +396,11 @@ void RenderablePlanetProjection::initializeGL() {
|
||||
}
|
||||
);
|
||||
|
||||
_fboUniformCache.projectionTexture = _fboProgramObject->uniformLocation(
|
||||
"projectionTexture"
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_fboProgramObject,
|
||||
_fboUniformCache,
|
||||
FboUniformNames
|
||||
);
|
||||
_fboUniformCache.projectorMatrix = _fboProgramObject->uniformLocation(
|
||||
"ProjectorMatrix"
|
||||
);
|
||||
_fboUniformCache.modelTransform = _fboProgramObject->uniformLocation(
|
||||
"ModelTransform"
|
||||
);
|
||||
_fboUniformCache.scaling = _fboProgramObject->uniformLocation("_scaling");
|
||||
_fboUniformCache.boresight = _fboProgramObject->uniformLocation("boresight");
|
||||
_fboUniformCache.radius = _fboProgramObject->uniformLocation("_radius");
|
||||
_fboUniformCache.segments = _fboProgramObject->uniformLocation("_segments");
|
||||
|
||||
loadColorTexture();
|
||||
loadHeightTexture();
|
||||
@@ -464,7 +447,7 @@ void RenderablePlanetProjection::deinitializeGL() {
|
||||
glDeleteVertexArrays(1, &_quad);
|
||||
glDeleteBuffers(1, &_vertexPositionBuffer);
|
||||
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.releaseProgramObject(
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.release(
|
||||
ProjectiveProgramName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
@@ -472,7 +455,7 @@ void RenderablePlanetProjection::deinitializeGL() {
|
||||
);
|
||||
_programObject = nullptr;
|
||||
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.releaseProgramObject(
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.release(
|
||||
FBOPassProgramName
|
||||
);
|
||||
_fboProgramObject = nullptr;
|
||||
@@ -639,8 +622,8 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&)
|
||||
// Main renderpass
|
||||
_programObject->activate();
|
||||
_programObject->setUniform(_mainUniformCache.sunPos, sun_pos.vec3());
|
||||
//_programObject->setUniform("ViewProjection" , data.camera.viewProjectionMatrix());
|
||||
//_programObject->setUniform("ModelTransform" , _transform);
|
||||
//_program->setUniform("ViewProjection" , data.camera.viewProjectionMatrix());
|
||||
//_program->setUniform("ModelTransform" , _transform);
|
||||
|
||||
// Model transform and view transform needs to be in double precision
|
||||
glm::dmat4 modelTransform =
|
||||
@@ -714,53 +697,22 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&)
|
||||
void RenderablePlanetProjection::update(const UpdateData& data) {
|
||||
if (_programObject->isDirty()) {
|
||||
_programObject->rebuildFromFile();
|
||||
|
||||
_mainUniformCache.sunPos = _programObject->uniformLocation("sun_pos");
|
||||
_mainUniformCache.modelTransform = _programObject->uniformLocation(
|
||||
"modelTransform"
|
||||
);
|
||||
_mainUniformCache.modelViewProjectionTransform = _programObject->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
);
|
||||
_mainUniformCache.hasBaseMap = _programObject->uniformLocation("_hasBaseMap");
|
||||
_mainUniformCache.hasHeightMap = _programObject->uniformLocation("_hasHeightMap");
|
||||
_mainUniformCache.heightExaggeration = _programObject->uniformLocation(
|
||||
"_heightExaggeration"
|
||||
);
|
||||
_mainUniformCache.meridianShift = _programObject->uniformLocation(
|
||||
"_meridianShift"
|
||||
);
|
||||
_mainUniformCache.ambientBrightness = _programObject->uniformLocation(
|
||||
"_ambientBrightness"
|
||||
);
|
||||
_mainUniformCache.projectionFading = _programObject->uniformLocation(
|
||||
"_projectionFading"
|
||||
);
|
||||
_mainUniformCache.baseTexture = _programObject->uniformLocation("baseTexture");
|
||||
_mainUniformCache.projectionTexture = _programObject->uniformLocation(
|
||||
"projectionTexture"
|
||||
);
|
||||
_mainUniformCache.heightTexture = _programObject->uniformLocation(
|
||||
"heightTexture"
|
||||
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_programObject,
|
||||
_mainUniformCache,
|
||||
MainUniformNames
|
||||
);
|
||||
}
|
||||
|
||||
if (_fboProgramObject->isDirty()) {
|
||||
_fboProgramObject->rebuildFromFile();
|
||||
|
||||
_fboUniformCache.projectionTexture = _fboProgramObject->uniformLocation(
|
||||
"projectionTexture"
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_fboProgramObject,
|
||||
_fboUniformCache,
|
||||
FboUniformNames
|
||||
);
|
||||
_fboUniformCache.projectorMatrix = _fboProgramObject->uniformLocation(
|
||||
"ProjectorMatrix"
|
||||
);
|
||||
_fboUniformCache.modelTransform = _fboProgramObject->uniformLocation(
|
||||
"ModelTransform"
|
||||
);
|
||||
_fboUniformCache.scaling = _fboProgramObject->uniformLocation("_scaling");
|
||||
_fboUniformCache.boresight = _fboProgramObject->uniformLocation("boresight");
|
||||
_fboUniformCache.radius = _fboProgramObject->uniformLocation("_radius");
|
||||
_fboUniformCache.segments = _fboProgramObject->uniformLocation("_segments");
|
||||
}
|
||||
|
||||
if (_colorTextureDirty) {
|
||||
|
||||
@@ -39,6 +39,10 @@ namespace {
|
||||
constexpr const char* ProgramName = "ShadowCylinderProgram";
|
||||
constexpr const char* MainFrame = "GALACTIC";
|
||||
|
||||
constexpr const std::array<const char*, 2> UniformNames = {
|
||||
"modelViewProjectionTransform", "shadowColor"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo NumberPointsInfo = {
|
||||
"AmountOfPoints",
|
||||
"Points",
|
||||
@@ -277,7 +281,7 @@ void RenderableShadowCylinder::initializeGL() {
|
||||
glGenVertexArrays(1, &_vao);
|
||||
glGenBuffers(1, &_vbo);
|
||||
|
||||
_shader = SpacecraftInstrumentsModule::ProgramObjectManager.requestProgramObject(
|
||||
_shader = SpacecraftInstrumentsModule::ProgramObjectManager.request(
|
||||
ProgramName,
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return OsEng.renderEngine().buildRenderProgram(
|
||||
@@ -292,16 +296,11 @@ void RenderableShadowCylinder::initializeGL() {
|
||||
}
|
||||
);
|
||||
|
||||
_uniformCache.modelViewProjectionTransform = _shader->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
);
|
||||
_uniformCache.shadowColor = _shader->uniformLocation(
|
||||
"shadowColor"
|
||||
);
|
||||
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
|
||||
}
|
||||
|
||||
void RenderableShadowCylinder::deinitializeGL() {
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.releaseProgramObject(
|
||||
SpacecraftInstrumentsModule::ProgramObjectManager.release(
|
||||
ProgramName,
|
||||
[](ghoul::opengl::ProgramObject* p) {
|
||||
OsEng.renderEngine().removeRenderProgram(p);
|
||||
@@ -352,15 +351,10 @@ void RenderableShadowCylinder::update(const UpdateData& data) {
|
||||
MainFrame,
|
||||
data.time.j2000Seconds()
|
||||
);
|
||||
|
||||
if (_shader->isDirty()) {
|
||||
_shader->rebuildFromFile();
|
||||
|
||||
_uniformCache.modelViewProjectionTransform = _shader->uniformLocation(
|
||||
"modelViewProjectionTransform"
|
||||
);
|
||||
_uniformCache.shadowColor = _shader->uniformLocation(
|
||||
"shadowColor"
|
||||
);
|
||||
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
|
||||
}
|
||||
createCylinder(data.time.j2000Seconds());
|
||||
}
|
||||
|
||||
@@ -233,13 +233,11 @@ bool ImageSequencer::imagePaths(std::vector<Image>& captures,
|
||||
// check if this instance is either in range or
|
||||
// a valid candidate to recieve data
|
||||
|
||||
if (!isInstrumentActive(time, instrumentRequest)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_subsetMap[projectee]._range.includes(time) &&
|
||||
!_subsetMap[projectee]._range.includes(sinceTime))
|
||||
{
|
||||
const bool instrumentActive = isInstrumentActive(time, instrumentRequest);
|
||||
const bool hasCurrentTime = _subsetMap[projectee]._range.includes(time);
|
||||
const bool hasSinceTime = _subsetMap[projectee]._range.includes(sinceTime);
|
||||
|
||||
if (!instrumentActive || (!hasCurrentTime && !hasSinceTime)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ bool LabelParser::create() {
|
||||
using Recursive = ghoul::filesystem::Directory::Recursive;
|
||||
using Sort = ghoul::filesystem::Directory::Sort;
|
||||
std::vector<std::string> sequencePaths = sequenceDir.read(Recursive::Yes, Sort::No);
|
||||
for (std::string path : sequencePaths) {
|
||||
for (const std::string& path : sequencePaths) {
|
||||
size_t position = path.find_last_of('.') + 1;
|
||||
if (position == 0 || position == std::string::npos) {
|
||||
continue;
|
||||
@@ -182,22 +182,39 @@ bool LabelParser::create() {
|
||||
|
||||
_detectorType = "CAMERA"; //default value
|
||||
|
||||
constexpr const char* ErrorMsg =
|
||||
"Unrecognized '{}' in line {} in file {}. The 'Convert' table must "
|
||||
"contain the identity tranformation for all values encountered in the "
|
||||
"label files, for example: ROSETTA = {{ \"ROSETTA\" }}";
|
||||
|
||||
/* Add more */
|
||||
if (read == "TARGET_NAME") {
|
||||
_target = decode(line);
|
||||
if (_target.empty()) {
|
||||
LWARNING(fmt::format(ErrorMsg, "TARGET_NAME", line, path));
|
||||
}
|
||||
count++;
|
||||
}
|
||||
if (read == "INSTRUMENT_HOST_NAME") {
|
||||
_instrumentHostID = decode(line);
|
||||
if (_instrumentHostID.empty()) {
|
||||
LWARNING(fmt::format(ErrorMsg, "INSTRUMENT_HOST_NAME", line, path));
|
||||
}
|
||||
count++;
|
||||
}
|
||||
if (read == "INSTRUMENT_ID") {
|
||||
_instrumentID = decode(line);
|
||||
if (_instrumentID.empty()) {
|
||||
LWARNING(fmt::format(ErrorMsg, "INSTRUMENT_ID", line, path));
|
||||
}
|
||||
lblName = encode(line);
|
||||
count++;
|
||||
}
|
||||
if (read == "DETECTOR_TYPE") {
|
||||
_detectorType = decode(line);
|
||||
if (_detectorType.empty()) {
|
||||
LWARNING(fmt::format(ErrorMsg, "DETECTOR_TYPE", line, path));
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -213,7 +230,7 @@ bool LabelParser::create() {
|
||||
line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
|
||||
|
||||
read = line.substr(0, line.find_first_of('='));
|
||||
if (read == "STOP_TIME"){
|
||||
if (read == "STOP_TIME") {
|
||||
std::string stop = line.substr(line.find('=') + 1);
|
||||
stop.erase(
|
||||
std::remove_if(
|
||||
@@ -245,14 +262,14 @@ bool LabelParser::create() {
|
||||
using namespace std::literals;
|
||||
std::string p = path.substr(0, path.size() - ("lbl"s).size());
|
||||
for (const std::string& ext : extensions) {
|
||||
path = p + ext;
|
||||
if (FileSys.fileExists(path)) {
|
||||
std::string imagePath = p + ext;
|
||||
if (FileSys.fileExists(imagePath)) {
|
||||
std::vector<std::string> spiceInstrument;
|
||||
spiceInstrument.push_back(_instrumentID);
|
||||
|
||||
Image image = {
|
||||
TimeRange(startTime, stopTime),
|
||||
path,
|
||||
imagePath,
|
||||
spiceInstrument,
|
||||
_target,
|
||||
false,
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#pragma optimize ("", off)
|
||||
|
||||
#include <modules/spacecraftinstruments/util/projectioncomponent.h>
|
||||
|
||||
#include <modules/spacecraftinstruments/util/hongkangparser.h>
|
||||
@@ -120,10 +122,7 @@ documentation::Documentation ProjectionComponent::Documentation() {
|
||||
{
|
||||
{
|
||||
keySequenceDir,
|
||||
new OrVerifier(
|
||||
new StringVerifier,
|
||||
new StringListVerifier
|
||||
),
|
||||
new OrVerifier({ new StringVerifier, new StringListVerifier }),
|
||||
Optional::Yes,
|
||||
"This value specifies one or more directories from which images are "
|
||||
"being used for image projections. If the sequence type is set to "
|
||||
|
||||
@@ -58,7 +58,7 @@ documentation::Documentation UrlSynchronization::Documentation() {
|
||||
{
|
||||
{
|
||||
KeyUrl,
|
||||
new OrVerifier(new StringVerifier, new StringListVerifier),
|
||||
new OrVerifier({ new StringVerifier, new StringListVerifier }),
|
||||
Optional::No,
|
||||
"The URL or urls from where the files are downloaded. If multiple URLs "
|
||||
"are provided, all files will be downloaded to the same directory."
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr const std::array<const char*, 4> UniformNames = {
|
||||
"radius", "transparency", "thickness", "color"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo VisibilityInfo = {
|
||||
"Visibility",
|
||||
"Toggle visibility of markers",
|
||||
@@ -97,10 +101,7 @@ void TouchMarker::initialize() {
|
||||
absPath("${MODULE_TOUCH}/shaders/marker_fs.glsl")
|
||||
);
|
||||
|
||||
_uniformCache.radius = _shader->uniformLocation("radius");
|
||||
_uniformCache.transparency = _shader->uniformLocation("transparency");
|
||||
_uniformCache.thickness = _shader->uniformLocation("thickness");
|
||||
_uniformCache.color = _shader->uniformLocation("color");
|
||||
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
|
||||
}
|
||||
|
||||
void TouchMarker::deinitialize() {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <openspace/documentation/verifier.h>
|
||||
|
||||
#include <openspace/documentation/documentationengine.h>
|
||||
#include <ghoul/misc/misc.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace openspace::documentation {
|
||||
@@ -291,21 +292,33 @@ std::string ReferencingVerifier::documentation() const {
|
||||
return "Referencing Documentation: '" + identifier + "'";
|
||||
}
|
||||
|
||||
AndVerifier::AndVerifier(Verifier* l, Verifier* r)
|
||||
: lhs(l)
|
||||
, rhs(r)
|
||||
{
|
||||
ghoul_assert(lhs, "lhs must not be nullptr");
|
||||
ghoul_assert(rhs, "rhs must not be nullptr");
|
||||
AndVerifier::AndVerifier(const std::vector<Verifier*> vs) {
|
||||
ghoul_assert(!vs.empty(), "values must not be empty");
|
||||
for (Verifier* v : vs) {
|
||||
values.push_back(std::shared_ptr<Verifier>(v));
|
||||
}
|
||||
}
|
||||
|
||||
TestResult AndVerifier::operator()(const ghoul::Dictionary& dictionary,
|
||||
const std::string& key) const
|
||||
{
|
||||
TestResult resLhs = lhs->operator()(dictionary, key);
|
||||
TestResult resRhs = rhs->operator()(dictionary, key);
|
||||
std::vector<TestResult> res(values.size());
|
||||
std::transform(
|
||||
values.begin(),
|
||||
values.end(),
|
||||
res.begin(),
|
||||
[dictionary, key](const std::shared_ptr<Verifier>& v) {
|
||||
return v->operator()(dictionary, key);
|
||||
}
|
||||
);
|
||||
|
||||
if (resLhs.success && resRhs.success) {
|
||||
const bool success = std::all_of(
|
||||
res.begin(),
|
||||
res.end(),
|
||||
[](const TestResult& res) { return res.success; }
|
||||
);
|
||||
|
||||
if (success) {
|
||||
return { true, {}, {} };
|
||||
}
|
||||
else {
|
||||
@@ -314,33 +327,60 @@ TestResult AndVerifier::operator()(const ghoul::Dictionary& dictionary,
|
||||
}
|
||||
|
||||
std::string AndVerifier::type() const {
|
||||
if (lhs->type() != rhs->type()) {
|
||||
return lhs->type() + " and " + rhs->type();
|
||||
}
|
||||
else {
|
||||
return lhs->type();
|
||||
}
|
||||
// Dirty hack to get an "and " inserted before the last element
|
||||
std::vector<std::string> types(values.size() - 1);
|
||||
std::transform(
|
||||
values.begin(),
|
||||
values.end() - 1,
|
||||
types.begin(),
|
||||
[](const std::shared_ptr<Verifier>& v) { return v->type(); }
|
||||
);
|
||||
types.push_back(std::string("and ") + values.back()->type());
|
||||
|
||||
return ghoul::join(types, ", ");
|
||||
}
|
||||
|
||||
std::string AndVerifier::documentation() const {
|
||||
return lhs->documentation() + " and " + rhs->documentation();
|
||||
// Dirty hack to get an "and " inserted before the last element
|
||||
std::vector<std::string> documentations(values.size() - 1);
|
||||
std::transform(
|
||||
values.begin(),
|
||||
values.end() - 1,
|
||||
documentations.begin(),
|
||||
[](const std::shared_ptr<Verifier>& v) { return v->documentation(); }
|
||||
);
|
||||
documentations.push_back(std::string("and ") + values.back()->documentation());
|
||||
|
||||
return ghoul::join(documentations, ", ");
|
||||
}
|
||||
|
||||
OrVerifier::OrVerifier(Verifier* l, Verifier* r)
|
||||
: lhs(l)
|
||||
, rhs(r)
|
||||
{
|
||||
ghoul_assert(lhs, "lhs must not be nullptr");
|
||||
ghoul_assert(rhs, "rhs must not be nullptr");
|
||||
OrVerifier::OrVerifier(const std::vector<Verifier*> vs) {
|
||||
ghoul_assert(!vs.empty(), "values must not be empty");
|
||||
for (Verifier* v : vs) {
|
||||
values.push_back(std::shared_ptr<Verifier>(v));
|
||||
}
|
||||
}
|
||||
|
||||
TestResult OrVerifier::operator()(const ghoul::Dictionary& dictionary,
|
||||
const std::string& key) const
|
||||
const std::string& key) const
|
||||
{
|
||||
TestResult resA = lhs->operator()(dictionary, key);
|
||||
TestResult resB = rhs->operator()(dictionary, key);
|
||||
std::vector<TestResult> res(values.size());
|
||||
std::transform(
|
||||
values.begin(),
|
||||
values.end(),
|
||||
res.begin(),
|
||||
[dictionary, key](const std::shared_ptr<Verifier>& v) {
|
||||
return v->operator()(dictionary, key);
|
||||
}
|
||||
);
|
||||
|
||||
if (resA.success || resB.success) {
|
||||
const bool success = std::any_of(
|
||||
res.begin(),
|
||||
res.end(),
|
||||
[](const TestResult& res) { return res.success; }
|
||||
);
|
||||
|
||||
if (success) {
|
||||
return { true, {}, {} };
|
||||
}
|
||||
else {
|
||||
@@ -349,17 +389,31 @@ TestResult OrVerifier::operator()(const ghoul::Dictionary& dictionary,
|
||||
}
|
||||
|
||||
std::string OrVerifier::type() const {
|
||||
if (lhs->type() != rhs->type()) {
|
||||
return lhs->type() + " or " + rhs->type();
|
||||
}
|
||||
else {
|
||||
return lhs->type();
|
||||
}
|
||||
// Dirty hack to get an "or " inserted before the last element
|
||||
std::vector<std::string> types(values.size() - 1);
|
||||
std::transform(
|
||||
values.begin(),
|
||||
values.end() - 1,
|
||||
types.begin(),
|
||||
[](const std::shared_ptr<Verifier>& v) { return v->type(); }
|
||||
);
|
||||
types.push_back(std::string("or ") + values.back()->type());
|
||||
|
||||
return ghoul::join(types, ", ");
|
||||
}
|
||||
|
||||
std::string OrVerifier::documentation() const {
|
||||
return lhs->documentation() + " or " + rhs->documentation();
|
||||
// Dirty hack to get an "or " inserted before the last element
|
||||
std::vector<std::string> documentations(values.size() - 1);
|
||||
std::transform(
|
||||
values.begin(),
|
||||
values.end() - 1,
|
||||
documentations.begin(),
|
||||
[](const std::shared_ptr<Verifier>& v) { return v->documentation(); }
|
||||
);
|
||||
documentations.push_back(std::string("or ") + values.back()->documentation());
|
||||
|
||||
return ghoul::join(documentations, ", ");
|
||||
}
|
||||
|
||||
|
||||
} // namespace openspace::documentation
|
||||
|
||||
@@ -49,6 +49,11 @@
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "FramebufferRenderer";
|
||||
|
||||
constexpr const std::array<const char*, 3> UniformNames = {
|
||||
"mainColorTextures", "blackoutFactor", "nAaSamples"
|
||||
};
|
||||
|
||||
constexpr const char* ExitFragmentShaderPath =
|
||||
"${SHADERS}/framebuffer/exitframebuffer.frag";
|
||||
constexpr const char* RaycastFragmentShaderPath =
|
||||
@@ -222,9 +227,7 @@ void FramebufferRenderer::initialize() {
|
||||
absPath("${SHADERS}/framebuffer/resolveframebuffer.frag")
|
||||
);
|
||||
|
||||
_uniformCache.mainColorTexture = _resolveProgram->uniformLocation("mainColorTexture");
|
||||
_uniformCache.blackoutFactor = _resolveProgram->uniformLocation("blackoutFactor");
|
||||
_uniformCache.nAaSamples = _resolveProgram->uniformLocation("nAaSamples");
|
||||
ghoul::opengl::updateUniformLocations(*_resolveProgram, _uniformCache, UniformNames);
|
||||
|
||||
OsEng.renderEngine().raycasterManager().addListener(*this);
|
||||
OsEng.renderEngine().deferredcasterManager().addListener(*this);
|
||||
@@ -294,11 +297,11 @@ void FramebufferRenderer::update() {
|
||||
if (_resolveProgram->isDirty()) {
|
||||
_resolveProgram->rebuildFromFile();
|
||||
|
||||
_uniformCache.mainColorTexture = _resolveProgram->uniformLocation(
|
||||
"mainColorTexture"
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_resolveProgram,
|
||||
_uniformCache,
|
||||
UniformNames
|
||||
);
|
||||
_uniformCache.blackoutFactor = _resolveProgram->uniformLocation("blackoutFactor");
|
||||
_uniformCache.nAaSamples = _resolveProgram->uniformLocation("nAaSamples");
|
||||
}
|
||||
|
||||
using K = VolumeRaycaster*;
|
||||
|
||||
@@ -110,9 +110,11 @@ LoadingScreen::LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeName
|
||||
absPath("${SHADERS}/loadingscreen.frag")
|
||||
);
|
||||
|
||||
_uniformCache.logoTexture = _program->uniformLocation("logoTexture");
|
||||
_uniformCache.useTexture = _program->uniformLocation("useTexture");
|
||||
_uniformCache.color = _program->uniformLocation("color");
|
||||
ghoul::opengl::updateUniformLocations(
|
||||
*_program,
|
||||
_uniformCache,
|
||||
{ "logoTexture", "useTexture", "color" }
|
||||
);
|
||||
|
||||
_loadingFont = OsEng.fontManager().font(
|
||||
"Loading",
|
||||
|
||||
@@ -66,6 +66,10 @@ namespace {
|
||||
// when horizontal scrolling is required.
|
||||
constexpr const int NVisibleCharsAfterCursor = 5;
|
||||
|
||||
constexpr std::array<const char*, 4> UniformNames = {
|
||||
"res", "color", "height", "ortho"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo VisibleInfo = {
|
||||
"IsVisible",
|
||||
"Is Visible",
|
||||
@@ -242,10 +246,7 @@ void LuaConsole::initialize() {
|
||||
absPath("${SHADERS}/luaconsole.frag")
|
||||
);
|
||||
|
||||
_uniformCache.res = _program->uniformLocation("res");
|
||||
_uniformCache.color = _program->uniformLocation("color");
|
||||
_uniformCache.height = _program->uniformLocation("height");
|
||||
_uniformCache.ortho = _program->uniformLocation("ortho");
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
|
||||
const GLfloat data[] = {
|
||||
0.f, 0.f,
|
||||
@@ -701,10 +702,7 @@ void LuaConsole::render() {
|
||||
if (_program->isDirty()) {
|
||||
_program->rebuildFromFile();
|
||||
|
||||
_uniformCache.res = _program->uniformLocation("res");
|
||||
_uniformCache.color = _program->uniformLocation("color");
|
||||
_uniformCache.height = _program->uniformLocation("height");
|
||||
_uniformCache.ortho = _program->uniformLocation("ortho");
|
||||
ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames);
|
||||
}
|
||||
|
||||
const glm::vec2 dpiScaling = OsEng.windowWrapper().dpiScaling();
|
||||
|
||||
@@ -42,6 +42,10 @@ namespace {
|
||||
constexpr const char* KeyTag = "Tag";
|
||||
constexpr const float PlaneDepth = -2.f;
|
||||
|
||||
constexpr const std::array<const char*, 5> UniformNames = {
|
||||
"OcclusionDepth", "Alpha", "ModelTransform", "ViewProjectionMatrix", "texture1"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo EnabledInfo = {
|
||||
"Enabled",
|
||||
"Is Enabled",
|
||||
@@ -201,10 +205,7 @@ documentation::Documentation ScreenSpaceRenderable::Documentation() {
|
||||
},
|
||||
{
|
||||
KeyTag,
|
||||
new OrVerifier(
|
||||
new StringVerifier,
|
||||
new StringListVerifier
|
||||
),
|
||||
new OrVerifier({ new StringVerifier, new StringListVerifier }),
|
||||
Optional::Yes,
|
||||
"Defines either a single or multiple tags that apply to this "
|
||||
"ScreenSpaceRenderable, thus making it possible to address multiple, "
|
||||
@@ -474,12 +475,7 @@ void ScreenSpaceRenderable::createShaders() {
|
||||
dict
|
||||
);
|
||||
|
||||
_uniformCache.occlusionDepth = _shader->uniformLocation("OcclusionDepth");
|
||||
_uniformCache.alpha = _shader->uniformLocation("Alpha");
|
||||
_uniformCache.modelTransform = _shader->uniformLocation("ModelTransform");
|
||||
_uniformCache.viewProj = _shader->uniformLocation("ViewProjectionMatrix");
|
||||
_uniformCache.texture = _shader->uniformLocation("texture1");
|
||||
|
||||
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
|
||||
}
|
||||
|
||||
glm::mat4 ScreenSpaceRenderable::scaleMatrix() {
|
||||
|
||||
@@ -207,12 +207,6 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(std::string filePath) {
|
||||
|
||||
if (it != _loadedKernels.end()) {
|
||||
it->refCount++;
|
||||
LDEBUG(
|
||||
fmt::format(
|
||||
"Kernel '{}' was already loaded. New reference count: {}",
|
||||
path, it->refCount
|
||||
)
|
||||
);
|
||||
return it->id;
|
||||
}
|
||||
|
||||
|
||||
@@ -2023,9 +2023,12 @@ TEST_F(DocumentationTest, AndOperator) {
|
||||
|
||||
Documentation doc {
|
||||
{
|
||||
{ "a", new AndVerifier(
|
||||
new IntGreaterEqualVerifier(2), new IntLessEqualVerifier(5)
|
||||
), Optional::No
|
||||
{
|
||||
"a",
|
||||
new AndVerifier({
|
||||
new IntGreaterEqualVerifier(2), new IntLessEqualVerifier(5)
|
||||
}),
|
||||
Optional::No
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -2061,7 +2064,7 @@ TEST_F(DocumentationTest, OrOperator) {
|
||||
using namespace std::string_literals;
|
||||
|
||||
Documentation doc {
|
||||
{{ "a", new OrVerifier(new StringVerifier, new IntVerifier), Optional::No}}
|
||||
{{ "a", new OrVerifier({ new StringVerifier, new IntVerifier }), Optional::No }}
|
||||
};
|
||||
|
||||
ghoul::Dictionary positive {
|
||||
|
||||
Reference in New Issue
Block a user