mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-07 12:10:52 -06:00
Merge branch 'thesis/2018/dsn' of github.com:OpenSpace/OpenSpace into thesis/2018/dsn
This commit is contained in:
@@ -111,8 +111,8 @@ namespace openspace {
|
||||
LERROR(fmt::format("{}: Error in json object number {} while reading file '{}'", objectIdentifier, objectCounter, filename));
|
||||
}
|
||||
RadecManager::positions.push_back(position);
|
||||
|
||||
}
|
||||
isReady = true;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace openspace {
|
||||
mutable double lightTravelTime; //Downlink light time travel time in seconds
|
||||
mutable double lightTravelHours = 1; //Downlink light time travel time in seconds
|
||||
};
|
||||
mutable bool isReady = false;
|
||||
|
||||
//Used to determine if we need to search for new data
|
||||
mutable int prevFileIndex;
|
||||
|
||||
@@ -141,24 +141,29 @@ glm::dvec3 RadecTranslation::radecToCartesianCoordinates(glm::vec3 pos) const {
|
||||
}
|
||||
|
||||
glm::dvec3 RadecTranslation::position(const UpdateData& data) const{
|
||||
double time = data.time.j2000Seconds();
|
||||
|
||||
double time = data.time.j2000Seconds();
|
||||
const bool haveDataForTime = (time >= _firstTimeInData) && (time < _lastTimeInData);
|
||||
|
||||
if (haveDataForTime) {
|
||||
glm::dvec3 radecPos = radecManager.getPosForTime(time);
|
||||
_position = radecToCartesianCoordinates(radecPos);
|
||||
if (radecManager.isReady) {
|
||||
_position = radecToCartesianCoordinates(radecPos);
|
||||
}
|
||||
}
|
||||
else if(time < _firstTimeInData){
|
||||
glm::dvec3 radecPos = radecManager.getPosForTime(_firstTimeInData);
|
||||
_position = radecToCartesianCoordinates(radecPos);
|
||||
if (radecManager.isReady) {
|
||||
_position = radecToCartesianCoordinates(radecPos);
|
||||
}
|
||||
}
|
||||
else {
|
||||
glm::dvec3 radecPos = radecManager.getPosForTime(_lastTimeInData);
|
||||
_position = radecToCartesianCoordinates(radecPos);
|
||||
if (radecManager.isReady) {
|
||||
_position = radecToCartesianCoordinates(radecPos);
|
||||
}
|
||||
}
|
||||
|
||||
return _position;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace openspace
|
||||
|
||||
@@ -605,6 +605,14 @@ scripting::LuaLibrary Scene::luaLibrary() {
|
||||
"Returns the value the property, identified by "
|
||||
"the provided URI."
|
||||
},
|
||||
{
|
||||
"getProperty",
|
||||
&luascriptfunctions::property_getProperty,
|
||||
{},
|
||||
"string",
|
||||
"Returns a list of property identifiers that match the passed regular "
|
||||
"expression"
|
||||
},
|
||||
{
|
||||
"loadScene",
|
||||
&luascriptfunctions::loadScene,
|
||||
|
||||
@@ -401,6 +401,51 @@ int property_getValue(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* getProperty
|
||||
* Returns a list of property identifiers that match the passed regular expression
|
||||
*/
|
||||
int property_getProperty(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::property_getProperty");
|
||||
|
||||
std::string regex = ghoul::lua::value<std::string>(L, 1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
|
||||
// Replace all wildcards * with the correct regex (.*)
|
||||
size_t startPos = regex.find("*");
|
||||
while (startPos != std::string::npos) {
|
||||
regex.replace(startPos, 1, "(.*)");
|
||||
startPos += 4; // (.*)
|
||||
startPos = regex.find("*", startPos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::regex r(regex);
|
||||
std::vector<properties::Property*> props = allProperties();
|
||||
std::vector<std::string> res;
|
||||
for (properties::Property* prop : props) {
|
||||
// Check the regular expression for all properties
|
||||
const std::string& id = prop->fullyQualifiedIdentifier();
|
||||
|
||||
if (std::regex_match(id, r)) {
|
||||
res.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
lua_newtable(L);
|
||||
int number = 1;
|
||||
for (const std::string& s : res) {
|
||||
lua_pushstring(L, s.c_str());
|
||||
lua_rawseti(L, -2, number);
|
||||
++number;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* getPropertyValue(string):
|
||||
|
||||
Reference in New Issue
Block a user