Merge branch 'master' into feature/profiles

# Conflicts:
#	include/openspace/scene/assetloader.h
#	src/scene/assetloader.cpp
This commit is contained in:
Alexander Bock
2020-06-14 17:54:25 +02:00
117 changed files with 3952 additions and 2105 deletions

View File

@@ -262,6 +262,7 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
}
}
addPropertySubOwner(_lightSourcePropertyOwner);
addPropertySubOwner(_geometry.get());
@@ -278,14 +279,13 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
addProperty(_rotationVec);
_rotationVec.onChange([this]() {
glm::vec3 degreeVector = _rotationVec;
glm::vec3 radianVector = glm::vec3(
glm::radians(degreeVector.x),
glm::radians(degreeVector.y),
glm::radians(degreeVector.z)
);
_modelTransform = glm::mat4_cast(glm::quat(radianVector));
_modelTransform = glm::mat4_cast(glm::quat(glm::radians(_rotationVec.value())));
});
if (dictionary.hasKey(RotationVecInfo.identifier)) {
_rotationVec = dictionary.value<glm::vec3>(RotationVecInfo.identifier);
}
}
bool RenderableModel::isReady() const {

View File

@@ -362,48 +362,49 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) {
float adjustedTransparency = _opacity;
if (_fadeInThreshold > -1.0) {
const float logDistCamera = glm::log(static_cast<float>(
glm::distance(data.camera.positionVec3(), data.modelTransform.translation)
));
const float startLogFadeDistance = glm::log(_size * _fadeInThreshold);
const float stopLogFadeDistance = startLogFadeDistance + 1.f;
if (!_disableFadeInDistance) {
if (_fadeInThreshold > -1.0) {
const float logDistCamera = glm::log(static_cast<float>(
glm::distance(data.camera.positionVec3(), data.modelTransform.translation)
));
const float startLogFadeDistance = glm::log(_size * _fadeInThreshold);
const float stopLogFadeDistance = startLogFadeDistance + 1.f;
if (logDistCamera > startLogFadeDistance && logDistCamera < stopLogFadeDistance) {
const float fadeFactor = glm::clamp(
(logDistCamera - startLogFadeDistance) /
(stopLogFadeDistance - startLogFadeDistance),
0.f,
1.f
);
adjustedTransparency *= fadeFactor;
if (logDistCamera > startLogFadeDistance && logDistCamera < stopLogFadeDistance) {
const float fadeFactor = glm::clamp(
(logDistCamera - startLogFadeDistance) /
(stopLogFadeDistance - startLogFadeDistance),
0.f,
1.f
);
adjustedTransparency *= fadeFactor;
}
else if (logDistCamera <= startLogFadeDistance) {
adjustedTransparency = 0.f;
}
}
else if (logDistCamera <= startLogFadeDistance) {
adjustedTransparency = 0.f;
if (_fadeOutThreshold > -1.0) {
const float logDistCamera = glm::log(static_cast<float>(
glm::distance(data.camera.positionVec3(), data.modelTransform.translation)
));
const float startLogFadeDistance = glm::log(_size * _fadeOutThreshold);
const float stopLogFadeDistance = startLogFadeDistance + 1.f;
if (logDistCamera > startLogFadeDistance && logDistCamera < stopLogFadeDistance) {
const float fadeFactor = glm::clamp(
(logDistCamera - startLogFadeDistance) /
(stopLogFadeDistance - startLogFadeDistance),
0.f,
1.f
);
adjustedTransparency *= (1.f - fadeFactor);
}
else if (logDistCamera >= stopLogFadeDistance) {
adjustedTransparency = 0.f;
}
}
}
if (_fadeOutThreshold > -1.0) {
const float logDistCamera = glm::log(static_cast<float>(
glm::distance(data.camera.positionVec3(), data.modelTransform.translation)
));
const float startLogFadeDistance = glm::log(_size * _fadeOutThreshold);
const float stopLogFadeDistance = startLogFadeDistance + 1.f;
if (logDistCamera > startLogFadeDistance && logDistCamera < stopLogFadeDistance) {
const float fadeFactor = glm::clamp(
(logDistCamera - startLogFadeDistance) /
(stopLogFadeDistance - startLogFadeDistance),
0.f,
1.f
);
adjustedTransparency *= (1.f - fadeFactor);
}
else if (logDistCamera >= stopLogFadeDistance) {
adjustedTransparency = 0.f;
}
}
// Performance wise
if (adjustedTransparency < 0.01f) {
return;

View File

@@ -80,7 +80,7 @@ documentation::Documentation RenderableSphericalGrid::Documentation() {
},
{
GridColorInfo.identifier,
new DoubleVector4Verifier,
new DoubleVector3Verifier,
Optional::Yes,
GridColorInfo.description
},
@@ -107,9 +107,9 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
, _gridMatrix(GridMatrixInfo, glm::mat4(1.f))
, _gridColor(
GridColorInfo,
glm::vec4(0.5f, 0.5, 0.5f, 1.f),
glm::vec4(0.f),
glm::vec4(1.f)
glm::vec3(0.5f, 0.5, 0.5f),
glm::vec3(0.f),
glm::vec3(1.f)
)
, _segments(SegmentsInfo, 36, 4, 200)
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
@@ -129,7 +129,7 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
addProperty(_gridMatrix);
if (dictionary.hasKey(GridColorInfo.identifier)) {
_gridColor = dictionary.value<glm::vec4>(GridColorInfo.identifier);
_gridColor = dictionary.value<glm::vec3>(GridColorInfo.identifier);
}
_gridColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_gridColor);
@@ -214,16 +214,29 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
const glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() *
modelTransform;
_gridProgram->setUniform("modelViewTransform", glm::mat4(modelViewTransform));
_gridProgram->setUniform("projectionTransform", data.camera.projectionMatrix());
_gridProgram->setUniform("modelViewTransform", modelViewTransform);
_gridProgram->setUniform(
"MVPTransform",
glm::dmat4(data.camera.projectionMatrix()) * modelViewTransform
);
_gridProgram->setUniform("gridColor", _gridColor);
float adjustedLineWidth = 1.f;
#ifndef __APPLE__
adjustedLineWidth = _lineWidth;
#endif
// Saves current state:
GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0);
GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH);
GLfloat currentLineWidth;
glGetFloatv(GL_LINE_WIDTH, &currentLineWidth);
GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH);
GLenum currentDepthFunction;
glGetIntegerv(GL_DEPTH_FUNC, &currentDepthFunction);
glDepthFunc(GL_LEQUAL);
GLenum blendEquationRGB, blendEquationAlpha, blendDestAlpha,
blendDestRGB, blendSrcAlpha, blendSrcRGB;
@@ -235,11 +248,11 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB);
// Changes GL state:
glLineWidth(_lineWidth);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glLineWidth(adjustedLineWidth);
glEnablei(GL_BLEND, 0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glDrawElements(_mode, _isize, GL_UNSIGNED_INT, nullptr);
@@ -251,12 +264,16 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){
glLineWidth(currentLineWidth);
glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha);
glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha);
if (!isBlendEnabled) {
glDisablei(GL_BLEND, 0);
}
if (!isLineSmoothEnabled) {
glDisable(GL_LINE_SMOOTH);
}
glDepthFunc(currentDepthFunction);
}
void RenderableSphericalGrid::update(const UpdateData&) {

View File

@@ -31,7 +31,7 @@
#include <openspace/properties/matrix/dmat4property.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/vector/vec4property.h>
#include <openspace/properties/vector/vec3property.h>
#include <ghoul/opengl/ghoul_gl.h>
namespace ghoul::opengl { class ProgramObject; }
@@ -63,7 +63,7 @@ protected:
ghoul::opengl::ProgramObject* _gridProgram;
properties::DMat4Property _gridMatrix;
properties::Vec4Property _gridColor;
properties::Vec3Property _gridColor;
properties::IntProperty _segments;
properties::FloatProperty _lineWidth;

View File

@@ -25,18 +25,22 @@
#include "fragment.glsl"
#include "PowerScaling/powerScaling_fs.hglsl"
in float vs_screenSpaceDepth;
in float vs_depthClipSpace;
in vec4 vs_positionViewSpace;
uniform vec4 gridColor;
uniform vec3 gridColor;
uniform float opacity;
Fragment getFragment() {
Fragment frag;
frag.color = gridColor;
frag.color.a *= opacity;
frag.depth = vs_screenSpaceDepth;
frag.gPosition = vs_positionViewSpace;
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
frag.color.rgb = gridColor;
frag.color.a = opacity;
frag.depth = vs_depthClipSpace;
frag.gPosition = vs_positionViewSpace;
// There is no normal here
frag.gNormal = vec4(0.0, 0.0, -1.0, 1.0);
return frag;
}

View File

@@ -28,18 +28,21 @@
layout(location = 0) in vec3 in_position;
out float vs_screenSpaceDepth;
out float vs_depthClipSpace;
out vec4 vs_positionViewSpace;
uniform mat4 modelViewTransform;
uniform mat4 projectionTransform;
uniform dmat4 modelViewTransform;
uniform dmat4 MVPTransform;
void main() {
vec4 positionViewSpace = modelViewTransform * vec4(in_position, 1.0);
vec4 positionClipSpace = projectionTransform * positionViewSpace;
vec4 positionScreenSpace = z_normalization(positionClipSpace);
vs_screenSpaceDepth = positionScreenSpace.w;
vs_positionViewSpace = positionViewSpace;
dvec4 objPosDouble = dvec4(in_position, 1.0);
dvec4 positionViewSpace = modelViewTransform * objPosDouble;
dvec4 positionClipSpace = MVPTransform * objPosDouble;
gl_Position = positionScreenSpace;
positionClipSpace.z = 0.0;
vs_depthClipSpace = float(positionClipSpace.w);
vs_positionViewSpace = vec4(positionViewSpace);
gl_Position = vec4(positionClipSpace);
}

View File

@@ -124,9 +124,11 @@ TimeFrameInterval::TimeFrameInterval(const ghoul::Dictionary& dictionary)
addProperty(_hasEnd);
addProperty(_end);
documentation::testSpecificationAndThrow(Documentation(),
dictionary,
"TimeFrameInterval");
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"TimeFrameInterval"
);
if (dictionary.hasValue<std::string>(StartInfo.identifier)) {
_start = SpiceManager::ref().ephemerisTimeFromDate(

View File

@@ -117,11 +117,6 @@ create_new_module(
${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES}
)
option(OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION "Instrumentation for GlobeBrowsing Performance" OFF)
if (OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION)
target_compile_definitions(openspace-module-globebrowsing INTERFACE "OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION")
endif ()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gdal_data DESTINATION modules/globebrowsing)
if (WIN32)

View File

@@ -106,14 +106,6 @@ namespace {
"The maximum size of the MemoryAwareTileCache, on the CPU and GPU."
};
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
constexpr const openspace::properties::Property::PropertyInfo InstrumentationInfo = {
"SaveInstrumentationInfo",
"Save Instrumentation Info",
"If enabled, the instrumentation data is saved to disk at the end of the frame."
};
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
openspace::GlobeBrowsingModule::Capabilities
parseSubDatasets(char** subDatasets, int nSubdatasets)
@@ -176,24 +168,12 @@ GlobeBrowsingModule::GlobeBrowsingModule()
, _wmsCacheLocation(WMSCacheLocationInfo, "${BASE}/cache_gdal")
, _wmsCacheSizeMB(WMSCacheSizeInfo, 1024)
, _tileCacheSizeMB(TileCacheSizeInfo, 1024)
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
, _saveInstrumentation(InstrumentationInfo, false)
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
{
addProperty(_wmsCacheEnabled);
addProperty(_offlineMode);
addProperty(_wmsCacheLocation);
addProperty(_wmsCacheSizeMB);
addProperty(_tileCacheSizeMB);
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
_saveInstrumentation.onChange([&]() {
if (_saveInstrumentation) {
_frameInfo.lastSavedFrame = global::renderEngine.frameNumber();
}
});
addProperty(_saveInstrumentation);
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
}
void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) {
@@ -268,45 +248,6 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) {
_tileCache->update();
});
// Postdraw
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
global::callback::postDraw.emplace_back([&]() {
ZoneScopedN("GlobeBrowsingModule")
// >= as we might have multiple frames per postDraw call (stereo rendering,
// fisheye, etc)
const uint16_t next = _frameInfo.lastSavedFrame + _frameInfo.saveEveryNthFrame;
const bool shouldSave = _saveInstrumentation &&
global::renderEngine.frameNumber() >= next;
if (shouldSave) {
using K = const globebrowsing::RenderableGlobe*;
using V = std::vector<FrameInfo>;
for (const std::pair<K, V>& i : _frameInfo.frames) {
std::string filename = fmt::format(
"_inst_globebrowsing_{}_{}_{}.txt",
i.first->owner()->identifier(), // Owner of the renderable has a name
_frameInfo.lastSavedFrame,
_frameInfo.saveEveryNthFrame
);
std::ofstream file(absPath("${BIN}/" + filename));
for (const FrameInfo& f : i.second) {
std::string line = fmt::format(
"{}\t{}\t{}\t{}",
f.iFrame,
f.nTilesRenderedLocal,
f.nTilesRenderedGlobal,
f.nTilesUploaded
);
file << line << '\n';
}
}
_frameInfo.frames.clear();
_frameInfo.lastSavedFrame = global::renderEngine.frameNumber();
}
});
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
// Deinitialize
global::callback::deinitialize.emplace_back([&]() {
ZoneScopedN("GlobeBrowsingModule")
@@ -834,27 +775,4 @@ uint64_t GlobeBrowsingModule::wmsCacheSize() const {
return size * 1024 * 1024;
}
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
void GlobeBrowsingModule::addFrameInfo(globebrowsing::RenderableGlobe* globe,
uint32_t nTilesRenderedLocal,
uint32_t nTilesRenderedGlobal,
uint32_t nTilesUploaded)
{
auto it = _frameInfo.frames.find(globe);
if (it == _frameInfo.frames.end()) {
_frameInfo.frames[globe] = std::vector<FrameInfo>();
_frameInfo.frames[globe].reserve(_frameInfo.saveEveryNthFrame);
}
else {
it->second.push_back({
global::renderEngine.frameNumber(),
nTilesRenderedLocal,
nTilesRenderedGlobal,
nTilesUploaded
});
}
}
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
} // namespace openspace

View File

@@ -95,11 +95,6 @@ public:
std::string wmsCacheLocation() const;
uint64_t wmsCacheSize() const; // bytes
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
void addFrameInfo(globebrowsing::RenderableGlobe* globe, uint32_t nTilesRenderedLocal,
uint32_t nTilesRenderedGlobal, uint32_t nTilesUploaded);
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
protected:
void internalInitialize(const ghoul::Dictionary&) override;
@@ -141,26 +136,6 @@ private:
std::map<std::string, Capabilities> _capabilitiesMap;
std::multimap<std::string, UrlInfo> _urlList;
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
struct FrameInfo {
uint64_t iFrame = 0;
uint32_t nTilesRenderedLocal = 0;
uint32_t nTilesRenderedGlobal = 0;
uint32_t nTilesUploaded = 0;
};
struct {
std::unordered_map<
globebrowsing::RenderableGlobe*,
std::vector<FrameInfo>
> frames;
uint64_t lastSavedFrame = 0;
const uint16_t saveEveryNthFrame = 2048;
} _frameInfo;
properties::BoolProperty _saveInstrumentation;
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
};
} // namespace openspace

View File

@@ -50,13 +50,6 @@
#include <numeric>
#include <queue>
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
#include <openspace/engine/moduleengine.h>
#include <modules/globebrowsing/globebrowsingmodule.h>
openspace::GlobeBrowsingModule* _module = nullptr;
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
namespace {
// Global flags to modify the RenderableGlobe
constexpr const bool LimitLevelByAvailableData = true;
@@ -709,10 +702,6 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
_generalProperties.shadowMapping = true;
}
_generalProperties.shadowMapping.onChange(notifyShaderRecompilation);
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
_module = global::moduleEngine.module<GlobeBrowsingModule>();
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
}
void RenderableGlobe::initializeGL() {
@@ -786,7 +775,7 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask
try {
// Before Shadows
//renderChunks(data, rendererTask);
//_globeLabelsComponent.draw(data);
_globeLabelsComponent.draw(data);
if (_hasShadows && _shadowComponent.isEnabled()) {
// Set matrices and other GL states
@@ -921,11 +910,7 @@ void RenderableGlobe::update(const UpdateData& data) {
_shadowComponent.update(data);
}
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
_nUploadedTiles = _layerManager.update();
#else
_layerManager.update();
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
if (_nLayersIsDirty) {
std::array<LayerGroup*, LayerManager::NumLayerGroups> lgs =
@@ -1237,15 +1222,6 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&,
}
_localRenderer.program->deactivate();
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
_module->addFrameInfo(
this,
std::min(localCount, ChunkBufferSize),
std::min(globalCount, ChunkBufferSize),
_nUploadedTiles
);
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
if (_debugProperties.showChunkBounds || _debugProperties.showChunkAABB) {
for (int i = 0; i < std::min(globalCount, ChunkBufferSize); ++i) {
debugRenderChunk(

View File

@@ -297,10 +297,6 @@ private:
// Labels
GlobeLabelsComponent _globeLabelsComponent;
ghoul::Dictionary _labelsDictionary;
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
int _nUploadedTiles = 0;
#endif // OPENSPACE_MODULE_GLOBEBROWSING_INSTRUMENTATION
};
} // namespace openspace::globebrowsing

View File

@@ -39,14 +39,14 @@ namespace {
using State = openspace::Asset::State;
switch (state) {
case State::Loaded: return "Loaded";
case State::LoadingFailed: return "LoadingFailed";
case State::Synchronizing: return "Synchronizing";
case State::SyncRejected: return "SyncRejected";
case State::SyncResolved: return "SyncResolved";
case State::Initialized: return "Initialized";
case State::InitializationFailed: return "InitializationFailed";
default: return "Unknown";
case State::Loaded: return "Loaded";
case State::LoadingFailed: return "LoadingFailed";
case State::Synchronizing: return "Synchronizing";
case State::SyncRejected: return "SyncRejected";
case State::SyncResolved: return "SyncResolved";
case State::Initialized: return "Initialized";
case State::InitializationFailed: return "InitializationFailed";
default: return "Unknown";
}
}
@@ -54,14 +54,14 @@ namespace {
using State = openspace::ResourceSynchronization::State;
switch (state) {
case State::Unsynced: return "Unsynced";
case State::Syncing: return "Syncing";
case State::Resolved: return "Resolved";
case State::Rejected: return "Rejected";
default: return "Unknown";
case State::Unsynced: return "Unsynced";
case State::Syncing: return "Syncing";
case State::Resolved: return "Resolved";
case State::Rejected: return "Rejected";
default: return "Unknown";
}
}
}
} // namespace
namespace openspace::gui {
@@ -69,7 +69,6 @@ GuiAssetComponent::GuiAssetComponent()
: GuiComponent("Assets")
{}
void GuiAssetComponent::render() {
bool e = _isEnabled;
ImGui::Begin("Assets", &e);
@@ -79,7 +78,7 @@ void GuiAssetComponent::render() {
std::string rootPath;
for (const std::shared_ptr<Asset>& a : assetManager.rootAsset()->childAssets()) {
for (Asset* a : assetManager.rootAsset().childAssets()) {
renderTree(*a, rootPath);
}
@@ -104,29 +103,29 @@ void GuiAssetComponent::renderTree(const Asset& asset, const std::string& relati
assetText += " (" + std::to_string(prog) + "%)";
}
const std::vector<std::shared_ptr<Asset>>& requested = asset.requestedAssets();
const std::vector<std::shared_ptr<Asset>>& required = asset.requiredAssets();
std::vector<Asset*> requested = asset.requestedAssets();
std::vector<Asset*> required = asset.requiredAssets();
const std::vector<std::shared_ptr<ResourceSynchronization>>& resourceSyncs =
const std::vector<ResourceSynchronization*>& resourceSyncs =
asset.ownSynchronizations();
if (requested.empty() && required.empty() && resourceSyncs.empty()) {
ImGui::Text("%s", assetText.c_str());
}
else if (ImGui::TreeNode(assetPath.c_str(), "%s", assetText.c_str())) {
for (const std::shared_ptr<Asset>& child : required) {
for (const Asset* child : required) {
renderTree(*child, assetDirectory);
}
if (!requested.empty() && ImGui::TreeNode("Requested assets")) {
for (const std::shared_ptr<Asset>& child : requested) {
for (const Asset* child : requested) {
renderTree(*child, assetDirectory);
}
ImGui::TreePop();
}
if (!resourceSyncs.empty() && ImGui::TreeNode("Resource Synchronizations")) {
for (const std::shared_ptr<ResourceSynchronization>& sync : resourceSyncs) {
for (ResourceSynchronization* sync : resourceSyncs) {
std::string resourceText = sync->directory() +
" " + syncStateToString(sync->state());
if (sync->state() == ResourceSynchronization::State::Syncing) {

View File

@@ -68,7 +68,7 @@ SpaceModule::SpaceModule()
addProperty(_showSpiceExceptions);
}
void SpaceModule::internalInitialize(const ghoul::Dictionary&) {
void SpaceModule::internalInitialize(const ghoul::Dictionary& dictionary) {
FactoryManager::ref().addFactory(
std::make_unique<ghoul::TemplateFactory<planetgeometry::PlanetGeometry>>(),
"PlanetGeometry"
@@ -106,6 +106,10 @@ void SpaceModule::internalInitialize(const ghoul::Dictionary&) {
auto fGeometry = FactoryManager::ref().factory<planetgeometry::PlanetGeometry>();
ghoul_assert(fGeometry, "Planet geometry factory was not created");
fGeometry->registerClass<planetgeometry::SimpleSphereGeometry>("SimpleSphere");
if (dictionary.hasKeyAndValue<bool>(SpiceExceptionInfo.identifier)) {
_showSpiceExceptions = dictionary.value<bool>(SpiceExceptionInfo.identifier);
}
}
void SpaceModule::internalDeinitializeGL() {

View File

@@ -29,7 +29,6 @@
#include <openspace/documentation/verifier.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/globals.h>
#include <openspace/scene/assetlistener.h>
#include <openspace/scene/assetloader.h>
#include <openspace/scripting/scriptengine.h>
#include <openspace/util/openspacemodule.h>
@@ -74,21 +73,6 @@ documentation::Documentation SyncAssetTask::documentation() {
};
}
class RequestListener : public AssetListener {
public:
virtual ~RequestListener() = default;
void assetStateChanged(std::shared_ptr<Asset> asset, Asset::State state) override {
if (state == Asset::State::LoadingFailed) {
LERROR(fmt::format("Failed to load asset: {}", asset->id()));
}
if (state == Asset::State::SyncRejected) {
LERROR(fmt::format("Failed to sync asset: {}", asset->id()));
}
}
void assetRequested(std::shared_ptr<Asset>, std::shared_ptr<Asset>) override {};
void assetUnrequested(std::shared_ptr<Asset>, std::shared_ptr<Asset>) override {};
};
SyncAssetTask::SyncAssetTask(const ghoul::Dictionary& dictionary) {
documentation::testSpecificationAndThrow(
documentation(),
@@ -125,18 +109,14 @@ void SyncAssetTask::perform(const Task::ProgressCallback& progressCallback) {
AssetLoader loader(&luaState, &watcher, "${ASSETS}");
RequestListener listener;
loader.addAssetListener(&listener);
loader.add(_asset);
loader.rootAsset()->startSynchronizations();
loader.rootAsset().startSynchronizations();
std::vector<std::shared_ptr<const Asset>> allAssets =
loader.rootAsset()->subTreeAssets();
std::vector<const Asset*> allAssets = loader.rootAsset().subTreeAssets();
while (true) {
bool inProgress = false;
for (const std::shared_ptr<const Asset>& asset : allAssets) {
for (const Asset* asset : allAssets) {
Asset::State state = asset->state();
if (state == Asset::State::Unloaded ||
state == Asset::State::Loaded ||
@@ -145,7 +125,7 @@ void SyncAssetTask::perform(const Task::ProgressCallback& progressCallback) {
inProgress = true;
}
}
progressCallback(loader.rootAsset()->requestedSynchronizationProgress());
progressCallback(loader.rootAsset().requestedSynchronizationProgress());
std::this_thread::sleep_for(ProgressPollInterval);
watcher.notify();
if (!inProgress) {