Commit 284989d4 authored by Michal Marcinkowski's avatar Michal Marcinkowski
Browse files

Cleanup and refractoring of RenderableFov.cpp

- Removed code causing memleaks
- Improved MVIC intersection when no cornerpoints intersect
- General readability and logical fixes (long overdue)
- Fix so arbitrary amount of fov-bound-vectors can be loaded
- Updated keybinds & data etc
parent 953e4c51
Showing with 320 additions and 406 deletions
+320 -406
data @ ddcba938
Subproject commit acf3b4658081da227fa8dc244a8b1814e70a0c11 Subproject commit ddcba938fbda7ec5cc1e8d06be0fc47e199b0f4f
Subproject commit 926b7c6b0d44ad72b7df8217ac7f65dfb6c59479 Subproject commit 310b4ece3653b13e37f0d49cc31386545cf45737
This diff is collapsed.
...@@ -52,37 +52,44 @@ public: ...@@ -52,37 +52,44 @@ public:
void update(const UpdateData& data) override; void update(const UpdateData& data) override;
private: private:
// properties
properties::FloatProperty _lineWidth; properties::FloatProperty _lineWidth;
properties::BoolProperty _drawSolid; properties::BoolProperty _drawSolid;
ghoul::opengl::ProgramObject* _programObject; ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::Texture* _texture; ghoul::opengl::Texture* _texture;
openspace::SceneGraphNode* _targetNode; openspace::SceneGraphNode* _targetNode;
// class methods
void loadTexture(); void loadTexture();
void allocateData(); void allocateData();
void insertPoint(std::vector<float>& arr, psc p, glm::vec4 c); void insertPoint(std::vector<float>& arr, glm::vec4 p, glm::vec4 c);
void fovProjection(bool H[], std::vector<glm::dvec3> bounds); void fovSurfaceIntercept(bool H[], std::vector<glm::dvec3> bounds);
void determineTarget();
void updateGPU();
void sendToGPU();
// helper methods
void computeColors();
void computeIntercepts(const RenderData& data);
psc orthogonalProjection(glm::dvec3 camvec); psc orthogonalProjection(glm::dvec3 camvec);
psc checkForIntercept(glm::dvec3 ray); psc checkForIntercept(glm::dvec3 ray);
psc pscInterpolate(psc p0, psc p1, float t); psc pscInterpolate(psc p0, psc p1, float t);
psc sphericalInterpolate(glm::dvec3 p0, glm::dvec3 p1, float t);
glm::dvec3 interpolate(glm::dvec3 p0, glm::dvec3 p1, float t); glm::dvec3 interpolate(glm::dvec3 p0, glm::dvec3 p1, float t);
glm::dvec3 pscSlerp(glm::dvec3 p0, glm::dvec3 p1, float t);
glm::dvec3 bisection(glm::dvec3 p1, glm::dvec3 p2, double tolerance); glm::dvec3 bisection(glm::dvec3 p1, glm::dvec3 p2, double tolerance);
void computeColors();
// instance variables // instance variables
int _nrInserted = 0; int _nrInserted = 0;
int _isteps; int _isteps;
bool _rebuild = false; bool _rebuild = false;
bool _interceptTag[9]; bool _interceptTag[8];
bool _withinFOV; bool _withinFOV;
psc _projectionBounds[8]; std::vector<psc> _projectionBounds;
psc _interceptVector; psc _interceptVector;
std::vector<float> _fovBounds;
std::vector<float> _fovPlane;
// spice // spice
std::string _spacecraft; std::string _spacecraft;
std::string _observer; std::string _observer;
...@@ -91,38 +98,39 @@ public: ...@@ -91,38 +98,39 @@ public:
std::string _method; std::string _method;
std::string _aberrationCorrection; std::string _aberrationCorrection;
std::string _fovTarget; std::string _fovTarget;
std::vector<std::string> _potentialTargets;
glm::dvec3 ipoint, ivec; glm::dvec3 ipoint, ivec;
glm::dvec3 _previousHalf; glm::dvec3 _previousHalf;
glm::vec3 _c; glm::dvec3 _boresight;
double _r, _g, _b;
// GPU stuff
GLuint _vaoID[2] ;
GLuint _vboID[2] ;
GLuint _iboID[2];
GLenum _mode;
unsigned int _isize[2];
unsigned int _vsize[2];
unsigned int _vtotal[2];
unsigned int _stride[2];
std::vector<float> _varray1;
std::vector<float> _varray2;
int* _iarray1[2];
void updateData();
void sendToGPU();
glm::dmat3 _stateMatrix; glm::dmat3 _stateMatrix;
glm::mat4 _spacecraftRotation;
std::vector<glm::dvec3> _bounds;
std::vector<std::string> _potentialTargets;
bool _drawFOV;
double _targetEpoch;
double _lt;
// GPU
GLuint _fovBoundsVAO;
GLuint _fovBoundsVBO;
unsigned int _vBoundsSize;
GLuint _fovPlaneVAO;
GLuint _fovPlaneVBO;
unsigned int _vPlaneSize;
GLenum _mode;
unsigned int _stride;
// time // time
double _time = 0; double _time = 0;
double _oldTime = 0; double _oldTime = 0;
// capturetime // colors
double _timeInterval; glm::vec4 col_sq; // orthogonal white square
double _nextCaptureTime; glm::vec4 col_project; // color when projections occur
glm::vec4 col_start; // intersection start color
glm::vec4 col_end; // intersection end color
glm::vec4 col_blue; // withinFov color
glm::vec4 col_gray; // no intersection color
}; };
} }
#endif #endif
...@@ -96,6 +96,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& ...@@ -96,6 +96,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
, _textureProj(nullptr) , _textureProj(nullptr)
, _textureWhiteSquare(nullptr) , _textureWhiteSquare(nullptr)
, _geometry(nullptr) , _geometry(nullptr)
, _capture(false)
, _clearingImage(absPath("${OPENSPACE_DATA}/scene/common/textures/clear.png")) , _clearingImage(absPath("${OPENSPACE_DATA}/scene/common/textures/clear.png"))
{ {
std::string name; std::string name;
...@@ -459,28 +460,28 @@ void RenderablePlanetProjection::project(){ ...@@ -459,28 +460,28 @@ void RenderablePlanetProjection::project(){
// Comment out if not using queue and prefer old method ------------- // Comment out if not using queue and prefer old method -------------
// + in update() function // + in update() function
if (!imageQueue.empty()){ //if (!imageQueue.empty()){
Image& img = imageQueue.front(); // Image& img = imageQueue.front();
RenderablePlanetProjection::attitudeParameters(img.startTime); // RenderablePlanetProjection::attitudeParameters(img.startTime);
// if image has new path - ie actual image, NOT placeholder // // if image has new path - ie actual image, NOT placeholder
if (_projectionTexturePath.value() != img.path){ // if (_projectionTexturePath.value() != img.path){
// rebind and upload // // rebind and upload
_projectionTexturePath = img.path; // _projectionTexturePath = img.path;
} // }
imageProjectGPU(); // fbopass // imageProjectGPU(); // fbopass
imageQueue.pop(); // imageQueue.pop();
} //}
// ------------------------------------------------------------------ // ------------------------------------------------------------------
//---- Old method --- // //---- Old method --- //
// @mm // @mm
//for (auto const &img : _imageTimes){ for (auto const &img : _imageTimes){
// RenderablePlanetProjection::attitudeParameters(img.startTime); RenderablePlanetProjection::attitudeParameters(img.startTime);
// if (_projectionTexturePath.value() != img.path){ if (_projectionTexturePath.value() != img.path){
// _projectionTexturePath = img.path; // path to current images _projectionTexturePath = img.path; // path to current images
// } }
// imageProjectGPU(); // fbopass imageProjectGPU(); // fbopass
//} }
_capture = false; _capture = false;
} }
...@@ -531,13 +532,13 @@ void RenderablePlanetProjection::render(const RenderData& data){ ...@@ -531,13 +532,13 @@ void RenderablePlanetProjection::render(const RenderData& data){
} }
void RenderablePlanetProjection::update(const UpdateData& data){ void RenderablePlanetProjection::update(const UpdateData& data){
if (_time > Time::ref().currentTime()){ if (_time >= Time::ref().currentTime()){
imageQueue = {}; // if jump back in time -> empty queue. imageQueue = {}; // if jump back in time -> empty queue.
} }
_time = Time::ref().currentTime(); _time = Time::ref().currentTime();
_capture = false; _capture = false;
if (openspace::ImageSequencer2::ref().isReady() && _performProjection){ if (openspace::ImageSequencer2::ref().isReady() && _performProjection){
openspace::ImageSequencer2::ref().updateSequencer(_time); openspace::ImageSequencer2::ref().updateSequencer(_time);
_capture = openspace::ImageSequencer2::ref().getImagePaths(_imageTimes, _projecteeID, _instrumentID); _capture = openspace::ImageSequencer2::ref().getImagePaths(_imageTimes, _projecteeID, _instrumentID);
...@@ -545,11 +546,11 @@ void RenderablePlanetProjection::update(const UpdateData& data){ ...@@ -545,11 +546,11 @@ void RenderablePlanetProjection::update(const UpdateData& data){
// remove these lines if not using queue ------------------------ // remove these lines if not using queue ------------------------
// @mm // @mm
_capture = true; //_capture = true;
for (auto img : _imageTimes){ //for (auto img : _imageTimes){
imageQueue.push(img); // imageQueue.push(img);
} //}
_imageTimes.clear(); //_imageTimes.clear();
// -------------------------------------------------------------- // --------------------------------------------------------------
if (_programObject->isDirty()) if (_programObject->isDirty())
......
...@@ -17,12 +17,12 @@ openspace.bindKey("SPACE", "openspace.time.togglePause()") ...@@ -17,12 +17,12 @@ openspace.bindKey("SPACE", "openspace.time.togglePause()")
openspace.bindKey("1", "openspace.time.setDeltaTime(1)") openspace.bindKey("1", "openspace.time.setDeltaTime(1)")
openspace.bindKey("2", "openspace.time.setDeltaTime(5)") openspace.bindKey("2", "openspace.time.setDeltaTime(5)")
openspace.bindKey("3", "openspace.time.setDeltaTime(10)") openspace.bindKey("3", "openspace.time.setDeltaTime(10)")
openspace.bindKey("4", "openspace.time.setDeltaTime(30)") openspace.bindKey("4", "openspace.time.setDeltaTime(20)")
openspace.bindKey("5", "openspace.time.setDeltaTime(60)") openspace.bindKey("5", "openspace.time.setDeltaTime(40)")
openspace.bindKey("6", "openspace.time.setDeltaTime(120)") openspace.bindKey("6", "openspace.time.setDeltaTime(60)")
openspace.bindKey("7", "openspace.time.setDeltaTime(360)") openspace.bindKey("7", "openspace.time.setDeltaTime(120)")
openspace.bindKey("8", "openspace.time.setDeltaTime(540)") openspace.bindKey("8", "openspace.time.setDeltaTime(360)")
openspace.bindKey("9", "openspace.time.setDeltaTime(720)") openspace.bindKey("9", "openspace.time.setDeltaTime(540)")
--[[openspace.bindKey("2", "openspace.time.setDeltaTime(30)") --[[openspace.bindKey("2", "openspace.time.setDeltaTime(30)")
openspace.bindKey("3", "openspace.time.setDeltaTime(180)") -- 3m openspace.bindKey("3", "openspace.time.setDeltaTime(180)") -- 3m
...@@ -59,17 +59,7 @@ openspace.bindKey("x", "openspace.setOrigin('Europa')") ...@@ -59,17 +59,7 @@ openspace.bindKey("x", "openspace.setOrigin('Europa')")
openspace.bindKey("g", "openspace.time.setTime('2007-02-28T11:40:00.00'); openspace.time.setDeltaTime(1);") openspace.bindKey("g", "openspace.time.setTime('2007-02-28T11:40:00.00'); openspace.time.setDeltaTime(1);")
openspace.bindKey("h", "openspace.setPropertyValue('PlutoProjection.renderable.performProjection', false); openspace.setPropertyValue('Charon.renderable.performProjection', false);openspace.time.setTime('2015-07-14T09:00:00.00'); openspace.time.setDeltaTime(1); openspace.changeCoordinateSystem('Pluto'); openspace.setOrigin('PlutoProjection'); openspace.printInfo('Changing Viewpoint to Pluto-in-center');") openspace.bindKey("h", "openspace.time.setTime('2015-07-14T10:00:00.00'); openspace.time.setDeltaTime(1); openspace.changeCoordinateSystem('Pluto'); openspace.setOrigin('PlutoProjection'); openspace.printInfo('Changing Viewpoint to Pluto-in-center');")
--[[
openspace.bindKey("1", "openspace.time.setTime('2007-02-27T16:40:00.00'); openspace.time.setDeltaTime(10)")
openspace.bindKey("2", "openspace.time.setTime('2015-07-14T10:50:00.00'); openspace.time.setDeltaTime(10)")
openspace.bindKey("3", "openspace.time.setTime('2015-07-14T11:22:00.00'); openspace.time.setDeltaTime(1)")
openspace.bindKey("4", "openspace.time.setTime('2015-07-14T11:36:40.00'); openspace.time.setDeltaTime(1)")
openspace.bindKey("5", "openspace.time.setTime('2015-07-14T11:48:43.00'); openspace.time.setDeltaTime(1)")
openspace.bindKey("6", "openspace.time.setTime('2015-07-14T12:04:35.00'); openspace.time.setDeltaTime(1)")
openspace.bindKey("7", "openspace.time.setTime('2015-07-14T15:02:46.00'); openspace.time.setDeltaTime(100)")
]]--
openspace.bindKey("i", "local b = openspace.getPropertyValue('PlutoTexture.renderable.enabled'); openspace.setPropertyValue('PlutoTexture.renderable.enabled', not b)") openspace.bindKey("i", "local b = openspace.getPropertyValue('PlutoTexture.renderable.enabled'); openspace.setPropertyValue('PlutoTexture.renderable.enabled', not b)")
...@@ -85,7 +75,6 @@ openspace.bindKey("k", "local b = openspace.getPropertyValue('KerberosText.rende ...@@ -85,7 +75,6 @@ openspace.bindKey("k", "local b = openspace.getPropertyValue('KerberosText.rende
openspace.bindKey("k", "local b = openspace.getPropertyValue('StyxText.renderable.enabled'); openspace.setPropertyValue('StyxText.renderable.enabled', not b)") openspace.bindKey("k", "local b = openspace.getPropertyValue('StyxText.renderable.enabled'); openspace.setPropertyValue('StyxText.renderable.enabled', not b)")
openspace.bindKey("j", "local b = openspace.getPropertyValue('PlutoText.renderable.enabled'); openspace.setPropertyValue('PlutoText.renderable.enabled', not b)") openspace.bindKey("j", "local b = openspace.getPropertyValue('PlutoText.renderable.enabled'); openspace.setPropertyValue('PlutoText.renderable.enabled', not b)")
openspace.bindKey("l", "local b = openspace.getPropertyValue('Labels.renderable.performFading'); openspace.setPropertyValue('Labels.renderable.performFading', not b)") openspace.bindKey("l", "local b = openspace.getPropertyValue('Labels.renderable.performFading'); openspace.setPropertyValue('Labels.renderable.performFading', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_LORRI.renderable.solidDraw'); openspace.setPropertyValue('NH_LORRI.renderable.solidDraw', not b)") openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_LORRI.renderable.solidDraw'); openspace.setPropertyValue('NH_LORRI.renderable.solidDraw', not b)")
......
...@@ -13,7 +13,7 @@ openspace.time.setTime("2007 FEB 27 16:30:00") -- This is the start tim ...@@ -13,7 +13,7 @@ openspace.time.setTime("2007 FEB 27 16:30:00") -- This is the start tim
--TESTING ALICE --TESTING ALICE
--openspace.time.setTime("2015-07-13T00:00:00.00") --openspace.time.setTime("2015-07-13T00:00:00.00")
--openspace.time.setTime("2015-07-14T08:00:00.00") --openspace.time.setTime("2015-07-14T10:00:00.00")
openspace.time.setDeltaTime(0) -- How many seconds pass per second of realtime, changeable in the GUI openspace.time.setDeltaTime(0) -- How many seconds pass per second of realtime, changeable in the GUI
......
...@@ -956,19 +956,20 @@ bool SpiceManager::getTerminatorEllipse(const int numberOfPoints, ...@@ -956,19 +956,20 @@ bool SpiceManager::getTerminatorEllipse(const int numberOfPoints,
glm::dvec3& observerPosition, glm::dvec3& observerPosition,
std::vector<psc>& terminatorPoints){ std::vector<psc>& terminatorPoints){
double(*tpoints)[3] = new double[numberOfPoints][3]; std::vector<std::array<double, 3>> tpoints(numberOfPoints);
// double (*tpoints)[3] = new double[numberOfPoints][3];
edterm_c(terminatorType.c_str(), edterm_c(terminatorType.c_str(),
lightSource.c_str(), lightSource.c_str(),
target.c_str(), target.c_str(),
ephemerisTime, ephemerisTime,
frame.c_str(), frame.c_str(),
aberrationCorrection.c_str(), aberrationCorrection.c_str(),
observer.c_str(), observer.c_str(),
numberOfPoints, numberOfPoints,
&targetEpoch, &targetEpoch,
glm::value_ptr(observerPosition), glm::value_ptr(observerPosition),
(double(*)[3])tpoints ); (double(*)[3])tpoints.data());
bool hasError = checkForError("Error getting " + terminatorType + bool hasError = checkForError("Error getting " + terminatorType +
"terminator for'" + target + "'"); "terminator for'" + target + "'");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment