speed up, check if previous index is same as current

This commit is contained in:
Agnes Heppich
2018-12-27 12:14:49 -05:00
parent 16242f34ef
commit feded18dd0
4 changed files with 20 additions and 14 deletions

View File

@@ -62,24 +62,27 @@ namespace openspace {
int idx = DataFileHelper::findFileIndexForCurrentTime(time, timeDoubles);
//If index is same as previous, don't parse the data again
if(idx != prevIndex){
prevIndex = idx;
if(idx != prevFileIndex){
prevFileIndex = idx;
updateRadecData(idx);
int index = DataFileHelper::findFileIndexForCurrentTime(time, minuteTimes);
updateActiveMinute(index);
if (positions.size()) {
int index = DataFileHelper::findFileIndexForCurrentTime(time, minuteTimes);
updateActiveMinute(index);
}
}
}
if (positions.size() && !correctUpdateInterval(time)) {
//Compensate for light travel time to the spacecraft
int idx = DataFileHelper::findFileIndexForCurrentTime(time, minuteTimes);
updateActiveMinute(idx);
if (idx != prevMinIndex) {
prevMinIndex = idx;
updateActiveMinute(idx);
double lighttimeCompensation = positions[idx].lightTravelTime;
int compensatedIdx = DataFileHelper::findFileIndexForCurrentTime(time + lighttimeCompensation, minuteTimes);
getPositionInVector(compensatedIdx);
double lighttimeCompensation = positions[idx].lightTravelTime;
int compensatedIdx = DataFileHelper::findFileIndexForCurrentTime(time + lighttimeCompensation, minuteTimes);
getPositionInVector(compensatedIdx);
}
}

View File

@@ -45,7 +45,10 @@ namespace openspace {
mutable double lightTravelTime; //Downlink light time travel time in seconds
mutable int lightTravelHours;
};
mutable int prevIndex;
//Used to determine if we need to search for new data
mutable int prevFileIndex;
mutable int prevMinIndex;
mutable std::vector<Position> positions;
mutable std::vector<double> minuteTimes;

View File

@@ -166,7 +166,7 @@ glm::dvec3 RadecTranslation::position(const UpdateData& data) const{
if (!haveDataForTime) {
LWARNING(fmt::format("No positioning data available for {} at time {}", radecManager.objectIdentifier.c_str(), data.time.UTC()));
return radecToCartesianCoordinates({ 0,0,0 });
return _position;//radecToCartesianCoordinates({ 0,0,0 });
}
else {
glm::dvec3 pos = radecManager.getPosForTime(data.time.j2000Seconds());
@@ -174,7 +174,7 @@ glm::dvec3 RadecTranslation::position(const UpdateData& data) const{
return _position;
}
}
else return radecToCartesianCoordinates({ 0,0,0 });
else return _position;
}
} // namespace openspace

View File

@@ -57,7 +57,7 @@ private:
///Transforms the cartesian coordinates with a rotation and a translation
glm::dvec3 radecToCartesianCoordinates(glm::vec3 pos) const;
///Translated position
mutable glm::vec3 _position;
mutable glm::dvec3 _position = {0.0,0.0,0.0};
///Determines between what dates there is data available. Set in the asset file.
double _dataStart, _dataEnd;
///Determines how many minutes between updates in positioning data