Cleanup for coding style

Add strict mode to check_style_guide script
This commit is contained in:
Alexander Bock
2017-11-08 10:35:39 -06:00
parent d94408224c
commit b50b52d351
387 changed files with 1907 additions and 2132 deletions
+2 -2
View File
@@ -78,7 +78,7 @@ std::unique_ptr<ModelGeometry> ModelGeometry::createFromDictionary(
}
const std::string geometryType = dictionary.value<std::string>(KeyType);
auto factory = FactoryManager::ref().factory<ModelGeometry>();
return factory->create(geometryType, dictionary);;
}
@@ -134,7 +134,7 @@ bool ModelGeometry::initialize(Renderable* parent) {
if (_vertices.empty()) {
return false;
}
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vbo);
glGenBuffers(1, &_ibo);
+2 -2
View File
@@ -53,11 +53,11 @@ public:
ModelGeometry(const ghoul::Dictionary& dictionary);
virtual ~ModelGeometry() = default;
virtual bool initialize(Renderable* parent);
virtual void deinitialize();
void render();
virtual bool loadModel(const std::string& filename) = 0;
void changeRenderMode(const GLenum mode);
//bool getVertices(std::vector<Vertex>* vertexList);
@@ -40,7 +40,7 @@ bool MultiModelGeometry::loadModel(const std::string& filename) {
std::vector<ghoul::io::ModelReaderBase::Vertex> vertices;
std::vector<int> indices;
ghoul::io::ModelReaderMultiFormat().loadModel(filename, vertices, indices);
_vertices.reserve(vertices.size());
for (const ghoul::io::ModelReaderBase::Vertex& v : vertices) {
Vertex vv;
+1 -1
View File
@@ -183,7 +183,7 @@ void RenderableModel::deinitialize() {
void RenderableModel::render(const RenderData& data, RendererTasks&) {
_programObject->activate();
// Model transform and view transform needs to be in double precision
glm::dmat4 modelTransform =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation
+2 -3
View File
@@ -107,7 +107,6 @@ documentation::Documentation RenderablePlane::Documentation() {
};
}
RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _texturePath(TextureInfo)
@@ -237,7 +236,7 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) {
_shader->setUniform("modelViewProjectionTransform",
data.camera.projectionMatrix() * glm::mat4(modelViewTransform));
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
@@ -330,7 +329,7 @@ void RenderablePlane::createPlane() {
sizeof(GLfloat) * 6,
nullptr
);
glEnableVertexAttribArray(1);
glVertexAttribPointer(
1,
+3 -3
View File
@@ -259,13 +259,13 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) {
if (_fadeOutThreshold > -1.0) {
float distCamera = glm::distance(data.camera.positionVec3(), data.position.dvec3());
double term = std::exp((-distCamera + _size * _fadeOutThreshold) / (_size * _fadeOutThreshold));
_shader->setUniform("alpha", _transparency * static_cast<float>(term / (term + 1.0)));
}
else {
_shader->setUniform("alpha", _transparency);
}
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
@@ -273,7 +273,7 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) {
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
bool usingFramebufferRenderer =
OsEng.renderEngine().rendererImplementation() == RenderEngine::RendererImplementation::Framebuffer;
+2 -2
View File
@@ -266,7 +266,7 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) {
bool usingFramebufferRenderer =
OsEng.renderEngine().rendererImplementation() ==
RenderEngine::RendererImplementation::Framebuffer;
if (usingFramebufferRenderer) {
glDepthMask(false);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
@@ -394,7 +394,7 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) {
if (renderPoints) {
glDisable(GL_PROGRAM_POINT_SIZE);
}
glBindVertexArray(0);
if (usingFramebufferRenderer) {
+1 -1
View File
@@ -91,7 +91,7 @@ protected:
/// Returns the documentation entries that the con
static documentation::Documentation Documentation();
/// The layout of the VBOs
struct TrailVBOLayout {
float x, y, z;
@@ -382,7 +382,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
// The previously oldest permanent point has been moved nNewPoints steps into the
// future
_firstPointTime += nNewPoints * secondsPerPoint;
return { true, nNewPoints };
}
else {
@@ -47,12 +47,12 @@ namespace documentation { struct Documentation; }
class RenderableTrailOrbit : public RenderableTrail {
public:
explicit RenderableTrailOrbit(const ghoul::Dictionary& dictionary);
void initialize() override;
void deinitialize() override;
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
private:
@@ -87,7 +87,7 @@ namespace openspace {
documentation::Documentation RenderableTrailTrajectory::Documentation() {
using namespace documentation;
documentation::Documentation doc {
"RenderableTrailTrajectory",
"base_renderable_renderabletrailtrajectory",
@@ -244,7 +244,7 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
// We clear the indexArray just in case. The base class will take care not to use
// it if it is empty
_indexArray.clear();
@@ -252,7 +252,7 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
_subsamplingIsDirty = true;
_needsFullSweep = false;
}
// This has to be done every update step;
if (_renderFullTrail) {
// If the full trail should be rendered at all times, we can directly render the
@@ -280,7 +280,7 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
_vertexArray[_primaryRenderInformation.count - 1].y,
_vertexArray[_primaryRenderInformation.count - 1].z
);
// And get the current location of the object
glm::dvec3 p = _translation->position(data.time.j2000Seconds());
glm::dvec3 v1 = { p.x, p.y, p.z };
@@ -57,7 +57,7 @@ public:
void deinitialize() override;
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
private:
@@ -107,7 +107,7 @@ void ScreenSpaceFramebuffer::render() {
);
GLint defaultFBO = _framebuffer->getActiveObject();
_framebuffer->activate();
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_ALPHA_TEST);
@@ -123,7 +123,7 @@ void ScreenSpaceFramebuffer::render() {
static_cast<GLsizei>(resolution.x),
static_cast<GLsizei>(resolution.y)
);
glm::mat4 rotation = rotationMatrix();
glm::mat4 translation = translationMatrix();
glm::mat4 scale = scaleMatrix();
@@ -54,7 +54,7 @@ public:
void setSize(glm::vec4);
void addRenderFunction(std::shared_ptr<std::function<void()>> renderFunction);
void removeAllRenderFunctions();
static documentation::Documentation Documentation();
private:
@@ -30,9 +30,9 @@
#include <openspace/properties/stringproperty.h>
#include <ghoul/opengl/texture.h>
namespace openspace {
namespace documentation { struct Documentation; }
class ScreenSpaceImageLocal : public ScreenSpaceRenderable {
@@ -31,9 +31,9 @@
#include <openspace/properties/stringproperty.h>
#include <ghoul/opengl/texture.h>
namespace openspace {
namespace documentation { struct Documentation; }
class ScreenSpaceImageOnline : public ScreenSpaceRenderable {
@@ -107,7 +107,6 @@ bool WavefrontGeometry::loadModel(const std::string& filename) {
_vertices[j + currentPosition].tex[0] = shapes[i].mesh.texcoords[2 * j + 0];
_vertices[j + currentPosition].tex[1] = shapes[i].mesh.texcoords[2 * j + 1];
}
}
currentPosition += shapes[i].mesh.positions.size() / 3;
+1 -1
View File
@@ -112,7 +112,7 @@ void LuaRotation::update(const UpdateData& data) {
_state,
duration_cast<milliseconds>(now.time_since_epoch()).count()
);
// Execute the scaling function
int success = lua_pcall(_state, 2, 9, 0);
if (success != 0) {
+2 -2
View File
@@ -32,9 +32,9 @@
#include <ghoul/lua/luastate.h>
namespace openspace {
namespace documentation { struct Documentation; }
class LuaRotation : public Rotation {
public:
LuaRotation();
+3 -3
View File
@@ -30,9 +30,9 @@
#include <openspace/properties/matrix/dmat3property.h>
namespace openspace {
namespace documentation { struct Documentation; }
class StaticRotation : public Rotation {
public:
StaticRotation();
@@ -43,7 +43,7 @@ public:
private:
properties::DMat3Property _rotationMatrix;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___STATICROTATION___H__
+1 -1
View File
@@ -103,7 +103,7 @@ void LuaScale::update(const UpdateData& data) {
_state,
duration_cast<milliseconds>(now.time_since_epoch()).count()
);
// Execute the scaling function
int success = lua_pcall(_state, 2, 1, 0);
if (success != 0) {
+2 -2
View File
@@ -32,9 +32,9 @@
#include <ghoul/lua/luastate.h>
namespace openspace {
namespace documentation { struct Documentation; }
class LuaScale : public Scale {
public:
LuaScale();
+1 -1
View File
@@ -66,7 +66,7 @@ StaticScale::StaticScale(const ghoul::Dictionary& dictionary)
: StaticScale()
{
documentation::testSpecificationAndThrow(Documentation(), dictionary, "StaticScale");
_scaleValue = static_cast<float>(dictionary.value<double>(ScaleInfo.identifier));
}
+3 -3
View File
@@ -30,9 +30,9 @@
#include <openspace/properties/scalar/floatproperty.h>
namespace openspace {
namespace documentation { struct Documentation; }
class StaticScale : public Scale {
public:
StaticScale();
@@ -43,7 +43,7 @@ public:
private:
properties::FloatProperty _scaleValue;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___STATICSCALE___H__
+1 -1
View File
@@ -120,7 +120,7 @@ void LuaTranslation::update(const UpdateData& data) {
_state,
duration_cast<milliseconds>(now.time_since_epoch()).count()
);
// Execute the scaling function
int success = lua_pcall(_state, 2, 3, 0);
if (success != 0) {
+2 -2
View File
@@ -37,7 +37,7 @@
namespace openspace {
namespace documentation { struct Documentation; }
class LuaTranslation : public Translation {
public:
LuaTranslation();
@@ -53,7 +53,7 @@ private:
std::unique_ptr<ghoul::filesystem::File> _fileHandle;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___LUATRANSLATION___H__
+2 -2
View File
@@ -32,7 +32,7 @@
namespace openspace {
namespace documentation { struct Documentation; }
class StaticTranslation : public Translation {
public:
StaticTranslation();
@@ -43,7 +43,7 @@ public:
private:
properties::DVec3Property _position;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___STATICTRANSLATION___H__
+1 -1
View File
@@ -34,7 +34,7 @@ public:
constexpr static const char* Name = "Debugging";
DebuggingModule();
std::vector<documentation::Documentation> documentations() const override;
protected:
@@ -119,7 +119,7 @@ void DebugRenderer::renderVertices(const Vertices& clippingSpacePoints, GLenum m
// the errors are not caused by DebugRenderer!!
//LERROR(error);
}
// Clean up after the draw call was made
glBindVertexArray(0);
glDeleteVertexArrays(1, &_vaoID);
@@ -168,7 +168,7 @@ void DebugRenderer::renderBoxEdges(const Vertices& clippingSpaceBoxCorners,
const Vertices& V = clippingSpaceBoxCorners;
std::vector<glm::vec4> lineVertices;
for (size_t i = 0; i < 4; i++) {
lineVertices.push_back(V[2 * i]);
lineVertices.push_back(V[2 * i + 1]);
@@ -234,7 +234,7 @@ void DebugRenderer::renderCameraFrustum(const RenderData& data, const Camera& ot
renderNiceBox(clippingSpaceFrustumCorners, rgba);
glEnable(GL_CULL_FACE);
}
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
void DebugRenderer::renderAABB2(const globebrowsing::AABB2& screenSpaceAABB,
RGBA rgba) const
@@ -248,7 +248,7 @@ void DebugRenderer::renderAABB2(const globebrowsing::AABB2& screenSpaceAABB,
renderVertices(vertices, GL_LINES, rgba);
}
#endif // OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
const DebugRenderer::Vertices DebugRenderer::verticesFor(
const globebrowsing::AABB3& screenSpaceAABB) const
+3 -3
View File
@@ -89,7 +89,7 @@ public:
*/
void renderBoxFaces(const Vertices& clippingSpaceBoxCorners,
RGBA rgba = { 1, 0, 0, 1 }) const;
/**
* Takes a vector of exactly 8 vertices, i.e. corner points in a box.
* The box corners should be ordered from smaller to larger,
@@ -140,7 +140,7 @@ public:
RGBA rgba = { 1, 1, 1, 0.3 }) const;
#endif // OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
/**
* Takes a AABB3 in screen space and returns vertices representing the corner points
@@ -149,7 +149,7 @@ public:
*/
const Vertices verticesFor(const globebrowsing::AABB3& screenSpaceAABB) const;
#endif // OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
protected:
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
@@ -50,7 +50,7 @@ namespace {
UpperRight,
Center
};
static const openspace::properties::Property::PropertyInfo TextureInfo = {
"Texture",
"Texture",
@@ -259,13 +259,13 @@ void RenderableDebugPlane::createPlane() {
const GLfloat size = _size;
const GLfloat vertex_data[] = {
// x y z w s t
// x y z w s t
-size, -size, 0.f, 0.f, 0.f, 0.f,
size, size, 0.f, 0.f, 1.f, 1.f,
-size, size, 0.f, 0.f, 0.f, 1.f,
size, size, 0.f, 0.f, 1.f, 1.f,
-size, size, 0.f, 0.f, 0.f, 1.f,
-size, -size, 0.f, 0.f, 0.f, 0.f,
size, -size, 0.f, 0.f, 1.f, 0.f,
size, size, 0.f, 0.f, 1.f, 1.f,
size, -size, 0.f, 0.f, 1.f, 0.f,
size, size, 0.f, 0.f, 1.f, 1.f,
};
glBindVertexArray(_quad); // bind array
@@ -69,7 +69,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",
@@ -324,7 +324,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
_hasSpeckFile = _hasSpeckFile == true? false : true; });
addProperty(_drawElements);
}
// DEBUG:
_renderOption.addOption(0, "Camera View Direction");
_renderOption.addOption(1, "Camera Position Normal");
@@ -409,13 +409,13 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
_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>(
@@ -446,7 +446,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
_labelFile = absPath(dictionary.value<std::string>(
LabelFileInfo.identifier
));
));
_hasLabel = true;
if (dictionary.hasKey(TextColorInfo.identifier)) {
@@ -465,7 +465,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di
if (dictionary.hasKey(LabelMinSizeInfo.identifier)) {
_textMinSize = static_cast<int>(dictionary.value<float>(LabelMinSizeInfo.identifier));
}
}
addProperty(_textMinSize);
}
}
@@ -476,12 +476,12 @@ bool RenderableBillboardsCloud::isReady() const {
void RenderableBillboardsCloud::initialize() {
RenderEngine& renderEngine = OsEng.renderEngine();
_program = renderEngine.buildRenderProgram("RenderableBillboardsCloud",
"${MODULE_DIGITALUNIVERSE}/shaders/billboard2_vs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/billboard2_fs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/billboard2_gs.glsl");
bool success = loadData();
if (!success) {
throw ghoul::RuntimeError("Error loading data");
@@ -491,7 +491,7 @@ void RenderableBillboardsCloud::initialize() {
// Following DU behavior here. The last colormap variable
// entry is the one selected by default.
_colorOption = static_cast<int>(_colorRangeData.size() - 1);
}
}
if (_hasPolygon) {
createPolygonTexture();
@@ -572,7 +572,7 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, const g
_program->setUniform("renderOption", _renderOption.value());
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", 1.f); // in pixels
_program->setUniform("color", _pointColor);
_program->setUniform("sides", 4);
@@ -631,7 +631,7 @@ void RenderableBillboardsCloud::renderLabels(const RenderData& data, const glm::
RenderEngine& renderEngine = OsEng.renderEngine();
_fontRenderer->setFramebufferSize(renderEngine.renderingResolution());
float scale = 0.0;
switch (_unit) {
case Meter:
@@ -698,14 +698,14 @@ void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) {
glm::vec3 orthoRight = glm::normalize(glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)));
glm::vec3 orthoUp = glm::normalize(glm::vec3(worldToModelTransform * glm::vec4(up, 0.0)));
if (_hasSpeckFile) {
renderBillboards(data, modelViewMatrix, projectionMatrix, orthoRight, orthoUp);
}
if (_drawLabels && _hasLabel) {
renderLabels(data, modelViewProjectionMatrix, orthoRight, orthoUp);
}
}
}
void RenderableBillboardsCloud::update(const UpdateData&) {
@@ -734,13 +734,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 nValues = _slicedData.size() / nAstronomicalObjects;
GLsizei stride = static_cast<GLsizei>(sizeof(float) * nValues);*/
glEnableVertexAttribArray(positionAttrib);
glVertexAttribPointer(
positionAttrib,
@@ -762,7 +762,7 @@ void RenderableBillboardsCloud::update(const UpdateData&) {
reinterpret_cast<void*>(sizeof(float)*4)
);
}
else {
else {
glEnableVertexAttribArray(positionAttrib);
glVertexAttribPointer(
positionAttrib,
@@ -796,11 +796,10 @@ void RenderableBillboardsCloud::update(const UpdateData&) {
[&](const ghoul::filesystem::File&) { _spriteTextureIsDirty = true; }
);
}
_spriteTextureIsDirty = false;
_spriteTextureIsDirty = false;
}
if (_hasLabel && _labelDataIsDirty) {
_labelDataIsDirty = false;
}
}
@@ -880,7 +879,7 @@ bool RenderableBillboardsCloud::loadData() {
// }
}
return success;
}
@@ -941,7 +940,7 @@ bool RenderableBillboardsCloud::readSpeckFile() {
_variableDataPositionMap.insert({ dummy, _nValuesPerAstronomicalObject });
_nValuesPerAstronomicalObject += 1; // We want the number, but the index is 0 based
}
}
}
_nValuesPerAstronomicalObject += 3; // X Y Z are not counted in the Speck file indices
@@ -964,7 +963,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());
@@ -980,7 +979,7 @@ bool RenderableBillboardsCloud::readColorMapFile() {
LERROR("Failed to open Color Map file '" << _file << "'");
return false;
}
int numberOfColors = 0;
// The beginning of the speck file has a header that either contains comments
@@ -1010,7 +1009,7 @@ bool RenderableBillboardsCloud::readColorMapFile() {
for (int 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];
@@ -1018,7 +1017,7 @@ bool RenderableBillboardsCloud::readColorMapFile() {
_colorMapData.push_back(color);
}
return true;
}
@@ -1029,7 +1028,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')
@@ -1091,7 +1090,7 @@ bool RenderableBillboardsCloud::readLabelFile() {
std::string dummy;
str >> dummy; // text keyword
std::string label;
str >> label;
dummy.clear();
@@ -1102,7 +1101,7 @@ bool RenderableBillboardsCloud::readLabelFile() {
}
_labelData.push_back(std::make_pair(position, label));
} while (!file.eof());
return true;
@@ -1135,7 +1134,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';
@@ -1173,7 +1172,7 @@ bool RenderableBillboardsCloud::saveCachedFile(const std::string& file) const {
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);
@@ -1201,7 +1200,7 @@ bool RenderableBillboardsCloud::saveCachedFile(const std::string& file) const {
return false;
}
}
void RenderableBillboardsCloud::createDataSlice() {
_slicedData.clear();
if (_hasColorMapFile) {
@@ -1223,12 +1222,12 @@ void RenderableBillboardsCloud::createDataSlice() {
colorBins.push_back(bin);
bin += colorMapBinSize;
}
}
}
for (size_t i = 0; i < _fullData.size(); i += _nValuesPerAstronomicalObject) {
glm::dvec4 transformedPos = glm::dvec4(_fullData[i + 0], _fullData[i + 1], _fullData[i + 2], 1.0);
glm::vec4 position(glm::vec3(transformedPos), static_cast<float>(_unit));
if (_hasColorMapFile) {
for (int j = 0; j < 4; ++j) {
_slicedData.push_back(position[j]);
@@ -1236,7 +1235,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 = static_cast<int>(colorBins.size() - 1);
// Float vs int comparison?
@@ -1245,9 +1244,9 @@ void RenderableBillboardsCloud::createDataSlice() {
if (c == 0)
break;
}
int colorIndex = (c == static_cast<int>(colorBins.size())) - 1 ? 0 : c + 1;
for (auto j = 0; j < 4; ++j) {
_slicedData.push_back(_colorMapData[colorIndex][j]);
}
@@ -1256,7 +1255,7 @@ void RenderableBillboardsCloud::createDataSlice() {
for (auto j = 0; j < 4; ++j) {
_slicedData.push_back(position[j]);
}
}
}
}
}
@@ -1278,7 +1277,7 @@ void RenderableBillboardsCloud::createPolygonTexture() {
this),
std::bind(&openspace::RenderableBillboardsCloud::renderPolygonGeometry,
this, std::placeholders::_1),
_pTexture, 256, 256);
_pTexture, 256, 256);
}
void RenderableBillboardsCloud::renderToTexture(
@@ -1286,7 +1285,7 @@ void RenderableBillboardsCloud::renderToTexture(
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];
@@ -1300,12 +1299,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]);
@@ -1317,7 +1316,7 @@ void RenderableBillboardsCloud::renderToTexture(
if (_polygonVao) {
glDeleteVertexArrays(1, &_polygonVao);
}
glDeleteFramebuffers(1, &textureFBO);
glDeleteFramebuffers(1, &textureFBO);
}
void RenderableBillboardsCloud::loadPolygonGeometryForRendering() {
@@ -69,7 +69,7 @@ public:
static documentation::Documentation Documentation();
private:
enum Unit {
Meter = 0,
Kilometer = 1,
@@ -99,7 +99,7 @@ private:
bool readLabelFile();
bool loadCachedFile(const std::string& file);
bool saveCachedFile(const std::string& file) const;
bool _hasSpeckFile;
bool _dataIsDirty;
bool _textColorIsDirty;
@@ -111,7 +111,7 @@ private:
bool _labelDataIsDirty;
int _polygonSides;
GLuint _pTexture;
properties::FloatProperty _alphaValue;
@@ -61,7 +61,7 @@ namespace {
const int8_t CurrentCacheVersion = 1;
const float PARSEC = 0.308567756E17;
static const openspace::properties::Property::PropertyInfo TransparencyInfo = {
"Transparency",
"Transparency",
@@ -258,7 +258,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary)
dictionary,
"RenderableDUMeshes"
);
if (dictionary.hasKey(KeyFile)) {
_speckFile = absPath(dictionary.value<std::string>(KeyFile));
_hasSpeckFile = true;
@@ -320,7 +320,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary)
);
}
addProperty(_scaleFactor);
if (dictionary.hasKey(DrawLabelInfo.identifier)) {
_drawLabels = dictionary.value<bool>(DrawLabelInfo.identifier);
}
@@ -383,7 +383,7 @@ void RenderableDUMeshes::initialize() {
}
createMeshes();
if (_hasLabel) {
if (_fontRenderer == nullptr)
_fontRenderer = std::unique_ptr<ghoul::fontrendering::FontRenderer>(
@@ -403,7 +403,7 @@ void RenderableDUMeshes::deinitialize() {
glDeleteBuffers(1, &pair.second.vboArray[i]);
}
}
RenderEngine& renderEngine = OsEng.renderEngine();
if (_program) {
renderEngine.removeRenderProgram(_program);
@@ -462,9 +462,9 @@ void RenderableDUMeshes::renderMeshes(const RenderData&,
default:
break;
}
}
}
}
glBindVertexArray(0);
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
@@ -650,7 +650,7 @@ bool RenderableDUMeshes::readSpeckFile() {
while (true) {
std::streampos position = file.tellg();
std::getline(file, line);
if (file.eof()) {
break;
}
@@ -716,7 +716,7 @@ bool RenderableDUMeshes::readSpeckFile() {
dummy.clear();
str >> dummy;
} while (dummy != "{");
std::getline(file, line);
std::stringstream dim(line);
dim >> mesh.numU; // numU
@@ -751,9 +751,9 @@ bool RenderableDUMeshes::readSpeckFile() {
else {
return false;
}
}
}
}
}
return true;
}
@@ -939,7 +939,7 @@ void RenderableDUMeshes::createMeshes() {
for (int v = 0; v < static_cast<int>(it->second.vertices.size()); ++v) {
it->second.vertices[v] *= scale;
}
for (int i = 0; i < it->second.numU; ++i) {
GLuint vao, vbo;
glGenVertexArrays(1, &vao);
@@ -67,7 +67,7 @@ public:
static documentation::Documentation Documentation();
private:
enum Unit {
Meter = 0,
Kilometer = 1,
@@ -123,7 +123,7 @@ private:
bool _hasLabel;
bool _labelDataIsDirty;
int _textMinSize;
int _textMinSize;
properties::FloatProperty _alphaValue;
properties::FloatProperty _scaleFactor;
@@ -136,12 +136,11 @@ private:
// DEBUG:
properties::OptionProperty _renderOption;
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
std::shared_ptr<ghoul::fontrendering::Font> _font;
std::string _speckFile;
std::string _labelFile;
@@ -291,7 +291,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
_hasSpeckFile = _hasSpeckFile == true? false : true; });
addProperty(_drawElements);
}
// DEBUG:
_renderOption.addOption(0, "Camera View Direction");
_renderOption.addOption(1, "Camera Position Normal");
@@ -347,11 +347,11 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
_scaleFactor.onChange([&]() {
_dataIsDirty = true;
});
if (dictionary.hasKey(LabelFileInfo.identifier)) {
_labelFile = absPath(dictionary.value<std::string>(
LabelFileInfo.identifier
));
));
_hasLabel = true;
if (dictionary.hasKey(TextColorInfo.identifier)) {
@@ -370,7 +370,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
if (dictionary.hasKey(LabelMinSizeInfo.identifier)) {
_textMinSize = static_cast<int>(dictionary.value<float>(LabelMinSizeInfo.identifier));
}
}
}
if (dictionary.hasKey(TransformationMatrixInfo.identifier)) {
@@ -421,11 +421,11 @@ bool RenderablePlanesCloud::isReady() const {
void RenderablePlanesCloud::initialize() {
RenderEngine& renderEngine = OsEng.renderEngine();
_program = renderEngine.buildRenderProgram("RenderablePlanesCloud",
"${MODULE_DIGITALUNIVERSE}/shaders/plane2_vs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/plane2_fs.glsl");
bool success = loadData();
if (!success) {
throw ghoul::RuntimeError("Error loading data");
@@ -457,12 +457,12 @@ void RenderablePlanesCloud::deleteDataGPU() {
void RenderablePlanesCloud::deinitialize() {
deleteDataGPU();
RenderEngine& renderEngine = OsEng.renderEngine();
if (_program) {
renderEngine.removeRenderProgram(_program);
_program = nullptr;
}
}
}
void RenderablePlanesCloud::renderPlanes(const RenderData&,
@@ -499,7 +499,7 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&,
_program->setUniform("alphaValue", _alphaValue);
_program->setUniform("scaleFactor", _scaleFactor);
//_program->setUniform("minPlaneSize", 1.f); // in pixels
//bool usingFramebufferRenderer =
// OsEng.renderEngine().rendererImplementation() == RenderEngine::RendererImplementation::Framebuffer;
@@ -515,7 +515,7 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&,
// //glDepthMask(false);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE);
//}
for (auto pair : _renderingPlanesMap) {
ghoul::opengl::TextureUnit unit;
unit.activate();
@@ -523,14 +523,14 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&,
_program->setUniform("galaxyTexture", unit);
glBindVertexArray(pair.second.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;
@@ -545,7 +545,7 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&,
if (!blendEnabled) {
glDisable(GL_BLEND);
}
}
}
void RenderablePlanesCloud::renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
@@ -553,7 +553,7 @@ void RenderablePlanesCloud::renderLabels(const RenderData& data, const glm::dmat
RenderEngine& renderEngine = OsEng.renderEngine();
_fontRenderer->setFramebufferSize(renderEngine.renderingResolution());
float scale = 0.0;
switch (_unit) {
case Meter:
@@ -578,14 +578,14 @@ void RenderablePlanesCloud::renderLabels(const RenderData& data, const glm::dmat
scale = 306391534.73091 * PARSEC;
break;
}
for (const std::pair<glm::vec3, std::string>& pair : _labelData) {
//glm::vec3 scaledPos(_transformationMatrix * glm::dvec4(pair.first, 1.0));
glm::vec3 scaledPos(pair.first);
scaledPos *= scale;
_fontRenderer->render(
*_font,
scaledPos,
scaledPos,
_textColor,
pow(10.0, _textSize.value()),
_textMinSize,
@@ -597,8 +597,7 @@ void RenderablePlanesCloud::renderLabels(const RenderData& data, const glm::dmat
_renderOption.value(),
"%s",
pair.second.c_str());
}
}
}
void RenderablePlanesCloud::render(const RenderData& data, RendererTasks&) {
@@ -620,14 +619,14 @@ void RenderablePlanesCloud::render(const RenderData& data, RendererTasks&) {
glm::vec3 orthoRight = glm::normalize(glm::vec3(worldToModelTransform * glm::vec4(right, 0.0)));
glm::vec3 orthoUp = glm::normalize(glm::vec3(worldToModelTransform * glm::vec4(up, 0.0)));
if (_hasSpeckFile) {
renderPlanes(data, modelViewMatrix, projectionMatrix);
renderPlanes(data, modelViewMatrix, projectionMatrix);
}
if (_hasLabel) {
renderLabels(data, modelViewProjectionMatrix, orthoRight, orthoUp);
}
}
}
void RenderablePlanesCloud::update(const UpdateData&) {
@@ -639,7 +638,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
@@ -673,7 +672,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
@@ -704,7 +703,7 @@ bool RenderablePlanesCloud::loadData() {
// }
}
return success;
}
@@ -722,7 +721,7 @@ bool RenderablePlanesCloud::loadTextures() {
it->second->uploadTexture();
it->second->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
}
}
}
}
else {
return false;
@@ -792,7 +791,7 @@ bool RenderablePlanesCloud::readSpeckFile() {
}
else {
_nValuesPerAstronomicalObject += 1; // We want the number, but the index is 0 based
}
}
}
if (line.substr(0, 10) == "polyorivar") {
@@ -817,9 +816,9 @@ bool RenderablePlanesCloud::readSpeckFile() {
if (line.substr(0, 8) == "texture ") {
std::stringstream str(line);
int textureIndex = 0;
std::string dummy;
str >> dummy; // command
str >> textureIndex;
@@ -847,7 +846,7 @@ bool RenderablePlanesCloud::readSpeckFile() {
if (line.empty()) {
continue;
}
std::stringstream str(line);
glm::vec3 u(0.0f), v(0.0f);
@@ -898,7 +897,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')
@@ -935,7 +934,7 @@ bool RenderablePlanesCloud::readLabelFile() {
}
}
do {
std::vector<float> values(_nValuesPerAstronomicalObject);
@@ -960,7 +959,7 @@ bool RenderablePlanesCloud::readLabelFile() {
std::string dummy;
str >> dummy; // text keyword
std::string label;
str >> label;
dummy.clear();
@@ -1073,21 +1072,21 @@ void RenderablePlanesCloud::createPlanes() {
RenderingPlane plane;
plane.planeIndex = _fullData[p + _textureVariableIndex];
// JCC: Ask Abbott about these points refeering to a non-existing texture.
if (plane.planeIndex == 30) {
//std::cout << "--- Creating planes - index: " << plane.planeIndex << std::endl;
plane.planeIndex = 0;
}
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:
@@ -1143,7 +1142,7 @@ void RenderablePlanesCloud::createPlanes() {
sizeof(GLfloat) * 6,
nullptr
);
// texture coords
glEnableVertexAttribArray(1);
glVertexAttribPointer(
@@ -1153,7 +1152,7 @@ void RenderablePlanesCloud::createPlanes() {
GL_FALSE,
sizeof(GLfloat) * 6,
reinterpret_cast<GLvoid*>(sizeof(GLfloat) * 4)
);
);
_renderingPlanesMap.insert({planeNumber++, plane});
}
@@ -1164,7 +1163,6 @@ void RenderablePlanesCloud::createPlanes() {
}
if (_hasLabel && _labelDataIsDirty) {
_labelDataIsDirty = false;
}
}
@@ -71,7 +71,6 @@ namespace openspace {
static documentation::Documentation Documentation();
private:
enum Unit {
Meter = 0,
Kilometer = 1,
@@ -86,12 +85,12 @@ namespace openspace {
struct RenderingPlane {
int planeIndex;
GLuint vao;
GLuint vbo;
GLuint vbo;
GLfloat vertexData[PLANES_VERTEX_DATA_SIZE];
};
void deleteDataGPU();
void createPlanes();
void createPlanes();
void renderPlanes(const RenderData& data, const glm::dmat4& modelViewMatrix,
const glm::dmat4& projectionMatrix);
void renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
@@ -103,7 +102,7 @@ namespace openspace {
bool readLabelFile();
bool loadCachedFile(const std::string& file);
bool saveCachedFile(const std::string& file) const;
bool _hasSpeckFile;
bool _dataIsDirty;
bool _textColorIsDirty;
@@ -112,7 +111,7 @@ namespace openspace {
int _textMinSize;
int _planeStartingIndexPos;
int _textureVariableIndex;
int _textureVariableIndex;
properties::FloatProperty _alphaValue;
properties::FloatProperty _scaleFactor;
@@ -134,13 +133,13 @@ namespace openspace {
std::string _labelFile;
std::string _texturesPath;
std::string _luminosityVar;
Unit _unit;
std::vector<float> _fullData;
std::vector<std::pair<glm::vec3, std::string>> _labelData;
std::unordered_map<std::string, int> _variableDataPositionMap;
int _nValuesPerAstronomicalObject;
float _sluminosity;
@@ -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",
@@ -174,9 +174,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) {
@@ -266,7 +266,7 @@ namespace openspace {
"${MODULE_DIGITALUNIVERSE}/shaders/points_fs.glsl");// ,
//"${MODULE_DIGITALUNIVERSE}/shaders/points_gs.glsl");
}
bool success = loadData();
if (!success) {
throw ghoul::RuntimeError("Error loading data");
@@ -295,7 +295,7 @@ 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()) *
@@ -305,7 +305,7 @@ namespace openspace {
_program->setUniform("sides", 4);
_program->setUniform("alphaValue", _alphaValue);
_program->setUniform("scaleFactor", _scaleFactor);
if (_hasSpriteTexture) {
ghoul::opengl::TextureUnit spriteTextureUnit;
spriteTextureUnit.activate();
@@ -319,12 +319,12 @@ namespace openspace {
else {
_program->setUniform("hasColorMap", false);
}
glEnable(GL_PROGRAM_POINT_SIZE);
glBindVertexArray(_vao);
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;
@@ -362,11 +362,10 @@ namespace openspace {
GLint positionAttrib = _program->attributeLocation("in_position");
if (_hasColorMapFile) {
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,
@@ -386,7 +385,7 @@ namespace openspace {
reinterpret_cast<void*>(sizeof(double)*4)
);
}
else {
else {
glEnableVertexAttribArray(positionAttrib);
glVertexAttribLPointer(
positionAttrib,
@@ -419,7 +418,7 @@ namespace openspace {
[&](const ghoul::filesystem::File&) { _spriteTextureIsDirty = true; }
);
}
_spriteTextureIsDirty = false;
_spriteTextureIsDirty = false;
}
}
@@ -484,7 +483,7 @@ namespace openspace {
while (true) {
std::streampos position = file.tellg();
std::getline(file, line);
if (line[0] == '#' || line.empty()) {
continue;
}
@@ -539,7 +538,7 @@ namespace openspace {
LERROR("Failed to open Color Map file '" << _file << "'");
return false;
}
int numberOfColors = 0;
// The beginning of the speck file has a header that either contains comments
@@ -563,13 +562,13 @@ namespace openspace {
}
else if (file.eof()) {
return false;
}
}
}
for (int 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];
@@ -577,7 +576,7 @@ namespace openspace {
_colorMapData.push_back(color);
}
return true;
}
@@ -637,7 +636,7 @@ namespace openspace {
return false;
}
}
void RenderablePoints::createDataSlice() {
_slicedData.clear();
if (_hasColorMapFile) {
@@ -686,13 +685,12 @@ namespace openspace {
_slicedData.push_back(position[j]);
}
}
colorIndex =
(colorIndex == (static_cast<int>(_colorMapData.size()) - 1)) ?
0 :
colorIndex + 1;
}
}
} // namespace openspace
@@ -64,7 +64,7 @@ namespace openspace {
static documentation::Documentation Documentation();
private:
enum Unit {
Meter = 0,
Kilometer = 1,
@@ -93,7 +93,7 @@ namespace openspace {
properties::FloatProperty _scaleFactor;
properties::Vec3Property _pointColor;
properties::StringProperty _spriteTexturePath;
std::unique_ptr<ghoul::opengl::Texture> _spriteTexture;
std::unique_ptr<ghoul::filesystem::File> _spriteTextureFile;
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
+1 -1
View File
@@ -34,7 +34,7 @@ public:
constexpr static const char* Name = "Fieldlines";
FieldlinesModule();
protected:
void internalInitialize() override;
};
@@ -113,7 +113,7 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
defaultFieldlineColor,
glm::vec4(0.f),
glm::vec4(1.f)
)
)
, _seedPointSource(SeedPointSourceInfo)
, _seedPointSourceFile(SeedPointFileInfo)
, _program(nullptr)
@@ -126,7 +126,7 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
dictionary.hasKeyAndValue<std::string>(SceneGraphNode::KeyName),
"Renderable does not have a name"
);
std::string name;
dictionary.getValue(SceneGraphNode::KeyName, name);
setName(name);
@@ -188,24 +188,27 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
void RenderableFieldlines::initializeDefaultPropertyValues() {
bool success;
// Step size
float stepSize;
success = _fieldlineInfo.getValue(keyFieldlinesStepSize, stepSize);
if (success)
if (success) {
_stepSize = stepSize;
}
// Classification
bool classification;
success = _fieldlineInfo.getValue(keyFieldlinesClassification, classification);
if (success)
if (success) {
_classification = classification;
}
// Fieldline Color
glm::vec4 color;
success = _fieldlineInfo.getValue(keyFieldlinesColor, color);
if (success)
if (success) {
_fieldlineColor = color;
}
// Seedpoints Type
std::string sourceType;
@@ -283,8 +286,9 @@ void RenderableFieldlines::render(const RenderData& data, RendererTasks&) {
}
void RenderableFieldlines::update(const UpdateData&) {
if (_program->isDirty())
if (_program->isDirty()) {
_program->rebuildFromFile();
}
if (_seedPointsAreDirty) {
loadSeedPoints();
@@ -295,8 +299,9 @@ void RenderableFieldlines::update(const UpdateData&) {
if (_fieldLinesAreDirty) {
std::vector<Line> fieldlines = generateFieldlines();
if (fieldlines.empty())
if (fieldlines.empty()) {
return ;
}
int prevEnd = 0;
std::vector<LinePoint> vertexData;
@@ -309,12 +314,14 @@ void RenderableFieldlines::update(const UpdateData&) {
}
LDEBUG("Number of vertices : " << vertexData.size());
if (_fieldlineVAO == 0)
if (_fieldlineVAO == 0) {
glGenVertexArrays(1, &_fieldlineVAO);
}
glBindVertexArray(_fieldlineVAO);
if (_vertexPositionBuffer == 0)
if (_vertexPositionBuffer == 0) {
glGenBuffers(1, &_vertexPositionBuffer);
}
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer);
glBufferData(GL_ARRAY_BUFFER, vertexData.size()*sizeof(LinePoint), &vertexData.front(), GL_STATIC_DRAW);
@@ -388,8 +395,9 @@ std::vector<RenderableFieldlines::Line> RenderableFieldlines::generateFieldlines
return {};
}
if (type == vectorFieldTypeVolumeKameleon)
if (type == vectorFieldTypeVolumeKameleon) {
return generateFieldlinesVolumeKameleon();
}
else {
LERROR(keyVectorField << "." << keyVectorFieldType <<
" does not name a valid type");
@@ -451,12 +459,12 @@ RenderableFieldlines::generateFieldlinesVolumeKameleon()
KameleonWrapper kw(fileName);
return kw.getClassifiedFieldLines(xVariable, yVariable, zVariable, _seedPoints, _stepSize);
}
if (lorentzForce) {
KameleonWrapper kw(fileName);
return kw.getLorentzTrajectories(_seedPoints, _fieldlineColor, _stepSize);
}
ghoul_assert(false, "Should not reach this");
return {};
}
@@ -38,7 +38,7 @@
namespace ghoul::opengl { class ProgramObject; }
namespace openspace {
struct LinePoint;
class RenderableFieldlines : public Renderable {
+1 -1
View File
@@ -44,5 +44,5 @@ void GalaxyModule::internalInitialize() {
fTask->registerClass<MilkywayConversionTask>("MilkywayConversionTask");
fTask->registerClass<MilkywayPointsConversionTask>("MilkywayPointsConversionTask");
}
} // namespace openspace
+18 -20
View File
@@ -36,12 +36,11 @@
#include <openspace/rendering/renderable.h>
namespace {
const std::string GlslRaycastPath = "${MODULES}/galaxy/shaders/galaxyraycast.glsl";
const std::string GlslBoundsVsPath = "${MODULES}/galaxy/shaders/raycasterbounds.vs";
const std::string GlslBoundsFsPath = "${MODULES}/galaxy/shaders/raycasterbounds.fs";
}
} // namespace
namespace openspace {
@@ -49,31 +48,31 @@ GalaxyRaycaster::GalaxyRaycaster(ghoul::opengl::Texture& texture)
: _boundingBox(glm::vec3(1.0))
, _texture(texture)
, _textureUnit(nullptr) {}
GalaxyRaycaster::~GalaxyRaycaster() {}
void GalaxyRaycaster::initialize() {
_boundingBox.initialize();
}
void GalaxyRaycaster::deinitialize() {
}
void GalaxyRaycaster::renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) {
program.setUniform("modelTransform", _modelTransform);
program.setUniform("viewProjection", data.camera.viewProjectionMatrix());
program.setUniform("blendMode", static_cast<unsigned int>(1));
Renderable::setPscUniforms(program, data.camera, data.position);
// Cull back face
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
// Render bounding geometry
_boundingBox.render();
}
void GalaxyRaycaster::renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) {
// Uniforms
program.setUniform("modelTransform", _modelTransform);
@@ -84,21 +83,21 @@ void GalaxyRaycaster::renderExitPoints(const RenderData& data, ghoul::opengl::Pr
// Cull front face
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
// Render bounding geometry
_boundingBox.render();
// Restore defaults
glCullFace(GL_BACK);
}
void GalaxyRaycaster::preRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) {
std::string colorUniformName = "color" + std::to_string(data.id);
std::string stepSizeUniformName = "maxStepSize" + std::to_string(data.id);
std::string galaxyTextureUniformName = "galaxyTexture" + std::to_string(data.id);
std::string volumeAspectUniformName = "aspect" + std::to_string(data.id);
std::string opacityCoefficientUniformName = "opacityCoefficient" + std::to_string(data.id);
program.setUniform(volumeAspectUniformName, _aspect);
program.setUniform(stepSizeUniformName, _stepSize);
program.setUniform(opacityCoefficientUniformName, _opacityCoefficient);
@@ -107,9 +106,8 @@ void GalaxyRaycaster::preRaycast(const RaycastData& data, ghoul::opengl::Program
_textureUnit->activate();
_texture.bind();
program.setUniform(galaxyTextureUniformName, *_textureUnit);
}
void GalaxyRaycaster::postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) {
_textureUnit = nullptr; // release texture unit.
}
@@ -119,7 +117,7 @@ bool GalaxyRaycaster::cameraIsInside(const RenderData& data, glm::vec3& localPos
glm::vec4 rigWorldPos = glm::vec4(data.camera.position().vec3(), 1.0);
//rigWorldPos /= data.camera.scaling().x * pow(10.0, data.camera.scaling().y);
//glm::mat4 invSgctMatrix = glm::inverse(data.camera.viewMatrix());
// Camera position in world coordinates.
glm::vec4 camWorldPos = rigWorldPos;
glm::vec3 objPos = data.position.vec3();
@@ -134,7 +132,7 @@ bool GalaxyRaycaster::cameraIsInside(const RenderData& data, glm::vec3& localPos
glm::mat4 scaledModelTransform = modelTransform / divisor;
glm::vec4 modelPos = (glm::inverse(scaledModelTransform) / divisor) * camWorldPos;
localPosition = (glm::vec3(modelPos) + glm::vec3(0.5));
return (localPosition.x > 0 && localPosition.y > 0 && localPosition.z > 0 && localPosition.x < 1 && localPosition.y < 1 && localPosition.z < 1);
}
@@ -142,7 +140,7 @@ bool GalaxyRaycaster::cameraIsInside(const RenderData& data, glm::vec3& localPos
std::string GalaxyRaycaster::getBoundsVsPath() const {
return GlslBoundsVsPath;
}
std::string GalaxyRaycaster::getBoundsFsPath() const {
return GlslBoundsFsPath;
}
@@ -170,9 +168,9 @@ void GalaxyRaycaster::setOpacityCoefficient(float opacityCoefficient) {
void GalaxyRaycaster::setTime(double time) {
_time = time;
}
void GalaxyRaycaster::setStepSize(float stepSize) {
_stepSize = stepSize;
}
}
} // namespace openspace
+13 -14
View File
@@ -150,7 +150,7 @@ namespace openspace {
}
}
RenderableGalaxy::~RenderableGalaxy() {}
void RenderableGalaxy::initialize() {
@@ -160,7 +160,7 @@ void RenderableGalaxy::initialize() {
volume::RawVolumeReader<glm::tvec4<GLfloat>> reader(_volumeFilename, _volumeDimensions);
_volume = reader.read();
_texture = std::make_unique<ghoul::opengl::Texture>(
_volumeDimensions,
ghoul::opengl::Texture::Format::RGBA,
@@ -168,7 +168,7 @@ void RenderableGalaxy::initialize() {
GL_FLOAT,
ghoul::opengl::Texture::FilterMode::Linear,
ghoul::opengl::Texture::WrappingMode::Clamp);
_texture->setPixelData(reinterpret_cast<char*>(_volume->data()), ghoul::opengl::Texture::TakeOwnership::No);
_texture->setDimensions(_volume->dimensions());
_texture->uploadTexture();
@@ -194,7 +194,7 @@ void RenderableGalaxy::initialize() {
addProperty(_translation);
addProperty(_rotation);
addProperty(_enabledPointsRatio);
// initialize points.
std::ifstream pointFile(_pointsFilename, std::ios::in | std::ios::binary);
@@ -215,7 +215,7 @@ void RenderableGalaxy::initialize() {
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];
@@ -225,9 +225,9 @@ void RenderableGalaxy::initialize() {
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;
@@ -270,22 +270,22 @@ void RenderableGalaxy::initialize() {
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::deinitialize() {
if (_raycaster) {
OsEng.renderEngine().raycasterManager().detachRaycaster(*_raycaster.get());
_raycaster = nullptr;
}
}
bool RenderableGalaxy::isReady() const {
return true;
}
void RenderableGalaxy::update(const UpdateData& data) {
if (_raycaster) {
@@ -298,7 +298,7 @@ void RenderableGalaxy::update(const UpdateData& data) {
glm::mat4 volumeTransform = glm::scale(transform, 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 +323,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.02;
float lowerRampEnd = maxDim * 0.5;
@@ -390,5 +389,5 @@ float RenderableGalaxy::safeLength(const glm::vec3& vector) {
OsEng.ref().renderEngine().postRaycast(*_pointsProgram);
}*/
}
+2 -2
View File
@@ -35,12 +35,12 @@
namespace openspace {
struct RenderData;
class RenderableGalaxy : public Renderable {
public:
RenderableGalaxy(const ghoul::Dictionary& dictionary);
~RenderableGalaxy();
void initialize() override;
void deinitialize() override;
bool isReady() const override;
@@ -42,7 +42,7 @@ namespace {
} // namespace
namespace openspace {
MilkywayConversionTask::MilkywayConversionTask(const ghoul::Dictionary& dictionary) {
std::string inFilenamePrefix;
if (dictionary.getValue(KeyInFilenamePrefix, inFilenamePrefix)) {
@@ -77,8 +77,7 @@ MilkywayConversionTask::MilkywayConversionTask(const ghoul::Dictionary& dictiona
MilkywayConversionTask::~MilkywayConversionTask() {}
std::string MilkywayConversionTask::description()
{
std::string MilkywayConversionTask::description() {
return std::string();
}
@@ -89,7 +88,7 @@ void MilkywayConversionTask::perform(const Task::ProgressCallback& progressCallb
for (int i = 0; i < _inNSlices; i++) {
filenames.push_back(_inFilenamePrefix + std::to_string(i + _inFirstIndex) + _inFilenameSuffix);
}
TextureSliceVolumeReader<glm::tvec4<GLfloat>> sliceReader(filenames, _inNSlices, 10);
sliceReader.initialize();
@@ -109,9 +108,8 @@ void MilkywayConversionTask::perform(const Task::ProgressCallback& progressCallb
rawWriter.write(sampleFunction, progressCallback);
}
documentation::Documentation MilkywayConversionTask::documentation()
{
documentation::Documentation MilkywayConversionTask::documentation() {
return documentation::Documentation();
}
}
} // namespace openspace
@@ -51,7 +51,7 @@ public:
static documentation::Documentation documentation();
private:
std::string _inFilename;
std::string _inFilename;
std::string _outFilename;
};
+2 -2
View File
@@ -40,7 +40,7 @@ class LRUCache {
public:
using Item = std::pair<KeyType, ValueType>;
using Items = std::list<Item>;
/**
* \param size is the maximum size of the cache given in number of cached items.
*/
@@ -62,7 +62,7 @@ public:
* Pops the front of the queue.
*/
Item popMRU();
/**
* Pops the back of the queue.
*/
+1 -1
View File
@@ -25,7 +25,7 @@
#include <ghoul/misc/assert.h>
namespace openspace::globebrowsing::cache {
template<typename KeyType, typename ValueType, typename HasherType>
LRUCache<KeyType, ValueType, HasherType>::LRUCache(size_t size)
: _maximumCacheSize(size)
+6 -6
View File
@@ -111,9 +111,9 @@ MemoryAwareTileCache::MemoryAwareTileCache()
_tileCacheSize.setMaxValue(
static_cast<int>(CpuCap.installedMainMemory() * 0.25)
);
setSizeEstimated(_tileCacheSize * 1024 * 1024);
_cpuAllocatedTileData.setReadOnly(true);
_gpuAllocatedTileData.setReadOnly(true);
@@ -166,7 +166,7 @@ void MemoryAwareTileCache::assureTextureContainerExists(
void MemoryAwareTileCache::setSizeEstimated(size_t estimatedSize) {
LINFO("Resetting tile cache size");
ghoul_assert(_textureContainerMap.size() > 0, "Texture containers must exist.");
size_t sumTextureTypeSize = std::accumulate(
_textureContainerMap.cbegin(),
_textureContainerMap.cend(),
@@ -177,7 +177,7 @@ void MemoryAwareTileCache::setSizeEstimated(size_t estimatedSize) {
return s + p.second.first->tileTextureInitData().totalNumBytes();
}
);
size_t numTexturesPerType = estimatedSize / sumTextureTypeSize;
resetTextureContainerSize(numTexturesPerType);
LINFO("Tile cache size was reset");
@@ -243,14 +243,14 @@ void MemoryAwareTileCache::createTileAndPut(ProviderTileKey key,
{
ghoul_precondition(rawTile, "RawTile can not be null");
using ghoul::opengl::Texture;
if (rawTile->error != RawTile::ReadError::None) {
return;
}
else {
const TileTextureInitData& initData = *rawTile->textureInitData;
Texture* texture = getTexture(initData);
// Re-upload texture, either using PBO or by using RAM data
if (rawTile->pbo != 0) {
texture->reUploadTextureFromPBO(rawTile->pbo);
+1 -1
View File
@@ -107,7 +107,7 @@ private:
void createDefaultTextureContainers();
void assureTextureContainerExists(const TileTextureInitData& initData);
void resetTextureContainerSize(size_t numTexturesPerTextureType);
using TileCache = LRUCache<ProviderTileKey, Tile, ProviderTileHasher>;
using TextureContainerTileCache =
std::pair<std::unique_ptr<TextureContainer>, std::unique_ptr<TileCache>>;
+3 -4
View File
@@ -42,8 +42,7 @@ void TextureContainer::reset() {
_initData.shouldAllocateDataOnCPU() ?
ghoul::opengl::Texture::AllocateData::Yes :
ghoul::opengl::Texture::AllocateData::No;
for (size_t i = 0; i < _numTextures; ++i)
{
for (size_t i = 0; i < _numTextures; ++i) {
auto tex = std::make_unique<ghoul::opengl::Texture>(
_initData.dimensions(),
_initData.ghoulTextureFormat(),
@@ -53,11 +52,11 @@ void TextureContainer::reset() {
ghoul::opengl::Texture::WrappingMode::ClampToEdge,
allocate
);
tex->setDataOwnership(ghoul::opengl::Texture::TakeOwnership::Yes);
tex->uploadTexture();
tex->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
_textures.push_back(std::move(tex));
}
}
+2 -2
View File
@@ -48,7 +48,7 @@ public:
void reset();
void reset(size_t numTextures);
/**
* \returns a pointer to a texture if there is one texture never used before.
* If there are no textures left, nullptr is returned. TextureContainer still owns
@@ -57,7 +57,7 @@ public:
ghoul::opengl::Texture* getTextureIfFree();
const TileTextureInitData& tileTextureInitData() const;
/**
* \returns the number of textures in this TextureContainer
*/
+5 -5
View File
@@ -155,7 +155,7 @@ Chunk::BoundingHeights Chunk::getBoundingHeights() const {
break;
}
}
return boundingHeights;
}
@@ -184,7 +184,7 @@ std::vector<glm::dvec4> Chunk::getBoundingPolyhedronCorners() const {
double y1 = tan(halfSize.lat);
double y2 = tan(halfSize.lon);
double scaleToCoverCenter = sqrt(1 + pow(y1, 2) + pow(y2, 2));
double maxCornerHeight = maxCenterRadius * scaleToCoverCenter - patchCenterRadius;
bool chunkIsNorthOfEquator = patch.isNorthern();
@@ -192,11 +192,11 @@ std::vector<glm::dvec4> Chunk::getBoundingPolyhedronCorners() const {
// The minimum height offset, however, we can simply
double minCornerHeight = boundingHeight.min;
std::vector<glm::dvec4> corners(8);
double latCloseToEquator = patch.edgeLatitudeNearestEquator();
Geodetic3 p1Geodetic = { { latCloseToEquator, patch.minLon() }, maxCornerHeight };
Geodetic3 p2Geodetic = { { latCloseToEquator, patch.maxLon() }, maxCornerHeight };
glm::vec3 p1 = ellipsoid.cartesianPosition(p1Geodetic);
glm::vec3 p2 = ellipsoid.cartesianPosition(p2Geodetic);
glm::vec3 p = 0.5f * (p1 + p2);
@@ -207,7 +207,7 @@ std::vector<glm::dvec4> Chunk::getBoundingPolyhedronCorners() const {
Quad q = static_cast<Quad>(i % 4);
double cornerHeight = i < 4 ? minCornerHeight : maxCornerHeight;
Geodetic3 cornerGeodetic = { patch.getCorner(q), cornerHeight };
bool cornerIsNorthern = !((i / 2) % 2);
bool cornerCloseToEquator = chunkIsNorthOfEquator ^ cornerIsNorthern;
if (cornerCloseToEquator) {
+2 -2
View File
@@ -53,7 +53,7 @@ public:
WantMerge,
WantSplit,
};
Chunk(const RenderableGlobe& owner, const TileIndex& tileIndex,
bool initVisible = true);
@@ -80,7 +80,7 @@ public:
const RenderableGlobe& owner() const;
const TileIndex tileIndex() const;
bool isVisible() const;
/**
* Returns BoundingHeights that fits the Chunk as tightly as possible.
*
@@ -32,12 +32,12 @@
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
namespace openspace::globebrowsing::chunklevelevaluator {
int AvailableTileData::getDesiredLevel(const Chunk& chunk, const RenderData&) const {
auto layerManager = chunk.owner().chunkedLodGlobe()->layerManager();
// auto layers = layerManager->layerGroup(LayerManager::HeightLayers).activeLayers();
int currLevel = chunk.tileIndex().level;
for (size_t i = 0; i < layergroupid::NUM_LAYER_GROUPS; ++i) {
for (const auto& layer : layerManager->layerGroup(i).activeLayers()) {
Tile::Status status = layer->getTileStatus(chunk.tileIndex());
@@ -28,7 +28,7 @@
namespace openspace { struct RenderData; }
namespace openspace::globebrowsing { class Chunk; }
namespace openspace::globebrowsing::chunklevelevaluator {
/**
@@ -32,7 +32,7 @@
#include <openspace/util/updatestructures.h>
namespace openspace::globebrowsing::chunklevelevaluator {
int Distance::getDesiredLevel(const Chunk& chunk, const RenderData& data) const {
// Calculations are done in the reference frame of the globe
// (model space). Hence, the camera position needs to be transformed
@@ -43,19 +43,19 @@ int Distance::getDesiredLevel(const Chunk& chunk, const RenderData& data) const
glm::dvec3 cameraPosition =
glm::dvec3(inverseModelTransform * glm::dvec4(data.camera.positionVec3(), 1));
Geodetic2 pointOnPatch = chunk.surfacePatch().closestPoint(
ellipsoid.cartesianToGeodetic2(cameraPosition)
);
glm::dvec3 patchNormal = ellipsoid.geodeticSurfaceNormal(pointOnPatch);
glm::dvec3 patchPosition = ellipsoid.cartesianSurfacePosition(pointOnPatch);
Chunk::BoundingHeights heights = chunk.getBoundingHeights();
double heightToChunk = heights.min;
// Offset position according to height
patchPosition += patchNormal * heightToChunk;
glm::dvec3 cameraToChunk = patchPosition - cameraPosition;
// Calculate desired level based on distance
@@ -32,7 +32,7 @@
#include <openspace/util/updatestructures.h>
namespace openspace::globebrowsing::chunklevelevaluator {
int ProjectedArea::getDesiredLevel(const Chunk& chunk, const RenderData& data) const {
// Calculations are done in the reference frame of the globe
// (model space). Hence, the camera position needs to be transformed
@@ -47,13 +47,13 @@ int ProjectedArea::getDesiredLevel(const Chunk& chunk, const RenderData& data) c
glm::dvec3 cameraToEllipsoidCenter = -cameraPosition;
Geodetic2 cameraGeodeticPos = ellipsoid.cartesianToGeodetic2(cameraPosition);
// Approach:
// The projected area of the chunk will be calculated based on a small area that
// is close to the camera, and the scaled up to represent the full area.
// The advantage of doing this is that it will better handle the cases where the
// full patch is very curved (e.g. stretches from latitude 0 to 90 deg).
const Geodetic2 center = chunk.surfacePatch().center();
const Geodetic2 closestCorner = chunk.surfacePatch().closestCorner(cameraGeodeticPos);
@@ -71,12 +71,12 @@ int ProjectedArea::getDesiredLevel(const Chunk& chunk, const RenderData& data) c
// | center |
// | |
// +-----------------+ <-- south east corner
Chunk::BoundingHeights heights = chunk.getBoundingHeights();
const Geodetic3 c = { center, heights.min };
const Geodetic3 c1 = { Geodetic2(center.lat, closestCorner.lon), heights.min };
const Geodetic3 c2 = { Geodetic2(closestCorner.lat, center.lon), heights.min };
// Camera
// |
// V
@@ -28,7 +28,7 @@
#include <modules/globebrowsing/chunk/chunklevelevaluator/chunklevelevaluator.h>
namespace openspace::globebrowsing::chunklevelevaluator {
/**
* Evaluate the chunk level using the area of the non-heightmapped Chunk projected
* on a sphere with the center in the position of the camera. A Chunk near the
+1 -1
View File
@@ -177,7 +177,7 @@ void ChunkNode::merge() {
}
_children[i] = nullptr;
}
ghoul_assert(isLeaf(), "ChunkNode must be leaf after merge");
}
@@ -42,7 +42,7 @@ bool FrustumCuller::isCullable(const Chunk& chunk, const RenderData& data) {
* viewTransform * modelTransform;
const std::vector<glm::dvec4>& corners = chunk.getBoundingPolyhedronCorners();
// Create a bounding box that fits the patch corners
AABB3 bounds; // in screen space
std::vector<glm::vec4> clippingSpaceCorners(8);
@@ -53,7 +53,7 @@ bool FrustumCuller::isCullable(const Chunk& chunk, const RenderData& data) {
glm::dvec3 ndc = glm::dvec3((1.0f / glm::abs(cornerClippingSpace.w)) * cornerClippingSpace);
bounds.expand(ndc);
}
return !(_viewFrustum.intersects(bounds));
}
@@ -74,7 +74,7 @@ bool HorizonCuller::isCullable(const Chunk& chunk, const RenderData& data) {
objectPosition = corners[i];
}
}
return isCullable(cameraPosition, globePosition, objectPosition,
maxHeight, minimumGlobeRadius);
}
@@ -88,16 +88,16 @@ bool HorizonCuller::isCullable(const glm::dvec3& cameraPosition,
double distanceToHorizon =
sqrt(pow(length(cameraPosition - globePosition), 2) -
pow(minimumGlobeRadius, 2));
double minimumAllowedDistanceToObjectFromHorizon = sqrt(
pow(length(objectPosition - globePosition), 2) -
pow(minimumGlobeRadius - objectBoundingSphereRadius, 2));
// Minimum allowed for the object to be occluded
double minimumAllowedDistanceToObjectSquared =
pow(distanceToHorizon + minimumAllowedDistanceToObjectFromHorizon, 2)
+ pow(objectBoundingSphereRadius, 2);
double distanceToObjectSquared = pow(length(objectPosition - cameraPosition), 2);
return distanceToObjectSquared > minimumAllowedDistanceToObjectSquared;
}
+1 -1
View File
@@ -120,7 +120,7 @@ public:
Angle<T> getClamped(const Angle<T>& min = ZERO, const Angle<T>& max = FULL) const;
Angle<T> getAbs() const;
private:
T _radians;
};
+3 -4
View File
@@ -41,7 +41,7 @@ void Ellipsoid::updateInternalCache() {
_cached._oneOverRadiiSquared = glm::dvec3(1) / _cached._radiiSquared;
_cached._radiiToTheFourth = _cached._radiiSquared * _cached._radiiSquared;
std::vector<double> radii = { _radii.x, _radii.y, _radii.z };
std::sort(radii.begin(), radii.end());
_cached._minimumRadius = radii[0];
@@ -58,7 +58,7 @@ glm::dvec3 Ellipsoid::geodeticSurfaceProjection(const glm::dvec3& p) const {
double beta = 1.0 / sqrt(dot(p * p, _cached._oneOverRadiiSquared));
double n = glm::length(beta * p * _cached._oneOverRadiiSquared);
double alpha = (1.0 - beta) * (glm::length(p) / n);
glm::dvec3 p2 = p * p;
glm::dvec3 d, d2, d3;
@@ -72,7 +72,7 @@ glm::dvec3 Ellipsoid::geodeticSurfaceProjection(const glm::dvec3& p) const {
d = glm::dvec3(1.0) + alpha * _cached._oneOverRadiiSquared;
d2 = d * d;
d3 = d * d2;
s = glm::dot(p2 / (_cached._radiiSquared * d2), glm::dvec3(1.0)) - 1.0;
dSdA = -2.0 * glm::dot(p2 / (_cached._radiiToTheFourth * d3), glm::dvec3(1.0));
@@ -99,7 +99,6 @@ const glm::dvec3& Ellipsoid::radii() const {
return _radii;
}
const glm::dvec3& Ellipsoid::radiiSquared() const {
return _cached._radiiSquared;
}
+2 -2
View File
@@ -66,12 +66,12 @@ public:
glm::dvec3 geodeticSurfaceNormalForGeocentricallyProjectedPoint(const glm::dvec3& p) const;
glm::dvec3 geodeticSurfaceNormal(Geodetic2 geodetic2) const;
const glm::dvec3& radii() const;
const glm::dvec3& radiiSquared() const;
const glm::dvec3& oneOverRadiiSquared() const;
const glm::dvec3& radiiToTheFourth() const;
double minimumRadius() const;
double maximumRadius() const;
double averageRadius() const;
+1 -1
View File
@@ -32,7 +32,7 @@ namespace openspace::globebrowsing {
struct Geodetic2 {
Geodetic2(double latitude = 0.0, double longitude = 0.0);
Geodetic2(const Geodetic2& src);
//static Geodetic2 fromCartesian(const Vec3& v);
//Vec3 asUnitCartesian() const;
@@ -114,7 +114,7 @@ double GeodeticPatch::minLon() const {
double GeodeticPatch::maxLon() const {
return _center.lon + _halfSize.lon;
}
bool GeodeticPatch::contains(const Geodetic2& p) const {
Geodetic2 diff = _center - p;
return glm::abs(diff.lat) <= _halfSize.lat && glm::abs(diff.lon) <= _halfSize.lon;
@@ -158,11 +158,11 @@ Geodetic2 GeodeticPatch::closestCorner(const Geodetic2& p) const {
// LatLon vector from patch center to the point
Geodetic2 centerToPoint = p - _center;
// Normalize the difference angles to be centered around 0.
Ang latDiff = Ang::fromRadians(centerToPoint.lat).normalizeAround(Ang::ZERO);
Ang lonDiff = Ang::fromRadians(centerToPoint.lon).normalizeAround(Ang::ZERO);
// If latDiff > 0
// --> point p is north of the patch center
// --> the closest corner to the point must be a northern one
@@ -204,7 +204,6 @@ Geodetic2 GeodeticPatch::closestPoint(const Geodetic2& p) const {
//
// Just doing this actually makes points returned from this methods being the
// true closest point, great-circle distance-wise.
using Ang = Angle<double>;
+21 -22
View File
@@ -59,7 +59,6 @@
#include "globebrowsingmodule_lua.inl"
namespace {
const char* _loggerCat = "GlobeBrowsingModule";
@@ -70,7 +69,6 @@ namespace {
// Idea: Iterate over the list of sublayers keeping a current layer and identify it
// by its number. If this number changes, we know that we have a new layer
using Layer = openspace::GlobeBrowsingModule::Layer;
std::vector<Layer> result;
@@ -87,7 +85,6 @@ namespace {
);
if (iDataset != currentLayerNumber) {
// We are done with the previous version
result.push_back(std::move(currentLayer));
@@ -146,7 +143,7 @@ void GlobeBrowsingModule::internalInitialize() {
addPropertySubOwner(GdalWrapper::ref());
#endif // GLOBEBROWSING_USE_GDAL
});
// Render
OsEng.registerModuleCallback(OpenSpaceEngine::CallbackOption::Render, [&]{
_tileCache->update();
@@ -166,7 +163,7 @@ void GlobeBrowsingModule::internalInitialize() {
auto fTileProvider =
std::make_unique<ghoul::TemplateFactory<tileprovider::TileProvider>>();
ghoul_assert(fTileProvider, "TileProvider factory was not created");
// Register renderable class
fRenderable->registerClass<globebrowsing::RenderableGlobe>("RenderableGlobe");
@@ -187,7 +184,7 @@ void GlobeBrowsingModule::internalInitialize() {
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(layergroupid::TypeID::ByLevelTileLayer)]);
fTileProvider->registerClass<tileprovider::TileProviderByIndex>(
layergroupid::LAYER_TYPE_NAMES[static_cast<int>(layergroupid::TypeID::ByIndexTileLayer)]);
FactoryManager::ref().addFactory(std::move(fTileProvider));
}
@@ -298,7 +295,7 @@ void GlobeBrowsingModule::goToGeo(double latitude, double longitude,
double altitude)
{
using namespace globebrowsing;
Camera* cam = OsEng.navigationHandler().camera();
goToGeodetic3(
*cam,
@@ -328,18 +325,18 @@ void GlobeBrowsingModule::goToChunk(Camera& camera, globebrowsing::TileIndex ti,
glm::dmat4 inverseModelTransform = globe->inverseModelTransform();
glm::dvec3 cameraPositionModelSpace =
glm::dvec3(inverseModelTransform * glm::dvec4(camPos, 1));
GeodeticPatch patch(ti);
Geodetic2 corner = patch.getCorner(SOUTH_WEST);
Geodetic2 positionOnPatch = patch.getSize();
positionOnPatch.lat *= uv.y;
positionOnPatch.lon *= uv.x;
Geodetic2 pointPosition = corner + positionOnPatch;
glm::dvec3 positionOnEllipsoid =
globe->ellipsoid().geodeticSurfaceProjection(cameraPositionModelSpace);
double altitude = glm::length(cameraPositionModelSpace - positionOnEllipsoid);
goToGeodetic3(camera, {pointPosition, altitude}, resetCameraDirection);
}
@@ -354,22 +351,23 @@ void GlobeBrowsingModule::goToGeodetic2(Camera& camera,
LERROR("Focus node must have a RenderableGlobe renderable.");
return;
}
glm::dvec3 cameraPosition = OsEng.navigationHandler().camera()->positionVec3();
glm::dmat4 inverseModelTransform =
OsEng.navigationHandler().focusNode()->inverseModelTransform();
glm::dvec3 cameraPositionModelSpace =
glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0));
SurfacePositionHandle posHandle = globe->calculateSurfacePositionHandle(
cameraPositionModelSpace);
cameraPositionModelSpace
);
glm::dvec3 centerToActualSurface = posHandle.centerToReferenceSurface +
posHandle.referenceSurfaceOutDirection * posHandle.heightToSurface;
double altitude = glm::length(cameraPositionModelSpace - centerToActualSurface);
goToGeodetic3(camera, {geo2, altitude}, resetCameraDirection);
}
void GlobeBrowsingModule::goToGeodetic3(Camera& camera, globebrowsing::Geodetic3 geo3,
bool resetCameraDirection)
{
@@ -403,24 +401,27 @@ void GlobeBrowsingModule::resetCameraDirection(Camera& camera, globebrowsing::Ge
// Camera is described in world space
glm::dmat4 modelTransform = globe->modelTransform();
// Lookup vector
glm::dvec3 positionModelSpace = globe->ellipsoid().cartesianSurfacePosition(geo2);
glm::dvec3 slightlyNorth = globe->ellipsoid().cartesianSurfacePosition(
Geodetic2(geo2.lat + 0.001, geo2.lon));
glm::dvec3 lookUpModelSpace = glm::normalize(slightlyNorth - positionModelSpace);
glm::dvec3 lookUpWorldSpace = glm::dmat3(modelTransform) * lookUpModelSpace;
// Lookat vector
glm::dvec3 lookAtWorldSpace = glm::dvec3(modelTransform * glm::dvec4(positionModelSpace, 1.0));
// Eye position
glm::dvec3 eye = camera.positionVec3();
// Matrix
glm::dmat4 lookAtMatrix = glm::lookAt(
eye, lookAtWorldSpace, lookUpWorldSpace);
eye,
lookAtWorldSpace,
lookUpWorldSpace
);
// Set rotation
glm::dquat rotation = glm::quat_cast(inverse(lookAtMatrix));
camera.setRotation(rotation);
@@ -487,7 +488,7 @@ void GlobeBrowsingModule::loadWMSCapabilities(std::string name, std::string glob
GDALClose(dataset);
return cap;
};
_inFlightCapabilitiesMap[name] = std::async(std::launch::async, downloadFunction, url);
_urlList.emplace(std::move(globe), UrlInfo{ std::move(name), std::move(url) });
@@ -541,7 +542,6 @@ void GlobeBrowsingModule::removeWMSServer(const std::string& name) {
}
}
std::vector<GlobeBrowsingModule::UrlInfo>
GlobeBrowsingModule::urlInfo(const std::string& globe) const
{
@@ -553,7 +553,6 @@ GlobeBrowsingModule::urlInfo(const std::string& globe) const
return res;
}
#endif // GLOBEBROWSING_USE_GDAL
} // namespace openspace
@@ -85,7 +85,6 @@ protected:
void internalInitialize() override;
private:
void goToChunk(Camera& camera, globebrowsing::TileIndex ti, glm::vec2 uv,
bool resetCameraDirection);
void goToGeodetic2(Camera& camera, globebrowsing::Geodetic2 geo2,
@@ -61,13 +61,13 @@ int addLayer(lua_State* L) {
if (!node) {
return luaL_error(L, ("Unknown globe name: " + GlobeName).c_str());
}
// Get the renderable globe
RenderableGlobe* globe = dynamic_cast<RenderableGlobe*>(node->renderable());
if (!globe) {
return luaL_error(L, ("Renderable is not a globe: " + GlobeName).c_str());
}
// Get the layer group
layergroupid::GroupID groupID = layergroupid::getGroupIDFromName(LayerGroupName);
if (groupID == layergroupid::GroupID::Unknown) {
@@ -85,7 +85,7 @@ int addLayer(lua_State* L) {
}
globe->layerManager()->addLayer(groupID, d);
return 0;
}
@@ -115,13 +115,13 @@ int deleteLayer(lua_State* L) {
if (!node) {
return luaL_error(L, ("Unknown globe name: " + GlobeName).c_str());
}
// Get the renderable globe
RenderableGlobe* globe = dynamic_cast<RenderableGlobe*>(node->renderable());
if (!globe) {
return luaL_error(L, ("Renderable is not a globe: " + GlobeName).c_str());
}
// Get the layer group
layergroupid::GroupID groupID = layergroupid::getGroupIDFromName(LayerGroupName);
if (groupID == layergroupid::GroupID::Unknown) {
@@ -129,7 +129,7 @@ int deleteLayer(lua_State* L) {
}
globe->layerManager()->deleteLayer(groupID, LayerName);
return 0;
}
@@ -251,7 +251,7 @@ int capabilities(lua_State* L) {
lua_newtable(L);
for (unsigned long i = 0; i < cap.size(); ++i) {
const GlobeBrowsingModule::Layer& l = cap[i];
lua_newtable(L);
lua_pushstring(L, "Name");
@@ -269,5 +269,4 @@ int capabilities(lua_State* L) {
}
#endif // GLOBEBROWSING_USE_GDAL
} // namespace openspace::globebrowsing::luascriptfunctions
@@ -93,7 +93,7 @@ ChunkedLodGlobe::ChunkedLodGlobe(const RenderableGlobe& owner, size_t segmentsPe
// The destructor is defined here to make it feasiable to use a unique_ptr
// with a forward declaration
ChunkedLodGlobe::~ChunkedLodGlobe() {}
bool ChunkedLodGlobe::isReady() const {
return true;
}
@@ -144,14 +144,14 @@ int ChunkedLodGlobe::getDesiredLevel(
desiredLevel = glm::clamp(desiredLevel, minSplitDepth, maxSplitDepth);
return desiredLevel;
}
float ChunkedLodGlobe::getHeight(glm::dvec3 position) const {
float height = 0;
// Get the uv coordinates to sample from
Geodetic2 geodeticPosition = _owner.ellipsoid().cartesianToGeodetic2(position);
int chunkLevel = findChunkNode(geodeticPosition).getChunk().tileIndex().level;
TileIndex tileIndex = TileIndex(geodeticPosition, chunkLevel);
GeodeticPatch patch = GeodeticPatch(tileIndex);
@@ -167,7 +167,7 @@ float ChunkedLodGlobe::getHeight(glm::dvec3 position) const {
// Get the tile providers for the height maps
const std::vector<std::shared_ptr<Layer>>& heightMapLayers =
_layerManager->layerGroup(layergroupid::GroupID::HeightLayers).activeLayers();
for (const std::shared_ptr<Layer>& layer : heightMapLayers) {
tileprovider::TileProvider* tileProvider = layer->tileProvider();
if (!tileProvider) {
@@ -199,7 +199,7 @@ float ChunkedLodGlobe::getHeight(glm::dvec3 position) const {
// in range [0,1] and uses the set interpolation method and clamping.
glm::uvec3 dimensions = tileTexture->dimensions();
glm::vec2 samplePos = transformedUv * glm::vec2(dimensions);
glm::uvec2 samplePos00 = samplePos;
samplePos00 = glm::clamp(
@@ -239,7 +239,7 @@ float ChunkedLodGlobe::getHeight(glm::dvec3 position) const {
sample01 == tileProvider->noDataValueAsFloat() ||
sample10 == tileProvider->noDataValueAsFloat() ||
sample11 == tileProvider->noDataValueAsFloat();
if (anySampleIsNaN || anySampleIsNoData) {
continue;
}
@@ -253,8 +253,7 @@ float ChunkedLodGlobe::getHeight(glm::dvec3 position) const {
// if the sample is actually a no-data-value (min_float) the interpolated
// value might not be. Therefore we have a cut-off. Assuming no data value
// is smaller than -100000
if (sample > -100000)
{
if (sample > -100000) {
// Perform depth transform to get the value in meters
height = depthTransform.depthOffset + depthTransform.depthScale * sample;
// Make sure that the height value follows the layer settings.
@@ -282,7 +281,7 @@ void ChunkedLodGlobe::render(const RenderData& data, RendererTasks&) {
_renderer->recompileShaders(_owner);
_shadersNeedRecompilation = false;
}
auto duration = std::chrono::system_clock::now().time_since_epoch();
auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
stats.i["time"] = millis;
@@ -311,7 +310,7 @@ void ChunkedLodGlobe::render(const RenderData& data, RendererTasks&) {
_leftRoot->breadthFirst(renderJob);
_rightRoot->breadthFirst(renderJob);
//_leftRoot->reverseBreadthFirst(renderJob);
//_rightRoot->reverseBreadthFirst(renderJob);
@@ -328,7 +327,7 @@ void ChunkedLodGlobe::debugRenderChunk(const Chunk& chunk, const glm::dmat4& mvp
chunk.getBoundingPolyhedronCorners();
std::vector<glm::vec4> clippingSpaceCorners(8);
AABB3 screenSpaceBounds;
for (size_t i = 0; i < 8; ++i) {
const glm::vec4& clippingSpaceCorner = mvp * modelSpaceCorners[i];
clippingSpaceCorners[i] = clippingSpaceCorner;
@@ -359,5 +358,5 @@ void ChunkedLodGlobe::update(const UpdateData& data) {
));
_renderer->update();
}
} // namespace openspace::globebrowsing
@@ -36,7 +36,7 @@
namespace openspace::globebrowsing {
namespace chunklevelevaluator { class Evaluator; }
namespace culling { class ChunkCuller; }
class Chunk;
@@ -51,7 +51,7 @@ public:
ChunkedLodGlobe(const RenderableGlobe& owner, size_t segmentsPerPatch,
std::shared_ptr<LayerManager> layerManager);
~ChunkedLodGlobe();
bool isReady() const override;
void render(const RenderData& data, RendererTasks& rendererTask) override;
@@ -86,7 +86,7 @@ public:
* its siblings.
*/
int getDesiredLevel(const Chunk& chunk, const RenderData& renderData) const;
/**
* Calculates the height from the surface of the reference ellipsoid to the
* heigh mapped surface.
@@ -118,7 +118,7 @@ public:
std::shared_ptr<LayerManager> layerManager() const;
StatsCollector stats;
private:
void debugRenderChunk(const Chunk& chunk, const glm::dmat4& data) const;
@@ -127,7 +127,7 @@ private:
static const TileIndex RIGHT_HEMISPHERE_INDEX;
const RenderableGlobe& _owner;
// Covers all negative longitudes
std::unique_ptr<ChunkNode> _leftRoot;
+10 -10
View File
@@ -83,7 +83,7 @@ void PointGlobe::initialize() {
glm::vec2(1.0f, -1.0f),
glm::vec2(1.0f, 1.0f)
}};
// Vertex buffer
glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferID);
glBufferData(
@@ -108,7 +108,7 @@ void PointGlobe::deinitialize() {
bool PointGlobe::isReady() const {
return (_vaoID != 0) && (_vertexBufferID != 0);
}
void PointGlobe::render(const RenderData& data, RendererTasks&) {
_programObject->activate();
@@ -119,7 +119,7 @@ void PointGlobe::render(const RenderData& data, RendererTasks&) {
glm::dvec3(0.0f),
data.camera.positionVec3() - bodyPosition,
glm::normalize(glm::dvec3(1000000.0f) - bodyPosition));
glm::dvec3 camToBody = bodyPosition - data.camera.positionVec3();
float distanceToBody = static_cast<float>(glm::length(camToBody));
@@ -132,7 +132,7 @@ void PointGlobe::render(const RenderData& data, RendererTasks&) {
float billboardRadius = lightIntensityClamped * distanceToBody;
glm::dmat4 scaleTransform = glm::scale(glm::dmat4(1.0), glm::dvec3(billboardRadius));
setBoundingSphere(billboardRadius);
// Model transform and view transform needs to be in double precision
@@ -143,29 +143,29 @@ void PointGlobe::render(const RenderData& data, RendererTasks&) {
glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform;
//glm::vec3 directionToSun = glm::normalize(glm::vec3(0) - glm::vec3(bodyPosition));
//glm::vec3 directionToSunViewSpace = glm::mat3(data.camera.combinedViewMatrix()) * directionToSun;
_programObject->setUniform("lightIntensityClamped", lightIntensityClamped);
//_programObject->setUniform("lightOverflow", lightOverflow);
//_programObject->setUniform("directionToSunViewSpace", directionToSunViewSpace);
_programObject->setUniform("modelViewTransform", glm::mat4(modelViewTransform));
_programObject->setUniform("projectionTransform", data.camera.sgctInternal.projectionMatrix());
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vertexBufferID);
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
_programObject->deactivate();
}
+1 -1
View File
@@ -46,7 +46,7 @@ public:
bool isReady() const override;
void render(const RenderData& data, RendererTasks& rendererTask) override;
private:
const RenderableGlobe& _owner;
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
@@ -23,7 +23,7 @@
****************************************************************************************/
#include <modules/globebrowsing/globes/renderableglobe.h>
#include <modules/debugging/rendering/debugrenderer.h>
#include <modules/globebrowsing/globes/chunkedlodglobe.h>
#include <modules/globebrowsing/globes/pointglobe.h>
@@ -182,7 +182,7 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
, _debugPropertyOwner({ "Debug" })
{
setName("RenderableGlobe");
dictionary.getValue(keyFrame, _frame);
// Read the radii in to its own dictionary
@@ -216,17 +216,17 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
_layerManager
);
//_pointGlobe = std::make_shared<PointGlobe>(*this);
_distanceSwitch.addSwitchValue(_chunkedLodGlobe);
//_distanceSwitch.addSwitchValue(_pointGlobe);
addProperty(_generalProperties.atmosphereEnabled);
addProperty(_generalProperties.performShading);
addProperty(_generalProperties.useAccurateNormals);
addProperty(_generalProperties.lodScaleFactor);
addProperty(_generalProperties.cameraMinHeight);
addProperty(_generalProperties.orenNayarRoughness);
_debugPropertyOwner.addProperty(_debugProperties.saveOrThrowCamera);
_debugPropertyOwner.addProperty(_debugProperties.showChunkEdges);
_debugPropertyOwner.addProperty(_debugProperties.showChunkBounds);
@@ -242,7 +242,7 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
_debugPropertyOwner.addProperty(_debugProperties.collectStats);
_debugPropertyOwner.addProperty(_debugProperties.limitLevelByAvailableData);
_debugPropertyOwner.addProperty(_debugProperties.modelSpaceRenderingCutoffLevel);
auto notifyShaderRecompilation = [&](){
_chunkedLodGlobe->notifyShaderRecompilation();
};
@@ -357,7 +357,7 @@ const RenderableGlobe::DebugProperties&
RenderableGlobe::debugProperties() const{
return _debugProperties;
}
const RenderableGlobe::GeneralProperties&
RenderableGlobe::generalProperties() const{
return _generalProperties;
@@ -68,7 +68,7 @@ public:
properties::BoolProperty limitLevelByAvailableData;
properties::IntProperty modelSpaceRenderingCutoffLevel;
};
struct GeneralProperties {
properties::BoolProperty performShading;
properties::BoolProperty atmosphereEnabled;
@@ -77,7 +77,7 @@ public:
properties::FloatProperty cameraMinHeight;
properties::FloatProperty orenNayarRoughness;
};
RenderableGlobe(const ghoul::Dictionary& dictionary);
~RenderableGlobe() = default;
@@ -91,7 +91,7 @@ public:
// Getters that perform calculations
glm::dvec3 projectOnEllipsoid(glm::dvec3 position);
float getHeight(glm::dvec3 position);
// Getters
std::shared_ptr<ChunkedLodGlobe> chunkedLodGlobe() const;
LayerManager* layerManager() const;
@@ -119,7 +119,7 @@ private:
std::shared_ptr<LayerManager> _layerManager;
DistanceSwitch _distanceSwitch;
std::shared_ptr<Camera> _savedCamera;
std::string _frame;
double _time;
+5 -5
View File
@@ -43,7 +43,7 @@ namespace openspace::globebrowsing {
class Grid {
public:
Grid(int xSegments, int ySegments);
virtual ~Grid() = default;
TriangleSoup& geometry();
@@ -53,7 +53,7 @@ public:
* in the x direction is xResolution + 1.
*/
virtual int xSegments() const = 0;
/**
* Returns the number of grid cells in the y direction. Hence the number of vertices
* in the y direction is xResolution + 1.
@@ -67,14 +67,14 @@ protected:
* of segments + 1.
*/
virtual std::vector<GLuint> createElements(int xSegments, int ySegments) = 0;
/**
* Should return the positions of vertices for a grid with size <code>xSegments</code>
* * <code>ySegments</code>. Where the number of vertices in each direction is the
* number of segments + 1.
*/
virtual std::vector<glm::vec4> createPositions(int xSegments, int ySegments) = 0;
/**
* Should return the texture coordinates of vertices for a grid with size
* <code>xSegments</code> * <code>ySegments</code>. Where the number of vertices in
@@ -82,7 +82,7 @@ protected:
*/
virtual std::vector<glm::vec2>
createTextureCoordinates(int xSegments, int ySegments) = 0;
/**
* Should return the normals of vertices for a grid with size <code>xSegments</code> *
* <code>ySegments</code>. Where the number of vertices in each direction is the number
+1 -1
View File
@@ -53,7 +53,7 @@ public:
Positions usePositions = Positions::No,
TextureCoordinates useTextures = TextureCoordinates::No,
Normals useNormals = Normals::No);
~TriangleSoup();
// Setters
@@ -52,7 +52,7 @@ void DistanceSwitch::render(const RenderData& data, RendererTasks& tasks) {
// view is 'fov' radians and the screen resolution is 'res' pixels.
const double fov = 2 * glm::pi<double>() / 6; // 60 degrees
int res = 2880;
// linear search through nodes to find which Renderable to render
for (std::shared_ptr<Renderable> renderable : _renderables) {
const double distance = res * renderable->boundingSphere() / tan(fov / 2);
+1 -1
View File
@@ -74,7 +74,7 @@ public:
void clearEnqueuedTasks();
private:
struct DefaultHasher {
unsigned long long operator()(const KeyType& key) const {
return static_cast<unsigned long long>(key);
@@ -49,7 +49,7 @@ void LRUThreadPoolWorker<KeyType>::operator()() {
// get the task from the queue
task = _pool._queuedTasks.popMRU().second;
}// release lock
// execute the task
+2 -2
View File
@@ -71,7 +71,7 @@ public:
* \param usage is the <code>Usage</code> for the pixel buffer
*/
PixelBuffer(size_t numBytes, Usage usage);
/**
* calls glDeleteBuffers().
*/
@@ -86,7 +86,7 @@ public:
* failed
*/
void* mapBuffer(Access access);
/**
* Maps an address pointer to GPU direct memory access. Gives access to a range of
* the buffer. The user must make sure the buffer is bound before calling this
@@ -62,7 +62,7 @@ public:
* is already mapped or if something else failed.
*/
void* mapBuffer(KeyType key, PixelBuffer::Access access);
/**
* Finds a Pixel buffer and maps a range of it if it is available.
* \param key is the identifier for the pixel buffer which can be used later when
@@ -100,7 +100,7 @@ private:
const globebrowsing::PixelBuffer::Usage _usage;
std::vector<std::unique_ptr<PixelBuffer>> _pixelBuffers;
// Maps from KeyType to index of mapped buffers
std::map<KeyType, int> _indexMap;
};
@@ -66,12 +66,12 @@ void* PixelBufferContainer<KeyType>::mapBufferRange(KeyType key, GLintptr offset
{
typename std::map<KeyType, int>::const_iterator iter = _indexMap.find(key);
bool notFoundAmongMappedBuffers = iter == _indexMap.end();
if (!notFoundAmongMappedBuffers) { // This PBO is already mapped
ghoul_assert(_pixelBuffers[iter->second], "Incorrect index map");
return nullptr;
}
// Find a pixel buffer that is unmapped
for (int i = 0; i < _pixelBuffers.size(); ++i) {
bool bufferIsMapped = _pixelBuffers[i]->isMapped();
@@ -88,7 +88,7 @@ private:
std::mutex _finishedJobsMutex;
/// An LRU thread pool is used since the jobs can be bumped and hence prioritized.
LRUThreadPool<KeyType> _threadPool;
};
} // namespace openspace::globebrowsing
+1 -1
View File
@@ -84,7 +84,7 @@ public:
Enabled enabled = Enabled::Yes, const std::string& delimiter = ",");
~StatsCollector();
void startNewRecord();
void setEnabled(bool enabled);
@@ -85,14 +85,14 @@ ghoul::opengl::ProgramObject* ChunkRenderer::getActivatedProgramWithTileData(
// Now the shader program can be accessed
ghoul::opengl::ProgramObject* programObject = layeredShaderManager->programObject();
if (layeredShaderManager->updatedOnLastCall()) {
gpuLayerManager->bind(programObject, *_layerManager);
}
// Activate the shader program
programObject->activate();
gpuLayerManager->setValue(programObject, *_layerManager, tileIndex);
// The length of the skirts is proportional to its size
@@ -106,8 +106,8 @@ ghoul::opengl::ProgramObject* ChunkRenderer::getActivatedProgramWithTileData(
if (chunk.owner().debugProperties().showHeightResolution) {
programObject->setUniform("vertexResolution",
glm::vec2(_grid->xSegments(), _grid->ySegments()));
}
}
return programObject;
}
@@ -122,7 +122,7 @@ void ChunkRenderer::setCommonUniforms(ghoul::opengl::ProgramObject& programObjec
!_layerManager->layerGroup(layergroupid::NightLayers).activeLayers().empty();
const bool waterLayersActive =
!_layerManager->layerGroup(layergroupid::WaterMasks).activeLayers().empty();
if (nightLayersActive ||
waterLayersActive ||
chunk.owner().generalProperties().atmosphereEnabled ||
@@ -153,7 +153,7 @@ void ChunkRenderer::setCommonUniforms(ghoul::opengl::ProgramObject& programObjec
chunk.surfacePatch().getCorner(Quad::NORTH_WEST));
glm::dvec3 corner11 = chunk.owner().ellipsoid().cartesianSurfacePosition(
chunk.surfacePatch().getCorner(Quad::NORTH_EAST));
// This is an assumption that the height tile has a resolution of 64 * 64
// If it does not it will still produce "correct" normals. If the resolution is
// higher the shadows will be softer, if it is lower, pixels will be visible.
@@ -180,8 +180,7 @@ void ChunkRenderer::setCommonUniforms(ghoul::opengl::ProgramObject& programObjec
}
}
void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& data){
void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& data) {
ghoul::opengl::ProgramObject* programObject = getActivatedProgramWithTileData(
_globalLayerShaderManager,
_globalGpuLayerManager,
@@ -205,11 +204,11 @@ void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& da
programObject->setUniform("distanceScaleFactor", distanceScaleFactor);
programObject->setUniform("chunkLevel", chunk.tileIndex().level);
}
// Calculate other uniform variables needed for rendering
Geodetic2 swCorner = chunk.surfacePatch().getCorner(Quad::SOUTH_WEST);
auto patchSize = chunk.surfacePatch().size();
glm::dmat4 modelTransform = chunk.owner().modelTransform();
glm::dmat4 viewTransform = data.camera.combinedViewMatrix();
glm::mat4 modelViewTransform = glm::mat4(viewTransform * modelTransform);
@@ -232,7 +231,7 @@ void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& da
{
programObject->setUniform("modelViewTransform", modelViewTransform);
}
if (chunk.owner().generalProperties().useAccurateNormals &&
!_layerManager->layerGroup(layergroupid::HeightLayers).activeLayers().empty())
{
@@ -250,16 +249,15 @@ void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& da
// render
_grid->geometry().drawUsingActiveProgram();
_globalGpuLayerManager->deactivate();
// disable shader
programObject->deactivate();
}
void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& data) {
ghoul::opengl::ProgramObject* programObject = getActivatedProgramWithTileData(
_localLayerShaderManager,
_localGpuLayerManager,
@@ -318,8 +316,6 @@ void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& dat
}
setCommonUniforms(*programObject, chunk, data);
// OpenGL rendering settings
glEnable(GL_DEPTH_TEST);
@@ -328,7 +324,7 @@ void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& dat
// render
_grid->geometry().drawUsingActiveProgram();
_localGpuLayerManager->deactivate();
// disable shader
@@ -33,7 +33,7 @@ void GPULayer::setValue(ghoul::opengl::ProgramObject* programObject, const Layer
{
gpuRenderSettings.setValue(programObject, layer.renderSettings());
gpuLayerAdjustment.setValue(programObject, layer.layerAdjustment());
switch (layer.type()) {
// Intentional fall through. Same for all tile layers
case layergroupid::TypeID::DefaultTileLayer:
@@ -62,7 +62,7 @@ void GPULayer::bind(ghoul::opengl::ProgramObject* programObject, const Layer& la
{
gpuRenderSettings.bind(layer.renderSettings(), programObject, nameBase + "settings.");
gpuLayerAdjustment.bind(layer.layerAdjustment(), programObject, nameBase + "adjustment.");
switch (layer.type()) {
// Intentional fall through. Same for all tile layers
case layergroupid::TypeID::DefaultTileLayer:
@@ -72,7 +72,7 @@ private:
GPUChunkTilePile gpuChunkTilePile;
GPULayerRenderSettings gpuRenderSettings;
GPULayerAdjustment gpuLayerAdjustment;
GPUData<glm::ivec2> paddingStartOffset;
GPUData<glm::ivec2> paddingSizeDifference;
// Adjustment layer stuff
@@ -75,5 +75,5 @@ void GPULayerGroup::deactivate() {
l->deactivate();
}
}
} // namespace openspace::globebrowsing
@@ -48,7 +48,7 @@ void GPULayerManager::bind(ghoul::opengl::ProgramObject* programObject,
gpuLayerGroup = std::make_unique<GPULayerGroup>();
}
}
for (size_t i = 0; i < layerGroups.size(); ++i) {
const std::string& nameBase = layergroupid::LAYER_GROUP_NAMES[i];
_gpuLayerGroups[i]->bind(
@@ -55,7 +55,7 @@ public:
*/
void bind(ghoul::opengl::ProgramObject* programObject,
const std::string& nameBase);
private:
GPUData<float> _gpuDepthOffset;
GPUData<float> _gpuDepthScale;
@@ -118,7 +118,7 @@ Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict,
bool padTiles = true;
layerDict.getValue<bool>(KeyPadTiles, padTiles);
TileTextureInitData initData = LayerManager::getTileTextureInitData(_layerGroupId,
padTiles);
_padTilePixelStartOffset = initData.tilePixelStartOffset();
@@ -66,9 +66,9 @@ public:
const OtherTypesProperties& otherTypesProperties() const;
const LayerRenderSettings& renderSettings() const;
const LayerAdjustment& layerAdjustment() const;
void onChange(std::function<void(void)> callback);
void update();
glm::ivec2 tilePixelStartOffset() const;
@@ -85,7 +85,7 @@ private:
void removeVisibleProperties();
LayerGroup& _parent;
properties::OptionProperty _typeOption;
properties::OptionProperty _blendModeOption;
properties::BoolProperty _enabled;
@@ -102,7 +102,7 @@ private:
glm::ivec2 _padTilePixelSizeDifference;
const layergroupid::GroupID _layerGroupId;
std::function<void(void)> _onChangeCallback;
};
@@ -84,7 +84,7 @@ void LayerAdjustment::setValuesFromDictionary(
std::string dictType;
glm::vec3 dictChromaKeyColor;
float dictChromaKeyTolerance;
if (adjustmentDict.getValue(keyType, dictType)) {
_typeOption.setValue(
static_cast<int>(layergroupid::getAdjustmentTypeIDFromName(dictType)));
@@ -55,7 +55,7 @@ public:
private:
void addVisibleProperties();
void removeVisibleProperties();
properties::OptionProperty _typeOption;
layergroupid::AdjustmentTypeID _type;
@@ -51,7 +51,7 @@ LayerManager::LayerManager(const ghoul::Dictionary& layerGroupsDict)
// Create all the layer groups
for (const std::string& groupName : layerGroupNamesInDict) {
layergroupid::GroupID groupId = layergroupid::getGroupIDFromName(groupName);
if (groupId != layergroupid::GroupID::Unknown) {
ghoul::Dictionary layerGroupDict =
layerGroupsDict.value<ghoul::Dictionary>(groupName);
@@ -62,7 +62,7 @@ LayerManager::LayerManager(const ghoul::Dictionary& layerGroupsDict)
LWARNING("Unknown layer group: " + groupName);
}
}
for (const std::shared_ptr<LayerGroup>& layerGroup : _layerGroups) {
addPropertySubOwner(layerGroup.get());
}
@@ -35,7 +35,7 @@
#include <functional>
namespace openspace::globebrowsing {
struct LayerGroup;
/**

Some files were not shown because too many files have changed in this diff Show More