Clean up code for planet radius and bounding sphere calculation (#289)

- Remove some power scaled coordaintes.
- Remove spice dependency from sphere geometry.
- Remove dead code.
This commit is contained in:
Emil Axelsson
2017-04-18 09:58:27 +02:00
committed by GitHub
parent 481ee7d821
commit 4b38b33e18
62 changed files with 178 additions and 342 deletions
+1 -1
View File
@@ -144,7 +144,7 @@ bool ModelGeometry::initialize(Renderable* parent) {
glm::pow(v.location[1], 2.f) +
glm::pow(v.location[2], 2.f), maximumDistanceSquared);
}
_parent->setBoundingSphere(PowerScaledScalar(glm::sqrt(maximumDistanceSquared), 0.0));
_parent->setBoundingSphere(glm::sqrt(maximumDistanceSquared));
if (_vertices.empty())
return false;
+10 -13
View File
@@ -55,7 +55,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
, _texturePath("texture", "Texture")
, _billboard("billboard", "Billboard", false)
, _projectionListener("projectionListener", "DisplayProjections", false)
, _size("size", "Size", glm::vec2(1,1), glm::vec2(0.f), glm::vec2(1.f, 25.f))
, _size("size", "Size", 10, 0, std::pow(10, 25))
, _origin(Origin::Center)
, _shader(nullptr)
, _textureIsDirty(false)
@@ -64,9 +64,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
, _quad(0)
, _vertexPositionBuffer(0)
{
glm::vec2 size;
dictionary.getValue("Size", size);
_size = size;
dictionary.getValue("Size", _size);
if (dictionary.hasKey("Name")) {
dictionary.getValue("Name", _nodeName);
@@ -127,7 +125,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
//_size.onChange(std::bind(&RenderablePlane::createPlane, this));
_size.onChange([this](){ _planeIsDirty = true; });
setBoundingSphere(_size.value());
setBoundingSphere(_size);
}
RenderablePlane::~RenderablePlane() {
@@ -299,16 +297,15 @@ void RenderablePlane::createPlane() {
// ============================
// GEOMETRY (quad)
// ============================
const GLfloat size = _size.value()[0];
const GLfloat w = _size.value()[1];
const GLfloat size = _size;
const GLfloat vertex_data[] = {
// x y z w s t
-size, -size, 0.f, w, 0.f, 0.f,
size, size, 0.f, w, 1.f, 1.f,
-size, size, 0.f, w, 0.f, 1.f,
-size, -size, 0.f, w, 0.f, 0.f,
size, -size, 0.f, w, 1.f, 0.f,
size, size, 0.f, w, 1.f, 1.f,
-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, 0.f, 0.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
+1 -2
View File
@@ -29,7 +29,6 @@
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/vector/vec2property.h>
#include <openspace/util/updatestructures.h>
namespace ghoul {
@@ -75,7 +74,7 @@ private:
properties::StringProperty _texturePath;
properties::BoolProperty _billboard;
properties::BoolProperty _projectionListener;
properties::Vec2Property _size;
properties::FloatProperty _size;
Origin _origin;
std::string _nodeName;
@@ -27,6 +27,7 @@
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/util/spicemanager.h>
#include <glm/glm.hpp>
#define _USE_MATH_DEFINES
#include <math.h>
@@ -39,12 +40,10 @@ namespace {
const char* KeyGridSegments = "GridSegments";
const char* KeyGridRadius = "GridRadius";
const char* KeyGridParentsRotation = "ParentsRotation";
const glm::vec2 GridRadius = { 1.f, 20.f };
}
namespace openspace {
// needs to be set from dictionary - REMEMBER
const PowerScaledScalar radius = PowerScaledScalar(1.f, 20.f);
RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _gridProgram(nullptr)
@@ -78,7 +77,7 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
int nr = 0;
const float fsegments = static_cast<float>(_segments);
const float r = static_cast<float>(radius[0]);
const float r = static_cast<float>(GridRadius[0]);
//int nr2 = 0;
@@ -117,7 +116,7 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
_varray[nr].location[i] = tmp[i];
_varray[nr].normal[i] = normal[i];
}
_varray[nr].location[3] = static_cast<GLfloat>(radius[1]);
_varray[nr].location[3] = static_cast<GLfloat>(GridRadius[1]);
++nr;
}
}
@@ -62,7 +62,6 @@ protected:
bool staticGrid;
std::string _parentsRotation;
glm::dmat3 _parentMatrix;
PowerScaledScalar _radius;
GLuint _vaoID = 3;
GLuint _vBufferID = 4;