Make it possible to not load an asset on default and later load it at runtime (closes #694)

This commit is contained in:
Alexander Bock
2018-08-24 02:34:55 -06:00
parent 5ad69b841b
commit 4d901b688b
4 changed files with 21 additions and 7 deletions

View File

@@ -37,7 +37,7 @@ namespace documentation { struct Documentation; }
struct Configuration {
std::string windowConfiguration = "${CONFIG}/single.xml";
std::string asset = "default";
std::string asset;
std::vector<std::string> globalCustomizationScripts;
std::map<std::string, std::string> pathTokens = {
{ "CACHE" , "CACHE = \"${BASE}/cache\"" }

View File

@@ -44,7 +44,7 @@ documentation::Documentation Configuration::Documentation = {
new StringAnnotationVerifier(
"A valid scene file as described in the Scene documentation"
),
Optional::No,
Optional::Yes,
"The scene description that is used to populate the application after "
"startup. The scene determines which objects are loaded, the startup "
"time and other scene-specific settings. More information is provided in "

View File

@@ -1193,10 +1193,12 @@ void OpenSpaceEngine::preSynchronization() {
_renderEngine->updateScene();
//_navigationHandler->updateCamera(dt);
Camera* camera = _scene->camera();
if (camera) {
_navigationHandler->updateCamera(dt);
camera->invalidateCache();
if (_scene) {
Camera* camera = _scene->camera();
if (camera) {
_navigationHandler->updateCamera(dt);
camera->invalidateCache();
}
}
_parallelPeer->preSynchronization();
}

View File

@@ -22,6 +22,9 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
namespace openspace::luascriptfunctions::asset {
int add(lua_State* state) {
@@ -35,7 +38,16 @@ int add(lua_State* state) {
1,
ghoul::lua::PopValue::Yes
);
assetManager->add(assetName);
if (OsEng.renderEngine().scene()) {
assetManager->add(assetName);
}
else {
// The scene might not exist yet if OpenSpace was started without specifying an
// initial asset
OsEng.scheduleLoadSingleAsset(assetName);
}
ghoul_assert(lua_gettop(state) == 0, "Incorrect number of items left on stack");
return 0;