mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-10 21:49:38 -06:00
speed up, check if previous index is same as current
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user