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:
Alexander Bock
2018-06-10 04:47:34 +00:00
committed by GitHub
parent 5de728442d
commit 4952f8f977
796 changed files with 22428 additions and 24063 deletions
+40 -38
View File
@@ -33,22 +33,22 @@
#include <openspace/scene/scene.h>
#include <openspace/util/camera.h>
#include <openspace/util/factorymanager.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/misc/defer.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/textureunit.h>
namespace {
const char* KeyType = "Type";
const char* KeyTag = "Tag";
const float PlaneDepth = -2.f;
constexpr const char* KeyType = "Type";
constexpr const char* KeyTag = "Tag";
constexpr const float PlaneDepth = -2.f;
static const openspace::properties::Property::PropertyInfo EnabledInfo = {
const openspace::properties::Property::PropertyInfo EnabledInfo = {
"Enabled",
"Is Enabled",
"This setting determines whether this sceen space plane will be visible or not."
};
static const openspace::properties::Property::PropertyInfo FlatScreenInfo = {
const openspace::properties::Property::PropertyInfo FlatScreenInfo = {
"FlatScreen",
"Flat Screen specification",
"This value determines whether the location of this screen space plane will be "
@@ -59,21 +59,21 @@ namespace {
"useful in a planetarium environment."
};
static const openspace::properties::Property::PropertyInfo EuclideanPositionInfo = {
const openspace::properties::Property::PropertyInfo EuclideanPositionInfo = {
"EuclideanPosition",
"Euclidean coordinates",
"This value determines the position of this screen space plane in Euclidean "
"two-dimensional coordinates."
};
static const openspace::properties::Property::PropertyInfo SphericalPositionInfo = {
const openspace::properties::Property::PropertyInfo SphericalPositionInfo = {
"SphericalPosition",
"Spherical coordinates",
"This value determines the position of this screen space plane in a spherical "
"coordinate system."
};
static const openspace::properties::Property::PropertyInfo DepthInfo = {
const openspace::properties::Property::PropertyInfo DepthInfo = {
"Depth",
"Depth value",
"This value determines the depth of the plane. This value does not change the "
@@ -82,7 +82,7 @@ namespace {
"value."
};
static const openspace::properties::Property::PropertyInfo ScaleInfo = {
const openspace::properties::Property::PropertyInfo ScaleInfo = {
"Scale",
"Scale value",
"This value determines a scale factor for the plane. The default size of a plane "
@@ -90,7 +90,7 @@ namespace {
"the image being displayed."
};
static const openspace::properties::Property::PropertyInfo AlphaInfo = {
const openspace::properties::Property::PropertyInfo AlphaInfo = {
"Alpha",
"Transparency",
"This value determines the transparency of the screen space plane. If this value "
@@ -98,12 +98,29 @@ namespace {
"completely transparent."
};
static const openspace::properties::Property::PropertyInfo DeleteInfo = {
const openspace::properties::Property::PropertyInfo DeleteInfo = {
"Delete",
"Delete",
"If this property is triggered, this screen space plane is removed from the "
"scene."
};
glm::vec2 toEuclidean(const glm::vec2& spherical, float r) {
const float x = r * sin(spherical[0]) * sin(spherical[1]);
const float y = r * cos(spherical[1]);
return glm::vec2(x, y);
}
glm::vec3 toSpherical(const glm::vec2& euclidean) {
const float r = -sqrt(
pow(euclidean[0], 2) + pow(euclidean[1], 2) + pow(PlaneDepth, 2)
);
const float theta = atan2(-PlaneDepth, euclidean[0]) - glm::half_pi<float>();
const float phi = acos(euclidean[1] / r);
return glm::vec3(theta, phi, r);
}
} // namespace
namespace openspace {
@@ -206,7 +223,7 @@ std::unique_ptr<ScreenSpaceRenderable> ScreenSpaceRenderable::createFromDictiona
"ScreenSpaceRenderable"
);
std::string renderableType = dictionary.value<std::string>(KeyType);
const std::string& renderableType = dictionary.value<std::string>(KeyType);
return FactoryManager::ref().factory<ScreenSpaceRenderable>()->create(
renderableType,
dictionary
@@ -233,9 +250,6 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary
, _scale(ScaleInfo, 0.25f, 0.f, 2.f)
, _alpha(AlphaInfo, 1.f, 0.f, 1.f)
, _delete(DeleteInfo)
, _quad(0)
, _vertexPositionBuffer(0)
, _shader(nullptr)
, _radius(PlaneDepth)
{
if (dictionary.hasKey(KeyIdentifier)) {
@@ -310,11 +324,10 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary
addTag(std::move(tagName));
}
} else if (dictionary.hasKeyAndValue<ghoul::Dictionary>(KeyTag)) {
ghoul::Dictionary tagNames = dictionary.value<ghoul::Dictionary>(KeyTag);
std::vector<std::string> keys = tagNames.keys();
std::string tagName;
const ghoul::Dictionary& tagNames = dictionary.value<ghoul::Dictionary>(KeyTag);
const std::vector<std::string>& keys = tagNames.keys();
for (const std::string& key : keys) {
tagName = tagNames.value<std::string>(key);
std::string tagName = tagNames.value<std::string>(key);
if (!tagName.empty()) {
addTag(std::move(tagName));
}
@@ -332,6 +345,8 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary
addProperty(_delete);
}
ScreenSpaceRenderable::~ScreenSpaceRenderable() {} // NOLINT
bool ScreenSpaceRenderable::initialize() {
return true;
}
@@ -432,27 +447,14 @@ void ScreenSpaceRenderable::createPlane() {
void ScreenSpaceRenderable::useEuclideanCoordinates(bool b) {
_useEuclideanCoordinates = b;
if (_useEuclideanCoordinates) {
_euclideanPosition = toEuclidean(_sphericalPosition.value(), _radius);
_euclideanPosition = toEuclidean(_sphericalPosition, _radius);
} else {
_sphericalPosition = toSpherical(_euclideanPosition.value());
glm::vec3 sph = toSpherical(_euclideanPosition);
_sphericalPosition = sph;
_radius = sph.z;
}
}
glm::vec2 ScreenSpaceRenderable::toEuclidean(const glm::vec2& spherical, float r) {
float x = r * sin(spherical[0]) * sin(spherical[1]);
float y = r * cos(spherical[1]);
return glm::vec2(x, y);
}
glm::vec2 ScreenSpaceRenderable::toSpherical(const glm::vec2& euclidean) {
_radius = -sqrt(pow(euclidean[0],2) + pow(euclidean[1],2) + pow(PlaneDepth,2));
float theta = atan2(-PlaneDepth, euclidean[0]) - glm::half_pi<float>();
float phi = acos(euclidean[1]/_radius);
return glm::vec2(theta, phi);
}
void ScreenSpaceRenderable::createShaders() {
ghoul::Dictionary dict = ghoul::Dictionary();