mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Code cleanup branch (#618)
* Make height map fallback layer work again * Add documentation to joystick button bindings * Removed grouped property headers * Add new version number constant generated by CMake * Make Joystick deadzone work properly * Change the startup date on Earth to today * Fix key modifier handling * Add debugging indices for TreeNodeDebugging * Fix script schedule for OsirisRex * Do not open Mission schedule automatically * Upload default projection texture automatically * General code cleanup * Fix check_style_guide warnings * Remove .clang-format * MacOS compile fixes * Clang analyzer fixes
This commit is contained in:
@@ -24,13 +24,12 @@
|
||||
|
||||
#include <modules/debugging/debuggingmodule.h>
|
||||
|
||||
#include <modules/debugging/rendering/renderabledebugplane.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
#include <modules/debugging/rendering/renderabledebugplane.h>
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
|
||||
@@ -24,16 +24,14 @@
|
||||
|
||||
#include <modules/debugging/rendering/debugrenderer.h>
|
||||
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <iostream>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
//#include <ostream>
|
||||
//#include <iostream>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "DebugRenderer";
|
||||
@@ -57,15 +55,10 @@ DebugRenderer::DebugRenderer(std::unique_ptr<ghoul::opengl::ProgramObject> progr
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
DebugRenderer::~DebugRenderer()
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
DebugRenderer::~DebugRenderer() { }
|
||||
|
||||
const DebugRenderer& DebugRenderer::ref() {
|
||||
if (_reference == nullptr) {
|
||||
if (!_reference) {
|
||||
try {
|
||||
_reference = new DebugRenderer();
|
||||
}
|
||||
@@ -77,10 +70,9 @@ const DebugRenderer& DebugRenderer::ref() {
|
||||
}
|
||||
|
||||
void DebugRenderer::renderVertices(const Vertices& clippingSpacePoints, GLenum mode,
|
||||
RGBA rgba) const
|
||||
const glm::vec4& rgba) const
|
||||
{
|
||||
if (clippingSpacePoints.size() == 0) {
|
||||
// nothing to render
|
||||
if (clippingSpacePoints.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,14 +112,6 @@ void DebugRenderer::renderVertices(const Vertices& clippingSpacePoints, GLenum m
|
||||
// Draw the vertices
|
||||
glDrawArrays(mode, 0, static_cast<GLsizei>(clippingSpacePoints.size()));
|
||||
|
||||
// Check for errors
|
||||
GLenum error = glGetError();
|
||||
if (error != GL_NO_ERROR) {
|
||||
// Commenting this line. It causes errors to be printed. However
|
||||
// the errors are not caused by DebugRenderer!!
|
||||
//LERROR(error);
|
||||
}
|
||||
|
||||
// Clean up after the draw call was made
|
||||
glBindVertexArray(0);
|
||||
glDeleteVertexArrays(1, &_vaoID);
|
||||
@@ -135,11 +119,11 @@ void DebugRenderer::renderVertices(const Vertices& clippingSpacePoints, GLenum m
|
||||
_programObject->deactivate();
|
||||
}
|
||||
|
||||
|
||||
void DebugRenderer::renderBoxFaces(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba) const
|
||||
const glm::vec4& rgba) const
|
||||
{
|
||||
ghoul_assert(clippingSpaceBoxCorners.size() == 8, "Box must have 8 vertices");
|
||||
|
||||
const Vertices& V = clippingSpaceBoxCorners;
|
||||
|
||||
std::vector<glm::vec4> T;
|
||||
@@ -170,9 +154,10 @@ void DebugRenderer::renderBoxFaces(const Vertices& clippingSpaceBoxCorners,
|
||||
}
|
||||
|
||||
void DebugRenderer::renderBoxEdges(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba) const
|
||||
const glm::vec4& rgba) const
|
||||
{
|
||||
ghoul_assert(clippingSpaceBoxCorners.size() == 8, "Box must have 8 vertices");
|
||||
|
||||
const Vertices& V = clippingSpaceBoxCorners;
|
||||
|
||||
std::vector<glm::vec4> lineVertices;
|
||||
@@ -192,52 +177,51 @@ void DebugRenderer::renderBoxEdges(const Vertices& clippingSpaceBoxCorners,
|
||||
}
|
||||
|
||||
void DebugRenderer::renderNiceBox(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba) const
|
||||
const glm::vec4& rgba) const
|
||||
{
|
||||
renderBoxFaces(clippingSpaceBoxCorners, rgba);
|
||||
|
||||
glLineWidth(4.0f);
|
||||
glLineWidth(4.f);
|
||||
DebugRenderer::ref().renderBoxEdges(clippingSpaceBoxCorners, rgba);
|
||||
|
||||
glPointSize(10.0f);
|
||||
glPointSize(10.f);
|
||||
DebugRenderer::ref().renderVertices(clippingSpaceBoxCorners, GL_POINTS, rgba);
|
||||
}
|
||||
|
||||
void DebugRenderer::renderCameraFrustum(const RenderData& data, const Camera& otherCamera,
|
||||
RGBA rgba) const
|
||||
const glm::vec4& rgba) const
|
||||
{
|
||||
using namespace glm;
|
||||
// dmat4 modelTransform = translate(dmat4(1), data.position.dvec3());
|
||||
dmat4 viewTransform = dmat4(data.camera.combinedViewMatrix());
|
||||
dmat4 vp = dmat4(data.camera.projectionMatrix()) * viewTransform;
|
||||
const dmat4 viewTransform = dmat4(data.camera.combinedViewMatrix());
|
||||
const dmat4 vp = dmat4(data.camera.projectionMatrix()) * viewTransform;
|
||||
|
||||
dmat4 inverseSavedV = glm::inverse(otherCamera.combinedViewMatrix());
|
||||
dmat4 inverseSavedP = glm::inverse(otherCamera.projectionMatrix());
|
||||
const dmat4 inverseSavedV = glm::inverse(otherCamera.combinedViewMatrix());
|
||||
const dmat4 inverseSavedP = glm::inverse(otherCamera.projectionMatrix());
|
||||
Vertices clippingSpaceFrustumCorners(8);
|
||||
// loop through the corners of the saved camera frustum
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
bool cornerIsRight = i % 2 == 0;
|
||||
bool cornerIsUp = i > 3;
|
||||
bool cornerIsFar = (i / 2) % 2 == 1;
|
||||
const bool cornerIsRight = i % 2 == 0;
|
||||
const bool cornerIsUp = i > 3;
|
||||
const bool cornerIsFar = (i / 2) % 2 == 1;
|
||||
|
||||
double x = cornerIsRight ? 1 : -1;
|
||||
double y = cornerIsUp ? 1 : -1;
|
||||
double z = cornerIsFar ? 1 : 0;
|
||||
const double x = cornerIsRight ? 1 : -1;
|
||||
const double y = cornerIsUp ? 1 : -1;
|
||||
const double z = cornerIsFar ? 1 : 0;
|
||||
|
||||
// p represents a corner in the frustum of the saved camera
|
||||
dvec4 pSavedClippingSpace(x, y, z, 1);
|
||||
const dvec4 pSavedClippingSpace(x, y, z, 1);
|
||||
dvec4 pSavedCameraSpace = inverseSavedP * pSavedClippingSpace;
|
||||
if (cornerIsFar) {
|
||||
pSavedCameraSpace.w *= 1e-7;
|
||||
}
|
||||
pSavedCameraSpace = glm::abs(1.0 / pSavedCameraSpace.w) * pSavedCameraSpace;
|
||||
|
||||
dvec4 pWorldSpace = inverseSavedV * pSavedCameraSpace;
|
||||
dvec4 pCurrentClippingSpace = vp * pWorldSpace;
|
||||
const dvec4 pWorldSpace = inverseSavedV * pSavedCameraSpace;
|
||||
const dvec4 pCurrentClippingSpace = vp * pWorldSpace;
|
||||
clippingSpaceFrustumCorners[i] = pCurrentClippingSpace;
|
||||
}
|
||||
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
renderNiceBox(clippingSpaceFrustumCorners, rgba);
|
||||
glEnable(GL_CULL_FACE);
|
||||
@@ -245,13 +229,14 @@ void DebugRenderer::renderCameraFrustum(const RenderData& data, const Camera& ot
|
||||
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
void DebugRenderer::renderAABB2(const globebrowsing::AABB2& screenSpaceAABB,
|
||||
RGBA rgba) const
|
||||
const glm::vec4& rgba) const
|
||||
{
|
||||
Vertices vertices(4);
|
||||
vertices[0] = glm::vec4(screenSpaceAABB.min.x, screenSpaceAABB.min.y, 1, 1);
|
||||
vertices[1] = glm::vec4(screenSpaceAABB.min.x, screenSpaceAABB.max.y, 1, 1);
|
||||
vertices[2] = glm::vec4(screenSpaceAABB.max.x, screenSpaceAABB.min.y, 1, 1);
|
||||
vertices[3] = glm::vec4(screenSpaceAABB.max.x, screenSpaceAABB.max.y, 1, 1);
|
||||
Vertices vertices = {
|
||||
glm::vec4(screenSpaceAABB.min.x, screenSpaceAABB.min.y, 1, 1),
|
||||
glm::vec4(screenSpaceAABB.min.x, screenSpaceAABB.max.y, 1, 1),
|
||||
glm::vec4(screenSpaceAABB.max.x, screenSpaceAABB.min.y, 1, 1),
|
||||
glm::vec4(screenSpaceAABB.max.x, screenSpaceAABB.max.y, 1, 1)
|
||||
};
|
||||
|
||||
renderVertices(vertices, GL_LINES, rgba);
|
||||
}
|
||||
@@ -263,13 +248,13 @@ const DebugRenderer::Vertices DebugRenderer::verticesFor(
|
||||
{
|
||||
Vertices vertices(8);
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
bool cornerIsRight = i % 2 == 0;
|
||||
bool cornerIsUp = i > 3;
|
||||
bool cornerIsFar = (i / 2) % 2 == 1;
|
||||
const bool cornerIsRight = i % 2 == 0;
|
||||
const bool cornerIsUp = i > 3;
|
||||
const bool cornerIsFar = (i / 2) % 2 == 1;
|
||||
|
||||
double x = cornerIsRight ? screenSpaceAABB.max.x : screenSpaceAABB.min.x;
|
||||
double y = cornerIsUp ? screenSpaceAABB.max.y : screenSpaceAABB.min.y;
|
||||
double z = cornerIsFar ? screenSpaceAABB.max.z : screenSpaceAABB.min.z;
|
||||
const double x = cornerIsRight ? screenSpaceAABB.max.x : screenSpaceAABB.min.x;
|
||||
const double y = cornerIsUp ? screenSpaceAABB.max.y : screenSpaceAABB.min.y;
|
||||
const double z = cornerIsFar ? screenSpaceAABB.max.z : screenSpaceAABB.min.z;
|
||||
|
||||
vertices[i] = glm::vec4(x, y, z, 1);
|
||||
}
|
||||
|
||||
@@ -25,17 +25,18 @@
|
||||
#ifndef __OPENSPACE_MODULE_DEBUGGING___DEBUGRENDERER___H__
|
||||
#define __OPENSPACE_MODULE_DEBUGGING___DEBUGRENDERER___H__
|
||||
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
#include <modules/globebrowsing/geometry/aabb.h>
|
||||
#endif // OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
namespace ghoul::opengl { class ProgramObject; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -49,8 +50,7 @@ namespace openspace {
|
||||
*/
|
||||
class DebugRenderer {
|
||||
public:
|
||||
typedef std::vector<glm::vec4> Vertices;
|
||||
typedef glm::vec4 RGBA;
|
||||
using Vertices = std::vector<glm::vec4>;
|
||||
|
||||
/**
|
||||
* Consider using ref() before creating a new default instance!
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
* Render the vector of clipping space points in the specified mode and color.
|
||||
*/
|
||||
void renderVertices(const Vertices& clippingSpacePoints, GLenum mode,
|
||||
RGBA color = {1, 0, 0, 1}) const;
|
||||
const glm::vec4& color = { 1.f, 0.f, 0.f, 1.f }) const;
|
||||
|
||||
/**
|
||||
* Takes a vector of exactly 8 vertices, i.e. corner points in a box.
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
*
|
||||
*/
|
||||
void renderBoxFaces(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba = { 1, 0, 0, 1 }) const;
|
||||
const glm::vec4& rgba = { 1.f, 0.f, 0.f, 1.f }) const;
|
||||
|
||||
/**
|
||||
* Takes a vector of exactly 8 vertices, i.e. corner points in a box.
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
*
|
||||
*/
|
||||
void renderBoxEdges(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba = { 1, 0, 0, 1 }) const;
|
||||
const glm::vec4& rgba = { 1.f, 0.f, 0.f, 1.f }) const;
|
||||
|
||||
/**
|
||||
* Takes a vector of exactly 8 vertices, i.e. corner points in a box.
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
*
|
||||
*/
|
||||
void renderNiceBox(const Vertices& clippingSpaceBoxCorners,
|
||||
RGBA rgba = { 1, 0, 0, 0.3 }) const;
|
||||
const glm::vec4& rgba = { 1.f, 0.f, 0.f, 0.3f }) const;
|
||||
|
||||
/**
|
||||
* Input arguments:
|
||||
@@ -130,14 +130,14 @@ public:
|
||||
* 3. RGBA rgba Color to draw the view frustum with
|
||||
*/
|
||||
void renderCameraFrustum(const RenderData& data, const Camera& otherCamera,
|
||||
RGBA rgba = { 1, 1, 1, 0.3 }) const;
|
||||
const glm::vec4& rgba = { 1.f, 1.f, 1.f, 0.3f }) const;
|
||||
|
||||
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
/**
|
||||
* Renders a screen space AABB2 to the screen with the provided color
|
||||
*/
|
||||
void renderAABB2(const globebrowsing::AABB2& screenSpaceAABB,
|
||||
RGBA rgba = { 1, 1, 1, 0.3 }) const;
|
||||
const glm::vec4& rgba = { 1.f, 1.f, 1.f, 0.3f }) const;
|
||||
#endif // OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
|
||||
|
||||
|
||||
|
||||
@@ -26,22 +26,18 @@
|
||||
|
||||
#include <modules/debugging/rendering/renderabledebugplane.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <modules/spacecraftinstruments/rendering/renderableplanetprojection.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
|
||||
namespace {
|
||||
enum Origin {
|
||||
LowerLeft = 0,
|
||||
@@ -51,13 +47,13 @@ namespace {
|
||||
Center
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
const openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
"Texture",
|
||||
"Texture",
|
||||
"The OpenGL name of the texture that is displayed on this plane."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo BillboardInfo = {
|
||||
const openspace::properties::Property::PropertyInfo BillboardInfo = {
|
||||
"Billboard",
|
||||
"Billboard mode",
|
||||
"This value specifies whether the plane is a billboard, which means that it is "
|
||||
@@ -65,13 +61,13 @@ namespace {
|
||||
"transformations."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo SizeInfo = {
|
||||
const openspace::properties::Property::PropertyInfo SizeInfo = {
|
||||
"Size",
|
||||
"Size (in meters)",
|
||||
"This value specifies the size of the plane in meters."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo OriginInfo = {
|
||||
const openspace::properties::Property::PropertyInfo OriginInfo = {
|
||||
"Origin",
|
||||
"Texture Coordinate Origin",
|
||||
"The origin of the texture coorinate system."
|
||||
@@ -123,9 +119,6 @@ RenderableDebugPlane::RenderableDebugPlane(const ghoul::Dictionary& dictionary)
|
||||
, _billboard(BillboardInfo, false)
|
||||
, _size(SizeInfo, 10.f, 0.f, 1e25f)
|
||||
, _origin(OriginInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _shader(nullptr)
|
||||
, _quad(0)
|
||||
, _vertexPositionBuffer(0)
|
||||
{
|
||||
if (dictionary.hasKey(TextureInfo.identifier)) {
|
||||
_texture = static_cast<int>(dictionary.value<double>(TextureInfo.identifier));
|
||||
@@ -258,7 +251,7 @@ void RenderableDebugPlane::createPlane() {
|
||||
// ============================
|
||||
const GLfloat size = _size;
|
||||
|
||||
const GLfloat vertex_data[] = {
|
||||
const GLfloat vertexData[] = {
|
||||
// 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,
|
||||
@@ -270,7 +263,7 @@ void RenderableDebugPlane::createPlane() {
|
||||
|
||||
glBindVertexArray(_quad); // bind array
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, nullptr);
|
||||
glEnableVertexAttribArray(1);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
namespace ghoul::filesystem { class File; }
|
||||
namespace ghoul::opengl {
|
||||
@@ -43,6 +43,7 @@ namespace documentation { struct Documentation; }
|
||||
namespace openspace {
|
||||
|
||||
struct LinePoint;
|
||||
struct UpdateStructure;
|
||||
|
||||
class RenderableDebugPlane : public Renderable {
|
||||
public:
|
||||
@@ -71,8 +72,8 @@ private:
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
|
||||
|
||||
GLuint _quad;
|
||||
GLuint _vertexPositionBuffer;
|
||||
GLuint _quad = 0;
|
||||
GLuint _vertexPositionBuffer = 0;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user