Fix style guide issues

Update Ghoul repository
This commit is contained in:
Alexander Bock
2017-12-29 19:18:06 +01:00
parent 023b654c16
commit c9a3c68f19
94 changed files with 1324 additions and 1424 deletions
+1 -1
View File
@@ -632,7 +632,7 @@ int main_main(int argc, char** argv) {
LDEBUG("Starting rendering loop");
SgctEngine->render();
LDEBUG("Ending rendering loop");
cleanup(IsInitialized::Yes);
// Exit program
+1 -1
View File
@@ -223,7 +223,7 @@ private:
properties::StringProperty versionString;
properties::StringProperty sourceControlInformation;
} _versionInformation;
bool _hasScheduledAssetLoading;
std::string _scheduledAssetPathToLoad;
+13 -18
View File
@@ -25,32 +25,27 @@
#ifndef __OPENSPACE_CORE___ABUFFERRENDERER___H__
#define __OPENSPACE_CORE___ABUFFERRENDERER___H__
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/glm.h>
#include <ghoul/misc/dictionary.h>
#include <memory>
#include <string>
#include <vector>
#include <map>
#include <ghoul/opengl/textureunit.h>
#include <openspace/rendering/volume.h>
#include <openspace/rendering/renderer.h>
#include <openspace/rendering/raycasterlistener.h>
#include <openspace/util/updatestructures.h>
namespace ghoul {
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/glm.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/opengl/textureunit.h>
namespace filesystem { class File; }
#include <map>
#include <memory>
#include <string>
#include <vector>
namespace opengl {
namespace ghoul::filesystem { class File; }
namespace ghoul::opengl {
class ProgramObject;
class Texture;
} // namepsace opengl
} // namespace ghoul
} // namespace opengl
namespace openspace {
@@ -101,7 +96,7 @@ private:
void updateMSAASamplingPattern();
void saveTextureToMemory(const GLenum color_buffer_attachment,
const int width, const int height, std::vector<double> & memory) const;
Camera* _camera;
Scene* _scene;
glm::ivec2 _resolution;
+9 -9
View File
@@ -25,9 +25,10 @@
#ifndef __OPENSPACE_CORE___DEFERREDCASTER___H
#define __OPENSPACE_CORE___DEFERREDCASTER___H
#include <openspace/util/updatestructures.h>
#include <string>
#include <vector>
#include <openspace/util/updatestructures.h>
namespace ghoul::opengl {
class Texture;
@@ -41,16 +42,15 @@ struct DeferredcastData;
class Deferredcaster {
public:
/**
* Destructor
*/
virtual ~Deferredcaster() {};
virtual ~Deferredcaster() = default;
virtual void preRaycast(const RenderData& /*renderData*/,
const DeferredcastData& /*deferredData*/, ghoul::opengl::ProgramObject& /*program*/) {};
const DeferredcastData& /*deferredData*/,
ghoul::opengl::ProgramObject& /*program*/) {};
virtual void postRaycast(const RenderData & /*renderData*/,
const DeferredcastData& /*deferredData*/, ghoul::opengl::ProgramObject& /*program*/) {};
const DeferredcastData& /*deferredData*/,
ghoul::opengl::ProgramObject& /*program*/) {};
virtual std::string deferredcastPath() const = 0;
@@ -65,8 +65,8 @@ public:
* regardless of how many volumes say they require the file.
* Ideal to avoid redefinitions of helper functions.
*
* The shader preprocessor will have access to the #{namespace} variable (unique per helper file)
* which should be a prefix to all symbols defined by the helper
* The shader preprocessor will have access to the #{namespace} variable (unique per
* helper file) which should be a prefix to all symbols defined by the helper
*/
virtual std::string helperPath() const = 0;
};
@@ -41,5 +41,4 @@ public:
} // openspace
#endif // __OPENSPACE_CORE___DEFERREDCASTERLISTENER___H__
@@ -25,18 +25,18 @@
#ifndef __OPENSPACE_CORE___FRAMEBUFFERRENDERER___H__
#define __OPENSPACE_CORE___FRAMEBUFFERRENDERER___H__
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/glm.h>
#include <string>
#include <vector>
#include <map>
#include <openspace/rendering/deferredcasterlistener.h>
#include <openspace/rendering/raycasterlistener.h>
#include <openspace/rendering/renderer.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/glm.h>
#include <map>
#include <string>
#include <vector>
namespace ghoul { class Dictionary; }
namespace ghoul::filesystem { class File; }
@@ -49,7 +49,7 @@ namespace openspace {
class Camera;
class Scene;
class FramebufferRenderer : public Renderer, public RaycasterListener,
public DeferredcasterListener
{
@@ -89,7 +89,8 @@ public:
virtual void updateRendererData() override;
virtual void raycastersChanged(VolumeRaycaster& raycaster, bool attached) override;
virtual void deferredcastersChanged(Deferredcaster& deferredcaster, ghoul::Boolean isAttached) override;
virtual void deferredcastersChanged(Deferredcaster& deferredcaster,
ghoul::Boolean isAttached) override;
private:
std::map<VolumeRaycaster*, RaycastData> _raycastData;
@@ -104,7 +105,10 @@ private:
> _insideRaycastPrograms;
std::map<Deferredcaster*, DeferredcastData> _deferredcastData;
std::map<Deferredcaster*, std::unique_ptr<ghoul::opengl::ProgramObject>> _deferredcastPrograms;
std::map<
Deferredcaster*,
std::unique_ptr<ghoul::opengl::ProgramObject>
> _deferredcastPrograms;
std::unique_ptr<ghoul::opengl::ProgramObject> _hdrBackGroundProgram;
std::unique_ptr<ghoul::opengl::ProgramObject> _resolveProgram;
@@ -41,6 +41,7 @@ public:
void addListener(RaycasterListener& listener);
void removeListener(RaycasterListener& listener);
private:
std::vector<VolumeRaycaster*> _raycasters;
std::vector<RaycasterListener*> _listeners;
+10 -9
View File
@@ -30,12 +30,12 @@
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/filesystem/file.h>
#include <string>
#include <vector>
#include <memory>
#include <unordered_map>
#include <iterator>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
namespace openspace {
@@ -53,7 +53,7 @@ public:
Initialized,
InitializationFailed
};
using StateChangeCallback = std::function<void(State)>;
using CallbackHandle = size_t;
@@ -68,7 +68,7 @@ public:
Asset(AssetLoader* loader,
SynchronizationWatcher* watcher,
ghoul::filesystem::File assetPath);
~Asset();
std::string id() const;
@@ -78,7 +78,7 @@ public:
std::string assetName() const;
AssetLoader* loader() const;
State state() const;
void addSynchronization(std::shared_ptr<ResourceSynchronization> synchronization);
std::vector<std::shared_ptr<ResourceSynchronization>> ownSynchronizations() const;
@@ -142,6 +142,7 @@ public:
bool shouldBeInitialized() const;
std::string resolveLocalResource(std::string resourceName);
private:
void setState(State state);
@@ -174,11 +175,11 @@ private:
// Assets that refers to this asset as a requested asset
std::vector<std::weak_ptr<Asset>> _requestingAssets;
// Synchronization watches
std::vector<SynchronizationWatcher::WatchHandle> _syncWatches;
};
} // namespace openspace
#endif // __OPENSPACE_CORE___ASSET__H__
#endif // __OPENSPACE_CORE___ASSET___H__
+13 -24
View File
@@ -26,15 +26,13 @@
#define __OPENSPACE_CORE___ASSETLOADER___H__
#include <openspace/scene/asset.h>
#include <openspace/scripting/lualibrary.h>
#include <openspace/util/resourcesynchronization.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/lua/luastate.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/filesystem/directory.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/luastate.h>
#include <memory>
#include <string>
@@ -42,8 +40,8 @@
namespace openspace {
namespace assetloader {
int onInitialize(lua_State* state);
int onDeinitialize(lua_State* state);
int onInitializeDependency(lua_State* state);
@@ -54,33 +52,27 @@ int localResource(lua_State* state);
int syncedResource(lua_State* state);
int noOperation(lua_State* state);
int exportAsset(lua_State* state);
} // namespace assetloader
class SynchronizationWatcher;
class AssetListener {
public:
virtual ~AssetListener() = default;
virtual void assetStateChanged(std::shared_ptr<Asset> asset, Asset::State state) = 0;
virtual void assetRequested(std::shared_ptr<Asset> parent,
std::shared_ptr<Asset> child) = 0;
std::shared_ptr<Asset> child) = 0;
virtual void assetUnrequested(std::shared_ptr<Asset> parent,
std::shared_ptr<Asset> child) = 0;
std::shared_ptr<Asset> child) = 0;
};
class SynchronizationWatcher;
class AssetLoader {
public:
/**
* Constructor
*/
AssetLoader(ghoul::lua::LuaState& luaState,
SynchronizationWatcher* syncWatcher,
public:
AssetLoader(ghoul::lua::LuaState& luaState, SynchronizationWatcher* syncWatcher,
std::string assetRoot);
/**
* Destructor
*/
~AssetLoader();
/**
@@ -159,7 +151,7 @@ public:
* relative to `baseDirectory`
*/
std::string generateAssetPath(const std::string& baseDirectory,
const std::string& path) const;
const std::string& path) const;
/**
* Add listener to asset state changes
@@ -185,7 +177,7 @@ public:
* Notify listeners about removed requests
*/
void assetUnrequested(std::shared_ptr<Asset> parent, std::shared_ptr<Asset> child);
private:
std::shared_ptr<Asset> require(const std::string& identifier);
std::shared_ptr<Asset> request(const std::string& path);
@@ -243,9 +235,6 @@ private:
int _assetsTableRef;
};
} // namespace openspace
#endif // __OPENSPACE_CORE___ASSETLOADER___H__
+6 -6
View File
@@ -26,16 +26,14 @@
#define __OPENSPACE_CORE___ASSETMANAGER___H__
#include <openspace/scene/asset.h>
#include <openspace/scene/assetloader.h>
#include <openspace/scripting/lualibrary.h>
#include <openspace/util/synchronizationwatcher.h>
#include <openspace/scripting/lualibrary.h>
#include <vector>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace openspace {
@@ -66,8 +64,10 @@ public:
std::shared_ptr<Asset> rootAsset();
void assetStateChanged(std::shared_ptr<Asset> asset, Asset::State state) override;
void assetRequested(std::shared_ptr<Asset> parent, std::shared_ptr<Asset> child) override;
void assetUnrequested(std::shared_ptr<Asset> parent, std::shared_ptr<Asset> child) override;
void assetRequested(std::shared_ptr<Asset> parent,
std::shared_ptr<Asset> child) override;
void assetUnrequested(std::shared_ptr<Asset> parent,
std::shared_ptr<Asset> child) override;
bool update();
scripting::LuaLibrary luaLibrary();
+5 -5
View File
@@ -26,12 +26,11 @@
#define __OPENSPACE_CORE___SCENEINITIALIZER___H__
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/threadpool.h>
#include <mutex>
#include <vector>
#include <unordered_set>
#include <vector>
namespace openspace {
@@ -42,28 +41,29 @@ public:
virtual std::vector<SceneGraphNode*> getInitializedNodes() = 0;
virtual bool isInitializing() const = 0;
};
class SingleThreadedSceneInitializer : public SceneInitializer {
public:
void initializeNode(SceneGraphNode* node) override;
std::vector<SceneGraphNode*> getInitializedNodes() override;
bool isInitializing() const override;
private:
std::vector<SceneGraphNode*> _initializedNodes;
};
class MultiThreadedSceneInitializer : public SceneInitializer {
public:
MultiThreadedSceneInitializer(unsigned int nThreads);
void initializeNode(SceneGraphNode* node) override;
std::vector<SceneGraphNode*> getInitializedNodes() override;
bool isInitializing() const override;
private:
std::vector<SceneGraphNode*> _initializedNodes;
std::unordered_set<SceneGraphNode*> _initializingNodes;
ThreadPool _threadPool;
mutable std::mutex _mutex;
};
} // namespace openspace
+3 -3
View File
@@ -38,7 +38,7 @@
#include <condition_variable>
namespace openspace {
namespace curlfunctions {
size_t writeCallback(
char *ptr,
@@ -91,7 +91,7 @@ public:
};
using ReadyStateChangeCallback = std::function<void(ReadyState)>;
// ProgressCallback: Return non-zero value to cancel download.
using ProgressCallback = std::function<int(Progress)>;
@@ -131,7 +131,7 @@ private:
ReadyState _readyState;
Progress _progress;
RequestOptions _options;
friend size_t curlfunctions::writeCallback(
char *ptr,
size_t size,
@@ -25,23 +25,16 @@
#ifndef __OPENSPACE_CORE___RESOURCESYNCHRONIZATION___H__
#define __OPENSPACE_CORE___RESOURCESYNCHRONIZATION___H__
#include <openspace/documentation/documentation.h>
#include <openspace/util/concurrentjobmanager.h>
#include <ghoul/filesystem/directory.h>
#include <ghoul/misc/dictionary.h>
#include <openspace/documentation/documentation.h>
#include <unordered_map>
namespace openspace {
struct SynchronizationConfiguration {
std::string syncRoot;
std::vector<std::string> httpRepositories;
bool allowSynchronization;
};
class ResourceSynchronization
: public std::enable_shared_from_this<ResourceSynchronization>
{
@@ -27,16 +27,15 @@
#include <openspace/util/resourcesynchronization.h>
#include <mutex>
#include <vector>
#include <memory>
#include <mutex>
#include <unordered_map>
#include <vector>
namespace openspace {
/**
* Delays callbacks of synchronization state changes to
* Delays callbacks of synchronization state changes to
* when notify is called.
*/
class SynchronizationWatcher {
+2 -2
View File
@@ -1,4 +1,4 @@
/*****************************************************************************************
/*****************************************************************************************
* *
* OpenSpace *
* *
@@ -32,7 +32,7 @@
namespace openspace {
AtmosphereModule::AtmosphereModule() :
AtmosphereModule::AtmosphereModule() :
OpenSpaceModule("Atmosphere")
{}
@@ -149,7 +149,7 @@ AtmosphereDeferredcaster::AtmosphereDeferredcaster()
, _mu_samples(128)
, _mu_s_samples(32)
, _nu_samples(8)
, _hardShadowsEnabled(false)
, _hardShadowsEnabled(false)
, _calculationTextureScale(1.0)
, _saveCalculationTextures(false)
{}
@@ -170,7 +170,7 @@ void AtmosphereDeferredcaster::deinitialize() {
_deltaSProgramObject = nullptr;
_deltaSSupTermsProgramObject = nullptr;
_deltaJProgramObject = nullptr;
glDeleteTextures(1, &_transmittanceTableTexture);
glDeleteTextures(1, &_irradianceTableTexture);
glDeleteTextures(1, &_inScatteringTableTexture);
@@ -179,13 +179,12 @@ void AtmosphereDeferredcaster::deinitialize() {
glDeleteTextures(1, &_deltaSMieTableTexture);
glDeleteTextures(1, &_deltaJTableTexture);
glDeleteTextures(1, &_atmosphereTexture);
}
void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData,
const DeferredcastData& deferredData,
ghoul::opengl::ProgramObject& program)
{
ghoul::opengl::ProgramObject& program)
{
// Atmosphere Frustum Culling
glm::dvec3 tPlanetPosWorld = glm::dvec3(
_modelTransform * glm::dvec4(0.0, 0.0, 0.0, 1.0)
@@ -193,7 +192,7 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData,
double distance = glm::distance(tPlanetPosWorld, renderData.camera.positionVec3());
if (distance > DISTANCE_CULLING) {
program.setUniform("cullAtmosphere", 1);
program.setUniform("cullAtmosphere", 1);
}
else {
glm::dmat4 MV = glm::dmat4(
@@ -227,7 +226,7 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData,
program.setUniform("ozoneLayerEnabled", _ozoneEnabled);
program.setUniform("HO", _ozoneHeightScale);
program.setUniform("betaOzoneExtinction", _ozoneExtinctionCoeff);
program.setUniform("TRANSMITTANCE_W", _transmittance_table_width);
program.setUniform("TRANSMITTANCE_H", _transmittance_table_height);
program.setUniform("SKY_W", _irradiance_table_width);
@@ -301,7 +300,7 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData,
);
}
else {
sunPosObj = inverseModelMatrix *
sunPosObj = inverseModelMatrix *
glm::dvec4(sunPosWorld - renderData.modelTransform.translation, 1.0);
}
@@ -335,7 +334,7 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData,
lt
);
casterPos *= KM_TO_M; // converting to meters
// First we determine if the caster is shadowing the current planet
// (all calculations in World Coordinates):
glm::dvec3 planetCasterVec = casterPos - renderData.position.dvec3();
@@ -404,9 +403,8 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData,
}
program.setUniform("hardShadows", _hardShadowsEnabled);
}
}
}
}
_transmittanceTableTextureUnit.activate();
glBindTexture(GL_TEXTURE_2D, _transmittanceTableTexture);
program.setUniform("transmittanceTexture", _transmittanceTableTextureUnit);
@@ -424,7 +422,7 @@ void AtmosphereDeferredcaster::postRaycast(const RenderData& renderData,
const DeferredcastData& deferredData,
ghoul::opengl::ProgramObject& program)
{
// Deactivate the texture units
// Deactivate the texture units
_transmittanceTableTextureUnit.deactivate();
_irradianceTableTextureUnit.deactivate();
_inScatteringTableTextureUnit.deactivate();
@@ -703,7 +701,7 @@ void AtmosphereDeferredcaster::createComputationTextures() {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, _transmittance_table_width,
_transmittance_table_height, 0, GL_RGB, GL_FLOAT, nullptr);
//============== Irradiance =================
ghoul::opengl::TextureUnit irradianceTableTextureUnit;
irradianceTableTextureUnit.activate();
@@ -716,7 +714,7 @@ void AtmosphereDeferredcaster::createComputationTextures() {
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, _irradiance_table_width,
_irradiance_table_height, 0, GL_RGB, GL_FLOAT, nullptr);
//============== InScattering =================
ghoul::opengl::TextureUnit inScatteringTableTextureUnit;
inScatteringTableTextureUnit.activate();
@@ -853,7 +851,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
//glClear(GL_COLOR_BUFFER_BIT);
static const float black[] = { 0.0f, 0.0f, 0.0f, 0.0f };
glClearBufferfv(GL_COLOR, 0, black);
renderQuadForCalc(quadCalcVAO, vertexSize);
renderQuadForCalc(quadCalcVAO, vertexSize);
if (_saveCalculationTextures) {
saveTextureToPPMFile(
GL_COLOR_ATTACHMENT0,
@@ -863,7 +861,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
);
}
_transmittanceProgramObject->deactivate();
// line 2 in algorithm 4.1
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, _deltaETableTexture, 0);
checkFrameBufferState("_deltaETableTexture");
@@ -887,7 +885,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
);
}
_irradianceProgramObject->deactivate();
// line 3 in algorithm 4.1
glFramebufferTexture(
GL_FRAMEBUFFER,
@@ -936,7 +934,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
glDrawBuffers(1, drawBuffers);
_inScatteringProgramObject->deactivate();
// line 4 in algorithm 4.1
glFramebufferTexture(
GL_FRAMEBUFFER,
@@ -961,7 +959,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
_delta_e_table_width, _delta_e_table_height);
}
_deltaEProgramObject->deactivate();
// line 5 in algorithm 4.1
glFramebufferTexture(
GL_FRAMEBUFFER,
@@ -992,7 +990,6 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
// loop in line 6 in algorithm 4.1
for (int scatteringOrder = 2; scatteringOrder <= 4; ++scatteringOrder) {
// line 7 in algorithm 4.1
glFramebufferTexture(
GL_FRAMEBUFFER,
@@ -1039,7 +1036,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
_mu_s_samples * _nu_samples, _mu_samples);
}
_deltaJProgramObject->deactivate();
// line 8 in algorithm 4.1
glFramebufferTexture(
GL_FRAMEBUFFER,
@@ -1089,7 +1086,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
_delta_e_table_width, _delta_e_table_height);
}
_irradianceSupTermsProgramObject->deactivate();
// line 9 in algorithm 4.1
glFramebufferTexture(
GL_FRAMEBUFFER,
@@ -1107,7 +1104,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
transmittanceTableTextureUnit
);
deltaJTableTextureUnit.activate();
glBindTexture(GL_TEXTURE_3D, _deltaJTableTexture);
glBindTexture(GL_TEXTURE_3D, _deltaJTableTexture);
_inScatteringSupTermsProgramObject->setUniform(
"deltaJTexture",
deltaJTableTextureUnit
@@ -1128,7 +1125,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
);
}
_inScatteringSupTermsProgramObject->deactivate();
glEnable(GL_BLEND);
glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
glBlendFuncSeparate(GL_ONE, GL_ONE, GL_ONE, GL_ONE);
@@ -1158,11 +1155,11 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
_delta_e_table_width, _delta_e_table_height);
}
_irradianceFinalProgramObject->deactivate();
// line 11 in algorithm 4.1
glFramebufferTexture(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT0,
_inScatteringTableTexture,
0
);
@@ -1187,7 +1184,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO,
_mu_s_samples * _nu_samples, _mu_samples);
}
_deltaSSupTermsProgramObject->deactivate();
glDisable(GL_BLEND);
}
@@ -1204,7 +1201,7 @@ void AtmosphereDeferredcaster::preCalculateAtmosphereParam() {
//========= Load Shader Programs for Calculations ==========
//==========================================================
loadComputationPrograms();
//==========================================================
//============ Create Textures for Calculations ============
//==========================================================
@@ -1241,8 +1238,12 @@ void AtmosphereDeferredcaster::preCalculateAtmosphereParam() {
// Restores system state
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
glViewport(m_viewport[0], m_viewport[1],
m_viewport[2], m_viewport[3]);
glViewport(
m_viewport[0],
m_viewport[1],
m_viewport[2],
m_viewport[3]
);
glDeleteBuffers(1, &quadCalcVBO);
glDeleteVertexArrays(1, &quadCalcVAO);
glDeleteFramebuffers(1, &calcFBO);
@@ -1250,9 +1251,7 @@ void AtmosphereDeferredcaster::preCalculateAtmosphereParam() {
LDEBUG("Ended precalculations for Atmosphere effects...");
}
void AtmosphereDeferredcaster::resetAtmosphereTextures(){
}
void AtmosphereDeferredcaster::resetAtmosphereTextures() {}
void AtmosphereDeferredcaster::createRenderQuad(GLuint* vao, GLuint* vbo, GLfloat size) {
glGenVertexArrays(1, vao);
@@ -1390,7 +1389,7 @@ void AtmosphereDeferredcaster::step3DTexture(
float diff = atm2 - earth2;
float ri = static_cast<float>(layer) / static_cast<float>(_r_samples - 1);
float ri_2 = ri * ri;
float epsilon =
float epsilon =
(layer == 0) ?
0.01f :
(layer == (static_cast<int>(_r_samples) - 1)) ? -0.001f : 0.0f;
@@ -1418,7 +1417,7 @@ void AtmosphereDeferredcaster::saveTextureToPPMFile(GLenum color_buffer_attachme
unsigned char * pixels = new unsigned char[width*height * 3];
for (int t = 0; t < width*height * 3; ++t)
pixels[t] = 255;
if (color_buffer_attachment != GL_DEPTH_ATTACHMENT) {
glReadBuffer(color_buffer_attachment);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels);
@@ -1475,7 +1474,6 @@ bool AtmosphereDeferredcaster::isAtmosphereInFrustum(const double* MVMatrix,
glm::dvec3 nearNormal = col3 + col4;
glm::dvec3 farNormal = col4 - col3;
// Plane Distances
double leftDistance = MVMatrix[15] + MVMatrix[12];
double rightDistance = MVMatrix[15] - MVMatrix[12];
@@ -1483,7 +1481,7 @@ bool AtmosphereDeferredcaster::isAtmosphereInFrustum(const double* MVMatrix,
double topDistance = MVMatrix[15] - MVMatrix[13];
double nearDistance = MVMatrix[15] + MVMatrix[14];
double farDistance = MVMatrix[15] - MVMatrix[14];
// Normalize Planes
double invMag = 1.0 / glm::length(leftNormal);
leftNormal *= invMag;
@@ -1511,15 +1509,19 @@ bool AtmosphereDeferredcaster::isAtmosphereInFrustum(const double* MVMatrix,
if ((glm::dot(leftNormal, position) + leftDistance) < -radius) {
return false;
} else if ((glm::dot(rightNormal, position) + rightDistance) < -radius) {
}
else if ((glm::dot(rightNormal, position) + rightDistance) < -radius) {
return false;
} else if ((glm::dot(bottomNormal, position) + bottomDistance) < -radius) {
}
else if ((glm::dot(bottomNormal, position) + bottomDistance) < -radius) {
return false;
} else if ((glm::dot(topNormal, position) + topDistance) < -radius) {
}
else if ((glm::dot(topNormal, position) + topDistance) < -radius) {
return false;
} else if ((glm::dot(nearNormal, position) + nearDistance) < -radius) {
}
else if ((glm::dot(nearNormal, position) + nearDistance) < -radius) {
return false;
}
}
// The far plane testing is disabled because the atm has no depth.
/*else if ((glm::dot(farNormal, position) + farDistance) < -radius) {
return false;
@@ -25,16 +25,16 @@
#ifndef __OPENSPACE_MODULE_ATMOSPHERE___ATMOSPHEREDEFERREDCASTER___H__
#define __OPENSPACE_MODULE_ATMOSPHERE___ATMOSPHEREDEFERREDCASTER___H__
#include <ghoul/glm.h>
#include <string>
#include <vector>
#include <openspace/rendering/deferredcaster.h>
#include <ghoul/glm.h>
#include <ghoul/opengl/textureunit.h>
//#include <modules/atmosphere/rendering/renderableatmosphere.h>
#include <string>
#include <vector>
namespace ghoul::opengl {
class Texture;
class Texture;
class ProgramObject;
} // namespace ghoul::opengl
@@ -45,7 +45,7 @@ struct DeferredcastData;
struct ShadowConfiguration;
class AtmosphereDeferredcaster : public Deferredcaster {
public:
public:
AtmosphereDeferredcaster();
virtual ~AtmosphereDeferredcaster() = default;
@@ -55,7 +55,7 @@ public:
ghoul::opengl::ProgramObject& program) override;
void postRaycast(const RenderData& renderData, const DeferredcastData& deferredData,
ghoul::opengl::ProgramObject& program) override;
std::string deferredcastPath() const override;
std::string deferredcastVSPath() const override;
std::string deferredcastFSPath() const override;
@@ -105,13 +105,12 @@ private:
);
void renderQuadForCalc(GLuint vao, GLsizei numberOfVertices);
void saveTextureToPPMFile(GLenum color_buffer_attachment, const std::string& fileName,
int width, int height) const;
int width, int height) const;
bool isAtmosphereInFrustum(const double* MVMatrix, const glm::dvec3& position,
double radius) const;
const double DISTANCE_CULLING = 1e10;
std::unique_ptr<ghoul::opengl::ProgramObject> _transmittanceProgramObject;
std::unique_ptr<ghoul::opengl::ProgramObject> _irradianceProgramObject;
std::unique_ptr<ghoul::opengl::ProgramObject> _irradianceSupTermsProgramObject;
@@ -133,7 +132,7 @@ private:
GLuint _deltaSMieTableTexture;
GLuint _deltaJTableTexture;
GLuint _atmosphereTexture;
ghoul::opengl::TextureUnit _transmittanceTableTextureUnit;
ghoul::opengl::TextureUnit _irradianceTableTextureUnit;
ghoul::opengl::TextureUnit _inScatteringTableTextureUnit;
@@ -151,7 +150,7 @@ private:
float _mieHeightScale;
float _miePhaseConstant;
float _sunRadianceIntensity;
glm::vec3 _rayleighScatteringCoeff;
glm::vec3 _ozoneExtinctionCoeff;
glm::vec3 _mieScatteringCoeff;
@@ -179,7 +178,7 @@ private:
// Atmosphere Debugging
float _calculationTextureScale;
bool _saveCalculationTextures;
bool _saveCalculationTextures;
};
} // openspace
@@ -61,7 +61,7 @@ namespace {
const char* keyShadowGroup = "ShadowGroup";
const char* keyShadowSource = "Source";
const char* keyShadowCaster = "Caster";
const char* keyAtmosphere = "Atmosphere";
const char* keyAtmosphereRadius = "AtmosphereRadius";
const char* keyPlanetRadius = "PlanetRadius";
@@ -84,57 +84,68 @@ namespace {
"Atmosphere Height (KM)",
"The thickness of the atmosphere in Km"
};
static const openspace::properties::Property::PropertyInfo AverageGroundReflectanceInfo = {
"AverageGroundReflectance",
static const openspace::properties::Property::PropertyInfo
AverageGroundReflectanceInfo = {
"AverageGroundReflectance",
"Average Ground Reflectance (%)",
"Average percentage of light reflected by the ground during the pre-calculation phase"
"Average percentage of light reflected by the ground during the pre-calculation "
"phase"
};
static const openspace::properties::Property::PropertyInfo GroundRadianceEmittioninfo = {
static const openspace::properties::Property::PropertyInfo
GroundRadianceEmittioninfo = {
"GroundRadianceEmittion",
"Percentage of initial radiance emitted from ground",
"Multiplier of the ground radiance color during the rendering phase"
};
static const openspace::properties::Property::PropertyInfo RayleighHeightScaleInfo = {
"RayleighHeightScale",
"RayleighHeightScale",
"Rayleigh Scale Height (KM)",
"It is the vertical distance over which the density and pressure fall by a constant factor"
"It is the vertical distance over which the density and pressure fall by a "
"constant factor"
};
static const openspace::properties::Property::PropertyInfo RayleighScatteringCoeffXInfo = {
"RayleighScatteringCoeffX",
static const openspace::properties::Property::PropertyInfo
RayleighScatteringCoeffXInfo =
{
"RayleighScatteringCoeffX",
"Rayleigh Scattering Coeff X (x10e-3)",
"Rayleigh sea-level scattering coefficients in meters"
};
static const openspace::properties::Property::PropertyInfo RayleighScatteringCoeffYInfo = {
static const openspace::properties::Property::PropertyInfo
RayleighScatteringCoeffYInfo =
{
"RayleighScatteringCoeffY",
"Rayleigh Scattering Coeff Y (x10e-3)",
"Rayleigh sea-level scattering coefficients in meters"
};
static const openspace::properties::Property::PropertyInfo RayleighScatteringCoeffZInfo = {
static const openspace::properties::Property::PropertyInfo
RayleighScatteringCoeffZInfo =
{
"RayleighScatteringCoeffZ",
"Rayleigh Scattering Coeff Z (x10e-3)",
"Rayleigh sea-level scattering coefficients in meters"
};
static const openspace::properties::Property::PropertyInfo OzoneLayerInfo = {
"Ozone",
"Ozone",
"Ozone Layer Enabled",
"Enables/Disable Ozone Layer during pre-calculation phase"
};
static const openspace::properties::Property::PropertyInfo OzoneHeightScaleInfo = {
"OzoneLayerHeightScale",
"OzoneLayerHeightScale",
"Ozone Scale Height (KM)",
"It is the vertical distance over which the density and pressure fall by a constant factor"
"It is the vertical distance over which the density and pressure fall by a "
"constant factor"
};
static const openspace::properties::Property::PropertyInfo OzoneLayerCoeffXInfo = {
"OzoneLayerCoeffX",
"OzoneLayerCoeffX",
"Ozone Layer Extinction Coeff X (x10e-5)",
"Ozone scattering coefficients in meters"
};
@@ -152,9 +163,10 @@ namespace {
};
static const openspace::properties::Property::PropertyInfo MieHeightScaleInfo = {
"MieHeightScale",
"MieHeightScale",
"Mie Scale Height (KM)",
"It is the vertical distance over which the density and pressure fall by a constant factor"
"It is the vertical distance over which the density and pressure fall by a "
"constant factor"
};
static const openspace::properties::Property::PropertyInfo MieScatteringCoeffXInfo = {
@@ -168,45 +180,51 @@ namespace {
"Mie Scattering Coeff Y (x10e-3)",
"Mie sea-level scattering coefficients in meters"
};
static const openspace::properties::Property::PropertyInfo MieScatteringCoeffZInfo = {
"MieScatteringCoeffZ",
"Mie Scattering Coeff Z (x10e-3)",
"Mie sea-level scattering coefficients in meters"
};
static const openspace::properties::Property::PropertyInfo MieScatteringExtinctionPropCoeffInfo = {
static const openspace::properties::Property::PropertyInfo
MieScatteringExtinctionPropCoeffInfo =
{
"MieScatteringExtinctionPropCoefficient",
"Mie Scattering/Extinction Proportion Coefficient (%)",
"Mie Scattering/Extinction Proportion Coefficient (%)"
};
static const openspace::properties::Property::PropertyInfo MieAsymmetricFactorGInfo = {
"MieAsymmetricFactorG",
static const openspace::properties::Property::PropertyInfo
MieAsymmetricFactorGInfo =
{
"MieAsymmetricFactorG",
"Mie Asymmetric Factor G",
"Averaging of the scattering angle over a high number of scattering events"
};
static const openspace::properties::Property::PropertyInfo SunIntensityInfo = {
"SunIntensity",
"SunIntensity",
"Sun Intensity",
"Unitless for now"
};
static const openspace::properties::Property::PropertyInfo AtmosphereExposureInfo = {
"HdrExposure",
"HdrExposure",
"Atmosphere Exposure",
"Constant to controls the exposure of the radiance range"
};
static const openspace::properties::Property::PropertyInfo AtmosphereGammaInfo = {
"Gamma",
"Gamma",
"Gamma Correction",
"Gamma Correction"
};
static const openspace::properties::Property::PropertyInfo EnableSunOnCameraPositionInfo = {
"SunFollowingCamera",
static const openspace::properties::Property::PropertyInfo
EnableSunOnCameraPositionInfo =
{
"SunFollowingCamera",
"Enable Sun On Camera Position",
"When selected the Sun is artificially positioned behind the observer all times"
};
@@ -225,24 +243,7 @@ documentation::Documentation RenderableAtmosphere::Documentation() {
return {
"RenderableAtmosphere",
"atmosphere_renderable_atmosphere",
{ /*
{
keyAtmosphereRadius,
new ReferencingVerifier("atmosphere"),
"Specifies the atmosphere's height in this RenderableAtmosphere.",
Optional::No
},
{
KeyShading,
new BoolVerifier,
"Specifies whether the atmosphere should be rendered shaded by the Sun. If "
"this value is 'false', any existing night texture will not be used. "
"This value defaults to 'true'.",
Optional::Yes
}
*/
}
{}
};
}
@@ -264,7 +265,12 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
, _mieScatteringCoeffXP(MieScatteringCoeffXInfo, 4.0f, 0.01f, 1000.0f)
, _mieScatteringCoeffYP(MieScatteringCoeffYInfo, 4.0f, 0.01f, 1000.0f)
, _mieScatteringCoeffZP(MieScatteringCoeffZInfo, 4.0f, 0.01f, 1000.0f)
, _mieScatteringExtinctionPropCoefficientP(MieScatteringExtinctionPropCoeffInfo, 0.9f, 0.01f, 1.0f)
, _mieScatteringExtinctionPropCoefficientP(
MieScatteringExtinctionPropCoeffInfo,
0.9f,
0.01f,
1.0f
)
, _mieAsymmetricFactorGP(MieAsymmetricFactorGInfo, 0.85f, -1.0f, 1.0f)
, _sunIntensityP(SunIntensityInfo, 50.0f, 0.1f, 1000.0f)
, _sunFollowingCameraEnabledP(EnableSunOnCameraPositionInfo, false)
@@ -280,7 +286,7 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
, _ozoneHeightScale(0.f)
, _mieHeightScale(0.f)
, _miePhaseConstant(0.f)
, _sunRadianceIntensity(50.f)
, _sunRadianceIntensity(50.f)
, _mieExtinctionCoeff(glm::vec3(0.f))
, _rayleighScatteringCoeff(glm::vec3(0.f))
, _ozoneExtinctionCoeff(glm::vec3(0.f))
@@ -302,7 +308,6 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
);
const std::string name = dictionary.value<std::string>(SceneGraphNode::KeyName);
//================================================================
//======== Reads Shadow (Eclipses) Entries in mod file ===========
//================================================================
@@ -311,14 +316,14 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
bool disableShadows = false;
if (success) {
std::vector<std::pair<std::string, double>> sourceArray;
unsigned int sourceCounter = 1;
unsigned int sourceCounter = 1;
while (success) {
std::string sourceName;
success = shadowDictionary.getValue(keyShadowSource +
success = shadowDictionary.getValue(keyShadowSource +
std::to_string(sourceCounter) + ".Name", sourceName);
if (success) {
double sourceRadius;
success = shadowDictionary.getValue(keyShadowSource +
success = shadowDictionary.getValue(keyShadowSource +
std::to_string(sourceCounter) + ".Radius", sourceRadius);
if (success) {
sourceArray.emplace_back(sourceName, sourceRadius);
@@ -394,16 +399,28 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
<< name << " planet.\nDisabling atmosphere effects for this planet.");
}
if (!atmosphereDictionary.getValue(keyAverageGroundReflectance, _planetAverageGroundReflectance)) {
if (!atmosphereDictionary.getValue(
keyAverageGroundReflectance,
_planetAverageGroundReflectance))
{
errorReadingAtmosphereData = true;
LWARNING("No Average Atmosphere Ground Reflectance value expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet.");
LWARNING(
"No Average Atmosphere Ground Reflectance value expecified for "
"Atmosphere Effects of " << name << " planet.\nDisabling atmosphere "
"effects for this planet."
);
}
if (!atmosphereDictionary.getValue(GroundRadianceEmittioninfo.identifier, _planetGroundRadianceEmittion)) {
if (!atmosphereDictionary.getValue(
GroundRadianceEmittioninfo.identifier,
_planetGroundRadianceEmittion))
{
errorReadingAtmosphereData = true;
LWARNING("No Ground Radiance Emitted percentage value expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet.");
LWARNING(
"No Ground Radiance Emitted percentage value expecified for Atmosphere "
"Effects of " << name << " planet.\nDisabling atmosphere effects for "
"this planet."
);
}
ghoul::Dictionary rayleighDictionary;
@@ -412,18 +429,32 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
if (success) {
// Not using right now.
glm::vec3 rayleighWavelengths;
success = rayleighDictionary.getValue("Coefficients.Wavelengths", rayleighWavelengths);
success = rayleighDictionary.getValue(
"Coefficients.Wavelengths",
rayleighWavelengths
);
if (!rayleighDictionary.getValue("Coefficients.Scattering", _rayleighScatteringCoeff)) {
if (!rayleighDictionary.getValue(
"Coefficients.Scattering",
_rayleighScatteringCoeff))
{
errorReadingAtmosphereData = true;
LWARNING("No Rayleigh Scattering parameters expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet.");
LWARNING(
"No Rayleigh Scattering parameters expecified for Atmosphere Effects "
"of " << name << " planet.\nDisabling atmosphere effects for this "
"planet."
);
}
if (!rayleighDictionary.getValue(keyRayleighHeightScale, _rayleighHeightScale)) {
if (!rayleighDictionary.getValue(
keyRayleighHeightScale,
_rayleighHeightScale))
{
errorReadingAtmosphereData = true;
LWARNING("No Rayleigh Height Scale value expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet.");
LWARNING(
"No Rayleigh Height Scale value expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet."
);
}
}
else {
@@ -440,7 +471,10 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
_ozoneLayerEnabled = false;
}
if (!ozoneDictionary.getValue("Coefficients.Extinction", _ozoneExtinctionCoeff)) {
if (!ozoneDictionary.getValue(
"Coefficients.Extinction",
_ozoneExtinctionCoeff))
{
_ozoneLayerEnabled = false;
}
}
@@ -453,32 +487,42 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
if (success) {
if (!mieDictionary.getValue(keyMieHeightScale, _mieHeightScale)) {
errorReadingAtmosphereData = true;
LWARNING("No Mie Height Scale value expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet.");
LWARNING(
"No Mie Height Scale value expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet."
);
}
if (!mieDictionary.getValue("Coefficients.Scattering", _mieScatteringCoeff)) {
errorReadingAtmosphereData = true;
LWARNING("No Mie Scattering parameters expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet.");
LWARNING(
"No Mie Scattering parameters expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet."
);
}
if (!mieDictionary.getValue("Coefficients.Extinction", _mieExtinctionCoeff)) {
errorReadingAtmosphereData = true;
LWARNING("No Mie Extinction parameters expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet.");
LWARNING(
"No Mie Extinction parameters expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet."
);
}
if (!mieDictionary.getValue(keyMiePhaseConstant, _miePhaseConstant)) {
errorReadingAtmosphereData = true;
LWARNING("No Mie Phase Constant value expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet.");
LWARNING(
"No Mie Phase Constant value expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet."
);
}
}
else {
errorReadingAtmosphereData = true;
LWARNING("No Mie parameters expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet.");
LWARNING(
"No Mie parameters expecified for Atmosphere Effects of "
<< name << " planet.\nDisabling atmosphere effects for this planet."
);
}
ghoul::Dictionary ImageDictionary;
@@ -588,7 +632,7 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
_sunIntensityP = _sunRadianceIntensity;
_sunIntensityP.onChange(updateAtmosphere);
addProperty(_sunIntensityP);
_sunFollowingCameraEnabledP = _sunFollowingCameraEnabled;
_sunFollowingCameraEnabledP.onChange(updateAtmosphere);
addProperty(_sunFollowingCameraEnabledP);
@@ -597,7 +641,7 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
_hardShadowsEnabledP.onChange(updateAtmosphere);
if (_shadowEnabled) {
addProperty(_hardShadowsEnabledP);
}
}
}
}
}
@@ -669,10 +713,10 @@ bool RenderableAtmosphere::isReady() const {
glm::dmat4 RenderableAtmosphere::computeModelTransformMatrix(
const openspace::TransformData& transformData)
{
// scale the planet to appropriate size since the planet is a unit sphere
// scale the planet to appropriate size since the planet is a unit sphere
return glm::translate(glm::dmat4(1.0), transformData.translation) * // Translation
glm::dmat4(transformData.rotation) * // Spice rotation
glm::dmat4(glm::scale(glm::dmat4(1.0), glm::dvec3(transformData.scale)));
glm::dmat4(glm::scale(glm::dmat4(1.0), glm::dvec3(transformData.scale)));
}
void RenderableAtmosphere::render(const RenderData& data, RendererTasks& renderTask) {
@@ -684,13 +728,13 @@ void RenderableAtmosphere::render(const RenderData& data, RendererTasks& renderT
void RenderableAtmosphere::update(const UpdateData& data) {
_stateMatrix = data.modelTransform.rotation;
if (_deferredcaster) {
_deferredcaster->setTime(data.time.j2000Seconds());
glm::dmat4 modelTransform = computeModelTransformMatrix(data.modelTransform);
_deferredcaster->setModelTransform(modelTransform);
}
}
_deferredcaster->setModelTransform(modelTransform);
}
}
void RenderableAtmosphere::updateAtmosphereParameters() {
bool executeComputation = true;
@@ -701,7 +745,7 @@ void RenderableAtmosphere::updateAtmosphereParameters() {
_hardShadows != _hardShadowsEnabledP) {
executeComputation = false;
}
_atmosphereRadius = _atmospherePlanetRadius + _atmosphereHeightP;
_planetAverageGroundReflectance = _groundAverageReflectanceP;
_planetGroundRadianceEmittion = _groundRadianceEmittionP;
@@ -719,7 +763,7 @@ void RenderableAtmosphere::updateAtmosphereParameters() {
_mieHeightScale = _mieHeightScaleP;
_mieScatteringCoeff = glm::vec3(
_mieScatteringCoeffXP * 0.001f,
_mieScatteringCoeffYP * 0.001f,
_mieScatteringCoeffYP * 0.001f,
_mieScatteringCoeffZP * 0.001f
);
_mieExtinctionCoeff = _mieScatteringCoeff * (1.0f /
@@ -22,11 +22,13 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_SPACE___RENDERABLEATMOSPHERE___H__
#define __OPENSPACE_MODULE_SPACE___RENDERABLEATMOSPHERE___H__
#ifndef __OPENSPACE_MODULE_ATMOSPHERE___RENDERABLEATMOSPHERE___H__
#define __OPENSPACE_MODULE_ATMOSPHERE___RENDERABLEATMOSPHERE___H__
#include <openspace/rendering/renderable.h>
#include <modules/atmosphere/rendering/atmospheredeferredcaster.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/scalar/intproperty.h>
@@ -35,8 +37,6 @@
#include <ghoul/opengl/textureunit.h>
#include <modules/atmosphere/rendering/atmospheredeferredcaster.h>
#include <memory>
#include <string>
#include <vector>
@@ -59,25 +59,20 @@ struct ShadowConfiguration {
};
struct ShadowRenderingStruct {
double xu,
xp;
double rs,
rc;
double xu;
double xp;
double rs;
double rc;
glm::dvec3 sourceCasterVec;
glm::dvec3 casterPositionVec;
bool isShadowing;
};
namespace planetgeometry {
class PlanetGeometry;
}
namespace documentation { struct Documentation; }
namespace planetgeometry { class PlanetGeometry; }
class RenderableAtmosphere : public Renderable {
public:
public:
RenderableAtmosphere(const ghoul::Dictionary& dictionary);
void deinitialize() override;
@@ -90,10 +85,10 @@ public:
static documentation::Documentation Documentation();
private:
private:
glm::dmat4 computeModelTransformMatrix(const openspace::TransformData& transformData);
void updateAtmosphereParameters();
properties::FloatProperty _atmosphereHeightP;
properties::FloatProperty _groundAverageReflectanceP;
properties::FloatProperty _groundRadianceEmittionP;
@@ -118,7 +113,7 @@ private:
bool _atmosphereEnabled;
bool _ozoneLayerEnabled;
bool _sunFollowingCameraEnabled;
bool _sunFollowingCameraEnabled;
float _atmosphereRadius;
float _atmospherePlanetRadius;
float _planetAverageGroundReflectance;
@@ -128,7 +123,7 @@ private:
float _mieHeightScale;
float _miePhaseConstant;
float _sunRadianceIntensity;
glm::vec3 _mieExtinctionCoeff;
glm::vec3 _rayleighScatteringCoeff;
glm::vec3 _ozoneExtinctionCoeff;
@@ -150,4 +145,4 @@ private:
} // namespace openspace
#endif // __OPENSPACE_MODULE_SPACE___RENDERABLEATMOSPHERE___H__
#endif // __OPENSPACE_MODULE_ATMOSPHERE___RENDERABLEATMOSPHERE___H__
+1 -1
View File
@@ -58,7 +58,7 @@ private:
Focus,
Camera
};
struct Component {
properties::OptionProperty type;
properties::StringProperty nodeName;
+1 -1
View File
@@ -107,7 +107,7 @@ DashboardItemDate::DashboardItemDate(ghoul::Dictionary dictionary)
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
@@ -59,7 +59,7 @@ private:
Focus,
Camera
};
struct Component {
properties::OptionProperty type;
properties::StringProperty nodeName;
@@ -94,7 +94,7 @@ documentation::Documentation DashboardItemFramerate::Documentation() {
};
}
DashboardItemFramerate::DashboardItemFramerate(ghoul::Dictionary dictionary)
DashboardItemFramerate::DashboardItemFramerate(ghoul::Dictionary dictionary)
: DashboardItem("Framerate")
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
@@ -123,7 +123,7 @@ DashboardItemFramerate::DashboardItemFramerate(ghoul::Dictionary dictionary)
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_frametimeType.addOptions({
{ static_cast<int>(FrametimeType::DtTimeAvg), "Average Deltatime" },
{ static_cast<int>(FrametimeType::FPS), "Frames per second" },
@@ -22,8 +22,8 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___DASHBOARDFRAMERATE___H__
#define __OPENSPACE_CORE___DASHBOARDFRAMERATE___H__
#ifndef __OPENSPACE_MODULE_BASE___DASHBOARDITEMFRAMERATE___H__
#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMFRAMERATE___H__
#include <openspace/rendering/dashboarditem.h>
@@ -66,4 +66,4 @@ private:
} // openspace
#endif // __OPENSPACE_CORE___DASHBOARDFRAMERATE___H__
#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMFRAMERATE___H__
@@ -127,7 +127,7 @@ DashboardItemMission::DashboardItemMission(ghoul::Dictionary dictionary)
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
@@ -83,7 +83,8 @@ documentation::Documentation DashboardItemParallelConnection::Documentation() {
};
}
DashboardItemParallelConnection::DashboardItemParallelConnection(ghoul::Dictionary dictionary)
DashboardItemParallelConnection::DashboardItemParallelConnection(
ghoul::Dictionary dictionary)
: DashboardItem("Parallel Connection")
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
@@ -111,7 +112,7 @@ DashboardItemParallelConnection::DashboardItemParallelConnection(ghoul::Dictiona
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
@@ -80,7 +80,8 @@ documentation::Documentation DashboardItemSimulationIncrement::Documentation() {
};
}
DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(ghoul::Dictionary dictionary)
DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(
ghoul::Dictionary dictionary)
: DashboardItem("Simulation Increment")
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
@@ -108,7 +109,7 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(ghoul::Dictio
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
+3 -1
View File
@@ -220,7 +220,9 @@ void RenderableModel::update(const UpdateData&) {
_programObject->rebuildFromFile();
}
_sunPos = OsEng.renderEngine().scene()->sceneGraphNode("SolarSystemBarycenter")->worldPosition();
_sunPos = OsEng.renderEngine().scene()->sceneGraphNode(
"SolarSystemBarycenter"
)->worldPosition();
}
void RenderableModel::loadTexture() {
+1 -1
View File
@@ -245,7 +245,7 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) {
_shader->setUniform("modelViewTransform",
glm::mat4(data.camera.combinedViewMatrix() * glm::dmat4(modelViewTransform)));
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
+5 -5
View File
@@ -238,13 +238,13 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
if (dictionary.hasKey(FadeOutThreshouldInfo.identifier)) {
_fadeOutThreshold = static_cast<float>(
dictionary.value<double>(FadeOutThreshouldInfo.identifier)
);
);
}
if (dictionary.hasKey(FadeInThreshouldInfo.identifier)) {
_fadeInThreshold = static_cast<float>(
dictionary.value<double>(FadeInThreshouldInfo.identifier)
);
);
}
if (dictionary.hasKey(FadeOutThreshouldInfo.identifier) ||
@@ -305,7 +305,7 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) {
float distCamera = glm::length(data.camera.positionVec3());
float funcValue = static_cast<float>(
(1.0 / double(_fadeInThreshold/1E24))*(distCamera / 1E24)
);
);
adjustedTransparency *= funcValue > 1.0 ? 1.0 : funcValue;
}
@@ -318,10 +318,10 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) {
double term = std::exp(
(-distCamera + _size * _fadeOutThreshold) / (_size * _fadeOutThreshold)
);
adjustedTransparency *= static_cast<float>(term / (term + 1.0));
}
// Performance wise
if (adjustedTransparency < 0.01) {
return;
+1 -1
View File
@@ -250,7 +250,7 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) {
glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale));
_programObject->setUniform("projectionTransform", data.camera.projectionMatrix());
_programObject->setUniform("color", _lineColor);
_programObject->setUniform("useLineFade", _useLineFade);
if (_useLineFade) {
@@ -90,7 +90,10 @@ int addDashboardItemToScreenSpace(lua_State* L) {
ScreenSpaceDashboard* dash = dynamic_cast<ScreenSpaceDashboard*>(ssr.get());
if (!dash) {
return luaL_error(L, "Provided name is a ScreenSpace item but not a dashboard");
return luaL_error(
L,
"Provided name is a ScreenSpace item but not a dashboard"
);
}
dash->dashboard().addDashboardItem(DashboardItem::createFromDictionary(d));
@@ -40,7 +40,7 @@
#include <ghoul/font/fontrenderer.h>
#include <glm/gtx/string_cast.hpp>
#include <glm/glm.hpp>
#include <ghoul/glm.h>
#include <array>
#include <fstream>
@@ -67,9 +67,9 @@ namespace {
static const openspace::properties::Property::PropertyInfo SpriteTextureInfo = {
"Texture",
"Point Sprite Texture",
"The path to the texture that should be used as the point sprite."
"The path to the texture that should be used as the point sprite."
};
static const openspace::properties::Property::PropertyInfo TransparencyInfo = {
"Transparency",
"Transparency",
@@ -221,10 +221,10 @@ documentation::Documentation RenderableBillboardsCloud::Documentation() {
KeyFile,
new StringVerifier,
Optional::Yes,
"The path to the SPECK file that contains information about the astronomical "
"object being rendered."
"The path to the SPECK file that contains information about the "
"astronomical object being rendered."
},
{
{
keyColor,
new Vector3Verifier<float>,
Optional::No,
@@ -358,7 +358,12 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
, _pTexture(0)
, _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f)
, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 600.f)
, _pointColor(ColorInfo, glm::vec3(1.f, 0.4f, 0.2f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(1.0f, 1.0f, 1.0f))
, _pointColor(
ColorInfo,
glm::vec3(1.f, 0.4f, 0.2f),
glm::vec3(0.f, 0.f, 0.f),
glm::vec3(1.0f, 1.0f, 1.0f)
)
, _spriteTexturePath(SpriteTextureInfo)
, _textColor(
TextColorInfo,
@@ -372,7 +377,12 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
, _drawElements(DrawElementsInfo, true)
, _drawLabels(DrawLabelInfo, false)
, _colorOption(ColorOptionInfo, properties::OptionProperty::DisplayType::Dropdown)
, _fadeInDistance(FadeInDistancesInfo, glm::vec2(0.0f), glm::vec2(0.0), glm::vec2(100.0))
, _fadeInDistance(
FadeInDistancesInfo,
glm::vec2(0.0f),
glm::vec2(0.0),
glm::vec2(100.0)
)
, _disableFadeInDistance(DisableFadeInInfo, true)
, _billboardMaxSize(BillboardMaxSizeInfo, 400.0, 0.0, 1000.0)
, _billboardMinSize(BillboardMinSizeInfo, 0.0, 0.0, 100.0)
@@ -405,11 +415,11 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
if (dictionary.hasKey(KeyFile)) {
_speckFile = absPath(dictionary.value<std::string>(KeyFile));
_hasSpeckFile = true;
_drawElements.onChange([&]() {
_drawElements.onChange([&]() {
_hasSpeckFile = _hasSpeckFile == true? false : true; });
addProperty(_drawElements);
}
// DEBUG:
_renderOption.addOption(0, "Camera View Direction");
_renderOption.addOption(1, "Camera Position Normal");
@@ -423,7 +433,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
}
else if (unit == KilometerUnit) {
_unit = Kilometer;
}
}
else if (unit == ParsecUnit) {
_unit = Parsec;
}
@@ -440,10 +450,12 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
_unit = GigalightYears;
}
else {
LWARNING("No unit given for RenderableBillboardsCloud. Using meters as units.");
LWARNING(
"No unit given for RenderableBillboardsCloud. Using meters as units."
);
_unit = Meter;
}
}
}
if (dictionary.hasKey(SpriteTextureInfo.identifier)) {
_spriteTexturePath = absPath(dictionary.value<std::string>(
@@ -477,11 +489,11 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
_colorOption.addOption(i, colorMapInUseName);
_optionConversionMap.insert({i, colorMapInUseName});
_colorOptionString = colorMapInUseName;
}
}
}
_colorOption.onChange(
[&] {
_dataIsDirty = true;
[&] {
_dataIsDirty = true;
_colorOptionString = _optionConversionMap[_colorOption.value()];
});
addProperty(_colorOption);
@@ -490,36 +502,35 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
ghoul::Dictionary rangeDataDic = dictionary.value<ghoul::Dictionary>(
ColorRangeInfo.identifier
);
for (int i = 0; i < rangeDataDic.size(); ++i) {
for (int i = 0; i < rangeDataDic.size(); ++i) {
_colorRangeData.push_back(
rangeDataDic.value<glm::vec2>(std::to_string(i+1)));
}
}
} else if (dictionary.hasKey(keyColor)) {
_pointColor = dictionary.value<glm::vec3>(keyColor);
addProperty(_pointColor);
}
}
if (dictionary.hasKey(TransparencyInfo.identifier)) {
_alphaValue = static_cast<float>(
dictionary.value<double>(TransparencyInfo.identifier)
);
);
}
addProperty(_alphaValue);
if (dictionary.hasKey(ScaleFactorInfo.identifier)) {
_scaleFactor = static_cast<float>(
dictionary.value<double>(ScaleFactorInfo.identifier)
);
);
}
addProperty(_scaleFactor);
if (dictionary.hasKey(PolygonSidesInfo.identifier)) {
_polygonSides = static_cast<float>(
dictionary.value<double>(PolygonSidesInfo.identifier)
);
);
_hasPolygon = true;
}
@@ -549,12 +560,16 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
addProperty(_textSize);
if (dictionary.hasKey(LabelMinSizeInfo.identifier)) {
_textMinSize = static_cast<int>(dictionary.value<float>(LabelMinSizeInfo.identifier));
_textMinSize = static_cast<int>(
dictionary.value<float>(LabelMinSizeInfo.identifier)
);
}
addProperty(_textMinSize);
if (dictionary.hasKey(LabelMaxSizeInfo.identifier)) {
_textMaxSize = static_cast<int>(dictionary.value<float>(LabelMaxSizeInfo.identifier));
_textMaxSize = static_cast<int>(
dictionary.value<float>(LabelMaxSizeInfo.identifier)
);
}
addProperty(_textMaxSize);
}
@@ -588,7 +603,6 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
);
addProperty(_billboardMinSize);
}
}
bool RenderableBillboardsCloud::isReady() const {
@@ -602,7 +616,7 @@ void RenderableBillboardsCloud::initialize() {
}
if (!_colorOptionString.empty()) {
// Following DU behavior here. The last colormap variable
// Following DU behavior here. The last colormap variable
// entry is the one selected by default.
_colorOption.setValue(_colorRangeData.size() - 1);
}
@@ -610,7 +624,7 @@ void RenderableBillboardsCloud::initialize() {
void RenderableBillboardsCloud::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_program = renderEngine.buildRenderProgram(
"RenderableBillboardsCloud",
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard2_vs.glsl"),
@@ -628,8 +642,12 @@ void RenderableBillboardsCloud::initializeGL() {
ghoul::fontrendering::FontRenderer::createProjectionSubjectText());
if (_font == nullptr) {
size_t _fontSize = 50;
_font = OsEng.fontManager().font("Mono", static_cast<float>(_fontSize),
ghoul::fontrendering::FontManager::Outline::Yes, ghoul::fontrendering::FontManager::LoadGlyphs::No);
_font = OsEng.fontManager().font(
"Mono",
static_cast<float>(_fontSize),
ghoul::fontrendering::FontManager::Outline::Yes,
ghoul::fontrendering::FontManager::LoadGlyphs::No
);
}
}
}
@@ -691,7 +709,10 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data,
_program->setIgnoreUniformLocationError(IgnoreError::Yes);
glm::dmat4 projMatrix = glm::dmat4(data.camera.projectionMatrix());
_program->setUniform("screenSize", glm::vec2(OsEng.renderEngine().renderingResolution()));
_program->setUniform(
"screenSize",
glm::vec2(OsEng.renderEngine().renderingResolution())
);
_program->setUniform("projection", projMatrix);
_program->setUniform("modelViewTransform", modelViewMatrix);
_program->setUniform("modelViewProjectionTransform", projMatrix * modelViewMatrix);
@@ -705,11 +726,11 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data,
_program->setUniform("renderOption", _renderOption.value());
glm::dvec4 centerScreenWorld = glm::inverse(data.camera.combinedViewMatrix()) *
glm::dvec4(0.0, 0.0, 0.0, 1.0);
glm::dvec4 centerScreenWorld = glm::inverse(data.camera.combinedViewMatrix()) *
glm::dvec4(0.0, 0.0, 0.0, 1.0);
_program->setUniform("centerScreenInWorldPosition", centerScreenWorld);
_program->setUniform("minBillboardSize", _billboardMinSize); // in pixels
_program->setUniform("maxBillboardSize", _billboardMaxSize); // in pixels
_program->setUniform("color", _pointColor);
@@ -751,7 +772,8 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data,
}
glBindVertexArray(_vao);
const GLsizei nAstronomicalObjects = static_cast<GLsizei>(_fullData.size() / _nValuesPerAstronomicalObject);
const GLsizei nAstronomicalObjects = static_cast<GLsizei>(_fullData.size() /
_nValuesPerAstronomicalObject);
glDrawArrays(GL_POINTS, 0, nAstronomicalObjects);
glBindVertexArray(0);
@@ -780,7 +802,7 @@ void RenderableBillboardsCloud::renderLabels(const RenderData& data,
RenderEngine& renderEngine = OsEng.renderEngine();
_fontRenderer->setFramebufferSize(renderEngine.renderingResolution());
float scale = 0.0;
switch (_unit) {
case Meter:
@@ -863,7 +885,9 @@ void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) {
/*
// Linear Fading
float funcValue = static_cast<float>((1.0 / double(_fadeInDistance*scale))*(distCamera));
float funcValue = static_cast<float>(
(1.0 / double(_fadeInDistance*scale))*(distCamera)
);
fadeInVariable *= funcValue > 1.0 ? 1.0 : funcValue;
if (funcValue < 0.01) {
@@ -930,7 +954,7 @@ void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) {
glm::inverse(glm::dmat4(projectionMatrix));
glm::dvec3 orthoRight = glm::dvec3(glm::normalize(glm::dvec3(invMVPParts * glm::dvec4(1.0, 0.0, 0.0, 0.0))));
glm::dvec3 orthoUp = glm::dvec3(glm::normalize(glm::dvec3(invMVPParts * glm::dvec4(0.0, 1.0, 0.0, 0.0))));
if (_hasSpeckFile) {
renderBillboards(
data,
@@ -941,13 +965,19 @@ void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) {
fadeInVariable
);
}
if (_drawLabels && _hasLabel) {
renderLabels(data, modelViewProjectionMatrix, orthoRight, orthoUp, fadeInVariable);
}
renderLabels(
data,
modelViewProjectionMatrix,
orthoRight,
orthoUp,
fadeInVariable
);
}
}
void RenderableBillboardsCloud::update(const UpdateData&) {
void RenderableBillboardsCloud::update(const UpdateData&) {
if (_dataIsDirty && _hasSpeckFile) {
LDEBUG("Regenerating data");
@@ -973,13 +1003,13 @@ void RenderableBillboardsCloud::update(const UpdateData&) {
GL_STATIC_DRAW
);
GLint positionAttrib = _program->attributeLocation("in_position");
if (_hasColorMapFile) {
/*const size_t nAstronomicalObjects = _fullData.size() / _nValuesPerAstronomicalObject;
/*const size_t nAstronomicalObjects = _fullData.size() /
_nValuesPerAstronomicalObject;
const size_t nValues = _slicedData.size() / nAstronomicalObjects;
GLsizei stride = static_cast<GLsizei>(sizeof(float) * nValues);*/
glEnableVertexAttribArray(positionAttrib);
glVertexAttribPointer(
positionAttrib,
@@ -1001,7 +1031,7 @@ void RenderableBillboardsCloud::update(const UpdateData&) {
reinterpret_cast<void*>(sizeof(float)*4)
);
}
else {
else {
glEnableVertexAttribArray(positionAttrib);
glVertexAttribPointer(
positionAttrib,
@@ -1022,12 +1052,16 @@ void RenderableBillboardsCloud::update(const UpdateData&) {
LDEBUG("Reloading Sprite Texture");
_spriteTexture = nullptr;
if (_spriteTexturePath.value() != "") {
_spriteTexture = ghoul::io::TextureReader::ref().loadTexture(absPath(_spriteTexturePath));
_spriteTexture = ghoul::io::TextureReader::ref().loadTexture(
absPath(_spriteTexturePath)
);
if (_spriteTexture) {
LDEBUG("Loaded texture from '" << absPath(_spriteTexturePath) << "'");
_spriteTexture->uploadTexture();
}
_spriteTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
_spriteTexture->setFilter(
ghoul::opengl::Texture::FilterMode::AnisotropicMipMap
);
_spriteTextureFile = std::make_unique<ghoul::filesystem::File>(
_spriteTexturePath);
@@ -1035,7 +1069,7 @@ void RenderableBillboardsCloud::update(const UpdateData&) {
[&](const ghoul::filesystem::File&) { _spriteTextureIsDirty = true; }
);
}
_spriteTextureIsDirty = false;
_spriteTextureIsDirty = false;
}
if (_hasLabel && _labelDataIsDirty) {
@@ -1045,7 +1079,7 @@ void RenderableBillboardsCloud::update(const UpdateData&) {
}
bool RenderableBillboardsCloud::loadData() {
bool success = false;
bool success = false;
if (_hasSpeckFile) {
std::string _file = _speckFile;
// I disabled the cache as it didn't work on Mac --- abock
@@ -1057,16 +1091,19 @@ bool RenderableBillboardsCloud::loadData() {
// bool hasCachedFile = FileSys.fileExists(cachedFile);
// if (hasCachedFile) {
// LINFO("Cached file '" << cachedFile << "' used for Speck file '" << _file << "'");
// LINFO(
// "Cached file '" << cachedFile << "' used for Speck file '" <<
// _file << "'"
// );
// success = loadCachedFile(cachedFile);
// if (!success) {
// FileSys.cacheManager()->removeCacheFile(_file);
// // Intentional fall-through to the 'else' computation to generate the cache
// // Intentional fall-through to the 'else' to generate the cache
// // file for the next run
// }
// }
// else
// else
// {
// LINFO("Cache for Speck file '" << _file << "' not found");
LINFO("Loading Speck file '" << _file << "'");
@@ -1098,16 +1135,19 @@ bool RenderableBillboardsCloud::loadData() {
success = true;
//bool hasCachedFile = FileSys.fileExists(cachedFile);
//if (hasCachedFile) {
// LINFO("Cached file '" << cachedFile << "' used for Label file '" << labelFile << "'");
//
// LINFO(
// "Cached file '" << cachedFile << "' used for Label file '" <<
// labelFile << "'"
// );
//
// success &= loadCachedFile(cachedFile);
// if (!success) {
// FileSys.cacheManager()->removeCacheFile(labelFile);
// // Intentional fall-through to the 'else' computation to generate the cache
// // Intentional fall-through to the 'else' to generate the cache
// // file for the next run
// }
//}
//else
//else
// {
// LINFO("Cache for Label file '" << labelFile << "' not found");
LINFO("Loading Label file '" << labelFile << "'");
@@ -1119,7 +1159,7 @@ bool RenderableBillboardsCloud::loadData() {
// }
}
return success;
}
@@ -1142,7 +1182,7 @@ bool RenderableBillboardsCloud::readSpeckFile() {
std::getline(file, line);
// Guard against wrong line endings (copying files from Windows to Mac) causes
// lines to have a final \r
// lines to have a final \r
if (!line.empty() && line.back() == '\r') {
line = line.substr(0, line.length() -1);
}
@@ -1171,16 +1211,17 @@ bool RenderableBillboardsCloud::readSpeckFile() {
// number of values (+3 since X Y Z are not counted in the Speck file index)
std::stringstream str(line);
std::string dummy;
std::string dummy;
str >> dummy; // command
str >> _nValuesPerAstronomicalObject; // variable index
dummy.clear();
str >> dummy; // variable name
_variableDataPositionMap.insert({ dummy, _nValuesPerAstronomicalObject });
_variableDataPositionMap.insert({ dummy, _nValuesPerAstronomicalObject });
_nValuesPerAstronomicalObject += 1; // We want the number, but the index is 0 based
}
// We want the number, but the index is 0 based
_nValuesPerAstronomicalObject += 1;
}
}
_nValuesPerAstronomicalObject += 3; // X Y Z are not counted in the Speck file indices
@@ -1191,7 +1232,7 @@ bool RenderableBillboardsCloud::readSpeckFile() {
std::getline(file, line);
// Guard against wrong line endings (copying files from Windows to Mac) causes
// lines to have a final \r
// lines to have a final \r
if (!line.empty() && line.back() == '\r') {
line = line.substr(0, line.length() -1);
}
@@ -1203,7 +1244,7 @@ bool RenderableBillboardsCloud::readSpeckFile() {
std::stringstream str(line);
for (int i = 0; i < _nValuesPerAstronomicalObject; ++i) {
str >> values[i];
str >> values[i];
}
_fullData.insert(_fullData.end(), values.begin(), values.end());
@@ -1219,7 +1260,7 @@ bool RenderableBillboardsCloud::readColorMapFile() {
LERROR("Failed to open Color Map file '" << _file << "'");
return false;
}
std::size_t numberOfColors = 0;
// The beginning of the speck file has a header that either contains comments
@@ -1243,13 +1284,13 @@ bool RenderableBillboardsCloud::readColorMapFile() {
}
else if (file.eof()) {
return false;
}
}
}
for (auto i = 0; i < numberOfColors; ++i) {
std::getline(file, line);
std::stringstream str(line);
glm::vec4 color;
for (auto j = 0; j < 4; ++j) {
str >> color[j];
@@ -1257,7 +1298,7 @@ bool RenderableBillboardsCloud::readColorMapFile() {
_colorMapData.push_back(color);
}
return true;
}
@@ -1268,7 +1309,7 @@ bool RenderableBillboardsCloud::readLabelFile() {
LERROR("Failed to open Label file '" << _file << "'");
return false;
}
// The beginning of the speck file has a header that either contains comments
// (signaled by a preceding '#') or information about the structure of the file
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
@@ -1278,7 +1319,7 @@ bool RenderableBillboardsCloud::readLabelFile() {
std::getline(file, line);
// Guard against wrong line endings (copying files from Windows to Mac) causes
// lines to have a final \r
// lines to have a final \r
if (!line.empty() && line.back() == '\r') {
line = line.substr(0, line.length() -1);
}
@@ -1312,7 +1353,7 @@ bool RenderableBillboardsCloud::readLabelFile() {
std::getline(file, line);
// Guard against wrong line endings (copying files from Windows to Mac) causes
// lines to have a final \r
// lines to have a final \r
if (!line.empty() && line.back() == '\r') {
line = line.substr(0, line.length() -1);
}
@@ -1330,7 +1371,7 @@ bool RenderableBillboardsCloud::readLabelFile() {
std::string dummy;
str >> dummy; // text keyword
std::string label;
str >> label;
dummy.clear();
@@ -1367,7 +1408,10 @@ bool RenderableBillboardsCloud::loadCachedFile(const std::string& file) {
int32_t nValues = 0;
fileStream.read(reinterpret_cast<char*>(&nValues), sizeof(int32_t));
fileStream.read(reinterpret_cast<char*>(&_nValuesPerAstronomicalObject), sizeof(int32_t));
fileStream.read(
reinterpret_cast<char*>(&_nValuesPerAstronomicalObject),
sizeof(int32_t)
);
_fullData.resize(nValues);
fileStream.read(reinterpret_cast<char*>(&_fullData[0]),
@@ -1380,7 +1424,7 @@ bool RenderableBillboardsCloud::loadCachedFile(const std::string& file) {
for (int i = 0; i < nItems; ++i) {
int32_t keySize = 0;
fileStream.read(reinterpret_cast<char*>(&keySize), sizeof(int32_t));
std::string key;
std::string key;
for (int c = 0; c < keySize; ++c) {
char t[2];
t[1] = '\0';
@@ -1416,9 +1460,14 @@ bool RenderableBillboardsCloud::saveCachedFile(const std::string& file) const {
}
fileStream.write(reinterpret_cast<const char*>(&nValues), sizeof(int32_t));
int32_t nValuesPerAstronomicalObject = static_cast<int32_t>(_nValuesPerAstronomicalObject);
fileStream.write(reinterpret_cast<const char*>(&nValuesPerAstronomicalObject), sizeof(int32_t));
int32_t nValuesPerAstronomicalObject = static_cast<int32_t>(
_nValuesPerAstronomicalObject
);
fileStream.write(
reinterpret_cast<const char*>(&nValuesPerAstronomicalObject),
sizeof(int32_t)
);
size_t nBytes = nValues * sizeof(_fullData[0]);
fileStream.write(reinterpret_cast<const char*>(&_fullData[0]), nBytes);
@@ -1428,10 +1477,16 @@ bool RenderableBillboardsCloud::saveCachedFile(const std::string& file) const {
for (auto pair : _variableDataPositionMap) {
int32_t keySize = static_cast<int32_t>(pair.first.size());
fileStream.write(reinterpret_cast<const char*>(&keySize), sizeof(int32_t));
fileStream.write(
reinterpret_cast<const char*>(&keySize),
sizeof(int32_t)
);
for (int c = 0; c < pair.first.size(); ++c) {
int32_t keyChar = static_cast<int32_t>(pair.first[c]);
fileStream.write(reinterpret_cast<const char*>(&keyChar), sizeof(int32_t));
fileStream.write(
reinterpret_cast<const char*>(&keyChar),
sizeof(int32_t)
);
}
int32_t value = static_cast<int32_t>(pair.second);
fileStream.write(reinterpret_cast<const char*>(&value), sizeof(int32_t));
@@ -1446,7 +1501,7 @@ bool RenderableBillboardsCloud::saveCachedFile(const std::string& file) const {
return false;
}
}
void RenderableBillboardsCloud::createDataSlice() {
_slicedData.clear();
if (_hasColorMapFile) {
@@ -1462,13 +1517,14 @@ void RenderableBillboardsCloud::createDataSlice() {
if (_hasColorMapFile) {
colorMapInUse = _variableDataPositionMap[_colorOptionString];
glm::vec2 currentColorRange = _colorRangeData[_colorOption.value()];
float colorMapBinSize = (currentColorRange.y - currentColorRange.x) / static_cast<float>(_colorMapData.size());
float colorMapBinSize = (currentColorRange.y - currentColorRange.x) /
static_cast<float>(_colorMapData.size());
float bin = colorMapBinSize;
for (int i = 0; i < _colorMapData.size(); ++i) {
colorBins.push_back(bin);
bin += colorMapBinSize;
}
}
}
float biggestCoord = -1.0f;
for (size_t i = 0; i < _fullData.size(); i += _nValuesPerAstronomicalObject) {
@@ -1479,7 +1535,7 @@ void RenderableBillboardsCloud::createDataSlice() {
1.0
);
glm::vec4 position(glm::vec3(transformedPos), static_cast<float>(_unit));
if (_hasColorMapFile) {
for (auto j = 0; j < 4; ++j) {
_slicedData.push_back(position[j]);
@@ -1488,7 +1544,7 @@ void RenderableBillboardsCloud::createDataSlice() {
// Finds from which bin to get the color.
// Note: the first color in the colormap file
// is the outliers color.
glm::vec4 itemColor;
glm::vec4 itemColor;
float variableColor = _fullData[i + 3 + colorMapInUse];
int c = colorBins.size()-1;
while (variableColor < colorBins[c]) {
@@ -1496,9 +1552,9 @@ void RenderableBillboardsCloud::createDataSlice() {
if (c == 0)
break;
}
int colorIndex = c == colorBins.size() - 1 ? 0 : c + 1;
for (auto j = 0; j < 4; ++j) {
_slicedData.push_back(_colorMapData[colorIndex][j]);
}
@@ -1507,7 +1563,7 @@ void RenderableBillboardsCloud::createDataSlice() {
for (auto j = 0; j < 4; ++j) {
_slicedData.push_back(position[j]);
}
}
}
}
_fadeInDistance.setMaxValue(glm::vec2(10.0f * biggestCoord));
}
@@ -1526,19 +1582,29 @@ void RenderableBillboardsCloud::createPolygonTexture() {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 256,
256, 0, GL_RGBA, GL_BYTE, nullptr);
renderToTexture(std::bind(&openspace::RenderableBillboardsCloud::loadPolygonGeometryForRendering,
this),
std::bind(&openspace::RenderableBillboardsCloud::renderPolygonGeometry,
this, std::placeholders::_1),
_pTexture, 256, 256);
renderToTexture(
std::bind(
&openspace::RenderableBillboardsCloud::loadPolygonGeometryForRendering,
this
),
std::bind(
&openspace::RenderableBillboardsCloud::renderPolygonGeometry,
this,
std::placeholders::_1
),
_pTexture,
256,
256
);
}
void RenderableBillboardsCloud::renderToTexture(
std::function<void(void)> geometryLoadingFunction,
std::function<void(GLuint)> renderFunction,
GLuint textureToRenderTo, GLuint textureWidth, GLuint textureHeight) {
std::function<void(void)> geometryLoadingFunction,
std::function<void(GLuint)> renderFunction,
GLuint textureToRenderTo, GLuint textureWidth, GLuint textureHeight)
{
LDEBUG("Rendering to Texture");
// Saves initial Application's OpenGL State
GLint defaultFBO;
GLint viewport[4];
@@ -1552,12 +1618,12 @@ void RenderableBillboardsCloud::renderToTexture(
glDrawBuffers(1, drawBuffers);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureToRenderTo, 0);
glViewport(0, 0, textureWidth, textureHeight);
geometryLoadingFunction();
renderFunction(_polygonVao);
// Restores Applications' OpenGL State
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
@@ -1569,7 +1635,7 @@ void RenderableBillboardsCloud::renderToTexture(
if (_polygonVao) {
glDeleteVertexArrays(1, &_polygonVao);
}
glDeleteFramebuffers(1, &textureFBO);
glDeleteFramebuffers(1, &textureFBO);
}
void RenderableBillboardsCloud::loadPolygonGeometryForRendering() {
@@ -1584,13 +1650,20 @@ void RenderableBillboardsCloud::loadPolygonGeometryForRendering() {
};
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 4, reinterpret_cast<GLvoid*>(0));
glVertexAttribPointer(
0,
4,
GL_FLOAT,
GL_FALSE,
sizeof(GLfloat) * 4,
nullptr
);
glEnableVertexAttribArray(0);
glBindVertexArray(0);
}
void RenderableBillboardsCloud::renderPolygonGeometry(GLuint vao) {
std::unique_ptr<ghoul::opengl::ProgramObject> program =
std::unique_ptr<ghoul::opengl::ProgramObject> program =
ghoul::opengl::ProgramObject::Build("RenderableBillboardsCloud_Polygon",
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_vs.glsl"),
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_fs.glsl"),
@@ -41,9 +41,7 @@
#include <functional>
#include <unordered_map>
namespace ghoul::filesystem {
class File;
}
namespace ghoul::filesystem { class File; }
namespace ghoul::opengl {
class ProgramObject;
@@ -93,7 +91,7 @@ private:
void renderBillboards(const RenderData& data, const glm::dmat4& modelViewMatrix,
const glm::dmat4& worldToModelTransform, const glm::dvec3& orthoRight,
const glm::dvec3& orthoUp, float fadeInVariable);
void renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
void renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVariable);
bool loadData();
@@ -141,7 +139,7 @@ private:
std::unique_ptr<ghoul::opengl::Texture> _spriteTexture;
std::unique_ptr<ghoul::filesystem::File> _spriteTextureFile;
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
std::shared_ptr<ghoul::fontrendering::Font> _font;
std::string _speckFile;
@@ -158,7 +156,7 @@ private:
std::unordered_map<std::string, int> _variableDataPositionMap;
std::unordered_map<int, std::string> _optionConversionMap;
std::vector<glm::vec2> _colorRangeData;
int _nValuesPerAstronomicalObject;
glm::dmat4 _transformationMatrix;
@@ -80,7 +80,7 @@ namespace {
"Color",
"Color",
"This value is used to define the color of the astronomical object."
};
};
static const openspace::properties::Property::PropertyInfo TextColorInfo = {
"TextColor",
@@ -167,7 +167,7 @@ documentation::Documentation RenderableDUMeshes::Documentation() {
"The path to the SPECK file that contains information about the "
"astronomical object being rendered."
},
{
{
keyColor,
new Vector3Verifier<float>,
Optional::No,
@@ -244,7 +244,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary)
, _dataIsDirty(true)
, _textColorIsDirty(true)
, _hasLabel(false)
, _labelDataIsDirty(true)
, _labelDataIsDirty(true)
, _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f)
, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 64.f)
, _textColor(
@@ -294,7 +294,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary)
}
else if (unit == KilometerUnit) {
_unit = Kilometer;
}
}
else if (unit == ParsecUnit) {
_unit = Parsec;
}
@@ -434,7 +434,7 @@ void RenderableDUMeshes::deinitializeGL() {
for (int i = 0; i < pair.second.numU; ++i) {
glDeleteVertexArrays(1, &pair.second.vaoArray[i]);
glDeleteBuffers(1, &pair.second.vboArray[i]);
}
}
}
RenderEngine& renderEngine = OsEng.renderEngine();
@@ -480,7 +480,7 @@ void RenderableDUMeshes::renderMeshes(const RenderData&,
_program->setUniform("modelViewTransform", modelViewMatrix);
_program->setUniform("projectionTransform", projectionMatrix);
_program->setUniform("alphaValue", _alphaValue);
_program->setUniform("scaleFactor", _scaleFactor);
_program->setUniform("scaleFactor", _scaleFactor);
for (auto pair : _renderingMeshesMap) {
_program->setUniform("color", _meshColorMap[pair.second.colorIndex]);
@@ -622,17 +622,20 @@ bool RenderableDUMeshes::loadData() {
// );
// bool hasCachedFile = FileSys.fileExists(cachedFile);
// //if (hasCachedFile) {
// // LINFO("Cached file '" << cachedFile << "' used for Speck file '" << _file << "'");
// if (hasCachedFile) {
// LINFO(
// "Cached file '" << cachedFile <<
// "' used for Speck file '" << _file << "'"
// );
// // success = loadCachedFile(cachedFile);
// // if (!success) {
// // FileSys.cacheManager()->removeCacheFile(_file);
// // // Intentional fall-through to the 'else' computation to generate the cache
// // // file for the next run
// // }
// //}
// //else
// success = loadCachedFile(cachedFile);
// if (!success) {
// FileSys.cacheManager()->removeCacheFile(_file);
// // Intentional fall-through to the 'else' to generate the cache
// // file for the next run
// }
// }
// else
// {
// LINFO("Cache for Speck file '" << _file << "' not found");
LINFO("Loading Speck file '" << _file << "'");
@@ -656,12 +659,15 @@ bool RenderableDUMeshes::loadData() {
// );
// bool hasCachedFile = FileSys.fileExists(cachedFile);
// if (hasCachedFile) {
// LINFO("Cached file '" << cachedFile << "' used for Label file '" << labelFile << "'");
// LINFO(
// "Cached file '" << cachedFile << "' used for Label file '" <<
// labelFile << "'"
// );
// success &= loadCachedFile(cachedFile);
// if (!success) {
// FileSys.cacheManager()->removeCacheFile(labelFile);
// // Intentional fall-through to the 'else' computation to generate the cache
// // Intentional fall-through to the 'else' to generate the cache
// // file for the next run
// }
// }
@@ -703,7 +709,7 @@ bool RenderableDUMeshes::readSpeckFile() {
}
// Guard against wrong line endings (copying files from Windows to Mac) causes
// lines to have a final \r
// lines to have a final \r
if (!line.empty() && line.back() == '\r') {
line = line.substr(0, line.length() -1);
}
@@ -721,8 +727,8 @@ bool RenderableDUMeshes::readSpeckFile() {
if (line.substr(0, 4) == "mesh") {
// mesh lines are structured as follows:
// mesh -t texnum -c colorindex -s style {
// where textnum is the index of the texture;
// mesh -t texnum -c colorindex -s style {
// where textnum is the index of the texture;
// colorindex is the index of the color for the mesh
// and style is solid, wire or point (for now we support only wire)
std::stringstream str(line);
@@ -737,7 +743,7 @@ bool RenderableDUMeshes::readSpeckFile() {
do {
if (dummy == "-t") {
dummy.clear();
str >> mesh.textureIndex; // texture index
str >> mesh.textureIndex; // texture index
}
else if (dummy == "-c") {
dummy.clear();
@@ -821,7 +827,7 @@ bool RenderableDUMeshes::readLabelFile() {
std::getline(file, line);
// Guard against wrong line endings (copying files from Windows to Mac) causes
// lines to have a final \r
// lines to have a final \r
if (!line.empty() && line.back() == '\r') {
line = line.substr(0, line.length() -1);
}
@@ -856,7 +862,7 @@ bool RenderableDUMeshes::readLabelFile() {
std::getline(file, line);
// Guard against wrong line endings (copying files from Windows to Mac) causes
// lines to have a final \r
// lines to have a final \r
if (!line.empty() && line.back() == '\r') {
line = line.substr(0, line.length() -1);
}
@@ -967,7 +973,7 @@ void RenderableDUMeshes::createMeshes() {
std::unordered_map<int, RenderingMesh>::iterator itEnd =
_renderingMeshesMap.end();
for (; it != itEnd; ++it) {
for (; it != itEnd; ++it) {
float scale = 0.0;
switch (_unit) {
case Meter:
@@ -1051,8 +1057,8 @@ void RenderableDUMeshes::createMeshes() {
sizeof(GLfloat) * 3 * i * it->second.numV
)
);
}
}
}
}
// Grid: we need columns
if (it->second.numU > 1) {
@@ -1066,7 +1072,7 @@ void RenderableDUMeshes::createMeshes() {
glBindVertexArray(cvao);
glBindBuffer(GL_ARRAY_BUFFER, cvbo);
glBufferData(
GL_ARRAY_BUFFER,
GL_ARRAY_BUFFER,
it->second.vertices.size() * sizeof(GLfloat),
&it->second.vertices[0],
GL_STATIC_DRAW
@@ -1107,9 +1113,9 @@ void RenderableDUMeshes::createMeshes() {
reinterpret_cast<GLvoid*>(sizeof(GLfloat) * 3 * i)
);
}
}
}
}
}
}
glBindVertexArray(0);
@@ -39,8 +39,8 @@
#include <unordered_map>
namespace ghoul::filesystem {
class File;
namespace ghoul::filesystem {
class File;
}
namespace ghoul::opengl {
@@ -49,6 +49,7 @@ namespace ghoul::opengl {
} // namespace ghoul::opengl
namespace openspace {
namespace documentation { struct Documentation; }
class RenderableDUMeshes : public Renderable {
@@ -91,12 +92,12 @@ private:
int colorIndex;
int textureIndex;
// From: Partiview Users Guide
// Brian Abbott
// Brian Abbott
// Hayden Planetarium American Museum of Natural History New York, USA
// "Species the dimensions of the mesh."
// "If you wish to draw a line between points, then numU will be 1 while
// "Specifies the dimensions of the mesh."
// "If you wish to draw a line between points, then numU will be 1 while
// numV will equal the number of points to connect.
// If you want a square, 4000×4000 grid with lines every 200 units,
// If you want a square, 4000×4000 grid with lines every 200 units,
// then numU numU will both equal 21
int numU, numV;
MeshType style;
@@ -122,7 +123,7 @@ private:
bool _textColorIsDirty;
bool _hasLabel;
bool _labelDataIsDirty;
properties::FloatProperty _alphaValue;
properties::FloatProperty _scaleFactor;
//properties::Vec3Property _pointColor;
@@ -212,7 +212,7 @@ documentation::Documentation RenderablePlanesCloud::Documentation() {
new DoubleVerifier,
Optional::Yes,
ScaleFactorInfo.description
},
},
{
TextColorInfo.identifier,
new DoubleVector4Verifier,
@@ -306,7 +306,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
, _textMinSize(0)
, _textMaxSize(200)
, _planeStartingIndexPos(0)
, _textureVariableIndex(0)
, _textureVariableIndex(0)
, _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f)
, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 50.f)
, _textColor(
@@ -315,7 +315,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
glm::vec4(0.f),
glm::vec4(1.f)
)
, _textSize(TextSizeInfo, 8.0, 0.5, 24.0)
, _textSize(TextSizeInfo, 8.0, 0.5, 24.0)
, _drawElements(DrawElementsInfo, true)
, _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown)
, _fadeInDistance(
@@ -337,7 +337,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
, _unit(Parsec)
, _nValuesPerAstronomicalObject(0)
, _sluminosity(1.f)
, _transformationMatrix(glm::dmat4(1.0))
, _transformationMatrix(glm::dmat4(1.0))
{
documentation::testSpecificationAndThrow(
Documentation(),
@@ -348,11 +348,11 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
if (dictionary.hasKey(KeyFile)) {
_speckFile = absPath(dictionary.value<std::string>(KeyFile));
_hasSpeckFile = true;
_drawElements.onChange([&]() {
_drawElements.onChange([&]() {
_hasSpeckFile = _hasSpeckFile == true? false : true; });
addProperty(_drawElements);
}
// DEBUG:
_renderOption.addOption(0, "Camera View Direction");
_renderOption.addOption(1, "Camera Position Normal");
@@ -367,7 +367,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
}
else if (unit == KilometerUnit) {
_unit = Kilometer;
}
}
else if (unit == ParsecUnit) {
_unit = Parsec;
}
@@ -396,24 +396,24 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
if (dictionary.hasKey(TransparencyInfo.identifier)) {
_alphaValue = static_cast<float>(
dictionary.value<double>(TransparencyInfo.identifier)
);
);
}
addProperty(_alphaValue);
if (dictionary.hasKey(ScaleFactorInfo.identifier)) {
_scaleFactor = static_cast<float>(
dictionary.value<double>(ScaleFactorInfo.identifier)
);
);
}
addProperty(_scaleFactor);
_scaleFactor.onChange([&]() {
_dataIsDirty = true;
});
if (dictionary.hasKey(LabelFileInfo.identifier)) {
_labelFile = absPath(dictionary.value<std::string>(
LabelFileInfo.identifier
));
));
_hasLabel = true;
if (dictionary.hasKey(TextColorInfo.identifier)) {
@@ -434,7 +434,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
_textMinSize = static_cast<int>(
dictionary.value<float>(LabelMinSizeInfo.identifier)
);
}
}
if (dictionary.hasKey(LabelMaxSizeInfo.identifier)) {
_textMaxSize = static_cast<int>(
@@ -479,7 +479,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
_texturesPath = absPath(dictionary.value<std::string>(TexturePathInfo.identifier));
if (dictionary.hasKey(LuminosityInfo.identifier)) {
_luminosityVar = dictionary.value<std::string>(LuminosityInfo.identifier);
_luminosityVar = dictionary.value<std::string>(LuminosityInfo.identifier);
}
if (dictionary.hasKey(ScaleLuminosityInfo.identifier)) {
@@ -519,13 +519,13 @@ void RenderablePlanesCloud::initialize() {
void RenderablePlanesCloud::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_program = renderEngine.buildRenderProgram(
"RenderablePlanesCloud",
absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane2_vs.glsl"),
absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane2_fs.glsl")
);
createPlanes();
loadTextures();
@@ -556,12 +556,12 @@ void RenderablePlanesCloud::deleteDataGPU() {
void RenderablePlanesCloud::deinitializeGL() {
deleteDataGPU();
RenderEngine& renderEngine = OsEng.renderEngine();
if (_program) {
renderEngine.removeRenderProgram(_program);
_program = nullptr;
}
}
}
void RenderablePlanesCloud::renderPlanes(const RenderData&,
@@ -600,10 +600,10 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&,
_program->setUniform("alphaValue", _alphaValue);
_program->setUniform("scaleFactor", _scaleFactor);
_program->setUniform("fadeInValue", fadeInVariable);
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
ghoul::opengl::TextureUnit unit;
unit.activate();
_program->setUniform("galaxyTexture", unit);
@@ -614,14 +614,14 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&,
continue;
}
glm::dvec4 vertex0(renderingPlane.vertexData[0], renderingPlane.vertexData[1],
glm::dvec4 vertex0(renderingPlane.vertexData[0], renderingPlane.vertexData[1],
renderingPlane.vertexData[2], renderingPlane.vertexData[3]);
glm::dvec4 vertex1(renderingPlane.vertexData[6], renderingPlane.vertexData[7],
renderingPlane.vertexData[8], renderingPlane.vertexData[9]);
vertex0 = modelViewProjectionMatrix * vertex0;
vertex1 = modelViewProjectionMatrix * vertex1;
// Testing size:
glm::vec4 topRight = vertex1 / vertex1.w;
topRight = ((topRight + glm::vec4(1.0)) / glm::vec4(2.0)) *
@@ -634,7 +634,7 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&,
float lengthX = std::fabs(topRight.x - bottomLeft.x);
float lengthXY = glm::length(glm::vec2(topRight) - glm::vec2(bottomLeft));
float biggestAxis =
lengthY > lengthX ? (lengthY > lengthXY ? lengthY : lengthXY) :
lengthY > lengthX ? (lengthY > lengthXY ? lengthY : lengthXY) :
(lengthX > lengthXY ? lengthX : lengthXY);
if (biggestAxis < _planeMinSize ) {
continue;
@@ -643,16 +643,16 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&,
if (currentTextureIndex != renderingPlane.planeIndex) {
_textureMap[renderingPlane.planeIndex]->bind();
currentTextureIndex = renderingPlane.planeIndex;
}
}
glBindVertexArray(renderingPlane.vao);
glDrawArrays(GL_TRIANGLES, 0, 6);
}
glDrawArrays(GL_TRIANGLES, 0, 6);
}
//if (additiveBlending) {
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// //glDepthMask(true);
//}
glBindVertexArray(0);
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
@@ -667,7 +667,7 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&,
if (!blendEnabled) {
glDisable(GL_BLEND);
}
}
}
void RenderablePlanesCloud::renderLabels(const RenderData& data,
@@ -678,7 +678,7 @@ void RenderablePlanesCloud::renderLabels(const RenderData& data,
RenderEngine& renderEngine = OsEng.renderEngine();
_fontRenderer->setFramebufferSize(renderEngine.renderingResolution());
float scale = 0.0;
switch (_unit) {
case Meter:
@@ -703,7 +703,7 @@ void RenderablePlanesCloud::renderLabels(const RenderData& data,
scale = 306391534.73091 * PARSEC;
break;
}
glm::vec4 textColor = _textColor;
textColor.a *= fadeInVariable;
for (const std::pair<glm::vec3, std::string>& pair : _labelData) {
@@ -712,7 +712,7 @@ void RenderablePlanesCloud::renderLabels(const RenderData& data,
scaledPos *= scale;
_fontRenderer->render(
*_font,
scaledPos,
scaledPos,
//_textColor,
textColor,
pow(10.0, _textSize.value()),
@@ -726,8 +726,7 @@ void RenderablePlanesCloud::renderLabels(const RenderData& data,
_renderOption.value(),
"%s",
pair.second.c_str());
}
}
}
void RenderablePlanesCloud::render(const RenderData& data, RendererTasks&) {
@@ -815,15 +814,21 @@ void RenderablePlanesCloud::render(const RenderData& data, RendererTasks&) {
);
if (_hasSpeckFile) {
renderPlanes(data, modelViewMatrix, projectionMatrix, fadeInVariable);
renderPlanes(data, modelViewMatrix, projectionMatrix, fadeInVariable);
}
if (_hasLabel) {
renderLabels(data, modelViewProjectionMatrix, orthoRight, orthoUp, fadeInVariable);
}
renderLabels(
data,
modelViewProjectionMatrix,
orthoRight,
orthoUp,
fadeInVariable
);
}
}
void RenderablePlanesCloud::update(const UpdateData&) {
void RenderablePlanesCloud::update(const UpdateData&) {
if (_dataIsDirty && _hasSpeckFile) {
deleteDataGPU();
createPlanes();
@@ -832,7 +837,7 @@ void RenderablePlanesCloud::update(const UpdateData&) {
}
bool RenderablePlanesCloud::loadData() {
bool success = false;
bool success = false;
if (_hasSpeckFile) {
std::string _file = _speckFile;
// I disabled the cache as it didn't work on Mac --- abock
@@ -842,17 +847,20 @@ bool RenderablePlanesCloud::loadData() {
// );
// bool hasCachedFile = FileSys.fileExists(cachedFile);
// //if (hasCachedFile) {
// // LINFO("Cached file '" << cachedFile << "' used for Speck file '" << _file << "'");
// if (hasCachedFile) {
// LINFO(
// "Cached file '" << cachedFile <<
// "' used for Speck file '" << _file << "'"
// );
// // success = loadCachedFile(cachedFile);
// // if (!success) {
// // FileSys.cacheManager()->removeCacheFile(_file);
// // // Intentional fall-through to the 'else' computation to generate the cache
// // // file for the next run
// // }
// //}
// //else
// success = loadCachedFile(cachedFile);
// if (!success) {
// FileSys.cacheManager()->removeCacheFile(_file);
// // Intentional fall-through to the 'else' to generate the cache
// // file for the next run
// }
// }
// else
// {
// LINFO("Cache for Speck file '" << _file << "' not found");
LINFO("Loading Speck file '" << _file << "'");
@@ -866,7 +874,7 @@ bool RenderablePlanesCloud::loadData() {
//success &= saveCachedFile(cachedFile);
// }
}
std::string labelFile = _labelFile;
if (!labelFile.empty()) {
// I disabled the cache as it didn't work on Mac --- abock
@@ -875,17 +883,20 @@ bool RenderablePlanesCloud::loadData() {
// ghoul::filesystem::CacheManager::Persistent::Yes
// );
// bool hasCachedFile = FileSys.fileExists(cachedFile);
// //if (hasCachedFile) {
// // LINFO("Cached file '" << cachedFile << "' used for Label file '" << labelFile << "'");
// //
// // success &= loadCachedFile(cachedFile);
// // if (!success) {
// // FileSys.cacheManager()->removeCacheFile(labelFile);
// // // Intentional fall-through to the 'else' computation to generate the cache
// // // file for the next run
// // }
// //}
// //else
// if (hasCachedFile) {
// LINFO(
// "Cached file '" << cachedFile <<
// "' used for Label file '" << labelFile << "'"
// );
//
// success &= loadCachedFile(cachedFile);
// if (!success) {
// FileSys.cacheManager()->removeCacheFile(labelFile);
// // Intentional fall-through to the 'else' to generate the cache
// // file for the next run
// }
// }
// else
// {
// LINFO("Cache for Label file '" << labelFile << "' not found");
LINFO("Loading Label file '" << labelFile << "'");
@@ -897,15 +908,17 @@ bool RenderablePlanesCloud::loadData() {
// }
}
return success;
}
bool RenderablePlanesCloud::loadTextures() {
if (!_textureFileMap.empty()) {
for (auto pair : _textureFileMap) {
auto p = _textureMap.insert(std::make_pair(pair.first,
ghoul::io::TextureReader::ref().loadTexture(pair.second)));
auto p = _textureMap.insert(std::make_pair(
pair.first,
ghoul::io::TextureReader::ref().loadTexture(pair.second)
));
if (p.second) {
LDEBUGC(
"RenderablePlanesCloud",
@@ -915,7 +928,7 @@ bool RenderablePlanesCloud::loadTextures() {
it->second->uploadTexture();
it->second->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
}
}
}
}
else {
return false;
@@ -942,7 +955,7 @@ bool RenderablePlanesCloud::readSpeckFile() {
std::getline(file, line);
// Guard against wrong line endings (copying files from Windows to Mac) causes
// lines to have a final \r
// lines to have a final \r
if (!line.empty() && line.back() == '\r') {
line = line.substr(0, line.length() -1);
}
@@ -971,14 +984,14 @@ bool RenderablePlanesCloud::readSpeckFile() {
// number of values (+3 since X Y Z are not counted in the Speck file index)
std::stringstream str(line);
std::string dummy;
std::string dummy;
str >> dummy; // command
str >> _nValuesPerAstronomicalObject; // variable index
dummy.clear();
str >> dummy; // variable name
// +3 because of the x, y and z at the begining of each line.
_variableDataPositionMap.insert({ dummy, _nValuesPerAstronomicalObject + 3});
_variableDataPositionMap.insert({ dummy, _nValuesPerAstronomicalObject + 3});
if ((dummy == "orientation") || (dummy == "ori")) { // 3d vectors u and v
// We want the number, but the index is 0 based
@@ -987,7 +1000,7 @@ bool RenderablePlanesCloud::readSpeckFile() {
else {
// We want the number, but the index is 0 based
_nValuesPerAstronomicalObject += 1;
}
}
}
if (line.substr(0, 10) == "polyorivar") {
@@ -996,8 +1009,8 @@ bool RenderablePlanesCloud::readSpeckFile() {
std::string dummy;
str >> dummy; // command
str >> _planeStartingIndexPos;
_planeStartingIndexPos += 3; // 3 for xyz
str >> _planeStartingIndexPos;
_planeStartingIndexPos += 3; // 3 for xyz
}
if (line.substr(0, 10) == "texturevar") {
@@ -1006,25 +1019,25 @@ bool RenderablePlanesCloud::readSpeckFile() {
std::string dummy;
str >> dummy; // command
str >> _textureVariableIndex;
str >> _textureVariableIndex;
_textureVariableIndex += 3; // 3 for xyz
}
if (line.substr(0, 8) == "texture ") {
std::stringstream str(line);
std::size_t found = line.find("-");
int textureIndex = 0;
std::string dummy;
str >> dummy; // command
if (found != std::string::npos) {
std::string option; // Not being used right now.
str >> option;
}
str >> textureIndex;
str >> dummy; // texture file name
@@ -1042,7 +1055,7 @@ bool RenderablePlanesCloud::readSpeckFile() {
std::getline(file, line);
// Guard against wrong line endings (copying files from Windows to Mac) causes
// lines to have a final \r
// lines to have a final \r
if (!line.empty() && line.back() == '\r') {
line = line.substr(0, line.length() -1);
}
@@ -1050,7 +1063,7 @@ bool RenderablePlanesCloud::readSpeckFile() {
if (line.empty()) {
continue;
}
std::stringstream str(line);
glm::vec3 u(0.0f), v(0.0f);
@@ -1101,7 +1114,7 @@ bool RenderablePlanesCloud::readLabelFile() {
LERROR("Failed to open Label file '" << _file << "'");
return false;
}
// The beginning of the speck file has a header that either contains comments
// (signaled by a preceding '#') or information about the structure of the file
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
@@ -1111,7 +1124,7 @@ bool RenderablePlanesCloud::readLabelFile() {
std::getline(file, line);
// Guard against wrong line endings (copying files from Windows to Mac) causes
// lines to have a final \r
// lines to have a final \r
if (!line.empty() && line.back() == '\r') {
line = line.substr(0, line.length() -1);
}
@@ -1138,14 +1151,13 @@ bool RenderablePlanesCloud::readLabelFile() {
}
}
do {
std::vector<float> values(_nValuesPerAstronomicalObject);
std::getline(file, line);
// Guard against wrong line endings (copying files from Windows to Mac) causes
// lines to have a final \r
// lines to have a final \r
if (!line.empty() && line.back() == '\r') {
line = line.substr(0, line.length() -1);
}
@@ -1163,14 +1175,14 @@ bool RenderablePlanesCloud::readLabelFile() {
std::string dummy;
str >> dummy; // text keyword
std::string label;
str >> label;
dummy.clear();
while (str >> dummy) {
label += " " + dummy;
dummy.clear();
dummy.clear();
}
glm::vec3 transformedPos = glm::vec3(
@@ -1254,23 +1266,23 @@ void RenderablePlanesCloud::createPlanes() {
float maxSize = 0.0f;
int planeNumber = 0;
for (int p = 0; p < _fullData.size(); p += _nValuesPerAstronomicalObject) {
glm::vec4 transformedPos = glm::vec4(_transformationMatrix *
glm::dvec4(_fullData[p + 0], _fullData[p + 1], _fullData[p + 2], 1.0));
glm::vec4 transformedPos = glm::vec4(_transformationMatrix *
glm::dvec4(_fullData[p + 0], _fullData[p + 1], _fullData[p + 2], 1.0));
// Plane vectors u and v
glm::vec4 u = glm::vec4(_transformationMatrix *
glm::dvec4(
_fullData[p + _planeStartingIndexPos + 0],
_fullData[p + _planeStartingIndexPos + 1],
_fullData[p + _planeStartingIndexPos + 2],
_fullData[p + _planeStartingIndexPos + 0],
_fullData[p + _planeStartingIndexPos + 1],
_fullData[p + _planeStartingIndexPos + 2],
1.0));
u /= 2.f;
u.w = 0.0;
glm::vec4 v = glm::vec4(_transformationMatrix *
glm::dvec4(
_fullData[p + _planeStartingIndexPos + 3],
_fullData[p + _planeStartingIndexPos + 4],
_fullData[p + _planeStartingIndexPos + 5],
_fullData[p + _planeStartingIndexPos + 3],
_fullData[p + _planeStartingIndexPos + 4],
_fullData[p + _planeStartingIndexPos + 5],
1.0));
v /= 2.f;
v.w = 0.0;
@@ -1285,22 +1297,22 @@ void RenderablePlanesCloud::createPlanes() {
u *= _scaleFactor;
v *= _scaleFactor;
RenderingPlane plane;
RenderingPlane plane;
plane.planeIndex = _fullData[p + _textureVariableIndex];
// JCC: Ask Abbott about these points refeering to a non-existing texture.
if (plane.planeIndex == 30) {
plane.planeIndex = -1;
}
glGenVertexArrays(1, &plane.vao);
glGenBuffers(1, &plane.vbo);
glm::vec4 vertex0 = transformedPos - u - v; // same as 3
glm::vec4 vertex1 = transformedPos + u + v; // same as 5
glm::vec4 vertex2 = transformedPos - u + v;
glm::vec4 vertex4 = transformedPos + u - v;
float scale = 0.0;
switch (_unit) {
case Meter:
@@ -1336,8 +1348,8 @@ void RenderablePlanesCloud::createPlanes() {
vertex0 *= static_cast<float>(scale);
vertex1 *= static_cast<float>(scale);
vertex2 *= static_cast<float>(scale);
vertex4 *= static_cast<float>(scale);
vertex4 *= static_cast<float>(scale);
GLfloat vertexData[] = {
// x y z w s t
vertex0.x, vertex0.y, vertex0.z, 1.f, 0.f, 0.f,
@@ -1348,7 +1360,7 @@ void RenderablePlanesCloud::createPlanes() {
vertex1.x, vertex1.y, vertex1.z, 1.f, 1.f, 1.f,
};
std::memcpy(plane.vertexData, vertexData, sizeof(vertexData));
std::memcpy(plane.vertexData, vertexData, sizeof(vertexData));
glBindVertexArray(plane.vao);
glBindBuffer(GL_ARRAY_BUFFER, plane.vbo);
@@ -1368,7 +1380,7 @@ void RenderablePlanesCloud::createPlanes() {
sizeof(GLfloat) * 6,
nullptr
);
// texture coords
glEnableVertexAttribArray(1);
glVertexAttribPointer(
@@ -1378,7 +1390,7 @@ void RenderablePlanesCloud::createPlanes() {
GL_FALSE,
sizeof(GLfloat) * 6,
reinterpret_cast<GLvoid*>(sizeof(GLfloat) * 4)
);
);
_renderingPlanesArray.push_back(plane);
}
@@ -1391,18 +1403,16 @@ void RenderablePlanesCloud::createPlanes() {
}
if (_hasLabel && _labelDataIsDirty) {
_labelDataIsDirty = false;
}
// Sort planes by texture index
if (!_renderingPlanesArray.empty()) {
std::sort(_renderingPlanesArray.begin(), _renderingPlanesArray.end(),
std::sort(_renderingPlanesArray.begin(), _renderingPlanesArray.end(),
[](const RenderingPlane& planeA, const RenderingPlane& planeB) {
return planeA.planeIndex < planeB.planeIndex;
});
}
}
}
} // namespace openspace
@@ -41,9 +41,7 @@
#include <functional>
#include <unordered_map>
namespace ghoul::filesystem {
class File;
}
namespace ghoul::filesystem { class File; }
namespace ghoul::opengl {
class ProgramObject;
@@ -95,8 +93,9 @@ namespace openspace {
void createPlanes();
void renderPlanes(const RenderData& data, const glm::dmat4& modelViewMatrix,
const glm::dmat4& projectionMatrix, float fadeInVariable);
void renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVarible);
void renderLabels(const RenderData& data,
const glm::dmat4& modelViewProjectionMatrix, const glm::dvec3& orthoRight,
const glm::dvec3& orthoUp, float fadeInVarible);
bool loadData();
bool loadTextures();
@@ -130,7 +129,7 @@ namespace openspace {
properties::OptionProperty _renderOption;
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
std::shared_ptr<ghoul::fontrendering::Font> _font;
std::unordered_map<int, std::unique_ptr<ghoul::opengl::Texture>> _textureMap;
std::unordered_map<int, std::string> _textureFileMap;
@@ -149,10 +148,10 @@ namespace openspace {
int _nValuesPerAstronomicalObject;
float _sluminosity;
glm::dmat4 _transformationMatrix;
std::vector<RenderingPlane> _renderingPlanesArray;
std::vector<RenderingPlane> _renderingPlanesArray;
};
@@ -64,7 +64,7 @@ namespace {
"Point Sprite Texture",
"The path to the texture that should be used as the point sprite."
};
static const openspace::properties::Property::PropertyInfo TransparencyInfo = {
"Transparency",
"Transparency",
@@ -109,8 +109,8 @@ namespace openspace {
KeyFile,
new StringVerifier,
Optional::No,
"The path to the SPECK file that contains information about the astronomical "
"object being rendered."
"The path to the SPECK file that contains information about the "
"astronomical object being rendered."
},
{
keyColor,
@@ -156,7 +156,12 @@ namespace openspace {
, _hasColorMapFile(false)
, _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f)
, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 64.f)
, _pointColor(ColorInfo, glm::vec3(1.f, 0.4f, 0.2f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(1.0f, 1.0f, 1.0f))
, _pointColor(
ColorInfo,
glm::vec3(1.f, 0.4f, 0.2f),
glm::vec3(0.f, 0.f, 0.f),
glm::vec3(1.0f, 1.0f, 1.0f)
)
, _spriteTexturePath(SpriteTextureInfo)
, _spriteTexture(nullptr)
, _program(nullptr)
@@ -174,9 +179,9 @@ namespace openspace {
dictionary,
"RenderablePoints"
);
_speckFile = absPath(dictionary.value<std::string>(KeyFile));
if (dictionary.hasKey(keyUnit)) {
std::string unit = dictionary.value<std::string>(keyUnit);
if (unit == MeterUnit) {
@@ -300,17 +305,20 @@ namespace openspace {
_program->activate();
glm::dmat4 modelMatrix = glm::dmat4(1.0);
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
_program->setIgnoreUniformLocationError(IgnoreError::Yes);
_program->setUniform("modelViewProjectionTransform", glm::dmat4(data.camera.projectionMatrix()) *
data.camera.combinedViewMatrix() * modelMatrix);
_program->setUniform(
"modelViewProjectionTransform",
glm::dmat4(data.camera.projectionMatrix()) *
data.camera.combinedViewMatrix() * modelMatrix
);
_program->setUniform("color", _pointColor);
_program->setUniform("sides", 4);
_program->setUniform("alphaValue", _alphaValue);
_program->setUniform("scaleFactor", _scaleFactor);
if (_hasSpriteTexture) {
ghoul::opengl::TextureUnit spriteTextureUnit;
spriteTextureUnit.activate();
@@ -324,12 +332,14 @@ namespace openspace {
else {
_program->setUniform("hasColorMap", false);
}
glEnable(GL_PROGRAM_POINT_SIZE);
glBindVertexArray(_vao);
const GLsizei nAstronomicalObjects = static_cast<GLsizei>(_fullData.size() / _nValuesPerAstronomicalObject);
const GLsizei nAstronomicalObjects = static_cast<GLsizei>(
_fullData.size() / _nValuesPerAstronomicalObject
);
glDrawArrays(GL_POINTS, 0, nAstronomicalObjects);
glDisable(GL_PROGRAM_POINT_SIZE);
glBindVertexArray(0);
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
@@ -367,11 +377,12 @@ namespace openspace {
GLint positionAttrib = _program->attributeLocation("in_position");
if (_hasColorMapFile) {
const size_t nAstronomicalObjects = _fullData.size() / _nValuesPerAstronomicalObject;
const size_t nAstronomicalObjects = _fullData.size() /
_nValuesPerAstronomicalObject;
const size_t nValues = _slicedData.size() / nAstronomicalObjects;
GLsizei stride = static_cast<GLsizei>(sizeof(double) * nValues);
glEnableVertexAttribArray(positionAttrib);
glVertexAttribLPointer(
positionAttrib,
@@ -391,7 +402,7 @@ namespace openspace {
reinterpret_cast<void*>(sizeof(double)*4)
);
}
else {
else {
glEnableVertexAttribArray(positionAttrib);
glVertexAttribLPointer(
positionAttrib,
@@ -411,20 +422,24 @@ namespace openspace {
LDEBUG("Reloading Sprite Texture");
_spriteTexture = nullptr;
if (_spriteTexturePath.value() != "") {
_spriteTexture = ghoul::io::TextureReader::ref().loadTexture(absPath(_spriteTexturePath));
_spriteTexture = ghoul::io::TextureReader::ref().loadTexture(
absPath(_spriteTexturePath)
);
if (_spriteTexture) {
LDEBUG("Loaded texture from '" << absPath(_spriteTexturePath) << "'");
_spriteTexture->uploadTexture();
}
_spriteTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
_spriteTexture->setFilter(
ghoul::opengl::Texture::FilterMode::AnisotropicMipMap
);
_spriteTextureFile = std::make_unique<ghoul::filesystem::File>(
_spriteTexturePath);
_spriteTextureFile->setCallback(
[&](const ghoul::filesystem::File&) { _spriteTextureIsDirty = true; }
);
);
}
_spriteTextureIsDirty = false;
_spriteTextureIsDirty = false;
}
}
@@ -437,7 +452,9 @@ namespace openspace {
bool hasCachedFile = FileSys.fileExists(cachedFile);
if (hasCachedFile) {
LINFO("Cached file '" << cachedFile << "' used for Speck file '" << _file << "'");
LINFO(
"Cached file '" << cachedFile << "' used for Speck file '" << _file << "'"
);
bool success = loadCachedFile(cachedFile);
if (success) {
@@ -448,8 +465,8 @@ namespace openspace {
}
else {
FileSys.cacheManager()->removeCacheFile(_file);
// Intentional fall-through to the 'else' computation to generate the cache
// file for the next run
// Intentional fall-through to the 'else' to generate the cache file for
// the next run
}
}
else {
@@ -489,7 +506,7 @@ namespace openspace {
while (true) {
std::streampos position = file.tellg();
std::getline(file, line);
if (line[0] == '#' || line.empty()) {
continue;
}
@@ -498,8 +515,8 @@ namespace openspace {
line.substr(0, 10) != "texturevar" &&
line.substr(0, 7) != "texture")
{
// we read a line that doesn't belong to the header, so we have to jump back
// before the beginning of the current line
// we read a line that doesn't belong to the header, so we have to jump
// back before the beginning of the current line
file.seekg(position);
break;
}
@@ -507,19 +524,22 @@ namespace openspace {
if (line.substr(0, 7) == "datavar") {
// datavar lines are structured as follows:
// datavar # description
// where # is the index of the data variable; so if we repeatedly overwrite
// the 'nValues' variable with the latest index, we will end up with the total
// number of values (+3 since X Y Z are not counted in the Speck file index)
// where # is the index of the data variable; so if we repeatedly
// overwrite the 'nValues' variable with the latest index, we will end up
// with the total number of values (+3 since X Y Z are not counted in the
// Speck file index)
std::stringstream str(line);
std::string dummy;
str >> dummy;
str >> _nValuesPerAstronomicalObject;
_nValuesPerAstronomicalObject += 1; // We want the number, but the index is 0 based
// We want the number, but the index is 0 based
_nValuesPerAstronomicalObject += 1;
}
}
_nValuesPerAstronomicalObject += 3; // X Y Z are not counted in the Speck file indices
// X Y Z are not counted in the Speck file indices
_nValuesPerAstronomicalObject += 3;
do {
std::vector<float> values(_nValuesPerAstronomicalObject);
@@ -544,7 +564,7 @@ namespace openspace {
LERROR("Failed to open Color Map file '" << _file << "'");
return false;
}
std::size_t numberOfColors = 0;
// The beginning of the speck file has a header that either contains comments
@@ -568,13 +588,13 @@ namespace openspace {
}
else if (file.eof()) {
return false;
}
}
}
for (auto i = 0; i < numberOfColors; ++i) {
std::getline(file, line);
std::stringstream str(line);
glm::vec4 color;
for (auto j = 0; j < 4; ++j) {
str >> color[j];
@@ -582,7 +602,7 @@ namespace openspace {
_colorMapData.push_back(color);
}
return true;
}
@@ -600,7 +620,10 @@ namespace openspace {
int32_t nValues = 0;
fileStream.read(reinterpret_cast<char*>(&nValues), sizeof(int32_t));
fileStream.read(reinterpret_cast<char*>(&_nValuesPerAstronomicalObject), sizeof(int32_t));
fileStream.read(
reinterpret_cast<char*>(&_nValuesPerAstronomicalObject),
sizeof(int32_t)
);
_fullData.resize(nValues);
fileStream.read(reinterpret_cast<char*>(&_fullData[0]),
@@ -628,8 +651,13 @@ namespace openspace {
}
fileStream.write(reinterpret_cast<const char*>(&nValues), sizeof(int32_t));
int32_t nValuesPerAstronomicalObject = static_cast<int32_t>(_nValuesPerAstronomicalObject);
fileStream.write(reinterpret_cast<const char*>(&nValuesPerAstronomicalObject), sizeof(int32_t));
int32_t nValuesPerAstronomicalObject = static_cast<int32_t>(
_nValuesPerAstronomicalObject
);
fileStream.write(
reinterpret_cast<const char*>(&nValuesPerAstronomicalObject),
sizeof(int32_t)
);
size_t nBytes = nValues * sizeof(_fullData[0]);
fileStream.write(reinterpret_cast<const char*>(&_fullData[0]), nBytes);
@@ -642,7 +670,7 @@ namespace openspace {
return false;
}
}
void RenderablePoints::createDataSlice() {
_slicedData.clear();
if (_hasColorMapFile) {
@@ -654,7 +682,11 @@ namespace openspace {
int colorIndex = 0;
for (size_t i = 0; i < _fullData.size(); i += _nValuesPerAstronomicalObject) {
glm::dvec3 p = glm::dvec3(_fullData[i + 0], _fullData[i + 1], _fullData[i + 2]);
glm::dvec3 p = glm::dvec3(
_fullData[i + 0],
_fullData[i + 1],
_fullData[i + 2]
);
// Converting untis
if (_unit == Kilometer) {
@@ -691,10 +723,9 @@ namespace openspace {
_slicedData.push_back(position[j]);
}
}
colorIndex = (colorIndex == (_colorMapData.size() - 1)) ? 0 : colorIndex + 1;
}
}
} // namespace openspace
+17 -20
View File
@@ -148,9 +148,8 @@ namespace openspace {
} else {
LERROR("No points dictionary specified.");
}
}
RenderableGalaxy::~RenderableGalaxy() {}
void RenderableGalaxy::initializeGL() {
@@ -163,7 +162,7 @@ void RenderableGalaxy::initializeGL() {
_volumeDimensions
);
_volume = reader.read();
_texture = std::make_unique<ghoul::opengl::Texture>(
_volumeDimensions,
ghoul::opengl::Texture::Format::RGBA,
@@ -201,7 +200,7 @@ void RenderableGalaxy::initializeGL() {
addProperty(_translation);
addProperty(_rotation);
addProperty(_enabledPointsRatio);
// initialize points.
std::ifstream pointFile(_pointsFilename, std::ios::in | std::ios::binary);
@@ -222,7 +221,7 @@ void RenderableGalaxy::initializeGL() {
pointFile.close();
float maxdist = 0;
for (size_t i = 0; i < _nPoints; ++i) {
float x = pointData[i * 7 + 0];
float y = pointData[i * 7 + 1];
@@ -232,9 +231,9 @@ void RenderableGalaxy::initializeGL() {
float b = pointData[i * 7 + 5];
maxdist = std::max(maxdist, glm::length(glm::vec3(x, y, z)));
//float a = pointData[i * 7 + 6]; alpha is not used.
pointPositions.push_back(glm::vec3(x, y, z));
pointColors.push_back(glm::vec3(r, g, b));
pointColors.push_back(glm::vec3(r, g, b));
}
std::cout << maxdist << std::endl;
@@ -250,14 +249,15 @@ void RenderableGalaxy::initializeGL() {
glBufferData(GL_ARRAY_BUFFER,
pointPositions.size()*sizeof(glm::vec3),
pointPositions.data(),
GL_STATIC_DRAW);
GL_STATIC_DRAW
);
glBindBuffer(GL_ARRAY_BUFFER, _colorVbo);
glBufferData(GL_ARRAY_BUFFER,
pointColors.size()*sizeof(glm::vec3),
pointColors.data(),
GL_STATIC_DRAW);
GL_STATIC_DRAW
);
RenderEngine& renderEngine = OsEng.renderEngine();
_pointsProgram = renderEngine.buildRenderProgram(
@@ -281,25 +281,24 @@ void RenderableGalaxy::initializeGL() {
glBindBuffer(GL_ARRAY_BUFFER, _colorVbo);
glEnableVertexAttribArray(colorAttrib);
glVertexAttribPointer(colorAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
void RenderableGalaxy::deinitializeGL() {
if (_raycaster) {
OsEng.renderEngine().raycasterManager().detachRaycaster(*_raycaster.get());
_raycaster = nullptr;
}
}
bool RenderableGalaxy::isReady() const {
return true;
}
void RenderableGalaxy::update(const UpdateData& data) {
if (_raycaster) {
//glm::mat4 transform = glm::translate(, static_cast<glm::vec3>(_translation));
glm::vec3 eulerRotation = static_cast<glm::vec3>(_rotation);
glm::mat4 transform = glm::rotate(
@@ -315,7 +314,7 @@ void RenderableGalaxy::update(const UpdateData& data) {
static_cast<glm::vec3>(_volumeSize)
);
_pointTransform = glm::scale(transform, static_cast<glm::vec3>(_pointScaling));
glm::vec4 translation = glm::vec4(static_cast<glm::vec3>(_translation), 0.0);
// Todo: handle floating point overflow, to actually support translation.
@@ -323,7 +322,6 @@ void RenderableGalaxy::update(const UpdateData& data) {
volumeTransform[3] += translation;
_pointTransform[3] += translation;
_raycaster->setStepSize(_stepSize);
_raycaster->setAspect(_aspect);
_raycaster->setModelTransform(volumeTransform);
@@ -340,7 +338,6 @@ void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) {
glm::vec3 galaxySize = static_cast<glm::vec3>(_volumeSize);
float maxDim = std::max(std::max(galaxySize.x, galaxySize.y), galaxySize.z);
float lowerRampStart = maxDim * 0.02f;
float lowerRampEnd = maxDim * 0.5f;
@@ -413,5 +410,5 @@ float RenderableGalaxy::safeLength(const glm::vec3& vector) {
OsEng.ref().renderEngine().postRaycast(*_pointsProgram);
}*/
}
} // namespace openspace
+2 -2
View File
@@ -35,12 +35,12 @@
namespace openspace {
struct RenderData;
class RenderableGalaxy : public Renderable {
public:
RenderableGalaxy(const ghoul::Dictionary& dictionary);
~RenderableGalaxy();
void initializeGL() override;
void deinitializeGL() override;
bool isReady() const override;
@@ -1,4 +1,4 @@
/*****************************************************************************************
/*****************************************************************************************
* *
* OpenSpace *
* *
@@ -145,7 +145,7 @@ namespace {
"EclipseHardShadows",
"Eclipse Hard Shadows",
"Enables the rendering of eclipse shadows using hard shadows"
};
};
static const openspace::properties::Property::PropertyInfo LodScaleFactorInfo = {
"LodScaleFactor",
@@ -88,15 +88,15 @@ public:
// Shadow structure
struct ShadowRenderingStruct {
double xu,
xp;
double rs,
rc;
double xu;
double xp;
double rs;
double rc;
glm::dvec3 sourceCasterVec;
glm::dvec3 casterPositionVec;
bool isShadowing;
};
RenderableGlobe(const ghoul::Dictionary& dictionary);
~RenderableGlobe() = default;
@@ -33,7 +33,7 @@
#include <modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.h>
#include <openspace/util/updatestructures.h>
#include <openspace/util/spicemanager.h>
namespace {
const double KM_TO_M = 1000.0;
}
@@ -82,9 +82,9 @@ void ChunkRenderer::recompileShaders(const RenderableGlobe& globe) {
}
ghoul::opengl::ProgramObject* ChunkRenderer::getActivatedProgramWithTileData(
std::shared_ptr<LayerShaderManager> layeredShaderManager,
std::shared_ptr<GPULayerManager> gpuLayerManager,
const Chunk& chunk)
std::shared_ptr<LayerShaderManager> layeredShaderManager,
std::shared_ptr<GPULayerManager> gpuLayerManager,
const Chunk& chunk)
{
const TileIndex& tileIndex = chunk.tileIndex();
@@ -116,36 +116,67 @@ ghoul::opengl::ProgramObject* ChunkRenderer::getActivatedProgramWithTileData(
return programObject;
}
void ChunkRenderer::calculateEclipseShadows(const Chunk& chunk, ghoul::opengl::ProgramObject* programObject,
const RenderData& data) {
void ChunkRenderer::calculateEclipseShadows(const Chunk& chunk,
ghoul::opengl::ProgramObject* programObject,
const RenderData& data)
{
// Shadow calculations..
if (chunk.owner().ellipsoid().hasEclipseShadows()) {
std::vector<RenderableGlobe::ShadowRenderingStruct> shadowDataArray;
std::vector<Ellipsoid::ShadowConfiguration> shadowConfArray = chunk.owner().ellipsoid().shadowConfigurationArray();
std::vector<Ellipsoid::ShadowConfiguration> shadowConfArray =
chunk.owner().ellipsoid().shadowConfigurationArray();
shadowDataArray.reserve(shadowConfArray.size());
double lt;
for (const auto & shadowConf : shadowConfArray) {
// TO REMEMBER: all distances and lengths in world coordinates are in meters!!! We need to move this to view space...
// TO REMEMBER: all distances and lengths in world coordinates are in
// meters!!! We need to move this to view space...
// Getting source and caster:
glm::dvec3 sourcePos = SpiceManager::ref().targetPosition(shadowConf.source.first, "SUN", "GALACTIC", {},
data.time.j2000Seconds(), lt);
glm::dvec3 sourcePos = SpiceManager::ref().targetPosition(
shadowConf.source.first,
"SUN",
"GALACTIC",
{},
data.time.j2000Seconds(),
lt
);
sourcePos *= KM_TO_M; // converting to meters
glm::dvec3 casterPos = SpiceManager::ref().targetPosition(shadowConf.caster.first, "SUN", "GALACTIC", {},
data.time.j2000Seconds(), lt);
glm::dvec3 casterPos = SpiceManager::ref().targetPosition(
shadowConf.caster.first,
"SUN",
"GALACTIC",
{},
data.time.j2000Seconds(),
lt
);
casterPos *= KM_TO_M; // converting to meters
psc caster_pos = PowerScaledCoordinate::CreatePowerScaledCoordinate(casterPos.x, casterPos.y, casterPos.z);
psc caster_pos = PowerScaledCoordinate::CreatePowerScaledCoordinate(
casterPos.x,
casterPos.y,
casterPos.z
);
// First we determine if the caster is shadowing the current planet (all calculations in World Coordinates):
// First we determine if the caster is shadowing the current planet (all
// calculations in World Coordinates):
glm::dvec3 planetCasterVec = casterPos - data.position.dvec3();
glm::dvec3 sourceCasterVec = casterPos - sourcePos;
double sc_length = glm::length(sourceCasterVec);
glm::dvec3 planetCaster_proj = (glm::dot(planetCasterVec, sourceCasterVec) / (sc_length*sc_length)) * sourceCasterVec;
glm::dvec3 planetCaster_proj = (glm::dot(planetCasterVec, sourceCasterVec) /
(sc_length*sc_length)) * sourceCasterVec;
double d_test = glm::length(planetCasterVec - planetCaster_proj);
double xp_test = shadowConf.caster.second * sc_length / (shadowConf.source.second + shadowConf.caster.second);
double rp_test = shadowConf.caster.second * (glm::length(planetCaster_proj) + xp_test) / xp_test;
double xp_test = shadowConf.caster.second * sc_length /
(shadowConf.source.second + shadowConf.caster.second);
double rp_test = shadowConf.caster.second *
(glm::length(planetCaster_proj) + xp_test) / xp_test;
glm::dvec3 sunPos = SpiceManager::ref().targetPosition("SUN", "SUN", "GALACTIC", {}, data.time.j2000Seconds(), lt);
glm::dvec3 sunPos = SpiceManager::ref().targetPosition(
"SUN",
"SUN",
"GALACTIC",
{},
data.time.j2000Seconds(),
lt
);
double casterDistSun = glm::length(casterPos - sunPos);
double planetDistSun = glm::length(data.position.dvec3() - sunPos);
@@ -161,7 +192,8 @@ void ChunkRenderer::calculateEclipseShadows(const Chunk& chunk, ghoul::opengl::P
shadowData.rc = shadowConf.caster.second;
shadowData.sourceCasterVec = glm::normalize(sourceCasterVec);
shadowData.xp = xp_test;
shadowData.xu = shadowData.rc * sc_length / (shadowData.rs - shadowData.rc);
shadowData.xu = shadowData.rc * sc_length /
(shadowData.rs - shadowData.rc);
shadowData.casterPositionVec = casterPos;
}
shadowDataArray.push_back(shadowData);
@@ -196,9 +228,15 @@ void ChunkRenderer::calculateEclipseShadows(const Chunk& chunk, ghoul::opengl::P
counter++;
}
programObject->setUniform("inverseViewTransform", glm::inverse(data.camera.combinedViewMatrix()));
programObject->setUniform(
"inverseViewTransform",
glm::inverse(data.camera.combinedViewMatrix())
);
programObject->setUniform("modelTransform", chunk.owner().modelTransform());
programObject->setUniform("hardShadows", chunk.owner().generalProperties().eclipseHardShadows);
programObject->setUniform(
"hardShadows",
chunk.owner().generalProperties().eclipseHardShadows
);
programObject->setUniform("calculateEclipseShadows", true);
}
}
@@ -288,7 +326,7 @@ void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& da
}
const Ellipsoid& ellipsoid = chunk.owner().ellipsoid();
if (_layerManager->hasAnyBlendingLayersEnabled()) {
// Calculations are done in the reference frame of the globe. Hence, the
// camera position needs to be transformed with the inverse model matrix
@@ -435,7 +473,7 @@ void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& dat
}
setCommonUniforms(*programObject, chunk, data);
if (chunk.owner().ellipsoid().hasEclipseShadows()) {
calculateEclipseShadows(chunk, programObject, data);
}
@@ -83,11 +83,11 @@ private:
std::shared_ptr<GPULayerManager> gpuLayerManager,
const Chunk& chunk);
void calculateEclipseShadows(const Chunk& chunk, ghoul::opengl::ProgramObject* programObject,
const RenderData& data);
void calculateEclipseShadows(const Chunk& chunk,
ghoul::opengl::ProgramObject* programObject, const RenderData& data);
void setCommonUniforms(ghoul::opengl::ProgramObject& programObject,
const Chunk& chunk, const RenderData& data);
const Chunk& chunk, const RenderData& data);
// shared pointer to a grid which can be the same for all rendered chunks.
std::shared_ptr<Grid> _grid;
@@ -112,8 +112,14 @@ LayerShaderManager::LayerShaderPreprocessingData
);
pairs.emplace_back("useAtmosphere", std::to_string(generalProps.atmosphereEnabled));
pairs.emplace_back("performShading", std::to_string(generalProps.performShading));
pairs.emplace_back("useEclipseShadows", std::to_string(generalProps.eclipseShadowsEnabled));
pairs.emplace_back("useEclipseHardShadows", std::to_string(generalProps.eclipseHardShadows));
pairs.emplace_back(
"useEclipseShadows",
std::to_string(generalProps.eclipseShadowsEnabled)
);
pairs.emplace_back(
"useEclipseHardShadows",
std::to_string(generalProps.eclipseHardShadows)
);
pairs.emplace_back("showChunkEdges", std::to_string(debugProps.showChunkEdges));
pairs.emplace_back("showHeightResolution",
std::to_string(debugProps.showHeightResolution)
+4 -1
View File
@@ -92,7 +92,10 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
const std::vector<SceneGraphNode*>& nodes = scene ?
scene->allSceneGraphNodes() :
std::vector<SceneGraphNode*>();
return std::vector<properties::PropertyOwner*>(nodes.begin(), nodes.end());
return std::vector<properties::PropertyOwner*>(
nodes.begin(),
nodes.end()
);
}
);
+5 -4
View File
@@ -27,9 +27,7 @@
#include <modules/imgui/include/guicomponent.h>
namespace openspace {
class Asset;
}
namespace openspace { class Asset; }
namespace openspace::gui {
@@ -37,8 +35,11 @@ class GuiAssetComponent : public GuiComponent {
public:
GuiAssetComponent();
void render() override;
private:
void renderTree(const std::shared_ptr<openspace::Asset> a, const std::string& rootPath);
void renderTree(const std::shared_ptr<openspace::Asset> a,
const std::string& rootPath
);
};
} // namespace openspace::gui
+1 -1
View File
@@ -1,4 +1,4 @@
/*****************************************************************************************
/*****************************************************************************************
* *
* OpenSpace *
* *
+8 -1
View File
@@ -761,7 +761,14 @@ void renderDMat2Property(Property* prop, const std::string& ownerName,
"%.5f",
p->exponent()
);
changed |= ImGui::SliderFloat2("[1]", glm::value_ptr(value[1]), min, max, "%.5f", p->exponent());
changed |= ImGui::SliderFloat2(
"[1]",
glm::value_ptr(value[1]),
min,
max,
"%.5f",
p->exponent()
);
if (showTooltip) {
renderTooltip(prop, tooltipDelay);
@@ -48,7 +48,7 @@ class RenderableKameleonVolume : public Renderable {
public:
RenderableKameleonVolume(const ghoul::Dictionary& dictionary);
~RenderableKameleonVolume();
void initializeGL() override;
void deinitializeGL() override;
bool isReady() const override;
@@ -43,7 +43,7 @@ public:
bool readHeader();
bool initialize();
bool initialize();
bool BuildBrickList(BUFFER_INDEX _bufIdx, std::vector<int> &_brickRequest);
@@ -47,7 +47,9 @@ struct BrickSelection {
BrickSelection() {}
BrickSelection(int numBricks, int numTimeSteps, SplitType splitType, float splitPoints) {
BrickSelection(int numBricks, int numTimeSteps, SplitType splitType,
float splitPoints)
{
this->cover = BrickCover(numBricks);
this->lowT = 0;
this->highT = numTimeSteps;
@@ -58,7 +60,9 @@ struct BrickSelection {
this->nTemporalSplits = 0;
}
BrickSelection splitSpatially(bool x, bool y, bool z, unsigned int childBrickIndex, SplitType childSplitType, float childSplitPoints) {
BrickSelection splitSpatially(bool x, bool y, bool z, unsigned int childBrickIndex,
SplitType childSplitType, float childSplitPoints)
{
BrickSelection child;
child.cover = cover.split(x, y, z);
child.brickIndex = childBrickIndex;
@@ -71,7 +75,9 @@ struct BrickSelection {
return child;
}
BrickSelection splitTemporally(bool t, unsigned int childBrickIndex, SplitType childSplitType, float childSplitPoints) {
BrickSelection splitTemporally(bool t, unsigned int childBrickIndex,
SplitType childSplitType, float childSplitPoints)
{
BrickSelection child;
child.cover = cover;
child.brickIndex = childBrickIndex;
@@ -43,7 +43,8 @@ public:
float temporal;
};
LocalTfBrickSelector(TSP* tsp, LocalErrorHistogramManager* hm, TransferFunction* tf, int memoryBudget, int streamingBudget);
LocalTfBrickSelector(TSP* tsp, LocalErrorHistogramManager* hm, TransferFunction* tf,
int memoryBudget, int streamingBudget);
~LocalTfBrickSelector();
virtual bool initialize();
@@ -59,10 +59,14 @@ public:
void initialize();
void deinitialize();
void renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) override;
void renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) override;
void preRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) override;
void postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) override;
void renderEntryPoints(const RenderData& data,
ghoul::opengl::ProgramObject& program) override;
void renderExitPoints(const RenderData& data,
ghoul::opengl::ProgramObject& program) override;
void preRaycast(const RaycastData& data,
ghoul::opengl::ProgramObject& program) override;
void postRaycast(const RaycastData& data,
ghoul::opengl::ProgramObject& program) override;
bool cameraIsInside(const RenderData& data, glm::vec3& localPosition) override;
std::string getBoundsVsPath() const override;
@@ -85,11 +89,12 @@ private:
std::unique_ptr<ghoul::opengl::TextureUnit> _tfUnit;
std::unique_ptr<ghoul::opengl::TextureUnit> _atlasUnit;
std::unique_ptr < ghoul::opengl::BufferBinding<ghoul::opengl::bufferbinding::Buffer::ShaderStorage>> _atlasMapBinding;
std::unique_ptr<
ghoul::opengl::BufferBinding<ghoul::opengl::bufferbinding::Buffer::ShaderStorage>
> _atlasMapBinding;
}; // MultiresVolumeRaycaster
} // namespace openspace
#endif // __OPENSPACE_MODULE_MULTIRESVOLUME___MULTIRESVOLUMERAYCASTER___H__
#endif // __OPENSPACE_MODULE_MULTIRESVOLUME___MULTIRESVOLUMERAYCASTER___H__
@@ -174,7 +174,7 @@ RenderableMultiresVolume::RenderableMultiresVolume (const ghoul::Dictionary& dic
, _errorHistogramManager(nullptr)
, _histogramManager(nullptr)
, _localErrorHistogramManager(nullptr)
, _stepSizeCoefficient(StepSizeCoefficientInfo, 1.f, 0.01f, 10.f)
, _stepSizeCoefficient(StepSizeCoefficientInfo, 1.f, 0.01f, 10.f)
, _currentTime(CurrentTimeInfo, 0, 0, 0)
, _memoryBudget(MemoryBudgetInfo, 0, 0, 0)
, _streamingBudget(StreamingBudgetInfo, 0, 0, 0)
@@ -89,7 +89,8 @@ private:
properties::BoolProperty _useGlobalTime;
properties::BoolProperty _loop;
properties::IntProperty _currentTime; // used to vary time, if not using global time nor looping
// used to vary time, if not using global time nor looping
properties::IntProperty _currentTime;
properties::IntProperty _memoryBudget;
properties::IntProperty _streamingBudget;
properties::FloatProperty _stepSizeCoefficient;
+2 -3
View File
@@ -46,7 +46,6 @@ public:
unsigned int xNumBricks_;
unsigned int yNumBricks_;
unsigned int zNumBricks_;
};
enum NodeData {
@@ -60,7 +59,7 @@ public:
TSP(const std::string& filename);
~TSP();
// load performs readHeader, readCache, writeCache and construct
// load performs readHeader, readCache, writeCache and construct
// in the correct sequence
bool load();
@@ -98,7 +97,7 @@ public:
bool isOctreeLeaf(unsigned int _brickIndex);
private:
// Returns a list of the octree leaf nodes that a given input
// Returns a list of the octree leaf nodes that a given input
// brick covers. If the input is already a leaf, the list will
// only contain that one index.
std::list<unsigned int> CoveredLeafBricks(unsigned int _brickIndex);
+8 -6
View File
@@ -407,8 +407,10 @@ bool RenderablePlanet::isReady() const {
return ready;
}
glm::dmat4 RenderablePlanet::computeModelTransformMatrix(const openspace::TransformData & transformData) {
// scale the planet to appropriate size since the planet is a unit sphere
glm::dmat4 RenderablePlanet::computeModelTransformMatrix(
const openspace::TransformData& transformData)
{
// scale the planet to appropriate size since the planet is a unit sphere
glm::dmat4 modelTransform =
glm::translate(glm::dmat4(1.0), transformData.translation) * // Translation
glm::dmat4(transformData.rotation) * // Spice rotation
@@ -432,21 +434,21 @@ glm::dmat4 RenderablePlanet::computeModelTransformMatrix(const openspace::Transf
// glm::dmat4(1.0),
// glm::radians(static_cast<double>(_rotation)), glm::dvec3(0, 1, 0)
//);
return modelTransform = modelTransform * rot * roty /** rotProp*/;
}
void RenderablePlanet::render(const RenderData& data, RendererTasks& renderTask) {
// activate shader
_programObject->activate();
glm::dmat4 modelTransform = computeModelTransformMatrix(data.modelTransform);
glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform;
_programObject->setUniform("transparency", _alpha);
_programObject->setUniform("modelViewTransform", modelViewTransform);
_programObject->setUniform("modelViewProjectionTransform",
_programObject->setUniform("modelViewProjectionTransform",
data.camera.sgctInternal.projectionMatrix() * glm::mat4(modelViewTransform)
);
_programObject->setUniform("ModelTransform", glm::mat4(modelTransform));
+7 -7
View File
@@ -64,10 +64,10 @@ public:
};
struct ShadowRenderingStruct {
float xu,
xp;
float rs,
rc;
float xu;
float xp;
float rs;
float rc;
glm::vec3 sourceCasterVec;
glm::vec3 casterPositionVec;
bool isShadowing;
@@ -87,8 +87,8 @@ public:
protected:
void loadTexture();
private:
glm::dmat4 computeModelTransformMatrix(const openspace::TransformData & transformData);
private:
glm::dmat4 computeModelTransformMatrix(const openspace::TransformData& transformData);
properties::StringProperty _colorTexturePath;
properties::StringProperty _nightTexturePath;
@@ -114,7 +114,7 @@ private:
glm::dmat3 _stateMatrix;
std::vector<ShadowConfiguration> _shadowConfArray;
std::vector<ShadowConfiguration> _shadowConfArray;
};
} // namespace openspace
@@ -655,7 +655,6 @@ bool RenderableStars::readSpeckFile() {
if (!nullArray) {
_fullData.insert(_fullData.end(), values.begin(), values.end());
}
} while (!file.eof());
return true;
@@ -1,4 +1,4 @@
/*****************************************************************************************
/****************************************************************************************
* *
* OpenSpace *
* *
@@ -60,8 +60,8 @@ namespace {
"ActiveColor",
"Active Color",
"This value determines the color that the active instrument is rendered in. "
"Shortly after activation, the used color is mixture of this and the flash color. "
"The default value is (0.6, 1.0, 0.0)."
"Shortly after activation, the used color is mixture of this and the flash "
"color. The default value is (0.6, 1.0, 0.0)."
};
static const openspace::properties::Property::PropertyInfo FlashColorInfo = {
@@ -423,7 +423,7 @@ glm::vec2 DashboardItemInstruments::size() const {
ss.append(std::to_string(second));
size = addToBoundingbox(
size,
size,
ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Data acquisition adjacency: [%s:%s:%s]",
@@ -54,7 +54,7 @@ class RenderablePlaneProjection : public Renderable {
public:
RenderablePlaneProjection(const ghoul::Dictionary& dictionary);
~RenderablePlaneProjection();
void initializeGL() override;
void deinitializeGL() override;
@@ -69,7 +69,7 @@ private:
void setTarget(std::string body);
std::string _texturePath;
bool _planeIsDirty;
glm::dmat3 _stateMatrix;
+2 -2
View File
@@ -34,8 +34,8 @@ set(HEADER_FILES
source_group("Header Files" FILES ${HEADER_FILES})
set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/syncmodule.cpp
${CMAKE_CURRENT_SOURCE_DIR}/torrentclient.cpp
${CMAKE_CURRENT_SOURCE_DIR}/syncmodule.cpp
${CMAKE_CURRENT_SOURCE_DIR}/torrentclient.cpp
${CMAKE_CURRENT_SOURCE_DIR}/syncs/httpsynchronization.cpp
${CMAKE_CURRENT_SOURCE_DIR}/syncs/torrentsynchronization.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tasks/syncassettask.cpp
+21 -24
View File
@@ -26,42 +26,38 @@
#include <modules/sync/syncs/httpsynchronization.h>
#include <modules/sync/syncs/torrentsynchronization.h>
#include <modules/sync/tasks/syncassettask.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/documentation/documentation.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderable.h>
#include <openspace/rendering/screenspacerenderable.h>
#include <openspace/util/factorymanager.h>
#include <openspace/util/resourcesynchronization.h>
#include <ghoul/misc/assert.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/misc/assert.h>
#include <ghoul/misc/dictionary.h>
namespace {
const char* KeyHttpSynchronizationRepositories = "HttpSynchronizationRepositories";
const char* KeySynchronizationRoot = "SynchronizationRoot";
constexpr const char* KeyHttpSynchronizationRepositories =
"HttpSynchronizationRepositories";
constexpr const char* KeySynchronizationRoot = "SynchronizationRoot";
const char* _loggerCat = "SyncModule";
}
namespace openspace {
SyncModule::SyncModule()
: OpenSpaceModule(Name)
{}
SyncModule::SyncModule() : OpenSpaceModule(Name) {}
void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) {
if (configuration.hasKey(KeyHttpSynchronizationRepositories))
{
if (configuration.hasKey(KeyHttpSynchronizationRepositories)) {
ghoul::Dictionary dictionary = configuration.value<ghoul::Dictionary>(
KeyHttpSynchronizationRepositories);
for (std::string key : dictionary.keys()) {
for (const std::string& key : dictionary.keys()) {
_httpSynchronizationRepositories.push_back(
dictionary.value<std::string>(key)
);
@@ -71,7 +67,10 @@ void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) {
if (configuration.hasKey(KeySynchronizationRoot)) {
_synchronizationRoot = configuration.value<std::string>(KeySynchronizationRoot);
} else {
LWARNING("No synchronization root specified. Resource synchronization will be disabled.");
LWARNING(
"No synchronization root specified."
"Resource synchronization will be disabled."
);
//_synchronizationEnabled = false;
// TODO: Make it possible to disable synchronization manyally.
// Group root and enabled into a sync config object that can be passed to syncs.
@@ -80,16 +79,15 @@ void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) {
auto fSynchronization = FactoryManager::ref().factory<ResourceSynchronization>();
ghoul_assert(fSynchronization, "ResourceSynchronization factory was not created");
fSynchronization->registerClass(
"HttpSynchronization",
[this](bool, const ghoul::Dictionary& dictionary) {
return new HttpSynchronization(
dictionary,
_synchronizationRoot,
_httpSynchronizationRepositories
);
}
return new HttpSynchronization(
dictionary,
_synchronizationRoot,
_httpSynchronizationRepositories
);
}
);
fSynchronization->registerClass(
@@ -117,8 +115,7 @@ std::vector<documentation::Documentation> SyncModule::documentations() const {
};
}
std::string SyncModule::synchronizationRoot() const
{
std::string SyncModule::synchronizationRoot() const {
return _synchronizationRoot;
}
@@ -130,7 +127,7 @@ std::vector<std::string> SyncModule::httpSynchronizationRepositories() const {
return _httpSynchronizationRepositories;
}
TorrentClient* SyncModule::torrentClient() {
TorrentClient* SyncModule::torrentClient() {
return &_torrentClient;
}
+3
View File
@@ -34,6 +34,7 @@ namespace openspace {
class SyncModule : public OpenSpaceModule {
public:
constexpr static const char* Name = "Sync";
SyncModule();
virtual ~SyncModule() = default;
std::vector<documentation::Documentation> documentations() const override;
@@ -41,8 +42,10 @@ public:
void addHttpSynchronizationRepository(const std::string& repository);
std::vector<std::string> httpSynchronizationRepositories() const;
TorrentClient* torrentClient();
protected:
void internalInitialize(const ghoul::Dictionary& configuration) override;
private:
TorrentClient _torrentClient;
std::vector<std::string> _httpSynchronizationRepositories;
+19 -13
View File
@@ -189,7 +189,7 @@ bool HttpSynchronization::trySyncFromUrl(std::string listUrl) {
_nSynchronizedBytes = 0;
_nTotalBytes = 0;
_nTotalBytesKnown = false;
std::istringstream fileList(std::string(buffer.begin(), buffer.end()));
std::string line = "";
@@ -198,24 +198,24 @@ bool HttpSynchronization::trySyncFromUrl(std::string listUrl) {
std::mutex fileSizeMutex;
std::atomic_bool startedAllDownloads(false);
std::atomic_size_t nDownloads(0);
std::vector<std::unique_ptr<AsyncHttpFileDownload>> downloads;
while (fileList >> line) {
size_t lastSlash = line.find_last_of('/');
std::string filename = line.substr(lastSlash + 1);
std::string fileDestination = directory() +
ghoul::filesystem::FileSystem::PathSeparator +
filename;
downloads.push_back(std::make_unique<AsyncHttpFileDownload>(
line, fileDestination, HttpFileDownload::Overwrite::Yes));
auto& fileDownload = downloads.back();
++nDownloads;
fileDownload->onProgress(
[this, line, &fileSizes, &fileSizeMutex,
&startedAllDownloads, &nDownloads](HttpRequest::Progress p)
@@ -223,13 +223,19 @@ bool HttpSynchronization::trySyncFromUrl(std::string listUrl) {
if (p.totalBytesKnown) {
std::lock_guard<std::mutex> guard(fileSizeMutex);
fileSizes[line] = p.totalBytes;
if (!_nTotalBytesKnown && startedAllDownloads && fileSizes.size() == nDownloads) {
if (!_nTotalBytesKnown && startedAllDownloads &&
fileSizes.size() == nDownloads)
{
_nTotalBytesKnown = true;
_nTotalBytes = std::accumulate(fileSizes.begin(), fileSizes.end(), size_t(0),
_nTotalBytes = std::accumulate(
fileSizes.begin(),
fileSizes.end(),
size_t(0),
[](size_t a, auto b) {
return a + b.second;
});
return a + b.second;
}
);
}
}
return !_shouldCancel;
@@ -238,7 +244,7 @@ bool HttpSynchronization::trySyncFromUrl(std::string listUrl) {
fileDownload->start(opt);
}
startedAllDownloads = true;
bool failed = false;
for (auto& d : downloads) {
d->wait();
@@ -192,7 +192,9 @@ bool TorrentSynchronization::nTotalBytesIsKnown() {
return _progress.nTotalBytesKnown;
}
void TorrentSynchronization::updateTorrentProgress(TorrentClient::TorrentProgress progress) {
void TorrentSynchronization::updateTorrentProgress(
TorrentClient::TorrentProgress progress)
{
std::lock_guard<std::mutex> g(_progressMutex);
_progress = progress;
if (progress.finished && state() == State::Syncing) {
+1 -1
View File
@@ -96,7 +96,7 @@ void SyncAssetTask::perform(const Task::ProgressCallback & progressCallback) {
bool inProgress = false;
for (const std::shared_ptr<Asset>& asset : allAssets) {
Asset::State state = asset->state();
if (state == Asset::State::Unloaded ||
if (state == Asset::State::Unloaded ||
state == Asset::State::Loaded ||
state == Asset::State::Synchronizing) {
inProgress = true;
+18 -20
View File
@@ -22,23 +22,24 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include "torrentclient.h"
#include <modules/sync/torrentclient.h>
#include <openspace/openspace.h>
#include <ghoul/logging/logmanager.h>
namespace {
const char* _loggerCat = "TorrentClient";
constexpr const char* _loggerCat = "TorrentClient";
std::chrono::milliseconds PollInterval(200);
} // namespace
namespace openspace {
TorrentError::TorrentError(std::string component)
: RuntimeError("TorrentClient", component)
TorrentError::TorrentError(std::string component)
: RuntimeError("TorrentClient", component)
{}
}
} // namespace openspace
#ifdef SYNC_USE_LIBTORRENT
@@ -68,7 +69,8 @@ void TorrentClient::initialize() {
settings.set_str(libtorrent::settings_pack::user_agent, "OpenSpace/" +
std::to_string(openspace::OPENSPACE_VERSION_MAJOR) + "." +
std::to_string(openspace::OPENSPACE_VERSION_MINOR) + "." +
std::to_string(openspace::OPENSPACE_VERSION_PATCH));
std::to_string(openspace::OPENSPACE_VERSION_PATCH)
);
settings.set_bool(libtorrent::settings_pack::allow_multiple_connections_per_ip, true);
//settings.set_bool(libtorrent::settings_pack::ignore_limits_on_local_network, true);
@@ -152,7 +154,8 @@ TorrentClient::TorrentId TorrentClient::addTorrentFile(std::string torrentFile,
TorrentClient::TorrentId TorrentClient::addMagnetLink(std::string magnetLink,
std::string destination,
TorrentProgressCallback cb) {
TorrentProgressCallback cb)
{
std::lock_guard<std::mutex> guard(_mutex);
// TODO: register callback!
@@ -178,7 +181,7 @@ TorrentClient::TorrentId TorrentClient::addMagnetLink(std::string magnetLink,
void TorrentClient::removeTorrent(TorrentId id) {
std::lock_guard<std::mutex> guard(_mutex);
const auto it = _torrents.find(id);
auto it = _torrents.find(id);
if (it == _torrents.end()) {
return;
}
@@ -187,13 +190,12 @@ void TorrentClient::removeTorrent(TorrentId id) {
_session->remove_torrent(h);
_torrents.erase(it);
}
void TorrentClient::notify(TorrentId id) {
std::lock_guard<std::mutex> guard(_mutex);
const auto& torrent = _torrents.find(id);
auto torrent = _torrents.find(id);
if (torrent == _torrents.end()) {
return;
}
@@ -211,10 +213,9 @@ void TorrentClient::notify(TorrentId id) {
progress.nDownloadedBytes = status.total_wanted_done;
torrent->second.callback(progress);
}
}
} // namespace openspace
#else // SYNC_USE_LIBTORRENT
@@ -228,23 +229,20 @@ void TorrentClient::initialize() {}
void TorrentClient::pollAlerts() {}
TorrentClient::TorrentId TorrentClient::addTorrentFile(
std::string,
std::string,
TorrentProgressCallback)
TorrentClient::TorrentId TorrentClient::addTorrentFile(std::string, std::string,
TorrentProgressCallback)
{
throw TorrentError("SyncModule is not compiled with libtorrent");
}
TorrentClient::TorrentId TorrentClient::addMagnetLink(std::string,
std::string,
TorrentProgressCallback)
TorrentClient::TorrentId TorrentClient::addMagnetLink(std::string, std::string,
TorrentProgressCallback)
{
throw TorrentError("SyncModule is not compiled with libtorrent");
}
void TorrentClient::removeTorrent(TorrentId id) {}
}
} // namespace openspace
#endif // SYNC_USE_LIBTORRENT
+7 -7
View File
@@ -25,9 +25,10 @@
#ifndef __OPENSPACE_MODULE_SYNC___TORRENTCLIENT___H__
#define __OPENSPACE_MODULE_SYNC___TORRENTCLIENT___H__
#include <functional>
#include <ghoul/misc/exception.h>
#include <functional>
namespace openspace {
struct TorrentError : public ghoul::RuntimeError {
@@ -57,8 +58,8 @@ public:
virtual void initialize() = 0;
virtual TorrentId addTorrentFile(std::string torrentFile,
std::string destination,
TorrentProgressCallback cb) = 0;
std::string destination,
TorrentProgressCallback cb) = 0;
virtual TorrentId addMagnetLink(std::string magnetLink,
std::string destination,
@@ -81,9 +82,7 @@ public:
#include "libtorrent/torrent_handle.hpp"
namespace libtorrent {
class session;
}
namespace libtorrent { class session; }
namespace openspace {
@@ -103,6 +102,7 @@ public:
void removeTorrent(TorrentId id) override;
void pollAlerts() override;
private:
struct Torrent {
TorrentId id;
@@ -145,6 +145,6 @@ public:
} // namespace openspace
#endif // SYNC_USE_LIBTORRENT
#endif // __OPENSPACE_MODULE_SYNC___TORRENTCLIENT___H__
@@ -104,7 +104,7 @@ RenderableToyVolume::RenderableToyVolume(const ghoul::Dictionary& dictionary)
_stepSize = stepSize;
}
}
RenderableToyVolume::~RenderableToyVolume() {}
void RenderableToyVolume::initializeGL() {
@@ -131,19 +131,19 @@ void RenderableToyVolume::initializeGL() {
addProperty(_rotation);
addProperty(_color);
}
void RenderableToyVolume::deinitializeGL() {
if (_raycaster) {
OsEng.renderEngine().raycasterManager().detachRaycaster(*_raycaster.get());
_raycaster = nullptr;
}
}
bool RenderableToyVolume::isReady() const {
// @TODO isReady function needs to be filled
return true;
}
void RenderableToyVolume::update(const UpdateData& data) {
if (_raycaster) {
glm::mat4 transform = glm::translate(
@@ -162,7 +162,6 @@ void RenderableToyVolume::update(const UpdateData& data) {
std::pow(10.0f, static_cast<float>(_scalingExponent))
);
_raycaster->setColor(_color);
_raycaster->setStepSize(_stepSize);
_raycaster->setModelTransform(transform);
@@ -174,5 +173,5 @@ void RenderableToyVolume::render(const RenderData& data, RendererTasks& tasks) {
RaycasterTask task{ _raycaster.get(), data };
tasks.raycasterTasks.push_back(task);
}
} // namespace openspace
@@ -38,12 +38,12 @@ namespace openspace {
class ToyVolumeRaycaster;
struct RenderData;
class RenderableToyVolume : public Renderable {
public:
RenderableToyVolume(const ghoul::Dictionary& dictionary);
~RenderableToyVolume();
void initializeGL() override;
void deinitializeGL() override;
bool isReady() const override;
@@ -57,7 +57,7 @@ private:
properties::Vec3Property _translation;
properties::Vec3Property _rotation;
properties::Vec4Property _color;
std::unique_ptr<ToyVolumeRaycaster> _raycaster;
};
@@ -213,7 +213,7 @@ RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(
_gridType = (gridType == VolumeGridType::Spherical) ? 1 : 0;
}
}
RenderableTimeVaryingVolume::~RenderableTimeVaryingVolume() {}
void RenderableTimeVaryingVolume::initializeGL() {
@@ -239,7 +239,7 @@ void RenderableTimeVaryingVolume::initializeGL() {
}
// TODO: defer loading of data to later. (separate thread or at least not when loading)
// TODO: defer loading of data to later (separate thread or at least not when loading)
for (auto& p : _volumeTimesteps) {
Timestep& t = p.second;
std::string path = FileSys.pathByAppendingComponent(
@@ -363,7 +363,7 @@ void RenderableTimeVaryingVolume::loadTimestepMetadata(const std::string& path)
t.time = Time::convertTime(timeString);
t.inRam = false;
t.onGpu = false;
_volumeTimesteps[t.time] = std::move(t);
}
@@ -384,7 +384,7 @@ RenderableTimeVaryingVolume::Timestep* RenderableTimeVaryingVolume::currentTimes
}
if (currentTimestepIt == _volumeTimesteps.begin()) {
// No such timestep was found: show first timestep if it is within the time margin.
// No such timestep was found: show first timestep if it is within the time margin
Timestep* firstTimestep = &(_volumeTimesteps.begin()->second);
double threshold = firstTimestep->time - static_cast<double>(_secondsBefore);
return currentTime >= threshold ? firstTimestep : nullptr;
@@ -487,13 +487,10 @@ void RenderableTimeVaryingVolume::render(const RenderData& data, RendererTasks&
}
}
bool RenderableTimeVaryingVolume::isReady() const {
return true;
}
void RenderableTimeVaryingVolume::deinitializeGL() {
if (_raycaster) {
OsEng.renderEngine().raycasterManager().detachRaycaster(*_raycaster.get());
@@ -47,7 +47,7 @@ class RenderableTimeVaryingVolume : public Renderable {
public:
RenderableTimeVaryingVolume(const ghoul::Dictionary& dictionary);
~RenderableTimeVaryingVolume();
void initializeGL() override;
void deinitializeGL() override;
bool isReady() const override;
+3 -4
View File
@@ -426,7 +426,8 @@ void OpenSpaceEngine::create(int argc, char** argv,
sgctArguments.insert(sgctArguments.begin() + 2, absPath(sgctConfigurationPath));
// Set up asset loader
std::unique_ptr<SynchronizationWatcher> w = std::make_unique<SynchronizationWatcher>();
std::unique_ptr<SynchronizationWatcher> w =
std::make_unique<SynchronizationWatcher>();
SynchronizationWatcher* rawWatcher = w.get();
_engine->_assetManager = std::make_unique<AssetManager>(
@@ -437,7 +438,6 @@ void OpenSpaceEngine::create(int argc, char** argv,
),
std::move(w)
);
//_engine->_globalPropertyNamespace->addPropertySubOwner(_engine->_assetLoader->rootAsset());
}
void OpenSpaceEngine::destroy() {
@@ -767,7 +767,7 @@ void OpenSpaceEngine::deinitialize() {
for (const auto& func : _engine->_moduleCallbacks.deinitialize) {
func();
}
_engine->assetManager().deinitialize();
_engine->_scene = nullptr;
@@ -901,7 +901,6 @@ void OpenSpaceEngine::loadFonts() {
}
}
void OpenSpaceEngine::configureLogging(bool consoleLog) {
const std::string KeyLogLevel =
ConfigurationManager::KeyLogging + '.' + ConfigurationManager::PartLogLevel;
+2 -1
View File
@@ -61,7 +61,8 @@ void SettingsEngine::initialize() {
// Load all matching files in the Scene
// TODO: match regex with either with new ghoul readFiles or local code
const std::string sceneDir = "${ASSETS}";
const std::vector<std::string> scenes = ghoul::filesystem::Directory(sceneDir).readFiles();
const std::vector<std::string> scenes =
ghoul::filesystem::Directory(sceneDir).readFiles();
const size_t nScenes = scenes.size();
for (std::size_t i = 0; i < nScenes; ++i) {
+1 -1
View File
@@ -49,7 +49,7 @@ int unloadMission(lua_State* L) {
if (missionName.empty()) {
return luaL_error(L, "Missing name is empty");
}
if (!MissionManager::ref().hasMission(missionName)) {
return luaL_error(L, "Mission was not previously loaded");
}
+52 -34
View File
@@ -69,7 +69,7 @@ ABufferRenderer::ABufferRenderer()
, _resolveProgram(nullptr)
, _hdrExposure(0.4)
, _hdrBackground(2.8)
, _gamma(2.2)
, _gamma(2.2)
{}
ABufferRenderer::~ABufferRenderer() {}
@@ -165,7 +165,6 @@ void ABufferRenderer::initialize() {
}
OsEng.renderEngine().raycasterManager().addListener(*this);
}
void ABufferRenderer::deinitialize() {
@@ -252,39 +251,40 @@ void ABufferRenderer::updateMSAASamplingPattern() {
sizeY = 1.0f;
const int NVERTEX = 4 * 6;
GLfloat openPixelSizeVertexData[GRIDSIZE * GRIDSIZE * NVERTEX];
// openPixelSizeVertexData
GLfloat vertexData[GRIDSIZE * GRIDSIZE * NVERTEX];
for (int y = 0; y < GRIDSIZE; ++y) {
for (int x = 0; x < GRIDSIZE; ++x) {
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX] = sizeX;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 1] = sizeY - step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 2] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 3] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX] = sizeX;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 1] = sizeY - step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 2] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 3] = 1.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 4] = sizeX + step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 5] = sizeY;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 6] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 7] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 4] = sizeX + step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 5] = sizeY;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 6] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 7] = 1.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 8] = sizeX;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 9] = sizeY;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 10] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 11] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 8] = sizeX;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 9] = sizeY;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 10] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 11] = 1.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 12] = sizeX;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 13] = sizeY - step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 14] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 15] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 12] = sizeX;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 13] = sizeY - step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 14] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 15] = 1.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 16] = sizeX + step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 17] = sizeY - step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 18] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 19] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 16] = sizeX + step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 17] = sizeY - step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 18] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 19] = 1.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 20] = sizeX + step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 21] = sizeY;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 22] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 23] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 20] = sizeX + step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 21] = sizeY;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 22] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 23] = 1.0f;
sizeX += step;
}
@@ -301,7 +301,12 @@ void ABufferRenderer::updateMSAASamplingPattern() {
glGenBuffers(1, &pixelSizeQuadVBO);
glBindBuffer(GL_ARRAY_BUFFER, pixelSizeQuadVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * GRIDSIZE * GRIDSIZE * NVERTEX, openPixelSizeVertexData, GL_STATIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
sizeof(GLfloat) * GRIDSIZE * GRIDSIZE * NVERTEX,
vertexData,
GL_STATIC_DRAW
);
// Position
glVertexAttribPointer(
@@ -341,7 +346,13 @@ void ABufferRenderer::updateMSAASamplingPattern() {
glGenFramebuffers(1, &pixelSizeFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, pixelSizeFramebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, pixelSizeTexture, 0);
glFramebufferTexture2D(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D_MULTISAMPLE,
pixelSizeTexture,
0
);
GLenum textureBuffers[1] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, textureBuffers);
@@ -443,7 +454,12 @@ void ABufferRenderer::updateMSAASamplingPattern() {
glBindVertexArray(nOneStripVAO);
glGenBuffers(1, &nOneStripVBO);
glBindBuffer(GL_ARRAY_BUFFER, nOneStripVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * _nAaSamples * (NVERTEX + 12), nOneStripVertexData, GL_STATIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
sizeof(GLfloat) * _nAaSamples * (NVERTEX + 12),
nOneStripVertexData,
GL_STATIC_DRAW
);
// position
glVertexAttribPointer(
@@ -543,11 +559,13 @@ void ABufferRenderer::updateMSAASamplingPattern() {
saveTextureToMemory(GL_COLOR_ATTACHMENT0, _nAaSamples, 1, _mSAAPattern);
// Convert back to [-1, 1] range and then scales to the current viewport size:
for (int d = 0; d < _nAaSamples; ++d) {
_mSAAPattern[d * 3] = (2.0 * _mSAAPattern[d * 3] - 1.0) / static_cast<double>(viewport[2]);
_mSAAPattern[(d * 3) + 1] = (2.0 * _mSAAPattern[(d * 3) + 1] - 1.0) / static_cast<double>(viewport[3]);
_mSAAPattern[d * 3] = (2.0 * _mSAAPattern[d * 3] - 1.0) /
static_cast<double>(viewport[2]);
_mSAAPattern[(d * 3) + 1] = (2.0 * _mSAAPattern[(d * 3) + 1] - 1.0) /
static_cast<double>(viewport[3]);
_mSAAPattern[(d * 3) + 2] = 0.0;
}
nOneStripProgram->deactivate();
// Restores default state
@@ -565,7 +583,7 @@ void ABufferRenderer::updateMSAASamplingPattern() {
glDeleteBuffers(1, &nOneStripVBO);
glDeleteVertexArrays(1, &nOneStripVAO);
}
void ABufferRenderer::render(float blackoutFactor, bool doPerformanceMeasurements) {
PerfMeasure("ABufferRenderer::render");
+14 -8
View File
@@ -1,4 +1,4 @@
/*****************************************************************************************
/*****************************************************************************************
* *
* OpenSpace *
* *
@@ -23,14 +23,12 @@
****************************************************************************************/
#include <openspace/rendering/deferredcastermanager.h>
#include <openspace/rendering/deferredcasterlistener.h>
#include <algorithm>
#include <string>
namespace {
const char* _loggerCat = "DeferredcasterManager";
}
namespace openspace {
DeferredcasterManager::DeferredcasterManager() = default;
@@ -47,7 +45,11 @@ void DeferredcasterManager::attachDeferredcaster(Deferredcaster& deferredcaster)
}
void DeferredcasterManager::detachDeferredcaster(Deferredcaster& deferredcaster) {
auto it = std::find(_deferredcasters.begin(), _deferredcasters.end(), &deferredcaster);
auto it = std::find(
_deferredcasters.begin(),
_deferredcasters.end(),
&deferredcaster
);
if (it != _deferredcasters.end()) {
_deferredcasters.erase(it);
for (auto &listener : _listeners) {
@@ -57,7 +59,11 @@ void DeferredcasterManager::detachDeferredcaster(Deferredcaster& deferredcaster)
}
bool DeferredcasterManager::isAttached(Deferredcaster& deferredcaster) {
auto it = std::find(_deferredcasters.begin(), _deferredcasters.end(), &deferredcaster);
auto it = std::find(
_deferredcasters.begin(),
_deferredcasters.end(),
&deferredcaster
);
return it != _deferredcasters.end();
}
@@ -79,4 +85,4 @@ const std::vector<Deferredcaster*>& DeferredcasterManager::deferredcasters() {
return _deferredcasters;
}
}
} // namespace openspace
+193 -103
View File
@@ -80,7 +80,7 @@ FramebufferRenderer::FramebufferRenderer()
, _resolution(glm::vec2(0))
, _hdrExposure(0.4f)
, _hdrBackground(2.8f)
, _gamma(2.2f)
, _gamma(2.2f)
{}
FramebufferRenderer::~FramebufferRenderer() {}
@@ -139,15 +139,45 @@ void FramebufferRenderer::initialize() {
updateResolution();
updateRendererData();
updateRaycastData();
glBindFramebuffer(GL_FRAMEBUFFER, _mainFramebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, _mainColorTexture, 0);
glFramebufferTexture2D(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D_MULTISAMPLE,
_mainColorTexture,
0
);
// G-buffer
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D_MULTISAMPLE, _mainOtherDataTexture, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D_MULTISAMPLE, _mainPositionTexture, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D_MULTISAMPLE, _mainNormalTexture, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE, _mainDepthTexture, 0);
glFramebufferTexture2D(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT1,
GL_TEXTURE_2D_MULTISAMPLE,
_mainOtherDataTexture,
0
);
glFramebufferTexture2D(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT2,
GL_TEXTURE_2D_MULTISAMPLE,
_mainPositionTexture,
0
);
glFramebufferTexture2D(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT3,
GL_TEXTURE_2D_MULTISAMPLE,
_mainNormalTexture,
0
);
glFramebufferTexture2D(
GL_FRAMEBUFFER,
GL_DEPTH_ATTACHMENT,
GL_TEXTURE_2D_MULTISAMPLE,
_mainDepthTexture,
0
);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
LERROR("Main framebuffer is not complete");
@@ -175,7 +205,13 @@ void FramebufferRenderer::initialize() {
}
glBindFramebuffer(GL_FRAMEBUFFER, _deferredFramebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _deferredColorTexture, 0);
glFramebufferTexture2D(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D,
_deferredColorTexture,
0
);
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
@@ -222,7 +258,6 @@ void FramebufferRenderer::deinitialize() {
glDeleteTextures(1, &_exitColorTexture);
glDeleteTextures(1, &_exitDepthTexture);
glDeleteBuffers(1, &_vertexPositionBuffer);
glDeleteVertexArrays(1, &_screenQuad);
@@ -234,7 +269,9 @@ void FramebufferRenderer::raycastersChanged(VolumeRaycaster&, bool) {
_dirtyRaycastData = true;
}
void FramebufferRenderer::deferredcastersChanged(Deferredcaster& deferredcaster, ghoul::Boolean isAttached) {
void FramebufferRenderer::deferredcastersChanged(Deferredcaster& deferredcaster,
ghoul::Boolean isAttached)
{
(void) deferredcaster;
(void) isAttached;
_dirtyDeferredcastData = true;
@@ -334,7 +371,7 @@ void FramebufferRenderer::updateResolution() {
nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _mainOtherDataTexture);
@@ -485,46 +522,51 @@ void FramebufferRenderer::updateRaycastData() {
void FramebufferRenderer::updateDeferredcastData() {
_deferredcastData.clear();
_deferredcastPrograms.clear();
const std::vector<Deferredcaster*>& deferredcasters = OsEng.renderEngine().deferredcasterManager().deferredcasters();
const std::vector<Deferredcaster*>& deferredcasters =
OsEng.renderEngine().deferredcasterManager().deferredcasters();
int nextId = 0;
for (auto &deferredcaster : deferredcasters) {
for (auto& caster : deferredcasters) {
DeferredcastData data;
data.id = nextId++;
data.namespaceName = "HELPER";
std::string vsPath = deferredcaster->deferredcastVSPath();
std::string fsPath = deferredcaster->deferredcastFSPath();
std::string deferredShaderPath = deferredcaster->deferredcastPath();
std::string vsPath = caster->deferredcastVSPath();
std::string fsPath = caster->deferredcastFSPath();
std::string deferredShaderPath = caster->deferredcastPath();
ghoul::Dictionary dict;
dict.setValue("rendererData", _rendererData);
//dict.setValue("fragmentPath", fsPath);
dict.setValue("id", data.id);
std::string helperPath = deferredcaster->helperPath();
std::string helperPath = caster->helperPath();
ghoul::Dictionary helpersDict;
if (helperPath != "") {
helpersDict.setValue("0", helperPath);
}
dict.setValue("helperPaths", helpersDict);
//dict.setValue("deferredcastPath", deferredcaster->getDeferredcastPath());
//dict.setValue("deferredcastPath", caster->getDeferredcastPath());
_deferredcastData[deferredcaster] = data;
_deferredcastData[caster] = data;
try {
ghoul::Dictionary deferredDict = dict;
//deferredDict.setValue("getEntryPath", GetEntryOutsidePath);
_deferredcastPrograms[deferredcaster] = ghoul::opengl::ProgramObject::Build(
_deferredcastPrograms[caster] = ghoul::opengl::ProgramObject::Build(
"Deferred " + std::to_string(data.id) + " raycast",
absPath(vsPath),
absPath(deferredShaderPath),
deferredDict);
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
_deferredcastPrograms[deferredcaster]->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes);
_deferredcastPrograms[deferredcaster]->setIgnoreUniformLocationError(IgnoreError::Yes);
_deferredcastPrograms[caster]->setIgnoreSubroutineUniformLocationError(
IgnoreError::Yes
);
_deferredcastPrograms[caster]->setIgnoreUniformLocationError(
IgnoreError::Yes
);
}
catch (ghoul::RuntimeError e) {
LERROR(e.message);
catch (ghoul::RuntimeError& e) {
LERRORC(e.component, e.message);
}
}
@@ -549,46 +591,47 @@ void FramebufferRenderer::updateHDRData() {
void FramebufferRenderer::updateMSAASamplingPattern() {
LINFO("Updating MSAA Sampling Pattern");
const int GRIDSIZE = 32;
GLfloat step = 2.0f / static_cast<GLfloat>(GRIDSIZE);
GLfloat sizeX = -1.0f,
sizeY = 1.0f;
const int NVERTEX = 4 * 6;
GLfloat openPixelSizeVertexData[GRIDSIZE * GRIDSIZE * NVERTEX];
// openPixelSizeVertexData
GLfloat vertexData[GRIDSIZE * GRIDSIZE * NVERTEX];
for (int y = 0; y < GRIDSIZE; ++y) {
for (int x = 0; x < GRIDSIZE; ++x) {
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX] = sizeX;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 1] = sizeY - step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 2] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 3] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX] = sizeX;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 1] = sizeY - step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 2] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 3] = 1.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 4] = sizeX + step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 5] = sizeY;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 6] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 7] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 4] = sizeX + step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 5] = sizeY;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 6] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 7] = 1.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 8] = sizeX;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 9] = sizeY;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 10] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 11] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 8] = sizeX;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 9] = sizeY;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 10] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 11] = 1.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 12] = sizeX;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 13] = sizeY - step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 14] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 15] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 12] = sizeX;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 13] = sizeY - step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 14] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 15] = 1.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 16] = sizeX + step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 17] = sizeY - step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 18] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 19] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 16] = sizeX + step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 17] = sizeY - step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 18] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 19] = 1.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 20] = sizeX + step;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 21] = sizeY;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 22] = 0.0f;
openPixelSizeVertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 23] = 1.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 20] = sizeX + step;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 21] = sizeY;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 22] = 0.0f;
vertexData[y * GRIDSIZE * NVERTEX + x * NVERTEX + 23] = 1.0f;
sizeX += step;
}
@@ -596,8 +639,8 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
sizeY -= step;
}
GLuint pixelSizeQuadVAO = 0,
pixelSizeQuadVBO = 0;
GLuint pixelSizeQuadVAO = 0;
GLuint pixelSizeQuadVBO = 0;
glGenVertexArrays(1, &pixelSizeQuadVAO);
glBindVertexArray(pixelSizeQuadVAO);
@@ -605,8 +648,13 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
glGenBuffers(1, &pixelSizeQuadVBO);
glBindBuffer(GL_ARRAY_BUFFER, pixelSizeQuadVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * GRIDSIZE * GRIDSIZE * NVERTEX, openPixelSizeVertexData, GL_STATIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
sizeof(GLfloat) * GRIDSIZE * GRIDSIZE * NVERTEX,
vertexData,
GL_STATIC_DRAW
);
// Position
glVertexAttribPointer(
0,
@@ -627,7 +675,7 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
// Main framebuffer
GLuint pixelSizeTexture = 0;
GLuint pixelSizeFramebuffer = 0;
glGenTextures(1, &pixelSizeTexture);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, pixelSizeTexture);
@@ -640,12 +688,18 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
ONEPIXEL,
true
);
glViewport(0, 0, ONEPIXEL, ONEPIXEL);
glGenFramebuffers(1, &pixelSizeFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, pixelSizeFramebuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, pixelSizeTexture, 0);
glFramebufferTexture2D(
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D_MULTISAMPLE,
pixelSizeTexture,
0
);
GLenum textureBuffers[1] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, textureBuffers);
@@ -658,7 +712,7 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
LERROR("MSAA Sampling pattern framebuffer is not complete");
return;
}
std::unique_ptr<ghoul::opengl::ProgramObject> pixelSizeProgram = nullptr;
try {
pixelSizeProgram = ghoul::opengl::ProgramObject::Build(
@@ -677,20 +731,20 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
glEnable(GL_SAMPLE_SHADING);
glBindVertexArray(pixelSizeQuadVAO);
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
glDepthMask(false);
glDrawArrays(GL_TRIANGLES, 0, GRIDSIZE * GRIDSIZE * 6);
glBindVertexArray(0);
glDepthMask(true);
glEnable(GL_DEPTH_TEST);
glDisable(GL_SAMPLE_SHADING);
pixelSizeProgram->deactivate();
// Now we render the Nx1 quad strip
GLuint nOneStripFramebuffer = 0,
nOneStripVAO = 0,
nOneStripVBO = 0,
nOneStripTexture = 0;
GLuint nOneStripFramebuffer = 0;
GLuint nOneStripVAO = 0;
GLuint nOneStripVBO = 0;
GLuint nOneStripTexture = 0;
sizeX = -1.0f;
step = 2.0f / static_cast<GLfloat>(_nAaSamples);
@@ -740,15 +794,20 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
nOneStripVertexData[x * (NVERTEX + 12) + 34] = 1.0f;
nOneStripVertexData[x * (NVERTEX + 12) + 35] = 1.0f;
sizeX += step;
sizeX += step;
}
glGenVertexArrays(1, &nOneStripVAO);
glBindVertexArray(nOneStripVAO);
glGenBuffers(1, &nOneStripVBO);
glBindBuffer(GL_ARRAY_BUFFER, nOneStripVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * _nAaSamples * (NVERTEX + 12), nOneStripVertexData, GL_STATIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
sizeof(GLfloat) * _nAaSamples * (NVERTEX + 12),
nOneStripVertexData,
GL_STATIC_DRAW
);
// position
glVertexAttribPointer(
0,
@@ -789,7 +848,7 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glGenFramebuffers(1, &nOneStripFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, nOneStripFramebuffer);
glFramebufferTexture2D(
@@ -804,7 +863,7 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
if (status != GL_FRAMEBUFFER_COMPLETE) {
LERROR("nOneStrip framebuffer is not complete");
}
glViewport(0, 0, _nAaSamples, ONEPIXEL);
std::unique_ptr<ghoul::opengl::ProgramObject> nOneStripProgram = nullptr;
@@ -825,7 +884,7 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
pixelSizeTextureUnit.activate();
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, pixelSizeTexture);
nOneStripProgram->setUniform("pixelSizeTexture", pixelSizeTextureUnit);
// render strip
glDrawBuffers(1, textureBuffers);
@@ -834,6 +893,7 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
glBindVertexArray(nOneStripVAO);
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
for (int sample = 0; sample < _nAaSamples; ++sample) {
nOneStripProgram->setUniform("currentSample", sample);
glDrawArrays(GL_TRIANGLES, sample * 6, 6);
@@ -844,20 +904,22 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
saveTextureToMemory(GL_COLOR_ATTACHMENT0, _nAaSamples, 1, _mSAAPattern);
// Convert back to [-1, 1] range and then scale for the current viewport size:
for (int d = 0; d < _nAaSamples; ++d) {
_mSAAPattern[d * 3] = (2.0 * _mSAAPattern[d * 3] - 1.0) / static_cast<double>(viewport[2]);
_mSAAPattern[(d * 3) + 1] = (2.0 * _mSAAPattern[(d * 3) + 1] - 1.0) / static_cast<double>(viewport[3]);
for (int d = 0; d < _nAaSamples; ++d) {
_mSAAPattern[d * 3] = (2.0 * _mSAAPattern[d * 3] - 1.0) /
static_cast<double>(viewport[2]);
_mSAAPattern[(d * 3) + 1] = (2.0 * _mSAAPattern[(d * 3) + 1] - 1.0) /
static_cast<double>(viewport[3]);
_mSAAPattern[(d * 3) + 2] = 0.0;
}
nOneStripProgram->deactivate();
// Restores default state
glBindFramebuffer(GL_FRAMEBUFFER, defaultFbo);
glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
// Deletes unused buffers
glDeleteFramebuffers(1, &pixelSizeFramebuffer);
glDeleteFramebuffers(1, &pixelSizeFramebuffer);
glDeleteTextures(1, &pixelSizeTexture);
glDeleteBuffers(1, &pixelSizeQuadVBO);
glDeleteVertexArrays(1, &pixelSizeQuadVAO);
@@ -865,7 +927,7 @@ void FramebufferRenderer::updateMSAASamplingPattern() {
glDeleteFramebuffers(1, &nOneStripFramebuffer);
glDeleteTextures(1, &nOneStripTexture);
glDeleteBuffers(1, &nOneStripVBO);
glDeleteVertexArrays(1, &nOneStripVAO);
glDeleteVertexArrays(1, &nOneStripVAO);
}
void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasurements) {
@@ -896,7 +958,12 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure
glBindFramebuffer(GL_FRAMEBUFFER, _mainFramebuffer);
// deferred g-buffer
GLenum textureBuffers[4] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
GLenum textureBuffers[4] = {
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2,
GL_COLOR_ATTACHMENT3
};
glDrawBuffers(4, textureBuffers);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -971,7 +1038,6 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure
raycastProgram->setUniform("nAaSamples", _nAaSamples);
raycastProgram->setUniform("windowSize", _resolution);
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
if (cameraIsInside) {
@@ -997,8 +1063,8 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure
glBindFramebuffer(GL_FRAMEBUFFER, defaultFbo);
GLenum dBuffer[1] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, dBuffer);
glClear(GL_COLOR_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT);
bool firstPaint = true;
for (const DeferredcasterTask& deferredcasterTask : tasks.deferredcasterTasks) {
@@ -1020,23 +1086,34 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure
ghoul::opengl::TextureUnit mainDColorTextureUnit;
mainDColorTextureUnit.activate();
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _mainColorTexture);
deferredcastProgram->setUniform("mainColorTexture", mainDColorTextureUnit);
deferredcastProgram->setUniform(
"mainColorTexture",
mainDColorTextureUnit
);
ghoul::opengl::TextureUnit otherDataTextureUnit;
otherDataTextureUnit.activate();
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _mainOtherDataTexture);
deferredcastProgram->setUniform("otherDataTexture", otherDataTextureUnit);
deferredcastProgram->setUniform(
"otherDataTexture",
otherDataTextureUnit
);
ghoul::opengl::TextureUnit mainPositionTextureUnit;
mainPositionTextureUnit.activate();
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _mainPositionTexture);
deferredcastProgram->setUniform("mainPositionTexture", mainPositionTextureUnit);
deferredcastProgram->setUniform(
"mainPositionTexture",
mainPositionTextureUnit
);
ghoul::opengl::TextureUnit mainNormalTextureUnit;
mainNormalTextureUnit.activate();
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, _mainNormalTexture);
deferredcastProgram->setUniform("mainNormalTexture", mainNormalTextureUnit);
deferredcastProgram->setUniform(
"mainNormalTexture",
mainNormalTextureUnit
);
deferredcastProgram->setUniform("nAaSamples", _nAaSamples);
// 48 = 16 samples * 3 coords
@@ -1046,9 +1123,11 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure
deferredcastProgram->setUniform("atmExposure", _hdrExposure);
deferredcastProgram->setUniform("backgroundConstant", _hdrBackground);
deferredcaster->preRaycast(deferredcasterTask.renderData,
deferredcaster->preRaycast(
deferredcasterTask.renderData,
_deferredcastData[deferredcaster],
*deferredcastProgram);
*deferredcastProgram
);
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
@@ -1071,15 +1150,17 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure
}
}
else {
LWARNING("Deferredcaster is not attached when trying to perform deferred task");
LWARNING(
"Deferredcaster is not attached when trying to perform deferred task"
);
}
}
}
if (!tasks.deferredcasterTasks.empty()) {
// JCC: Temporarily disabled. Need to test it on mac and linux before final merging.
/*glBindFramebuffer(GL_READ_FRAMEBUFFER, _deferredFramebuffer);
// JCC: Temporarily disabled. Need to test it on mac and linux before final
// merging.
/*glBindFramebuffer(GL_READ_FRAMEBUFFER, _deferredFramebuffer);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, defaultFbo);
GLenum dBuffer[] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, dBuffer);
@@ -1145,7 +1226,7 @@ void FramebufferRenderer::setHDRBackground(float hdrBackground) {
_hdrBackground = hdrBackground;
if (_hdrBackground < 0.0f) {
LERROR("HDR Background constant must be greater than zero.");
_hdrBackground = 1.0f;
_hdrBackground = 1.0f;
}
}
@@ -1179,8 +1260,8 @@ void FramebufferRenderer::updateRendererData() {
}
void saveTextureToPPMFile(const GLenum color_buffer_attachment,
const std::string & fileName,
const int width, const int height) {
const std::string & fileName, const int width, const int height)
{
std::fstream ppmFile;
ppmFile.open(fileName.c_str(), std::fstream::out);
@@ -1195,7 +1276,15 @@ void saveTextureToPPMFile(const GLenum color_buffer_attachment,
}
else {
glReadPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, pixels);
glReadPixels(
0,
0,
width,
height,
GL_DEPTH_COMPONENT,
GL_UNSIGNED_BYTE,
pixels
);
}
ppmFile << "P3" << std::endl;
@@ -1206,7 +1295,9 @@ void saveTextureToPPMFile(const GLenum color_buffer_attachment,
int k = 0;
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
ppmFile << (unsigned int)pixels[k] << " " << (unsigned int)pixels[k + 1] << " " << (unsigned int)pixels[k + 2] << " ";
ppmFile << (unsigned int)pixels[k] << " "
<< (unsigned int)pixels[k + 1] << " "
<< (unsigned int)pixels[k + 2] << " ";
k += 3;
}
ppmFile << std::endl;
@@ -1243,5 +1334,4 @@ void saveTextureToMemory(const GLenum color_buffer_attachment,
delete[] tempMemory;
}
} // namespace openspace
+27 -451
View File
@@ -1,26 +1,26 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/renderengine.h>
@@ -207,7 +207,8 @@ namespace {
static const openspace::properties::Property::PropertyInfo GammaInfo = {
"Gamma",
"Gamma Correction",
"Gamma, is the nonlinear operation used to encode and decode luminance or tristimulus values in the image."
"Gamma, is the nonlinear operation used to encode and decode luminance or "
"tristimulus values in the image."
};
} // namespace
@@ -438,7 +439,7 @@ void RenderEngine::initializeGL() {
LINFO("Finished initializing GL");
LTRACE("RenderEngine::initializeGL(end)");
}
void RenderEngine::deinitialize() {
for (std::shared_ptr<ScreenSpaceRenderable>& ssr : _screenSpaceRenderables) {
ssr->deinitialize();
@@ -595,7 +596,7 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat
10.f,
fontResolution().y
);
penPosition.y -= OsEng.console().currentHeight();
OsEng.dashboard().render(penPosition);
@@ -905,7 +906,7 @@ scripting::LuaLibrary RenderEngine::luaLibrary() {
{
"removeScreenSpaceRenderable",
&luascriptfunctions::removeScreenSpaceRenderable,
{},
{},
"string",
"Given a ScreenSpaceRenderable name this script will remove it from the "
"renderengine"
@@ -993,432 +994,7 @@ RenderEngine::RendererImplementation RenderEngine::rendererFromString(
return RendererImplementation::Invalid;
}
}
/*
<<<<<<< HEAD
std::string RenderEngine::progressToStr(int size, double t) {
std::string progress = "|";
int g = static_cast<int>((t * (size - 1)) + 1);
g = std::max(g, 0);
for (int i = 0; i < g; i++) {
progress.append("-");
}
progress.append(">");
for (int i = 0; i < size - g; i++) {
progress.append(" ");
}
progress.append("|");
return progress;
}
void RenderEngine::renderInformation() {
using ghoul::fontrendering::RenderFont;
glm::vec2 penPosition = glm::vec2(
10.f,
fontResolution().y
);
// If the console is opened, move all text downwards
penPosition.y -= OsEng.console().currentHeight();
if (_showDate && _fontDate) {
penPosition.y -= _fontDate->height();
RenderFontCr(
*_fontDate,
penPosition,
"Date: %s",
OsEng.timeManager().time().UTC().c_str()
);
}
else {
penPosition.y -= _fontInfo->height();
}
if (_showInfo && _fontInfo) {
std::pair<double, std::string> deltaTime = simplifyTime(
OsEng.timeManager().time().deltaTime()
);
RenderFontCr(
*_fontInfo,
penPosition,
"Simulation increment: %.1f %s / second",
deltaTime.first,
deltaTime.second.c_str()
);
double distance = glm::length(
_camera->positionVec3() -
OsEng.navigationHandler().focusNode()->worldPosition()
);
std::pair<double, std::string> dist = simplifyDistance(distance);
RenderFontCr(
*_fontInfo,
penPosition,
"Distance from focus: %f %s",
dist.first,
dist.second.c_str()
);
FrametimeType frametimeType = FrametimeType(_frametimeType.value());
switch (frametimeType) {
case FrametimeType::DtTimeAvg:
RenderFontCr(
*_fontInfo,
penPosition,
"Avg. Frametime: %.5f",
OsEng.windowWrapper().averageDeltaTime()
);
break;
case FrametimeType::FPS:
RenderFontCr(
*_fontInfo,
penPosition,
"FPS: %3.2f",
1.0 / OsEng.windowWrapper().deltaTime()
);
break;
case FrametimeType::FPSAvg:
RenderFontCr(
*_fontInfo,
penPosition,
"Avg. FPS: %3.2f",
1.0 / OsEng.windowWrapper().averageDeltaTime()
);
break;
case FrametimeType::None:
break;
}
ParallelConnection::Status status = OsEng.parallelConnection().status();
size_t nConnections = OsEng.parallelConnection().nConnections();
const std::string& hostName = OsEng.parallelConnection().hostName();
std::string connectionInfo = "";
int nClients = static_cast<int>(nConnections);
if (status == ParallelConnection::Status::Host) {
nClients--;
if (nClients == 1) {
connectionInfo = "Hosting session with 1 client";
}
else {
connectionInfo =
"Hosting session with " + std::to_string(nClients) + " clients";
}
}
else if (status == ParallelConnection::Status::ClientWithHost) {
nClients--;
connectionInfo = "Session hosted by '" + hostName + "'";
}
else if (status == ParallelConnection::Status::ClientWithoutHost) {
connectionInfo = "Host is disconnected";
}
if (status == ParallelConnection::Status::ClientWithHost ||
status == ParallelConnection::Status::ClientWithoutHost) {
connectionInfo += "\n";
if (nClients > 2) {
std::string c = std::to_string(nClients - 1);
connectionInfo += "You and " + c + " more clients are tuned in";
}
else if (nClients == 2) {
std::string c = std::to_string(nClients - 1);
connectionInfo += "You and " + c + " more client are tuned in";
}
else if (nClients == 1) {
connectionInfo += "You are the only client";
}
}
if (!connectionInfo.empty()) {
RenderFontCr(
*_fontInfo,
penPosition,
connectionInfo.c_str()
);
}
#ifdef OPENSPACE_MODULE_SPACECRAFTINSTRUMENTS_ENABLED
bool hasNewHorizons = scene()->sceneGraphNode("NewHorizons");
double currentTime = OsEng.timeManager().time().j2000Seconds();
//if (MissionManager::ref().hasCurrentMission()) {
// const Mission& mission = MissionManager::ref().currentMission();
// if (mission.phases().size() > 0) {
// static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1);
// //static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1);
// static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1);
// static const glm::vec4 missionProgressColor = currentMissionColor;
// // static const glm::vec4 currentLeafMissionColor = missionProgressColor;
// static const glm::vec4 nonCurrentMissionColor(0.3, 0.3, 0.3, 1);
// // Add spacing
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, " ");
// auto phaseTrace = mission.phaseTrace(currentTime);
// if (phaseTrace.size()) {
// const MissionPhase& phase = phaseTrace.back().get();
// std::string title = "Current Mission Phase: " + phase.name();
// RenderFontCr(
// *_fontInfo,
// penPosition,
// missionProgressColor,
// title.c_str()
// );
// double remaining = phase.timeRange().end - currentTime;
// float t = static_cast<float>(
// 1.0 - remaining / phase.timeRange().duration()
// );
// std::string progress = progressToStr(25, t);
// //RenderFontCr(*_fontInfo, penPosition, missionProgressColor,
// // "%.0f s %s %.1f %%", remaining, progress.c_str(), t * 100);
// }
// else {
// RenderFontCr(
// *_fontInfo,
// penPosition,
// nextMissionColor,
// "Next Mission:"
// );
// double remaining = mission.timeRange().start - currentTime;
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor,
// "%.0f s", remaining);
// }
// bool showAllPhases = false;
// typedef std::pair<const MissionPhase*, int> PhaseWithDepth;
// std::stack<PhaseWithDepth> S;
// int pixelIndentation = 20;
// S.push({ &mission, 0 });
// while (!S.empty()) {
// const MissionPhase* phase = S.top().first;
// int depth = S.top().second;
// S.pop();
// bool isCurrentPhase = phase->timeRange().includes(currentTime);
// penPosition.x += depth * pixelIndentation;
// if (isCurrentPhase) {
// double remaining = phase->timeRange().end - currentTime;
// float t = static_cast<float>(
// 1.0 - remaining / phase->timeRange().duration()
// );
// std::string progress = progressToStr(25, t);
// RenderFontCr(*_fontInfo, penPosition, currentMissionColor,
// "%s %s %.1f %%",
// phase->name().c_str(),
// progress.c_str(),
// t * 100
// );
// }
// else {
// RenderFontCr(
// *_fontInfo,
// penPosition,
// nonCurrentMissionColor,
// phase->name().c_str()
// );
// }
// penPosition.x -= depth * pixelIndentation;
// if (isCurrentPhase || showAllPhases) {
// // phases are sorted increasingly by start time, and will be
// // popped last-in-first-out from the stack, so add them in
// // reversed order.
// int indexLastPhase = static_cast<int>(
// phase->phases().size()
// ) - 1;
// for (int i = indexLastPhase; 0 <= i; --i) {
// S.push({ &phase->phases()[i], depth + 1 });
// }
// }
// }
// }
// }
if (openspace::ImageSequencer::ref().isReady()) {
penPosition.y -= 25.f;
glm::vec4 targetColor(0.00, 0.75, 1.00, 1);
if (hasNewHorizons) {
try {
double lt;
glm::dvec3 p = SpiceManager::ref().targetPosition(
"PLUTO",
"NEW HORIZONS",
"GALACTIC",
{},
currentTime,
lt
);
psc nhPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(
p.x,
p.y,
p.z
);
float a, b;
glm::dvec3 radii;
SpiceManager::ref().getValue("PLUTO", "RADII", radii);
a = static_cast<float>(radii.x);
b = static_cast<float>(radii.y);
float radius = (a + b) / 2.f;
float distToSurf = glm::length(nhPos.vec3()) - radius;
RenderFont(*_fontInfo,
penPosition,
"Distance to Pluto: % .1f (KM)",
distToSurf
);
penPosition.y -= _fontInfo->height();
}
catch (...) {
// @CLEANUP: This is bad as it will discard all exceptions
// without telling us about it! ---abock
}
}
double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() -
currentTime;
float t = static_cast<float>(
1.0 - remaining / openspace::ImageSequencer::ref().getIntervalLength()
);
std::string str = SpiceManager::ref().dateFromEphemerisTime(
ImageSequencer::ref().getNextCaptureTime(),
"YYYY MON DD HR:MN:SC"
);
glm::vec4 active(0.6, 1, 0.00, 1);
glm::vec4 brigther_active(0.9, 1, 0.75, 1);
if (remaining > 0) {
std::string progress = progressToStr(25, t);
brigther_active *= (1 - t);
RenderFontCr(*_fontInfo,
penPosition,
active * t + brigther_active,
"Next instrument activity:"
);
RenderFontCr(*_fontInfo,
penPosition,
active * t + brigther_active,
"%.0f s %s %.1f %%",
remaining, progress.c_str(), t * 100
);
RenderFontCr(*_fontInfo,
penPosition,
active,
"Data acquisition time: %s",
str.c_str()
);
}
std::pair<double, std::string> nextTarget =
ImageSequencer::ref().getNextTarget();
std::pair<double, std::string> currentTarget =
ImageSequencer::ref().getCurrentTarget();
if (currentTarget.first > 0.0) {
int timeleft = static_cast<int>(nextTarget.first - currentTime);
int hour = timeleft / 3600;
int second = timeleft % 3600;
int minute = second / 60;
second = second % 60;
std::string hh, mm, ss;
if (hour < 10)
hh.append("0");
if (minute < 10)
mm.append("0");
if (second < 10)
ss.append("0");
hh.append(std::to_string(hour));
mm.append(std::to_string(minute));
ss.append(std::to_string(second));
RenderFontCr(*_fontInfo,
penPosition,
targetColor,
"Data acquisition adjacency: [%s:%s:%s]",
hh.c_str(), mm.c_str(), ss.c_str()
);
penPosition.y -= _fontInfo->height();
std::map<std::string, bool> activeMap =
ImageSequencer::ref().getActiveInstruments();
glm::vec4 firing(0.58 - t, 1 - t, 1 - t, 1);
glm::vec4 notFiring(0.5, 0.5, 0.5, 1);
RenderFontCr(*_fontInfo,
penPosition,
active,
"Active Instruments:"
);
for (auto m : activeMap) {
if (m.second == false) {
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
"| |"
);
RenderFontCr(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" %5s",
m.first.c_str()
);
}
else {
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
"|"
);
if (m.first == "NH_LORRI") {
RenderFont(*_fontInfo,
penPosition,
firing,
" + "
);
}
RenderFont(*_fontInfo,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" |"
);
RenderFontCr(*_fontInfo,
penPosition,
active,
" %5s",
m.first.c_str()
);
}
}
}
}
#endif
}
}
=======
>>>>>>> master
*/
void RenderEngine::renderCameraInformation() {
if (!_showCameraInfo) {
return;
+4 -4
View File
@@ -170,8 +170,8 @@ void Asset::requestedAssetChangedState(std::shared_ptr<Asset> child,
}
void Asset::addSynchronization(std::shared_ptr<ResourceSynchronization> synchronization) {
_synchronizations.push_back(synchronization);
_synchronizations.push_back(synchronization);
// Set up callback for synchronization state change
// The synchronization watcher will make sure that callbacks
// are invoked in the main thread.
@@ -185,7 +185,7 @@ void Asset::addSynchronization(std::shared_ptr<ResourceSynchronization> synchron
);
_syncWatches.push_back(watch);
}
void Asset::syncStateChanged(ResourceSynchronization::State state)
{
if (state == ResourceSynchronization::State::Resolved) {
@@ -786,7 +786,7 @@ void Asset::unrequest(std::shared_ptr<Asset> child) {
// Do nothing if the request node not exist.
return;
}
_requestedAssets.erase(childIt);
auto parentIt = std::find_if(
+8 -8
View File
@@ -240,7 +240,7 @@ bool AssetLoader::loadAsset(std::shared_ptr<Asset> asset) {
ghoul::OnScopeExit e([this, parentAsset] {
setCurrentAsset(parentAsset);
});
if (!FileSys.fileExists(asset->assetFilePath())) {
LERROR("Could not load asset '" << asset->assetFilePath() <<
"': File does not exist.");
@@ -299,7 +299,7 @@ std::string AssetLoader::generateAssetPath(const std::string& baseDirectory,
prefix = _assetRootDirectory + ghoul::filesystem::FileSystem::PathSeparator;
}
// Construct the full path including the .asset extension
// Construct the full path including the .asset extension
std::string assetSuffix = std::string(".") + AssetFileSuffix;
bool hasAssetSuffix =
(assetPath.size() > assetSuffix.size()) &&
@@ -310,12 +310,12 @@ std::string AssetLoader::generateAssetPath(const std::string& baseDirectory,
prefix + assetPath + assetSuffix;
bool fullAssetPathExists = FileSys.fileExists(FileSys.absPath(fullAssetPath));
// Construct the full path including the .scene extension
// Construct the full path including the .scene extension
std::string sceneSuffix = std::string(".") + SceneFileSuffix;
bool hasSceneSuffix =
(assetPath.size() > sceneSuffix.size()) &&
(assetPath.substr(assetPath.size() - sceneSuffix.size()) == sceneSuffix);
std::string fullScenePath =
std::string fullScenePath =
hasSceneSuffix ?
prefix + assetPath :
prefix + assetPath + sceneSuffix;
@@ -499,7 +499,7 @@ void AssetLoader::callOnDependencyInitialize(Asset* asset, Asset* dependant) {
lua_rawgeti(*_luaState, LUA_REGISTRYINDEX, init);
if (lua_pcall(*_luaState, 0, 0, 0) != LUA_OK) {
throw ghoul::lua::LuaRuntimeException(
"When initializing dependency " + dependant->assetFilePath() + " -> " +
"When initializing dependency " + dependant->assetFilePath() + " -> " +
asset->assetFilePath() + ": " + luaL_checkstring(*_luaState, -1)
);
}
@@ -602,13 +602,13 @@ int AssetLoader::requireLua(Asset* dependant) {
int AssetLoader::requestLua(Asset* parent) {
int nArguments = lua_gettop(*_luaState);
SCRIPT_CHECK_ARGUMENTS("request", *_luaState, 1, nArguments);
std::string assetName = luaL_checkstring(*_luaState, 1);
std::shared_ptr<Asset> child = request(assetName);
addLuaDependencyTable(parent, child.get());
// Get the dependency table
lua_rawgeti(*_luaState, LUA_REGISTRYINDEX, _assetsTableRef);
lua_getfield(*_luaState, -1, child->id().c_str());
+9 -3
View File
@@ -92,7 +92,7 @@ Scene::Scene(std::unique_ptr<SceneInitializer> initializer)
)
, _dirtyNodeRegistry(false)
, _initializer(std::move(initializer))
{
{
_rootDummy.setName(SceneGraphNode::RootNodeName);
_rootDummy.setScene(this);
}
@@ -120,7 +120,9 @@ Camera* Scene::camera() const {
void Scene::registerNode(SceneGraphNode* node) {
if (_nodesByName.count(node->name())){
throw Scene::InvalidSceneError("Node with name " + node->name() + " already exits.");
throw Scene::InvalidSceneError(
"Node with name " + node->name() + " already exits."
);
}
_topologicallySortedNodes.push_back(node);
@@ -130,7 +132,11 @@ void Scene::registerNode(SceneGraphNode* node) {
void Scene::unregisterNode(SceneGraphNode* node) {
_topologicallySortedNodes.erase(
std::remove(_topologicallySortedNodes.begin(), _topologicallySortedNodes.end(), node),
std::remove(
_topologicallySortedNodes.begin(),
_topologicallySortedNodes.end(),
node
),
_topologicallySortedNodes.end()
);
_nodesByName.erase(node->name());
+1 -2
View File
@@ -1,4 +1,4 @@
/*****************************************************************************************
/*****************************************************************************************
* *
* OpenSpace *
* *
@@ -627,7 +627,6 @@ void SceneGraphNode::setScene(Scene* scene) {
scene->registerNode(node);
}
});
}
std::vector<SceneGraphNode*> SceneGraphNode::children() const {
+1 -1
View File
@@ -35,7 +35,7 @@ void SingleThreadedSceneInitializer::initializeNode(SceneGraphNode* node) {
node->initialize();
_initializedNodes.push_back(node);
}
std::vector<SceneGraphNode*> SingleThreadedSceneInitializer::getInitializedNodes() {
std::vector<SceneGraphNode*> nodes = std::move(_initializedNodes);
return nodes;
+9 -6
View File
@@ -85,9 +85,10 @@ size_t writeCallback(char* ptr, size_t size, size_t nmemb, void* userData) {
HttpRequest* r = reinterpret_cast<HttpRequest*>(userData);
return r->_onData(HttpRequest::Data{ptr, size * nmemb});
}
}
HttpRequest::HttpRequest(std::string url)
} // namespace curlfunctions
HttpRequest::HttpRequest(std::string url)
: _url(std::move(url))
, _onReadyStateChange([](ReadyState) {})
, _onProgress([](Progress) { return 0; })
@@ -128,7 +129,7 @@ void HttpRequest::perform(RequestOptions opt) {
curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlfunctions::writeCallback);
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, this);
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, curlfunctions::progressCallback);
@@ -150,13 +151,13 @@ void HttpRequest::perform(RequestOptions opt) {
}
curl_easy_cleanup(curl);
}
void HttpRequest::setReadyState(openspace::HttpRequest::ReadyState state) {
_readyState = state;
_onReadyStateChange(state);
}
HttpDownload::HttpDownload()
HttpDownload::HttpDownload()
: _onProgress([] (HttpRequest::Progress) { return true; })
{}
@@ -171,6 +172,7 @@ bool HttpDownload::hasStarted() {
bool HttpDownload::hasFailed() {
return _failed;
}
bool HttpDownload::hasSucceeded() {
return _successful;
}
@@ -182,6 +184,7 @@ void HttpDownload::markAsStarted() {
void HttpDownload::markAsFailed() {
_failed = true;
}
void HttpDownload::markAsSuccessful() {
_successful = true;
}
+5 -5
View File
@@ -56,11 +56,11 @@ documentation::Documentation ResourceSynchronization::Documentation() {
"A valid ResourceSyncrhonization created by a factory"
),
Optional::No,
"This key specifies the type of ResourceSyncrhonization that gets created. "
"It has to be one of the valid ResourceSyncrhonizations that are available "
"for creation (see the FactoryDocumentation for a list of possible "
"ResourceSyncrhonizations), which depends on the configration of the "
" application"
"This key specifies the type of ResourceSyncrhonization that gets "
"created. It has to be one of the valid ResourceSyncrhonizations that "
"are available for creation (see the FactoryDocumentation for a list of "
"possible ResourceSyncrhonizations), which depends on the configration "
"of the application"
},
{
KeyName,
+4 -2
View File
@@ -35,7 +35,9 @@ SynchronizationWatcher::WatchHandle SynchronizationWatcher::watchSynchronization
WatchHandle watchHandle = generateWatchHandle();
ResourceSynchronization::CallbackHandle cbh = synchronization->addStateChangeCallback(
[this, synchronization, watchHandle, callback](ResourceSynchronization::State state) {
[this, synchronization, watchHandle, callback]
(ResourceSynchronization::State state)
{
std::lock_guard<std::mutex> g(_mutex);
_pendingNotifications.push_back({
synchronization,
@@ -72,7 +74,7 @@ void SynchronizationWatcher::unwatchSynchronization(
// Remove from the list of watches
_watchedSyncs.erase(it);
// Remove notifications that are pending
_pendingNotifications.erase(std::remove_if(
_pendingNotifications.begin(),
-13
View File
@@ -297,19 +297,6 @@ def check_empty_only_line(lines):
def check_line_length(lines):
# Disable this check in non-strict mode
if not is_strict_mode:
return ''
index = [i + 1 for i, s in enumerate(lines) if len(s) > (90 + 1)]
if len(index) > 0:
return index
else:
return ''
def check_assert_usage(lines):
# _assert checks for both ghoul_assert and static_assert, which are both reasonable
index = [i + 1 for i,s in enumerate(lines) if ('assert(' in s and not '_assert(' in s) and s.strip()[0:2] != '//']