Merge branch 'master' of github.com:OpenSpace/OpenSpace into feature/data-management

This commit is contained in:
Emil Axelsson
2017-11-10 16:07:58 +01:00
482 changed files with 7286 additions and 3720 deletions
+17 -17
View File
@@ -81,7 +81,7 @@ void ScriptEngine::initializeLuaState(lua_State* state) {
LDEBUG("Create openspace base library");
lua_newtable(state);
lua_setglobal(state, OpenSpaceLibraryName.c_str());
LDEBUG("Add OpenSpace modules");
for (LuaLibrary& lib : _registeredLibraries) {
registerLuaLibrary(state, lib);
@@ -176,10 +176,10 @@ bool ScriptEngine::runScript(const std::string& script) {
LERRORC(e.component, e.message);
return false;
}
return true;
}
bool ScriptEngine::runScriptFile(const std::string& filename) {
if (filename.empty()) {
LWARNING("Filename was empty");
@@ -189,7 +189,7 @@ bool ScriptEngine::runScriptFile(const std::string& filename) {
LERROR("Script with name '" << filename << "' did not exist");
return false;
}
try {
ghoul::lua::runScriptFile(_state, filename);
}
@@ -201,7 +201,7 @@ bool ScriptEngine::runScriptFile(const std::string& filename) {
LERRORC(e.component, e.message);
return false;
}
return true;
}
@@ -214,7 +214,7 @@ bool ScriptEngine::runScriptFile(const std::string& filename) {
break;
}
}
std::vector<scripting::LuaLibrary::Function>::const_iterator funcit;
//library was found
if (libit != _registeredLibraries.cend()){
@@ -228,19 +228,19 @@ bool ScriptEngine::runScriptFile(const std::string& filename) {
}
}
}
return false;
}*/
/*void ScriptEngine::cacheScript(const std::string &library, const std::string &function, const std::string &script){
_cachedScriptsMutex.lock();
_cachedScripts[library][function] = script;
_cachedScriptsMutex.unlock();
}
std::vector<std::string> ScriptEngine::cachedScripts(){
_cachedScriptsMutex.lock();
std::vector<std::string> retVal;
std::map<std::string, std::map<std::string, std::string>>::const_iterator outerIt;
std::map<std::string, std::string>::const_iterator innerIt;
@@ -253,15 +253,15 @@ std::vector<std::string> ScriptEngine::cachedScripts(){
retVal.push_back(innerIt->second);
}
}
_cachedScriptsMutex.unlock();
return retVal;
}*/
/*
bool ScriptEngine::parseLibraryAndFunctionNames(std::string &library, std::string &function, const std::string &script){
//"deconstruct the script to find library and function name
//assuming a script looks like: "openspace.library.function()"
//or openspace.funcion()
@@ -270,7 +270,7 @@ bool ScriptEngine::parseLibraryAndFunctionNames(std::string &library, std::strin
function.clear();
//find first "."
std::size_t pos = script.find(".");
if (pos != std::string::npos){
//strip "openspace."
sub = script.substr(pos + 1, script.size());
@@ -411,7 +411,7 @@ void ScriptEngine::addLibraryFunctions(lua_State* state, LuaLibrary& library, bo
}
}
}
void ScriptEngine::addBaseLibrary() {
LuaLibrary lib = {
"",
@@ -540,7 +540,7 @@ LuaLibrary lib = {
};
addLibrary(lib);
}
void ScriptEngine::remapPrintFunction() {
//ghoul::lua::logStack(_state);
// lua_getglobal(_state, _luaGlobalNamespace.c_str());
@@ -777,7 +777,7 @@ void ScriptEngine::queueScript(const std::string &script, ScriptEngine::RemoteSc
if (script.empty()) {
return;
}
_mutex.lock();
_queuedScripts.insert(_queuedScripts.begin(), std::make_pair(script, remoteScripting));
_mutex.unlock();
+4 -4
View File
@@ -201,7 +201,7 @@ int absolutePath(lua_State* L) {
path = FileSys.convertPathSeparator(path, '/');
lua_pushstring(L, path.c_str());
return 1;
}
}
/**
* \ingroup LuaScripts
@@ -262,7 +262,7 @@ int directoryExists(lua_State* L) {
/**
* \ingroup LuaScripts
* walkDirectory(string, bool, bool):
* Walks a directory and returns the contents of the directory as absolute paths. The
* Walks a directory and returns the contents of the directory as absolute paths. The
* first argument is the path of the directory that should be walked, the second argument
* determines if the walk is recursive and will continue in contained directories. The
* default value for this parameter is "false". The third argument determines whether the
@@ -303,8 +303,8 @@ int walkDirectoryFolder(lua_State* L) {
/**
* \ingroup LuaScripts
* directoryForPath(string):
* This function extracts the directory part of the passed path. For example, if the
* parameter is 'C:\\OpenSpace\\foobar\\foo.txt', this function returns
* This function extracts the directory part of the passed path. For example, if the
* parameter is 'C:\\OpenSpace\\foobar\\foo.txt', this function returns
* 'C:\\OpenSpace\\foobar'."
*/
int directoryForPath(lua_State* L) {
+15 -15
View File
@@ -102,7 +102,7 @@ ScriptScheduler::ScheduledScript::ScheduledScript(const ghoul::Dictionary& dicti
{
std::string timeStr = dictionary.value<std::string>(KeyTime);
time = Time::convertTime(timeStr);
// If a universal script is specified, retrieve it and add a ; as a separator so that
// it can be added to the other scripts
std::string universal;
@@ -110,12 +110,12 @@ ScriptScheduler::ScheduledScript::ScheduledScript(const ghoul::Dictionary& dicti
if (!universal.empty()) {
universal += ";";
}
if (dictionary.hasKeyAndValue<std::string>(KeyForwardScript)) {
forwardScript =
universal + dictionary.value<std::string>(KeyForwardScript);
}
if (dictionary.hasKeyAndValue<std::string>(KeyBackwardScript)) {
backwardScript =
universal + dictionary.value<std::string>(KeyBackwardScript);
@@ -129,7 +129,7 @@ void ScriptScheduler::loadScripts(const ghoul::Dictionary& dictionary) {
dictionary,
"ScriptScheduler"
);
// Create all the scheduled script first
std::vector<ScheduledScript> scheduledScripts;
for (size_t i = 1; i <= dictionary.size(); ++i) {
@@ -148,7 +148,7 @@ void ScriptScheduler::loadScripts(const ghoul::Dictionary& dictionary) {
return lhs.time < rhs.time;
}
);
// Move the scheduled scripts into their SOA alignment
// For the forward scripts, this is the forwards direction
// For the backward scripts, we insert them in the opposite order so that we can still
@@ -168,7 +168,7 @@ void ScriptScheduler::loadScripts(const ghoul::Dictionary& dictionary) {
double lastTime = _currentTime;
rewind();
progressTo(lastTime);
ghoul_assert(
(_timings.size() == _forwardScripts.size()) &&
(_timings.size() == _backwardScripts.size()),
@@ -206,14 +206,14 @@ ScriptScheduler::progressTo(double newTime)
_timings.end(),
newTime
);
// How many values did we pass over?
ptrdiff_t n = std::distance(_timings.begin() + prevIndex, it);
_currentIndex = static_cast<int>(prevIndex + n);
// Update the new time
_currentTime = newTime;
return {
_forwardScripts.begin() + prevIndex,
_forwardScripts.begin() + _currentIndex
@@ -228,11 +228,11 @@ ScriptScheduler::progressTo(double newTime)
_timings.begin() + prevIndex, // We can stop at the previous time
newTime
);
// How many values did we pass over?
ptrdiff_t n = std::distance(it, _timings.begin() + prevIndex);
_currentIndex = static_cast<int>(prevIndex - n);
// Update the new time
_currentTime = newTime;
@@ -244,23 +244,23 @@ ScriptScheduler::progressTo(double newTime)
}
double ScriptScheduler::currentTime() const {
return _currentTime;
return _currentTime;
}
std::vector<ScriptScheduler::ScheduledScript> ScriptScheduler::allScripts() const {
std::vector<ScheduledScript> result;
for (size_t i = 0; i < _timings.size(); ++i) {
ScheduledScript script;
ScheduledScript script;
script.time = _timings[i];
script.forwardScript = _forwardScripts[i];
script.backwardScript = _backwardScripts[i];
result.push_back(std::move(script));
}
return result;
}
LuaLibrary ScriptScheduler::luaLibrary() {
LuaLibrary ScriptScheduler::luaLibrary() {
return {
"scriptScheduler",
{
+1 -1
View File
@@ -38,7 +38,7 @@ int loadFile(lua_State* L) {
OsEng.scriptScheduler().loadScripts(
ghoul::lua::loadDictionaryFromFile(missionFileName, L)
);
return 0;
}
+25 -28
View File
@@ -58,7 +58,7 @@ int cores(lua_State* L) {
lua_pushnumber(L, CpuCap.cores());
return 1;
}
int cacheLineSize(lua_State* L) {
lua_pushnumber(L, CpuCap.cacheLineSize());
return 1;
@@ -68,32 +68,31 @@ int L2Associativity(lua_State* L) {
lua_pushnumber(L, CpuCap.L2Associativity());
return 1;
}
int cacheSize(lua_State* L) {
lua_pushnumber(L, CpuCap.cacheSize());
return 1;
}
int extensions(lua_State* L) {
lua_pushstring(L, CpuCap.extensions().c_str());
return 1;
}
} // namespace luascripting::general
namespace luascripting::opengl {
int hasOpenGLVersion(lua_State* L) {
int nArguments = lua_gettop(L);
SCRIPT_CHECK_ARGUMENTS("hasVersion", L, 1, nArguments);
std::vector<std::string> v = ghoul::tokenizeString(luaL_checkstring(L, -1));
if (v.size() != 2 && v.size() != 3) {
LERRORC("hasVersion", ghoul::lua::errorLocation(L) << "Malformed version string");
return 0;
}
for (const std::string& i : v) {
for (char c : i) {
if (!std::isdigit(c)) {
@@ -102,7 +101,6 @@ int hasOpenGLVersion(lua_State* L) {
ghoul::lua::errorLocation(L) << "Malformed version string"
);
return 0;
}
}
}
@@ -111,81 +109,80 @@ int hasOpenGLVersion(lua_State* L) {
int minor = std::stoi(v[1]);
int release = v.size() == 3 ? std::stoi(v[2]) : 0;
Version version = { major, minor, release };
bool supported = OpenGLCap.openGLVersion() >= version;
lua_pushboolean(L, supported);
return 1;
}
int openGLVersion(lua_State* L) {
lua_pushstring(L, std::to_string(OpenGLCap.openGLVersion()).c_str());
return 1;
}
int glslCompiler(lua_State* L) {
lua_pushstring(L, OpenGLCap.glslCompiler().c_str());
return 1;
}
int gpuVendor(lua_State* L) {
lua_pushstring(L, OpenGLCap.gpuVendorString().c_str());
return 1;
}
int extensions(lua_State* L) {
const std::vector<std::string>& extensions = OpenGLCap.extensions();
lua_newtable(L);
for (size_t i = 1; i <= extensions.size(); ++i) {
lua_pushstring(L, extensions[i].c_str());
lua_rawseti(L, -2, i);
}
return 1;
}
int isExtensionSupported(lua_State* L) {
int nArguments = lua_gettop(L);
SCRIPT_CHECK_ARGUMENTS("hasVersion", L, 1, nArguments);
std::string extension = luaL_checkstring(L, -1);
lua_pushboolean(L, OpenGLCap.isExtensionSupported(extension));
return 1;
}
int maxTextureUnits(lua_State* L) {
lua_pushnumber(L, OpenGLCap.maxTextureUnits());
return 1;
}
int max2DTextureSize(lua_State* L) {
lua_pushnumber(L, OpenGLCap.max2DTextureSize());
return 1;
}
int max3DTextureSize(lua_State* L) {
lua_pushnumber(L, OpenGLCap.max3DTextureSize());
return 1;
}
int maxAtomicCounterBufferBindings(lua_State* L) {
lua_pushnumber(L, OpenGLCap.maxAtomicCounterBufferBindings());
return 1;
}
int maxShaderStorageBufferBindings(lua_State* L) {
lua_pushnumber(L, OpenGLCap.maxShaderStorageBufferBindings());
return 1;
}
int maxUniformBufferBindings(lua_State* L) {
lua_pushnumber(L, OpenGLCap.maxUniformBufferBindings());
return 1;
}
} // namespace luascripting::opengl
@@ -259,7 +256,7 @@ LuaLibrary generalSystemCapabilities() {
}
};
}
LuaLibrary openglSystemCapabilities() {
return {
"openglCapabilities",