From bf0a8291d61c2abb1b75ae7541c528b03b2af24d Mon Sep 17 00:00:00 2001 From: Jonas Strandstedt Date: Mon, 15 Dec 2014 17:10:43 +0100 Subject: [PATCH 01/31] Updated to the most recent Ghoul - Using new VertexBufferObject in PowerScaledSphere as a test case. --- ext/ghoul | 2 +- include/openspace/util/powerscaledsphere.h | 52 ++++++++-------- src/util/powerscaledsphere.cpp | 70 +++++----------------- 3 files changed, 41 insertions(+), 83 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index f33aef8eca..aff42bcc4f 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit f33aef8eca31db1c58855ff10a38785403cbbd5c +Subproject commit aff42bcc4fd3a7cd4c1c712c2d7e9fd0f67ccb3d diff --git a/include/openspace/util/powerscaledsphere.h b/include/openspace/util/powerscaledsphere.h index a89ea773e5..d5d6a0b41e 100644 --- a/include/openspace/util/powerscaledsphere.h +++ b/include/openspace/util/powerscaledsphere.h @@ -1,26 +1,27 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014 * -* * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this * -* software and associated documentation files (the "Software"), to deal in the Software * -* without restriction, including without limitation the rights to use, copy, modify, * -* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * -* permit persons to whom the Software is furnished to do so, subject to the following * -* conditions: * -* * -* The above copyright notice and this permission notice shall be included in all copies * -* or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * -* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * -* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * -* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * -* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * -* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * -****************************************************************************************/ + * * + * GHOUL * + * General Helpful Open Utility Library * + * * + * Copyright (c) 2012-2014 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ #ifndef __POWERSCALEDSPHERE_H__ #define __POWERSCALEDSPHERE_H__ @@ -29,6 +30,7 @@ #include #include #include +#include namespace openspace { @@ -51,14 +53,12 @@ private: GLubyte padding[28]; // Pads the struct out to 64 bytes for performance increase } Vertex; - GLuint _vaoID; - GLuint _vBufferID; - GLuint _iBufferID; - unsigned int _isize; unsigned int _vsize; Vertex* _varray; int* _iarray; + + ghoul::opengl::VertexBufferObject _vbo; }; } // namespace openspace diff --git a/src/util/powerscaledsphere.cpp b/src/util/powerscaledsphere.cpp index ec0a577be8..5d68f8fe1d 100644 --- a/src/util/powerscaledsphere.cpp +++ b/src/util/powerscaledsphere.cpp @@ -37,10 +37,7 @@ const std::string _loggerCat = "PowerScaledSphere"; namespace openspace { PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segments) - : _vaoID(0) - , _vBufferID(0) - , _iBufferID(0) - , _isize(6 * segments * segments) + : _isize(6 * segments * segments) , _vsize((segments + 1) * (segments + 1)) , _varray(new Vertex[_vsize]) , _iarray(new int[_isize]) @@ -53,7 +50,6 @@ PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segmen const float r = static_cast(radius[0]); - for (int i = 0; i <= segments; i++) { // define an extra vertex around the y-axis due to texture mapping for (int j = 0; j <= segments; j++) { @@ -134,69 +130,31 @@ PowerScaledSphere::~PowerScaledSphere() delete[] _varray; if (_iarray) delete[] _iarray; - - _varray = 0; - _iarray = 0; - - glDeleteBuffers(1, &_vBufferID); - glDeleteBuffers(1, &_iBufferID); - glDeleteVertexArrays(1, &_vaoID); } bool PowerScaledSphere::initialize() { - // Initialize and upload to graphics card - GLuint errorID; - if (_vaoID == 0) - glGenVertexArrays(1, &_vaoID); - if (_vBufferID == 0) { - glGenBuffers(1, &_vBufferID); + std::vector varray(_vsize); + std::vector iarray(_isize); + for (size_t i = 0; i < _vsize; ++i) { + varray.at(i) = _varray[i]; + } + for (size_t i = 0; i < _isize; ++i) { + iarray.at(i) = _iarray[i]; + } - if (_vBufferID == 0) { - LERROR("Could not create vertex buffer"); - return false; - } - } + _vbo.initialize(varray, iarray); + _vbo.vertexAttribPointer(0, 4, GL_FLOAT, sizeof(Vertex), offsetof(Vertex, location)); + _vbo.vertexAttribPointer(1, 2, GL_FLOAT, sizeof(Vertex), offsetof(Vertex, tex)); + _vbo.vertexAttribPointer(2, 3, GL_FLOAT, sizeof(Vertex), offsetof(Vertex, normal)); - if (_iBufferID == 0) { - glGenBuffers(1, &_iBufferID); - - if (_iBufferID == 0) { - LERROR("Could not create index buffer"); - return false; - } - } - - // First VAO setup - glBindVertexArray(_vaoID); - - glBindBuffer(GL_ARRAY_BUFFER, _vBufferID); - glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(Vertex), _varray, GL_STATIC_DRAW); - - glEnableVertexAttribArray(0); - glEnableVertexAttribArray(1); - glEnableVertexAttribArray(2); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), - reinterpret_cast(offsetof(Vertex, location))); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), - reinterpret_cast(offsetof(Vertex, tex))); - glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), - reinterpret_cast(offsetof(Vertex, normal))); - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW); - - glBindVertexArray(0); return true; } void PowerScaledSphere::render() { - glBindVertexArray(_vaoID); // select first VAO - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID); - glDrawElements(GL_TRIANGLES, _isize, GL_UNSIGNED_INT, 0); - glBindVertexArray(0); + _vbo.render(); } } // namespace openspace From 734ce03d72e52bc9ee36141f33edef91f12b24e1 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 15 Dec 2014 20:51:00 +0100 Subject: [PATCH 02/31] Changed the deinitialization of renderable from the destructorto the scenegraphnode --- include/openspace/rendering/renderable.h | 2 +- src/rendering/model/renderablemodel.cpp | 1 - src/rendering/planets/renderableplanet.cpp | 6 ++++- src/rendering/renderable.cpp | 3 +-- src/rendering/renderablefieldlines.cpp | 1 - src/rendering/renderablefov.cpp | 1 - src/rendering/renderablepath.cpp | 1 - src/rendering/renderableplane.cpp | 1 - src/rendering/renderablesphericalgrid.cpp | 2 -- src/rendering/renderabletrail.cpp | 1 - src/rendering/renderablevolumegl.cpp | 1 - .../stars/renderableconstellationbounds.cpp | 1 - src/rendering/stars/renderablestars.cpp | 1 - src/scenegraph/scenegraph.cpp | 7 ++++-- src/scenegraph/scenegraphnode.cpp | 25 +++++++++++-------- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index b19c501490..ab2b1b6d4d 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -75,7 +75,7 @@ protected: private: properties::BoolProperty _enabled; - + PowerScaledScalar boundingSphere_; std::string _relativePath; }; diff --git a/src/rendering/model/renderablemodel.cpp b/src/rendering/model/renderablemodel.cpp index e4506143cc..30aa4b9c55 100644 --- a/src/rendering/model/renderablemodel.cpp +++ b/src/rendering/model/renderablemodel.cpp @@ -86,7 +86,6 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) RenderableModel::~RenderableModel(){ - deinitialize(); } bool RenderableModel::isReady() const { diff --git a/src/rendering/planets/renderableplanet.cpp b/src/rendering/planets/renderableplanet.cpp index 231660481f..f78156dd01 100644 --- a/src/rendering/planets/renderableplanet.cpp +++ b/src/rendering/planets/renderableplanet.cpp @@ -84,10 +84,14 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) addProperty(_colorTexturePath); _colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this)); + + std::string s = _colorTexturePath.description(); + ghoul::Dictionary d; + ghoul::lua::loadDictionaryFromString(s, d); + } RenderablePlanet::~RenderablePlanet() { - deinitialize(); } bool RenderablePlanet::initialize() { diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 2a7269eb3c..258a306203 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -89,8 +89,7 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary) addProperty(_enabled); } -Renderable::~Renderable() -{ +Renderable::~Renderable() { } void Renderable::setBoundingSphere(const PowerScaledScalar& boundingSphere) diff --git a/src/rendering/renderablefieldlines.cpp b/src/rendering/renderablefieldlines.cpp index 755a78178d..9214b1e48f 100644 --- a/src/rendering/renderablefieldlines.cpp +++ b/src/rendering/renderablefieldlines.cpp @@ -87,7 +87,6 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary) } RenderableFieldlines::~RenderableFieldlines() { - deinitialize(); } bool RenderableFieldlines::isReady() const { diff --git a/src/rendering/renderablefov.cpp b/src/rendering/renderablefov.cpp index 1b3507ded7..52018218e2 100644 --- a/src/rendering/renderablefov.cpp +++ b/src/rendering/renderablefov.cpp @@ -90,7 +90,6 @@ void RenderableFov::fullYearSweep(){ } RenderableFov::~RenderableFov(){ - deinitialize(); } bool RenderableFov::isReady() const { diff --git a/src/rendering/renderablepath.cpp b/src/rendering/renderablepath.cpp index 9513f9c783..b91e047c79 100644 --- a/src/rendering/renderablepath.cpp +++ b/src/rendering/renderablepath.cpp @@ -142,7 +142,6 @@ bool RenderablePath::fullYearSweep(){ } RenderablePath::~RenderablePath(){ - deinitialize(); } bool RenderablePath::isReady() const { diff --git a/src/rendering/renderableplane.cpp b/src/rendering/renderableplane.cpp index a1b60246ff..853cf9b70f 100644 --- a/src/rendering/renderableplane.cpp +++ b/src/rendering/renderableplane.cpp @@ -95,7 +95,6 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary) } RenderablePlane::~RenderablePlane() { - deinitialize(); } bool RenderablePlane::isReady() const { diff --git a/src/rendering/renderablesphericalgrid.cpp b/src/rendering/renderablesphericalgrid.cpp index 3110cbf8dd..bb0e0c0688 100644 --- a/src/rendering/renderablesphericalgrid.cpp +++ b/src/rendering/renderablesphericalgrid.cpp @@ -128,8 +128,6 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio } RenderableSphericalGrid::~RenderableSphericalGrid(){ - deinitialize(); - // Delete not done in deinitialize because new is done in constructor delete[] _varray; delete[] _iarray; diff --git a/src/rendering/renderabletrail.cpp b/src/rendering/renderabletrail.cpp index 7c73b06497..a2bc4af6f2 100644 --- a/src/rendering/renderabletrail.cpp +++ b/src/rendering/renderabletrail.cpp @@ -139,7 +139,6 @@ void RenderableTrail::fullYearSweep(){ } RenderableTrail::~RenderableTrail(){ - deinitialize(); } bool RenderableTrail::isReady() const { diff --git a/src/rendering/renderablevolumegl.cpp b/src/rendering/renderablevolumegl.cpp index 2b343d44b3..88484cd473 100644 --- a/src/rendering/renderablevolumegl.cpp +++ b/src/rendering/renderablevolumegl.cpp @@ -160,7 +160,6 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary) } RenderableVolumeGL::~RenderableVolumeGL() { - deinitialize(); } bool RenderableVolumeGL::isReady() const { diff --git a/src/rendering/stars/renderableconstellationbounds.cpp b/src/rendering/stars/renderableconstellationbounds.cpp index 7c0d85bd30..e8e057662f 100644 --- a/src/rendering/stars/renderableconstellationbounds.cpp +++ b/src/rendering/stars/renderableconstellationbounds.cpp @@ -88,7 +88,6 @@ RenderableConstellationBounds::RenderableConstellationBounds( } RenderableConstellationBounds::~RenderableConstellationBounds() { - deinitialize(); } bool RenderableConstellationBounds::initialize() { diff --git a/src/rendering/stars/renderablestars.cpp b/src/rendering/stars/renderablestars.cpp index 35b61f6284..a671d7c161 100644 --- a/src/rendering/stars/renderablestars.cpp +++ b/src/rendering/stars/renderablestars.cpp @@ -123,7 +123,6 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) } RenderableStars::~RenderableStars() { - deinitialize(); } bool RenderableStars::isReady() const { diff --git a/src/scenegraph/scenegraph.cpp b/src/scenegraph/scenegraph.cpp index eb181d4913..e0614a6dd9 100644 --- a/src/scenegraph/scenegraph.cpp +++ b/src/scenegraph/scenegraph.cpp @@ -290,8 +290,11 @@ void SceneGraph::scheduleLoadSceneFile(const std::string& sceneDescriptionFilePa void SceneGraph::clearSceneGraph() { // deallocate the scene graph. Recursive deallocation will occur - delete _root; - _root = nullptr; + if (_root) { + _root->deinitialize(); + delete _root; + _root = nullptr; + } _nodes.erase(_nodes.begin(), _nodes.end()); _allNodes.erase(_allNodes.begin(), _allNodes.end()); diff --git a/src/scenegraph/scenegraphnode.cpp b/src/scenegraph/scenegraphnode.cpp index 092dc9ffbb..ac396a503d 100644 --- a/src/scenegraph/scenegraphnode.cpp +++ b/src/scenegraph/scenegraphnode.cpp @@ -140,10 +140,10 @@ SceneGraphNode::~SceneGraphNode() bool SceneGraphNode::initialize() { - if (_renderable != nullptr) + if (_renderable) _renderable->initialize(); - if (_ephemeris != nullptr) + if (_ephemeris) _ephemeris->initialize(); return true; @@ -153,16 +153,21 @@ bool SceneGraphNode::deinitialize() { LDEBUG("Deinitialize: " << name()); - if(_renderable) + if (_renderable) { + _renderable->deinitialize(); delete _renderable; - _renderable = nullptr; - if(_ephemeris) - delete _ephemeris; - _ephemeris = nullptr; + _renderable = nullptr; + } - // deallocate the child nodes and delete them, iterate c++11 style - for (SceneGraphNode* child : _children) - delete child; + if (_ephemeris) { + delete _ephemeris; + _ephemeris = nullptr; + } + + for (SceneGraphNode* child : _children) { + child->deinitialize(); + delete child; + } _children.clear(); // reset variables From 73c123dc691cd64a5a00d50caba622cb70647b53 Mon Sep 17 00:00:00 2001 From: Jonas Strandstedt Date: Tue, 16 Dec 2014 11:37:46 +0100 Subject: [PATCH 03/31] Updated to latest Ghoul. --- ext/ghoul | 2 +- src/util/powerscaledsphere.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index aff42bcc4f..cf0879e60f 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit aff42bcc4fd3a7cd4c1c712c2d7e9fd0f67ccb3d +Subproject commit cf0879e60fc88ecbc1ae7bf2f0df9e8393b9e708 diff --git a/src/util/powerscaledsphere.cpp b/src/util/powerscaledsphere.cpp index 5d68f8fe1d..e6b938cca7 100644 --- a/src/util/powerscaledsphere.cpp +++ b/src/util/powerscaledsphere.cpp @@ -130,6 +130,8 @@ PowerScaledSphere::~PowerScaledSphere() delete[] _varray; if (_iarray) delete[] _iarray; + + _vbo.deinitialize(); } bool PowerScaledSphere::initialize() From f7c2398b3d97fc943e866c9370d0222f07b0848d Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 16 Dec 2014 16:35:08 +0100 Subject: [PATCH 04/31] Update to newest ghoul version --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index cf0879e60f..909e982577 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit cf0879e60fc88ecbc1ae7bf2f0df9e8393b9e708 +Subproject commit 909e9825779c7c3e0b33a6e416f99f31d9da2809 From 6ad4d0743e1361cca43cd45818f56a8da2272370 Mon Sep 17 00:00:00 2001 From: Jonas Strandstedt Date: Tue, 16 Dec 2014 18:28:55 +0100 Subject: [PATCH 05/31] Updated to most recent ghoul --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index cf0879e60f..6b4efc521d 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit cf0879e60fc88ecbc1ae7bf2f0df9e8393b9e708 +Subproject commit 6b4efc521d9027d91077dc364875af3607f3e708 From b81133e381628b854b4db63779e4f6515c6105ff Mon Sep 17 00:00:00 2001 From: Jonas Strandstedt Date: Tue, 16 Dec 2014 19:09:32 +0100 Subject: [PATCH 06/31] Removes most of Visual Studio warnings --- src/engine/openspaceengine.cpp | 2 +- src/interaction/interactionhandler.cpp | 4 +- src/interaction/keyboardcontroller.cpp | 10 ++-- src/interaction/mousecontroller.cpp | 20 +++---- src/rendering/model/renderablemodel.cpp | 2 +- src/rendering/planets/renderableplanet.cpp | 2 +- src/rendering/renderablefieldlines.cpp | 6 +-- src/rendering/renderablefov.cpp | 11 ++-- src/rendering/renderablepath.cpp | 4 +- src/rendering/renderablesphericalgrid.cpp | 2 +- src/rendering/renderabletrail.cpp | 12 ++--- src/rendering/renderablevolume.cpp | 11 ++-- src/rendering/renderablevolumegl.cpp | 12 ++--- src/rendering/renderengine.cpp | 2 +- src/scenegraph/scenegraphnode.cpp | 2 +- src/util/kameleonwrapper.cpp | 62 ++++++++++++---------- src/util/progressbar.cpp | 2 +- 17 files changed, 87 insertions(+), 79 deletions(-) diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 97cec8b9b4..8409dc85fe 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -516,7 +516,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { bool buttons[2] = { button0 != 0, button1 != 0 }; double dt = std::max(sgct::Engine::instance()->getDt(), 1.0/60.0); - _gui.startFrame(dt, glm::vec2(glm::ivec2(x,y)), glm::vec2(posX, posY), buttons); + _gui.startFrame(static_cast(dt), glm::vec2(glm::ivec2(x,y)), glm::vec2(posX, posY), buttons); } } diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp index 6957623518..af18524f6a 100644 --- a/src/interaction/interactionhandler.cpp +++ b/src/interaction/interactionhandler.cpp @@ -313,7 +313,7 @@ int distance(lua_State* L) { double d1 = luaL_checknumber(L, -2); double d2 = luaL_checknumber(L, -1); - PowerScaledScalar dist(d1, d2); + PowerScaledScalar dist(static_cast(d1), static_cast(d2)); OsEng.interactionHandler().distanceDelta(dist); return 0; } @@ -515,7 +515,7 @@ void InteractionHandler::mousePositionCallback(int x, int y) { void InteractionHandler::mouseScrollWheelCallback(int pos) { if (_mouseController) - _mouseController->scrollWheel(float(pos)); + _mouseController->scrollWheel(pos); } void InteractionHandler::orbitDelta(const glm::quat& rotation) diff --git a/src/interaction/keyboardcontroller.cpp b/src/interaction/keyboardcontroller.cpp index d143bf532d..dd68e496b9 100644 --- a/src/interaction/keyboardcontroller.cpp +++ b/src/interaction/keyboardcontroller.cpp @@ -37,8 +37,8 @@ namespace interaction { void KeyboardControllerFixed::keyPressed(KeyAction action, Key key, KeyModifier modifier) { // TODO package in script - const double speed = 2.75; - const double dt = _handler->deltaTime(); + const float speed = 2.75; + const float dt = static_cast( _handler->deltaTime()); if(action == KeyAction::Press|| action == KeyAction::Repeat) { if (key == Key::S) { glm::vec3 euler(speed * dt, 0.0, 0.0); @@ -92,7 +92,7 @@ void KeyboardControllerFixed::keyPressed(KeyAction action, Key key, KeyModifier _handler->distanceDelta(dist); } if (key == Key::T) { - PowerScaledScalar dist(-speed * pow(10, 11) * dt, 0.0); + PowerScaledScalar dist(-speed * pow(10.0f, 11.0f) * dt, 0.0f); _handler->distanceDelta(dist); } //if (key == Keys::G) { @@ -101,11 +101,11 @@ void KeyboardControllerFixed::keyPressed(KeyAction action, Key key, KeyModifier // distanceDelta(dist); //} if (key == Key::Y) { - PowerScaledScalar dist(-speed * 100.0 * dt, 6.0); + PowerScaledScalar dist(-speed * 100.0f * dt, 6.0f); _handler->distanceDelta(dist); } if (key == Key::H) { - PowerScaledScalar dist(speed * 100.0 * dt, 6.0); + PowerScaledScalar dist(speed * 100.0f * dt, 6.0f); _handler->distanceDelta(dist); } diff --git a/src/interaction/mousecontroller.cpp b/src/interaction/mousecontroller.cpp index 9d089f4d15..04f9e35be7 100644 --- a/src/interaction/mousecontroller.cpp +++ b/src/interaction/mousecontroller.cpp @@ -43,10 +43,10 @@ glm::vec3 MouseController::mapToTrackball(glm::vec2 mousePos) { if (out.x*out.x + out.y*out.y <= RADIUS*RADIUS / 2.0) { //Spherical Region out.z = RADIUS*RADIUS - (out.x*out.x + out.y*out.y); - out.z = out.z > 0.0 ? sqrtf(out.z) : 0.0; + out.z = out.z > 0.0f ? sqrtf(out.z) : 0.0f; } else { //Hyperbolic Region - for smooth z values - out.z = (RADIUS*RADIUS) / (2.0*sqrt(out.x*out.x + out.y*out.y)); + out.z = (RADIUS*RADIUS) / (2.0f*sqrt(out.x*out.x + out.y*out.y)); } return glm::normalize(out); @@ -70,8 +70,8 @@ glm::vec3 MouseController::mapToCamera(glm::vec3 trackballPos) { void MouseController::trackballRotate(int x, int y) { // Normalize mouse coordinates to [0,1] - float width = sgct::Engine::instance()->getActiveXResolution(); - float height = sgct::Engine::instance()->getActiveYResolution(); + float width = static_cast(sgct::Engine::instance()->getActiveXResolution()); + float height = static_cast(sgct::Engine::instance()->getActiveYResolution()); glm::vec2 mousePos = glm::vec2((float)x / width, (float)y / height); mousePos = glm::clamp(mousePos, -0.5, 1.5); // Ugly fix #1: Camera position becomes NaN on mouse values outside [-0.5, 1.5] @@ -89,7 +89,7 @@ void MouseController::trackballRotate(int x, int y) { if (curTrackballPos != _lastTrackballPos) { // calculate rotation angle (in radians) float rotationAngle = glm::angle(curTrackballPos, _lastTrackballPos); - rotationAngle *= _handler->deltaTime() * 100.0f; + rotationAngle *= static_cast(_handler->deltaTime()) * 100.0f; // Map trackballpos to camera // glm::vec3 trackballMappedToCamera = mapToCamera(_lastTrackballPos - curTrackballPos); @@ -125,18 +125,18 @@ void TrackballMouseController::button(MouseAction action, MouseButton button) { void TrackballMouseController::move(float x, float y) { if (_leftMouseButtonDown) - trackballRotate(x, y); + trackballRotate(static_cast(x), static_cast(y)); } void TrackballMouseController::scrollWheel(int pos) { - const double speed = 4.75; - const double dt = _handler->deltaTime(); + const float speed = 4.75f; + const float dt = static_cast(_handler->deltaTime()); if (pos < 0) { - PowerScaledScalar dist(speed * dt, 0.0); + PowerScaledScalar dist(speed * dt, 0.0f); _handler->distanceDelta(dist); } else if (pos > 0) { - PowerScaledScalar dist(-speed * dt, 0.0); + PowerScaledScalar dist(-speed * dt, 0.0f); _handler->distanceDelta(dist); } } diff --git a/src/rendering/model/renderablemodel.cpp b/src/rendering/model/renderablemodel.cpp index 30aa4b9c55..850449e7ea 100644 --- a/src/rendering/model/renderablemodel.cpp +++ b/src/rendering/model/renderablemodel.cpp @@ -135,7 +135,7 @@ void RenderableModel::render(const RenderData& data) glm::mat4 tmp = glm::mat4(1); for (int i = 0; i < 3; i++){ for (int j = 0; j < 3; j++){ - tmp[i][j] = _stateMatrix[i][j]; + tmp[i][j] = static_cast(_stateMatrix[i][j]); } } diff --git a/src/rendering/planets/renderableplanet.cpp b/src/rendering/planets/renderableplanet.cpp index f78156dd01..44aa839a21 100644 --- a/src/rendering/planets/renderableplanet.cpp +++ b/src/rendering/planets/renderableplanet.cpp @@ -138,7 +138,7 @@ void RenderablePlanet::render(const RenderData& data) for (int i = 0; i < 3; i++){ for (int j = 0; j < 3; j++){ - transform[i][j] = _stateMatrix[i][j]; + transform[i][j] = static_cast(_stateMatrix[i][j]); } } transform = transform* rot; diff --git a/src/rendering/renderablefieldlines.cpp b/src/rendering/renderablefieldlines.cpp index 9214b1e48f..13a73dd2c2 100644 --- a/src/rendering/renderablefieldlines.cpp +++ b/src/rendering/renderablefieldlines.cpp @@ -114,8 +114,8 @@ bool RenderableFieldlines::initialize() { // Arrange data for glMultiDrawArrays for (int j = 0; j < fieldlinesData.size(); ++j) { _lineStart.push_back(prevEnd); - _lineCount.push_back(fieldlinesData[j].size()); - prevEnd = prevEnd + fieldlinesData[j].size(); + _lineCount.push_back(static_cast(fieldlinesData[j].size())); + prevEnd = prevEnd + static_cast(fieldlinesData[j].size()); vertexData.insert( vertexData.end(), fieldlinesData[j].begin(), fieldlinesData[j].end()); } } @@ -164,7 +164,7 @@ void RenderableFieldlines::render(const RenderData& data) { // ------ DRAW FIELDLINES ----------------- glBindVertexArray(_fieldlineVAO); - glMultiDrawArrays(GL_LINE_STRIP_ADJACENCY, &_lineStart[0], &_lineCount[0], _lineStart.size()); + glMultiDrawArrays(GL_LINE_STRIP_ADJACENCY, &_lineStart[0], &_lineCount[0], static_cast(_lineStart.size())); glBindVertexArray(0); _shader->deactivate(); diff --git a/src/rendering/renderablefov.cpp b/src/rendering/renderablefov.cpp index 52018218e2..12f9615d26 100644 --- a/src/rendering/renderablefov.cpp +++ b/src/rendering/renderablefov.cpp @@ -85,7 +85,7 @@ void RenderableFov::fullYearSweep(){ } _stride = 8; - _vsize = _varray.size(); + _vsize = static_cast(_varray.size()); _vtotal = static_cast(_vsize / _stride); } @@ -167,7 +167,7 @@ void RenderableFov::render(const RenderData& data){ for (int i = 0; i < 3; i++){ for (int j = 0; j < 3; j++){ - tmp[i][j] = _stateMatrix[i][j]; + tmp[i][j] = static_cast(_stateMatrix[i][j]); } } transform = tmp*rot; @@ -187,7 +187,7 @@ void RenderableFov::render(const RenderData& data){ bool found = openspace::SpiceManager::ref().getFieldOfView("NH_LORRI", shape, name, boresight, bounds); - float size = 4 * sizeof(float); + size_t size = 4 * sizeof(float); float *begin = &_varray[0]; glm::vec4 origin(0); @@ -195,7 +195,7 @@ void RenderableFov::render(const RenderData& data){ glm::vec4 col_end(1.00, 0.29, 0.00, 1); glm::vec4 bsight_t(boresight[0], boresight[1], boresight[2], data.position[3]-3); - float sc = 2.2; + float sc = 2.2f; glm::vec4 corner1(bounds[0][0], bounds[0][1], bounds[0][2], data.position[3]-sc); memcpy(begin, glm::value_ptr(origin), size); memcpy(begin + 4, glm::value_ptr(col_start), size); @@ -231,9 +231,8 @@ void RenderableFov::render(const RenderData& data){ void RenderableFov::update(const UpdateData& data){ - double lightTime; _time = data.time; - _delta = data.delta; + _delta = static_cast(data.delta); openspace::SpiceManager::ref().getPositionTransformMatrix("NH_SPACECRAFT", "GALACTIC", data.time, _stateMatrix); } diff --git a/src/rendering/renderablepath.cpp b/src/rendering/renderablepath.cpp index b91e047c79..9cd922930f 100644 --- a/src/rendering/renderablepath.cpp +++ b/src/rendering/renderablepath.cpp @@ -136,7 +136,7 @@ bool RenderablePath::fullYearSweep(){ et += _increment; } _stride = 8; - _vsize = _varray.size(); + _vsize = static_cast(_varray.size()); _vtotal = static_cast(_vsize / _stride); return true; } @@ -243,7 +243,7 @@ void RenderablePath::update(const UpdateData& data){ double lightTime; _time = data.time; - _delta = data.delta; + _delta = static_cast(data.delta); SpiceManager::ref().getTargetState(_target, _observer, _frame, "LT+S", data.time, _pscpos, _pscvel, lightTime); } diff --git a/src/rendering/renderablesphericalgrid.cpp b/src/rendering/renderablesphericalgrid.cpp index bb0e0c0688..1758e4ffcd 100644 --- a/src/rendering/renderablesphericalgrid.cpp +++ b/src/rendering/renderablesphericalgrid.cpp @@ -59,7 +59,7 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio dictionary.getValue(constants::renderablesphericalgrid::gridMatrix , _gridMatrix); dictionary.getValue(constants::renderablesphericalgrid::gridSegments, s); - _segments = s[0]; + _segments = static_cast(s[0]); _isize = int(6 * _segments * _segments); _vsize = int((_segments + 1) * (_segments + 1)); diff --git a/src/rendering/renderabletrail.cpp b/src/rendering/renderabletrail.cpp index a2bc4af6f2..367cf561a2 100644 --- a/src/rendering/renderabletrail.cpp +++ b/src/rendering/renderabletrail.cpp @@ -99,8 +99,8 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) void RenderableTrail::fullYearSweep(){ double lightTime = 0.0; double et = _startTrail; - double planetYear = 31540000 * _ratio; - int segments = _tropic; + float planetYear = 31540000.0f * _ratio; + int segments = static_cast(_tropic); _increment = planetYear / _tropic; @@ -134,7 +134,7 @@ void RenderableTrail::fullYearSweep(){ et -= _increment; } _stride = 8; - _vsize = _varray.size(); + _vsize = static_cast(_varray.size()); _vtotal = static_cast(_vsize / _stride); } @@ -196,7 +196,7 @@ bool RenderableTrail::initialize(){ // SpiceManager::ref().getETfromDate("2006 Aug 22 17:00:00", _startTrail); SpiceManager::ref().getETfromDate("2007 feb 26 17:30:00", _startTrail); - _dtEt = _startTrail; + _dtEt = static_cast(_startTrail); fullYearSweep(); sendToGPU(); @@ -309,8 +309,8 @@ void RenderableTrail::render(const RenderData& data){ } void RenderableTrail::update(const UpdateData& data){ - _time = data.time; - _delta = data.delta; + _time = static_cast(data.time); + _delta = static_cast(data.delta); SpiceManager::ref().getTargetState(_target, _observer, _frame, "NONE", data.time, _pscpos, _pscvel, lightTime); _pscpos[3] += 3; // KM to M diff --git a/src/rendering/renderablevolume.cpp b/src/rendering/renderablevolume.cpp index 4f409281f1..e73616cfda 100644 --- a/src/rendering/renderablevolume.cpp +++ b/src/rendering/renderablevolume.cpp @@ -152,12 +152,12 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume( float* data = new float[length]; #ifdef VOLUME_LOAD_PROGRESSBAR LINFO("Loading cache: " << cachepath); - ProgressBar pb(dimensions[2]); + ProgressBar pb(static_cast(dimensions[2])); for (size_t i = 0; i < dimensions[2]; ++i) { size_t offset = length / dimensions[2]; std::streamsize offsetsize = sizeof(float)*offset; file.read(reinterpret_cast(data + offset * i), offsetsize); - pb.print(i); + pb.print(static_cast(i)); } #else file.read(reinterpret_cast(data), sizeof(float)*length); @@ -195,10 +195,11 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume( float* data = kw.getUniformSampledVectorValues(xVariable, yVariable, zVariable, dimensions); if(cache) { - FILE* file = fopen (cachepath.c_str(), "wb"); + //FILE* file = fopen (cachepath.c_str(), "wb"); + std::ofstream file(cachepath, std::ios::in | std::ios::binary); size_t length = dimensions[0] * dimensions[1] * dimensions[2]; - fwrite(data, sizeof(float), length, file); - fclose(file); + file.write(reinterpret_cast(data), sizeof(float)*length); + file.close(); } return new ghoul::opengl::Texture(data, dimensions, ghoul::opengl::Texture::Format::RGBA, GL_RGBA, GL_FLOAT, filtermode, wrappingmode); diff --git a/src/rendering/renderablevolumegl.cpp b/src/rendering/renderablevolumegl.cpp index 88484cd473..37bec48866 100644 --- a/src/rendering/renderablevolumegl.cpp +++ b/src/rendering/renderablevolumegl.cpp @@ -126,9 +126,9 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary) _boxScaling = kw.getModelScale(); if (std::get<0>(t) == "R" && std::get<1>(t) == "R" && std::get<2>(t) == "R") { // Earth radius - _boxScaling.x *= 6.371; - _boxScaling.y *= 6.371; - _boxScaling.z *= 6.371; + _boxScaling.x *= 6.371f; + _boxScaling.y *= 6.371f; + _boxScaling.z *= 6.371f; _w = 6; } else if (std::get<0>(t) == "m" && std::get<1>(t) == "radian" && std::get<2>(t) == "radian") { @@ -143,9 +143,9 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary) _pscOffset = kw.getModelBarycenterOffset(); if (std::get<0>(t) == "R" && std::get<1>(t) == "R" && std::get<2>(t) == "R") { // Earth radius - _pscOffset[0] *= 6.371; - _pscOffset[1] *= 6.371; - _pscOffset[2] *= 6.371; + _pscOffset[0] *= 6.371f; + _pscOffset[1] *= 6.371f; + _pscOffset[2] *= 6.371f; _pscOffset[3] = 6; } else { diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index fd049ce3d9..38c0391815 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -666,7 +666,7 @@ void RenderEngine::storePerformanceMeasurements() { PerformanceLayoutEntry entries[maxValues]; }; - const int nNodes = sceneGraph()->allSceneGraphNodes().size(); + const int nNodes = static_cast(sceneGraph()->allSceneGraphNodes().size()); if (!_performanceMemory) { // Compute the total size diff --git a/src/scenegraph/scenegraphnode.cpp b/src/scenegraph/scenegraphnode.cpp index ac396a503d..5f1ccad999 100644 --- a/src/scenegraph/scenegraphnode.cpp +++ b/src/scenegraph/scenegraphnode.cpp @@ -256,7 +256,7 @@ void SceneGraphNode::render(const RenderData& data) { RenderData newData = {data.camera, thisPosition, data.doPerformanceMeasurement}; - _performanceRecord.renderTime = 0.f; + _performanceRecord.renderTime = 0; if (_renderableVisible && _renderable->isVisible() && _renderable->isReady() && _renderable->isEnabled()) { if (data.doPerformanceMeasurement) { glFinish(); diff --git a/src/util/kameleonwrapper.cpp b/src/util/kameleonwrapper.cpp index 4be16d2ebf..9a517b62ff 100644 --- a/src/util/kameleonwrapper.cpp +++ b/src/util/kameleonwrapper.cpp @@ -152,7 +152,7 @@ float* KameleonWrapper::getUniformSampledValues( assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0); LINFO("Loading variable " << var << " from CDF data with a uniform sampling"); - int size = outDimensions.x*outDimensions.y*outDimensions.z; + unsigned int size = static_cast(outDimensions.x*outDimensions.y*outDimensions.z); float* data = new float[size]; double* doubleData = new double[size]; @@ -168,7 +168,7 @@ float* KameleonWrapper::getUniformSampledValues( // HISTOGRAM const int bins = 200; - const float truncLim = 0.9; + const float truncLim = 0.9f; std::vector histogram (bins,0); auto mapToHistogram = [varMin, varMax, bins](double val) { double zeroToOne = (val-varMin)/(varMax-varMin); @@ -178,14 +178,14 @@ float* KameleonWrapper::getUniformSampledValues( return glm::clamp(izerotoone, 0, bins-1); }; - ProgressBar pb(outDimensions.x); + ProgressBar pb(static_cast(outDimensions.x)); for (int x = 0; x < outDimensions.x; ++x) { pb.print(x); for (int y = 0; y < outDimensions.y; ++y) { for (int z = 0; z < outDimensions.z; ++z) { - int index = x + y*outDimensions.x + z*outDimensions.x*outDimensions.y; + unsigned int index = static_cast(x + y*outDimensions.x + z*outDimensions.x*outDimensions.y); if (_gridType == GridType::Spherical) { // Put r in the [0..sqrt(3)] range @@ -223,7 +223,11 @@ float* KameleonWrapper::getUniformSampledValues( // Convert from [0, 2pi] rad to [0, 360] degrees phiPh = phiPh*180.f/M_PI; // Sample - value = _interpolator->interpolate(var, rPh, thetaPh, phiPh); + value = _interpolator->interpolate( + var, + static_cast(rPh), + static_cast(thetaPh), + static_cast(phiPh)); // value = _interpolator->interpolate(var, rPh, phiPh, thetaPh); } @@ -246,7 +250,11 @@ float* KameleonWrapper::getUniformSampledValues( // get interpolated data value for (xPos, yPos, zPos) // swap yPos and zPos because model has Z as up - double value = _interpolator->interpolate(var, xPos, zPos, yPos); + double value = _interpolator->interpolate( + var, + static_cast(xPos), + static_cast(zPos), + static_cast(yPos)); doubleData[index] = value; histogram[mapToHistogram(value)]++; } @@ -275,7 +283,7 @@ float* KameleonWrapper::getUniformSampledValues( int sum = 0; int stop = 0; - const int sumuntil = size * truncLim; + const int sumuntil = static_cast(static_cast(size) * truncLim); for(int i = 0; i < bins; ++i) { sum += histogram[i]; if(sum > sumuntil) { @@ -292,7 +300,7 @@ float* KameleonWrapper::getUniformSampledValues( varMax = varMin + dist; //LDEBUG(var << "Min: " << varMin); //LDEBUG(var << "Max: " << varMax); - for(int i = 0; i < size; ++i) { + for(size_t i = 0; i < size; ++i) { double normalizedVal = (doubleData[i]-varMin)/(varMax-varMin); data[i] = static_cast(glm::clamp(normalizedVal, 0.0, 1.0)); @@ -325,7 +333,7 @@ float* KameleonWrapper::getUniformSampledVectorValues( LINFO("Loading variables " << xVar << " " << yVar << " " << zVar << " from CDF data with a uniform sampling"); int channels = 4; - int size = channels*outDimensions.x*outDimensions.y*outDimensions.z; + unsigned int size = static_cast(channels*outDimensions.x*outDimensions.y*outDimensions.z); float* data = new float[size]; float varXMin = _model->getVariableAttribute(xVar, "actual_min").getAttributeFloat(); @@ -346,14 +354,14 @@ float* KameleonWrapper::getUniformSampledVectorValues( //LDEBUG(zVar << "Min: " << varZMin); //LDEBUG(zVar << "Max: " << varZMax); - ProgressBar pb(outDimensions.x); + ProgressBar pb(static_cast(outDimensions.x)); for (int x = 0; x < outDimensions.x; ++x) { pb.print(x); for (int y = 0; y < outDimensions.y; ++y) { for (int z = 0; z < outDimensions.z; ++z) { - int index = x*channels + y*channels*outDimensions.x + z*channels*outDimensions.x*outDimensions.y; + unsigned int index = static_cast(x*channels + y*channels*outDimensions.x + z*channels*outDimensions.x*outDimensions.y); if(_gridType == GridType::Cartesian) { float xPos = _xMin + stepX*x; @@ -475,7 +483,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getLorentzTrajectories( minusTraj = traceLorentzTrajectory(seedPoint, stepsize, -1.0); //minusTraj.erase(minusTraj.begin()); - int plusNum = plusTraj.size(); + size_t plusNum = plusTraj.size(); minusTraj.insert(minusTraj.begin(), plusTraj.rbegin(), plusTraj.rend()); // write colors and convert positions to meter @@ -581,21 +589,21 @@ KameleonWrapper::TraceLine KameleonWrapper::traceCartesianFieldline( k1.z = _interpolator->interpolate(zID, pos.x, pos.y, pos.z); k1 = (float)direction*glm::normalize(k1); stepX=stepX*stepSize, stepY=stepY*stepSize, stepZ=stepZ*stepSize; - k2.x = _interpolator->interpolate(xID, pos.x+(stepX/2.0)*k1.x, pos.y+(stepY/2.0)*k1.y, pos.z+(stepZ/2.0)*k1.z); - k2.y = _interpolator->interpolate(yID, pos.x+(stepX/2.0)*k1.x, pos.y+(stepY/2.0)*k1.y, pos.z+(stepZ/2.0)*k1.z); - k2.z = _interpolator->interpolate(zID, pos.x+(stepX/2.0)*k1.x, pos.y+(stepY/2.0)*k1.y, pos.z+(stepZ/2.0)*k1.z); + k2.x = _interpolator->interpolate(xID, pos.x+(stepX/2.0f)*k1.x, pos.y+(stepY/2.0f)*k1.y, pos.z+(stepZ/2.0f)*k1.z); + k2.y = _interpolator->interpolate(yID, pos.x+(stepX/2.0f)*k1.x, pos.y+(stepY/2.0f)*k1.y, pos.z+(stepZ/2.0f)*k1.z); + k2.z = _interpolator->interpolate(zID, pos.x+(stepX/2.0f)*k1.x, pos.y+(stepY/2.0f)*k1.y, pos.z+(stepZ/2.0f)*k1.z); k2 = (float)direction*glm::normalize(k2); - k3.x = _interpolator->interpolate(xID, pos.x+(stepX/2.0)*k2.x, pos.y+(stepY/2.0)*k2.y, pos.z+(stepZ/2.0)*k2.z); - k3.y = _interpolator->interpolate(yID, pos.x+(stepX/2.0)*k2.x, pos.y+(stepY/2.0)*k2.y, pos.z+(stepZ/2.0)*k2.z); - k3.z = _interpolator->interpolate(zID, pos.x+(stepX/2.0)*k2.x, pos.y+(stepY/2.0)*k2.y, pos.z+(stepZ/2.0)*k2.z); + k3.x = _interpolator->interpolate(xID, pos.x+(stepX/2.0f)*k2.x, pos.y+(stepY/2.0f)*k2.y, pos.z+(stepZ/2.0f)*k2.z); + k3.y = _interpolator->interpolate(yID, pos.x+(stepX/2.0f)*k2.x, pos.y+(stepY/2.0f)*k2.y, pos.z+(stepZ/2.0f)*k2.z); + k3.z = _interpolator->interpolate(zID, pos.x+(stepX/2.0f)*k2.x, pos.y+(stepY/2.0f)*k2.y, pos.z+(stepZ/2.0f)*k2.z); k3 = (float)direction*glm::normalize(k3); k4.x = _interpolator->interpolate(xID, pos.x+stepX*k3.x, pos.y+stepY*k3.y, pos.z+stepZ*k3.z); k4.y = _interpolator->interpolate(yID, pos.x+stepX*k3.x, pos.y+stepY*k3.y, pos.z+stepZ*k3.z); k4.z = _interpolator->interpolate(zID, pos.x+stepX*k3.x, pos.y+stepY*k3.y, pos.z+stepZ*k3.z); k4 = (float)direction*glm::normalize(k4); - pos.x = pos.x + (stepX/6.0)*(k1.x + 2.0*k2.x + 2.0*k3.x + k4.x); - pos.y = pos.y + (stepY/6.0)*(k1.y + 2.0*k2.y + 2.0*k3.y + k4.y); - pos.z = pos.z + (stepZ/6.0)*(k1.z + 2.0*k2.z + 2.0*k3.z + k4.z); + pos.x = pos.x + (stepX/6.0f)*(k1.x + 2.0f*k2.x + 2.0f*k3.x + k4.x); + pos.y = pos.y + (stepY/6.0f)*(k1.y + 2.0f*k2.y + 2.0f*k3.y + k4.y); + pos.z = pos.z + (stepZ/6.0f)*(k1.z + 2.0f*k2.z + 2.0f*k3.z + k4.z); ++numSteps; if (numSteps > maxSteps) { @@ -692,13 +700,13 @@ KameleonWrapper::TraceLine KameleonWrapper::traceLorentzTrajectory( k4 = eCharge*(E + glm::cross(tmpV, B)); k4 = glm::normalize(k4); - pos.x = pos.x + stepX*v0.x + (stepX*stepX/6.0)*(k1.x + k2.x + k3.x); - pos.y = pos.y + stepY*v0.y + (stepY*stepY/6.0)*(k1.y + k2.y + k3.y); - pos.z = pos.z + stepZ*v0.z + (stepZ*stepZ/6.0)*(k1.z + k2.z + k3.z); + pos.x = pos.x + stepX*v0.x + (stepX*stepX/6.0f)*(k1.x + k2.x + k3.x); + pos.y = pos.y + stepY*v0.y + (stepY*stepY/6.0f)*(k1.y + k2.y + k3.y); + pos.z = pos.z + stepZ*v0.z + (stepZ*stepZ/6.0f)*(k1.z + k2.z + k3.z); - v0.x = v0.x + (stepX/6.0)*(k1.x + 2.0*k2.x + 2.0*k3.x + k4.z); - v0.y = v0.y + (stepY/6.0)*(k1.y + 2.0*k2.y + 2.0*k3.y + k4.y); - v0.z = v0.z + (stepZ/6.0)*(k1.z + 2.0*k2.z + 2.0*k3.z + k4.z); + v0.x = v0.x + (stepX/6.0f)*(k1.x + 2.0f*k2.x + 2.0f*k3.x + k4.z); + v0.y = v0.y + (stepY/6.0f)*(k1.y + 2.0f*k2.y + 2.0f*k3.y + k4.y); + v0.z = v0.z + (stepZ/6.0f)*(k1.z + 2.0f*k2.z + 2.0f*k3.z + k4.z); ++numSteps; if (numSteps > maxSteps) { diff --git a/src/util/progressbar.cpp b/src/util/progressbar.cpp index 45c9a77e9c..8878471651 100644 --- a/src/util/progressbar.cpp +++ b/src/util/progressbar.cpp @@ -47,7 +47,7 @@ void ProgressBar::print(int current) { float progress = static_cast(current) / static_cast(_end - 1); int iprogress = static_cast(progress*100.0f); if (iprogress != _previous) { - int pos = _width * progress; + int pos = static_cast(static_cast(_width)* progress); int eqWidth = pos + 1; int spWidth = _width - pos + 2; _stream << "[" << std::setfill('=') << std::setw(eqWidth) From c9a3080c48fd852c9599d0a9a1e5abad9c2b33b5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 16 Dec 2014 20:09:00 +0100 Subject: [PATCH 07/31] Updated ghoul repository --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index 6b4efc521d..a6325c0ebe 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 6b4efc521d9027d91077dc364875af3607f3e708 +Subproject commit a6325c0ebef36b7fc0653de752bdee44f5d94bb1 From 5a7a518badd9323ead359f1732727755a948be10 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 16 Dec 2014 21:54:53 +0100 Subject: [PATCH 08/31] Remove cppcheck warnings --- ext/ghoul | 2 +- .../openspace/rendering/renderablevolumegl.h | 2 +- include/openspace/scenegraph/scenegraphnode.h | 2 +- src/interaction/keyboardcontroller.cpp | 6 ++-- src/interaction/luaconsole.cpp | 4 +-- src/properties/property.cpp | 3 +- src/rendering/renderablefieldlines.cpp | 5 ++-- src/rendering/renderablevolume.cpp | 2 +- src/rendering/renderablevolumegl.cpp | 3 ++ src/rendering/stars/renderablestars.cpp | 2 +- src/scenegraph/scenegraphnode.cpp | 4 +-- src/scripting/scriptengine.cpp | 1 - src/util/camera.cpp | 10 ++++++- src/util/kameleonwrapper.cpp | 30 +++++++++++++++++++ src/util/progressbar.cpp | 1 + src/util/spicemanager.cpp | 2 +- 16 files changed, 62 insertions(+), 17 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index a6325c0ebe..6c127769c1 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit a6325c0ebef36b7fc0653de752bdee44f5d94bb1 +Subproject commit 6c127769c1984285ed9d069900144d8f92207bc5 diff --git a/include/openspace/rendering/renderablevolumegl.h b/include/openspace/rendering/renderablevolumegl.h index 3b15c18edc..280ce45c66 100644 --- a/include/openspace/rendering/renderablevolumegl.h +++ b/include/openspace/rendering/renderablevolumegl.h @@ -72,7 +72,7 @@ private: GLuint _boxArray; GLuint _vertexPositionBuffer; - ghoul::opengl::ProgramObject *_boxProgram; + ghoul::opengl::ProgramObject* _boxProgram; glm::vec3 _boxScaling; psc _pscOffset; float _w; diff --git a/include/openspace/scenegraph/scenegraphnode.h b/include/openspace/scenegraph/scenegraphnode.h index 4fa81315a6..a436173cc5 100644 --- a/include/openspace/scenegraph/scenegraphnode.h +++ b/include/openspace/scenegraph/scenegraphnode.h @@ -85,7 +85,7 @@ public: Renderable* renderable(); private: - bool sphereInsideFrustum(const psc s_pos, const PowerScaledScalar& s_rad, const Camera* camera); + bool sphereInsideFrustum(const psc& s_pos, const PowerScaledScalar& s_rad, const Camera* camera); std::vector _children; SceneGraphNode* _parent; diff --git a/src/interaction/keyboardcontroller.cpp b/src/interaction/keyboardcontroller.cpp index dd68e496b9..f3279d4871 100644 --- a/src/interaction/keyboardcontroller.cpp +++ b/src/interaction/keyboardcontroller.cpp @@ -32,6 +32,10 @@ #include #include +namespace { + const std::string _loggerCat = "KeyboardController"; +} + namespace openspace { namespace interaction { @@ -149,8 +153,6 @@ void KeyboardControllerFixed::keyPressed(KeyAction action, Key key, KeyModifier } void KeyboardControllerLua::keyPressed(KeyAction action, Key key, KeyModifier modifier) { - std::string _loggerCat = "KeyboardControllerLua"; - lua_State* s = luaL_newstate(); luaL_openlibs(s); diff --git a/src/interaction/luaconsole.cpp b/src/interaction/luaconsole.cpp index e852161af9..900f063ce8 100644 --- a/src/interaction/luaconsole.cpp +++ b/src/interaction/luaconsole.cpp @@ -328,10 +328,10 @@ void LuaConsole::keyboardCallback(int key, int action) { if (_commands.at(_activeCommand) != "") { OsEng.scriptEngine().runScript(_commands.at(_activeCommand)); - if (_commandsHistory.size() > 0 && + if (!_commandsHistory.empty() && _commands.at(_activeCommand) != _commandsHistory.at(_commandsHistory.size() - 1)) _commandsHistory.push_back(_commands.at(_activeCommand)); - else if (_commandsHistory.size() == 0) + else if (_commandsHistory.empty()) _commandsHistory.push_back(_commands.at(_activeCommand)); _commands = _commandsHistory; diff --git a/src/properties/property.cpp b/src/properties/property.cpp index 6f2f8d2792..26d5b28147 100644 --- a/src/properties/property.cpp +++ b/src/properties/property.cpp @@ -52,7 +52,8 @@ const std::string Property::TypeKey = "Type"; const std::string Property::MetaDataKey = "MetaData"; Property::Property(std::string identifier, std::string guiName) - : _identifier(std::move(identifier)) + : _owner(nullptr) + , _identifier(std::move(identifier)) { if (_identifier.empty()) LWARNING("Property identifier is empty"); diff --git a/src/rendering/renderablefieldlines.cpp b/src/rendering/renderablefieldlines.cpp index 13a73dd2c2..7bd1c3d9ca 100644 --- a/src/rendering/renderablefieldlines.cpp +++ b/src/rendering/renderablefieldlines.cpp @@ -94,7 +94,7 @@ bool RenderableFieldlines::isReady() const { } bool RenderableFieldlines::initialize() { - if(_filenames.size() == 0) { + if(_filenames.empty()) { LWARNING("No proper filenames provided, cannot initialize!"); return false; } @@ -192,11 +192,12 @@ std::vector > RenderableFieldlines::getFieldlinesData(std // ------ VARIBLES / LORENTZ ----------------- if (hintsDictionary.hasKey("Variables")) { - bool xVar, yVar, zVar; + bool xVar; xVar = hintsDictionary.getValue("Variables.1", xVariable); if (xVar && xVariable == "Lorentz") { lorentz = true; } else { + bool yVar, zVar; yVar = hintsDictionary.getValue("Variables.2", yVariable); zVar = hintsDictionary.getValue("Variables.3", zVariable); diff --git a/src/rendering/renderablevolume.cpp b/src/rendering/renderablevolume.cpp index e73616cfda..15181d0ad5 100644 --- a/src/rendering/renderablevolume.cpp +++ b/src/rendering/renderablevolume.cpp @@ -330,7 +330,6 @@ ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string std::string line; while (std::getline(in, line)) { - float intensity = 1.0f; glm::vec4 rgba = glm::vec4(0.0f); // tokenize the line std::istringstream iss(line); @@ -346,6 +345,7 @@ ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string } else if(key == "upper" && tokenSize == 2) { upper = stringToNumber(tokens.at(1),upperLowerValidator); } else if(key == "mappingkey" && tokenSize == 6) { + float intensity = 1.0f; intensity = stringToNumber(tokens.at(1), intensityValidator); for(int i = 0; i < 4; ++i) rgba[i] = stringToNumber(tokens.at(i+2)); diff --git a/src/rendering/renderablevolumegl.cpp b/src/rendering/renderablevolumegl.cpp index 37bec48866..ec7109134b 100644 --- a/src/rendering/renderablevolumegl.cpp +++ b/src/rendering/renderablevolumegl.cpp @@ -52,6 +52,9 @@ RenderableVolumeGL::RenderableVolumeGL(const ghoul::Dictionary& dictionary) , _volumeName("") , _boxArray(0) , _vertexPositionBuffer(0) + , _volume(nullptr) + , _transferFunction(nullptr) + , _boxProgram(nullptr) , _boxScaling(1.0, 1.0, 1.0) , _w(0.f) , _updateTransferfunction(false) diff --git a/src/rendering/stars/renderablestars.cpp b/src/rendering/stars/renderablestars.cpp index a671d7c161..bc5a8d82fc 100644 --- a/src/rendering/stars/renderablestars.cpp +++ b/src/rendering/stars/renderablestars.cpp @@ -126,7 +126,7 @@ RenderableStars::~RenderableStars() { } bool RenderableStars::isReady() const { - return (_program != nullptr) && (_fullData.size() > 0); + return (_program != nullptr) && (!_fullData.empty()); } bool RenderableStars::initialize() { diff --git a/src/scenegraph/scenegraphnode.cpp b/src/scenegraph/scenegraphnode.cpp index 5f1ccad999..08fb6aae85 100644 --- a/src/scenegraph/scenegraphnode.cpp +++ b/src/scenegraph/scenegraphnode.cpp @@ -319,7 +319,7 @@ PowerScaledScalar SceneGraphNode::calculateBoundingSphere(){ // set the bounding sphere to 0.0 _boundingSphere = 0.0; - if (_children.size() > 0) { // node + if (!_children.empty()) { // node PowerScaledScalar maxChild; // loop though all children and find the one furthest away/with the largest @@ -367,7 +367,7 @@ Renderable* SceneGraphNode::renderable() { } // private helper methods -bool SceneGraphNode::sphereInsideFrustum(const psc s_pos, const PowerScaledScalar& s_rad, +bool SceneGraphNode::sphereInsideFrustum(const psc& s_pos, const PowerScaledScalar& s_rad, const Camera* camera) { // direction the camera is looking at in power scale diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index ecf18a9aa8..565760c71d 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -512,7 +512,6 @@ bool ScriptEngine::registerLuaLibrary(lua_State* state, const LuaLibrary& librar bool ScriptEngine::writeDocumentation(const std::string& filename, const std::string& type) const { if (type == "text") { // The additional space between the longest function name and the descriptions - const size_t AdditionalSpace = 5; LDEBUG("Writing Lua documentation of type '" << type << "' to file '" << filename << "'"); std::ofstream file(filename); diff --git a/src/util/camera.cpp b/src/util/camera.cpp index 59ffc6cf09..d86a59549a 100644 --- a/src/util/camera.cpp +++ b/src/util/camera.cpp @@ -35,7 +35,15 @@ namespace openspace { Camera::Camera() - : _cameraDirection(0.f, 0.f, 0.f) + : _maxFov(0.f) + , _sinMaxFov(0.f) + , _position() + , _viewProjectionMatrix() + , _modelMatrix() + , _viewMatrix() + , _projectionMatrix() + , _viewDirection() + , _cameraDirection(0.f, 0.f, 0.f) , _scaling(1.f, 0.f) //, _viewRotation(glm::quat(glm::vec3(0.f, 0.f, 0.f))) , _viewRotationMatrix(1.f) diff --git a/src/util/kameleonwrapper.cpp b/src/util/kameleonwrapper.cpp index 9a517b62ff..f861d07463 100644 --- a/src/util/kameleonwrapper.cpp +++ b/src/util/kameleonwrapper.cpp @@ -53,6 +53,21 @@ KameleonWrapper::KameleonWrapper() , _model(nullptr) , _type(Model::Unknown) , _interpolator(nullptr) + , _xMin(0.f) + , _xMax(0.f) + , _yMin(0.f) + , _yMax(0.f) + , _zMin(0.f) + , _zMax(0.f) + , _xValidMin(0.f) + , _xValidMax(0.f) + , _yValidMin(0.f) + , _yValidMax(0.f) + , _zValidMin(0.f) + , _zValidMax(0.f) + , _xCoordVar("") + , _yCoordVar("") + , _zCoordVar("") , _gridType(GridType::Unknown) {} @@ -61,6 +76,21 @@ KameleonWrapper::KameleonWrapper(const std::string& filename) , _model(nullptr) , _type(Model::Unknown) , _interpolator(nullptr) + , _xMin(0.f) + , _xMax(0.f) + , _yMin(0.f) + , _yMax(0.f) + , _zMin(0.f) + , _zMax(0.f) + , _xValidMin(0.f) + , _xValidMax(0.f) + , _yValidMin(0.f) + , _yValidMax(0.f) + , _zValidMin(0.f) + , _zValidMax(0.f) + , _xCoordVar("") + , _yCoordVar("") + , _zCoordVar("") , _gridType(GridType::Unknown) { open(filename); diff --git a/src/util/progressbar.cpp b/src/util/progressbar.cpp index 8878471651..2ca3881649 100644 --- a/src/util/progressbar.cpp +++ b/src/util/progressbar.cpp @@ -33,6 +33,7 @@ ProgressBar::ProgressBar(int end, int width) ProgressBar::ProgressBar(int end, int width, std::ostream& stream) : _width(width) + , _previous(-1) , _end(end) , _stream(stream) { diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index ed1a9682e0..f845e95778 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -230,7 +230,7 @@ bool SpiceManager::getValue(const std::string& body, const std::string& value, LERROR("No value was provided"); return false; } - if (v.size() == 0) { + if (v.empty()) { LERROR("Array for values has to be preallocaed"); return false; } From 72adb770f7665acc727c411a69f5f0632ece2eed Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 17 Dec 2014 18:18:12 +0100 Subject: [PATCH 09/31] Set the correct default values for MatrixProperties --- ext/ghoul | 2 +- src/properties/matrixproperty.cpp | 534 +++++++++++++++++++++++++++--- 2 files changed, 481 insertions(+), 55 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 6c127769c1..dd5ad1d055 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 6c127769c1984285ed9d069900144d8f92207bc5 +Subproject commit dd5ad1d055109bd65583086e27427382f78a7018 diff --git a/src/properties/matrixproperty.cpp b/src/properties/matrixproperty.cpp index e6cd6a8974..98b8c28c0b 100644 --- a/src/properties/matrixproperty.cpp +++ b/src/properties/matrixproperty.cpp @@ -68,128 +68,554 @@ namespace properties { } REGISTER_NUMERICALPROPERTY_SOURCE(Mat2Property, glm::mat2x2, glm::mat2x2(0), - glm::mat2x2(numeric_limits::lowest()), - glm::mat2x2(numeric_limits::max()), - glm::mat2x2(0.01f), + glm::mat2x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat2x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat2x2( + 0.01f, + 0.01f, + 0.01f, + 0.01f, + ), DEFAULT_FROM_LUA_LAMBDA(glm::mat2x2), DEFAULT_TO_LUA_LAMBDA(glm::mat2x2), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x3Property, glm::mat2x3, glm::mat2x3(0), - glm::mat2x3(numeric_limits::lowest()), - glm::mat2x3(numeric_limits::max()), - glm::mat2x3(0.01f), + glm::mat2x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat2x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat2x3( + 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f + ), DEFAULT_FROM_LUA_LAMBDA(glm::mat2x3), DEFAULT_TO_LUA_LAMBDA(glm::mat2x3), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x4Property, glm::mat2x4, glm::mat2x4(0), - glm::mat2x4(numeric_limits::lowest()), - glm::mat2x4(numeric_limits::max()), - glm::mat2x4(0.01f), + glm::mat2x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat2x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat2x4( + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f + ), DEFAULT_FROM_LUA_LAMBDA(glm::mat2x4), DEFAULT_TO_LUA_LAMBDA(glm::mat2x4), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x2Property, glm::mat3x2, glm::mat3x2(0), - glm::mat3x2(numeric_limits::lowest()), - glm::mat3x2(numeric_limits::max()), - glm::mat3x2(0.01f), + glm::mat3x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat3x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat3x2( + 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f + ), DEFAULT_FROM_LUA_LAMBDA(glm::mat3x2), DEFAULT_TO_LUA_LAMBDA(glm::mat3x2), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(Mat3Property, glm::mat3x3, glm::mat3x3(0), - glm::mat3x3(numeric_limits::lowest()), - glm::mat3x3(numeric_limits::max()), - glm::mat3x3(0.01f), + glm::mat3x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat3x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat3x3( + 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f + ), DEFAULT_FROM_LUA_LAMBDA(glm::mat3x3), DEFAULT_TO_LUA_LAMBDA(glm::mat3x3), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x4Property, glm::mat3x4, glm::mat3x4(0), - glm::mat3x4(numeric_limits::lowest()), - glm::mat3x4(numeric_limits::max()), - glm::mat3x4(0.01f), + glm::mat3x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat3x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat3x4( + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f + ), DEFAULT_FROM_LUA_LAMBDA(glm::mat3x4), DEFAULT_TO_LUA_LAMBDA(glm::mat3x4), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x2Property, glm::mat4x2, glm::mat4x2(0), - glm::mat4x2(numeric_limits::lowest()), - glm::mat4x2(numeric_limits::max()), - glm::mat4x2(0.01f), + glm::mat4x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat4x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat4x2( + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f + ), DEFAULT_FROM_LUA_LAMBDA(glm::mat4x2), DEFAULT_TO_LUA_LAMBDA(glm::mat4x2), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x3Property, glm::mat4x3, glm::mat4x3(0), - glm::mat4x3(numeric_limits::lowest()), - glm::mat4x3(numeric_limits::max()), - glm::mat4x3(0.01f), + glm::mat4x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat4x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat4x3( + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f + ), DEFAULT_FROM_LUA_LAMBDA(glm::mat4x3), DEFAULT_TO_LUA_LAMBDA(glm::mat4x3), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(Mat4Property, glm::mat4x4, glm::mat4x4(0), - glm::mat4x4(numeric_limits::lowest()), - glm::mat4x4(numeric_limits::max()), - glm::mat4x4(0.01f), + glm::mat4x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat4x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat4x4( + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f + ), DEFAULT_FROM_LUA_LAMBDA(glm::mat4x4), DEFAULT_TO_LUA_LAMBDA(glm::mat4x4), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(DMat2Property, glm::dmat2x2, glm::dmat2x2(0), - glm::dmat2x2(numeric_limits::lowest()), - glm::dmat2x2(numeric_limits::max()), - glm::dmat2x2(0.01), + glm::dmat2x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat2x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat2x2( + 0.01, 0.01, + 0.01, 0.01 + ), DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x2), DEFAULT_TO_LUA_LAMBDA(glm::dmat2x2), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x3Property, glm::dmat2x3, glm::dmat2x3(0), - glm::dmat2x3(numeric_limits::lowest()), - glm::dmat2x3(numeric_limits::max()), - glm::dmat2x3(0.01), + glm::dmat2x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat2x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat2x3( + 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01 + ), DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x3), DEFAULT_TO_LUA_LAMBDA(glm::dmat2x3), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x4Property, glm::dmat2x4, glm::dmat2x4(0), - glm::dmat2x4(numeric_limits::lowest()), - glm::dmat2x4(numeric_limits::max()), - glm::dmat2x4(0.01), + glm::dmat2x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat2x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat2x4( + 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, 0.01 + ), DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x4), DEFAULT_TO_LUA_LAMBDA(glm::dmat2x4), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x2Property, glm::dmat3x2, glm::dmat3x2(0), - glm::dmat3x2(numeric_limits::lowest()), - glm::dmat3x2(numeric_limits::max()), - glm::dmat3x2(0.01), + glm::dmat3x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat3x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat3x2( + 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01 + ), DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x2), DEFAULT_TO_LUA_LAMBDA(glm::dmat3x2), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(DMat3Property, glm::dmat3x3, glm::dmat3x3(0), - glm::dmat3x3(numeric_limits::lowest()), - glm::dmat3x3(numeric_limits::max()), - glm::dmat3x3(0.01), + glm::dmat3x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat3x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat3x3( + 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01 + ), DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x3), DEFAULT_TO_LUA_LAMBDA(glm::dmat3x3), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x4Property, glm::dmat3x4, glm::dmat3x4(0), - glm::dmat3x4(numeric_limits::lowest()), - glm::dmat3x4(numeric_limits::max()), - glm::dmat3x4(0.01), + glm::dmat3x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat3x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat3x4( + 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, 0.01 + ), DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x4), DEFAULT_TO_LUA_LAMBDA(glm::dmat3x4), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x2Property, glm::dmat4x2, glm::dmat4x2(0), - glm::dmat4x2(numeric_limits::lowest()), - glm::dmat4x2(numeric_limits::max()), - glm::dmat4x2(0.01), + glm::dmat4x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat4x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat4x2( + 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, 0.01 + ), DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x2), DEFAULT_TO_LUA_LAMBDA(glm::dmat4x2), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x3Property, glm::dmat4x3, glm::dmat4x3(0), - glm::dmat4x3(numeric_limits::lowest()), - glm::dmat4x3(numeric_limits::max()), - glm::dmat4x3(0.01), + glm::dmat4x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat4x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat4x3( + 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, 0.01 + ), DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x3), DEFAULT_TO_LUA_LAMBDA(glm::dmat4x3), LUA_TTABLE); REGISTER_NUMERICALPROPERTY_SOURCE(DMat4Property, glm::dmat4x4, glm::dmat4x4(0), - glm::dmat4x4(numeric_limits::lowest()), - glm::dmat4x4(numeric_limits::max()), - glm::dmat4x4(0.01), + glm::dmat4x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat4x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat4x4( + 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, 0.01 + ), DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x4), DEFAULT_TO_LUA_LAMBDA(glm::dmat4x4), LUA_TTABLE); From 618f3ab930b162f3919adbb195d28bd6536b4eb0 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 17 Dec 2014 18:18:34 +0100 Subject: [PATCH 10/31] Add description for numerical properties --- include/openspace/properties/numericalproperty.h | 5 +++++ .../openspace/properties/numericalproperty.inl | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/openspace/properties/numericalproperty.h b/include/openspace/properties/numericalproperty.h index 5f97c23fcb..1ec0a3e815 100644 --- a/include/openspace/properties/numericalproperty.h +++ b/include/openspace/properties/numericalproperty.h @@ -50,6 +50,11 @@ public: using TemplateProperty::operator=; protected: + static const std::string MinimumValueKey; + static const std::string MaximumValueKey; + + std::string generateAdditionalDescription() const; + T _minimumValue; T _maximumValue; }; diff --git a/include/openspace/properties/numericalproperty.inl b/include/openspace/properties/numericalproperty.inl index be04323787..0886975f1f 100644 --- a/include/openspace/properties/numericalproperty.inl +++ b/include/openspace/properties/numericalproperty.inl @@ -142,6 +142,13 @@ namespace properties { return PropertyDelegate>::typeLua(); \ } + +template +const std::string NumericalProperty::MinimumValueKey = "MinimumValue"; + +template +const std::string NumericalProperty::MaximumValueKey = "MaximumValueKey"; + // Delegating constructors are necessary; automatic template deduction cannot // deduce template argument for 'U' if 'default' methods are used as default values in // a single constructor @@ -199,7 +206,6 @@ int NumericalProperty::typeLua() const { return PropertyDelegate>::typeLua(); } - template T NumericalProperty::minValue() const { return _minimumValue; @@ -210,5 +216,13 @@ T NumericalProperty::maxValue() const { return _maximumValue; } +template +std::string NumericalProperty::generateAdditionalDescription() const { + std::string result; + result += MinimumValueKey + " = " + std::to_string(_minimumValue) + ","; + result += MaximumValueKey + " = " + std::to_string(_maximumValue); + return result; +} + } // namespace properties } // namespace openspace From 7181a8f9da8c9bdf526b564466e8acbaef706e33 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 17 Dec 2014 18:19:06 +0100 Subject: [PATCH 11/31] Remove test code --- src/rendering/planets/renderableplanet.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/rendering/planets/renderableplanet.cpp b/src/rendering/planets/renderableplanet.cpp index 44aa839a21..232c7bb0fd 100644 --- a/src/rendering/planets/renderableplanet.cpp +++ b/src/rendering/planets/renderableplanet.cpp @@ -84,11 +84,6 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) addProperty(_colorTexturePath); _colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this)); - - std::string s = _colorTexturePath.description(); - ghoul::Dictionary d; - ghoul::lua::loadDictionaryFromString(s, d); - } RenderablePlanet::~RenderablePlanet() { From 6336ee998afa5587221861ce752a7c56a7dbdb94 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 17 Dec 2014 18:47:30 +0100 Subject: [PATCH 12/31] Added description for SelectionProperty --- .../openspace/properties/selectionproperty.h | 7 +- src/properties/selectionproperty.cpp | 64 +++++-------------- .../stars/renderableconstellationbounds.cpp | 1 - 3 files changed, 19 insertions(+), 53 deletions(-) diff --git a/include/openspace/properties/selectionproperty.h b/include/openspace/properties/selectionproperty.h index 86b20298cb..2a094c6b77 100644 --- a/include/openspace/properties/selectionproperty.h +++ b/include/openspace/properties/selectionproperty.h @@ -32,8 +32,6 @@ namespace openspace { namespace properties { -//REGISTER_TEMPLATEPROPERTY_HEADER(SelectionProperty, std::vector); - class SelectionProperty : public TemplateProperty> { public: struct Option { @@ -46,9 +44,10 @@ public: void addOption(Option option); const std::vector