From caf125c592357fbe695d42d414b6c10b5dca1f2d Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 9 Aug 2020 11:21:25 +0200 Subject: [PATCH 01/59] Some more work on this --- include/openspace/rendering/renderable.h | 3 +++ src/rendering/renderable.cpp | 4 ++++ src/scene/scenegraphnode.cpp | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index 281c5ef85b..385e0173d8 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -72,6 +72,7 @@ public: virtual bool isReady() const = 0; bool isEnabled() const; + bool shouldUpdateIfDisabled() const; void setBoundingSphere(float boundingSphere); float boundingSphere() const; @@ -99,6 +100,8 @@ protected: properties::FloatProperty _boundingSphere; properties::StringProperty _renderableType; + bool _shouldUpdateIfDisabled = false; + void setRenderBinFromOpacity(); void registerUpdateRenderBinFromOpacity(); diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 453e040829..beae4048a4 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -235,6 +235,10 @@ bool Renderable::isEnabled() const { return _enabled; } +bool Renderable::shouldUpdateIfDisabled() const { + return _shouldUpdateIfDisabled; +} + void Renderable::onEnabledChange(std::function callback) { _enabled.onChange([this, c = std::move(callback)]() { c(isEnabled()); diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 2344ee9f77..fb7905e9bb 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -472,7 +472,9 @@ void SceneGraphNode::update(const UpdateData& data) { _modelTransformCached = translation * rotation * scaling; _inverseModelTransformCached = glm::inverse(_modelTransformCached); - if (_renderable && _renderable->isReady()) { + if (_renderable && _renderable->isReady() && + (_renderable->isEnabled() || _renderable->shouldUpdateIfDisabled())) + { _renderable->update(newUpdateData); } } From 77db3b6ce80eb9b8357b1f95ce161f90ab116eec Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 11 Aug 2020 11:43:50 +0200 Subject: [PATCH 02/59] Remove caching of inverse model transform for every scene graph node --- include/openspace/rendering/renderable.h | 2 +- include/openspace/scene/scenegraphnode.h | 2 -- modules/globebrowsing/globebrowsingmodule.cpp | 8 ++++++-- modules/globebrowsing/globebrowsingmodule_lua.inl | 2 +- .../globebrowsing/src/dashboarditemglobelocation.cpp | 2 +- modules/globebrowsing/src/renderableglobe.cpp | 2 ++ modules/globebrowsing/src/ringscomponent.cpp | 3 +++ modules/globebrowsing/src/shadowcomponent.cpp | 3 +++ src/interaction/orbitalnavigator.cpp | 6 +++--- src/scene/scenegraphnode.cpp | 10 ++++------ 10 files changed, 24 insertions(+), 16 deletions(-) diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index 385e0173d8..589daf3827 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -36,7 +36,7 @@ namespace ghoul { class Dictionary; } namespace ghoul::opengl { class ProgramObject; class Texture; -} +} // namespace ghoul::opengl namespace openspace { diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index adf30bdc44..3bf4a2b600 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -120,7 +120,6 @@ public: glm::dvec3 worldPosition() const; const glm::dmat3& worldRotationMatrix() const; glm::dmat4 modelTransform() const; - glm::dmat4 inverseModelTransform() const; glm::dvec3 worldScale() const; bool isTimeFrameActive(const Time& time) const; @@ -176,7 +175,6 @@ private: glm::dvec3 _worldScaleCached = glm::dvec3(1.0); glm::dmat4 _modelTransformCached = glm::dmat4(1.0); - glm::dmat4 _inverseModelTransformCached = glm::dmat4(1.0); properties::FloatProperty _boundingSphere; properties::BoolProperty _computeScreenSpaceValues; diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index 7314da9eff..5c93d78964 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -521,7 +521,9 @@ void GlobeBrowsingModule::goToChunk(const globebrowsing::RenderableGlobe& globe, ); return; } - const glm::dmat4 inverseModelTransform = globeSceneGraphNode->inverseModelTransform(); + const glm::dmat4 inverseModelTransform = glm::inverse( + globeSceneGraphNode->modelTransform() + ); const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0)); const SurfacePositionHandle posHandle = globe.calculateSurfacePositionHandle( @@ -551,7 +553,9 @@ void GlobeBrowsingModule::goToGeodetic2(const globebrowsing::RenderableGlobe& gl LERROR("Error when going to Geodetic2"); } - const glm::dmat4 inverseModelTransform = globeSceneGraphNode->inverseModelTransform(); + const glm::dmat4 inverseModelTransform = glm::inverse( + globeSceneGraphNode->modelTransform() + ); const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0)); diff --git a/modules/globebrowsing/globebrowsingmodule_lua.inl b/modules/globebrowsing/globebrowsingmodule_lua.inl index 86d474d64c..666b942143 100644 --- a/modules/globebrowsing/globebrowsingmodule_lua.inl +++ b/modules/globebrowsing/globebrowsingmodule_lua.inl @@ -329,7 +329,7 @@ int getGeoPositionForCamera(lua_State* L) { const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3(); const SceneGraphNode* anchor = global::navigationHandler.orbitalNavigator().anchorNode(); - const glm::dmat4 inverseModelTransform = anchor->inverseModelTransform(); + const glm::dmat4 inverseModelTransform = glm::inverse(anchor->modelTransform()); const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0)); const SurfacePositionHandle posHandle = globe->calculateSurfacePositionHandle( diff --git a/modules/globebrowsing/src/dashboarditemglobelocation.cpp b/modules/globebrowsing/src/dashboarditemglobelocation.cpp index 183e08ea8d..4bac59a59f 100644 --- a/modules/globebrowsing/src/dashboarditemglobelocation.cpp +++ b/modules/globebrowsing/src/dashboarditemglobelocation.cpp @@ -153,7 +153,7 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) { } const glm::dvec3 cameraPosition = global::navigationHandler.camera()->positionVec3(); - const glm::dmat4 inverseModelTransform = n->inverseModelTransform(); + const glm::dmat4 inverseModelTransform = glm::inverse(n->modelTransform()); const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0)); const SurfacePositionHandle posHandle = globe->calculateSurfacePositionHandle( diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 00b1d1adcf..81512db291 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -843,6 +843,8 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask } void RenderableGlobe::update(const UpdateData& data) { + ZoneScoped + if (_localRenderer.program && _localRenderer.program->isDirty()) { _localRenderer.program->rebuildFromFile(); diff --git a/modules/globebrowsing/src/ringscomponent.cpp b/modules/globebrowsing/src/ringscomponent.cpp index 7bf3a70d73..19ef939018 100644 --- a/modules/globebrowsing/src/ringscomponent.cpp +++ b/modules/globebrowsing/src/ringscomponent.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -379,6 +380,8 @@ void RingsComponent::draw(const RenderData& data, } void RingsComponent::update(const UpdateData& data) { + ZoneScoped + if (_shader && _shader->isDirty()) { compileShadowShader(); } diff --git a/modules/globebrowsing/src/shadowcomponent.cpp b/modules/globebrowsing/src/shadowcomponent.cpp index aacf1f8e04..c615d3a64b 100644 --- a/modules/globebrowsing/src/shadowcomponent.cpp +++ b/modules/globebrowsing/src/shadowcomponent.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -437,6 +438,8 @@ void ShadowComponent::end() { } void ShadowComponent::update(const UpdateData&) { + ZoneScoped + _sunPosition = global::renderEngine.scene()->sceneGraphNode("Sun")->worldPosition(); glm::ivec2 renderingResolution = global::renderEngine.renderingResolution(); diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index b383eef56e..bbee6702f0 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -789,7 +789,7 @@ bool OrbitalNavigator::shouldFollowAnchorRotation(const glm::dvec3& cameraPositi } const glm::dmat4 modelTransform = _anchorNode->modelTransform(); - const glm::dmat4 inverseModelTransform = _anchorNode->inverseModelTransform(); + const glm::dmat4 inverseModelTransform = glm::inverse(modelTransform); const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform * glm::dvec4(cameraPosition, 1.0)); @@ -843,8 +843,8 @@ OrbitalNavigator::CameraRotationDecomposition const glm::dvec3 cameraViewDirection = cameraPose.rotation * glm::dvec3(0.0, 0.0, -1.0); - const glm::dmat4 inverseModelTransform = reference.inverseModelTransform(); const glm::dmat4 modelTransform = reference.modelTransform(); + const glm::dmat4 inverseModelTransform = glm::inverse(modelTransform); const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform * glm::dvec4(cameraPose.position, 1)); @@ -1407,7 +1407,7 @@ SurfacePositionHandle OrbitalNavigator::calculateSurfacePositionHandle( const SceneGraphNode& node, const glm::dvec3 cameraPositionWorldSpace) { - const glm::dmat4 inverseModelTransform = node.inverseModelTransform(); + const glm::dmat4 inverseModelTransform = glm::inverse(node.modelTransform()); const glm::dvec3 cameraPositionModelSpace = glm::dvec3(inverseModelTransform * glm::dvec4(cameraPositionWorldSpace, 1)); const SurfacePositionHandle posHandle = diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index fb7905e9bb..7e7f679373 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -467,10 +467,12 @@ void SceneGraphNode::update(const UpdateData& data) { newUpdateData.modelTransform.translation ); glm::dmat4 rotation = glm::dmat4(newUpdateData.modelTransform.rotation); - glm::dmat4 scaling = glm::scale(glm::dmat4(1.0), newUpdateData.modelTransform.scale); + glm::dmat4 scaling = glm::scale( + glm::dmat4(1.0), + newUpdateData.modelTransform.scale + ); _modelTransformCached = translation * rotation * scaling; - _inverseModelTransformCached = glm::inverse(_modelTransformCached); if (_renderable && _renderable->isReady() && (_renderable->isEnabled() || _renderable->shouldUpdateIfDisabled())) @@ -769,10 +771,6 @@ glm::dmat4 SceneGraphNode::modelTransform() const { return _modelTransformCached; } -glm::dmat4 SceneGraphNode::inverseModelTransform() const { - return _inverseModelTransformCached; -} - glm::dvec3 SceneGraphNode::worldScale() const { return _worldScaleCached; } From d97c96d14466b8534842589088475b25114283fe Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 11 Aug 2020 11:44:02 +0200 Subject: [PATCH 03/59] Don't update the scene twice on the master --- src/engine/openspaceengine.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index cf84e4ecff..c0f48d388a 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1148,7 +1148,9 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { writeSceneDocumentation(); } - global::renderEngine.updateScene(); + if (!global::windowDelegate.isMaster()) { + global::renderEngine.updateScene(); + } global::renderEngine.updateRenderer(); global::renderEngine.updateScreenSpaceRenderables(); global::renderEngine.updateShaderPrograms(); From 38eac377e8028a1bca74580c3c6265b9bded24b7 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 13 Aug 2020 10:47:30 +0200 Subject: [PATCH 04/59] Introduce the date library --- .gitmodules | 3 + ext/date | 1 + include/openspace/util/time.h | 3 +- modules/globebrowsing/src/tileprovider.cpp | 2 + modules/globebrowsing/src/timequantizer.cpp | 260 ++++++++++---------- modules/globebrowsing/src/timequantizer.h | 20 +- src/CMakeLists.txt | 2 + src/util/time.cpp | 11 +- 8 files changed, 152 insertions(+), 150 deletions(-) create mode 160000 ext/date diff --git a/.gitmodules b/.gitmodules index 516a853c2b..0bfcb7f59d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -26,3 +26,6 @@ [submodule "apps/OpenSpace-MinVR/ext/glfw"] path = apps/OpenSpace-MinVR/ext/glfw url = https://github.com/opensgct/glfw +[submodule "ext/date"] + path = ext/date + url = https://github.com/HowardHinnant/date diff --git a/ext/date b/ext/date new file mode 160000 index 0000000000..569b2d6785 --- /dev/null +++ b/ext/date @@ -0,0 +1 @@ +Subproject commit 569b2d678547985d0ead3b73ee93a28919000887 diff --git a/include/openspace/util/time.h b/include/openspace/util/time.h index d98cd896cb..25c29bd2e6 100644 --- a/include/openspace/util/time.h +++ b/include/openspace/util/time.h @@ -66,6 +66,7 @@ public: static double convertTime(const std::string& time); explicit Time(double secondsJ2000 = -1); + explicit Time(const std::string& time); Time(const Time& other) = default; /** @@ -98,7 +99,7 @@ public: * (http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html) * \param time The time to be set as a date string */ - void setTime(std::string time); + void setTime(const std::string& time); /** * Returns the current time as the number of seconds past the J2000 epoch. If the diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index 95be5d9d26..c67a88a49d 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -274,6 +274,8 @@ TileProvider* levelProvider(TileProviderByLevel& t, int level) { // std::string timeStringify(TemporalTileProvider::TimeFormatType type, const Time& t) { + ZoneScoped + switch (type) { case TemporalTileProvider::TimeFormatType::YYYY_MM_DD: return t.ISO8601().substr(0, 10); diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index e6b660c988..9173f84c5c 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -29,7 +29,10 @@ #include #include #include +#include +#include #include +#include #include #include @@ -42,74 +45,54 @@ namespace openspace::globebrowsing { namespace { - -// returns the number of days in a given month and year (takes leap year into account) -int monthSize(int month, int year) { - // A year is a leap year if it is divisible by 4 unless it is also divisible by 100 - // unless it is divisible by 4 *and* 100 - const bool leap = ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)); - - switch (month) { - case 2: - return leap ? 29 : 28; - case 4: - case 6: - case 9: - case 11: - return 30; - case 1: - case 3: - case 5: - case 7: - case 8: - case 10: - case 12: - default: - return 31; + // returns the number of days in a given month and year (takes leap year into account) + constexpr int monthSize(int month, int year) { + date::year_month_day_last d = date::year(year) / date::month(month) / date::last; + return static_cast(static_cast(d.day())); } -} -/** - * singleIncrement is used for any of the date/time types, and handles overflow - * values using the min/max parameters - * - * \param oper the date/time variable to operate on (will be changed) - * \param val the value of the increment, which may be changed in this function - * if an overflow occurs - * \param min the minimum allowable value - * \param max the maximum allowable value (determines where overflow occurs) - */ -bool singleIncrement(int& oper, int& val, int min, int max) { - oper += val; - if (oper <= max) { - return true; + /** + * singleIncrement is used for any of the date/time types, and handles overflow + * values using the min/max parameters + * + * \param oper the date/time variable to operate on (will be changed) + * \param val the value of the increment, which may be changed in this function + * if an overflow occurs + * \param min the minimum allowable value + * \param max the maximum allowable value (determines where overflow occurs) + */ + bool singleIncrement(int& oper, int& val, int min, int max) { + oper += val; + if (oper <= max) { + return true; + } + oper = oper - max - (1 - min); + // Only single increments for the less-significant units on rollover + val = 1; + return false; } - oper = oper - max - (1 - min); - // Only single increments for the less-significant units on rollover - val = 1; - return false; -} -/** - * singleDecrement is used for any of the date/time types, and handles underflow - * values using the min/max parameters - * - * \param oper the date/time variable to operate on (will be changed) - * \param val the value of the decrement, which may be changed in this function - * if an underflow occurs - * \param min the minimum allowable value - * \param max the maximum allowable value (determines where underflow occurs) - */ -bool singleDecrement(int& oper, int& val, int min, int max) { - oper -= val; - if (oper >= min) { - return true; + /** + * singleDecrement is used for any of the date/time types, and handles underflow + * values using the min/max parameters + * + * \param oper the date/time variable to operate on (will be changed) + * \param val the value of the decrement, which may be changed in this function + * if an underflow occurs + * \param min the minimum allowable value + * \param max the maximum allowable value (determines where underflow occurs) + */ + bool singleDecrement(int& oper, int& val, int min, int max) { + oper -= val; + if (oper >= min) { + return true; + } + oper = oper + max + (1 - min); + // Only single increments for the less-significant units on rollover + val = 1; + return false; } - oper = oper + max + (1 - min); - // Only single increments for the less-significant units on rollover - val = 1; - return false; -} + } // namespace RangedTime::RangedTime(std::string start, std::string end) @@ -124,20 +107,18 @@ void RangedTime::setStart(std::string start) { Time t1; t1.setTime(start); _startJ2000 = t1.j2000Seconds(); - _start = start; + _start = std::move(start); } -void RangedTime::setEnd(const std::string end) { +void RangedTime::setEnd(std::string end) { Time t2; t2.setTime(end); _endJ2000 = t2.j2000Seconds(); - _end = end; + _end = std::move(end); } -bool RangedTime::includes(const std::string& checkTime) { - Time t; - t.setTime(checkTime); - const double tj = t.j2000Seconds(); +bool RangedTime::includes(const Time& checkTime) const { + const double tj = checkTime.j2000Seconds(); return (_startJ2000 <= tj && tj <= _endJ2000); } @@ -164,17 +145,25 @@ std::string RangedTime::end() const { return _end; } -DateTime::DateTime(const std::string& initDateTime) { +DateTime::DateTime(std::string_view initDateTime) { setTime(initDateTime); }; -void DateTime::setTime(const std::string& input) { - _year = std::stoi(input.substr(index_year, len_year)); - _month = std::stoi(input.substr(index_month, len_nonYear)); - _day = std::stoi(input.substr(index_day, len_nonYear)); - _hour = std::stoi(input.substr(index_hour, len_nonYear)); - _minute = std::stoi(input.substr(index_minute, len_nonYear)); - _second = std::stoi(input.substr(index_second, len_nonYear)); +void DateTime::setTime(std::string_view input) { + // Indices into an ISO8601 YYYY-MM-ddTHH:mm:ss string + constexpr const size_t IndexYear = 0; + constexpr const size_t IndexMonth = 5; + constexpr const size_t IndexDay = 8; + constexpr const size_t IndexHour = 11; + constexpr const size_t IndexMinute = 14; + constexpr const size_t IndexSecond = 17; + + std::from_chars(input.data() + IndexYear, input.data() + 4, _year); + std::from_chars(input.data() + IndexMonth, input.data() + 2, _month); + std::from_chars(input.data() + IndexDay, input.data() + 2, _day); + std::from_chars(input.data() + IndexHour, input.data() + 2, _hour); + std::from_chars(input.data() + IndexMinute, input.data() + 2, _minute); + std::from_chars(input.data() + IndexSecond, input.data() + 2, _second); } std::string DateTime::ISO8601() const { @@ -215,31 +204,30 @@ void DateTime::incrementOnce(int value, char unit) { bool inBounds = true; switch (unit) { case 'm': - if (singleIncrement(_minute, value, 0, 59)) + if (singleIncrement(_minute, value, 0, 59)) { break; - // else fall-through if overflow... - + } + //[[ fallthrough ]] case 'h': - if (singleIncrement(_hour, value, 0, 23)) + if (singleIncrement(_hour, value, 0, 23)) { break; - // else fall-through if overflow... - + } + //[[ fallthrough ]] case 'd': - if (singleIncrement(_day, value, 1, monthSize(_month, _year))) + if (singleIncrement(_day, value, 1, monthSize(_month, _year))) { break; - // else fall-through if overflow... - + } + //[[ fallthrough ]] case 'M': inBounds = singleIncrement(_month, value, 1, 12); _day = std::clamp(_day, 1, monthSize(_month, _year)); - if (inBounds) + if (inBounds) { break; - // else fall-through if overflow... - + } + //[[ fallthrough ]] case 'y': _year += value; break; - default: throw ghoul::RuntimeError( "Invalid unit format in TQ incrementOnce '" + std::to_string(unit) + @@ -481,33 +469,43 @@ double TimeQuantizer::computeSecondsFromResolution(const int valueIn, const char } bool TimeQuantizer::quantize(Time& t, bool clamp) { + ZoneScoped + const std::string unquantizedStr = t.ISO8601(); DateTime unquantized(unquantizedStr); - //resolutionFraction helps to improve iteration performance - const double resolutionFraction = 0.7; - double error = 0.0; - const int iterationLimit = 50; + // resolutionFraction helps to improve iteration performance + constexpr const double ResolutionFraction = 0.7; + constexpr const int IterationLimit = 50; int iterations = 0; int lastIncr = 0; int lastDecr = 0; - if (_timerange.includes(unquantizedStr)) { + if (_timerange.includes(t)) { + ZoneScopedN("includes") DateTime quantized = DateTime(_timerange.start()); doFirstApproximation(quantized, unquantized, _resolutionValue, _resolutionUnit); - error = diff(quantized, unquantized); - while (error > (_resolution * resolutionFraction) || error < 0) { + double error = unquantized.J2000() - quantized.J2000(); + while (error > (_resolution * ResolutionFraction) || error < 0) { if (error > 0) { - lastIncr = quantized.increment(static_cast(_resolutionValue), - _resolutionUnit, error, _resolution); + lastIncr = quantized.increment( + static_cast(_resolutionValue), + _resolutionUnit, + error, + _resolution + ); } else if (error < 0) { - lastDecr = quantized.decrement(static_cast(_resolutionValue), - _resolutionUnit, error, _resolution); + lastDecr = quantized.decrement( + static_cast(_resolutionValue), + _resolutionUnit, + error, + _resolution + ); } - error = diff(quantized, unquantized); + error = unquantized.J2000() - quantized.J2000(); bool hasSettled = (lastIncr == 1 && lastDecr == 1 && error >= 0.0); iterations++; - if (hasSettled || iterations > iterationLimit) { + if (hasSettled || iterations > IterationLimit) { break; } } @@ -525,50 +523,50 @@ bool TimeQuantizer::quantize(Time& t, bool clamp) { } } -double TimeQuantizer::diff(DateTime& from, DateTime& to) { - return to.J2000() - from.J2000(); -} - -void TimeQuantizer::doFirstApproximation(DateTime& quantized, DateTime& unQ, - double value, char unit) +void TimeQuantizer::doFirstApproximation(DateTime& quantized, DateTime& unQ, double value, + char unit) { - double minYearsToAdjust; - double minIncrementsAdjust; - bool isSimMonthPastQuantizedMonth; - double error = 0.0; - int originalHour, originalMinute, originalSecond; - Time testDay; - double addToTime; + ZoneScoped switch (unit) { case 'y': - minYearsToAdjust = static_cast(unQ.year()) - - static_cast(_start.year()); - minIncrementsAdjust = minYearsToAdjust / value; + { + const double minYearsToAdjust = static_cast( + unQ.year()) - static_cast(_start.year() + ); + const double minIncrementsAdjust = minYearsToAdjust / value; quantized.setYear( _start.year() + static_cast(minIncrementsAdjust * value) ); break; + } case 'M': - isSimMonthPastQuantizedMonth = unQ.month() > static_cast(value); + { + bool isSimMonthPastQuantizedMonth = unQ.month() > static_cast(value); quantized.setYear( (isSimMonthPastQuantizedMonth) ? unQ.year() : unQ.year() - 1 ); break; + } case 'd': - error = diff(quantized, unQ) / (60 * 60 * 24); - originalHour = quantized.hour(); - originalMinute = quantized.minute(); - originalSecond = quantized.second(); - addToTime = std::round(error) * 86400; - testDay.setTime(quantized.J2000() + addToTime); + { + ZoneScopedN("d") + const double error = (unQ.J2000() - quantized.J2000()) / (60 * 60 * 24); + const int originalHour = quantized.hour(); + const int originalMinute = quantized.minute(); + const int originalSecond = quantized.second(); + const double addToTime = std::round(error) * 86400; + Time testDay(quantized.J2000() + addToTime); quantized.setTime(testDay.ISO8601()); quantized.setHour(originalHour); quantized.setMinute(originalMinute); quantized.setSecond(originalSecond); break; + } case 'h': - quantized = unQ; + { + ZoneScopedN("h") + quantized = unQ; quantized.setMinute(0); quantized.setSecond(0); if (unQ.hour() >= 12) { @@ -578,6 +576,7 @@ void TimeQuantizer::doFirstApproximation(DateTime& quantized, DateTime& unQ, quantized.decrementOnce(1, 'd'); } break; + } case 'm': quantized = unQ; quantized.setMinute(0); @@ -591,8 +590,7 @@ void TimeQuantizer::doFirstApproximation(DateTime& quantized, DateTime& unQ, break; default: throw ghoul::RuntimeError(fmt::format( - "Invalid unit format in doFirstApproximation '{}'. Expected 'y', 'M', " - "d', 'h', or 'm'", unit + "Invalid unit '{}'. Expected 'y', 'M', 'd', 'h', or 'm'", unit )); } } @@ -617,7 +615,7 @@ std::vector TimeQuantizer::quantized(Time& start, Time& end) { std::vector result; DateTime itr = s; RangedTime range(start.ISO8601(), end.ISO8601()); - while (range.includes(itr.ISO8601())) { + while (range.includes(Time(itr.ISO8601()))) { itr.incrementOnce(static_cast(_resolutionValue), _resolutionUnit); result.push_back(itr.ISO8601()); } diff --git a/modules/globebrowsing/src/timequantizer.h b/modules/globebrowsing/src/timequantizer.h index 19decc6fa9..3d7b00b81a 100644 --- a/modules/globebrowsing/src/timequantizer.h +++ b/modules/globebrowsing/src/timequantizer.h @@ -54,11 +54,11 @@ public: * Checks if a date/time value falls within the start/end range defined in this * instance of the class. * - * \param checkTime An ISO8601 date/time string to test if it falls within the range + * \param checkTime The time to test if it falls within the range * * \returns true if the input date/time falls between the start and end date/times */ - bool includes(const std::string& checkTime); + bool includes(const Time& checkTime) const; /* * Enforces the start/end range on a given date/time string by clamping the value @@ -122,14 +122,14 @@ public: * * \params initDateTime the ISO8601 date/time string (YYYY-MM-DDTHH:mm:ss) */ - DateTime(const std::string& initDateTime); + DateTime(std::string_view initDateTime); /* * Set the date/time value * * \params input the ISO8601 date/time string (YYYY-MM-DDTHH:mm:ss) to set */ - void setTime(const std::string& input); + void setTime(std::string_view input); /* * Used to deep-copy from another DateTime instance @@ -276,17 +276,6 @@ public: void decrementOnce(int value, char unit); private: - // index_ values are indices into an ISO8601 YYYY-MM-ddTHH:mm:ss string - const int index_year = 0; - const int index_month = 5; - const int index_day = 8; - const int index_hour = 11; - const int index_minute = 14; - const int index_second = 17; - - const int len_year = 4; - const int len_nonYear = 2; - int _year = 2000; int _month = 1; int _day = 1; @@ -369,7 +358,6 @@ public: private: void verifyStartTimeRestrictions(); void verifyResolutionRestrictions(const int value, const char unit); - double diff(DateTime& from, DateTime& to); void doFirstApproximation(DateTime& q, DateTime& unQ, double value, char unit); double computeSecondsFromResolution(const int valueIn, const char unit); double _resolution = 0.0; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8453570bf8..513db837e4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -433,6 +433,8 @@ target_include_directories(openspace-core PUBLIC ${OPENSPACE_BASE_DIR}/include # In order to be able to include module files ${OPENSPACE_BASE_DIR} + # In order to use the date library + ${OPENSPACE_BASE_DIR}/ext/date/include # In order to be able to include the module_registration file ${CMAKE_BINARY_DIR}/_generated/include ) diff --git a/src/util/time.cpp b/src/util/time.cpp index 819ef4788f..437a9408f4 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,10 @@ double Time::convertTime(const std::string& time) { Time::Time(double secondsJ2000) : _time(secondsJ2000) {} +Time::Time(const std::string& time) : + _time(SpiceManager::ref().ephemerisTimeFromDate(time)) +{} + Time Time::now() { Time now; time_t secondsSince1970; @@ -70,8 +75,8 @@ double Time::advanceTime(double delta) { return _time; } -void Time::setTime(std::string time) { - _time = SpiceManager::ref().ephemerisTimeFromDate(std::move(time)); +void Time::setTime(const std::string& time) { + _time = SpiceManager::ref().ephemerisTimeFromDate(time); } std::string Time::UTC() const { @@ -79,6 +84,8 @@ std::string Time::UTC() const { } std::string Time::ISO8601() const { + ZoneScoped + std::string datetime = SpiceManager::ref().dateFromEphemerisTime(_time); std::string_view month = std::string_view(datetime).substr(5, 3); From 760c34660f447723390982c807b5daada931502b Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 13 Aug 2020 11:42:12 +0200 Subject: [PATCH 05/59] Directly create the correct date/time format --- modules/globebrowsing/src/timequantizer.cpp | 12 +++++----- src/util/time.cpp | 25 ++++----------------- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index 9173f84c5c..080af9b3b9 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -229,10 +229,10 @@ void DateTime::incrementOnce(int value, char unit) { _year += value; break; default: - throw ghoul::RuntimeError( - "Invalid unit format in TQ incrementOnce '" + std::to_string(unit) + - "'. Expected 'y', 'M', 'd', 'h', or 'm'." - ); + throw ghoul::RuntimeError(fmt::format( + "Invalid unit in incrementOnce '{}'. Expected 'y', 'M', 'd', 'h', or 'm'", + unit + )); } } @@ -550,7 +550,6 @@ void TimeQuantizer::doFirstApproximation(DateTime& quantized, DateTime& unQ, dou } case 'd': { - ZoneScopedN("d") const double error = (unQ.J2000() - quantized.J2000()) / (60 * 60 * 24); const int originalHour = quantized.hour(); const int originalMinute = quantized.minute(); @@ -565,8 +564,7 @@ void TimeQuantizer::doFirstApproximation(DateTime& quantized, DateTime& unQ, dou } case 'h': { - ZoneScopedN("h") - quantized = unQ; + quantized = unQ; quantized.setMinute(0); quantized.setSecond(0); if (unQ.hour() >= 12) { diff --git a/src/util/time.cpp b/src/util/time.cpp index 437a9408f4..f9ad8bc102 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -86,27 +86,10 @@ std::string Time::UTC() const { std::string Time::ISO8601() const { ZoneScoped - std::string datetime = SpiceManager::ref().dateFromEphemerisTime(_time); - std::string_view month = std::string_view(datetime).substr(5, 3); - - std::string_view mm = [](std::string_view month) { - if (month == "JAN") { return "-01-"; } - else if (month == "FEB") { return "-02-"; } - else if (month == "MAR") { return "-03-"; } - else if (month == "APR") { return "-04-"; } - else if (month == "MAY") { return "-05-"; } - else if (month == "JUN") { return "-06-"; } - else if (month == "JUL") { return "-07-"; } - else if (month == "AUG") { return "-08-"; } - else if (month == "SEP") { return "-09-"; } - else if (month == "OCT") { return "-10-"; } - else if (month == "NOV") { return "-11-"; } - else if (month == "DEC") { return "-12-"; } - else { throw ghoul::MissingCaseException(); } - }(month); - - datetime.replace(4, 5, mm); - return datetime; + return SpiceManager::ref().dateFromEphemerisTime( + _time, + "YYYY-MM-DDTHR:MN:SC.###" + ); } scripting::LuaLibrary Time::luaLibrary() { From a6ca95347c15c6926cf905d84fa00731dca020d7 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 13 Aug 2020 14:02:02 +0200 Subject: [PATCH 06/59] Some small improvements --- modules/globebrowsing/src/memoryawaretilecache.h | 3 +-- modules/globebrowsing/src/renderableglobe.cpp | 10 ++++++++++ modules/globebrowsing/src/tileprovider.cpp | 5 +++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/globebrowsing/src/memoryawaretilecache.h b/modules/globebrowsing/src/memoryawaretilecache.h index 209e0e9aa5..eb199d6598 100644 --- a/modules/globebrowsing/src/memoryawaretilecache.h +++ b/modules/globebrowsing/src/memoryawaretilecache.h @@ -48,8 +48,7 @@ struct ProviderTileKey { unsigned int providerID; bool operator==(const ProviderTileKey& r) const { - return (providerID == r.providerID) && - (tileIndex == r.tileIndex); + return (providerID == r.providerID) && (tileIndex == r.tileIndex); } }; diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 81512db291..6d07fc9244 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -275,6 +275,8 @@ tilesAndSettingsUnsorted(const LayerGroup& layerGroup, const TileIndex& tileInde } BoundingHeights boundingHeightsForChunk(const Chunk& chunk, const LayerManager& lm) { + ZoneScoped + using ChunkTileSettingsPair = std::pair; BoundingHeights boundingHeights { 0.f, 0.f, false, true }; @@ -337,6 +339,8 @@ BoundingHeights boundingHeightsForChunk(const Chunk& chunk, const LayerManager& } bool colorAvailableForChunk(const Chunk& chunk, const LayerManager& lm) { + ZoneScoped + using ChunkTileSettingsPair = std::pair; const LayerGroup& colormaps = lm.layerGroup(layergroupid::GroupID::ColorLayers); std::vector chunkTileSettingPairs = tilesAndSettingsUnsorted( @@ -359,6 +363,8 @@ std::array boundingCornersForChunk(const Chunk& chunk, const Ellipsoid& ellipsoid, const BoundingHeights& heights) { + ZoneScoped + // assume worst case const double patchCenterRadius = ellipsoid.maximumRadius(); @@ -2490,6 +2496,7 @@ bool RenderableGlobe::updateChunkTree(Chunk& cn, const RenderData& data) { // children and then again it self to be processed after the children finish). // In addition, this didn't even improve performance --- 2018-10-04 if (isLeaf(cn)) { + ZoneScopedN("leaf") updateChunk(cn, data); if (cn.status == Chunk::Status::WantSplit) { @@ -2503,6 +2510,7 @@ bool RenderableGlobe::updateChunkTree(Chunk& cn, const RenderData& data) { return cn.status == Chunk::Status::WantMerge; } else { + ZoneScopedN("!leaf") char requestedMergeMask = 0; for (int i = 0; i < 4; ++i) { if (updateChunkTree(*cn.children[i], data)) { @@ -2528,6 +2536,8 @@ bool RenderableGlobe::updateChunkTree(Chunk& cn, const RenderData& data) { } void RenderableGlobe::updateChunk(Chunk& chunk, const RenderData& data) const { + ZoneScoped + const BoundingHeights& heights = boundingHeightsForChunk(chunk, _layerManager); chunk.heightTileOK = heights.tileOK; chunk.colorTileOK = colorAvailableForChunk(chunk, _layerManager); diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index c67a88a49d..6b71986482 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -923,16 +923,17 @@ Tile tile(TileProvider& tp, const TileIndex& tileIndex) { return Tile{ nullptr, std::nullopt, Tile::Status::OutOfRange }; } const cache::ProviderTileKey key = { tileIndex, t.uniqueIdentifier }; - const Tile tile = t.tileCache->get(key); + Tile tile = t.tileCache->get(key); if (!tile.texture) { + TracyMessage("Enqueuing tile", 32); t.asyncTextureDataProvider->enqueueTileIO(tileIndex); } return tile; } else { - return Tile{ nullptr, std::nullopt, Tile::Status::Unavailable }; + return Tile { nullptr, std::nullopt, Tile::Status::Unavailable }; } } case Type::SingleImageTileProvider: { From 4f68f99c9dab8e12191010954c7a08bcb173b226 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 13 Aug 2020 15:37:00 +0200 Subject: [PATCH 07/59] Remove dynamic memory allocation from TileMetaData --- apps/OpenSpace/ext/sgct | 2 +- ext/ghoul | 2 +- modules/globebrowsing/src/basictypes.h | 13 +++++-- modules/globebrowsing/src/lrucache.inl | 5 ++- .../globebrowsing/src/memoryawaretilecache.h | 4 +- .../globebrowsing/src/rawtiledatareader.cpp | 38 ++++++++----------- modules/globebrowsing/src/tileindex.cpp | 2 +- modules/globebrowsing/src/tileindex.h | 8 ++-- modules/globebrowsing/src/tileprovider.cpp | 4 +- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index f51dcffcc1..b712e64848 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit f51dcffcc18f0edbfa0ae87ffaa05af8eb52b91d +Subproject commit b712e6484894d70a60277bdcf719613b217954a7 diff --git a/ext/ghoul b/ext/ghoul index 44531db21c..b019427a8f 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 44531db21c0c9c5c0e90e672baa6f5d3f851be83 +Subproject commit b019427a8f6df48c3ed46f2980821deb79e701d3 diff --git a/modules/globebrowsing/src/basictypes.h b/modules/globebrowsing/src/basictypes.h index e26d439bf8..234a3eb542 100644 --- a/modules/globebrowsing/src/basictypes.h +++ b/modules/globebrowsing/src/basictypes.h @@ -26,6 +26,7 @@ #define __OPENSPACE_MODULE_GLOBEBROWSING__BASICTYPES___H__ #include +#include #include #include #include @@ -95,9 +96,15 @@ struct TileDepthTransform { struct TileMetaData { - std::vector maxValues; - std::vector minValues; - std::vector hasMissingData; + // 4 => the number of rasters, which has a maximum of 4 for RGBA images, we don't + // currently support images with arbitrary number of color channels and I don't know + // if GDAL does either. The std::vector here causes a dynamic memory allocation every + // time we return a Tile (which contains a TileMetaData as a member variable + + std::array maxValues; + std::array minValues; + std::array hasMissingData; + uint8_t nValues; }; diff --git a/modules/globebrowsing/src/lrucache.inl b/modules/globebrowsing/src/lrucache.inl index 2e67893a80..1ee02b4e1a 100644 --- a/modules/globebrowsing/src/lrucache.inl +++ b/modules/globebrowsing/src/lrucache.inl @@ -23,6 +23,7 @@ ****************************************************************************************/ #include +#include namespace openspace::globebrowsing::cache { @@ -82,11 +83,11 @@ bool LRUCache::isEmpty() const { template ValueType LRUCache::get(const KeyType& key) { - //ghoul_assert(exist(key), "Key " << key << " must exist"); const auto it = _itemMap.find(key); // Move list iterator pointing to value _itemList.splice(_itemList.begin(), _itemList, it->second); - return it->second->second; + ValueType res = it->second->second; + return res; } template diff --git a/modules/globebrowsing/src/memoryawaretilecache.h b/modules/globebrowsing/src/memoryawaretilecache.h index eb199d6598..41e90a1c32 100644 --- a/modules/globebrowsing/src/memoryawaretilecache.h +++ b/modules/globebrowsing/src/memoryawaretilecache.h @@ -45,7 +45,7 @@ namespace openspace::globebrowsing::cache { struct ProviderTileKey { TileIndex tileIndex; - unsigned int providerID; + uint16_t providerID; bool operator==(const ProviderTileKey& r) const { return (providerID == r.providerID) && (tileIndex == r.tileIndex); @@ -127,7 +127,7 @@ private: const TileTextureInitData& tileTextureInitData() const; /** - * \returns the number of textures in this TextureContainer + * \return the number of textures in this TextureContainer */ size_t size() const; diff --git a/modules/globebrowsing/src/rawtiledatareader.cpp b/modules/globebrowsing/src/rawtiledatareader.cpp index 43791302ea..4b1db96cbb 100644 --- a/modules/globebrowsing/src/rawtiledatareader.cpp +++ b/modules/globebrowsing/src/rawtiledatareader.cpp @@ -398,15 +398,11 @@ RawTile::ReadError postProcessErrorCheck(const RawTile& rawTile, [[ maybe_unused ]] size_t nRasters, float noDataValue) { - // This check was implicit before and just made explicit here - ghoul_assert( - nRasters == rawTile.tileMetaData.maxValues.size(), - "Wrong numbers of max values" - ); + ghoul_assert(nRasters == rawTile.tileMetaData.nValues, "Wrong numbers of max values"); const bool hasMissingData = std::any_of( rawTile.tileMetaData.maxValues.begin(), - rawTile.tileMetaData.maxValues.end(), + rawTile.tileMetaData.maxValues.begin() + rawTile.tileMetaData.nValues, [noDataValue](float v) { return v == noDataValue; } ); @@ -935,18 +931,14 @@ TileMetaData RawTileDataReader::tileMetaData(RawTile& rawTile, { const size_t bytesPerLine = _initData.bytesPerPixel * region.numPixels.x; - TileMetaData preprocessData; - preprocessData.maxValues.resize(_initData.nRasters); - preprocessData.minValues.resize(_initData.nRasters); - preprocessData.hasMissingData.resize(_initData.nRasters); + TileMetaData ppData; + ghoul_assert(_initData.nRasters <= 4, "Unexpected number of rasters"); + ppData.nValues = static_cast(_initData.nRasters); - std::vector noDataValues(_initData.nRasters); - for (size_t raster = 0; raster < _initData.nRasters; ++raster) { - preprocessData.maxValues[raster] = -FLT_MAX; - preprocessData.minValues[raster] = FLT_MAX; - preprocessData.hasMissingData[raster] = false; - noDataValues[raster] = noDataValueAsFloat(); - } + std::fill(ppData.maxValues.begin(), ppData.maxValues.end(), -FLT_MAX); + std::fill(ppData.minValues.begin(), ppData.minValues.end(), FLT_MAX); + std::fill(ppData.hasMissingData.begin(), ppData.hasMissingData.end(), false); + std::vector noDataValues(_initData.nRasters, noDataValueAsFloat()); bool allIsMissing = true; for (int y = 0; y < region.numPixels.y; ++y) { @@ -960,18 +952,18 @@ TileMetaData RawTileDataReader::tileMetaData(RawTile& rawTile, &(rawTile.imageData.get()[yi + i]) ); if (val != noDataValue && val == val) { - preprocessData.maxValues[raster] = std::max( + ppData.maxValues[raster] = std::max( val, - preprocessData.maxValues[raster] + ppData.maxValues[raster] ); - preprocessData.minValues[raster] = std::min( + ppData.minValues[raster] = std::min( val, - preprocessData.minValues[raster] + ppData.minValues[raster] ); allIsMissing = false; } else { - preprocessData.hasMissingData[raster] = true; + ppData.hasMissingData[raster] = true; float& floatToRewrite = reinterpret_cast( rawTile.imageData[yi + i] ); @@ -986,7 +978,7 @@ TileMetaData RawTileDataReader::tileMetaData(RawTile& rawTile, rawTile.error = RawTile::ReadError::Failure; } - return preprocessData; + return ppData; } int RawTileDataReader::maxChunkLevel() const { diff --git a/modules/globebrowsing/src/tileindex.cpp b/modules/globebrowsing/src/tileindex.cpp index e79acff1a4..56a2738b8a 100644 --- a/modules/globebrowsing/src/tileindex.cpp +++ b/modules/globebrowsing/src/tileindex.cpp @@ -30,7 +30,7 @@ bool operator==(const TileIndex& lhs, const TileIndex& rhs) { return (lhs.x == rhs.x) && (lhs.y == rhs.y) && (lhs.level == rhs.level); } -TileIndex::TileIndex(int x_, int y_, int level_) +TileIndex::TileIndex(uint32_t x_, uint32_t y_, uint8_t level_) : x(x_) , y(y_) , level(level_) diff --git a/modules/globebrowsing/src/tileindex.h b/modules/globebrowsing/src/tileindex.h index c29a4a4157..65d35150a9 100644 --- a/modules/globebrowsing/src/tileindex.h +++ b/modules/globebrowsing/src/tileindex.h @@ -34,11 +34,11 @@ namespace openspace::globebrowsing { struct TileIndex { using TileHashKey = uint64_t; - TileIndex(int x, int y, int level); + TileIndex(uint32_t x, uint32_t y, uint8_t level); - int x = 0; - int y = 0; - int level = 0; + uint32_t x = 0; + uint32_t y = 0; + uint8_t level = 0; TileIndex child(Quad q) const; glm::vec2 positionRelativeParent() const; diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index 6b71986482..39d61f9e37 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -77,7 +77,7 @@ namespace openspace::globebrowsing::tileprovider { namespace { std::unique_ptr DefaultTileTexture; -Tile DefaultTile = Tile{ nullptr, std::nullopt, Tile::Status::Unavailable }; +Tile DefaultTile = Tile { nullptr, std::nullopt, Tile::Status::Unavailable }; constexpr const char* KeyFilePath = "FilePath"; @@ -926,7 +926,7 @@ Tile tile(TileProvider& tp, const TileIndex& tileIndex) { Tile tile = t.tileCache->get(key); if (!tile.texture) { - TracyMessage("Enqueuing tile", 32); + //TracyMessage("Enqueuing tile", 32); t.asyncTextureDataProvider->enqueueTileIO(tileIndex); } From cabb962f6a1f69186e76e3c118c429305d49375a Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 13 Aug 2020 16:48:18 +0200 Subject: [PATCH 08/59] Use temporary memory arena to create unsorted list of tiles, preventing dynamic memory allocations --- include/openspace/util/memorymanager.h | 8 ++++- modules/globebrowsing/src/renderableglobe.cpp | 36 ++++++++++--------- modules/globebrowsing/src/tileprovider.cpp | 8 ++--- modules/imgui/src/guimemorycomponent.cpp | 4 +-- src/engine/openspaceengine.cpp | 4 +++ 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/include/openspace/util/memorymanager.h b/include/openspace/util/memorymanager.h index b1be10738d..893574d527 100644 --- a/include/openspace/util/memorymanager.h +++ b/include/openspace/util/memorymanager.h @@ -26,13 +26,19 @@ #define __OPENSPACE_CORE___MEMORYMANAGER___H__ #include +#include namespace openspace { class MemoryManager { public: ghoul::MemoryPool<8 * 1024 * 1024, false> PersistentMemory; - ghoul::MemoryPool<10 * 1024, false> TemporaryMemory; + + // This should be replaced with a std::pmr::memory_resource wrapper around our own + // Memory pool. Resetting the monotoic_buffer_resource costs an allocation, that we + // can prevent + std::pmr::monotonic_buffer_resource TemporaryMemory = + std::pmr::monotonic_buffer_resource(4096); }; } // namespace openspace diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 6d07fc9244..e5dae2b4b0 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -37,11 +37,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -49,6 +51,7 @@ #include #include #include +#include namespace { // Global flags to modify the RenderableGlobe @@ -258,10 +261,14 @@ const Chunk& findChunkNode(const Chunk& node, const Geodetic2& location) { return *n; } -std::vector> +std::pmr::vector> tilesAndSettingsUnsorted(const LayerGroup& layerGroup, const TileIndex& tileIndex) { - std::vector> tilesAndSettings; + ZoneScoped + + std::pmr::vector> tilesAndSettings( + &global::memoryManager.TemporaryMemory + ); for (Layer* layer : layerGroup.activeLayers()) { if (layer->tileProvider()) { tilesAndSettings.emplace_back( @@ -286,10 +293,9 @@ BoundingHeights boundingHeightsForChunk(const Chunk& chunk, const LayerManager& // (that is channel 0). const size_t HeightChannel = 0; const LayerGroup& heightmaps = lm.layerGroup(layergroupid::GroupID::HeightLayers); - std::vector chunkTileSettingPairs = tilesAndSettingsUnsorted( - heightmaps, - chunk.tileIndex - ); + + std::pmr::vector chunkTileSettingPairs = + tilesAndSettingsUnsorted(heightmaps, chunk.tileIndex); bool lastHadMissingData = true; for (const ChunkTileSettingsPair& chunkTileSettingsPair : chunkTileSettingPairs) { @@ -341,18 +347,14 @@ BoundingHeights boundingHeightsForChunk(const Chunk& chunk, const LayerManager& bool colorAvailableForChunk(const Chunk& chunk, const LayerManager& lm) { ZoneScoped - using ChunkTileSettingsPair = std::pair; - const LayerGroup& colormaps = lm.layerGroup(layergroupid::GroupID::ColorLayers); - std::vector chunkTileSettingPairs = tilesAndSettingsUnsorted( - colormaps, - chunk.tileIndex - ); + const LayerGroup& colorLayers = lm.layerGroup(layergroupid::GroupID::ColorLayers); - for (const ChunkTileSettingsPair& chunkTileSettingsPair : chunkTileSettingPairs) { - const ChunkTile& chunkTile = chunkTileSettingsPair.first; - - if (chunkTile.tile.status == Tile::Status::Unavailable) { - return false; + for (Layer* lyr : colorLayers.activeLayers()) { + if (lyr->tileProvider()) { + ChunkTile t = tileprovider::chunkTile(*lyr->tileProvider(), chunk.tileIndex); + if (t.tile.status == Tile::Status::Unavailable) { + return false; + } } } diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index 39d61f9e37..f0ae0b93d5 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -1404,7 +1404,7 @@ ChunkTile chunkTile(TileProvider& tp, TileIndex tileIndex, int parents, int maxP maxParents--; } if (maxParents < 0) { - return ChunkTile{ Tile(), uvTransform, TileDepthTransform() }; + return ChunkTile { Tile(), uvTransform, TileDepthTransform() }; } // Step 3. Traverse 0 or more parents up the chunkTree until we find a chunk that @@ -1413,16 +1413,16 @@ ChunkTile chunkTile(TileProvider& tp, TileIndex tileIndex, int parents, int maxP Tile t = tile(tp, tileIndex); if (t.status != Tile::Status::OK) { if (--maxParents < 0) { - return ChunkTile{ Tile(), uvTransform, TileDepthTransform() }; + return ChunkTile { Tile(), uvTransform, TileDepthTransform() }; } ascendToParent(tileIndex, uvTransform); } else { - return ChunkTile{ std::move(t), uvTransform, TileDepthTransform() }; + return ChunkTile { std::move(t), uvTransform, TileDepthTransform() }; } } - return ChunkTile{ Tile(), uvTransform, TileDepthTransform() }; + return ChunkTile { Tile(), uvTransform, TileDepthTransform() }; } diff --git a/modules/imgui/src/guimemorycomponent.cpp b/modules/imgui/src/guimemorycomponent.cpp index edec044174..2118679db4 100644 --- a/modules/imgui/src/guimemorycomponent.cpp +++ b/modules/imgui/src/guimemorycomponent.cpp @@ -66,8 +66,8 @@ void GuiMemoryComponent::render() { ImGui::Text("%s", "Persistent Memory Pool"); renderMemoryPoolInformation(global::memoryManager.PersistentMemory); - ImGui::Text("%s", "Temporary Memory Pool"); - renderMemoryPoolInformation(global::memoryManager.TemporaryMemory); + //ImGui::Text("%s", "Temporary Memory Pool"); + //renderMemoryPoolInformation(global::memoryManager.TemporaryMemory); ImGui::End(); } diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index c0f48d388a..e9216124cb 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -1059,6 +1060,9 @@ void OpenSpaceEngine::preSynchronization() { FileSys.triggerFilesystemEvents(); + // Reset the temporary, frame-based storage + global::memoryManager.TemporaryMemory.release(); + if (_hasScheduledAssetLoading) { LINFO(fmt::format("Loading asset: {}", _scheduledAssetPathToLoad)); global::profile.setIgnoreUpdates(true); From c55aa5f69ad9304553e3daa8ca55cf94d7bf2ea5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 13 Aug 2020 17:06:33 +0200 Subject: [PATCH 09/59] Remove capturing of variables in globe traversal lambda, reducing dynamic memory allocation there --- modules/globebrowsing/src/renderableglobe.cpp | 42 +++++++++---------- modules/globebrowsing/src/renderableglobe.h | 2 + 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index e5dae2b4b0..e12331f8ae 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -615,6 +615,8 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) addPropertySubOwner(_debugPropertyOwner); addPropertySubOwner(_layerManager); + _globalChunkBuffer.reserve(2048); + _localChunkBuffer.reserve(2048); _traversalMemory.reserve(512); //================================================================ @@ -1175,24 +1177,22 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, _globalRenderer.program->setIgnoreUniformLocationError(IgnoreError::Yes); } - constexpr const int ChunkBufferSize = 2048; - std::array global; int globalCount = 0; - std::array local; int localCount = 0; - auto traversal = [&global, &globalCount, &local, &localCount, this, - cutoff = _debugProperties.modelSpaceRenderingCutoffLevel](const Chunk& node) + auto traversal = [](const Chunk& node, std::vector& global, + int& globalCount, std::vector& local, int& localCount, int cutoff, + std::vector& traversalMemory) { ZoneScopedN("traversal") - _traversalMemory.clear(); + traversalMemory.clear(); // Loop through nodes in breadths first order - _traversalMemory.push_back(&node); - while (!_traversalMemory.empty()) { - const Chunk* n = _traversalMemory.front(); - _traversalMemory.erase(_traversalMemory.begin()); + traversalMemory.push_back(&node); + while (!traversalMemory.empty()) { + const Chunk* n = traversalMemory.front(); + traversalMemory.erase(traversalMemory.begin()); if (isLeaf(*n) && n->isVisible) { if (n->tileIndex.level < cutoff) { @@ -1208,43 +1208,43 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, // Add children to queue, if any if (!isLeaf(*n)) { for (int i = 0; i < 4; ++i) { - _traversalMemory.push_back(n->children[i]); + traversalMemory.push_back(n->children[i]); } } } }; - traversal(_leftRoot); - traversal(_rightRoot); + traversal(_leftRoot, _globalChunkBuffer, globalCount, _localChunkBuffer, localCount, _debugProperties.modelSpaceRenderingCutoffLevel, _traversalMemory); + traversal(_rightRoot, _globalChunkBuffer, globalCount, _localChunkBuffer, localCount, _debugProperties.modelSpaceRenderingCutoffLevel, _traversalMemory); // Render all chunks that want to be rendered globally _globalRenderer.program->activate(); - for (int i = 0; i < std::min(globalCount, ChunkBufferSize); ++i) { - renderChunkGlobally(*global[i], data, shadowData, renderGeomOnly); + for (int i = 0; i < globalCount; ++i) { + renderChunkGlobally(*_globalChunkBuffer[i], data, shadowData, renderGeomOnly); } _globalRenderer.program->deactivate(); // Render all chunks that need to be rendered locally _localRenderer.program->activate(); - for (int i = 0; i < std::min(localCount, ChunkBufferSize); ++i) { - renderChunkLocally(*local[i], data, shadowData, renderGeomOnly); + for (int i = 0; i < localCount; ++i) { + renderChunkLocally(*_localChunkBuffer[i], data, shadowData, renderGeomOnly); } _localRenderer.program->deactivate(); if (_debugProperties.showChunkBounds || _debugProperties.showChunkAABB) { - for (int i = 0; i < std::min(globalCount, ChunkBufferSize); ++i) { + for (int i = 0; i < globalCount; ++i) { debugRenderChunk( - *global[i], + *_globalChunkBuffer[i], mvp, _debugProperties.showChunkBounds, _debugProperties.showChunkAABB ); } - for (int i = 0; i < std::min(localCount, ChunkBufferSize); ++i) { + for (int i = 0; i < localCount; ++i) { debugRenderChunk( - *local[i], + *_localChunkBuffer[i], mvp, _debugProperties.showChunkBounds, _debugProperties.showChunkAABB diff --git a/modules/globebrowsing/src/renderableglobe.h b/modules/globebrowsing/src/renderableglobe.h index 5774bba960..6e7386cd84 100644 --- a/modules/globebrowsing/src/renderableglobe.h +++ b/modules/globebrowsing/src/renderableglobe.h @@ -258,6 +258,8 @@ private: ghoul::ReusableTypedMemoryPool _chunkPool; + std::vector _globalChunkBuffer; + std::vector _localChunkBuffer; std::vector _traversalMemory; From 5091fa7ddb98e556f605aec5f53d806ef7a1f2a5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 13 Aug 2020 17:50:22 +0200 Subject: [PATCH 10/59] Using a fixed number of chunktiles in the chunktilepile as they number has to be 1 or 3 --- include/openspace/util/memorymanager.h | 2 +- modules/globebrowsing/src/basictypes.h | 6 ++++- modules/globebrowsing/src/gpulayergroup.cpp | 6 ++++- modules/globebrowsing/src/layer.cpp | 10 +++++--- .../src/memoryawaretilecache.cpp | 2 ++ modules/globebrowsing/src/renderableglobe.cpp | 3 +-- modules/globebrowsing/src/tileprovider.cpp | 25 +++++++++++-------- 7 files changed, 34 insertions(+), 20 deletions(-) diff --git a/include/openspace/util/memorymanager.h b/include/openspace/util/memorymanager.h index 893574d527..f50eb525e5 100644 --- a/include/openspace/util/memorymanager.h +++ b/include/openspace/util/memorymanager.h @@ -38,7 +38,7 @@ public: // Memory pool. Resetting the monotoic_buffer_resource costs an allocation, that we // can prevent std::pmr::monotonic_buffer_resource TemporaryMemory = - std::pmr::monotonic_buffer_resource(4096); + std::pmr::monotonic_buffer_resource(100 * 4096); }; } // namespace openspace diff --git a/modules/globebrowsing/src/basictypes.h b/modules/globebrowsing/src/basictypes.h index 234a3eb542..049ce3d8ed 100644 --- a/modules/globebrowsing/src/basictypes.h +++ b/modules/globebrowsing/src/basictypes.h @@ -168,7 +168,11 @@ struct ChunkTile { -using ChunkTilePile = std::vector; +//using ChunkTilePile = std::vector; +// The ChunkTilePile either contains 1 or 3 ChunkTile, depending on if layer-blending is +// enabled. If it is enabled, we need the two adjacent levels, if it is not enabled, only +// the current layer is needed +using ChunkTilePile = std::array, 3>; } // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/src/gpulayergroup.cpp b/modules/globebrowsing/src/gpulayergroup.cpp index 5f7797bf1e..512727089d 100644 --- a/modules/globebrowsing/src/gpulayergroup.cpp +++ b/modules/globebrowsing/src/gpulayergroup.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include namespace openspace::globebrowsing { @@ -34,6 +35,8 @@ namespace openspace::globebrowsing { void GPULayerGroup::setValue(ghoul::opengl::ProgramObject& program, const LayerGroup& layerGroup, const TileIndex& tileIndex) { + ZoneScoped + ghoul_assert( layerGroup.activeLayers().size() == _gpuActiveLayers.size(), "GPU and CPU active layers must have same size!" @@ -76,7 +79,8 @@ void GPULayerGroup::setValue(ghoul::opengl::ProgramObject& program, ); for (size_t j = 0; j < _gpuActiveLayers[i].gpuChunkTiles.size(); ++j) { GPULayer::GPUChunkTile& t = _gpuActiveLayers[i].gpuChunkTiles[j]; - const ChunkTile& ct = ctp[j]; + ghoul_assert(ctp[j].has_value(), "Wrong ChunkTiles number in pile"); + const ChunkTile& ct = *ctp[j]; t.texUnit.activate(); if (ct.tile.texture) { diff --git a/modules/globebrowsing/src/layer.cpp b/modules/globebrowsing/src/layer.cpp index 2345258483..d4a049be46 100644 --- a/modules/globebrowsing/src/layer.cpp +++ b/modules/globebrowsing/src/layer.cpp @@ -386,16 +386,18 @@ void Layer::deinitialize() { } ChunkTilePile Layer::chunkTilePile(const TileIndex& tileIndex, int pileSize) const { + ZoneScoped + if (_tileProvider) { return tileprovider::chunkTilePile(*_tileProvider, tileIndex, pileSize); } else { ChunkTilePile chunkTilePile; - chunkTilePile.resize(pileSize); + std::fill(chunkTilePile.begin(), chunkTilePile.end(), std::nullopt); for (int i = 0; i < pileSize; ++i) { - chunkTilePile[i].tile = Tile(); - chunkTilePile[i].uvTransform.uvOffset = { 0, 0 }; - chunkTilePile[i].uvTransform.uvScale = { 1, 1 }; + chunkTilePile[i] = ChunkTile { + Tile(), TileUvTransform { { 0, 0 }, { 1, 1 } } + }; } return chunkTilePile; } diff --git a/modules/globebrowsing/src/memoryawaretilecache.cpp b/modules/globebrowsing/src/memoryawaretilecache.cpp index efc0175e56..b2d34f1ce4 100644 --- a/modules/globebrowsing/src/memoryawaretilecache.cpp +++ b/modules/globebrowsing/src/memoryawaretilecache.cpp @@ -376,6 +376,8 @@ bool MemoryAwareTileCache::exist(const ProviderTileKey& key) const { } Tile MemoryAwareTileCache::get(const ProviderTileKey& key) { + ZoneScoped + const TextureContainerMap::const_iterator it = std::find_if( _textureContainerMap.cbegin(), _textureContainerMap.cend(), diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index e12331f8ae..8a9a74298f 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -1283,11 +1283,10 @@ void RenderableGlobe::renderChunkGlobally(const Chunk& chunk, const RenderData& ZoneScoped TracyGpuZone("renderChunkGlobally") - //PerfMeasure("globally"); const TileIndex& tileIndex = chunk.tileIndex; ghoul::opengl::ProgramObject& program = *_globalRenderer.program; - const std::array& layerGroups = + std::array layerGroups = _layerManager.layerGroups(); for (size_t i = 0; i < layerGroups.size(); ++i) { _globalRenderer.gpuLayerGroups[i].setValue(program, *layerGroups[i], tileIndex); diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index f0ae0b93d5..eaed99936f 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -1436,22 +1436,25 @@ ChunkTilePile chunkTilePile(TileProvider& tp, TileIndex tileIndex, int pileSize) ghoul_assert(tp.isInitialized, "TileProvider was not initialized."); ghoul_assert(pileSize >= 0, "pileSize must be positive"); - ChunkTilePile chunkTilePile(pileSize); + ChunkTilePile chunkTilePile; + std::fill(chunkTilePile.begin(), chunkTilePile.end(), std::nullopt); for (int i = 0; i < pileSize; ++i) { chunkTilePile[i] = chunkTile(tp, tileIndex, i); - if (chunkTilePile[i].tile.status == Tile::Status::Unavailable) { - if (i > 0) { + if (chunkTilePile[i]->tile.status == Tile::Status::Unavailable) { + if (i == 0) { // First iteration - chunkTilePile[i].tile = chunkTilePile[i - 1].tile; - chunkTilePile[i].uvTransform.uvOffset = - chunkTilePile[i - 1].uvTransform.uvOffset; - chunkTilePile[i].uvTransform.uvScale = - chunkTilePile[i - 1].uvTransform.uvScale; + chunkTilePile[i]->tile = DefaultTile; + chunkTilePile[i]->uvTransform.uvOffset = { 0.f, 0.f }; + chunkTilePile[i]->uvTransform.uvScale = { 1.f, 1.f }; } else { - chunkTilePile[i].tile = DefaultTile; - chunkTilePile[i].uvTransform.uvOffset = { 0.f, 0.f }; - chunkTilePile[i].uvTransform.uvScale = { 1.f, 1.f }; + // We are iterating through the array one-by-one, so we are guaranteed + // that for tile 'i', tile 'i-1' already was initializated + chunkTilePile[i]->tile = chunkTilePile[i - 1]->tile; + chunkTilePile[i]->uvTransform.uvOffset = + chunkTilePile[i - 1]->uvTransform.uvOffset; + chunkTilePile[i]->uvTransform.uvScale = + chunkTilePile[i - 1]->uvTransform.uvScale; } } } From 97811d82d0356615608d22960fc40f7c5012a768 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 14 Aug 2020 14:10:54 +0200 Subject: [PATCH 11/59] Fix error with time quantizer string conversion Fix error with uninitialized memory in GlobeBrowsing Remove dynamic memory allocation from on-screen rendering --- include/openspace/rendering/renderengine.h | 2 + modules/base/dashboard/dashboarditemangle.cpp | 33 +++-- modules/base/dashboard/dashboarditemangle.h | 1 + modules/base/dashboard/dashboarditemdate.cpp | 5 + .../base/dashboard/dashboarditemdistance.cpp | 23 ++-- .../base/dashboard/dashboarditemdistance.h | 2 + .../base/dashboard/dashboarditemframerate.cpp | 79 ++++++----- .../base/dashboard/dashboarditemframerate.h | 1 + .../base/dashboard/dashboarditemmission.cpp | 5 + .../dashboarditemparallelconnection.cpp | 5 + .../dashboard/dashboarditempropertyvalue.cpp | 5 + .../dashboarditemsimulationincrement.cpp | 5 + .../base/dashboard/dashboarditemvelocity.cpp | 5 + .../src/dashboarditemglobelocation.cpp | 37 ++++-- .../src/dashboarditemglobelocation.h | 2 + modules/globebrowsing/src/lrucache.inl | 10 +- .../src/memoryawaretilecache.cpp | 3 +- modules/globebrowsing/src/renderableglobe.cpp | 26 +++- modules/globebrowsing/src/tileprovider.cpp | 1 - modules/globebrowsing/src/timequantizer.cpp | 12 +- .../dashboard/dashboarditeminstruments.cpp | 3 + src/rendering/dashboard.cpp | 3 + src/rendering/renderengine.cpp | 123 +++++++++--------- 23 files changed, 256 insertions(+), 135 deletions(-) diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 152f494e0c..233a166689 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -242,6 +242,8 @@ private: glm::ivec4 zoom = glm::ivec4(0); glm::ivec4 roll = glm::ivec4(0); } _cameraButtonLocations; + + std::string _versionString; }; } // namespace openspace diff --git a/modules/base/dashboard/dashboarditemangle.cpp b/modules/base/dashboard/dashboarditemangle.cpp index 12a0003a69..991afa4520 100644 --- a/modules/base/dashboard/dashboarditemangle.cpp +++ b/modules/base/dashboard/dashboarditemangle.cpp @@ -37,6 +37,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -352,6 +353,7 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary) addProperty(_destination.nodeName); _font = global::fontManager.font(_fontName, _fontSize); + _buffer.resize(128); } std::pair DashboardItemAngle::positionAndLabel( @@ -391,6 +393,8 @@ std::pair DashboardItemAngle::positionAndLabel( } void DashboardItemAngle::render(glm::vec2& penPosition) { + ZoneScoped + std::pair sourceInfo = positionAndLabel(_source); std::pair referenceInfo = positionAndLabel(_reference); std::pair destinationInfo = positionAndLabel(_destination); @@ -398,16 +402,16 @@ void DashboardItemAngle::render(glm::vec2& penPosition) { const glm::dvec3 a = referenceInfo.first - sourceInfo.first; const glm::dvec3 b = destinationInfo.first - sourceInfo.first; + std::fill(_buffer.begin(), _buffer.end(), 0); if (glm::length(a) == 0.0 || glm::length(b) == 0) { penPosition.y -= _font->height(); - RenderFont( - *_font, - penPosition, - fmt::format( - "Could not compute angle at {} between {} and {}", - sourceInfo.second, destinationInfo.second, referenceInfo.second - ) + char* end = fmt::format_to( + _buffer.data(), + "Could not compute angle at {} between {} and {}", + sourceInfo.second, destinationInfo.second, referenceInfo.second ); + std::string_view text = std::string_view(_buffer.data(), end - _buffer.data()); + RenderFont(*_font, penPosition, text); } else { const double angle = glm::degrees( @@ -415,18 +419,19 @@ void DashboardItemAngle::render(glm::vec2& penPosition) { ); penPosition.y -= _font->height(); - RenderFont( - *_font, - penPosition, - fmt::format( - "Angle at {} between {} and {}: {} degrees", - sourceInfo.second, destinationInfo.second, referenceInfo.second, angle - ) + char* end = fmt::format_to( + _buffer.data(), + "Angle at {} between {} and {}: {} degrees", + sourceInfo.second, destinationInfo.second, referenceInfo.second, angle ); + std::string_view text = std::string_view(_buffer.data(), end - _buffer.data()); + RenderFont(*_font, penPosition, text); } } glm::vec2 DashboardItemAngle::size() const { + ZoneScoped + constexpr const double Angle = 120; return _font->boundingBox("Angle: " + std::to_string(Angle)); diff --git a/modules/base/dashboard/dashboarditemangle.h b/modules/base/dashboard/dashboarditemangle.h index 21791cc63b..111f1a8a79 100644 --- a/modules/base/dashboard/dashboarditemangle.h +++ b/modules/base/dashboard/dashboarditemangle.h @@ -73,6 +73,7 @@ private: properties::StringProperty _fontName; properties::FloatProperty _fontSize; + std::vector _buffer; std::shared_ptr _font; }; diff --git a/modules/base/dashboard/dashboarditemdate.cpp b/modules/base/dashboard/dashboarditemdate.cpp index 4accac477f..b003e06882 100644 --- a/modules/base/dashboard/dashboarditemdate.cpp +++ b/modules/base/dashboard/dashboarditemdate.cpp @@ -31,6 +31,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -110,6 +111,8 @@ DashboardItemDate::DashboardItemDate(const ghoul::Dictionary& dictionary) } void DashboardItemDate::render(glm::vec2& penPosition) { + ZoneScoped + penPosition.y -= _font->height(); RenderFont( *_font, @@ -119,6 +122,8 @@ void DashboardItemDate::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemDate::size() const { + ZoneScoped + return _font->boundingBox( fmt::format("Date: {} UTC", global::timeManager.time().UTC()) ); diff --git a/modules/base/dashboard/dashboarditemdistance.cpp b/modules/base/dashboard/dashboarditemdistance.cpp index 92e1b74365..655e7881a8 100644 --- a/modules/base/dashboard/dashboarditemdistance.cpp +++ b/modules/base/dashboard/dashboarditemdistance.cpp @@ -38,6 +38,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -358,6 +359,8 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary addProperty(_requestedUnit); _font = global::fontManager.font(_fontName, _fontSize); + + _buffer.resize(256); } std::pair DashboardItemDistance::positionAndLabel( @@ -419,6 +422,8 @@ std::pair DashboardItemDistance::positionAndLabel( } void DashboardItemDistance::render(glm::vec2& penPosition) { + ZoneScoped + std::pair sourceInfo = positionAndLabel( _source, _destination @@ -440,18 +445,20 @@ void DashboardItemDistance::render(glm::vec2& penPosition) { } penPosition.y -= _font->height(); - - RenderFont( - *_font, - penPosition, - fmt::format( - "Distance from {} to {}: {:f} {}", - sourceInfo.second, destinationInfo.second, dist.first, dist.second - ) + std::fill(_buffer.begin(), _buffer.end(), 0); + char* end = fmt::format_to( + _buffer.data(), + "Distance from {} to {}: {:f} {}\0", + sourceInfo.second, destinationInfo.second, dist.first, dist.second ); + + std::string_view text = std::string_view(_buffer.data(), end - _buffer.data()); + RenderFont(*_font, penPosition, text); } glm::vec2 DashboardItemDistance::size() const { + ZoneScoped + const double d = glm::length(1e20); std::pair dist; if (_doSimplification) { diff --git a/modules/base/dashboard/dashboarditemdistance.h b/modules/base/dashboard/dashboarditemdistance.h index aab5098bfb..f66cd745c4 100644 --- a/modules/base/dashboard/dashboarditemdistance.h +++ b/modules/base/dashboard/dashboarditemdistance.h @@ -79,6 +79,8 @@ private: Component _source; Component _destination; + std::vector _buffer; + std::shared_ptr _font; }; diff --git a/modules/base/dashboard/dashboarditemframerate.cpp b/modules/base/dashboard/dashboarditemframerate.cpp index 7588c7a215..b72a4441b8 100644 --- a/modules/base/dashboard/dashboarditemframerate.cpp +++ b/modules/base/dashboard/dashboarditemframerate.cpp @@ -31,6 +31,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -70,17 +71,22 @@ namespace { constexpr const char* ValueFpsAvg = "Average frames per second"; constexpr const char* ValueNone = "None"; - std::string formatDt() { - return fmt::format( - "Avg. Frametime: {:.2f} ms", + [[ nodiscard ]] char* formatDt(std::vector& buffer) { + return fmt::format_to( + buffer.data(), + "Avg. Frametime: {:.2f} ms\0", openspace::global::windowDelegate.averageDeltaTime() * 1000.0 ); } - std::string formatDtExtremes(double minFrametimeCache, double maxFrametimeCache) { - return fmt::format( + [[ nodiscard ]] char* formatDtExtremes(std::vector& buffer, + double minFrametimeCache, + double maxFrametimeCache) + { + return fmt::format_to( + buffer.data(), "Last frametimes between: {:.2f} and {:.2f} ms\n" - "Overall between: {:.2f} and {:.2f} ms", + "Overall between: {:.2f} and {:.2f} ms\0", openspace::global::windowDelegate.minDeltaTime() * 1000.0, openspace::global::windowDelegate.maxDeltaTime() * 1000.0, minFrametimeCache, @@ -88,54 +94,59 @@ namespace { ); } - std::string formatDtStandardDeviation() { - return fmt::format( - "Frametime standard deviation : {:.2f} ms", + [[ nodiscard ]] char* formatDtStandardDeviation(std::vector& buffer) { + return fmt::format_to( + buffer.data(), + "Frametime standard deviation : {:.2f} ms\0", openspace::global::windowDelegate.deltaTimeStandardDeviation() * 1000.0 ); } - std::string formatDtCoefficientOfVariation() { - return fmt::format( - "Frametime coefficient of variation : {:.2f} %", + [[ nodiscard ]] char* formatDtCoefficientOfVariation(std::vector& buffer) { + return fmt::format_to( + buffer.data(), + "Frametime coefficient of variation : {:.2f} %\0", openspace::global::windowDelegate.deltaTimeStandardDeviation() / openspace::global::windowDelegate.averageDeltaTime() * 100.0 ); } - std::string formatFps() { - return fmt::format( - "FPS: {:3.2f}", + [[ nodiscard ]] char* formatFps(std::vector& buffer) { + return fmt::format_to( + buffer.data(), + "FPS: {:3.2f}\0", 1.0 / openspace::global::windowDelegate.deltaTime() ); } - std::string formatAverageFps() { - return fmt::format( - "Avg. FPS: {:3.2f}", + [[ nodiscard ]] char* formatAverageFps(std::vector& buffer) { + return fmt::format_to( + buffer.data(), + "Avg. FPS: {:3.2f}\0", 1.0 / openspace::global::windowDelegate.averageDeltaTime() ); } - std::string format(openspace::DashboardItemFramerate::FrametimeType frametimeType, - double minFrametimeCache, double maxFrametimeCache) + [[ nodiscard ]] char* format(std::vector& buffer, + openspace::DashboardItemFramerate::FrametimeType frametimeType, + double minFrametimeCache, double maxFrametimeCache) { using namespace openspace; switch (frametimeType) { case DashboardItemFramerate::FrametimeType::DtTimeAvg: - return formatDt(); + return formatDt(buffer); case DashboardItemFramerate::FrametimeType::DtTimeExtremes: - return formatDtExtremes(minFrametimeCache, maxFrametimeCache); + return formatDtExtremes(buffer, minFrametimeCache, maxFrametimeCache); case DashboardItemFramerate::FrametimeType::DtStandardDeviation: - return formatDtStandardDeviation(); + return formatDtStandardDeviation(buffer); case DashboardItemFramerate::FrametimeType::DtCoefficientOfVariation: - return formatDtCoefficientOfVariation(); + return formatDtCoefficientOfVariation(buffer); case DashboardItemFramerate::FrametimeType::FPS: - return formatFps(); + return formatFps(buffer); case DashboardItemFramerate::FrametimeType::FPSAvg: - return formatAverageFps(); + return formatAverageFps(buffer); default: - return ""; + throw ghoul::MissingCaseException(); } } } // namespace @@ -262,9 +273,13 @@ DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictiona addProperty(_clearCache); _font = global::fontManager.font(_fontName, _fontSize); + + _buffer.resize(128); } void DashboardItemFramerate::render(glm::vec2& penPosition) { + ZoneScoped + if (_shouldClearCache) { _minDeltaTimeCache = 1.0; _maxDeltaTimeCache = -1.0; @@ -282,11 +297,14 @@ void DashboardItemFramerate::render(glm::vec2& penPosition) { FrametimeType frametimeType = FrametimeType(_frametimeType.value()); - const std::string output = format( + std::fill(_buffer.begin(), _buffer.end(), 0); + char* end = format( + _buffer, frametimeType, _minDeltaTimeCache, _maxDeltaTimeCache ); + std::string_view output = std::string_view(_buffer.data(), end - _buffer.data()); int nLines = output.empty() ? 0 : static_cast((std::count(output.begin(), output.end(), '\n') + 1)); @@ -301,8 +319,11 @@ void DashboardItemFramerate::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemFramerate::size() const { + ZoneScoped + const FrametimeType t = FrametimeType(_frametimeType.value()); - const std::string output = format(t, _minDeltaTimeCache, _maxDeltaTimeCache); + format(_buffer, t, _minDeltaTimeCache, _maxDeltaTimeCache); + std::string_view output = _buffer.data(); if (output.empty()) { return { 0.f, 0.f }; diff --git a/modules/base/dashboard/dashboarditemframerate.h b/modules/base/dashboard/dashboarditemframerate.h index 2b1b8c2de9..8fc952f537 100644 --- a/modules/base/dashboard/dashboarditemframerate.h +++ b/modules/base/dashboard/dashboarditemframerate.h @@ -68,6 +68,7 @@ private: double _minDeltaTimeCache = 1.0; double _maxDeltaTimeCache = -1.0; bool _shouldClearCache = true; + mutable std::vector _buffer; }; } // openspace diff --git a/modules/base/dashboard/dashboarditemmission.cpp b/modules/base/dashboard/dashboarditemmission.cpp index 8fc99bb908..eb65bc8651 100644 --- a/modules/base/dashboard/dashboarditemmission.cpp +++ b/modules/base/dashboard/dashboarditemmission.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace { @@ -129,6 +130,8 @@ DashboardItemMission::DashboardItemMission(const ghoul::Dictionary& dictionary) } void DashboardItemMission::render(glm::vec2& penPosition) { + ZoneScoped + if (!global::missionManager.hasCurrentMission()) { return; } @@ -245,6 +248,8 @@ void DashboardItemMission::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemMission::size() const { + ZoneScoped + // @TODO fix this up ---abock return { 0.f, 0.f }; } diff --git a/modules/base/dashboard/dashboarditemparallelconnection.cpp b/modules/base/dashboard/dashboarditemparallelconnection.cpp index 30911be306..54a2642387 100644 --- a/modules/base/dashboard/dashboarditemparallelconnection.cpp +++ b/modules/base/dashboard/dashboarditemparallelconnection.cpp @@ -34,6 +34,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -114,6 +115,8 @@ DashboardItemParallelConnection::DashboardItemParallelConnection( } void DashboardItemParallelConnection::render(glm::vec2& penPosition) { + ZoneScoped + const ParallelConnection::Status status = global::parallelPeer.status(); const size_t nConnections = global::parallelPeer.nConnections(); const std::string& hostName = global::parallelPeer.hostName(); @@ -164,6 +167,8 @@ void DashboardItemParallelConnection::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemParallelConnection::size() const { + ZoneScoped + ParallelConnection::Status status = global::parallelPeer.status(); size_t nConnections = global::parallelPeer.nConnections(); const std::string& hostName = global::parallelPeer.hostName(); diff --git a/modules/base/dashboard/dashboarditempropertyvalue.cpp b/modules/base/dashboard/dashboarditempropertyvalue.cpp index c884458d7d..d388e379fb 100644 --- a/modules/base/dashboard/dashboarditempropertyvalue.cpp +++ b/modules/base/dashboard/dashboarditempropertyvalue.cpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -151,6 +152,8 @@ DashboardItemPropertyValue::DashboardItemPropertyValue( } void DashboardItemPropertyValue::render(glm::vec2& penPosition) { + ZoneScoped + if (_propertyIsDirty) { _property = openspace::property(_propertyUri); _propertyIsDirty = false; @@ -166,6 +169,8 @@ void DashboardItemPropertyValue::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemPropertyValue::size() const { + ZoneScoped + return _font->boundingBox(_displayString.value()); } diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.cpp b/modules/base/dashboard/dashboarditemsimulationincrement.cpp index 11c310943c..def2b6f9e1 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.cpp +++ b/modules/base/dashboard/dashboarditemsimulationincrement.cpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -176,6 +177,8 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement( } void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { + ZoneScoped + const double targetDt = global::timeManager.targetDeltaTime(); const double currentDt = global::timeManager.deltaTime(); std::pair targetDeltaTime; @@ -227,6 +230,8 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemSimulationIncrement::size() const { + ZoneScoped + double t = global::timeManager.targetDeltaTime(); std::pair deltaTime; if (_doSimplification) { diff --git a/modules/base/dashboard/dashboarditemvelocity.cpp b/modules/base/dashboard/dashboarditemvelocity.cpp index 12952fb0bb..e89fedb6be 100644 --- a/modules/base/dashboard/dashboarditemvelocity.cpp +++ b/modules/base/dashboard/dashboarditemvelocity.cpp @@ -38,6 +38,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -187,6 +188,8 @@ DashboardItemVelocity::DashboardItemVelocity(const ghoul::Dictionary& dictionary } void DashboardItemVelocity::render(glm::vec2& penPosition) { + ZoneScoped + const glm::dvec3 currentPos = global::renderEngine.scene()->camera()->positionVec3(); const glm::dvec3 dt = currentPos - _prevPosition; const double speedPerFrame = glm::length(dt); @@ -218,6 +221,8 @@ void DashboardItemVelocity::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemVelocity::size() const { + ZoneScoped + const double d = glm::length(1e20); std::pair dist; if (_doSimplification) { diff --git a/modules/globebrowsing/src/dashboarditemglobelocation.cpp b/modules/globebrowsing/src/dashboarditemglobelocation.cpp index 4bac59a59f..d23f1cf868 100644 --- a/modules/globebrowsing/src/dashboarditemglobelocation.cpp +++ b/modules/globebrowsing/src/dashboarditemglobelocation.cpp @@ -37,6 +37,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -135,12 +136,25 @@ DashboardItemGlobeLocation::DashboardItemGlobeLocation( }); addProperty(_fontSize); + auto updateFormatString = [this]() { + using namespace fmt::literals; + + _formatString = + "Position: {{:03.{0}f}}{{}}, {{:03.{0}f}}{{}} Altitude: {{}} {{}}"_format( + _significantDigits.value() + ); + }; + _significantDigits.onChange(updateFormatString); addProperty(_significantDigits); + updateFormatString(); _font = global::fontManager.font(_fontName, _fontSize); + _buffer.resize(128); } void DashboardItemGlobeLocation::render(glm::vec2& penPosition) { + ZoneScoped + using namespace globebrowsing; const SceneGraphNode* n = global::navigationHandler.orbitalNavigator().anchorNode(); @@ -186,19 +200,22 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) { std::pair dist = simplifyDistance(altitude); penPosition.y -= _font->height(); - std::string d = std::to_string(_significantDigits); - std::string f = "Position: {:03." + d + "f}{}, {:03." + d + "f}{} Altitude: {} {}"; - RenderFont( - *_font, - penPosition, - fmt::format(f, - lat, isNorth ? "N" : "S", - lon, isEast ? "E" : "W", - dist.first, dist.second - ) + + std::fill(_buffer.begin(), _buffer.end(), 0); + char* end = fmt::format_to( + _buffer.data(), + _formatString.c_str(), + lat, isNorth ? "N" : "S", + lon, isEast ? "E" : "W", + dist.first, dist.second ); + std::string_view text = std::string_view(_buffer.data(), end - _buffer.data()); + + RenderFont(*_font, penPosition, text); } glm::vec2 DashboardItemGlobeLocation::size() const { + ZoneScoped + return _font->boundingBox( fmt::format("Position: {}, {} Altitude: {}", 1.f, 1.f, 1.f) ); diff --git a/modules/globebrowsing/src/dashboarditemglobelocation.h b/modules/globebrowsing/src/dashboarditemglobelocation.h index 12c6f6fc84..47f8cafce3 100644 --- a/modules/globebrowsing/src/dashboarditemglobelocation.h +++ b/modules/globebrowsing/src/dashboarditemglobelocation.h @@ -55,6 +55,8 @@ private: properties::IntProperty _significantDigits; std::shared_ptr _font; + std::string _formatString; + std::vector _buffer; }; } // namespace openspace diff --git a/modules/globebrowsing/src/lrucache.inl b/modules/globebrowsing/src/lrucache.inl index 1ee02b4e1a..5144250b6d 100644 --- a/modules/globebrowsing/src/lrucache.inl +++ b/modules/globebrowsing/src/lrucache.inl @@ -59,8 +59,16 @@ bool LRUCache::exist(const KeyType& key) const { template bool LRUCache::touch(const KeyType& key) { + ZoneScoped + const auto it = _itemMap.find(key); - if (it != _itemMap.end()) { // Found in cache + if (it != _itemMap.end()) { + // @TODO (abock, 2020-08-14) Instead of removing the iterator from the previous + // position and then readding it at the front, it might make more sense to move + // them around? That would prevent the dynamic memoray allocation that is + // happening here + + // Found in cache ValueType value = it->second->second; // Remove from current position _itemList.erase(it->second); diff --git a/modules/globebrowsing/src/memoryawaretilecache.cpp b/modules/globebrowsing/src/memoryawaretilecache.cpp index b2d34f1ce4..c6106137b1 100644 --- a/modules/globebrowsing/src/memoryawaretilecache.cpp +++ b/modules/globebrowsing/src/memoryawaretilecache.cpp @@ -395,8 +395,7 @@ Tile MemoryAwareTileCache::get(const ProviderTileKey& key) { } } -ghoul::opengl::Texture* MemoryAwareTileCache::texture( - const TileTextureInitData& initData) +ghoul::opengl::Texture* MemoryAwareTileCache::texture(const TileTextureInitData& initData) { // if this texture type does not exist among the texture containers // it needs to be created diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 8a9a74298f..4cf67df702 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -615,9 +615,9 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) addPropertySubOwner(_debugPropertyOwner); addPropertySubOwner(_layerManager); - _globalChunkBuffer.reserve(2048); - _localChunkBuffer.reserve(2048); - _traversalMemory.reserve(512); + _globalChunkBuffer.resize(2048); + _localChunkBuffer.resize(2048); + _traversalMemory.resize(512); //================================================================ //======== Reads Shadow (Eclipses) Entries in mod file =========== @@ -1214,8 +1214,24 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, } }; - traversal(_leftRoot, _globalChunkBuffer, globalCount, _localChunkBuffer, localCount, _debugProperties.modelSpaceRenderingCutoffLevel, _traversalMemory); - traversal(_rightRoot, _globalChunkBuffer, globalCount, _localChunkBuffer, localCount, _debugProperties.modelSpaceRenderingCutoffLevel, _traversalMemory); + traversal( + _leftRoot, + _globalChunkBuffer, + globalCount, + _localChunkBuffer, + localCount, + _debugProperties.modelSpaceRenderingCutoffLevel, + _traversalMemory + ); + traversal( + _rightRoot, + _globalChunkBuffer, + globalCount, + _localChunkBuffer, + localCount, + _debugProperties.modelSpaceRenderingCutoffLevel, + _traversalMemory + ); // Render all chunks that want to be rendered globally _globalRenderer.program->activate(); diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index eaed99936f..1b7686a322 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -924,7 +924,6 @@ Tile tile(TileProvider& tp, const TileIndex& tileIndex) { } const cache::ProviderTileKey key = { tileIndex, t.uniqueIdentifier }; Tile tile = t.tileCache->get(key); - if (!tile.texture) { //TracyMessage("Enqueuing tile", 32); t.asyncTextureDataProvider->enqueueTileIO(tileIndex); diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index 080af9b3b9..707c7f850e 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -158,12 +158,12 @@ void DateTime::setTime(std::string_view input) { constexpr const size_t IndexMinute = 14; constexpr const size_t IndexSecond = 17; - std::from_chars(input.data() + IndexYear, input.data() + 4, _year); - std::from_chars(input.data() + IndexMonth, input.data() + 2, _month); - std::from_chars(input.data() + IndexDay, input.data() + 2, _day); - std::from_chars(input.data() + IndexHour, input.data() + 2, _hour); - std::from_chars(input.data() + IndexMinute, input.data() + 2, _minute); - std::from_chars(input.data() + IndexSecond, input.data() + 2, _second); + std::from_chars(input.data() + IndexYear, input.data() + IndexYear + 4, _year); + std::from_chars(input.data() + IndexMonth, input.data() + IndexMonth + 2, _month); + std::from_chars(input.data() + IndexDay, input.data() + IndexDay + 2, _day); + std::from_chars(input.data() + IndexHour, input.data() + IndexHour + 2, _hour); + std::from_chars(input.data() + IndexMinute, input.data() + IndexMinute + 2, _minute); + std::from_chars(input.data() + IndexSecond, input.data() + IndexSecond + 2, _second); } std::string DateTime::ISO8601() const { diff --git a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp index 84eda4956f..7e6e05b87d 100644 --- a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp +++ b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include namespace { @@ -178,6 +179,8 @@ DashboardItemInstruments::DashboardItemInstruments(const ghoul::Dictionary& dict } void DashboardItemInstruments::render(glm::vec2& penPosition) { + ZoneScoped + double currentTime = global::timeManager.time().j2000Seconds(); if (!ImageSequencer::ref().isReady()) { diff --git a/src/rendering/dashboard.cpp b/src/rendering/dashboard.cpp index 77bc5162eb..c700326cbc 100644 --- a/src/rendering/dashboard.cpp +++ b/src/rendering/dashboard.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "dashboard_lua.inl" @@ -127,6 +128,8 @@ void Dashboard::clearDashboardItems() { } void Dashboard::render(glm::vec2& penPosition) { + ZoneScoped + if (!_isEnabled) { return; } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 08dd69ed3f..c952a43ebd 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -446,6 +447,22 @@ void RenderEngine::initialize() { ghoul::io::TextureReader::ref().addReader( std::make_unique() ); + + _versionString = OPENSPACE_VERSION_STRING_FULL; + if (global::versionChecker.hasLatestVersionInfo()) { + VersionChecker::SemanticVersion latest = global::versionChecker.latestVersion(); + + VersionChecker::SemanticVersion current{ + OPENSPACE_VERSION_MAJOR, + OPENSPACE_VERSION_MINOR, + OPENSPACE_VERSION_PATCH +}; + if (current < latest) { + _versionString += fmt::format( + " [Available: {}.{}.{}]", latest.major, latest.minor, latest.patch + ); + } + } } void RenderEngine::initializeGL() { @@ -1305,31 +1322,9 @@ void RenderEngine::renderVersionInformation() { return; } - std::string versionString = OPENSPACE_VERSION_STRING_FULL; - - if (global::versionChecker.hasLatestVersionInfo()) { - VersionChecker::SemanticVersion latestVersion = - global::versionChecker.latestVersion(); - - VersionChecker::SemanticVersion currentVersion { - OPENSPACE_VERSION_MAJOR, - OPENSPACE_VERSION_MINOR, - OPENSPACE_VERSION_PATCH - }; - if (currentVersion < latestVersion) { - versionString += fmt::format( - " [Available: {}.{}.{}]", - latestVersion.major, latestVersion.minor, latestVersion.patch - ); - } - } - using FR = ghoul::fontrendering::FontRenderer; - const glm::vec2 versionBox = _fontInfo->boundingBox(versionString); - - const glm::vec2 commitBox = _fontInfo->boundingBox( - fmt::format("{}@{}", OPENSPACE_GIT_BRANCH, OPENSPACE_GIT_COMMIT) - ); + const glm::vec2 versionBox = _fontInfo->boundingBox(_versionString); + const glm::vec2 commitBox = _fontInfo->boundingBox(OPENSPACE_GIT_FULL); FR::defaultRenderer().render( *_fontInfo, @@ -1337,13 +1332,13 @@ void RenderEngine::renderVersionInformation() { fontResolution().x - versionBox.x - 10.f, 5.f ), - versionString, + _versionString, glm::vec4(0.5, 0.5, 0.5, 1.f) ); // If a developer hasn't placed the Git command in the path, this variable will be // empty - if (!std::string(OPENSPACE_GIT_COMMIT).empty()) { + if (!std::string_view(OPENSPACE_GIT_COMMIT).empty()) { // We check OPENSPACE_GIT_COMMIT but puse OPENSPACE_GIT_FULL on purpose since // OPENSPACE_GIT_FULL will never be empty (always will contain at least @, but // checking for that is a bit brittle) @@ -1381,9 +1376,9 @@ void RenderEngine::renderScreenLog() { size_t nr = 1; const auto now = std::chrono::steady_clock::now(); for (auto& it = lastEntries.first; it != lastEntries.second; ++it) { - const ScreenLog::LogEntry* e = &(*it); + ZoneScopedN("Entry") - std::chrono::duration diff = now - e->timeStamp; + std::chrono::duration diff = now - it->timeStamp; float alpha = 1.f; std::chrono::duration ttf = ScreenLogTimeToLive - FadeTime; @@ -1398,32 +1393,37 @@ void RenderEngine::renderScreenLog() { if (alpha <= 0.f) { break; } - const std::string_view lvl = ghoul::to_string(e->level); - const std::string_view message = - std::string_view(e->message).substr(0, MessageLength); + std::string_view message = std::string_view(it->message).substr(0, MessageLength); nr += std::count(message.begin(), message.end(), '\n'); const glm::vec4 white(0.9f, 0.9f, 0.9f, alpha); - std::string str = fmt::format( - "{:<15} {}{}", - e->timeString, - e->category.substr(0, CategoryLength), - e->category.length() > CategoryLength ? "..." : "" - ); + std::array buf; + { + std::fill(buf.begin(), buf.end(), 0); + char* end = fmt::format_to( + buf.data(), + "{:<15} {}{}", + it->timeString, + std::string_view(it->category).substr(0, CategoryLength), + it->category.length() > CategoryLength ? "..." : "" + ); + std::string_view text = std::string_view(buf.data(), end - buf.data()); - RenderFont( - *_fontLog, - glm::vec2( - 10.f, - _fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset - ), - str, - white - ); + RenderFont( + *_fontLog, + glm::vec2( + 10.f, + _fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset + ), + text, + white + ); + } - const glm::vec4 color = [alpha, white](ScreenLog::LogLevel level) { - switch (level) { + { + const glm::vec4 color = [alpha, white](ScreenLog::LogLevel level) { + switch (level) { case ghoul::logging::LogLevel::Debug: return glm::vec4(0.f, 1.f, 0.f, alpha); case ghoul::logging::LogLevel::Warning: @@ -1434,18 +1434,23 @@ void RenderEngine::renderScreenLog() { return glm::vec4(0.3f, 0.3f, 0.85f, alpha); default: return white; - } - }(e->level); + } + }(it->level); - RenderFont( - *_fontLog, - glm::vec2( - 10 + 30 * _fontLog->pointSize(), - _fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset - ), - fmt::format("({})", lvl), - color - ); + const std::string_view lvl = ghoul::to_string(it->level); + std::fill(buf.begin(), buf.end(), 0); + char* end = fmt::format_to(buf.data(), "({})", lvl); + std::string_view levelText = std::string_view(buf.data(), end - buf.data()); + RenderFont( + *_fontLog, + glm::vec2( + 10 + 30 * _fontLog->pointSize(), + _fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset + ), + levelText, + color + ); + } RenderFont( *_fontLog, From df803af68ac33832225804df18c051b9294492ea Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 00:19:01 +0200 Subject: [PATCH 12/59] Replace request and requestAll with require and requireAll --- data/assets/base.asset | 10 ++-- .../dwarf_planets/pluto/charon/charon.asset | 2 +- .../dwarf_planets/pluto/pluto.asset | 2 +- .../dwarf_planets/pluto/system.asset | 18 +++---- .../missions/osirisrex/osirisrex.asset | 8 ++-- .../solarsystem/planets/earth/earth.asset | 2 +- .../solarsystem/planets/earth/moon/moon.asset | 2 +- .../earth/satellites/satellites_all.asset | 14 +++--- .../satellites_communications.asset | 26 +++++----- .../earth/satellites/satellites_debris.asset | 10 ++-- .../earth/satellites/satellites_misc.asset | 8 ++-- .../satellites/satellites_navigation.asset | 14 +++--- .../earth/satellites/satellites_science.asset | 8 ++-- .../earth/satellites/satellites_weather.asset | 20 ++++---- .../planets/jupiter/callisto/callisto.asset | 2 +- .../planets/jupiter/europa/europa.asset | 2 +- .../planets/jupiter/ganymede/ganymede.asset | 2 +- .../solarsystem/planets/jupiter/io/io.asset | 2 +- .../solarsystem/planets/jupiter/jupiter.asset | 2 +- .../planets/jupiter/minor_moons.asset | 16 +++---- .../scene/solarsystem/planets/mars/mars.asset | 2 +- .../solarsystem/planets/mercury/mercury.asset | 2 +- .../planets/neptune/major_moons.asset | 2 +- .../solarsystem/planets/neptune/neptune.asset | 2 +- .../scene/solarsystem/planets/planets.asset | 34 ++++++------- .../planets/saturn/dione/dione.asset | 2 +- .../planets/saturn/enceladus/enceladus.asset | 2 +- .../planets/saturn/hyperion/hyperion.asset | 2 +- .../planets/saturn/iapetus/iapetus.asset | 2 +- .../planets/saturn/major_moons.asset | 16 +++---- .../planets/saturn/mimas/mimas.asset | 2 +- .../planets/saturn/minor_moons.asset | 8 ++-- .../planets/saturn/rhea/rhea.asset | 2 +- .../solarsystem/planets/saturn/saturn.asset | 2 +- .../planets/saturn/tethys/tethys.asset | 2 +- .../planets/saturn/titan/titan.asset | 2 +- .../planets/uranus/minor_moons.asset | 6 +-- .../solarsystem/planets/uranus/uranus.asset | 2 +- .../solarsystem/planets/venus/venus.asset | 2 +- data/assets/scene/solarsystem/sun.asset | 4 +- data/assets/sync/everything.asset | 8 ++-- data/assets/util/asset_helper.asset | 16 ------- data/assets/util/vrt_flipbook_helper.asset | 48 +++++++++---------- 43 files changed, 162 insertions(+), 178 deletions(-) diff --git a/data/assets/base.asset b/data/assets/base.asset index 6646492c9b..86bdf3cbd6 100644 --- a/data/assets/base.asset +++ b/data/assets/base.asset @@ -19,11 +19,11 @@ asset.require('scene/solarsystem/planets/mars/moons/deimos') asset.require('scene/solarsystem/dwarf_planets/pluto/system') asset.require('scene/solarsystem/dwarf_planets/pluto/default_layers') asset.require('scene/solarsystem/dwarf_planets/pluto/charon/default_layers') -asset.request('scene/milkyway/milkyway/volume') -asset.request('scene/milkyway/constellations/constellation_art') -asset.request('scene/milkyway/constellations/constellation_keybinds') +asset.require('scene/milkyway/milkyway/volume') +asset.require('scene/milkyway/constellations/constellation_art') +asset.require('scene/milkyway/constellations/constellation_keybinds') -assetHelper.requestAll(asset, 'scene/digitaluniverse') +assetHelper.requireAll(asset, 'scene/digitaluniverse') -- Load default key bindings applicable to most scenes asset.require('util/default_keybindings') @@ -33,7 +33,7 @@ asset.require('util/default_joystick') -- Load web gui local webGui = asset.require('util/webgui') -asset.request('customization/globebrowsing') +asset.require('customization/globebrowsing') -- Keybindings that are specific for this scene local Keybindings = { diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/charon/charon.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/charon/charon.asset index 1ee6157510..b9a30df0b5 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/charon/charon.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/charon/charon.asset @@ -1,7 +1,7 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./../transforms') asset.require("spice/base") -asset.request('./../trail') +asset.require('../trail') local labelsPath = asset.require('./../pluto_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset index c90da31679..ceb9a72424 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset @@ -1,7 +1,7 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local labelsPath = asset.require('./pluto_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/system.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/system.asset index e649a45a58..c6497de839 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/system.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/system.asset @@ -1,10 +1,10 @@ -asset.request('./trail') -asset.request('./pluto') -asset.request('./pluto_trail') -asset.request('./charon/charon') -asset.request('./charon/charon_trail') -asset.request('./minor/hydra') -asset.request('./minor/kerberos') -asset.request('./minor/nix') -asset.request('./minor/styx') +asset.require('./trail') +asset.require('./pluto') +asset.require('./pluto_trail') +asset.require('./charon/charon') +asset.require('./charon/charon_trail') +asset.require('./minor/hydra') +asset.require('./minor/kerberos') +asset.require('./minor/nix') +asset.require('./minor/styx') diff --git a/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset b/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset index ed12d60ba9..9877ef9694 100644 --- a/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset +++ b/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset @@ -1,7 +1,7 @@ -asset.request('./bennu') -asset.request('./model') -asset.request('./trail') -asset.request('scene/solarsystem/sun/marker') +asset.require('./bennu') +asset.require('./model') +asset.require('./trail') +asset.require('scene/solarsystem/sun/marker') asset.require('./script_schedule') diff --git a/data/assets/scene/solarsystem/planets/earth/earth.asset b/data/assets/scene/solarsystem/planets/earth/earth.asset index c281713453..be78f5c522 100644 --- a/data/assets/scene/solarsystem/planets/earth/earth.asset +++ b/data/assets/scene/solarsystem/planets/earth/earth.asset @@ -2,7 +2,7 @@ local transforms = asset.require('./transforms') local assetHelper = asset.require('util/asset_helper') local labelsPath = asset.require('./earth_globelabels').LabelsPath -asset.request('./trail') +asset.require('./trail') -- local earthEllipsoid = { 6378137.0, 6378137.0, 6356752.314245 } local earthEllipsoid = { 6378137.0, 6378137.0, 6378137.0 } diff --git a/data/assets/scene/solarsystem/planets/earth/moon/moon.asset b/data/assets/scene/solarsystem/planets/earth/moon/moon.asset index 16e67dd16b..3859cf2b28 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/moon.asset +++ b/data/assets/scene/solarsystem/planets/earth/moon/moon.asset @@ -3,7 +3,7 @@ local transforms = asset.require('scene/solarsystem/planets/earth/transforms') local sunAsset = asset.require('scene/solarsystem/sun/sun') local earthAsset = asset.require('../earth') asset.require('spice/base') -asset.request('./trail') +asset.require('./trail') local labelsPath = asset.require('./moon_labels').LabelsPath local Moon = { diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_all.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_all.asset index cb663ed946..312d2f2cfb 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_all.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_all.asset @@ -1,8 +1,8 @@ -asset.request('./satellites_communications') +asset.require('./satellites_communications') -- The debris contains a **lot** of nodes, so we disable it on default --- asset.request('./satellites_debris') -asset.request('./satellites_interesting') -asset.request('./satellites_misc') -asset.request('./satellites_navigation') -asset.request('./satellites_science') -asset.request('./satellites_weather') +-- asset.require('./satellites_debris') +asset.require('./satellites_interesting') +asset.require('./satellites_misc') +asset.require('./satellites_navigation') +asset.require('./satellites_science') +asset.require('./satellites_weather') diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_communications.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_communications.asset index 78080e6557..872322c03c 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_communications.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_communications.asset @@ -1,13 +1,13 @@ -asset.request('./communications/geostationary') -asset.request('./communications/intelsat') -asset.request('./communications/ses') -asset.request('./communications/iridium') -asset.request('./communications/iridium_next') -asset.request('./communications/orbcomm') -asset.request('./communications/globalstar') -asset.request('./communications/amateur') -asset.request('./communications/experimental') -asset.request('./communications/other_comm') -asset.request('./communications/gorizont') -asset.request('./communications/raduga') -asset.request('./communications/molniya') +asset.require('./communications/geostationary') +asset.require('./communications/intelsat') +asset.require('./communications/ses') +asset.require('./communications/iridium') +asset.require('./communications/iridium_next') +asset.require('./communications/orbcomm') +asset.require('./communications/globalstar') +asset.require('./communications/amateur') +asset.require('./communications/experimental') +asset.require('./communications/other_comm') +asset.require('./communications/gorizont') +asset.require('./communications/raduga') +asset.require('./communications/molniya') diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_debris.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_debris.asset index 36806c5eb0..03feae1272 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_debris.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_debris.asset @@ -1,5 +1,5 @@ -asset.request('./debris/debris_asat') -asset.request('./debris/debris_breezem') -asset.request('./debris/debris_fengyun') -asset.request('./debris/debris_iridium33') -asset.request('./debris/debris_kosmos2251') +asset.require('./debris/debris_asat') +asset.require('./debris/debris_breezem') +asset.require('./debris/debris_fengyun') +asset.require('./debris/debris_iridium33') +asset.require('./debris/debris_kosmos2251') diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_misc.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_misc.asset index 117ad486e8..bd4c0d88b9 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_misc.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_misc.asset @@ -1,4 +1,4 @@ -asset.request('./misc/military') -asset.request('./misc/radar') -asset.request('./misc/cubesats') -asset.request('./misc/other') +asset.require('./misc/military') +asset.require('./misc/radar') +asset.require('./misc/cubesats') +asset.require('./misc/other') diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_navigation.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_navigation.asset index 2707ea06b4..6765ad4118 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_navigation.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_navigation.asset @@ -1,7 +1,7 @@ -asset.request('./navigation/beidou') -asset.request('./navigation/galileo') -asset.request('./navigation/glosnass') -asset.request('./navigation/gps') -asset.request('./navigation/musson') -asset.request('./navigation/nnss') -asset.request('./navigation/sbas') +asset.require('./navigation/beidou') +asset.require('./navigation/galileo') +asset.require('./navigation/glosnass') +asset.require('./navigation/gps') +asset.require('./navigation/musson') +asset.require('./navigation/nnss') +asset.require('./navigation/sbas') diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_science.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_science.asset index 8e8d0a3e0f..cb1ecee8e3 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_science.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_science.asset @@ -1,4 +1,4 @@ -asset.request('./science/spaceearth') -asset.request('./science/geodetic') -asset.request('./science/engineering') -asset.request('./science/education') +asset.require('./science/spaceearth') +asset.require('./science/geodetic') +asset.require('./science/engineering') +asset.require('./science/education') diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_weather.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_weather.asset index c464cb4a6f..fe272e6816 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_weather.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_weather.asset @@ -1,10 +1,10 @@ -asset.request('./weather/argos') -asset.request('./weather/dmc') -asset.request('./weather/earth_resources') -asset.request('./weather/goes') -asset.request('./weather/noaa') -asset.request('./weather/planet') -asset.request('./weather/sarsat') -asset.request('./weather/spire') -asset.request('./weather/tdrss') -asset.request('./weather/weather') +asset.require('./weather/argos') +asset.require('./weather/dmc') +asset.require('./weather/earth_resources') +asset.require('./weather/goes') +asset.require('./weather/noaa') +asset.require('./weather/planet') +asset.require('./weather/sarsat') +asset.require('./weather/spire') +asset.require('./weather/tdrss') +asset.require('./weather/weather') diff --git a/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset b/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset index 5b7208bf01..cf1828b9de 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local kernel = asset.require('../kernels').jup310 local labelsPath = asset.require('../jupiter_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset b/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset index 626cb52977..8e296655a5 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local kernel = asset.require('../kernels').jup310 local labelsPath = asset.require('../jupiter_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset b/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset index dc4f65f7cf..530745e4b7 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local kernel = asset.require('../kernels').jup310 local labelsPath = asset.require('../jupiter_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/jupiter/io/io.asset b/data/assets/scene/solarsystem/planets/jupiter/io/io.asset index 0c4af55b78..55ecb7a35b 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/io/io.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/io/io.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local kernel = asset.require('../kernels').jup310 local labelsPath = asset.require('../jupiter_globelabels').LabelsPath diff --git a/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset b/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset index 9142e7dce2..a581d7f1c0 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset @@ -1,7 +1,7 @@ local transforms = asset.require('./transforms') local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local Jupiter = { Identifier = "Jupiter", diff --git a/data/assets/scene/solarsystem/planets/jupiter/minor_moons.asset b/data/assets/scene/solarsystem/planets/jupiter/minor_moons.asset index 90a1812f3f..0609399eef 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/minor_moons.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/minor_moons.asset @@ -1,8 +1,8 @@ -asset.request('./minor/ananke_group') -asset.request('./minor/carme_group') -asset.request('./minor/carpo_group') -asset.request('./minor/himalia_group') -asset.request('./minor/inner_group') -asset.request('./minor/other_groups') -asset.request('./minor/pasiphae_group') -asset.request('./minor/themisto_group') +asset.require('./minor/ananke_group') +asset.require('./minor/carme_group') +asset.require('./minor/carpo_group') +asset.require('./minor/himalia_group') +asset.require('./minor/inner_group') +asset.require('./minor/other_groups') +asset.require('./minor/pasiphae_group') +asset.require('./minor/themisto_group') diff --git a/data/assets/scene/solarsystem/planets/mars/mars.asset b/data/assets/scene/solarsystem/planets/mars/mars.asset index 8be70b30a7..666f90e7bd 100644 --- a/data/assets/scene/solarsystem/planets/mars/mars.asset +++ b/data/assets/scene/solarsystem/planets/mars/mars.asset @@ -1,7 +1,7 @@ local transforms = asset.require('./transforms') local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local labelsPath = asset.require('./mars_globelabels').LabelsPath -- local marsRadii = { 3396190.0, 3396190.0, 3376200.0 } diff --git a/data/assets/scene/solarsystem/planets/mercury/mercury.asset b/data/assets/scene/solarsystem/planets/mercury/mercury.asset index 0aafae5c38..771c819783 100644 --- a/data/assets/scene/solarsystem/planets/mercury/mercury.asset +++ b/data/assets/scene/solarsystem/planets/mercury/mercury.asset @@ -3,7 +3,7 @@ local transforms = asset.require('./transforms') local labelsPath = asset.require('./mercury_globelabels').LabelsPath asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local Mercury = { Identifier = "Mercury", diff --git a/data/assets/scene/solarsystem/planets/neptune/major_moons.asset b/data/assets/scene/solarsystem/planets/neptune/major_moons.asset index 118e2f71b9..a6b9ebde18 100644 --- a/data/assets/scene/solarsystem/planets/neptune/major_moons.asset +++ b/data/assets/scene/solarsystem/planets/neptune/major_moons.asset @@ -1 +1 @@ -asset.request('./triton') +asset.require('./triton') diff --git a/data/assets/scene/solarsystem/planets/neptune/neptune.asset b/data/assets/scene/solarsystem/planets/neptune/neptune.asset index adff2b77fd..ee3f021892 100644 --- a/data/assets/scene/solarsystem/planets/neptune/neptune.asset +++ b/data/assets/scene/solarsystem/planets/neptune/neptune.asset @@ -1,7 +1,7 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local Neptune = { Identifier = "Neptune", diff --git a/data/assets/scene/solarsystem/planets/planets.asset b/data/assets/scene/solarsystem/planets/planets.asset index abac03b55a..fd537c3f98 100644 --- a/data/assets/scene/solarsystem/planets/planets.asset +++ b/data/assets/scene/solarsystem/planets/planets.asset @@ -1,27 +1,27 @@ -asset.request('./mercury/mercury') +asset.require('./mercury/mercury') -asset.request('./venus/venus') -asset.request('./venus/atmosphere') +asset.require('./venus/venus') +asset.require('./venus/atmosphere') -asset.request('./earth/earth') -asset.request('./earth/atmosphere') -asset.request('./earth/markers') -asset.request('./earth/moon/moon') +asset.require('./earth/earth') +asset.require('./earth/atmosphere') +asset.require('./earth/markers') +asset.require('./earth/moon/moon') -asset.request('./mars/mars') -asset.request('./mars/atmosphere') +asset.require('./mars/mars') +asset.require('./mars/atmosphere') -asset.request('./jupiter/jupiter') -asset.request('./jupiter/major_moons') +asset.require('./jupiter/jupiter') +asset.require('./jupiter/major_moons') -asset.request('./saturn/saturn') -asset.request('./saturn/major_moons') +asset.require('./saturn/saturn') +asset.require('./saturn/major_moons') -asset.request('./uranus/uranus') -asset.request('./uranus/major_moons') +asset.require('./uranus/uranus') +asset.require('./uranus/major_moons') -asset.request('./neptune/neptune') -asset.request('./neptune/major_moons') +asset.require('./neptune/neptune') +asset.require('./neptune/major_moons') asset.meta = { diff --git a/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset b/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset index 91081403c7..38e136eba1 100644 --- a/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset +++ b/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 -asset.request('./trail') +asset.require('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath local Dione = { diff --git a/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset b/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset index 4dd9296794..d27fc30a25 100644 --- a/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset +++ b/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 -asset.request('./trail') +asset.require('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath local Enceladus = { diff --git a/data/assets/scene/solarsystem/planets/saturn/hyperion/hyperion.asset b/data/assets/scene/solarsystem/planets/saturn/hyperion/hyperion.asset index f469c320e8..8698e41e73 100644 --- a/data/assets/scene/solarsystem/planets/saturn/hyperion/hyperion.asset +++ b/data/assets/scene/solarsystem/planets/saturn/hyperion/hyperion.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 -asset.request('./trail') +asset.require('./trail') diff --git a/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset b/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset index d87978c575..20dc032e50 100644 --- a/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset +++ b/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 -asset.request('./trail') +asset.require('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath local Iapetus = { diff --git a/data/assets/scene/solarsystem/planets/saturn/major_moons.asset b/data/assets/scene/solarsystem/planets/saturn/major_moons.asset index 08162dfd0f..e14aa30f56 100644 --- a/data/assets/scene/solarsystem/planets/saturn/major_moons.asset +++ b/data/assets/scene/solarsystem/planets/saturn/major_moons.asset @@ -1,8 +1,8 @@ -asset.request('./dione/dione') -asset.request('./enceladus/enceladus') -asset.request('./hyperion/hyperion') -asset.request('./iapetus/iapetus') -asset.request('./mimas/mimas') -asset.request('./rhea/rhea') -asset.request('./tethys/tethys') -asset.request('./titan/titan') +asset.require('./dione/dione') +asset.require('./enceladus/enceladus') +asset.require('./hyperion/hyperion') +asset.require('./iapetus/iapetus') +asset.require('./mimas/mimas') +asset.require('./rhea/rhea') +asset.require('./tethys/tethys') +asset.require('./titan/titan') diff --git a/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset b/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset index 122df73011..b453f6b0fa 100644 --- a/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset +++ b/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 -asset.request('./trail') +asset.require('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath local Mimas = { diff --git a/data/assets/scene/solarsystem/planets/saturn/minor_moons.asset b/data/assets/scene/solarsystem/planets/saturn/minor_moons.asset index fbdc302cff..ba7da9ccbc 100644 --- a/data/assets/scene/solarsystem/planets/saturn/minor_moons.asset +++ b/data/assets/scene/solarsystem/planets/saturn/minor_moons.asset @@ -1,4 +1,4 @@ -asset.request('./minor/gallic_group') -asset.request('./minor/inuit_group') -asset.request('./minor/norse_group') -asset.request('./minor/other_group') +asset.require('./minor/gallic_group') +asset.require('./minor/inuit_group') +asset.require('./minor/norse_group') +asset.require('./minor/other_group') diff --git a/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset b/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset index a662f29c57..faed079a9d 100644 --- a/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset +++ b/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 -asset.request('./trail') +asset.require('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath local Rhea = { diff --git a/data/assets/scene/solarsystem/planets/saturn/saturn.asset b/data/assets/scene/solarsystem/planets/saturn/saturn.asset index 5a3fd508e6..16dd8c7700 100644 --- a/data/assets/scene/solarsystem/planets/saturn/saturn.asset +++ b/data/assets/scene/solarsystem/planets/saturn/saturn.asset @@ -1,7 +1,7 @@ local transforms = asset.require('./transforms') local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local textures = asset.syncedResource({ Type = "HttpSynchronization", diff --git a/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset b/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset index f9ceb09277..59dc831c2b 100644 --- a/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset +++ b/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 -asset.request('./trail') +asset.require('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath local Tethys = { diff --git a/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset b/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset index b323e25ec8..40d3bfae51 100644 --- a/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset +++ b/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset @@ -1,7 +1,7 @@ local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') local kernel = asset.require('../kernels').sat375 -asset.request('./trail') +asset.require('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath local Titan = { diff --git a/data/assets/scene/solarsystem/planets/uranus/minor_moons.asset b/data/assets/scene/solarsystem/planets/uranus/minor_moons.asset index d4039d2b0c..83a3d6391f 100644 --- a/data/assets/scene/solarsystem/planets/uranus/minor_moons.asset +++ b/data/assets/scene/solarsystem/planets/uranus/minor_moons.asset @@ -1,3 +1,3 @@ -asset.request('./inner_moons') -asset.request('./irregular_prograde_moons') -asset.request('./irregular_retrograde_moons') +asset.require('./inner_moons') +asset.require('./irregular_prograde_moons') +asset.require('./irregular_retrograde_moons') diff --git a/data/assets/scene/solarsystem/planets/uranus/uranus.asset b/data/assets/scene/solarsystem/planets/uranus/uranus.asset index b25675fbf3..89421662c2 100644 --- a/data/assets/scene/solarsystem/planets/uranus/uranus.asset +++ b/data/assets/scene/solarsystem/planets/uranus/uranus.asset @@ -1,7 +1,7 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local Uranus = { Identifier = "Uranus", diff --git a/data/assets/scene/solarsystem/planets/venus/venus.asset b/data/assets/scene/solarsystem/planets/venus/venus.asset index fa3cc3a186..d591a30cc1 100644 --- a/data/assets/scene/solarsystem/planets/venus/venus.asset +++ b/data/assets/scene/solarsystem/planets/venus/venus.asset @@ -1,7 +1,7 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') asset.require("spice/base") -asset.request('./trail') +asset.require('./trail') local labelsPath = asset.require('./venus_globelabels').LabelsPath local Venus = { diff --git a/data/assets/scene/solarsystem/sun.asset b/data/assets/scene/solarsystem/sun.asset index a5a1502544..0d0b462d84 100644 --- a/data/assets/scene/solarsystem/sun.asset +++ b/data/assets/scene/solarsystem/sun.asset @@ -1,2 +1,2 @@ -asset.request('./sun/sun') -asset.request('./sun/glare') +asset.require('./sun/sun') +asset.require('./sun/glare') diff --git a/data/assets/sync/everything.asset b/data/assets/sync/everything.asset index 8979061ee2..976e7d3027 100644 --- a/data/assets/sync/everything.asset +++ b/data/assets/sync/everything.asset @@ -4,7 +4,7 @@ local assetHelper = asset.require('../util/asset_helper') -assetHelper.requestAll(asset, '../customization') -assetHelper.requestAll(asset, '../scene') -assetHelper.requestAll(asset, '../spice') -assetHelper.requestAll(asset, '../util') +assetHelper.requireAll(asset, '../customization') +assetHelper.requireAll(asset, '../scene') +assetHelper.requireAll(asset, '../spice') +assetHelper.requireAll(asset, '../util') diff --git a/data/assets/util/asset_helper.asset b/data/assets/util/asset_helper.asset index a785329785..0c8bb07cd7 100644 --- a/data/assets/util/asset_helper.asset +++ b/data/assets/util/asset_helper.asset @@ -132,21 +132,6 @@ local requireAll = function (sceneAsset, directory) return result end -local requestAll = function (sceneAsset, directory) - function string.ends(String,End) - return End=='' or string.sub(String,-string.len(End))==End - end - - local files = openspace.walkDirectoryFiles(sceneAsset.localResource('') .. directory, true) - for _, file in pairs(files) do - if file:ends('.asset') then - openspace.printDebug("Requesting: " .. file:sub(file:find(directory), -7)) - sceneAsset.request(file:sub(file:find(directory), -7)) - end - end -end - - local getDefaultLightSources = function (solarSystemBarycenterIdentifier) local sourceList = { { @@ -203,6 +188,5 @@ asset.export("registerScreenSpaceRenderables", registerScreenSpaceRenderables) asset.export("registerSpiceKernels", registerSpiceKernels) asset.export("registerDashboardItems", registerDashboardItems) asset.export("requireAll", requireAll) -asset.export("requestAll", requestAll) asset.export("getDefaultLightSources", getDefaultLightSources) asset.export("createModelPart", createModelPart) diff --git a/data/assets/util/vrt_flipbook_helper.asset b/data/assets/util/vrt_flipbook_helper.asset index 6693fca1d5..144a4d5ce7 100644 --- a/data/assets/util/vrt_flipbook_helper.asset +++ b/data/assets/util/vrt_flipbook_helper.asset @@ -10,39 +10,39 @@ end local nextFlipbookPage = function (flipbook) - if (flipbook.CurrentFlipIndex >= 0) then - local assetSring = flipbook.AssetPrefix .. flipbook.CurrentFlipIndex; - openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", false) - end + if (flipbook.CurrentFlipIndex >= 0) then + local assetSring = flipbook.AssetPrefix .. flipbook.CurrentFlipIndex; + openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", false) + end - if (flipbook.CurrentFlipIndex < flipbook.TotalCount - 1) then - flipbook.CurrentFlipIndex = flipbook.CurrentFlipIndex + 1; - local assetSring = flipbook.AssetPrefix .. flipbook.CurrentFlipIndex; - openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", true) - end + if (flipbook.CurrentFlipIndex < flipbook.TotalCount - 1) then + flipbook.CurrentFlipIndex = flipbook.CurrentFlipIndex + 1; + local assetSring = flipbook.AssetPrefix .. flipbook.CurrentFlipIndex; + openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", true) + end end local previousFlipbookPage = function (flipbook) - if (localIndex == -1) then - return - end + if (localIndex == -1) then + return + end - local localIndex = flipbook.CurrentFlipIndex; + local localIndex = flipbook.CurrentFlipIndex; - local assetSring = flipbook.AssetPrefix .. localIndex; - openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", false) - localIndex = localIndex - 1; + local assetSring = flipbook.AssetPrefix .. localIndex; + openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", false) + localIndex = localIndex - 1; - if (localIndex >= 0 ) then - assetSring = flipbook.AssetPrefix .. localIndex; - openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", true) - end + if (localIndex >= 0 ) then + assetSring = flipbook.AssetPrefix .. localIndex; + openspace.setPropertyValueSingle("Scene." .. flipbook.AssetGlobe .. ".Renderable.Layers.ColorLayers.".. assetSring .. ".Enabled", true) + end - if (localIndex < -1) then - localIndex = -1 - end - flipbook.CurrentFlipIndex = localIndex; + if (localIndex < -1) then + localIndex = -1 + end + flipbook.CurrentFlipIndex = localIndex; end From 0068ae111de05d2064338579840998fd66a66e57 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 00:30:12 +0200 Subject: [PATCH 13/59] No longer expose the request function on the asset object but still retain it for the add functionality --- include/openspace/scene/assetloader.h | 3 -- src/scene/assetloader.cpp | 46 +++------------------------ src/scene/assetloader_lua.inl | 13 +------- 3 files changed, 6 insertions(+), 56 deletions(-) diff --git a/include/openspace/scene/assetloader.h b/include/openspace/scene/assetloader.h index 4d99b176f8..644acf671d 100644 --- a/include/openspace/scene/assetloader.h +++ b/include/openspace/scene/assetloader.h @@ -45,7 +45,6 @@ int onDeinitialize(lua_State* state); int onInitializeDependency(lua_State* state); int onDeinitializeDependency(lua_State* state); int require(lua_State* state); -int request(lua_State* state); int exists(lua_State* state); int localResource(lua_State* state); int syncedResource(lua_State* state); @@ -164,7 +163,6 @@ public: void assetUnrequested(Asset* parent, std::shared_ptr child); private: - std::shared_ptr request(const std::string& identifier); void unrequest(const std::string& identifier); void setUpAssetLuaTable(Asset* asset); @@ -194,7 +192,6 @@ private: friend int assetloader::onInitializeDependency(lua_State* state); friend int assetloader::onDeinitializeDependency(lua_State* state); friend int assetloader::require(lua_State* state); - friend int assetloader::request(lua_State* state); friend int assetloader::exists(lua_State* state); friend int assetloader::localResource(lua_State* state); friend int assetloader::syncedResource(lua_State* state); diff --git a/src/scene/assetloader.cpp b/src/scene/assetloader.cpp index 9642504ccf..e0323584e1 100644 --- a/src/scene/assetloader.cpp +++ b/src/scene/assetloader.cpp @@ -190,12 +190,6 @@ void AssetLoader::setUpAssetLuaTable(Asset* asset) { lua_pushcclosure(*_luaState, &assetloader::require, 1); lua_setfield(*_luaState, assetTableIndex, RequireFunctionName); - // Register request function - // Dependency request(string path) - lua_pushlightuserdata(*_luaState, asset); - lua_pushcclosure(*_luaState, &assetloader::request, 1); - lua_setfield(*_luaState, assetTableIndex, RequestFunctionName); - // Register exists function // bool exists(string path) lua_pushlightuserdata(*_luaState, asset); @@ -472,14 +466,6 @@ int AssetLoader::onDeinitializeDependencyLua(Asset* dependant, Asset* dependency return 0; } -std::shared_ptr AssetLoader::request(const std::string& identifier) { - std::shared_ptr asset = getAsset(identifier); - Asset* parent = _currentAsset; - parent->request(asset); - assetRequested(parent, asset); - return asset; -} - void AssetLoader::unrequest(const std::string& identifier) { std::shared_ptr asset = has(identifier); Asset* parent = _currentAsset; @@ -498,7 +484,11 @@ ghoul::filesystem::Directory AssetLoader::currentDirectory() const { std::shared_ptr AssetLoader::add(const std::string& identifier) { setCurrentAsset(_rootAsset.get()); - return request(identifier); + std::shared_ptr asset = getAsset(identifier); + Asset* parent = _currentAsset; + parent->request(asset); + assetRequested(parent, asset); + return asset; } void AssetLoader::remove(const std::string& identifier) { @@ -695,32 +685,6 @@ int AssetLoader::requireLua(Asset* dependant) { return 2; } -int AssetLoader::requestLua(Asset* parent) { - ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::request"); - - const std::string assetName = luaL_checkstring(*_luaState, 1); - lua_settop(*_luaState, 0); - - std::shared_ptr child = request(assetName); - - addLuaDependencyTable(parent, child.get()); - - // Get the dependency table - lua_rawgeti(*_luaState, LUA_REGISTRYINDEX, _assetsTableRef); - lua_getfield(*_luaState, -1, child->id().c_str()); - lua_getfield(*_luaState, -1, DependantsTableName); - lua_getfield(*_luaState, -1, parent->id().c_str()); - const int dependencyTableIndex = lua_gettop(*_luaState); - - lua_pushvalue(*_luaState, dependencyTableIndex); - - lua_replace(*_luaState, 1); - lua_settop(*_luaState, 1); - - ghoul_assert(lua_gettop(*_luaState) == 1, "Incorrect number of items left on stack"); - return 1; -} - int AssetLoader::existsLua(Asset*) { ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::exists"); diff --git a/src/scene/assetloader_lua.inl b/src/scene/assetloader_lua.inl index 15b223f1e6..74c281411e 100644 --- a/src/scene/assetloader_lua.inl +++ b/src/scene/assetloader_lua.inl @@ -71,7 +71,7 @@ int onDeinitializeDependency(lua_State* state) { } /** - * Requires rependency + * Requires dependency * Gives access to * AssetTable: Exported lua values * Dependency: ... @@ -82,17 +82,6 @@ int require(lua_State* state) { return asset->loader()->requireLua(asset); } -/** - * Requests rependency - * Gives access to - * Dependency: ... - * Usage: Dependency = asset.import(string assetIdentifier) - */ -int request(lua_State* state) { - Asset* asset = reinterpret_cast(lua_touserdata(state, lua_upvalueindex(1))); - return asset->loader()->requestLua(asset); -} - int exists(lua_State* state) { Asset* asset = reinterpret_cast(lua_touserdata(state, lua_upvalueindex(1))); return asset->loader()->existsLua(asset); From 7f6e4a344756880284d7a8a7e0f84c14fcfc05d5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 01:01:25 +0200 Subject: [PATCH 14/59] Add text to the render window if Tracy is enabled --- CMakeLists.txt | 12 ++++++------ src/rendering/renderengine.cpp | 22 ++++++++++++++++++++++ support/cmake/handle_modules.cmake | 2 +- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0853c7b30..168f21c699 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,7 +155,7 @@ endif () # Ghoul add_subdirectory(${OPENSPACE_EXT_DIR}/ghoul) -target_link_libraries(openspace-core Ghoul) +target_link_libraries(openspace-core PUBLIC Ghoul) set_openspace_compile_settings(Ghoul) set_folder_location(Lua "External") set_folder_location(lz4 "External") @@ -165,7 +165,7 @@ link_directories("${GHOUL_LIBRARY_DIRS}") # Spice begin_dependency("Spice") add_subdirectory(${OPENSPACE_EXT_DIR}/spice) -target_link_libraries(openspace-core Spice) +target_link_libraries(openspace-core PUBLIC Spice) set_folder_location(Spice "External") end_dependency() @@ -174,13 +174,13 @@ begin_dependency("CURL") if (WIN32) set(CURL_ROOT_DIR "${OPENSPACE_EXT_DIR}/curl") target_include_directories(openspace-core SYSTEM PUBLIC ${CURL_ROOT_DIR}/include) - target_link_libraries(openspace-core ${CURL_ROOT_DIR}/lib/libcurl.lib) + target_link_libraries(openspace-core PUBLIC ${CURL_ROOT_DIR}/lib/libcurl.lib) target_compile_definitions(openspace-core PUBLIC "OPENSPACE_CURL_ENABLED" "CURL_STATICLIB") else () find_package(CURL) if (CURL_FOUND) target_include_directories(openspace-core SYSTEM PUBLIC ${CURL_INCLUDE_DIRS}) - target_link_libraries(openspace-core ${CURL_LIBRARIES}) + target_link_libraries(openspace-core PUBLIC ${CURL_LIBRARIES}) target_compile_definitions(openspace-core PUBLIC "OPENSPACE_CURL_ENABLED") endif () endif () @@ -206,7 +206,7 @@ if (MSVC) if (OPENSPACE_ENABLE_VLD) begin_dependency("Visual Leak Detector") target_compile_definitions(openspace-core PUBLIC "OPENSPACE_ENABLE_VLD") - target_link_libraries(openspace-core ${OPENSPACE_EXT_DIR}/vld/lib/vld.lib) + target_link_libraries(openspace-core PUBLIC ${OPENSPACE_EXT_DIR}/vld/lib/vld.lib) target_include_directories(openspace-core PUBLIC ${OPENSPACE_EXT_DIR}/vld) end_dependency() endif () @@ -217,7 +217,7 @@ if (MSVC) begin_dependency("Intel VTune") target_compile_definitions(openspace-core PUBLIC "OPENSPACE_HAS_VTUNE") target_include_directories(openspace-core PUBLIC "${OPENSPACE_VTUNE_PATH}/include") - target_link_libraries(openspace-core "${OPENSPACE_VTUNE_PATH}/lib64/libittnotify.lib") + target_link_libraries(openspace-core PUBLIC "${OPENSPACE_VTUNE_PATH}/lib64/libittnotify.lib") end_dependency() endif () diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 08dd69ed3f..45852d59ca 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -1354,6 +1354,28 @@ void RenderEngine::renderVersionInformation() { glm::vec4(0.5, 0.5, 0.5, 1.f) ); } + +#ifdef TRACY_ENABLE + { + // If we have Tracy enabled, we should inform the user about it that the + // application will crash after a while if no profiler is attached + + ZoneScopedN("Tracy Information") + + const glm::vec2 tracyBox = _fontInfo->boundingBox("TRACY PROFILING ENABLED"); + const glm::vec2 penPosition = glm::vec2( + fontResolution().x - tracyBox.x - 10.f, + versionBox.y + commitBox.y + 5.f + ); + FR::defaultRenderer().render( + *_fontInfo, + penPosition, + "TRACY PROFILING ENABLED", + glm::vec4(0.8f, 0.2f, 0.15f, 1.f) + ); + } +#endif // TRACY_ENABLE + } void RenderEngine::renderScreenLog() { diff --git a/support/cmake/handle_modules.cmake b/support/cmake/handle_modules.cmake index 6b5edc7fe1..fc0178d699 100644 --- a/support/cmake/handle_modules.cmake +++ b/support/cmake/handle_modules.cmake @@ -143,7 +143,7 @@ function (handle_modules internal_module_path external_modules_paths) # Only link openspace-core against the library if it has been set STATIC get_target_property(library_type ${library_name} TYPE) if (NOT ${library_type} STREQUAL "SHARED_LIBRARY") - target_link_libraries(openspace-core ${library_name}) + target_link_libraries(openspace-core PUBLIC ${library_name}) endif() create_define_name(${name} define_name) From b16ee5b35a8c99e4493df5a9d79265114a464739 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 10:07:38 +0200 Subject: [PATCH 15/59] Adapt to changes in Ghoul regarding string_view Fix compile error if Trace logging is not enabled Limit the number of threads to a maximum of 4 for asset initialization --- include/openspace/util/screenlog.h | 4 +- .../rendering/renderableatmosphere.cpp | 43 ++++++++++--------- modules/server/src/connection.cpp | 4 ++ modules/server/src/topics/timetopic.cpp | 6 ++- modules/server/src/topics/topic.cpp | 5 +++ src/engine/openspaceengine.cpp | 11 ++--- src/rendering/renderengine.cpp | 4 +- src/scene/asset.cpp | 6 +++ src/scene/assetloader.cpp | 21 ++++++++- src/scene/assetmanager.cpp | 2 + src/scene/profile.cpp | 8 +++- src/util/screenlog.cpp | 12 +++--- src/util/synchronizationwatcher.cpp | 5 ++- src/util/timemanager.cpp | 6 +++ 14 files changed, 97 insertions(+), 40 deletions(-) diff --git a/include/openspace/util/screenlog.h b/include/openspace/util/screenlog.h index c6ded67ff1..8c496ff57f 100644 --- a/include/openspace/util/screenlog.h +++ b/include/openspace/util/screenlog.h @@ -91,8 +91,8 @@ public: * \param category The category of the log message * \param message The actual log message that was transmitted */ - void log(ghoul::logging::LogLevel level, const std::string& category, - const std::string& message) override; + void log(ghoul::logging::LogLevel level, std::string_view category, + std::string_view message) override; /** * This method removes all the stored LogEntry%s that have expired, calculated by diff --git a/modules/atmosphere/rendering/renderableatmosphere.cpp b/modules/atmosphere/rendering/renderableatmosphere.cpp index 671cc2c3c9..7b31587b74 100644 --- a/modules/atmosphere/rendering/renderableatmosphere.cpp +++ b/modules/atmosphere/rendering/renderableatmosphere.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -55,29 +56,29 @@ namespace { static const char* _loggerCat = "RenderableAtmosphere"; - const char* KeyShadowGroup = "ShadowGroup"; - const char* KeyShadowSource = "Source"; - const char* KeyShadowCaster = "Caster"; + constexpr const char* KeyShadowGroup = "ShadowGroup"; + constexpr const char* KeyShadowSource = "Source"; + constexpr const char* KeyShadowCaster = "Caster"; - const char* keyAtmosphere = "Atmosphere"; - const char* keyAtmosphereRadius = "AtmosphereRadius"; - const char* keyPlanetRadius = "PlanetRadius"; - const char* keyAverageGroundReflectance = "PlanetAverageGroundReflectance"; - const char* keyRayleigh = "Rayleigh"; - const char* keyRayleighHeightScale = "H_R"; - const char* keyOzone = "Ozone"; - const char* keyOzoneHeightScale = "H_O"; - const char* keyMie = "Mie"; - const char* keyMieHeightScale = "H_M"; - const char* keyMiePhaseConstant = "G"; - const char* keyImage = "Image"; - const char* keyToneMappingOp = "ToneMapping"; - const char* keyATMDebug = "Debug"; - const char* keyTextureScale = "PreCalculatedTextureScale"; - const char* keySaveTextures = "SaveCalculatedTextures"; + constexpr const char* keyAtmosphere = "Atmosphere"; + constexpr const char* keyAtmosphereRadius = "AtmosphereRadius"; + constexpr const char* keyPlanetRadius = "PlanetRadius"; + constexpr const char* keyAverageGroundReflectance = "PlanetAverageGroundReflectance"; + constexpr const char* keyRayleigh = "Rayleigh"; + constexpr const char* keyRayleighHeightScale = "H_R"; + constexpr const char* keyOzone = "Ozone"; + constexpr const char* keyOzoneHeightScale = "H_O"; + constexpr const char* keyMie = "Mie"; + constexpr const char* keyMieHeightScale = "H_M"; + constexpr const char* keyMiePhaseConstant = "G"; + constexpr const char* keyImage = "Image"; + constexpr const char* keyToneMappingOp = "ToneMapping"; + constexpr const char* keyATMDebug = "Debug"; + constexpr const char* keyTextureScale = "PreCalculatedTextureScale"; + constexpr const char* keySaveTextures = "SaveCalculatedTextures"; constexpr openspace::properties::Property::PropertyInfo AtmosphereHeightInfo = { - "atmmosphereHeight", + "atmosphereHeight", "Atmosphere Height (KM)", "The thickness of the atmosphere in Km" }; @@ -715,6 +716,8 @@ glm::dmat4 RenderableAtmosphere::computeModelTransformMatrix( } void RenderableAtmosphere::render(const RenderData& data, RendererTasks& renderTask) { + ZoneScoped + if (_atmosphereEnabled) { DeferredcasterTask task{ _deferredcaster.get(), data }; renderTask.deferredcasterTasks.push_back(task); diff --git a/modules/server/src/connection.cpp b/modules/server/src/connection.cpp index 89cb02a96c..7e1b98891c 100644 --- a/modules/server/src/connection.cpp +++ b/modules/server/src/connection.cpp @@ -207,10 +207,14 @@ void Connection::handleJson(const nlohmann::json& json) { } void Connection::sendMessage(const std::string& message) { + ZoneScoped + _socket->putMessage(message); } void Connection::sendJson(const nlohmann::json& json) { + ZoneScoped + sendMessage(json.dump()); } diff --git a/modules/server/src/topics/timetopic.cpp b/modules/server/src/topics/timetopic.cpp index 789b9da924..71d422948c 100644 --- a/modules/server/src/topics/timetopic.cpp +++ b/modules/server/src/topics/timetopic.cpp @@ -30,6 +30,7 @@ #include #include #include +#include namespace { constexpr const char* EventKey = "event"; @@ -97,10 +98,13 @@ void TimeTopic::handleJson(const nlohmann::json& json) { } void TimeTopic::sendCurrentTime() { + ZoneScoped + const json timeJson = { { "time", global::timeManager.time().ISO8601() } }; - _connection->sendJson(wrappedPayload(timeJson)); + const json payload = wrappedPayload(timeJson); + _connection->sendJson(payload); _lastUpdateTime = std::chrono::system_clock::now(); } diff --git a/modules/server/src/topics/topic.cpp b/modules/server/src/topics/topic.cpp index 440252caab..3453c2d739 100644 --- a/modules/server/src/topics/topic.cpp +++ b/modules/server/src/topics/topic.cpp @@ -26,6 +26,7 @@ #include #include +#include namespace openspace { @@ -35,6 +36,8 @@ void Topic::initialize(Connection* connection, size_t topicId) { } nlohmann::json Topic::wrappedPayload(const nlohmann::json& payload) const { + ZoneScoped + // TODO: add message time nlohmann::json j = { { "topic", _topicId }, @@ -44,6 +47,8 @@ nlohmann::json Topic::wrappedPayload(const nlohmann::json& payload) const { } nlohmann::json Topic::wrappedError(std::string message, int code) { + ZoneScoped + nlohmann::json j = { { "topic", _topicId }, { "status", "error" }, diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index e9216124cb..1b78001201 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -262,11 +262,9 @@ void OpenSpaceEngine::initialize() { #endif // WIN32 #ifndef GHOUL_LOGGING_ENABLE_TRACE - LogLevel level = ghoul::logging::levelFromString(_configuration->logging.level); - if (level == ghoul::logging::LogLevel::Trace) { LWARNING( - "Desired logging level is set to 'Trace' but application was " << + "Desired logging level is set to 'Trace' but application was " "compiled without Trace support" ); } @@ -712,8 +710,11 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { std::unique_ptr sceneInitializer; if (global::configuration.useMultithreadedInitialization) { - unsigned int nAvailableThreads = std::thread::hardware_concurrency(); - unsigned int nThreads = nAvailableThreads == 0 ? 2 : nAvailableThreads - 1; + unsigned int nAvailableThreads = std::min( + std::thread::hardware_concurrency() - 1, + 4u + ); + unsigned int nThreads = nAvailableThreads == 0 ? 2 : nAvailableThreads; sceneInitializer = std::make_unique(nThreads); } else { diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index c952a43ebd..a83a69979c 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -1400,7 +1400,7 @@ void RenderEngine::renderScreenLog() { std::array buf; { - std::fill(buf.begin(), buf.end(), 0); + std::fill(buf.begin(), buf.end(), char(0)); char* end = fmt::format_to( buf.data(), "{:<15} {}{}", @@ -1438,7 +1438,7 @@ void RenderEngine::renderScreenLog() { }(it->level); const std::string_view lvl = ghoul::to_string(it->level); - std::fill(buf.begin(), buf.end(), 0); + std::fill(buf.begin(), buf.end(), char(0)); char* end = fmt::format_to(buf.data(), "({})", lvl); std::string_view levelText = std::string_view(buf.data(), end - buf.data()); RenderFont( diff --git a/src/scene/asset.cpp b/src/scene/asset.cpp index 5cc5e52b2d..8c5909bada 100644 --- a/src/scene/asset.cpp +++ b/src/scene/asset.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -94,6 +95,8 @@ Asset::State Asset::state() const { } void Asset::setState(Asset::State state) { + ZoneScoped + if (_state == state) { return; } @@ -188,6 +191,7 @@ void Asset::clearSynchronizations() { void Asset::syncStateChanged(ResourceSynchronization* sync, ResourceSynchronization::State state) { + ZoneScoped if (state == ResourceSynchronization::State::Resolved) { if (!isSynchronized() && isSyncResolveReady()) { @@ -488,6 +492,8 @@ void Asset::unloadIfUnwanted() { } bool Asset::initialize() { + ZoneScoped + if (isInitialized()) { return true; } diff --git a/src/scene/assetloader.cpp b/src/scene/assetloader.cpp index 9642504ccf..246a5399cf 100644 --- a/src/scene/assetloader.cpp +++ b/src/scene/assetloader.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "assetloader_lua.inl" @@ -497,11 +498,15 @@ ghoul::filesystem::Directory AssetLoader::currentDirectory() const { } std::shared_ptr AssetLoader::add(const std::string& identifier) { + ZoneScoped + setCurrentAsset(_rootAsset.get()); return request(identifier); } void AssetLoader::remove(const std::string& identifier) { + ZoneScoped + setCurrentAsset(_rootAsset.get()); unrequest(identifier); } @@ -530,6 +535,8 @@ const std::string& AssetLoader::assetRootDirectory() const { } void AssetLoader::callOnInitialize(Asset* asset) { + ZoneScoped + for (int init : _onInitializationFunctionRefs[asset]) { lua_rawgeti(*_luaState, LUA_REGISTRYINDEX, init); if (lua_pcall(*_luaState, 0, 0, 0) != LUA_OK) { @@ -543,7 +550,9 @@ void AssetLoader::callOnInitialize(Asset* asset) { } } -void AssetLoader::callOnDeinitialize(Asset * asset) { +void AssetLoader::callOnDeinitialize(Asset* asset) { + ZoneScoped + const std::vector& funs = _onDeinitializationFunctionRefs[asset]; for (auto it = funs.rbegin(); it != funs.rend(); it++) { lua_rawgeti(*_luaState, LUA_REGISTRYINDEX, *it); @@ -559,6 +568,8 @@ void AssetLoader::callOnDeinitialize(Asset * asset) { } void AssetLoader::callOnDependencyInitialize(Asset* asset, Asset* dependant) { + ZoneScoped + for (int init : _onDependencyInitializationFunctionRefs[dependant][asset]) { lua_rawgeti(*_luaState, LUA_REGISTRYINDEX, init); if (lua_pcall(*_luaState, 0, 0, 0) != LUA_OK) { @@ -577,6 +588,8 @@ void AssetLoader::callOnDependencyInitialize(Asset* asset, Asset* dependant) { } void AssetLoader::callOnDependencyDeinitialize(Asset* asset, Asset* dependant) { + ZoneScoped + const std::vector& funs = _onDependencyDeinitializationFunctionRefs[dependant][asset]; @@ -595,6 +608,8 @@ void AssetLoader::callOnDependencyDeinitialize(Asset* asset, Asset* dependant) { } int AssetLoader::localResourceLua(Asset* asset) { + ZoneScoped + ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::localResourceLua"); std::string name = ghoul::lua::value( @@ -613,6 +628,8 @@ int AssetLoader::localResourceLua(Asset* asset) { } int AssetLoader::syncedResourceLua(Asset* asset) { + ZoneScoped + ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::syncedResourceLua"); ghoul::Dictionary d; @@ -633,6 +650,8 @@ int AssetLoader::syncedResourceLua(Asset* asset) { } void AssetLoader::setCurrentAsset(Asset* asset) { + ZoneScoped + const int top = lua_gettop(*_luaState); _currentAsset = asset; diff --git a/src/scene/assetmanager.cpp b/src/scene/assetmanager.cpp index 06282fa109..f93a278a6b 100644 --- a/src/scene/assetmanager.cpp +++ b/src/scene/assetmanager.cpp @@ -58,6 +58,7 @@ bool AssetManager::update() { // Add assets for (const std::pair& c : _pendingStateChangeCommands) { + ZoneScopedN("(add) Pending State Change") const std::string& path = c.first; const bool add = c.second; if (add) { @@ -67,6 +68,7 @@ bool AssetManager::update() { } // Remove assets for (const std::pair& c : _pendingStateChangeCommands) { + ZoneScopedN("(remove) Pending State change") const std::string& path = c.first; const bool remove = !c.second; if (remove && _assetLoader.has(path)) { diff --git a/src/scene/profile.cpp b/src/scene/profile.cpp index 8c9e908ed8..f351928e2a 100644 --- a/src/scene/profile.cpp +++ b/src/scene/profile.cpp @@ -498,6 +498,8 @@ void Profile::setIgnoreUpdates(bool ignoreUpdates) { } void Profile::addAsset(const std::string& path) { + ZoneScoped + if (_ignoreUpdates) { return; } @@ -519,13 +521,15 @@ void Profile::addAsset(const std::string& path) { } void Profile::removeAsset(const std::string& path) { + ZoneScoped + if (_ignoreUpdates) { return; } const auto it = std::find_if( - assets.begin(), - assets.end(), + assets.cbegin(), + assets.cend(), [path](const Asset& a) { return a.path == path; } ); diff --git a/src/util/screenlog.cpp b/src/util/screenlog.cpp index c5ff3f67e2..9425298cf9 100644 --- a/src/util/screenlog.cpp +++ b/src/util/screenlog.cpp @@ -26,14 +26,14 @@ #include -using std::string; - namespace openspace { ScreenLog::ScreenLog(std::chrono::seconds timeToLive, LogLevel logLevel) : _timeToLive(std::move(timeToLive)) , _logLevel(logLevel) -{} +{ + _entries.reserve(64); +} void ScreenLog::removeExpiredEntries() { std::lock_guard guard(_mutex); @@ -48,15 +48,15 @@ void ScreenLog::removeExpiredEntries() { _entries.erase(rit, _entries.end() ); } -void ScreenLog::log(LogLevel level, const string& category, const string& message) { +void ScreenLog::log(LogLevel level, std::string_view category, std::string_view message) { std::lock_guard guard(_mutex); if (level >= _logLevel) { _entries.push_back({ level, std::chrono::steady_clock::now(), Log::timeString(), - category, - message + std::string(category), + std::string(message) }); } } diff --git a/src/util/synchronizationwatcher.cpp b/src/util/synchronizationwatcher.cpp index 2fe4377611..e176b7af8c 100644 --- a/src/util/synchronizationwatcher.cpp +++ b/src/util/synchronizationwatcher.cpp @@ -24,6 +24,7 @@ #include +#include #include namespace openspace { @@ -75,8 +76,9 @@ void SynchronizationWatcher::unwatchSynchronization(WatchHandle watchHandle) { ), _pendingNotifications.end()); } - void SynchronizationWatcher::notify() { + ZoneScoped + std::vector notifications; { std::lock_guard guard(_mutex); @@ -85,6 +87,7 @@ void SynchronizationWatcher::notify() { } for (const NotificationData& n : notifications) { + ZoneScopedN("Notification") std::shared_ptr sync = n.synchronization.lock(); if (!sync) { continue; diff --git a/src/util/timemanager.cpp b/src/util/timemanager.cpp index ca95d401fd..505eaad5f7 100644 --- a/src/util/timemanager.cpp +++ b/src/util/timemanager.cpp @@ -139,9 +139,11 @@ void TimeManager::preSynchronization(double dt) { const double newTime = time().j2000Seconds(); if (newTime != _lastTime) { + ZoneScopedN("newTime != _lastTime") using K = const CallbackHandle; using V = TimeChangeCallback; for (const std::pair& it : _timeChangeCallbacks) { + ZoneScopedN("tcc") it.second(); } } @@ -149,16 +151,20 @@ void TimeManager::preSynchronization(double dt) { _timePaused != _lastTimePaused || _targetDeltaTime != _lastTargetDeltaTime) { + ZoneScopedN("delta time changed") using K = const CallbackHandle; using V = TimeChangeCallback; for (const std::pair& it : _deltaTimeChangeCallbacks) { + ZoneScopedN("dtcc") it.second(); } } if (_timelineChanged) { + ZoneScopedN("timeline changed") using K = const CallbackHandle; using V = TimeChangeCallback; for (const std::pair& it : _timelineChangeCallbacks) { + ZoneScopedN("tlcc") it.second(); } } From 71415e3cdbfcff52bce25696d3765f82cb39cf3a Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 10:09:28 +0200 Subject: [PATCH 16/59] Update Ghoul repository --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index bd812defd7..e9cb5d37ff 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit bd812defd787ad34119cfe7ecef2be71a7a1553e +Subproject commit e9cb5d37ff38bc93b95a96a65146385a9e42e341 From 38caff9c02646b09406ca6d1e3febb0b56f0c943 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 10:30:05 +0200 Subject: [PATCH 17/59] Move a lot of the initialization of the RenderableGalaxy from the initializeGL to the initialize method to make use of the multithreading Don't keep the volume in RAM when it has been uploaded to the GPU --- modules/galaxy/rendering/renderablegalaxy.cpp | 175 +++++++++--------- modules/galaxy/rendering/renderablegalaxy.h | 4 + 2 files changed, 93 insertions(+), 86 deletions(-) diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index ba5a801649..34107597bc 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -327,41 +327,6 @@ RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary) else { LERROR("No points filename specified."); } -} - -void RenderableGalaxy::initializeGL() { - // Aspect is currently hardcoded to cubic voxels. - _aspect = static_cast(_volumeDimensions); - _aspect /= std::max(std::max(_aspect.x, _aspect.y), _aspect.z); - - // The volume - volume::RawVolumeReader> reader( - _volumeFilename, - _volumeDimensions - ); - _volume = reader.read(); - - _texture = std::make_unique( - _volumeDimensions, - ghoul::opengl::Texture::Format::RGBA, - GL_RGBA, - GL_UNSIGNED_BYTE, - ghoul::opengl::Texture::FilterMode::Linear, - ghoul::opengl::Texture::WrappingMode::ClampToEdge - ); - - _texture->setPixelData( - reinterpret_cast(_volume->data()), - ghoul::opengl::Texture::TakeOwnership::No - ); - - _texture->setDimensions(_volume->dimensions()); - _texture->uploadTexture(); - - _raycaster = std::make_unique(*_texture); - _raycaster->initialize(); - - global::raycasterManager.attachRaycaster(*_raycaster); auto onChange = [&](bool enabled) { if (enabled) { @@ -385,6 +350,89 @@ void RenderableGalaxy::initializeGL() { addProperty(_rotation); addProperty(_downScaleVolumeRendering); addProperty(_numberOfRayCastingSteps); +} + +void RenderableGalaxy::initialize() { + // Aspect is currently hardcoded to cubic voxels. + _aspect = static_cast(_volumeDimensions); + _aspect /= std::max(std::max(_aspect.x, _aspect.y), _aspect.z); + + // The volume + volume::RawVolumeReader> reader( + _volumeFilename, + _volumeDimensions + ); + _volume = reader.read(); + + std::string cachedPointsFile = FileSys.cacheManager()->cachedFilename( + _pointsFilename, + ghoul::filesystem::CacheManager::Persistent::Yes + ); + const bool hasCachedFile = FileSys.fileExists(cachedPointsFile); + if (hasCachedFile) { + LINFO(fmt::format("Cached file '{}' used for galaxy point file '{}'", + cachedPointsFile, _pointsFilename + )); + + Result res = loadCachedFile(cachedPointsFile); + if (res.success) { + _pointPositionsCache = std::move(res.positions); + _pointColorsCache = std::move(res.color); + } + else { + FileSys.cacheManager()->removeCacheFile(_pointsFilename); + Result resPoint = loadPointFile(_pointsFilename); + _pointPositionsCache = std::move(resPoint.positions); + _pointColorsCache = std::move(resPoint.color); + saveCachedFile( + cachedPointsFile, + _pointPositionsCache, + _pointColorsCache, + _nPoints, + _enabledPointsRatio + ); + } + } + else { + Result res = loadPointFile(_pointsFilename); + ghoul_assert(res.success, "Point file loading failed"); + _pointPositionsCache = std::move(res.positions); + _pointColorsCache = std::move(res.color); + saveCachedFile( + cachedPointsFile, + _pointPositionsCache, + _pointColorsCache, + _nPoints, + _enabledPointsRatio + ); + } +} + +void RenderableGalaxy::initializeGL() { + _texture = std::make_unique( + _volumeDimensions, + ghoul::opengl::Texture::Format::RGBA, + GL_RGBA, + GL_UNSIGNED_BYTE, + ghoul::opengl::Texture::FilterMode::Linear, + ghoul::opengl::Texture::WrappingMode::ClampToEdge + ); + + _texture->setPixelData( + reinterpret_cast(_volume->data()), + ghoul::opengl::Texture::TakeOwnership::No + ); + + _texture->setDimensions(_volume->dimensions()); + _texture->uploadTexture(); + + _raycaster = std::make_unique(*_texture); + _raycaster->initialize(); + + // We no longer need the data + _volume = nullptr; + + global::raycasterManager.attachRaycaster(*_raycaster); // initialize points. if (_pointsFilename.empty()) { @@ -442,53 +490,6 @@ void RenderableGalaxy::initializeGL() { GLint positionAttrib = _pointsProgram->attributeLocation("in_position"); GLint colorAttrib = _pointsProgram->attributeLocation("in_color"); - - std::vector pointPositions; - std::vector pointColors; - - std::string cachedPointsFile = FileSys.cacheManager()->cachedFilename( - _pointsFilename, - ghoul::filesystem::CacheManager::Persistent::Yes - ); - const bool hasCachedFile = FileSys.fileExists(cachedPointsFile); - if (hasCachedFile) { - LINFO(fmt::format("Cached file '{}' used for galaxy point file '{}'", - cachedPointsFile, _pointsFilename - )); - - Result res = loadCachedFile(cachedPointsFile); - if (res.success) { - pointPositions = std::move(res.positions); - pointColors = std::move(res.color); - } - else { - FileSys.cacheManager()->removeCacheFile(_pointsFilename); - Result resPoint = loadPointFile(_pointsFilename); - pointPositions = std::move(resPoint.positions); - pointColors = std::move(resPoint.color); - saveCachedFile( - cachedPointsFile, - pointPositions, - pointColors, - _nPoints, - _enabledPointsRatio - ); - } - } - else { - Result res = loadPointFile(_pointsFilename); - ghoul_assert(res.success, "Point file loading failed"); - pointPositions = std::move(res.positions); - pointColors = std::move(res.color); - saveCachedFile( - cachedPointsFile, - pointPositions, - pointColors, - _nPoints, - _enabledPointsRatio - ); - } - glGenVertexArrays(1, &_pointsVao); glGenBuffers(1, &_positionVbo); glGenBuffers(1, &_colorVbo); @@ -496,17 +497,19 @@ void RenderableGalaxy::initializeGL() { glBindVertexArray(_pointsVao); glBindBuffer(GL_ARRAY_BUFFER, _positionVbo); glBufferData(GL_ARRAY_BUFFER, - pointPositions.size() * sizeof(glm::vec3), - pointPositions.data(), + _pointPositionsCache.size() * sizeof(glm::vec3), + _pointPositionsCache.data(), GL_STATIC_DRAW ); + _pointPositionsCache.clear(); glBindBuffer(GL_ARRAY_BUFFER, _colorVbo); glBufferData(GL_ARRAY_BUFFER, - pointColors.size() * sizeof(glm::vec3), - pointColors.data(), + _pointColorsCache.size() * sizeof(glm::vec3), + _pointColorsCache.data(), GL_STATIC_DRAW ); + _pointColorsCache.clear(); glBindBuffer(GL_ARRAY_BUFFER, _positionVbo); glEnableVertexAttribArray(positionAttrib); diff --git a/modules/galaxy/rendering/renderablegalaxy.h b/modules/galaxy/rendering/renderablegalaxy.h index d48ac6d2ab..f89090c5d0 100644 --- a/modules/galaxy/rendering/renderablegalaxy.h +++ b/modules/galaxy/rendering/renderablegalaxy.h @@ -47,6 +47,7 @@ public: explicit RenderableGalaxy(const ghoul::Dictionary& dictionary); virtual ~RenderableGalaxy() = default; + void initialize() override; void initializeGL() override; void deinitializeGL() override; bool isReady() const override; @@ -110,6 +111,9 @@ private: GLuint _pointsVao = 0; GLuint _positionVbo = 0; GLuint _colorVbo = 0; + + std::vector _pointPositionsCache; + std::vector _pointColorsCache; }; } // namespace openspace From b49154b83ed5a6a1f6b7ad34f9ff9bbbf63c6ae1 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 10:40:17 +0200 Subject: [PATCH 18/59] No longer allocated unused data in the Milkyway that is overwritten immediately --- modules/galaxy/rendering/renderablegalaxy.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index 34107597bc..b86e9393f4 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -415,7 +415,9 @@ void RenderableGalaxy::initializeGL() { GL_RGBA, GL_UNSIGNED_BYTE, ghoul::opengl::Texture::FilterMode::Linear, - ghoul::opengl::Texture::WrappingMode::ClampToEdge + ghoul::opengl::Texture::WrappingMode::ClampToEdge, + ghoul::opengl::Texture::AllocateData::No, + ghoul::opengl::Texture::TakeOwnership::No ); _texture->setPixelData( From 2b6d95057bf59836600a1d8a409537f3b97e1843 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 10:48:56 +0200 Subject: [PATCH 19/59] Don't keep the majority of textures in RAM if they are not needed, further reducing the memory footprint --- modules/base/rendering/renderablemodel.cpp | 1 + modules/base/rendering/renderablesphere.cpp | 1 + modules/base/rendering/screenspaceframebuffer.cpp | 1 + modules/base/rendering/screenspaceimagelocal.cpp | 4 +--- modules/base/rendering/screenspaceimageonline.cpp | 4 +--- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index b4250a1238..957eae6e92 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -453,6 +453,7 @@ void RenderableModel::loadTexture() { ); _texture->uploadTexture(); _texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + _texture->purgeFromRAM(); } } } diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index d38c48c417..ae9a58ae92 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -488,6 +488,7 @@ void RenderableSphere::loadTexture() { ); texture->uploadTexture(); texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap); + texture->purgeFromRAM(); _texture = std::move(texture); } } diff --git a/modules/base/rendering/screenspaceframebuffer.cpp b/modules/base/rendering/screenspaceframebuffer.cpp index dab0c44e2b..46f96989ab 100644 --- a/modules/base/rendering/screenspaceframebuffer.cpp +++ b/modules/base/rendering/screenspaceframebuffer.cpp @@ -180,6 +180,7 @@ void ScreenSpaceFramebuffer::createFramebuffer() { _texture->uploadTexture(); _texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap); + _texture->purgeFromRAM(); _framebuffer->attachTexture(_texture.get(), GL_COLOR_ATTACHMENT0); _framebuffer->deactivate(); } diff --git a/modules/base/rendering/screenspaceimagelocal.cpp b/modules/base/rendering/screenspaceimagelocal.cpp index 7901089979..4239bb5b9a 100644 --- a/modules/base/rendering/screenspaceimagelocal.cpp +++ b/modules/base/rendering/screenspaceimagelocal.cpp @@ -132,10 +132,8 @@ void ScreenSpaceImageLocal::update() { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); texture->uploadTexture(); - - // Textures of planets looks much smoother with AnisotropicMipMap rather than - // linear texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap); + texture->purgeFromRAM(); _texture = std::move(texture); _objectSize = _texture->dimensions(); diff --git a/modules/base/rendering/screenspaceimageonline.cpp b/modules/base/rendering/screenspaceimageonline.cpp index e9f41f952f..10ad87dbde 100644 --- a/modules/base/rendering/screenspaceimageonline.cpp +++ b/modules/base/rendering/screenspaceimageonline.cpp @@ -142,10 +142,8 @@ void ScreenSpaceImageOnline::update() { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); texture->uploadTexture(); - - // Textures of planets looks much smoother with AnisotropicMipMap rather - // than linear texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap); + texture->purgeFromRAM(); _texture = std::move(texture); _objectSize = _texture->dimensions(); From c4db2a8ff9aea339cdc8e63b8982c7d617a840ec Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 11:02:44 +0200 Subject: [PATCH 20/59] No longer keep textures for RenderablePlanesCloud in RAM --- .../rendering/renderablebillboardscloud.cpp | 8 ++++++++ .../digitaluniverse/rendering/renderableplanescloud.cpp | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index 8fc50b03e5..a25018ceef 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -701,6 +702,8 @@ bool RenderableBillboardsCloud::isReady() const { } void RenderableBillboardsCloud::initialize() { + ZoneScoped + bool success = loadData(); if (!success) { throw ghoul::RuntimeError("Error loading data"); @@ -716,6 +719,8 @@ void RenderableBillboardsCloud::initialize() { } void RenderableBillboardsCloud::initializeGL() { + ZoneScoped + _program = DigitalUniverseModule::ProgramObjectManager.request( ProgramObjectName, []() { @@ -1177,6 +1182,7 @@ void RenderableBillboardsCloud::update(const UpdateData&) { ghoul::io::TextureReader::ref().loadTexture(absPath(path)); t->uploadTexture(); t->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + t->purgeFromRAM(); return t; } ); @@ -1714,6 +1720,8 @@ void RenderableBillboardsCloud::createDataSlice() { } void RenderableBillboardsCloud::createPolygonTexture() { + ZoneScoped + LDEBUG("Creating Polygon Texture"); glGenTextures(1, &_pTexture); diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.cpp b/modules/digitaluniverse/rendering/renderableplanescloud.cpp index 3fc991b7ee..4281fbe66b 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.cpp +++ b/modules/digitaluniverse/rendering/renderableplanescloud.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -478,6 +479,8 @@ bool RenderablePlanesCloud::isReady() const { } void RenderablePlanesCloud::initialize() { + ZoneScoped + const bool success = loadData(); if (!success) { throw ghoul::RuntimeError("Error loading data"); @@ -485,6 +488,8 @@ void RenderablePlanesCloud::initialize() { } void RenderablePlanesCloud::initializeGL() { + ZoneScoped + _program = DigitalUniverseModule::ProgramObjectManager.request( ProgramObjectName, []() -> std::unique_ptr { @@ -857,6 +862,7 @@ bool RenderablePlanesCloud::loadTextures() { p.first->second->setFilter( ghoul::opengl::Texture::FilterMode::LinearMipMap ); + p.first->second->purgeFromRAM(); } } } From 88b6fdd9fe98aa748ba81045533e491c5ab1252b Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 12:58:40 +0200 Subject: [PATCH 21/59] Add more Tracy markers in different renderables --- ext/ghoul | 2 +- .../rendering/atmospheredeferredcaster.cpp | 4 +++ .../lightsource/scenegraphlightsource.cpp | 3 +++ modules/base/rendering/modelgeometry.cpp | 3 +++ modules/base/rendering/renderablelabels.cpp | 3 +++ modules/base/rendering/renderablemodel.cpp | 7 ++++- modules/base/rendering/renderabletrail.cpp | 2 ++ modules/base/rotation/fixedrotation.cpp | 3 +++ .../rendering/renderablepoints.cpp | 5 ++++ modules/galaxy/rendering/galaxyraycaster.cpp | 3 +++ modules/galaxy/rendering/renderablegalaxy.cpp | 5 ++++ .../globebrowsing/globebrowsingmodule_lua.inl | 2 ++ .../src/asynctiledataprovider.cpp | 5 ++++ .../src/globelabelscomponent.cpp | 3 +++ modules/globebrowsing/src/layer.cpp | 2 ++ modules/globebrowsing/src/layergroup.cpp | 2 ++ .../globebrowsing/src/rawtiledatareader.cpp | 26 ++++++++++++------- modules/globebrowsing/src/ringscomponent.cpp | 4 +++ modules/globebrowsing/src/shadowcomponent.cpp | 2 ++ modules/globebrowsing/src/tileprovider.cpp | 7 +++++ modules/globebrowsing/src/tileprovider.h | 2 +- src/rendering/framebufferrenderer.cpp | 2 ++ src/scene/assetmanager.cpp | 2 ++ 23 files changed, 87 insertions(+), 12 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index e9cb5d37ff..c342cf9d25 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit e9cb5d37ff38bc93b95a96a65146385a9e42e341 +Subproject commit c342cf9d25995b02e709fc4bcc114ef40a3a8715 diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index 376b8db702..48bf03d06b 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -150,6 +150,8 @@ namespace { namespace openspace { void AtmosphereDeferredcaster::initialize() { + ZoneScoped + if (!_atmosphereCalculated) { preCalculateAtmosphereParam(); } @@ -159,6 +161,8 @@ void AtmosphereDeferredcaster::initialize() { } void AtmosphereDeferredcaster::deinitialize() { + ZoneScoped + _transmittanceProgramObject = nullptr; _irradianceProgramObject = nullptr; _irradianceSupTermsProgramObject = nullptr; diff --git a/modules/base/lightsource/scenegraphlightsource.cpp b/modules/base/lightsource/scenegraphlightsource.cpp index 628b8586bd..4d2432fad9 100644 --- a/modules/base/lightsource/scenegraphlightsource.cpp +++ b/modules/base/lightsource/scenegraphlightsource.cpp @@ -30,6 +30,7 @@ #include #include #include +#include namespace { constexpr openspace::properties::Property::PropertyInfo IntensityInfo = { @@ -115,6 +116,8 @@ SceneGraphLightSource::SceneGraphLightSource(const ghoul::Dictionary& dictionary } bool SceneGraphLightSource::initialize() { + ZoneScoped + _sceneGraphNode = global::renderEngine.scene()->sceneGraphNode(_sceneGraphNodeReference); return _sceneGraphNode != nullptr; diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index d597230d9f..f6a339711c 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -118,6 +119,8 @@ void ModelGeometry::changeRenderMode(GLenum mode) { } bool ModelGeometry::initialize(Renderable* parent) { + ZoneScoped + float maximumDistanceSquared = 0; for (const Vertex& v : _vertices) { maximumDistanceSquared = glm::max( diff --git a/modules/base/rendering/renderablelabels.cpp b/modules/base/rendering/renderablelabels.cpp index f9f9c4958c..9ad0172359 100644 --- a/modules/base/rendering/renderablelabels.cpp +++ b/modules/base/rendering/renderablelabels.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -604,6 +605,8 @@ bool RenderableLabels::isReady() const { } void RenderableLabels::initialize() { + ZoneScoped + bool success = true;// loadData(); if (!success) { throw ghoul::RuntimeError("Error loading objects labels data."); diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 957eae6e92..26b592797a 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -37,8 +37,9 @@ #include #include -#include #include +#include +#include #include #include #include @@ -294,12 +295,16 @@ bool RenderableModel::isReady() const { } void RenderableModel::initialize() { + ZoneScoped + for (const std::unique_ptr& ls : _lightSources) { ls->initialize(); } } void RenderableModel::initializeGL() { + ZoneScoped + _program = BaseModule::ProgramObjectManager.request( ProgramName, []() -> std::unique_ptr { diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index ed57c6830d..102cf6f5ee 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -282,6 +282,8 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) } void RenderableTrail::initializeGL() { + ZoneScoped + #ifdef __APPLE__ _programObject = BaseModule::ProgramObjectManager.request( ProgramName, diff --git a/modules/base/rotation/fixedrotation.cpp b/modules/base/rotation/fixedrotation.cpp index 5a9a07e5fd..6ebf88d97c 100644 --- a/modules/base/rotation/fixedrotation.cpp +++ b/modules/base/rotation/fixedrotation.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include namespace { @@ -444,6 +445,8 @@ FixedRotation::FixedRotation(const ghoul::Dictionary& dictionary) } bool FixedRotation::initialize() { + ZoneScoped + // We need to do this in the initialize and not the constructor as the scene graph // nodes referenced in the dictionary might not exist yet at construction time. At // initialization time, however, we know that they already have been created diff --git a/modules/digitaluniverse/rendering/renderablepoints.cpp b/modules/digitaluniverse/rendering/renderablepoints.cpp index d48ddd9313..7b5bca997f 100644 --- a/modules/digitaluniverse/rendering/renderablepoints.cpp +++ b/modules/digitaluniverse/rendering/renderablepoints.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -235,6 +236,8 @@ bool RenderablePoints::isReady() const { } void RenderablePoints::initialize() { + ZoneScoped + bool success = loadData(); if (!success) { throw ghoul::RuntimeError("Error loading data"); @@ -242,6 +245,8 @@ void RenderablePoints::initialize() { } void RenderablePoints::initializeGL() { + ZoneScoped + // OBS: The ProgramObject name is later used to release the program as well, so the // name parameter to requestProgramObject and the first parameter to // buildRenderProgram has to be the same or an assertion will be thrown at the diff --git a/modules/galaxy/rendering/galaxyraycaster.cpp b/modules/galaxy/rendering/galaxyraycaster.cpp index 076662d73c..3faa00b483 100644 --- a/modules/galaxy/rendering/galaxyraycaster.cpp +++ b/modules/galaxy/rendering/galaxyraycaster.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,8 @@ GalaxyRaycaster::GalaxyRaycaster(ghoul::opengl::Texture& texture) {} void GalaxyRaycaster::initialize() { + ZoneScoped + _boundingBox.initialize(); } diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index b86e9393f4..1c140a8b0b 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -353,6 +354,8 @@ RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary) } void RenderableGalaxy::initialize() { + ZoneScoped + // Aspect is currently hardcoded to cubic voxels. _aspect = static_cast(_volumeDimensions); _aspect /= std::max(std::max(_aspect.x, _aspect.y), _aspect.z); @@ -409,6 +412,8 @@ void RenderableGalaxy::initialize() { } void RenderableGalaxy::initializeGL() { + ZoneScoped + _texture = std::make_unique( _volumeDimensions, ghoul::opengl::Texture::Format::RGBA, diff --git a/modules/globebrowsing/globebrowsingmodule_lua.inl b/modules/globebrowsing/globebrowsingmodule_lua.inl index 666b942143..5f091b8108 100644 --- a/modules/globebrowsing/globebrowsingmodule_lua.inl +++ b/modules/globebrowsing/globebrowsingmodule_lua.inl @@ -44,6 +44,8 @@ namespace openspace::globebrowsing::luascriptfunctions { * Adds a layer to the specified globe. */ int addLayer(lua_State* L) { + ZoneScoped + ghoul::lua::checkArgumentsAndThrow(L, 3, "lua::addLayer"); // String arguments diff --git a/modules/globebrowsing/src/asynctiledataprovider.cpp b/modules/globebrowsing/src/asynctiledataprovider.cpp index 45e4fbe84b..e6795dc4df 100644 --- a/modules/globebrowsing/src/asynctiledataprovider.cpp +++ b/modules/globebrowsing/src/asynctiledataprovider.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include namespace openspace::globebrowsing { @@ -45,6 +46,8 @@ AsyncTileDataProvider::AsyncTileDataProvider(std::string name, , _rawTileDataReader(std::move(rawTileDataReader)) , _concurrentJobManager(LRUThreadPool(1, 10)) { + ZoneScoped + _globeBrowsingModule = global::moduleEngine.module(); performReset(ResetRawTileDataReader::No); } @@ -187,6 +190,8 @@ bool AsyncTileDataProvider::shouldBeDeleted() { } void AsyncTileDataProvider::performReset(ResetRawTileDataReader resetRawTileDataReader) { + ZoneScoped + ghoul_assert(_enqueuedTileRequests.empty(), "No enqueued requests left"); // Reset raw tile data reader diff --git a/modules/globebrowsing/src/globelabelscomponent.cpp b/modules/globebrowsing/src/globelabelscomponent.cpp index 28c9b60409..a603733eaf 100644 --- a/modules/globebrowsing/src/globelabelscomponent.cpp +++ b/modules/globebrowsing/src/globelabelscomponent.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -322,6 +323,8 @@ GlobeLabelsComponent::GlobeLabelsComponent() void GlobeLabelsComponent::initialize(const ghoul::Dictionary& dictionary, globebrowsing::RenderableGlobe* globe) { + ZoneScoped + documentation::testSpecificationAndThrow( Documentation(), dictionary, diff --git a/modules/globebrowsing/src/layer.cpp b/modules/globebrowsing/src/layer.cpp index d4a049be46..d9bdc6b8ec 100644 --- a/modules/globebrowsing/src/layer.cpp +++ b/modules/globebrowsing/src/layer.cpp @@ -374,6 +374,8 @@ Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict, } void Layer::initialize() { + ZoneScoped + if (_tileProvider) { tileprovider::initialize(*_tileProvider); } diff --git a/modules/globebrowsing/src/layergroup.cpp b/modules/globebrowsing/src/layergroup.cpp index 260594489f..ca175a1658 100644 --- a/modules/globebrowsing/src/layergroup.cpp +++ b/modules/globebrowsing/src/layergroup.cpp @@ -114,6 +114,8 @@ int LayerGroup::update() { } Layer* LayerGroup::addLayer(const ghoul::Dictionary& layerDict) { + ZoneScoped + documentation::TestResult res = documentation::testSpecification( Layer::Documentation(), layerDict diff --git a/modules/globebrowsing/src/rawtiledatareader.cpp b/modules/globebrowsing/src/rawtiledatareader.cpp index 4b1db96cbb..4463afb88b 100644 --- a/modules/globebrowsing/src/rawtiledatareader.cpp +++ b/modules/globebrowsing/src/rawtiledatareader.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef _MSC_VER #pragma warning (push) @@ -423,6 +424,8 @@ RawTileDataReader::RawTileDataReader(std::string filePath, , _initData(std::move(initData)) , _preprocess(preprocess) { + ZoneScoped + initialize(); } @@ -435,6 +438,8 @@ RawTileDataReader::~RawTileDataReader() { } void RawTileDataReader::initialize() { + ZoneScoped + if (_datasetFilePath.empty()) { throw ghoul::RuntimeError("File path must not be empty"); } @@ -443,6 +448,7 @@ void RawTileDataReader::initialize() { std::string content = _datasetFilePath; if (module.isWMSCachingEnabled()) { + ZoneScopedN("WMS Caching") std::string c; if (FileSys.fileExists(_datasetFilePath)) { // Only replace the 'content' if the dataset is an XML file and we want to do @@ -511,16 +517,19 @@ void RawTileDataReader::initialize() { } } - _dataset = static_cast(GDALOpen(content.c_str(), GA_ReadOnly)); - if (!_dataset) { - throw ghoul::RuntimeError("Failed to load dataset: " + _datasetFilePath); + { + ZoneScopedN("GDALOpen") + _dataset = static_cast(GDALOpen(content.c_str(), GA_ReadOnly)); + if (!_dataset) { + throw ghoul::RuntimeError("Failed to load dataset: " + _datasetFilePath); + } } // Assume all raster bands have the same data type _rasterCount = _dataset->GetRasterCount(); // calculateTileDepthTransform - unsigned long long maximumValue = [t = _initData.glType]() { + unsigned long long maximumValue = [](GLenum t) { switch (t) { case GL_UNSIGNED_BYTE: return 1ULL << 8ULL; case GL_UNSIGNED_SHORT: return 1ULL << 16ULL; @@ -530,11 +539,9 @@ void RawTileDataReader::initialize() { case GL_HALF_FLOAT: return 1ULL; case GL_FLOAT: return 1ULL; case GL_DOUBLE: return 1ULL; - default: - ghoul_assert(false, "Unknown data type"); - throw ghoul::MissingCaseException(); + default: throw ghoul::MissingCaseException(); } - }(); + }(_initData.glType); _depthTransform.scale = static_cast( @@ -554,7 +561,8 @@ void RawTileDataReader::initialize() { } double tileLevelDifference = calculateTileLevelDifference( - _dataset, _initData.dimensions.x + _dataset, + _initData.dimensions.x ); const int numOverviews = _dataset->GetRasterBand(1)->GetOverviewCount(); diff --git a/modules/globebrowsing/src/ringscomponent.cpp b/modules/globebrowsing/src/ringscomponent.cpp index 19ef939018..6cec19f313 100644 --- a/modules/globebrowsing/src/ringscomponent.cpp +++ b/modules/globebrowsing/src/ringscomponent.cpp @@ -198,6 +198,8 @@ RingsComponent::RingsComponent(const ghoul::Dictionary& dictionary) } void RingsComponent::initialize() { + ZoneScoped + using ghoul::filesystem::File; addProperty(_enabled); @@ -257,6 +259,8 @@ bool RingsComponent::isReady() const { } void RingsComponent::initializeGL() { + ZoneScoped + compileShadowShader(); try { diff --git a/modules/globebrowsing/src/shadowcomponent.cpp b/modules/globebrowsing/src/shadowcomponent.cpp index c615d3a64b..598cf1fc3a 100644 --- a/modules/globebrowsing/src/shadowcomponent.cpp +++ b/modules/globebrowsing/src/shadowcomponent.cpp @@ -227,6 +227,8 @@ bool ShadowComponent::isReady() const { } void ShadowComponent::initializeGL() { + ZoneScoped + createDepthTexture(); createShadowFBO(); } diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index 1b7686a322..3e57d400d3 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -824,6 +824,13 @@ bool initialize(TileProvider& tp) { ghoul_assert(!tp.isInitialized, "TileProvider can only be initialized once."); + if (TileProvider::NumTileProviders > std::numeric_limits::max()) { + LERRORC( + "TileProvider", + "Number of tile providers exceeds 65535. Something will break soon" + ); + TileProvider::NumTileProviders = 0; + } tp.uniqueIdentifier = TileProvider::NumTileProviders++; if (TileProvider::NumTileProviders == std::numeric_limits::max()) { --TileProvider::NumTileProviders; diff --git a/modules/globebrowsing/src/tileprovider.h b/modules/globebrowsing/src/tileprovider.h index 8f6bcd4772..909380f0a0 100644 --- a/modules/globebrowsing/src/tileprovider.h +++ b/modules/globebrowsing/src/tileprovider.h @@ -76,7 +76,7 @@ struct TileProvider : public properties::PropertyOwner { std::string name; - unsigned int uniqueIdentifier = 0; + uint16_t uniqueIdentifier = 0; bool isInitialized = false; }; diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index ab9512c6c0..e637d25e42 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -161,6 +161,8 @@ namespace { namespace openspace { void FramebufferRenderer::initialize() { + ZoneScoped + LDEBUG("Initializing FramebufferRenderer"); HasGLDebugInfo = glbinding::Binding::ObjectLabel.isResolved() && diff --git a/src/scene/assetmanager.cpp b/src/scene/assetmanager.cpp index f93a278a6b..80e892309f 100644 --- a/src/scene/assetmanager.cpp +++ b/src/scene/assetmanager.cpp @@ -43,6 +43,8 @@ AssetManager::AssetManager(ghoul::lua::LuaState* state, std::string assetRootDir {} void AssetManager::initialize() { + ZoneScoped + _assetLoader.addAssetListener(this); _assetLoader.rootAsset().initialize(); } From 4f2d612abe3e54dd085d23759d9e860a2cec07b2 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 13:43:51 +0200 Subject: [PATCH 22/59] Only create RenderData if we actually want to render the Renderable --- modules/base/rendering/renderableplane.cpp | 10 ++++++++- .../rendering/renderableplaneimagelocal.cpp | 5 +++++ src/scene/scenegraphnode.cpp | 22 +++++++++---------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 02b55d8379..3437bbd97f 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -166,6 +167,8 @@ bool RenderablePlane::isReady() const { } void RenderablePlane::initializeGL() { + ZoneScoped + glGenVertexArrays(1, &_quad); // generate array glGenBuffers(1, &_vertexPositionBuffer); // generate buffer createPlane(); @@ -183,6 +186,8 @@ void RenderablePlane::initializeGL() { } void RenderablePlane::deinitializeGL() { + ZoneScoped + glDeleteVertexArrays(1, &_quad); _quad = 0; @@ -199,8 +204,9 @@ void RenderablePlane::deinitializeGL() { } void RenderablePlane::render(const RenderData& data, RendererTasks&) { - _shader->activate(); + ZoneScoped + _shader->activate(); _shader->setUniform("opacity", _opacity); glm::dvec3 objectPositionWorld = glm::dvec3( @@ -277,6 +283,8 @@ void RenderablePlane::bindTexture() {} void RenderablePlane::unbindTexture() {} void RenderablePlane::update(const UpdateData&) { + ZoneScoped + if (_shader->isDirty()) { _shader->rebuildFromFile(); } diff --git a/modules/base/rendering/renderableplaneimagelocal.cpp b/modules/base/rendering/renderableplaneimagelocal.cpp index 0d190356a2..a6d711a046 100644 --- a/modules/base/rendering/renderableplaneimagelocal.cpp +++ b/modules/base/rendering/renderableplaneimagelocal.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -172,6 +173,8 @@ void RenderablePlaneImageLocal::bindTexture() { } void RenderablePlaneImageLocal::update(const UpdateData& data) { + ZoneScoped + RenderablePlane::update(data); if (_textureIsDirty) { @@ -181,6 +184,8 @@ void RenderablePlaneImageLocal::update(const UpdateData& data) { } void RenderablePlaneImageLocal::loadTexture() { + ZoneScoped + if (!_texturePath.value().empty()) { ghoul::opengl::Texture* t = _texture; diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 7e7f679373..a9617799a0 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -489,17 +489,6 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) { return; } - RenderData newData = { - data.camera, - data.time, - data.renderBinMask, - { _worldPositionCached, _worldRotationCached, _worldScaleCached } - }; - - if (!isTimeFrameActive(data.time)) { - return; - } - const bool visible = _renderable && _renderable->isVisible() && _renderable->isReady() && _renderable->isEnabled() && _renderable->matchesRenderBinMask(data.renderBinMask); @@ -508,9 +497,20 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) { return; } + if (!isTimeFrameActive(data.time)) { + return; + } + { TracyGpuZone("Render") + RenderData newData = { + data.camera, + data.time, + data.renderBinMask, + { _worldPositionCached, _worldRotationCached, _worldScaleCached } + }; + _renderable->render(newData, tasks); if (_computeScreenSpaceValues) { computeScreenSpaceData(newData); From d4291163ba7a25899babe2e21bb443c7fd6e70d9 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 16:00:32 +0200 Subject: [PATCH 23/59] Move ColorTexture from RenderableModel to ModelGeometry --- data/assets/examples/globetranslation.asset | 12 +- .../missions/apollo/11/apollo11.asset | 12 +- .../solarsystem/missions/apollo/11/lem.asset | 4 +- .../missions/apollo/15/apollo15.asset | 4 +- .../missions/apollo/17/bouldersstation2.asset | 12 +- .../missions/apollo/17/bouldersstation6.asset | 12 +- .../missions/apollo/17/bouldersstation7.asset | 4 +- .../solarsystem/missions/apollo/17/lem.asset | 4 +- .../solarsystem/missions/dawn/dawn.asset | 12 +- .../solarsystem/missions/dawn/vesta.asset | 4 +- .../solarsystem/missions/gaia/gaia.asset | 4 +- .../solarsystem/missions/insight/edl.asset | 124 +++++----- .../solarsystem/missions/juno/juno.asset | 4 +- .../missions/messenger/messengerSC.asset | 20 +- .../missions/newhorizons/label.asset | 4 +- .../missions/newhorizons/model.asset | 4 +- .../missions/osirisrex/bennu.asset | 4 +- .../missions/osirisrex/model.asset | 12 +- .../missions/perseverance/model.asset | 223 +++++++++--------- .../missions/pioneer/pioneer10.asset | 4 +- .../missions/pioneer/pioneer11.asset | 4 +- .../solarsystem/missions/rosetta/67p.asset | 4 +- .../missions/rosetta/rosetta.asset | 52 ++-- .../missions/voyager/voyager1.asset | 8 +- .../missions/voyager/voyager2.asset | 8 +- data/assets/util/asset_helper.asset | 4 +- modules/base/rendering/modelgeometry.cpp | 55 ++++- modules/base/rendering/modelgeometry.h | 8 + modules/base/rendering/renderablemodel.cpp | 52 +--- modules/base/rendering/renderablemodel.h | 9 - .../rendering/renderablemodelprojection.cpp | 45 +--- .../rendering/renderablemodelprojection.h | 4 - 32 files changed, 350 insertions(+), 386 deletions(-) diff --git a/data/assets/examples/globetranslation.asset b/data/assets/examples/globetranslation.asset index 1ecfbefdc2..4f400883bd 100644 --- a/data/assets/examples/globetranslation.asset +++ b/data/assets/examples/globetranslation.asset @@ -34,9 +34,9 @@ local Example_Fixed_Height = { Body = "NEW HORIZONS", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/NewHorizonsCleanModel.obj" - }, - ColorTexture = textures .. "/NHTexture.jpg", + GeometryFile = models .. "/NewHorizonsCleanModel.obj", + ColorTexture = textures .. "/NHTexture.jpg" + } }, GUI = { Path = "/Example" @@ -59,9 +59,9 @@ local Example_Adaptive_Height = { Body = "NEW HORIZONS", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/NewHorizonsCleanModel.obj" - }, - ColorTexture = textures .. "/NHTexture.jpg", + GeometryFile = models .. "/NewHorizonsCleanModel.obj", + ColorTexture = textures .. "/NHTexture.jpg" + } }, GUI = { Path = "/Example" diff --git a/data/assets/scene/solarsystem/missions/apollo/11/apollo11.asset b/data/assets/scene/solarsystem/missions/apollo/11/apollo11.asset index c65cd3c47a..8fa2acf516 100644 --- a/data/assets/scene/solarsystem/missions/apollo/11/apollo11.asset +++ b/data/assets/scene/solarsystem/missions/apollo/11/apollo11.asset @@ -58,9 +58,9 @@ local Apollo11Model = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/Apollo_CSM_shrunk_rotated_xy_double_size.obj" + GeometryFile = models .. "/Apollo_CSM_shrunk_rotated_xy_double_size.obj", + ColorTexture = models .. "/gray.png" }, - ColorTexture = models .. "/gray.png", LightSources = asset_helper.getDefaultLightSources(sun_transforms.SolarSystemBarycenter.Identifier) }, GUI = { @@ -177,11 +177,11 @@ local Apollo11LemDescentModel = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = lem_model.modelFolder .. "/lmremoved.obj" + GeometryFile = lem_model.modelFolder .. "/lmremoved.obj", + ColorTexture = lem_model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg" }, SpecularIntensity = 0.0, RotationVector = { 273.750,28.0,309.85 }, - ColorTexture = lem_model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg", LightSources = asset_helper.getDefaultLightSources(sun_transforms.SolarSystemBarycenter.Identifier) }, GUI = { @@ -207,11 +207,11 @@ local Apollo11LemLandedModel = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = lem_model.modelFolder .. "/LM-2_ver2clean.obj" + GeometryFile = lem_model.modelFolder .. "/LM-2_ver2clean.obj", + ColorTexture = lem_model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg" }, SpecularIntensity = 0.0, RotationVector = { 273.750,28.0,309.85 }, - ColorTexture = lem_model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg", LightSources = asset_helper.getDefaultLightSources(sun_transforms.SolarSystemBarycenter.Identifier) }, GUI = { diff --git a/data/assets/scene/solarsystem/missions/apollo/11/lem.asset b/data/assets/scene/solarsystem/missions/apollo/11/lem.asset index 0ca61edef6..5186ed9057 100644 --- a/data/assets/scene/solarsystem/missions/apollo/11/lem.asset +++ b/data/assets/scene/solarsystem/missions/apollo/11/lem.asset @@ -38,10 +38,10 @@ local Apollo11LemModel = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = lem_model.modelFolder .. "/LM-2_ver2clean.obj" + GeometryFile = lem_model.modelFolder .. "/LM-2_ver2clean.obj", + ColorTexture = lem_model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg" }, RotationVector = { 91.044090,171.229706,111.666664 }, - ColorTexture = lem_model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg", LightSources = asset_helper.getDefaultLightSources(sun_transforms.SolarSystemBarycenter.Identifier) }, GUI = { diff --git a/data/assets/scene/solarsystem/missions/apollo/15/apollo15.asset b/data/assets/scene/solarsystem/missions/apollo/15/apollo15.asset index 770592ba8e..584a064313 100644 --- a/data/assets/scene/solarsystem/missions/apollo/15/apollo15.asset +++ b/data/assets/scene/solarsystem/missions/apollo/15/apollo15.asset @@ -66,9 +66,9 @@ local Apollo15 = { -- Geometry = { -- Type = "MultiModelGeometry", -- -- GeometryFile = models .. "/Apollo_Spacecraft.obj" --- GeometryFile = models .. "/Apollo_CSM_shrunk_rotated_xy_doubble_size.obj" +-- GeometryFile = models .. "/Apollo_CSM_shrunk_rotated_xy_doubble_size.obj", + -- ColorTexture = models .. "/gray.png" -- }, --- ColorTexture = models .. "/gray.png", -- LightSources = LightSources, -- DisableFaceCulling = true -- }, diff --git a/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation2.asset b/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation2.asset index f709f0bc2b..e14c5e7566 100644 --- a/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation2.asset +++ b/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation2.asset @@ -49,10 +49,10 @@ local Station2Boulder1Model = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/b1-v2.obj" + GeometryFile = models .. "/b1-v2.obj", + ColorTexture = models .. "/b1-v2_u1_v1.jpeg" }, RotationVector = { 243.243256 ,206.270264, 309.677429 }, - ColorTexture = models .. "/b1-v2_u1_v1.jpeg", LightSources = LightSources, PerformShading = false, DisableFaceCulling = true @@ -95,10 +95,10 @@ local Station2Boulder2Model = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/b2model.obj" + GeometryFile = models .. "/b2model.obj", + ColorTexture = models .. "/b2model_u1_v1.jpeg" }, RotationVector = { 66.162155, 7.783780, 114.193550 }, - ColorTexture = models .. "/b2model_u1_v1.jpeg", LightSources = LightSources, PerformShading = false, DisableFaceCulling = true @@ -141,10 +141,10 @@ local Station2Boulder3Model = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/b3model.obj" + GeometryFile = models .. "/b3model.obj", + ColorTexture = models .. "/b3model_u1_v1.jpeg" }, RotationVector = { 161.513519 ,243.243256, 65.806450 }, - ColorTexture = models .. "/b3model_u1_v1.jpeg", LightSources = LightSources, PerformShading = false, DisableFaceCulling = true diff --git a/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation6.asset b/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation6.asset index d013b8fea4..828c2b039b 100644 --- a/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation6.asset +++ b/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation6.asset @@ -60,10 +60,10 @@ local Station6Frag1Model = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/A17-S6-frag1.obj" + GeometryFile = models .. "/A17-S6-frag1.obj", + ColorTexture = models .. "/A17-S6-frag1.png" }, RotationVector = { 235.909088,165.000000,286.299194 }, - ColorTexture = models .. "/A17-S6-frag1.png", LightSources = LightSources, PerformShading = false, DisableFaceCulling = true @@ -107,10 +107,10 @@ local Station6Frag2Model = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/station6_boulder_frag2.obj" + GeometryFile = models .. "/station6_boulder_frag2.obj", + ColorTexture = models .. "/frag2crop_u1_v1.jpeg" }, RotationVector = { 336.959991,210.239990,325.984253 }, - ColorTexture = models .. "/frag2crop_u1_v1.jpeg", LightSources = LightSources, PerformShading = false, DisableFaceCulling = true, @@ -142,10 +142,10 @@ local Station6Frag3Model = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/station6_boulder_frag3.obj" + GeometryFile = models .. "/station6_boulder_frag3.obj", + ColorTexture = models .. "/frag3crop_u1_v1.jpeg" }, RotationVector = { 293.181824,255.000000,4.090910 }, - ColorTexture = models .. "/frag3crop_u1_v1.jpeg", LightSources = LightSources, PerformShading = false, DisableFaceCulling = true diff --git a/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation7.asset b/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation7.asset index d2e9c5146c..6385768d1d 100644 --- a/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation7.asset +++ b/data/assets/scene/solarsystem/missions/apollo/17/bouldersstation7.asset @@ -49,10 +49,10 @@ local Station7BoulderModel = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/b7model.obj" + GeometryFile = models .. "/b7model.obj", + ColorTexture = models .. "/b7model_u1_v1.jpeg" }, RotationVector = { 1.945950,274.378387,212.903214 }, - ColorTexture = models .. "/b7model_u1_v1.jpeg", LightSources = LightSources, PerformShading = false, DisableFaceCulling = true diff --git a/data/assets/scene/solarsystem/missions/apollo/17/lem.asset b/data/assets/scene/solarsystem/missions/apollo/17/lem.asset index 50f81a1693..9c901a59a2 100644 --- a/data/assets/scene/solarsystem/missions/apollo/17/lem.asset +++ b/data/assets/scene/solarsystem/missions/apollo/17/lem.asset @@ -36,11 +36,11 @@ local Apollo17LemModel = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = model.modelFolder .. "/LM-2_ver2clean.obj" + GeometryFile = model.modelFolder .. "/LM-2_ver2clean.obj", + ColorTexture = model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg" }, SpecularIntensity = 0.0, RotationVector = { 110.255219,171.229706,126.666664 }, - ColorTexture = model.modelFolder .. "/LM-2_ver2clean_u1_v1.jpeg", LightSources = asset_helper.getDefaultLightSources(sun_transforms.SolarSystemBarycenter.Identifier) }, GUI = { diff --git a/data/assets/scene/solarsystem/missions/dawn/dawn.asset b/data/assets/scene/solarsystem/missions/dawn/dawn.asset index e7fc3a3747..5fefe46052 100644 --- a/data/assets/scene/solarsystem/missions/dawn/dawn.asset +++ b/data/assets/scene/solarsystem/missions/dawn/dawn.asset @@ -652,9 +652,9 @@ local Dawn = { Body = "DAWN", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/mainbodydawn.obj" + GeometryFile = models .. "/mainbodydawn.obj", + ColorTexture = textures .. "/gray.png" }, - ColorTexture = textures .. "/gray.png", LightSources = LightSources }, GUI = { @@ -684,9 +684,9 @@ local DawnSolarArray1 = { Body = "DAWN", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/solarpanelleft.obj" + GeometryFile = models .. "/solarpanelleft.obj", + ColorTexture = textures .. "/gray.png" }, - ColorTexture = textures .. "/gray.png", LightSources = LightSources }, GUI = { @@ -715,9 +715,9 @@ local DawnSolarArray2 = { Body = "DAWN", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/solarpanelright.obj" + GeometryFile = models .. "/solarpanelright.obj", + ColorTexture = textures .. "/gray.png" }, - ColorTexture = textures .. "/gray.png", LightSources = LightSources }, GUI = { diff --git a/data/assets/scene/solarsystem/missions/dawn/vesta.asset b/data/assets/scene/solarsystem/missions/dawn/vesta.asset index 75c1ed63f1..2d555b6834 100644 --- a/data/assets/scene/solarsystem/missions/dawn/vesta.asset +++ b/data/assets/scene/solarsystem/missions/dawn/vesta.asset @@ -47,10 +47,10 @@ local Vesta = { Type = "RenderableModelProjection", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/VestaComet_5000.obj" + GeometryFile = models .. "/VestaComet_5000.obj", + ColorTexture = textures .. "/dummy.jpg" }, BoundingSphereRadius = 10.0, - ColorTexture = textures .. "/dummy.jpg", Projection = { Sequence = images, SequenceType = "image-sequence", diff --git a/data/assets/scene/solarsystem/missions/gaia/gaia.asset b/data/assets/scene/solarsystem/missions/gaia/gaia.asset index b5c6d6a18d..55de00a894 100644 --- a/data/assets/scene/solarsystem/missions/gaia/gaia.asset +++ b/data/assets/scene/solarsystem/missions/gaia/gaia.asset @@ -41,9 +41,9 @@ local Gaia = { Body = "GAIA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = model .. "/gaia.obj" + GeometryFile = model .. "/gaia.obj", + ColorTexture = textures .. "/gaia-baked.png" }, - ColorTexture = textures .. "/gaia-baked.png", LightSources = { { Type = "SceneGraphLightSource", diff --git a/data/assets/scene/solarsystem/missions/insight/edl.asset b/data/assets/scene/solarsystem/missions/insight/edl.asset index 5ede98786a..62552b57f7 100644 --- a/data/assets/scene/solarsystem/missions/insight/edl.asset +++ b/data/assets/scene/solarsystem/missions/insight/edl.asset @@ -169,9 +169,9 @@ local Insight_Entry_CapsuleA = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_cruise_cone .. "/cruise_insight_doubleside2_newcapsule_diffuse.obj" + GeometryFile = models_cruise_cone .. "/cruise_insight_doubleside2_newcapsule_diffuse.obj", + ColorTexture = models_cruise_cone .. "/insight_newcapsule_diffuse.jpg" }, - ColorTexture = models_cruise_cone .. "/insight_newcapsule_diffuse.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -194,9 +194,9 @@ local Insight_Entry_Capsule_Ring = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_cruise_cone .. "/insight_cruise_cone_ring_foil_gold.obj" + GeometryFile = models_cruise_cone .. "/insight_cruise_cone_ring_foil_gold.obj", + ColorTexture = models_cruise_cone .. "/foil_gold_ramp.png" }, - ColorTexture = models_cruise_cone .. "/foil_gold_ramp.png", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -219,9 +219,9 @@ local Insight_Entry_Capsule_Plugs = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_cruise_cone .. "/insight_cruise_cone_capsule_diffuse.obj" + GeometryFile = models_cruise_cone .. "/insight_cruise_cone_capsule_diffuse.obj", + ColorTexture = models_cruise_cone .. "/insight_capsule_diffuse.png" }, - ColorTexture = models_cruise_cone .. "/insight_capsule_diffuse.png", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -244,9 +244,9 @@ local Insight_Entry_Heatshield = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_cruise_cone .. "/insight_cruise_heatshield_foil_gold.obj" + GeometryFile = models_cruise_cone .. "/insight_cruise_heatshield_foil_gold.obj", + ColorTexture = models_cruise_cone .. "/foil_gold_ramp.png" }, - ColorTexture = models_cruise_cone .. "/foil_gold_ramp.png", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -269,9 +269,9 @@ local Insight_Parachute_0 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_chutes .. "/insight_chute_frame01_diff1.obj" + GeometryFile = models_chutes .. "/insight_chute_frame01_diff1.obj", + ColorTexture = models_chutes .. "/chute_diff.png" }, - ColorTexture = models_chutes .. "/chute_diff.png", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -294,9 +294,9 @@ local Insight_Parachute_Cords_0 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_chutes .. "/insight_chute_frame01_cords1.obj" + GeometryFile = models_chutes .. "/insight_chute_frame01_cords1.obj", + ColorTexture = models_chutes .. "/foil_gold_ramp.png" }, - ColorTexture = models_chutes .. "/foil_gold_ramp.png", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -319,9 +319,9 @@ local Insight_Parachute_20 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_chutes .. "/insight_chute_frame20_diff1.obj" + GeometryFile = models_chutes .. "/insight_chute_frame20_diff1.obj", + ColorTexture = models_chutes .. "/chute_diff.png" }, - ColorTexture = models_chutes .. "/chute_diff.png", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -344,9 +344,9 @@ local Insight_Parachute_Cords_20 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_chutes .. "/insight_chute_frame20_cords1.obj" + GeometryFile = models_chutes .. "/insight_chute_frame20_cords1.obj", + ColorTexture = models_chutes .. "/foil_gold_ramp.png" }, - ColorTexture = models_chutes .. "/foil_gold_ramp.png", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -369,9 +369,9 @@ local Insight_Parachute_40 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_chutes .. "/chute_doubleside_frame40_diff.obj" + GeometryFile = models_chutes .. "/chute_doubleside_frame40_diff.obj", + ColorTexture = models_chutes .. "/chute_diff.png" }, - ColorTexture = models_chutes .. "/chute_diff.png", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -394,9 +394,9 @@ local Insight_Parachute_Cords_40 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_chutes .. "/insight_chute_frame40_cords1.obj" + GeometryFile = models_chutes .. "/insight_chute_frame40_cords1.obj", + ColorTexture = models_chutes .. "/foil_gold_ramp.png" }, - ColorTexture = models_chutes .. "/foil_gold_ramp.png", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -419,9 +419,9 @@ local Insight_Lander_A001 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO01.obj" + GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO01.obj", + ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_01.jpg" }, - ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_01.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -444,9 +444,9 @@ local Insight_Lander_A002 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO02.obj" + GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO02.obj", + ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_02.jpg" }, - ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_02.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -469,9 +469,9 @@ local Insight_Lander_A003 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO03.obj" + GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO03.obj", + ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_03.jpg" }, - ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_03.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -494,9 +494,9 @@ local Insight_Lander_A004 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO04.obj" + GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO04.obj", + ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_04.jpg" }, - ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_04.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -519,9 +519,9 @@ local Insight_Lander_A005 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO05.obj" + GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO05.obj", + ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_05.jpg" }, - ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_05.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -544,9 +544,9 @@ local Insight_Lander_A006 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO06.obj" + GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO06.obj", + ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_06.jpg" }, - ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_06.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -569,9 +569,9 @@ local Insight_Lander_A007 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO07.obj" + GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO07.obj", + ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_07.jpg" }, - ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_07.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -594,9 +594,9 @@ local Insight_Lander_A008 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO08.obj" + GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_AO08.obj", + ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_08.jpg" }, - ColorTexture = models_lander_lander_deck .. "/InSIGHT_AO_08.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -619,9 +619,9 @@ local Insight_Lander_foil1 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_foil1.obj" + GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_foil1.obj", + ColorTexture = models_lander_lander_deck .. "/foil_silver_ramp.jpg" }, - ColorTexture = models_lander_lander_deck .. "/foil_silver_ramp.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -644,9 +644,9 @@ local Insight_Lander_Tex01 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_tex01.obj" + GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_tex01.obj", + ColorTexture = models_lander_lander_deck .. "/InSIGHT_tex_01.jpg" }, - ColorTexture = models_lander_lander_deck .. "/InSIGHT_tex_01.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -669,9 +669,9 @@ local Insight_Lander_Tex02 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_tex02.obj" + GeometryFile = models_lander_lander_deck .. "/insight_lander_deck_tex02.obj", + ColorTexture = models_lander_lander_deck .. "/InSIGHT_tex_02.jpg" }, - ColorTexture = models_lander_lander_deck .. "/InSIGHT_tex_02.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -694,9 +694,9 @@ local Insight_Legs_Stowed_tex = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_legs_stow .. "/insight_lander_legs_stow_tex01.obj" + GeometryFile = models_lander_legs_stow .. "/insight_lander_legs_stow_tex01.obj", + ColorTexture = models_lander_legs_stow .. "/InSIGHT_tex_01.jpg" }, - ColorTexture = models_lander_legs_stow .. "/InSIGHT_tex_01.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -719,9 +719,9 @@ local Insight_Legs_Stowed_AO06 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_legs_stow .. "/insight_lander_legs_stow_AO06.obj" + GeometryFile = models_lander_legs_stow .. "/insight_lander_legs_stow_AO06.obj", + ColorTexture = models_lander_legs_stow .. "/InSIGHT_AO_06.jpg" }, - ColorTexture = models_lander_legs_stow .. "/InSIGHT_AO_06.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -744,9 +744,9 @@ local Insight_Legs_Deployed_tex = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_legs_deploy .. "/insight_lander_legs_deploy_tex01.obj" + GeometryFile = models_lander_legs_deploy .. "/insight_lander_legs_deploy_tex01.obj", + ColorTexture = models_lander_legs_deploy .. "/InSIGHT_tex_01.jpg" }, - ColorTexture = models_lander_legs_deploy .. "/InSIGHT_tex_01.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -769,9 +769,9 @@ local Insight_Legs_Deployed_AO06 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_legs_deploy .. "/insight_lander_legs_deploy_AO06.obj" + GeometryFile = models_lander_legs_deploy .. "/insight_lander_legs_deploy_AO06.obj", + ColorTexture = models_lander_legs_deploy .. "/InSIGHT_AO_06.jpg" }, - ColorTexture = models_lander_legs_deploy .. "/InSIGHT_AO_06.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -794,9 +794,9 @@ local Insight_Panels_Stowed_tex = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_panels_stow .. "/insight_lander_panels_stow_tex01.obj" + GeometryFile = models_lander_panels_stow .. "/insight_lander_panels_stow_tex01.obj", + ColorTexture = models_lander_panels_stow .. "/InSIGHT_tex_01.jpg" }, - ColorTexture = models_lander_panels_stow .. "/InSIGHT_tex_01.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -819,9 +819,9 @@ local Insight_Panels_Stowed_tex2 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_panels_stow .. "/insight_lander_panels_stow_tex02.obj" + GeometryFile = models_lander_panels_stow .. "/insight_lander_panels_stow_tex02.obj", + ColorTexture = models_lander_panels_stow .. "/InSIGHT_tex_02.jpg" }, - ColorTexture = models_lander_panels_stow .. "/InSIGHT_tex_02.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -844,9 +844,9 @@ local Insight_Panels_Stowed_AO01 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_panels_stow .. "/insight_lander_panels_stow_AO01.obj" + GeometryFile = models_lander_panels_stow .. "/insight_lander_panels_stow_AO01.obj", + ColorTexture = models_lander_panels_stow .. "/InSIGHT_AO_01.jpg" }, - ColorTexture = models_lander_panels_stow .. "/InSIGHT_AO_01.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -869,9 +869,9 @@ local Insight_Panels_Deployed_tex = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_panels_deploy .. "/insight_lander_panels_deploy_tex01.obj" + GeometryFile = models_lander_panels_deploy .. "/insight_lander_panels_deploy_tex01.obj", + ColorTexture = models_lander_panels_deploy .. "/InSIGHT_tex_01.jpg" }, - ColorTexture = models_lander_panels_deploy .. "/InSIGHT_tex_01.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -894,9 +894,9 @@ local Insight_Panels_Deployed_tex2 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_panels_deploy .. "/insight_lander_panels_deploy_tex02.obj" + GeometryFile = models_lander_panels_deploy .. "/insight_lander_panels_deploy_tex02.obj", + ColorTexture = models_lander_panels_deploy .. "/InSIGHT_tex_02.jpg" }, - ColorTexture = models_lander_panels_deploy .. "/InSIGHT_tex_02.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, @@ -919,9 +919,9 @@ local Insight_Panels_Deployed_AO06 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models_lander_panels_deploy .. "/insight_lander_panels_deploy_AO01.obj" + GeometryFile = models_lander_panels_deploy .. "/insight_lander_panels_deploy_AO01.obj", + ColorTexture = models_lander_panels_deploy .. "/InSIGHT_AO_01.jpg" }, - ColorTexture = models_lander_panels_deploy .. "/InSIGHT_AO_01.jpg", ModelTransform = RotationMatrix, LightSources = LightSources, }, diff --git a/data/assets/scene/solarsystem/missions/juno/juno.asset b/data/assets/scene/solarsystem/missions/juno/juno.asset index 78d0296a6f..7f3d8412c3 100644 --- a/data/assets/scene/solarsystem/missions/juno/juno.asset +++ b/data/assets/scene/solarsystem/missions/juno/juno.asset @@ -159,9 +159,9 @@ local Juno = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = model .. "/Juno.obj" + GeometryFile = model .. "/Juno.obj", + ColorTexture = textures .. "/gray.png" }, - ColorTexture = textures .. "/gray.png", ModelTransform = RotationMatrix, LightSources = assetHelper.getDefaultLightSources(sunTransforms.SolarSystemBarycenter.Identifier) }, diff --git a/data/assets/scene/solarsystem/missions/messenger/messengerSC.asset b/data/assets/scene/solarsystem/missions/messenger/messengerSC.asset index 70861f014e..f78d1f3655 100644 --- a/data/assets/scene/solarsystem/missions/messenger/messengerSC.asset +++ b/data/assets/scene/solarsystem/missions/messenger/messengerSC.asset @@ -94,9 +94,9 @@ local MessengerProbeBlack = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MessengerProbe_black.obj" + GeometryFile = models .. "/MessengerProbe_black.obj", + ColorTexture = models .. "/Tex_black.png" }, - ColorTexture = models .. "/Tex_black.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -113,9 +113,9 @@ local MessengerProbeFoil = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MessengerProbe_foil.obj" + GeometryFile = models .. "/MessengerProbe_foil.obj", + ColorTexture = models .. "/foil_n2.png" }, - ColorTexture = models .. "/foil_n2.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -132,9 +132,9 @@ local MessengerProbeHeatShield = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MessengerProbe_heatShield.obj" + GeometryFile = models .. "/MessengerProbe_heatShield.obj", + ColorTexture = models .. "/AO_heatshield4.png" }, - ColorTexture = models .. "/AO_heatshield4.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -151,9 +151,9 @@ local MessengerProbeMetal = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MessengerProbe_metal.obj" + GeometryFile = models .. "/MessengerProbe_metal.obj", + ColorTexture = models .. "/Tex_grey.png" }, - ColorTexture = models .. "/Tex_grey.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -171,9 +171,9 @@ local MessengerProbePanels = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MessengerProbe_panels.obj" + GeometryFile = models .. "/MessengerProbe_panels.obj", + ColorTexture = models .. "/Messenger_tex.png" }, - ColorTexture = models .. "/Messenger_tex.png", ModelTransform = RotationMatrix, LightSources = LightSources }, diff --git a/data/assets/scene/solarsystem/missions/newhorizons/label.asset b/data/assets/scene/solarsystem/missions/newhorizons/label.asset index 8353a01be9..69267f9f5f 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/label.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/label.asset @@ -16,9 +16,9 @@ local Labels = { Body = "NEW HORIZONS", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/Labels.obj" + GeometryFile = models .. "/Labels.obj", + ColorTexture = textures .. "/labels.png" }, - ColorTexture = textures .. "/labels.png", AmbientIntensity = 0.8 }, GUI = { diff --git a/data/assets/scene/solarsystem/missions/newhorizons/model.asset b/data/assets/scene/solarsystem/missions/newhorizons/model.asset index 57b6d401d8..b5b95ba870 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/model.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/model.asset @@ -24,9 +24,9 @@ local NewHorizons = { Body = "NEW HORIZONS", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/NewHorizonsCleanModel.obj" + GeometryFile = models .. "/NewHorizonsCleanModel.obj", + ColorTexture = textures .. "/NHTexture.jpg" }, - ColorTexture = textures .. "/NHTexture.jpg", AmbientIntensity = 0.0, DiffuseIntensity = 1.0, SpecularIntensity = 1.0, diff --git a/data/assets/scene/solarsystem/missions/osirisrex/bennu.asset b/data/assets/scene/solarsystem/missions/osirisrex/bennu.asset index a935cc6fcf..c6c5856413 100644 --- a/data/assets/scene/solarsystem/missions/osirisrex/bennu.asset +++ b/data/assets/scene/solarsystem/missions/osirisrex/bennu.asset @@ -36,9 +36,9 @@ local Bennu = { Body = BENNU_BODY, Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/BennuTextured.obj" + GeometryFile = models .. "/BennuTextured.obj", + ColorTexture = textures .. "/gray.png" }, - ColorTexture = textures .. "/gray.png", Projection = { Sequence = asset.localResource('InstrumentTimes'), SequenceType = "instrument-times", diff --git a/data/assets/scene/solarsystem/missions/osirisrex/model.asset b/data/assets/scene/solarsystem/missions/osirisrex/model.asset index 30a81b344c..b383470092 100644 --- a/data/assets/scene/solarsystem/missions/osirisrex/model.asset +++ b/data/assets/scene/solarsystem/missions/osirisrex/model.asset @@ -218,9 +218,9 @@ local OsirisRex = { Body = "OSIRIS-REX", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/orx_base_resized_12_sep_2016.obj" + GeometryFile = models .. "/orx_base_resized_12_sep_2016.obj", + ColorTexture = textures .. "/osirisTex.png" }, - ColorTexture = textures .. "/osirisTex.png", LightSources = LightSources }, GUI = { @@ -248,9 +248,9 @@ local PolyCam = { Body = "OSIRIS-REX", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/orx_polycam_resized_12_sep_2016.obj" + GeometryFile = models .. "/orx_polycam_resized_12_sep_2016.obj", + ColorTexture = textures .. "/osirisTex.png" }, - ColorTexture = textures .. "/osirisTex.png", LightSources = LightSources }, GUI = { @@ -267,9 +267,9 @@ local Rexis = { Body = "OSIRIS-REX", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/orx_rexis_resized_12_sep_2016.obj" + GeometryFile = models .. "/orx_rexis_resized_12_sep_2016.obj", + ColorTexture = textures .. "/osirisTex.png" }, - ColorTexture = textures .. "/osirisTex.png", LightSources = LightSources }, Transform = { diff --git a/data/assets/scene/solarsystem/missions/perseverance/model.asset b/data/assets/scene/solarsystem/missions/perseverance/model.asset index 24c0c37d9d..95554d5a6e 100644 --- a/data/assets/scene/solarsystem/missions/perseverance/model.asset +++ b/data/assets/scene/solarsystem/missions/perseverance/model.asset @@ -63,9 +63,9 @@ local Body = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_BODY_new_1.obj" + GeometryFile = models .. "/MSL_BODY_new_1.obj", + ColorTexture = textures .. "/tex_01.png" }, - ColorTexture = textures .. "/tex_01.png", LightSources = LightSources, PerformShading = false, }, @@ -85,9 +85,9 @@ local Body_detail = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_BODY_new_1_new_detail.obj" + GeometryFile = models .. "/MSL_BODY_new_1_new_detail.obj", + ColorTexture = textures .. "/tex_01.png" }, - ColorTexture = textures .. "/tex_01.png", LightSources = LightSources, PerformShading = false, }, @@ -106,9 +106,9 @@ local Body_staticParts_1 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_BODY_new_2.obj" + GeometryFile = models .. "/MSL_BODY_new_2.obj", + ColorTexture = textures .. "/tex_02.png" }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false }, @@ -126,9 +126,9 @@ local Body_staticParts_2 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_BODY_new_3.obj" + GeometryFile = models .. "/MSL_BODY_new_3.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -146,9 +146,9 @@ local Body_staticParts_3 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_BODY_new_4.obj" + GeometryFile = models .. "/MSL_BODY_new_4.obj", + ColorTexture = textures .. "/tex_04.png" }, - ColorTexture = textures .. "/tex_04.png", LightSources = LightSources, PerformShading = false }, @@ -166,9 +166,9 @@ local Body_staticParts_4 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_BODY_new_5.obj" + GeometryFile = models .. "/MSL_BODY_new_5.obj", + ColorTexture = textures .. "/tex_05.png" }, - ColorTexture = textures .. "/tex_05.png", LightSources = LightSources, PerformShading = false }, @@ -186,9 +186,9 @@ local Body_staticParts_5 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_BODY_new_A0.obj" + GeometryFile = models .. "/MSL_BODY_new_A0.obj", + ColorTexture = textures .. "/parts_AO.png" }, - ColorTexture = textures .. "/parts_AO.png", LightSources = LightSources, PerformShading = false }, @@ -207,9 +207,9 @@ local RA_Shoulder_AZ = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_SHOULDER_AZ_new.obj" + GeometryFile = models .. "/MSL_RA_SHOULDER_AZ_new.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -227,9 +227,9 @@ local RA_Shoulder_AZ_detail_1 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_SHOULDER_AZ_detail_1.obj" + GeometryFile = models .. "/MSL_RA_SHOULDER_AZ_detail_1.obj", + ColorTexture = textures .. "/tex_05.png" }, - ColorTexture = textures .. "/tex_05.png", LightSources = LightSources, PerformShading = false }, @@ -247,9 +247,9 @@ local RA_Shoulder_AZ_detail_2 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_SHOULDER_AZ_detail_2.obj" + GeometryFile = models .. "/MSL_RA_SHOULDER_AZ_detail_2.obj", + ColorTexture = textures .. "/tex_01.png" }, - ColorTexture = textures .. "/tex_01.png", LightSources = LightSources, PerformShading = false }, @@ -268,9 +268,9 @@ local RA_Shoulder_EL_1 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_SHOULDER_EL_1.obj" + GeometryFile = models .. "/MSL_RA_SHOULDER_EL_1.obj", + ColorTexture = textures .. "/tex_01.png" }, - ColorTexture = textures .. "/tex_01.png", LightSources = LightSources, PerformShading = false }, @@ -289,9 +289,9 @@ local RA_Shoulder_EL_detail_1 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_SHOULDER_EL_detail_1.obj" + GeometryFile = models .. "/MSL_RA_SHOULDER_EL_detail_1.obj", + ColorTexture = textures .. "/tex_04.png" }, - ColorTexture = textures .. "/tex_04.png", LightSources = LightSources, PerformShading = false }, @@ -309,9 +309,9 @@ local RA_Shoulder_EL_detail_2 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_SHOULDER_EL_detail_2.obj" + GeometryFile = models .. "/MSL_RA_SHOULDER_EL_detail_2.obj", + ColorTexture = textures .. "/tex_05.png" }, - ColorTexture = textures .. "/tex_05.png", LightSources = LightSources, PerformShading = false }, @@ -331,9 +331,9 @@ local RA_Shoulder_EL_2 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_SHOULDER_EL_2.obj" + GeometryFile = models .. "/MSL_RA_SHOULDER_EL_2.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -352,9 +352,9 @@ local RA_Elbow_1 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_ELBOW_1.obj" + GeometryFile = models .. "/MSL_RA_ELBOW_1.obj", + ColorTexture = textures .. "/tex_01.png" }, - ColorTexture = textures .. "/tex_01.png", LightSources = LightSources, PerformShading = false }, @@ -372,9 +372,9 @@ local RA_Elbow_detail_1 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_ELBOW_detail_1.obj" + GeometryFile = models .. "/MSL_RA_ELBOW_detail_1.obj", + ColorTexture = textures .. "/tex_04.png", }, - ColorTexture = textures .. "/tex_04.png", LightSources = LightSources, PerformShading = false }, @@ -392,9 +392,9 @@ local RA_Elbow_detail_2 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_ELBOW_detail_2.obj" + GeometryFile = models .. "/MSL_RA_ELBOW_detail_2.obj", + ColorTexture = textures .. "/tex_05.png" }, - ColorTexture = textures .. "/tex_05.png", LightSources = LightSources, PerformShading = false }, @@ -413,9 +413,9 @@ local RA_Elbow_2 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_ELBOW_2.obj" + GeometryFile = models .. "/MSL_RA_ELBOW_2.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -435,9 +435,9 @@ local RA_Wrist = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_TURRET_new_1.obj" + GeometryFile = models .. "/MSL_RA_TURRET_new_1.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -455,9 +455,9 @@ local RA_Wrist_details = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_TURRET_new_1_details.obj" + GeometryFile = models .. "/MSL_RA_TURRET_new_1_details.obj", + ColorTexture = textures .. "/tex_01.png" }, - ColorTexture = textures .. "/tex_01.png", LightSources = LightSources, PerformShading = false }, @@ -476,9 +476,9 @@ local RA_Turret = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_TURRET_new_2.obj" + GeometryFile = models .. "/MSL_RA_TURRET_new_2.obj", + ColorTexture = textures .. "/tex_04.png" }, - ColorTexture = textures .. "/tex_04.png", LightSources = LightSources, PerformShading = false }, @@ -497,9 +497,9 @@ local RA_Turret_details_1 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_TURRET_new_2_detail_1.obj" + GeometryFile = models .. "/MSL_RA_TURRET_new_2_detail_1.obj", + ColorTexture = textures .. "/tex_05.png" }, - ColorTexture = textures .. "/tex_05.png", LightSources = LightSources, PerformShading = false }, @@ -517,9 +517,9 @@ local RA_Turret_details_2 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RA_TURRET_new_2_detail_2.obj" + GeometryFile = models .. "/MSL_RA_TURRET_new_2_detail_2.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -538,10 +538,9 @@ local RSM_root = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RSM_ROOT.obj" - + GeometryFile = models .. "/MSL_RSM_ROOT.obj", + ColorTexture = textures .. "/tex_04.png" }, - ColorTexture = textures .. "/tex_04.png", LightSources = LightSources, PerformShading = false }, @@ -559,9 +558,9 @@ local RSM_AZ = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RSM_AZ.obj" + GeometryFile = models .. "/MSL_RSM_AZ.obj", + ColorTexture = textures .. "/tex_04.png" }, - ColorTexture = textures .. "/tex_04.png", LightSources = LightSources, PerformShading = false }, @@ -579,9 +578,9 @@ local RSM_EL = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_RSM_EL.obj" + GeometryFile = models .. "/MSL_RSM_EL.obj", + ColorTexture = textures .. "/tex_04.png" }, - ColorTexture = textures .. "/tex_04.png", LightSources = LightSources, PerformShading = false }, @@ -600,9 +599,9 @@ local HGA_AZ = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_HGA_AZ_0ANGLE.obj" + GeometryFile = models .. "/MSL_HGA_AZ_0ANGLE.obj", + ColorTexture = textures .. "/tex_02.png" }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false }, @@ -620,9 +619,9 @@ local HGA_EL = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_HGA_EL.obj" + GeometryFile = models .. "/MSL_HGA_EL.obj", + ColorTexture = textures .. "/tex_02.png" }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false }, @@ -641,9 +640,9 @@ local SAM_Cover_1 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_SAM_FIXED_COVER_1.obj" + GeometryFile = models .. "/MSL_SAM_FIXED_COVER_1.obj", + ColorTexture = textures .. "/MSLTextureTest.png" }, - ColorTexture = textures .. "/MSLTextureTest.png", LightSources = LightSources, PerformShading = false }, @@ -661,9 +660,9 @@ local SAM_Cover_2 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_SAM_FIXED_COVER_2.obj" + GeometryFile = models .. "/MSL_SAM_FIXED_COVER_2.obj", + ColorTexture = textures .. "/MSLTextureTest.png" }, - ColorTexture = textures .. "/MSLTextureTest.png", LightSources = LightSources, PerformShading = false }, @@ -681,9 +680,9 @@ local CHEMIN_Bottom = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_CHEMIN.obj" + GeometryFile = models .. "/MSL_CHEMIN.obj", + ColorTexture = textures .. "/MSLTextureTest.png" }, - ColorTexture = textures .. "/MSLTextureTest.png", LightSources = LightSources, PerformShading = false }, @@ -702,9 +701,9 @@ local Wheel_Base = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_BASE.obj" + GeometryFile = models .. "/MSL_WHEEL_BASE.obj", + ColorTexture = textures .. "/tex_02.png" }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false }, @@ -721,9 +720,9 @@ local Wheel_Base_2 = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_BASE_2.obj" + GeometryFile = models .. "/MSL_WHEEL_BASE_2.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -742,9 +741,9 @@ local Wheel_Leg_1_L = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_LEG_1_L.obj" + GeometryFile = models .. "/MSL_WHEEL_LEG_1_L.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -762,9 +761,9 @@ local Wheel_Leg_1A_L_detail = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_LEG_1A_L_detail.obj" + GeometryFile = models .. "/MSL_WHEEL_LEG_1A_L_detail.obj", + ColorTexture = textures .. "/tex_05.png" }, - ColorTexture = textures .. "/tex_05.png", LightSources = LightSources, PerformShading = false }, @@ -782,9 +781,9 @@ local Wheel_Leg_1B_L_detail = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_LEG_1B_L_detail.obj" + GeometryFile = models .. "/MSL_WHEEL_LEG_1B_L_detail.obj", + ColorTexture = textures .. "/tex_05.png" }, - ColorTexture = textures .. "/tex_05.png", LightSources = LightSources, PerformShading = false }, @@ -802,9 +801,9 @@ local Wheel_Leg_2_L = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_LEG_2_L_new.obj" + GeometryFile = models .. "/MSL_WHEEL_LEG_2_L_new.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -822,9 +821,9 @@ local Wheel_Wrist_F_L = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_WRIST_F_L.obj" + GeometryFile = models .. "/MSL_WHEEL_WRIST_F_L.obj", + ColorTexture = textures .. "/tex_02.png" }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false }, @@ -842,9 +841,9 @@ local Wheel_Wrist_hub_F_L = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_WRIST_1B_F_L.obj" + GeometryFile = models .. "/MSL_WHEEL_WRIST_1B_F_L.obj", + ColorTexture = textures .. "/tex_02.png" }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false }, @@ -862,9 +861,9 @@ local Wheel_F_L = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_L.obj" + GeometryFile = models .. "/MSL_WHEEL_L.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -882,9 +881,9 @@ local Wheel_C_L = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_L.obj" + GeometryFile = models .. "/MSL_WHEEL_L.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -902,9 +901,9 @@ local Wheel_Wrist_B_L = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_WRIST_B_L.obj" + GeometryFile = models .. "/MSL_WHEEL_WRIST_B_L.obj", + ColorTexture = textures .. "/tex_02.png" }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false }, @@ -922,9 +921,9 @@ local Wheel_Wrist_hub_B_L = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_WRIST_1B_B_L.obj" + GeometryFile = models .. "/MSL_WHEEL_WRIST_1B_B_L.obj", + ColorTexture = textures .. "/tex_02.png" }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false, }, @@ -943,9 +942,9 @@ local Wheel_B_L = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_L.obj" + GeometryFile = models .. "/MSL_WHEEL_L.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -964,9 +963,9 @@ local Wheel_Leg_1_R = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_LEG_1_R.obj" + GeometryFile = models .. "/MSL_WHEEL_LEG_1_R.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -984,9 +983,9 @@ local Wheel_Leg_1A_R_detail = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_LEG_1A_R_detail.obj" + GeometryFile = models .. "/MSL_WHEEL_LEG_1A_R_detail.obj", + ColorTexture = textures .. "/tex_05.png" }, - ColorTexture = textures .. "/tex_05.png", LightSources = LightSources, PerformShading = false }, @@ -1004,9 +1003,9 @@ local Wheel_Leg_1B_R_detail = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_LEG_1B_R_detail.obj" + GeometryFile = models .. "/MSL_WHEEL_LEG_1B_R_detail.obj", + ColorTexture = textures .. "/tex_05.png" }, - ColorTexture = textures .. "/tex_05.png", LightSources = LightSources, PerformShading = false }, @@ -1024,9 +1023,9 @@ local Wheel_Leg_2_R = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_LEG_2_R_new.obj" + GeometryFile = models .. "/MSL_WHEEL_LEG_2_R_new.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -1044,10 +1043,10 @@ local Wheel_Wrist_F_R = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_WRIST_F_R.obj" - --GeometryFile = models .. "/MSL_WHEEL_WRIST_F_L.obj" + GeometryFile = models .. "/MSL_WHEEL_WRIST_F_R.obj", + --GeometryFile = models .. "/MSL_WHEEL_WRIST_F_L.obj", + ColorTexture = textures .. "/tex_02.png" }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false }, @@ -1065,9 +1064,9 @@ local Wheel_Wrist_hub_F_R = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_WRIST_1B_F_R.obj" + GeometryFile = models .. "/MSL_WHEEL_WRIST_1B_F_R.obj", + ColorTexture = textures .. "/tex_02.png", }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false }, @@ -1085,9 +1084,9 @@ local Wheel_F_R = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_R.obj" + GeometryFile = models .. "/MSL_WHEEL_R.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -1105,9 +1104,9 @@ local Wheel_C_R = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_R.obj" + GeometryFile = models .. "/MSL_WHEEL_R.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, @@ -1125,9 +1124,9 @@ local Wheel_Wrist_B_R = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_WRIST_1A_B_R.obj" + GeometryFile = models .. "/MSL_WHEEL_WRIST_1A_B_R.obj", + ColorTexture = textures .. "/tex_02.png" }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false }, @@ -1145,9 +1144,9 @@ local Wheel_Wrist_hub_B_R = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_WRIST_1B_B_R.obj" + GeometryFile = models .. "/MSL_WHEEL_WRIST_1B_B_R.obj", + ColorTexture = textures .. "/tex_02.png" }, - ColorTexture = textures .. "/tex_02.png", LightSources = LightSources, PerformShading = false }, @@ -1165,9 +1164,9 @@ local Wheel_B_R = { Body = "MARS SCIENCE LABORATORY", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/MSL_WHEEL_R.obj" + GeometryFile = models .. "/MSL_WHEEL_R.obj", + ColorTexture = textures .. "/tex_03.png" }, - ColorTexture = textures .. "/tex_03.png", LightSources = LightSources, PerformShading = false }, diff --git a/data/assets/scene/solarsystem/missions/pioneer/pioneer10.asset b/data/assets/scene/solarsystem/missions/pioneer/pioneer10.asset index 40ec1f9334..04d9cab085 100644 --- a/data/assets/scene/solarsystem/missions/pioneer/pioneer10.asset +++ b/data/assets/scene/solarsystem/missions/pioneer/pioneer10.asset @@ -34,9 +34,9 @@ local Pioneer10 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = modelFolder .. "/Pioneer.obj" + GeometryFile = modelFolder .. "/Pioneer.obj", + ColorTexture = modelFolder .. "/gray.png" }, - ColorTexture = modelFolder .. "/gray.png", LightSources = assetHelper.getDefaultLightSources(sunTransforms.SolarSystemBarycenter.Identifier) }, GUI = { diff --git a/data/assets/scene/solarsystem/missions/pioneer/pioneer11.asset b/data/assets/scene/solarsystem/missions/pioneer/pioneer11.asset index 2b97f8e720..def3eeacc5 100644 --- a/data/assets/scene/solarsystem/missions/pioneer/pioneer11.asset +++ b/data/assets/scene/solarsystem/missions/pioneer/pioneer11.asset @@ -37,9 +37,9 @@ local Pioneer11 = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = modelFolder .. "/Pioneer.obj" + GeometryFile = modelFolder .. "/Pioneer.obj", + ColorTexture = modelFolder .. "/gray.png" }, - ColorTexture = modelFolder .. "/gray.png", LightSources = assetHelper.getDefaultLightSources(sunTransforms.SolarSystemBarycenter.Identifier) }, GUI = { diff --git a/data/assets/scene/solarsystem/missions/rosetta/67p.asset b/data/assets/scene/solarsystem/missions/rosetta/67p.asset index c5882719df..fd9d09ff50 100644 --- a/data/assets/scene/solarsystem/missions/rosetta/67p.asset +++ b/data/assets/scene/solarsystem/missions/rosetta/67p.asset @@ -56,9 +56,9 @@ local Comet67P = { Type = "RenderableModelProjection", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/67P_rotated_5_130.obj" + GeometryFile = models .. "/67P_rotated_5_130.obj", + ColorTexture = textures .. "/gray.jpg" }, - ColorTexture = textures .. "/gray.jpg", Projection = { Sequence = { imagesDestination }, SequenceType = "image-sequence", diff --git a/data/assets/scene/solarsystem/missions/rosetta/rosetta.asset b/data/assets/scene/solarsystem/missions/rosetta/rosetta.asset index cac99bdd49..8b29ea4180 100644 --- a/data/assets/scene/solarsystem/missions/rosetta/rosetta.asset +++ b/data/assets/scene/solarsystem/missions/rosetta/rosetta.asset @@ -140,9 +140,9 @@ local RosettaBlackFoil = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/black_foil.obj" + GeometryFile = models .. "/black_foil.obj", + ColorTexture = textures .. "/foil_silver_ramp.png" }, - ColorTexture = textures .. "/foil_silver_ramp.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -160,9 +160,9 @@ local RosettaBlackParts = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/black_parts.obj" + GeometryFile = models .. "/black_parts.obj", + ColorTexture = textures .. "/foil_silver_ramp.png" }, - ColorTexture = textures .. "/foil_silver_ramp.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -180,9 +180,9 @@ local RosettaDish = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/dish.obj" + GeometryFile = models .. "/dish.obj", + ColorTexture = textures .. "/dish_AO.png" }, - ColorTexture = textures .. "/dish_AO.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -200,9 +200,9 @@ local RosettaParts = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/parts.obj" + GeometryFile = models .. "/parts.obj", + ColorTexture = textures .. "/parts2_AO.png" }, - ColorTexture = textures .. "/parts2_AO.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -220,9 +220,9 @@ local RosettaSilverFoil = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/silver_foil.obj" + GeometryFile = models .. "/silver_foil.obj", + ColorTexture = textures .. "/foil_silver_ramp.png" }, - ColorTexture = textures .. "/foil_silver_ramp.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -240,9 +240,9 @@ local RosettaVents = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/vents.obj" + GeometryFile = models .. "/vents.obj", + ColorTexture = textures .. "/tex_01.png" }, - ColorTexture = textures .. "/tex_01.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -260,9 +260,9 @@ local RosettaWingA = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .."/wingA.obj" + GeometryFile = models .."/wingA.obj", + ColorTexture = textures .. "/tex_01.png" }, - ColorTexture = textures .. "/tex_01.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -280,9 +280,9 @@ local RosettaWingB = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/wingB.obj" + GeometryFile = models .. "/wingB.obj", + ColorTexture = textures .. "/tex_01.png" }, - ColorTexture = textures .. "/tex_01.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -300,9 +300,9 @@ local RosettaYellowFoil = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/yellow_foil.obj" + GeometryFile = models .. "/yellow_foil.obj", + ColorTexture = textures .. "/foil_gold_ramp.png" }, - ColorTexture = textures .. "/foil_gold_ramp.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -349,9 +349,9 @@ local PhilaeFoil = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/lander_foil.obj" + GeometryFile = models .. "/lander_foil.obj", + ColorTexture = textures .. "/foil_silver_ramp.png" }, - ColorTexture = textures .. "/foil_silver_ramp.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -369,9 +369,9 @@ local PhilaeLids = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/lander_lids.obj" + GeometryFile = models .. "/lander_lids.obj", + ColorTexture = textures .. "/parts2_AO.png" }, - ColorTexture = textures .. "/parts2_AO.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -389,9 +389,9 @@ local PhilaeParts = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/lander_parts.obj" + GeometryFile = models .. "/lander_parts.obj", + ColorTexture = textures .. "/foil_silver_ramp.png" }, - ColorTexture = textures .. "/foil_silver_ramp.png", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -409,9 +409,9 @@ local PhilaeSolarPanels = { Body = "ROSETTA", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/lander_solarp.obj" + GeometryFile = models .. "/lander_solarp.obj", + ColorTexture = textures .. "/tex_01.png" }, - ColorTexture = textures .. "/tex_01.png", ModelTransform = RotationMatrix, LightSources = LightSources }, diff --git a/data/assets/scene/solarsystem/missions/voyager/voyager1.asset b/data/assets/scene/solarsystem/missions/voyager/voyager1.asset index c5a8ae6b0c..f93ffdefe6 100644 --- a/data/assets/scene/solarsystem/missions/voyager/voyager1.asset +++ b/data/assets/scene/solarsystem/missions/voyager/voyager1.asset @@ -82,9 +82,9 @@ local Voyager1Main = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/voyager-main.obj" + GeometryFile = models .. "/voyager-main.obj", + ColorTexture = models .. "/voyager-main.jpg" }, - ColorTexture = models .. "/voyager-main.jpg", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -101,9 +101,9 @@ local Voyager1Antenna = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/voyager-antenna.obj" + GeometryFile = models .. "/voyager-antenna.obj", + ColorTexture = models .. "/voyager-antenna.png" }, - ColorTexture = models .. "/voyager-antenna.png", ModelTransform = RotationMatrix, LightSources = LightSources }, diff --git a/data/assets/scene/solarsystem/missions/voyager/voyager2.asset b/data/assets/scene/solarsystem/missions/voyager/voyager2.asset index f1a87c9e13..993b86dc90 100644 --- a/data/assets/scene/solarsystem/missions/voyager/voyager2.asset +++ b/data/assets/scene/solarsystem/missions/voyager/voyager2.asset @@ -85,9 +85,9 @@ local Voyager2Main = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/voyager-main.obj" + GeometryFile = models .. "/voyager-main.obj", + ColorTexture = models .. "/voyager-main.jpg" }, - ColorTexture = models .. "/voyager-main.jpg", ModelTransform = RotationMatrix, LightSources = LightSources }, @@ -104,9 +104,9 @@ local Voyager2Antenna = { Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/voyager-antenna.obj" + GeometryFile = models .. "/voyager-antenna.obj", + ColorTexture = models .. "/voyager-antenna.png" }, - ColorTexture = models .. "/voyager-antenna.png", ModelTransform = RotationMatrix, LightSources = LightSources }, diff --git a/data/assets/util/asset_helper.asset b/data/assets/util/asset_helper.asset index a785329785..2ae793c380 100644 --- a/data/assets/util/asset_helper.asset +++ b/data/assets/util/asset_helper.asset @@ -182,9 +182,9 @@ local createModelPart = function (parent, sunLightSourceNode, models, geometry, Type = "RenderableModel", Geometry = { Type = "MultiModelGeometry", - GeometryFile = models .. "/" .. geometry .. ".obj" + GeometryFile = models .. "/" .. geometry .. ".obj", + ColorTexture = models .. "/" .. texture }, - ColorTexture = models .. "/" .. texture, LightSources = lightSources, PerformShading = performShading, DisableFaceCulling = true diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index f6a339711c..ace3fa7b02 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,13 @@ namespace { constexpr const char* KeyType = "Type"; constexpr const char* KeyGeomModelFile = "GeometryFile"; constexpr const int8_t CurrentCacheVersion = 3; + + constexpr openspace::properties::Property::PropertyInfo TextureInfo = { + "ColorTexture", + "Color Texture", + "This value points to a color texture file that is applied to the geometry " + "rendered in this object." + }; } // namespace namespace openspace::modelgeometry { @@ -66,12 +74,17 @@ documentation:: Documentation ModelGeometry::Documentation() { "The file that should be loaded in this ModelGeometry. The file can " "contain filesystem tokens or can be specified relatively to the " "location of the .mod file." + }, + { + TextureInfo.identifier, + new StringVerifier, + Optional::Yes, + TextureInfo.description } } }; } - std::unique_ptr ModelGeometry::createFromDictionary( const ghoul::Dictionary& dictionary) { @@ -88,6 +101,7 @@ std::unique_ptr ModelGeometry::createFromDictionary( ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) : properties::PropertyOwner({ "ModelGeometry" }) + , _colorTexturePath(TextureInfo) { documentation::testSpecificationAndThrow( Documentation(), @@ -96,12 +110,49 @@ ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) ); _file = absPath(dictionary.value(KeyGeomModelFile)); + + + _colorTexturePath.onChange([this]() { _colorTextureDirty = true; }); + addProperty(_colorTexturePath); + if (dictionary.hasKey(TextureInfo.identifier)) { + _colorTexturePath = absPath(dictionary.value( + TextureInfo.identifier + )); + } } double ModelGeometry::boundingRadius() const { return _boundingRadius; } +void ModelGeometry::bindTexture() { + if (_texture) { + _texture->bind(); + } +} + +void ModelGeometry::update() { + if (_colorTextureDirty) { + _texture = nullptr; + if (!_colorTexturePath.value().empty()) { + _texture = ghoul::io::TextureReader::ref().loadTexture( + absPath(_colorTexturePath) + ); + if (_texture) { + LDEBUGC( + "RenderableModel", + fmt::format("Loaded texture from '{}'", absPath(_colorTexturePath)) + ); + _texture->uploadTexture(); + _texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + _texture->purgeFromRAM(); + } + } + + _colorTextureDirty = false; + } +} + void ModelGeometry::render() { glBindVertexArray(_vaoID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo); @@ -186,6 +237,8 @@ void ModelGeometry::deinitialize() { glDeleteBuffers(1, &_vbo); glDeleteVertexArrays(1, &_vaoID); glDeleteBuffers(1, &_ibo); + + _texture = nullptr; } bool ModelGeometry::loadObj(const std::string& filename) { diff --git a/modules/base/rendering/modelgeometry.h b/modules/base/rendering/modelgeometry.h index 8251fd4be3..f7e7bd7b05 100644 --- a/modules/base/rendering/modelgeometry.h +++ b/modules/base/rendering/modelgeometry.h @@ -27,7 +27,9 @@ #include +#include #include +#include #include namespace ghoul { class Dictionary; } @@ -55,6 +57,8 @@ public: virtual bool initialize(Renderable* parent); virtual void deinitialize(); + void bindTexture(); + void update(); void render(); virtual bool loadModel(const std::string& filename) = 0; @@ -73,12 +77,16 @@ protected: bool loadCachedFile(const std::string& filename); bool saveCachedFile(const std::string& filename); + properties::StringProperty _colorTexturePath; + bool _colorTextureDirty = false; + GLuint _vaoID = 0; GLuint _vbo = 0; GLuint _ibo = 0 ; GLenum _mode = GL_TRIANGLES; double _boundingRadius = 0.0; + std::unique_ptr _texture; std::vector _vertices; std::vector _indices; diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 26b592797a..fa9392203a 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -36,12 +36,10 @@ #include #include -#include #include #include #include #include -#include #include namespace { @@ -55,13 +53,6 @@ namespace { "specularIntensity" }; - constexpr openspace::properties::Property::PropertyInfo TextureInfo = { - "ColorTexture", - "Color Texture", - "This value points to a color texture file that is applied to the geometry " - "rendered in this object." - }; - constexpr openspace::properties::Property::PropertyInfo AmbientIntensityInfo = { "AmbientIntensity", "Ambient Intensity", @@ -127,12 +118,6 @@ documentation::Documentation RenderableModel::Documentation() { Optional::No, "This specifies the model that is rendered by the Renderable." }, - { - TextureInfo.identifier, - new StringVerifier, - Optional::Yes, - TextureInfo.description - }, { AmbientIntensityInfo.identifier, new DoubleVerifier, @@ -193,7 +178,6 @@ documentation::Documentation RenderableModel::Documentation() { RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _colorTexturePath(TextureInfo) , _ambientIntensity(AmbientIntensityInfo, 0.2f, 0.f, 1.f) , _diffuseIntensity(DiffuseIntensityInfo, 1.f, 0.f, 1.f) , _specularIntensity(SpecularIntensityInfo, 1.f, 0.f, 1.f) @@ -223,12 +207,6 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) _geometry = modelgeometry::ModelGeometry::createFromDictionary(dict); } - if (dictionary.hasKey(TextureInfo.identifier)) { - _colorTexturePath = absPath(dictionary.value( - TextureInfo.identifier - )); - } - if (dictionary.hasKey(ModelTransformInfo.identifier)) { _modelTransform = dictionary.value(ModelTransformInfo.identifier); } @@ -268,10 +246,6 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) addPropertySubOwner(_lightSourcePropertyOwner); addPropertySubOwner(_geometry.get()); - addProperty(_colorTexturePath); - _colorTexturePath.onChange(std::bind(&RenderableModel::loadTexture, this)); - - addProperty(_ambientIntensity); addProperty(_diffuseIntensity); addProperty(_specularIntensity); @@ -291,7 +265,7 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) } bool RenderableModel::isReady() const { - return _program && _texture; + return _program; } void RenderableModel::initialize() { @@ -318,8 +292,6 @@ void RenderableModel::initializeGL() { ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); - loadTexture(); - _geometry->initialize(this); } @@ -328,7 +300,6 @@ void RenderableModel::deinitializeGL() { _geometry->deinitialize(); _geometry = nullptr; } - _texture = nullptr; BaseModule::ProgramObjectManager.release( ProgramName, @@ -422,7 +393,7 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) { // Bind texture ghoul::opengl::TextureUnit unit; unit.activate(); - _texture->bind(); + _geometry->bindTexture(); _program->setUniform(_uniformCache.texture, unit); if (_disableFaceCulling) { @@ -443,24 +414,7 @@ void RenderableModel::update(const UpdateData&) { _program->rebuildFromFile(); ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); } -} - -void RenderableModel::loadTexture() { - _texture = nullptr; - if (!_colorTexturePath.value().empty()) { - _texture = ghoul::io::TextureReader::ref().loadTexture( - absPath(_colorTexturePath) - ); - if (_texture) { - LDEBUGC( - "RenderableModel", - fmt::format("Loaded texture from '{}'", absPath(_colorTexturePath)) - ); - _texture->uploadTexture(); - _texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); - _texture->purgeFromRAM(); - } - } + _geometry->update(); } } // namespace openspace diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index 60c9499e19..bb68a7a6c0 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -27,7 +27,6 @@ #include -#include #include #include #include @@ -36,8 +35,6 @@ #include #include - - namespace ghoul::opengl { class ProgramObject; class Texture; @@ -68,14 +65,9 @@ public: static documentation::Documentation Documentation(); -protected: - void loadTexture(); - private: std::unique_ptr _geometry; - properties::StringProperty _colorTexturePath; - properties::FloatProperty _ambientIntensity; properties::FloatProperty _diffuseIntensity; @@ -92,7 +84,6 @@ private: performShading, texture, ambientIntensity, diffuseIntensity, specularIntensity) _uniformCache; - std::unique_ptr _texture; std::vector> _lightSources; // Buffers for uniform uploading diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp index 9429362249..842343eaa4 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp @@ -65,13 +65,6 @@ namespace { "ProjectorMatrix", "ModelTransform" }; - constexpr openspace::properties::Property::PropertyInfo ColorTextureInfo = { - "ColorTexture", - "Color Base Texture", - "This is the path to a local image file that is used as the base texture for the " - "model on which the image projections are layered." - }; - constexpr openspace::properties::Property::PropertyInfo PerformShadingInfo = { "PerformShading", "Perform Shading", @@ -107,12 +100,6 @@ documentation::Documentation RenderableModelProjection::Documentation() { Optional::No, "Contains information about projecting onto this planet." }, - { - ColorTextureInfo.identifier, - new StringVerifier, - Optional::No, - ColorTextureInfo.description - }, { PerformShadingInfo.identifier, new BoolVerifier, @@ -134,7 +121,6 @@ documentation::Documentation RenderableModelProjection::Documentation() { RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _colorTexturePath(ColorTextureInfo) , _performShading(PerformShadingInfo, true) { documentation::testSpecificationAndThrow( @@ -146,16 +132,9 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di Dictionary geometryDictionary = dictionary.value(keyGeometry); _geometry = modelgeometry::ModelGeometry::createFromDictionary(geometryDictionary); - _colorTexturePath = absPath(dictionary.value( - ColorTextureInfo.identifier - )); - addPropertySubOwner(_geometry.get()); addPropertySubOwner(_projectionComponent); - addProperty(_colorTexturePath); - _colorTexturePath.onChange(std::bind(&RenderableModelProjection::loadTextures, this)); - _projectionComponent.initialize( identifier(), dictionary.value(keyProjection) @@ -175,8 +154,7 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di RenderableModelProjection::~RenderableModelProjection() {} // NOLINT bool RenderableModelProjection::isReady() const { - return (_programObject != nullptr) && (_baseTexture != nullptr) && - _projectionComponent.isReady(); + return (_programObject != nullptr) && _projectionComponent.isReady(); } void RenderableModelProjection::initializeGL() { @@ -234,7 +212,6 @@ void RenderableModelProjection::deinitializeGL() { } _geometry = nullptr; - _baseTexture = nullptr; _projectionComponent.deinitialize(); @@ -301,7 +278,7 @@ void RenderableModelProjection::render(const RenderData& data, RendererTasks&) { ghoul::opengl::TextureUnit baseUnit; baseUnit.activate(); - _baseTexture->bind(); + _geometry->bindTexture(); _programObject->setUniform(_mainUniformCache.baseTexture, baseUnit); ghoul::opengl::TextureUnit projectionUnit; @@ -378,6 +355,8 @@ void RenderableModelProjection::update(const UpdateData& data) { data.modelTransform.translation; _sunPosition = static_cast(p); + + _geometry->update(); } void RenderableModelProjection::imageProjectGPU( @@ -489,20 +468,4 @@ void RenderableModelProjection::project() { _shouldCapture = false; } -bool RenderableModelProjection::loadTextures() { - _baseTexture = nullptr; - if (!_colorTexturePath.value().empty()) { - _baseTexture = ghoul::io::TextureReader::ref().loadTexture( - absPath(_colorTexturePath) - ); - if (_baseTexture) { - LDEBUG(fmt::format("Loaded texture from '{}'", absPath(_colorTexturePath))); - _baseTexture->uploadTexture(); - _baseTexture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap); - } - } - - return _baseTexture != nullptr; -} - } // namespace openspace diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.h b/modules/spacecraftinstruments/rendering/renderablemodelprojection.h index 9c943c2388..64a0bbfacb 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.h +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.h @@ -73,8 +73,6 @@ private: ProjectionComponent _projectionComponent; - properties::StringProperty _colorTexturePath; - std::unique_ptr _programObject; UniformCache(performShading, directionToSunViewSpace, modelViewTransform, projectionTransform, projectionFading, baseTexture, @@ -86,8 +84,6 @@ private: std::unique_ptr _depthFboProgramObject; UniformCache(ProjectorMatrix, ModelTransform) _depthFboUniformCache; - std::unique_ptr _baseTexture; - std::unique_ptr _geometry; glm::dmat3 _instrumentMatrix = glm::dmat3(1.0); From 7603edf9063be95def0e074a1369842dccdb4d7f Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 18 Aug 2020 16:34:54 +0200 Subject: [PATCH 24/59] Add the ability to add multiple ModelGeometry's for a RenderableModel to show models with multiple OBJ files without needing to create multiple scene graph nodes --- .../planets/earth/satellites/misc/iss.asset | 181 ++++++++++++++++-- modules/base/rendering/modelgeometry.cpp | 64 +++---- modules/base/rendering/modelgeometry.h | 10 +- modules/base/rendering/renderablemodel.cpp | 44 +++-- modules/base/rendering/renderablemodel.h | 2 +- .../rendering/renderablemodelprojection.cpp | 4 - .../rendering/renderablemodelprojection.h | 1 - 7 files changed, 213 insertions(+), 93 deletions(-) diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset index 841a2536d9..bfde270d5a 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset @@ -57,6 +57,167 @@ local initializeAndAddNodes = function() YAxis = transforms.EarthInertial.Identifier } }, + Renderable = { + Type = "RenderableModel", + Geometry = { + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/0.obj", + ColorTexture = models .. "/0.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/1.obj", + ColorTexture = models .. "/1.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/2.obj", + ColorTexture = models .. "/2.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/3.obj", + ColorTexture = models .. "/3.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/4.obj", + ColorTexture = models .. "/4.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/5.obj", + ColorTexture = models .. "/5.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/6.obj", + ColorTexture = models .. "/6.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/7.obj", + ColorTexture = models .. "/7.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/8.obj", + ColorTexture = models .. "/8.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/10.obj", + ColorTexture = models .. "/10.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/11.obj", + ColorTexture = models .. "/11.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/13.obj", + ColorTexture = models .. "/13.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/14.obj", + ColorTexture = models .. "/14.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/15.obj", + ColorTexture = models .. "/15.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/16.obj", + ColorTexture = models .. "/16.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/17.obj", + ColorTexture = models .. "/17.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/19.obj", + ColorTexture = models .. "/19.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/21.obj", + ColorTexture = models .. "/21.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/22.obj", + ColorTexture = models .. "/22.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/23.obj", + ColorTexture = models .. "/23.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/24.obj", + ColorTexture = models .. "/24.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/25.obj", + ColorTexture = models .. "/25.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/foilsilver.obj", + ColorTexture = models .. "/foilsilver.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/olive.obj", + ColorTexture = models .. "/olive.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/basemetal.obj", + ColorTexture = models .. "/basemetal.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/white_20.obj", + ColorTexture = models .. "/white_20.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/plasticblack.obj", + ColorTexture = models .. "/plasticblack.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/ecostresswhite.obj", + ColorTexture = models .. "/ecostresswhite.png" + }, + { + Type = "MultiModelGeometry", + GeometryFile = models .. "/plain.obj", + ColorTexture = models .. "/plain.png" + }, + + }, + LightSources = { + { + Type = "SceneGraphLightSource", + Identifier = "Sun", + Node = sunTransforms.SolarSystemBarycenter.Identifier, + Intensity = 1.0 + } + }, + PerformShading = true, + DisableFaceCulling = true + }, GUI = { Name = "ISSparentNode", Path = "/Solar System/Planets/Earth/Satellites/ISS", @@ -64,24 +225,6 @@ local initializeAndAddNodes = function() } } - local list = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "10", "11", - "13", "14", "15", "16", "17", "19", "21", "22", "23", "24", "25", - "foilsilver", "olive", "basemetal", "white_20", "plasticblack", "ecostresswhite", - "plain"} - - local nodes = { iss, parentNode } - for i, info in ipairs(list) do - n = assetHelper.createModelPart( - parentNode.Identifier, - sunTransforms.SolarSystemBarycenter.Identifier, - models, - info, - info .. ".png", - true - ) - table.insert(nodes, n) - end - local issTrail = { Identifier = identifier .. "_trail", Parent = transforms.EarthInertial.Identifier, @@ -108,7 +251,7 @@ local initializeAndAddNodes = function() } table.insert(nodes, issTrail) - return nodes + return { iss, parentNode, issTrail } end asset.onInitialize(function () diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index ace3fa7b02..687f65773d 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -43,14 +43,8 @@ namespace { constexpr const char* KeyType = "Type"; constexpr const char* KeyGeomModelFile = "GeometryFile"; + constexpr const char* KeyColorTexture = "ColorTexture"; constexpr const int8_t CurrentCacheVersion = 3; - - constexpr openspace::properties::Property::PropertyInfo TextureInfo = { - "ColorTexture", - "Color Texture", - "This value points to a color texture file that is applied to the geometry " - "rendered in this object." - }; } // namespace namespace openspace::modelgeometry { @@ -76,10 +70,11 @@ documentation:: Documentation ModelGeometry::Documentation() { "location of the .mod file." }, { - TextureInfo.identifier, + KeyColorTexture, new StringVerifier, Optional::Yes, - TextureInfo.description + "This value points to a color texture file that is applied to the " + "geometry rendered in this object." } } }; @@ -99,10 +94,7 @@ std::unique_ptr ModelGeometry::createFromDictionary( return std::unique_ptr(geometry); } -ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) - : properties::PropertyOwner({ "ModelGeometry" }) - , _colorTexturePath(TextureInfo) -{ +ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow( Documentation(), dictionary, @@ -111,13 +103,8 @@ ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) _file = absPath(dictionary.value(KeyGeomModelFile)); - - _colorTexturePath.onChange([this]() { _colorTextureDirty = true; }); - addProperty(_colorTexturePath); - if (dictionary.hasKey(TextureInfo.identifier)) { - _colorTexturePath = absPath(dictionary.value( - TextureInfo.identifier - )); + if (dictionary.hasKey(KeyColorTexture)) { + _colorTexturePath = absPath(dictionary.value(KeyColorTexture)); } } @@ -131,28 +118,6 @@ void ModelGeometry::bindTexture() { } } -void ModelGeometry::update() { - if (_colorTextureDirty) { - _texture = nullptr; - if (!_colorTexturePath.value().empty()) { - _texture = ghoul::io::TextureReader::ref().loadTexture( - absPath(_colorTexturePath) - ); - if (_texture) { - LDEBUGC( - "RenderableModel", - fmt::format("Loaded texture from '{}'", absPath(_colorTexturePath)) - ); - _texture->uploadTexture(); - _texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); - _texture->purgeFromRAM(); - } - } - - _colorTextureDirty = false; - } -} - void ModelGeometry::render() { glBindVertexArray(_vaoID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo); @@ -230,6 +195,21 @@ bool ModelGeometry::initialize(Renderable* parent) { glBindVertexArray(0); + if (!_colorTexturePath.empty()) { + _texture = ghoul::io::TextureReader::ref().loadTexture( + absPath(_colorTexturePath) + ); + if (_texture) { + LDEBUGC( + "RenderableModel", + fmt::format("Loaded texture from '{}'", absPath(_colorTexturePath)) + ); + _texture->uploadTexture(); + _texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + _texture->purgeFromRAM(); + } + } + return true; } diff --git a/modules/base/rendering/modelgeometry.h b/modules/base/rendering/modelgeometry.h index f7e7bd7b05..5018b07c50 100644 --- a/modules/base/rendering/modelgeometry.h +++ b/modules/base/rendering/modelgeometry.h @@ -25,9 +25,6 @@ #ifndef __OPENSPACE_MODULE_BASE___MODELGEOMETRY___H__ #define __OPENSPACE_MODULE_BASE___MODELGEOMETRY___H__ -#include - -#include #include #include #include @@ -40,7 +37,7 @@ namespace openspace::documentation { struct Documentation; } namespace openspace::modelgeometry { -class ModelGeometry : public properties::PropertyOwner { +class ModelGeometry { public: struct Vertex { GLfloat location[4]; @@ -58,7 +55,6 @@ public: virtual bool initialize(Renderable* parent); virtual void deinitialize(); void bindTexture(); - void update(); void render(); virtual bool loadModel(const std::string& filename) = 0; @@ -77,15 +73,13 @@ protected: bool loadCachedFile(const std::string& filename); bool saveCachedFile(const std::string& filename); - properties::StringProperty _colorTexturePath; - bool _colorTextureDirty = false; - GLuint _vaoID = 0; GLuint _vbo = 0; GLuint _ibo = 0 ; GLenum _mode = GL_TRIANGLES; double _boundingRadius = 0.0; + std::string _colorTexturePath; std::unique_ptr _texture; std::vector _vertices; diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index fa9392203a..d18e34d12d 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -114,7 +114,13 @@ documentation::Documentation RenderableModel::Documentation() { { { KeyGeometry, - new ReferencingVerifier("base_geometry_model"), + new TableVerifier({ + { + "*", + new ReferencingVerifier("base_geometry_model"), + Optional::Yes + } + }), Optional::No, "This specifies the model that is rendered by the Renderable." }, @@ -204,7 +210,11 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) if (dictionary.hasKey(KeyGeometry)) { ghoul::Dictionary dict = dictionary.value(KeyGeometry); - _geometry = modelgeometry::ModelGeometry::createFromDictionary(dict); + for (int i = 1; i <= dict.size(); ++i) { + std::string key = std::to_string(i); + ghoul::Dictionary geom = dict.value(key); + _geometry.push_back(modelgeometry::ModelGeometry::createFromDictionary(geom)); + } } if (dictionary.hasKey(ModelTransformInfo.identifier)) { @@ -244,7 +254,6 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) addPropertySubOwner(_lightSourcePropertyOwner); - addPropertySubOwner(_geometry.get()); addProperty(_ambientIntensity); addProperty(_diffuseIntensity); @@ -292,14 +301,16 @@ void RenderableModel::initializeGL() { ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); - _geometry->initialize(this); + for (const std::unique_ptr& geom : _geometry) { + geom->initialize(this); + } } void RenderableModel::deinitializeGL() { - if (_geometry) { - _geometry->deinitialize(); - _geometry = nullptr; + for (const std::unique_ptr& geom : _geometry) { + geom->deinitialize(); } + _geometry.clear(); BaseModule::ProgramObjectManager.release( ProgramName, @@ -388,20 +399,18 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) { _performShading ); - _geometry->setUniforms(*_program); - - // Bind texture - ghoul::opengl::TextureUnit unit; - unit.activate(); - _geometry->bindTexture(); - _program->setUniform(_uniformCache.texture, unit); - if (_disableFaceCulling) { glDisable(GL_CULL_FACE); } - _geometry->render(); - + ghoul::opengl::TextureUnit unit; + unit.activate(); + _program->setUniform(_uniformCache.texture, unit); + for (const std::unique_ptr& geom : _geometry) { + geom->setUniforms(*_program); + geom->bindTexture(); + geom->render(); + } if (_disableFaceCulling) { glEnable(GL_CULL_FACE); } @@ -414,7 +423,6 @@ void RenderableModel::update(const UpdateData&) { _program->rebuildFromFile(); ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); } - _geometry->update(); } } // namespace openspace diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index bb68a7a6c0..33042fc208 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -66,7 +66,7 @@ public: static documentation::Documentation Documentation(); private: - std::unique_ptr _geometry; + std::vector> _geometry; properties::FloatProperty _ambientIntensity; diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp index 842343eaa4..083bd06bc4 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp @@ -132,7 +132,6 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di Dictionary geometryDictionary = dictionary.value(keyGeometry); _geometry = modelgeometry::ModelGeometry::createFromDictionary(geometryDictionary); - addPropertySubOwner(_geometry.get()); addPropertySubOwner(_projectionComponent); _projectionComponent.initialize( @@ -198,7 +197,6 @@ void RenderableModelProjection::initializeGL() { DepthFboUniformNames ); - loadTextures(); _projectionComponent.initializeGL(); float bs = boundingSphere(); @@ -355,8 +353,6 @@ void RenderableModelProjection::update(const UpdateData& data) { data.modelTransform.translation; _sunPosition = static_cast(p); - - _geometry->update(); } void RenderableModelProjection::imageProjectGPU( diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.h b/modules/spacecraftinstruments/rendering/renderablemodelprojection.h index 64a0bbfacb..08c64c6be1 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.h +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.h @@ -65,7 +65,6 @@ public: static documentation::Documentation Documentation(); private: - bool loadTextures(); void attitudeParameters(double time); void imageProjectGPU(const ghoul::opengl::Texture& projectionTexture); From 89af15126b64cf7d91f702ec5c2c405146a2d0c5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 19 Aug 2020 10:27:21 +0200 Subject: [PATCH 25/59] Use global memory block for the models --- modules/base/rendering/modelgeometry.cpp | 13 +++++++--- modules/base/rendering/modelgeometry.h | 3 ++- modules/base/rendering/renderablemodel.cpp | 26 +++++-------------- modules/base/rendering/renderablemodel.h | 7 ++--- .../rendering/renderablemodelprojection.h | 3 ++- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index 687f65773d..b51938be98 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -25,8 +25,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -80,7 +82,8 @@ documentation:: Documentation ModelGeometry::Documentation() { }; } -std::unique_ptr ModelGeometry::createFromDictionary( +// Create with ghoul::mm_unique_ptr +ghoul::mm_unique_ptr ModelGeometry::createFromDictionary( const ghoul::Dictionary& dictionary) { if (!dictionary.hasKeyAndValue(KeyType)) { @@ -90,8 +93,12 @@ std::unique_ptr ModelGeometry::createFromDictionary( const std::string& geometryType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - ModelGeometry* geometry = factory->create(geometryType, dictionary); - return std::unique_ptr(geometry); + ModelGeometry* geometry = factory->create( + geometryType, + dictionary, + &global::memoryManager.PersistentMemory + ); + return ghoul::mm_unique_ptr(geometry); } ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) { diff --git a/modules/base/rendering/modelgeometry.h b/modules/base/rendering/modelgeometry.h index 5018b07c50..c087d57d7e 100644 --- a/modules/base/rendering/modelgeometry.h +++ b/modules/base/rendering/modelgeometry.h @@ -25,6 +25,7 @@ #ifndef __OPENSPACE_MODULE_BASE___MODELGEOMETRY___H__ #define __OPENSPACE_MODULE_BASE___MODELGEOMETRY___H__ +#include #include #include #include @@ -45,7 +46,7 @@ public: GLfloat normal[3]; }; - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary ); diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index d18e34d12d..e975a74247 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -301,13 +301,13 @@ void RenderableModel::initializeGL() { ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); - for (const std::unique_ptr& geom : _geometry) { + for (const ghoul::mm_unique_ptr& geom : _geometry) { geom->initialize(this); } } void RenderableModel::deinitializeGL() { - for (const std::unique_ptr& geom : _geometry) { + for (const ghoul::mm_unique_ptr& geom : _geometry) { geom->deinitialize(); } _geometry.clear(); @@ -382,22 +382,10 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) { _uniformCache.projectionTransform, data.camera.projectionMatrix() ); - _program->setUniform( - _uniformCache.ambientIntensity, - _ambientIntensity - ); - _program->setUniform( - _uniformCache.diffuseIntensity, - _diffuseIntensity - ); - _program->setUniform( - _uniformCache.specularIntensity, - _specularIntensity - ); - _program->setUniform( - _uniformCache.performShading, - _performShading - ); + _program->setUniform(_uniformCache.ambientIntensity, _ambientIntensity); + _program->setUniform(_uniformCache.diffuseIntensity, _diffuseIntensity); + _program->setUniform(_uniformCache.specularIntensity, _specularIntensity); + _program->setUniform(_uniformCache.performShading, _performShading); if (_disableFaceCulling) { glDisable(GL_CULL_FACE); @@ -406,7 +394,7 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) { ghoul::opengl::TextureUnit unit; unit.activate(); _program->setUniform(_uniformCache.texture, unit); - for (const std::unique_ptr& geom : _geometry) { + for (const ghoul::mm_unique_ptr& geom : _geometry) { geom->setUniforms(*_program); geom->bindTexture(); geom->render(); diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index 33042fc208..721de33f44 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -27,13 +27,14 @@ #include +#include #include #include #include +#include +#include #include #include -#include -#include namespace ghoul::opengl { class ProgramObject; @@ -66,7 +67,7 @@ public: static documentation::Documentation Documentation(); private: - std::vector> _geometry; + std::vector> _geometry; properties::FloatProperty _ambientIntensity; diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.h b/modules/spacecraftinstruments/rendering/renderablemodelprojection.h index 08c64c6be1..45d5ccf252 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.h +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.h @@ -31,6 +31,7 @@ #include #include #include +#include #include namespace ghoul::opengl { @@ -83,7 +84,7 @@ private: std::unique_ptr _depthFboProgramObject; UniformCache(ProjectorMatrix, ModelTransform) _depthFboUniformCache; - std::unique_ptr _geometry; + ghoul::mm_unique_ptr _geometry; glm::dmat3 _instrumentMatrix = glm::dmat3(1.0); From 2621e16ec4c5b0cfba97d6f59757c050ddd1bfe6 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 19 Aug 2020 11:12:45 +0200 Subject: [PATCH 26/59] Pass the format string for the ephemeris conversion as a string_view to prevent an extra memory allocation --- include/openspace/util/spicemanager.h | 9 ++++--- src/util/spicemanager.cpp | 37 ++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/include/openspace/util/spicemanager.h b/include/openspace/util/spicemanager.h index e7afb7aaab..fd14a12faf 100644 --- a/include/openspace/util/spicemanager.h +++ b/include/openspace/util/spicemanager.h @@ -469,15 +469,18 @@ public: * * \param ephemerisTime The ephemeris time, that is the number of TDB seconds past the * J2000 epoch - * \param formatString The format string describing the output format + * \param format The format string describing the output format * \return The destination for the converted date. * - * \pre \p formatString must not be empty + * \pre \p format must not be empty * * \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/timout_c.html */ std::string dateFromEphemerisTime(double ephemerisTime, - const std::string& formatString = "YYYY MON DDTHR:MN:SC.### ::RND") const; + std::string_view format = "YYYY MON DDTHR:MN:SC.### ::RND") const; + + void dateFromEphemerisTime(double ephemerisTime, char* outBuf, int bufferSize, + std::string_view format = "YYYY MON DDTHR:MN:SC.### ::RND") const; /** * Returns the \p position of a \p target body relative to an \p observer in a diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index f7b940bc5b..7792a6b2ce 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -483,13 +483,40 @@ double SpiceManager::ephemerisTimeFromDate(const std::string& timeString) const } std::string SpiceManager::dateFromEphemerisTime(double ephemerisTime, - const std::string& formatString) const + std::string_view format) const { ghoul_assert(!formatString.empty(), "Format is empty"); + ghoul_assert(formatString.back() == '\0', "Format string must be null-terminated"); - constexpr const int BufferSize = 256; - SpiceChar buffer[BufferSize]; - timout_c(ephemerisTime, formatString.c_str(), BufferSize - 1, buffer); + if (format.size() < 32) { + constexpr const int BufferSize = 32; + SpiceChar buffer[BufferSize]; + dateFromEphemerisTime(ephemerisTime, buffer, BufferSize, format); + return std::string(buffer); + } + else if (format.size() < 256) { + constexpr const int BufferSize = 256; + SpiceChar buffer[BufferSize]; + dateFromEphemerisTime(ephemerisTime, buffer, BufferSize, format); + return std::string(buffer); + } + else { + std::string res; + res.resize(format.size() + 1); + dateFromEphemerisTime(ephemerisTime, res.data(), format.size(), format); + return res; + } +} + +void SpiceManager::dateFromEphemerisTime(double ephemerisTime, char* outBuf, + int bufferSize, + std::string_view formatString) const +{ + ghoul_assert(!formatString.empty(), "Format is empty"); + ghoul_assert(formatString.back() == '\0', "Format string must be null-terminated"); + ghoul_assert(formatString.size() > bufferSize - 1, "Buffer size too small"); + + timout_c(ephemerisTime, formatString.data(), bufferSize - 1, outBuf); if (failed_c()) { throwSpiceError( fmt::format("Error converting ephemeris time '{}' to date with format '{}'", @@ -497,8 +524,6 @@ std::string SpiceManager::dateFromEphemerisTime(double ephemerisTime, ) ); } - - return std::string(buffer); } glm::dvec3 SpiceManager::targetPosition(const std::string& target, From 6ac5d536facd39d273d27dbf38f4919c96e09419 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 19 Aug 2020 16:19:25 +0200 Subject: [PATCH 27/59] Update Ghoul repository Adapt to Ghoul changes in MemoryPool --- ext/ghoul | 2 +- include/openspace/scene/profile.h | 2 +- include/openspace/util/memorymanager.h | 6 ++---- modules/server/src/connection.cpp | 2 +- modules/sync/syncmodule.cpp | 4 ++-- src/engine/openspaceengine.cpp | 4 +++- src/scene/profile.cpp | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index c342cf9d25..26de570dec 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit c342cf9d25995b02e709fc4bcc114ef40a3a8715 +Subproject commit 26de570dec769496c7d04707325db9a390465906 diff --git a/include/openspace/scene/profile.h b/include/openspace/scene/profile.h index 71473693ee..de6aa8a2f5 100644 --- a/include/openspace/scene/profile.h +++ b/include/openspace/scene/profile.h @@ -121,7 +121,7 @@ public: * and all of the property & asset changes that were made since startup. */ void saveCurrentSettingsToProfile(const properties::PropertyOwner& rootOwner, - const std::string& currentTime, + std::string currentTime, interaction::NavigationHandler::NavigationState navState); /// If the value passed to this function is 'true', the addAsset and removeAsset diff --git a/include/openspace/util/memorymanager.h b/include/openspace/util/memorymanager.h index f50eb525e5..6d202f15ee 100644 --- a/include/openspace/util/memorymanager.h +++ b/include/openspace/util/memorymanager.h @@ -35,10 +35,8 @@ public: ghoul::MemoryPool<8 * 1024 * 1024, false> PersistentMemory; // This should be replaced with a std::pmr::memory_resource wrapper around our own - // Memory pool. Resetting the monotoic_buffer_resource costs an allocation, that we - // can prevent - std::pmr::monotonic_buffer_resource TemporaryMemory = - std::pmr::monotonic_buffer_resource(100 * 4096); + // Memory pool so that we can get a high-water mark out of it + ghoul::MemoryPool<100 * 4096, false> TemporaryMemory; }; } // namespace openspace diff --git a/modules/server/src/connection.cpp b/modules/server/src/connection.cpp index 7e1b98891c..e84baa0c35 100644 --- a/modules/server/src/connection.cpp +++ b/modules/server/src/connection.cpp @@ -85,7 +85,7 @@ Connection::Connection(std::unique_ptr s, AuthenticationTopicKey, [password](bool, const ghoul::Dictionary&, ghoul::MemoryPoolBase* pool) { if (pool) { - void* ptr = pool->alloc(sizeof(AuthorizationTopic)); + void* ptr = pool->allocate(sizeof(AuthorizationTopic)); return new (ptr) AuthorizationTopic(password); } else { diff --git a/modules/sync/syncmodule.cpp b/modules/sync/syncmodule.cpp index 582b7f2146..dc48ce9632 100644 --- a/modules/sync/syncmodule.cpp +++ b/modules/sync/syncmodule.cpp @@ -80,7 +80,7 @@ void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) { "HttpSynchronization", [this](bool, const ghoul::Dictionary& dictionary, ghoul::MemoryPoolBase* pool) { if (pool) { - void* ptr = pool->alloc(sizeof(HttpSynchronization)); + void* ptr = pool->allocate(sizeof(HttpSynchronization)); return new (ptr) HttpSynchronization( dictionary, _synchronizationRoot, @@ -101,7 +101,7 @@ void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) { "UrlSynchronization", [this](bool, const ghoul::Dictionary& dictionary, ghoul::MemoryPoolBase* pool) { if (pool) { - void* ptr = pool->alloc(sizeof(UrlSynchronization)); + void* ptr = pool->allocate(sizeof(UrlSynchronization)); return new (ptr) UrlSynchronization( dictionary, _synchronizationRoot diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 1b78001201..c0b79c92af 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1062,7 +1062,7 @@ void OpenSpaceEngine::preSynchronization() { FileSys.triggerFilesystemEvents(); // Reset the temporary, frame-based storage - global::memoryManager.TemporaryMemory.release(); + global::memoryManager.TemporaryMemory.reset(); if (_hasScheduledAssetLoading) { LINFO(fmt::format("Loading asset: {}", _scheduledAssetPathToLoad)); @@ -1260,6 +1260,8 @@ void OpenSpaceEngine::postDraw() { _isFirstRenderingFirstFrame = false; } + global::memoryManager.PersistentMemory.housekeeping(); + LTRACE("OpenSpaceEngine::postDraw(end)"); } diff --git a/src/scene/profile.cpp b/src/scene/profile.cpp index f351928e2a..bbfeec0351 100644 --- a/src/scene/profile.cpp +++ b/src/scene/profile.cpp @@ -454,7 +454,7 @@ namespace { } // namespace void Profile::saveCurrentSettingsToProfile(const properties::PropertyOwner& rootOwner, - const std::string& currentTime, + std::string currentTime, interaction::NavigationHandler::NavigationState navState) { version = Profile::CurrentVersion; @@ -476,7 +476,7 @@ void Profile::saveCurrentSettingsToProfile(const properties::PropertyOwner& root // add current time to profile file // Time t; - t.time = currentTime; + t.time = std::move(currentTime); t.type = Time::Type::Absolute; time = std::move(t); From e93f1833bee6ca95ab433dc333635a34c04224ef Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 19 Aug 2020 18:26:11 +0200 Subject: [PATCH 28/59] Make more use of temporary string objects in the TimeQuantizer Add GPU markers to the rendering --- ext/ghoul | 2 +- include/openspace/util/spicemanager.h | 31 +++++++- include/openspace/util/time.h | 5 +- .../util/fieldlinesstate.cpp | 4 +- modules/globebrowsing/src/tileprovider.cpp | 15 ++-- modules/globebrowsing/src/timequantizer.cpp | 22 +++--- modules/globebrowsing/src/timequantizer.h | 4 +- modules/imgui/src/guimissioncomponent.cpp | 6 +- modules/imgui/src/guispacetimecomponent.cpp | 7 +- modules/iswa/util/iswamanager.cpp | 5 +- modules/server/src/topics/timetopic.cpp | 2 +- .../dashboard/dashboarditeminstruments.cpp | 2 +- modules/volume/rawvolumemetadata.cpp | 6 +- src/engine/openspaceengine.cpp | 6 ++ src/rendering/framebufferrenderer.cpp | 22 +++++- src/scene/profile_lua.inl | 2 +- src/util/spicemanager.cpp | 76 +++++-------------- src/util/time.cpp | 29 +++++-- src/util/time_lua.inl | 4 +- 19 files changed, 145 insertions(+), 105 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 26de570dec..d073de9ab1 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 26de570dec769496c7d04707325db9a390465906 +Subproject commit d073de9ab1b81b234a5a1cf55fdec36f029fc639 diff --git a/include/openspace/util/spicemanager.h b/include/openspace/util/spicemanager.h index fd14a12faf..2768e29a59 100644 --- a/include/openspace/util/spicemanager.h +++ b/include/openspace/util/spicemanager.h @@ -33,11 +33,15 @@ #include #include #include +#include "SpiceUsr.h" +#include "SpiceZpr.h" namespace openspace { namespace scripting { struct LuaLibrary; } +void throwSpiceError(const std::string& errorMessage); + class SpiceManager { public: BooleanType(UseException); @@ -462,6 +466,7 @@ public: * \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html */ double ephemerisTimeFromDate(const std::string& timeString) const; + double ephemerisTimeFromDate(const char* timeString) const; /** * Converts the passed \p ephemerisTime into a human-readable date string with a @@ -476,11 +481,33 @@ public: * * \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/timout_c.html */ + template std::string dateFromEphemerisTime(double ephemerisTime, - std::string_view format = "YYYY MON DDTHR:MN:SC.### ::RND") const; + const char (&format)[N] = "YYYY MON DDTHR:MN:SC.### ::RND") const + { + static_assert(N != 0, "Format must not be empty"); + std::string res; + res.resize(N); + dateFromEphemerisTime(ephemerisTime, res.data(), N, format); + return res; + } + + template void dateFromEphemerisTime(double ephemerisTime, char* outBuf, int bufferSize, - std::string_view format = "YYYY MON DDTHR:MN:SC.### ::RND") const; + const char (&format)[N] = "YYYY MON DDTHR:MN:SC.### ::RND") const + { + static_assert(N != 0, "Format must not be empty"); + ghoul_assert(N > bufferSize - 1, "Buffer size too small"); + + timout_c(ephemerisTime, format, bufferSize - 1, outBuf); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error converting ephemeris time '{}' to date with format '{}'", + ephemerisTime, format + )); + } + } /** * Returns the \p position of a \p target body relative to an \p observer in a diff --git a/include/openspace/util/time.h b/include/openspace/util/time.h index 25c29bd2e6..d055971725 100644 --- a/include/openspace/util/time.h +++ b/include/openspace/util/time.h @@ -64,6 +64,7 @@ public: * \pre \p timeString must not be empty */ static double convertTime(const std::string& time); + static double convertTime(const char* time); explicit Time(double secondsJ2000 = -1); explicit Time(const std::string& time); @@ -113,13 +114,13 @@ public: * thus also compliant with the Spice library. * \return The current time as a formatted date string */ - std::string UTC() const; + std::string_view UTC() const; /** * Returns the current time as a ISO 8601 formatted, i.e YYYY-MM-DDThh:mm:ssZ * \return The current time as a ISO 8601 formatted string */ - std::string ISO8601() const; + std::string_view ISO8601() const; /** * Advances the simulation time using the deltaTime() and the tickTime. diff --git a/modules/fieldlinessequence/util/fieldlinesstate.cpp b/modules/fieldlinessequence/util/fieldlinesstate.cpp index bd717431ad..7327514e37 100644 --- a/modules/fieldlinessequence/util/fieldlinesstate.cpp +++ b/modules/fieldlinessequence/util/fieldlinesstate.cpp @@ -245,7 +245,7 @@ bool FieldlinesState::loadStateFromJson(const std::string& pathToJsonFile, */ void FieldlinesState::saveStateToOsfls(const std::string& absPath) { // ------------------------------- Create the file ------------------------------- // - std::string pathSafeTimeString = Time(_triggerTime).ISO8601(); + std::string pathSafeTimeString = std::string(Time(_triggerTime).ISO8601()); pathSafeTimeString.replace(13, 1, "-"); pathSafeTimeString.replace(16, 1, "-"); pathSafeTimeString.replace(19, 1, "-"); @@ -341,7 +341,7 @@ void FieldlinesState::saveStateToJson(const std::string& absPath) { json jFile; - const std::string timeStr = Time(_triggerTime).ISO8601(); + std::string_view timeStr = Time(_triggerTime).ISO8601(); const size_t nLines = _lineStart.size(); // const size_t nPoints = _vertexPositions.size(); const size_t nExtras = _extraQuantities.size(); diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index 3e57d400d3..fc0f9b4a2c 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -278,9 +278,9 @@ std::string timeStringify(TemporalTileProvider::TimeFormatType type, const Time& switch (type) { case TemporalTileProvider::TimeFormatType::YYYY_MM_DD: - return t.ISO8601().substr(0, 10); + return std::string(t.ISO8601().substr(0, 10)); case TemporalTileProvider::TimeFormatType::YYYYMMDD_hhmmss: { - std::string ts = t.ISO8601().substr(0, 19); + std::string ts = std::string(t.ISO8601().substr(0, 19)); // YYYY_MM_DDThh_mm_ss -> YYYYMMDD_hhmmss ts.erase(std::remove(ts.begin(), ts.end(), '-'), ts.end()); @@ -289,7 +289,7 @@ std::string timeStringify(TemporalTileProvider::TimeFormatType type, const Time& return ts; } case TemporalTileProvider::TimeFormatType::YYYYMMDD_hhmm: { - std::string ts = t.ISO8601().substr(0, 16); + std::string ts = std::string(t.ISO8601().substr(0, 16)); // YYYY_MM_DDThh_mm -> YYYYMMDD_hhmm ts.erase(std::remove(ts.begin(), ts.end(), '-'), ts.end()); @@ -298,9 +298,9 @@ std::string timeStringify(TemporalTileProvider::TimeFormatType type, const Time& return ts; } case TemporalTileProvider::TimeFormatType::YYYY_MM_DDThhColonmmColonssZ: - return t.ISO8601().substr(0, 19) + "Z"; + return std::string(t.ISO8601().substr(0, 19)) + "Z"; case TemporalTileProvider::TimeFormatType::YYYY_MM_DDThh_mm_ssZ: { - std::string timeString = t.ISO8601().substr(0, 19) + "Z"; + std::string timeString = std::string(t.ISO8601().substr(0, 19)) + "Z"; replace(timeString.begin(), timeString.end(), ':', '_'); return timeString; } @@ -423,7 +423,10 @@ std::string consumeTemporalMetaData(TemporalTileProvider& t, const std::string& } try { - t.timeQuantizer.setStartEndRange(start.ISO8601(), end.ISO8601()); + t.timeQuantizer.setStartEndRange( + std::string(start.ISO8601()), + std::string(end.ISO8601()) + ); t.timeQuantizer.setResolution(timeResolution); } catch (const ghoul::RuntimeError& e) { diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index 707c7f850e..7638cc5237 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -137,11 +137,11 @@ std::string RangedTime::clamp(const std::string& checkTime) { } } -std::string RangedTime::start() const { +std::string_view RangedTime::start() const { return _start; } -std::string RangedTime::end() const { +std::string_view RangedTime::end() const { return _end; } @@ -174,10 +174,14 @@ std::string DateTime::ISO8601() const { }; double DateTime::J2000() const { - Time t; - std::string timeString = ISO8601(); - t.setTime(timeString); - return t.j2000Seconds(); + char Buffer[20]; + std::memset(Buffer, 0, 20); + fmt::format_to( + Buffer, + "{:0>4}-{:0>2}-{:0>2}T{:0>2}:{:0>2}:{:0>2}", + _year, _month, _day, _hour, _minute, _second + ); + return Time::convertTime(Buffer); } void DateTime::operator=(DateTime& src) { @@ -471,7 +475,7 @@ double TimeQuantizer::computeSecondsFromResolution(const int valueIn, const char bool TimeQuantizer::quantize(Time& t, bool clamp) { ZoneScoped - const std::string unquantizedStr = t.ISO8601(); + std::string_view unquantizedStr = t.ISO8601(); DateTime unquantized(unquantizedStr); // resolutionFraction helps to improve iteration performance constexpr const double ResolutionFraction = 0.7; @@ -514,7 +518,7 @@ bool TimeQuantizer::quantize(Time& t, bool clamp) { return true; } else if (clamp) { - const std::string clampedTime = _timerange.clamp(unquantizedStr); + const std::string clampedTime = _timerange.clamp(std::string(unquantizedStr)); t.setTime(clampedTime); return true; } @@ -612,7 +616,7 @@ std::vector TimeQuantizer::quantized(Time& start, Time& end) { std::vector result; DateTime itr = s; - RangedTime range(start.ISO8601(), end.ISO8601()); + RangedTime range(std::string(start.ISO8601()), std::string(end.ISO8601())); while (range.includes(Time(itr.ISO8601()))) { itr.incrementOnce(static_cast(_resolutionValue), _resolutionUnit); result.push_back(itr.ISO8601()); diff --git a/modules/globebrowsing/src/timequantizer.h b/modules/globebrowsing/src/timequantizer.h index 3d7b00b81a..f439a952cc 100644 --- a/modules/globebrowsing/src/timequantizer.h +++ b/modules/globebrowsing/src/timequantizer.h @@ -76,14 +76,14 @@ public: * * \returns The ISO8601 date/time string that defines the start of the range */ - std::string start() const; + std::string_view start() const; /* * Get the end date/time of the time range * * \returns The ISO8601 date/time string that defines the end of the range */ - std::string end() const; + std::string_view end() const; /* * Set the start date/time of the time range diff --git a/modules/imgui/src/guimissioncomponent.cpp b/modules/imgui/src/guimissioncomponent.cpp index 12886f8821..49a7c9e3b4 100644 --- a/modules/imgui/src/guimissioncomponent.cpp +++ b/modules/imgui/src/guimissioncomponent.cpp @@ -63,7 +63,7 @@ namespace { openspace::gui::CaptionText("Mission Progress"); - ImGui::Text("%s", startTime.UTC().c_str()); + ImGui::Text("%s", std::string(startTime.UTC()).c_str()); ImGui::SameLine(); float v = static_cast(currentTime); const float s = static_cast(startTime.j2000Seconds()); @@ -74,10 +74,10 @@ namespace { &v, s, e, - openspace::global::timeManager.time().UTC().c_str() + std::string(openspace::global::timeManager.time().UTC()).c_str() ); ImGui::SameLine(); - ImGui::Text("%s", endTime.UTC().c_str()); + ImGui::Text("%s", std::string(endTime.UTC()).c_str()); openspace::gui::CaptionText("Phases"); diff --git a/modules/imgui/src/guispacetimecomponent.cpp b/modules/imgui/src/guispacetimecomponent.cpp index f9acbb05ab..132d52f466 100644 --- a/modules/imgui/src/guispacetimecomponent.cpp +++ b/modules/imgui/src/guispacetimecomponent.cpp @@ -211,7 +211,10 @@ void GuiSpaceTimeComponent::render() { ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f); - ImGui::Text("Current Date: %s", global::timeManager.time().UTC().c_str()); + ImGui::Text( + "Current Date: %s", + std::string(global::timeManager.time().UTC()).c_str() + ); constexpr int BufferSize = 256; static char Buffer[BufferSize]; @@ -296,7 +299,7 @@ void GuiSpaceTimeComponent::render() { const bool nowDay = ImGui::Button("Now"); if (nowDay) { - std::string nowTime = Time::now().UTC(); + std::string nowTime = std::string(Time::now().UTC()); // UTC returns a string of the type YYYY MMM DDTHH:mm:ss.xxx // setTime doesn't like the T in it and wants a space instead nowTime[11] = ' '; diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index 5046bb85a9..7d0eb666b9 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -269,8 +269,9 @@ std::string IswaManager::iswaUrl(int id, double timestamp, const std::string& ty } //std::string t = Time::ref().currentTimeUTC(); - std::string t = SpiceManager::ref().dateFromEphemerisTime(timestamp); - std::stringstream ss(t); + std::string_view t = SpiceManager::ref().dateFromEphemerisTime(timestamp); + std::stringstream ss; + ss << t; std::string token; std::getline(ss, token, ' '); diff --git a/modules/server/src/topics/timetopic.cpp b/modules/server/src/topics/timetopic.cpp index 71d422948c..0f69ec293b 100644 --- a/modules/server/src/topics/timetopic.cpp +++ b/modules/server/src/topics/timetopic.cpp @@ -109,7 +109,7 @@ void TimeTopic::sendCurrentTime() { } void TimeTopic::sendFullTimeData() { - const std::string currentTime = global::timeManager.time().ISO8601(); + std::string_view currentTime = global::timeManager.time().ISO8601(); const double deltaTime = global::timeManager.deltaTime(); const double targetDeltaTime = global::timeManager.targetDeltaTime(); const bool isPaused = global::timeManager.isPaused(); diff --git a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp index 7e6e05b87d..1d52867fa5 100644 --- a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp +++ b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp @@ -230,7 +230,7 @@ void DashboardItemInstruments::render(glm::vec2& penPosition) { ghoul::fontrendering::CrDirection::Down ); - std::string str = SpiceManager::ref().dateFromEphemerisTime( + std::string_view str = SpiceManager::ref().dateFromEphemerisTime( sequencer.nextCaptureTime(global::timeManager.time().j2000Seconds()), "YYYY MON DD HR:MN:SC" ); diff --git a/modules/volume/rawvolumemetadata.cpp b/modules/volume/rawvolumemetadata.cpp index 83b24616ef..e7886f57ca 100644 --- a/modules/volume/rawvolumemetadata.cpp +++ b/modules/volume/rawvolumemetadata.cpp @@ -112,12 +112,12 @@ ghoul::Dictionary RawVolumeMetadata::dictionary() { } if (hasTime) { - std::string timeString = Time(time).ISO8601(); + std::string_view timeString = Time(time).ISO8601(); // Do not include time offset in time string if (timeString.back() == 'Z') { - timeString.pop_back(); + timeString = timeString.substr(0, timeString.size() - 1); } - dict.setValue(KeyTime, timeString); + dict.setValue(KeyTime, std::string(timeString)); } return dict; } diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index c0b79c92af..627576a970 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1057,6 +1057,8 @@ void OpenSpaceEngine::writeSceneDocumentation() { void OpenSpaceEngine::preSynchronization() { ZoneScoped + TracyGpuZone("preSynchronization") + LTRACE("OpenSpaceEngine::preSynchronization(begin)"); FileSys.triggerFilesystemEvents(); @@ -1125,6 +1127,7 @@ void OpenSpaceEngine::preSynchronization() { void OpenSpaceEngine::postSynchronizationPreDraw() { ZoneScoped + TracyGpuZone("postSynchronizationPreDraw") LTRACE("OpenSpaceEngine::postSynchronizationPreDraw(begin)"); bool master = global::windowDelegate.isMaster(); @@ -1196,6 +1199,7 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& view const glm::mat4& projectionMatrix) { ZoneScoped + TracyGpuZone("Render") LTRACE("OpenSpaceEngine::render(begin)"); const bool isGuiWindow = @@ -1220,6 +1224,7 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& view void OpenSpaceEngine::drawOverlays() { ZoneScoped + TracyGpuZone("Draw2D") LTRACE("OpenSpaceEngine::drawOverlays(begin)"); const bool isGuiWindow = @@ -1244,6 +1249,7 @@ void OpenSpaceEngine::drawOverlays() { void OpenSpaceEngine::postDraw() { ZoneScoped + TracyGpuZone("postDraw") LTRACE("OpenSpaceEngine::postDraw(begin)"); global::renderEngine.postDraw(); diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index e637d25e42..19de9034df 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -1132,6 +1132,7 @@ void FramebufferRenderer::updateDownscaledVolume() { void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFactor) { ZoneScoped + TracyGpuZone("FramebufferRenderer") GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); @@ -1177,25 +1178,31 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac RendererTasks tasks; { + TracyGpuZone("Background") GLDebugGroup group("Background"); data.renderBinMask = static_cast(Renderable::RenderBin::Background); scene->render(data, tasks); } { + TracyGpuZone("Opaque") GLDebugGroup group("Opaque"); data.renderBinMask = static_cast(Renderable::RenderBin::Opaque); scene->render(data, tasks); } { + TracyGpuZone("PreDeferredTransparent") GLDebugGroup group("PreDeferredTransparent"); - data.renderBinMask = static_cast(Renderable::RenderBin::PreDeferredTransparent); + data.renderBinMask = static_cast( + Renderable::RenderBin::PreDeferredTransparent + ); scene->render(data, tasks); } // Run Volume Tasks { + TracyGpuZone("Raycaster Tasks") GLDebugGroup group("Raycaster Tasks"); performRaycasterTasks(tasks.raycasterTasks); @@ -1205,6 +1212,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac } if (!tasks.deferredcasterTasks.empty()) { + TracyGpuZone("Deferred Caster Tasks") GLDebugGroup group("Deferred Caster Tasks"); // We use ping pong rendering in order to be able to @@ -1220,12 +1228,16 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glEnablei(GL_BLEND, 0); { + TracyGpuZone("PostDeferredTransparent") GLDebugGroup group("PostDeferredTransparent"); - data.renderBinMask = static_cast(Renderable::RenderBin::PostDeferredTransparent); + data.renderBinMask = static_cast( + Renderable::RenderBin::PostDeferredTransparent + ); scene->render(data, tasks); } { + TracyGpuZone("Overlay") GLDebugGroup group("Overlay"); data.renderBinMask = static_cast(Renderable::RenderBin::Overlay); scene->render(data, tasks); @@ -1252,12 +1264,14 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac { // Apply the selected TMO on the results and resolve the result to the default FBO + TracyGpuZone("Apply TMO") GLDebugGroup group("Apply TMO"); applyTMO(blackoutFactor); } if (_enableFXAA) { + TracyGpuZone("Apply FXAA") GLDebugGroup group("Apply FXAA"); glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); applyFXAA(); @@ -1268,6 +1282,8 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector ZoneScoped for (const RaycasterTask& raycasterTask : tasks) { + TracyGpuZone("Raycaster") + VolumeRaycaster* raycaster = raycasterTask.raycaster; glBindFramebuffer(GL_FRAMEBUFFER, _exitFramebuffer); @@ -1399,6 +1415,8 @@ void FramebufferRenderer::performDeferredTasks( ZoneScoped for (const DeferredcasterTask& deferredcasterTask : tasks) { + TracyGpuZone("Deferredcaster") + Deferredcaster* deferredcaster = deferredcasterTask.deferredcaster; ghoul::opengl::ProgramObject* deferredcastProgram = nullptr; diff --git a/src/scene/profile_lua.inl b/src/scene/profile_lua.inl index 1c2c904ee7..a60c6b4c59 100644 --- a/src/scene/profile_lua.inl +++ b/src/scene/profile_lua.inl @@ -80,7 +80,7 @@ int saveSettingsToProfile(lua_State* L) { } const properties::PropertyOwner& root = global::rootPropertyOwner; - std::string currentTime = global::timeManager.time().ISO8601(); + std::string currentTime = std::string(global::timeManager.time().ISO8601()); interaction::NavigationHandler::NavigationState navState = global::navigationHandler.navigationState(); global::profile.saveCurrentSettingsToProfile(root, currentTime, navState); diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index 7792a6b2ce..e5ff380b61 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -43,18 +43,6 @@ namespace { // as the maximum message length constexpr const unsigned SpiceErrorBufferSize = 1841; - // This method checks if one of the previous SPICE methods has failed. If it has, an - // exception with the SPICE error message is thrown - // If an error occurred, true is returned, otherwise, false - void throwSpiceError(const std::string& errorMessage) { - if (openspace::SpiceManager::ref().exceptionHandling()) { - char buffer[SpiceErrorBufferSize]; - getmsg_c("LONG", SpiceErrorBufferSize, buffer); - reset_c(); - throw openspace::SpiceManager::SpiceException(errorMessage + ": " + buffer); - } - } - const char* toString(openspace::SpiceManager::FieldOfViewMethod m) { using SM = openspace::SpiceManager; switch (m) { @@ -196,6 +184,18 @@ SpiceManager& SpiceManager::ref() { return *_instance; } +// This method checks if one of the previous SPICE methods has failed. If it has, an +// exception with the SPICE error message is thrown +// If an error occurred, true is returned, otherwise, false +void throwSpiceError(const std::string& errorMessage) { + if (openspace::SpiceManager::ref().exceptionHandling()) { + char buffer[SpiceErrorBufferSize]; + getmsg_c("LONG", SpiceErrorBufferSize, buffer); + reset_c(); + throw openspace::SpiceManager::SpiceException(errorMessage + ": " + buffer); + } +} + SpiceManager::KernelHandle SpiceManager::loadKernel(std::string filePath) { ghoul_assert(!filePath.empty(), "Empty file path"); ghoul_assert( @@ -474,58 +474,20 @@ double SpiceManager::spacecraftClockToET(const std::string& craft, double craftT double SpiceManager::ephemerisTimeFromDate(const std::string& timeString) const { ghoul_assert(!timeString.empty(), "Empty timeString"); + return ephemerisTimeFromDate(timeString.c_str()); +} + +double SpiceManager::ephemerisTimeFromDate(const char* timeString) const { + ghoul_assert(!timeString.empty(), "Empty timeString"); + double et; - str2et_c(timeString.c_str(), &et); + str2et_c(timeString, &et); if (failed_c()) { throwSpiceError(fmt::format("Error converting date '{}'", timeString)); } return et; } -std::string SpiceManager::dateFromEphemerisTime(double ephemerisTime, - std::string_view format) const -{ - ghoul_assert(!formatString.empty(), "Format is empty"); - ghoul_assert(formatString.back() == '\0', "Format string must be null-terminated"); - - if (format.size() < 32) { - constexpr const int BufferSize = 32; - SpiceChar buffer[BufferSize]; - dateFromEphemerisTime(ephemerisTime, buffer, BufferSize, format); - return std::string(buffer); - } - else if (format.size() < 256) { - constexpr const int BufferSize = 256; - SpiceChar buffer[BufferSize]; - dateFromEphemerisTime(ephemerisTime, buffer, BufferSize, format); - return std::string(buffer); - } - else { - std::string res; - res.resize(format.size() + 1); - dateFromEphemerisTime(ephemerisTime, res.data(), format.size(), format); - return res; - } -} - -void SpiceManager::dateFromEphemerisTime(double ephemerisTime, char* outBuf, - int bufferSize, - std::string_view formatString) const -{ - ghoul_assert(!formatString.empty(), "Format is empty"); - ghoul_assert(formatString.back() == '\0', "Format string must be null-terminated"); - ghoul_assert(formatString.size() > bufferSize - 1, "Buffer size too small"); - - timout_c(ephemerisTime, formatString.data(), bufferSize - 1, outBuf); - if (failed_c()) { - throwSpiceError( - fmt::format("Error converting ephemeris time '{}' to date with format '{}'", - ephemerisTime, formatString - ) - ); - } -} - glm::dvec3 SpiceManager::targetPosition(const std::string& target, const std::string& observer, const std::string& referenceFrame, diff --git a/src/util/time.cpp b/src/util/time.cpp index f9ad8bc102..cf5600108d 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -24,7 +24,9 @@ #include +#include #include +#include #include #include #include @@ -43,6 +45,10 @@ double Time::convertTime(const std::string& time) { return SpiceManager::ref().ephemerisTimeFromDate(time); } +double Time::convertTime(const char* time) { + return SpiceManager::ref().ephemerisTimeFromDate(time); +} + Time::Time(double secondsJ2000) : _time(secondsJ2000) {} Time::Time(const std::string& time) : @@ -79,17 +85,26 @@ void Time::setTime(const std::string& time) { _time = SpiceManager::ref().ephemerisTimeFromDate(time); } -std::string Time::UTC() const { - return SpiceManager::ref().dateFromEphemerisTime(_time); +std::string_view Time::UTC() const { + constexpr const char Format[] = "YYYY MON DDTHR:MN:SC.### ::RND"; + char* b = reinterpret_cast(global::memoryManager.TemporaryMemory.allocate(32)); + std::memset(b, 0, 32); + + SpiceManager::ref().dateFromEphemerisTime(_time, b, 32, Format); + + return std::string_view(b, 32); } -std::string Time::ISO8601() const { +std::string_view Time::ISO8601() const { ZoneScoped - return SpiceManager::ref().dateFromEphemerisTime( - _time, - "YYYY-MM-DDTHR:MN:SC.###" - ); + constexpr const char Format[] = "YYYY-MM-DDTHR:MN:SC.###"; + char* b = reinterpret_cast(global::memoryManager.TemporaryMemory.allocate(24)); + std::memset(b, 0, 24); + + SpiceManager::ref().dateFromEphemerisTime(_time, b, 24, Format); + + return std::string_view(b, 24); } scripting::LuaLibrary Time::luaLibrary() { diff --git a/src/util/time_lua.inl b/src/util/time_lua.inl index 008f129b91..0437105147 100644 --- a/src/util/time_lua.inl +++ b/src/util/time_lua.inl @@ -506,7 +506,7 @@ int time_interpolateTimeRelative(lua_State* L) { * It is returned by calling the Time::currentTime method. */ int time_currentTime(lua_State* L) { - lua_pushnumber(L, global::timeManager.time().j2000Seconds()); + ghoul::lua::push(L, global::timeManager.time().j2000Seconds()); ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } @@ -518,7 +518,7 @@ int time_currentTime(lua_State* L) { * timezone by calling the Time::UTC method */ int time_currentTimeUTC(lua_State* L) { - lua_pushstring(L, global::timeManager.time().UTC().c_str()); + ghoul::lua::push(L, global::timeManager.time().UTC()); ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } From dc63946fefcf68c99cf34c918df011e14371c3bf Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 20 Aug 2020 11:08:49 +0200 Subject: [PATCH 29/59] Expose the const char* functionality for Spice to prevent unnecessary string creation --- include/openspace/util/time.h | 1 + modules/globebrowsing/src/timequantizer.cpp | 21 ++++++++++++++------- modules/globebrowsing/src/timequantizer.h | 2 +- src/util/time.cpp | 4 ++++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/include/openspace/util/time.h b/include/openspace/util/time.h index d055971725..e8db9a5694 100644 --- a/include/openspace/util/time.h +++ b/include/openspace/util/time.h @@ -101,6 +101,7 @@ public: * \param time The time to be set as a date string */ void setTime(const std::string& time); + void setTime(const char* time); /** * Returns the current time as the number of seconds past the J2000 epoch. If the diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index 7638cc5237..ef4998bdf7 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -122,15 +122,15 @@ bool RangedTime::includes(const Time& checkTime) const { return (_startJ2000 <= tj && tj <= _endJ2000); } -std::string RangedTime::clamp(const std::string& checkTime) { +const char* RangedTime::clamp(const char* checkTime) { Time t; t.setTime(checkTime); const double tj = t.j2000Seconds(); if (tj < _startJ2000) { - return _start; + return _start.c_str(); } else if (tj > _endJ2000) { - return _end; + return _end.c_str(); } else { return checkTime; @@ -485,7 +485,6 @@ bool TimeQuantizer::quantize(Time& t, bool clamp) { int lastDecr = 0; if (_timerange.includes(t)) { - ZoneScopedN("includes") DateTime quantized = DateTime(_timerange.start()); doFirstApproximation(quantized, unquantized, _resolutionValue, _resolutionUnit); double error = unquantized.J2000() - quantized.J2000(); @@ -513,12 +512,20 @@ bool TimeQuantizer::quantize(Time& t, bool clamp) { break; } } - quantized.setTime(_timerange.clamp(quantized.ISO8601())); - t.setTime(quantized.J2000()); + char Buffer[20]; + std::memset(Buffer, 0, 20); + fmt::format_to( + Buffer, + "{:0>4}-{:0>2}-{:0>2}T{:0>2}:{:0>2}:{:0>2}", + quantized.year(), quantized.month(), quantized.day(), + quantized.hour(), quantized.minute(), quantized.second() + ); + + t.setTime(_timerange.clamp(Buffer)); return true; } else if (clamp) { - const std::string clampedTime = _timerange.clamp(std::string(unquantizedStr)); + const std::string clampedTime = _timerange.clamp(std::string(unquantizedStr).c_str()); t.setTime(clampedTime); return true; } diff --git a/modules/globebrowsing/src/timequantizer.h b/modules/globebrowsing/src/timequantizer.h index f439a952cc..b940c8fe43 100644 --- a/modules/globebrowsing/src/timequantizer.h +++ b/modules/globebrowsing/src/timequantizer.h @@ -69,7 +69,7 @@ public: * less than start, equal to end if greater than end, or equal to input * parameter if falls in-between */ - std::string clamp(const std::string& checkTime); + const char* clamp(const char* checkTime); /* * Get the start date/time of the time range diff --git a/src/util/time.cpp b/src/util/time.cpp index cf5600108d..9e4f56ed85 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -85,6 +85,10 @@ void Time::setTime(const std::string& time) { _time = SpiceManager::ref().ephemerisTimeFromDate(time); } +void Time::setTime(const char* time) { + _time = SpiceManager::ref().ephemerisTimeFromDate(time); +} + std::string_view Time::UTC() const { constexpr const char Format[] = "YYYY MON DDTHR:MN:SC.### ::RND"; char* b = reinterpret_cast(global::memoryManager.TemporaryMemory.allocate(32)); From 1547609dad2262481da6ef68ed62900c53b5474d Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 20 Aug 2020 14:15:13 +0200 Subject: [PATCH 30/59] Remove dynamic memory allocations from the quantize function --- include/openspace/util/spicemanager.h | 3 +- include/openspace/util/time.h | 12 +++- modules/globebrowsing/src/tileprovider.cpp | 68 ++++++++++++--------- modules/globebrowsing/src/timequantizer.cpp | 24 ++++++-- src/util/time.cpp | 16 +++-- 5 files changed, 81 insertions(+), 42 deletions(-) diff --git a/include/openspace/util/spicemanager.h b/include/openspace/util/spicemanager.h index 2768e29a59..0c6be16e2c 100644 --- a/include/openspace/util/spicemanager.h +++ b/include/openspace/util/spicemanager.h @@ -26,6 +26,7 @@ #define __OPENSPACE_CORE___SPICEMANAGER___H__ #include +#include #include #include #include @@ -500,7 +501,7 @@ public: static_assert(N != 0, "Format must not be empty"); ghoul_assert(N > bufferSize - 1, "Buffer size too small"); - timout_c(ephemerisTime, format, bufferSize - 1, outBuf); + timout_c(ephemerisTime, format, bufferSize, outBuf); if (failed_c()) { throwSpiceError(fmt::format( "Error converting ephemeris time '{}' to date with format '{}'", diff --git a/include/openspace/util/time.h b/include/openspace/util/time.h index e8db9a5694..9a08d6a704 100644 --- a/include/openspace/util/time.h +++ b/include/openspace/util/time.h @@ -118,11 +118,17 @@ public: std::string_view UTC() const; /** - * Returns the current time as a ISO 8601 formatted, i.e YYYY-MM-DDThh:mm:ssZ - * \return The current time as a ISO 8601 formatted string - */ + * Returns the current time as a ISO 8601 formatted, i.e YYYY-MM-DDThh:mm:ssZ + * \return The current time as a ISO 8601 formatted string + */ std::string_view ISO8601() const; + /** + * Creates the current time as a ISO 8601 formatted, i.e YYYY-MM-DDThh:mm:ssZ into the + * provided Buffer. The buffer needs to have space for 25 characters. + */ + void ISO8601(char* buffer) const; + /** * Advances the simulation time using the deltaTime() and the tickTime. * The deltaTime() is the number of simulation seconds that pass for each real-time diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index fc0f9b4a2c..39cb0e2381 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -273,36 +274,46 @@ TileProvider* levelProvider(TileProviderByLevel& t, int level) { // TemporalTileProvider // -std::string timeStringify(TemporalTileProvider::TimeFormatType type, const Time& t) { +// Buffer needs at least 22 characters space +int timeStringify(TemporalTileProvider::TimeFormatType type, const Time& t, char* buffer) +{ ZoneScoped + std::memset(buffer, 0, 22); + const double time = t.j2000Seconds(); + switch (type) { case TemporalTileProvider::TimeFormatType::YYYY_MM_DD: - return std::string(t.ISO8601().substr(0, 10)); + { + constexpr const char Format[] = "YYYY-MM-DD"; + constexpr const int Size = sizeof(Format); + SpiceManager::ref().dateFromEphemerisTime(time, buffer, Size, Format); + return Size - 1; + } case TemporalTileProvider::TimeFormatType::YYYYMMDD_hhmmss: { - std::string ts = std::string(t.ISO8601().substr(0, 19)); - - // YYYY_MM_DDThh_mm_ss -> YYYYMMDD_hhmmss - ts.erase(std::remove(ts.begin(), ts.end(), '-'), ts.end()); - ts.erase(std::remove(ts.begin(), ts.end(), ':'), ts.end()); - replace(ts.begin(), ts.end(), 'T', '_'); - return ts; + constexpr const char Format[] = "YYYYMMDD_HRMNSC"; + constexpr const int Size = sizeof(Format); + SpiceManager::ref().dateFromEphemerisTime(time, buffer, Size, Format); + return Size - 1; } case TemporalTileProvider::TimeFormatType::YYYYMMDD_hhmm: { - std::string ts = std::string(t.ISO8601().substr(0, 16)); - - // YYYY_MM_DDThh_mm -> YYYYMMDD_hhmm - ts.erase(std::remove(ts.begin(), ts.end(), '-'), ts.end()); - ts.erase(std::remove(ts.begin(), ts.end(), ':'), ts.end()); - replace(ts.begin(), ts.end(), 'T', '_'); - return ts; + constexpr const char Format[] = "YYYYMMDD_HRMN"; + constexpr const int Size = sizeof(Format); + SpiceManager::ref().dateFromEphemerisTime(time, buffer, Size, Format); + return Size - 1; } case TemporalTileProvider::TimeFormatType::YYYY_MM_DDThhColonmmColonssZ: - return std::string(t.ISO8601().substr(0, 19)) + "Z"; + { + constexpr const char Format[] = "YYYY-MM-DDTHR:MN:SCZ"; + constexpr const int Size = sizeof(Format); + SpiceManager::ref().dateFromEphemerisTime(time, buffer, Size, Format); + return Size - 1; + } case TemporalTileProvider::TimeFormatType::YYYY_MM_DDThh_mm_ssZ: { - std::string timeString = std::string(t.ISO8601().substr(0, 19)) + "Z"; - replace(timeString.begin(), timeString.end(), ':', '_'); - return timeString; + constexpr const char Format[] = "YYYY-MM-DDTHR_MN_SCZ"; + constexpr const int Size = sizeof(Format); + SpiceManager::ref().dateFromEphemerisTime(time, buffer, Size, Format); + return Size - 1; } default: throw ghoul::MissingCaseException(); @@ -310,7 +321,7 @@ std::string timeStringify(TemporalTileProvider::TimeFormatType type, const Time& } std::unique_ptr initTileProvider(TemporalTileProvider& t, - const TemporalTileProvider::TimeKey& timekey) + std::string_view timekey) { ZoneScoped @@ -339,12 +350,12 @@ std::unique_ptr initTileProvider(TemporalTileProvider& t, return std::make_unique(t.initDict); } -TileProvider* getTileProvider(TemporalTileProvider& t, - const TemporalTileProvider::TimeKey& timekey) -{ +TileProvider* getTileProvider(TemporalTileProvider& t, std::string_view timekey) { ZoneScoped - const auto it = t.tileProviderMap.find(timekey); + // @TODO (abock, 2020-08-20) This std::string creation can be removed once we switch + // to C++20 thanks to P0919R2 + const auto it = t.tileProviderMap.find(std::string(timekey)); if (it != t.tileProviderMap.end()) { return it->second.get(); } @@ -353,7 +364,7 @@ TileProvider* getTileProvider(TemporalTileProvider& t, initialize(*tileProvider); TileProvider* res = tileProvider.get(); - t.tileProviderMap[timekey] = std::move(tileProvider); + t.tileProviderMap[std::string(timekey)] = std::move(tileProvider); return res; } } @@ -363,9 +374,10 @@ TileProvider* getTileProvider(TemporalTileProvider& t, const Time& time) { Time tCopy(time); if (t.timeQuantizer.quantize(tCopy, true)) { - TemporalTileProvider::TimeKey timeKey = timeStringify(t.timeFormat, tCopy); + char Buffer[22]; + const int size = timeStringify(t.timeFormat, tCopy, Buffer); try { - return getTileProvider(t, timeKey); + return getTileProvider(t, std::string_view(Buffer, size)); } catch (const ghoul::RuntimeError& e) { LERRORC("TemporalTileProvider", e.message); diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index ef4998bdf7..78e58e1f25 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -475,8 +476,17 @@ double TimeQuantizer::computeSecondsFromResolution(const int valueIn, const char bool TimeQuantizer::quantize(Time& t, bool clamp) { ZoneScoped - std::string_view unquantizedStr = t.ISO8601(); - DateTime unquantized(unquantizedStr); + constexpr const char Format[] = "YYYY-MM-DDTHR:MN:SC.###"; + constexpr const int BufferSize = sizeof(Format); + char unquantizedString[BufferSize]; + std::memset(unquantizedString, 0, BufferSize); + SpiceManager::ref().dateFromEphemerisTime( + t.j2000Seconds(), + unquantizedString, BufferSize, + Format + ); + + DateTime unquantized(std::string_view(unquantizedString, BufferSize)); // resolutionFraction helps to improve iteration performance constexpr const double ResolutionFraction = 0.7; constexpr const int IterationLimit = 50; @@ -525,8 +535,7 @@ bool TimeQuantizer::quantize(Time& t, bool clamp) { return true; } else if (clamp) { - const std::string clampedTime = _timerange.clamp(std::string(unquantizedStr).c_str()); - t.setTime(clampedTime); + t.setTime(_timerange.clamp(unquantizedString)); return true; } else { @@ -561,13 +570,16 @@ void TimeQuantizer::doFirstApproximation(DateTime& quantized, DateTime& unQ, dou } case 'd': { - const double error = (unQ.J2000() - quantized.J2000()) / (60 * 60 * 24); + const double error = (unQ.J2000() - quantized.J2000()) / (60.0 * 60.0 * 24.0); const int originalHour = quantized.hour(); const int originalMinute = quantized.minute(); const int originalSecond = quantized.second(); const double addToTime = std::round(error) * 86400; Time testDay(quantized.J2000() + addToTime); - quantized.setTime(testDay.ISO8601()); + + char Buffer[24]; + testDay.ISO8601(Buffer); + quantized.setTime(std::string_view(Buffer, 24)); quantized.setHour(originalHour); quantized.setMinute(originalMinute); quantized.setSecond(originalSecond); diff --git a/src/util/time.cpp b/src/util/time.cpp index 9e4f56ed85..b8ceb9167c 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -103,12 +103,20 @@ std::string_view Time::ISO8601() const { ZoneScoped constexpr const char Format[] = "YYYY-MM-DDTHR:MN:SC.###"; - char* b = reinterpret_cast(global::memoryManager.TemporaryMemory.allocate(24)); - std::memset(b, 0, 24); + constexpr const int S = sizeof(Format); + char* b = reinterpret_cast(global::memoryManager.TemporaryMemory.allocate(S)); + std::memset(b, 0, S); - SpiceManager::ref().dateFromEphemerisTime(_time, b, 24, Format); + SpiceManager::ref().dateFromEphemerisTime(_time, b, S, Format); - return std::string_view(b, 24); + return std::string_view(b, S); +} + +void Time::ISO8601(char* buffer) const { + constexpr const char Format[] = "YYYY-MM-DDTHR:MN:SC.###"; + constexpr const int S = sizeof(Format) + 1; + std::memset(buffer, 0, S); + SpiceManager::ref().dateFromEphemerisTime(_time, buffer, S, Format); } scripting::LuaLibrary Time::luaLibrary() { From 015168f651aa820e8fe47f74f79c0de5aa44f7d0 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 20 Aug 2020 14:52:27 +0200 Subject: [PATCH 31/59] update submodules No longer show log levels in log messages from SGCT twice --- apps/OpenSpace/ext/sgct | 2 +- apps/OpenSpace/main.cpp | 1 + ext/ghoul | 2 +- modules/server/servermodule.cpp | 5 +++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index b712e64848..96191ba658 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit b712e6484894d70a60277bdcf719613b217954a7 +Subproject commit 96191ba658700f60eedf7842ecffa851583f8768 diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index b4860fdeaf..93708a7cd8 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -1266,6 +1266,7 @@ int main(int argc, char** argv) { Log::instance().setLogToConsole(false); Log::instance().setShowTime(false); + Log::instance().setShowLogLevel(false); Log::instance().setLogCallback(mainLogCallback); #ifdef __APPLE__ diff --git a/ext/ghoul b/ext/ghoul index d073de9ab1..d8aa4871fe 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit d073de9ab1b81b234a5a1cf55fdec36f029fc639 +Subproject commit d8aa4871fe29ac56002b5b3b85f380ecc3255e08 diff --git a/modules/server/servermodule.cpp b/modules/server/servermodule.cpp index 47974dfe50..6d527b60b4 100644 --- a/modules/server/servermodule.cpp +++ b/modules/server/servermodule.cpp @@ -204,8 +204,9 @@ void ServerModule::handleConnection(std::shared_ptr connection) { ZoneScoped std::string messageString; + messageString.reserve(256); while (connection->socket()->getMessage(messageString)) { - std::lock_guard lock(_messageQueueMutex); + std::lock_guard lock(_messageQueueMutex); _messageQueue.push_back({ connection, std::move(messageString) }); } } @@ -213,7 +214,7 @@ void ServerModule::handleConnection(std::shared_ptr connection) { void ServerModule::consumeMessages() { ZoneScoped - std::lock_guard lock(_messageQueueMutex); + std::lock_guard lock(_messageQueueMutex); while (!_messageQueue.empty()) { const Message& m = _messageQueue.front(); if (std::shared_ptr c = m.connection.lock()) { From 7f5568581ac2306e548a7bb8dbe81786d5f8e138 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 20 Aug 2020 15:10:39 +0200 Subject: [PATCH 32/59] Debug mode compile fix --- src/util/spicemanager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index e5ff380b61..ab1bfb678a 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -478,8 +478,6 @@ double SpiceManager::ephemerisTimeFromDate(const std::string& timeString) const } double SpiceManager::ephemerisTimeFromDate(const char* timeString) const { - ghoul_assert(!timeString.empty(), "Empty timeString"); - double et; str2et_c(timeString, &et); if (failed_c()) { From 5aa2db28315dc0eec1a03275ec55b3eb3cbfaf12 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 20 Aug 2020 15:27:52 +0200 Subject: [PATCH 33/59] One more usecase of not creating a temporary std::string --- apps/OpenSpace/main.cpp | 2 +- ext/ghoul | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 0ff37673f3..f8b3467666 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -681,7 +681,7 @@ void mainDecodeFun(const std::vector& data, unsigned int) { void mainLogCallback(Log::Level level, const char* message) { ZoneScoped - std::string msg = message; + std::string_view msg = message; switch (level) { case Log::Level::Debug: LDEBUGC("SGCT", msg); diff --git a/ext/ghoul b/ext/ghoul index d8aa4871fe..2341b411c5 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit d8aa4871fe29ac56002b5b3b85f380ecc3255e08 +Subproject commit 2341b411c512e5dffd3cfd4713eed9f9c625da43 From 83622ce3395bbea12721c104cb5d2d1a53cc4ef9 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 21 Aug 2020 11:16:37 +0200 Subject: [PATCH 34/59] Add some more profilng code Update Ghoul repository --- ext/ghoul | 2 +- modules/globebrowsing/globebrowsingmodule.cpp | 6 +-- modules/globebrowsing/src/gdalwrapper.cpp | 3 ++ .../src/memoryawaretilecache.cpp | 19 ++++++- .../globebrowsing/src/memoryawaretilecache.h | 2 +- src/rendering/framebufferrenderer.cpp | 24 ++++++++- src/rendering/luaconsole.cpp | 2 +- src/rendering/renderengine.cpp | 51 +++++++++++++------ 8 files changed, 84 insertions(+), 25 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 2341b411c5..b461a01bcf 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 2341b411c512e5dffd3cfd4713eed9f9c625da43 +Subproject commit b461a01bcf07f5d43ede84e9d7984b9488863388 diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index 5c93d78964..89972ee1fb 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -219,10 +219,8 @@ void GlobeBrowsingModule::internalInitialize(const ghoul::Dictionary& dict) { global::callback::initializeGL.emplace_back([&]() { ZoneScopedN("GlobeBrowsingModule") - _tileCache = std::make_unique( - _tileCacheSizeMB - ); - addPropertySubOwner(*_tileCache); + _tileCache = std::make_unique(_tileCacheSizeMB); + addPropertySubOwner(_tileCache.get()); tileprovider::initializeDefaultTile(); diff --git a/modules/globebrowsing/src/gdalwrapper.cpp b/modules/globebrowsing/src/gdalwrapper.cpp index 976fa193e8..f8992d84d1 100644 --- a/modules/globebrowsing/src/gdalwrapper.cpp +++ b/modules/globebrowsing/src/gdalwrapper.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -106,6 +107,8 @@ GdalWrapper::GdalWrapper(size_t maximumCacheSize, size_t maximumMaximumCacheSize 1 // Step: One MB ) { + ZoneScoped + addProperty(_logGdalErrors); addProperty(_gdalMaximumCacheSize); diff --git a/modules/globebrowsing/src/memoryawaretilecache.cpp b/modules/globebrowsing/src/memoryawaretilecache.cpp index c6106137b1..79af26375d 100644 --- a/modules/globebrowsing/src/memoryawaretilecache.cpp +++ b/modules/globebrowsing/src/memoryawaretilecache.cpp @@ -195,10 +195,15 @@ MemoryAwareTileCache::TextureContainer::TextureContainer(TileTextureInitData ini : _initData(std::move(initData)) , _numTextures(numTextures) { + ZoneScoped + + _textures.reserve(_numTextures); reset(); } void MemoryAwareTileCache::TextureContainer::reset() { + ZoneScoped + _textures.clear(); _freeTexture = 0; for (size_t i = 0; i < _numTextures; ++i) { @@ -222,6 +227,8 @@ void MemoryAwareTileCache::TextureContainer::reset() { } void MemoryAwareTileCache::TextureContainer::reset(size_t numTextures) { + ZoneScoped + _numTextures = numTextures; reset(); } @@ -260,6 +267,8 @@ MemoryAwareTileCache::MemoryAwareTileCache(int tileCacheSize) , _applyTileCacheSize(ApplyTileCacheInfo) , _clearTileCache(ClearTileCacheInfo) { + ZoneScoped + createDefaultTextureContainers(); _clearTileCache.onChange([&]() { clear(); }); @@ -303,6 +312,8 @@ void MemoryAwareTileCache::clear() { } void MemoryAwareTileCache::createDefaultTextureContainers() { + ZoneScoped + for (int id = 0; id < layergroupid::NUM_LAYER_GROUPS; id++) { TileTextureInitData initData = tileTextureInitData( layergroupid::GroupID(id), @@ -315,6 +326,8 @@ void MemoryAwareTileCache::createDefaultTextureContainers() { void MemoryAwareTileCache::assureTextureContainerExists( const TileTextureInitData& initData) { + ZoneScoped + TileTextureInitData::HashKey initDataKey = initData.hashKey; if (_textureContainerMap.find(initDataKey) == _textureContainerMap.end()) { // For now create 500 textures of this type @@ -328,9 +341,11 @@ void MemoryAwareTileCache::assureTextureContainerExists( } void MemoryAwareTileCache::setSizeEstimated(size_t estimatedSize) { - LDEBUG("Resetting tile cache size"); + ZoneScoped ghoul_assert(!_textureContainerMap.empty(), "Texture containers must exist."); + LDEBUG("Resetting tile cache size"); + const size_t sumTextureTypeSize = std::accumulate( _textureContainerMap.cbegin(), _textureContainerMap.cend(), @@ -353,6 +368,8 @@ void MemoryAwareTileCache::setSizeEstimated(size_t estimatedSize) { } void MemoryAwareTileCache::resetTextureContainerSize(size_t numTexturesPerTextureType) { + ZoneScoped + _numTextureBytesAllocatedOnCPU = 0; for (std::pair& p : _textureContainerMap) diff --git a/modules/globebrowsing/src/memoryawaretilecache.h b/modules/globebrowsing/src/memoryawaretilecache.h index 41e90a1c32..83771c3996 100644 --- a/modules/globebrowsing/src/memoryawaretilecache.h +++ b/modules/globebrowsing/src/memoryawaretilecache.h @@ -84,7 +84,7 @@ struct ProviderTileHasher { class MemoryAwareTileCache : public properties::PropertyOwner { public: - MemoryAwareTileCache(int tileCacheSize = 1024); + explicit MemoryAwareTileCache(int tileCacheSize = 1024); void clear(); void setSizeEstimated(size_t estimatedSize); diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index 19de9034df..b904b2fa85 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -162,6 +162,7 @@ namespace openspace { void FramebufferRenderer::initialize() { ZoneScoped + TracyGpuZone("Rendering initialize"); LDEBUG("Initializing FramebufferRenderer"); @@ -479,6 +480,9 @@ void FramebufferRenderer::initialize() { } void FramebufferRenderer::deinitialize() { + ZoneScoped + TracyGpuZone("Renderer deinitialize") + LINFO("Deinitializing FramebufferRenderer"); glDeleteFramebuffers(1, &_gBuffers.framebuffer); @@ -523,6 +527,9 @@ void FramebufferRenderer::deferredcastersChanged(Deferredcaster&, } void FramebufferRenderer::applyTMO(float blackoutFactor) { + ZoneScoped + TracyGpuZone("applyTMO") + _hdrFilteringProgram->activate(); ghoul::opengl::TextureUnit hdrFeedingTextureUnit; @@ -797,6 +804,9 @@ void FramebufferRenderer::update() { } void FramebufferRenderer::updateResolution() { + ZoneScoped + TracyGpuZone("Renderer updateResolution") + glBindTexture(GL_TEXTURE_2D, _gBuffers.colorTexture); glTexImage2D( GL_TEXTURE_2D, @@ -983,6 +993,8 @@ void FramebufferRenderer::updateResolution() { } void FramebufferRenderer::updateRaycastData() { + ZoneScoped + _raycastData.clear(); _exitPrograms.clear(); _raycastPrograms.clear(); @@ -993,6 +1005,8 @@ void FramebufferRenderer::updateRaycastData() { int nextId = 0; for (VolumeRaycaster* raycaster : raycasters) { + ZoneScopedN("raycaster") + RaycastData data = { nextId++, "Helper" }; const std::string& vsPath = raycaster->boundsVertexShaderPath(); @@ -1107,6 +1121,8 @@ void FramebufferRenderer::updateDeferredcastData() { void FramebufferRenderer::updateHDRAndFiltering() { + ZoneScoped + _hdrFilteringProgram = ghoul::opengl::ProgramObject::Build( "HDR and Filtering Program", absPath("${SHADERS}/framebuffer/hdrAndFiltering.vert"), @@ -1115,6 +1131,8 @@ void FramebufferRenderer::updateHDRAndFiltering() { } void FramebufferRenderer::updateFXAA() { + ZoneScoped + _fxaaProgram = ghoul::opengl::ProgramObject::Build( "FXAA Program", absPath("${SHADERS}/framebuffer/fxaa.vert"), @@ -1123,7 +1141,9 @@ void FramebufferRenderer::updateFXAA() { } void FramebufferRenderer::updateDownscaledVolume() { - _downscaledVolumeProgram = ghoul::opengl::ProgramObject::Build( + ZoneScoped + + _downscaledVolumeProgram = ghoul::opengl::ProgramObject::Build( "Write Downscaled Volume Program", absPath("${SHADERS}/framebuffer/mergeDownscaledVolume.vert"), absPath("${SHADERS}/framebuffer/mergeDownscaledVolume.frag") @@ -1533,6 +1553,8 @@ void FramebufferRenderer::enableFXAA(bool enable) { } void FramebufferRenderer::updateRendererData() { + ZoneScoped + ghoul::Dictionary dict; dict.setValue("fragmentRendererPath", std::string(RenderFragmentShaderPath)); dict.setValue("hdrExposure", std::to_string(_hdrExposure)); diff --git a/src/rendering/luaconsole.cpp b/src/rendering/luaconsole.cpp index 20a302f976..97eee2f20e 100644 --- a/src/rendering/luaconsole.cpp +++ b/src/rendering/luaconsole.cpp @@ -687,7 +687,7 @@ void LuaConsole::render() { // Since the overflow is positive, at least one character needs to be removed. const size_t nCharsOverflow = static_cast(std::min( - std::max(1.f, overflow / _font->glyph('m')->width()), + std::max(1.f, overflow / _font->glyph('m')->width), static_cast(currentCommand.size()) )); diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index a83a69979c..803681a6e3 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -389,6 +389,8 @@ RenderEngine::RenderEngine() RenderEngine::~RenderEngine() {} // NOLINT void RenderEngine::setRendererFromString(const std::string& renderingMethod) { + ZoneScoped + _rendererImplementation = rendererFromString(renderingMethod); std::unique_ptr newRenderer = nullptr; @@ -486,10 +488,6 @@ void RenderEngine::initializeGL() { setRendererFromString(renderingMethod); - - // TODO: Fix the power scaled coordinates in such a way that these - // values can be set to more realistic values - // set the close clip plane and the far clip plane to extreme values while in // development global::windowDelegate.setNearFarClippingPlane(0.001f, 1000.f); @@ -498,19 +496,38 @@ void RenderEngine::initializeGL() { // initialized window _horizFieldOfView = static_cast(global::windowDelegate.getHorizFieldOfView()); - constexpr const float FontSizeFrameinfo = 32.f; - _fontFrameInfo = global::fontManager.font(KeyFontMono, FontSizeFrameinfo); - constexpr const float FontSizeTime = 15.f; - _fontDate = global::fontManager.font(KeyFontMono, FontSizeTime); - constexpr const float FontSizeMono = 10.f; - _fontInfo = global::fontManager.font(KeyFontMono, FontSizeMono); - constexpr const float FontSizeLight = 8.f; - _fontLog = global::fontManager.font(KeyFontLight, FontSizeLight); + { + ZoneScopedN("Font: Mono") + TracyGpuZone("Font: Mono") + constexpr const float FontSizeFrameinfo = 32.f; + _fontFrameInfo = global::fontManager.font(KeyFontMono, FontSizeFrameinfo); + } + { + ZoneScopedN("Font: Date") + TracyGpuZone("Font: Date") + constexpr const float FontSizeTime = 15.f; + _fontDate = global::fontManager.font(KeyFontMono, FontSizeTime); + } + { + ZoneScopedN("Font: Info") + TracyGpuZone("Font: Info") + constexpr const float FontSizeMono = 10.f; + _fontInfo = global::fontManager.font(KeyFontMono, FontSizeMono); + } + { + ZoneScopedN("Font: Log") + TracyGpuZone("Font: Log") + constexpr const float FontSizeLight = 8.f; + _fontLog = global::fontManager.font(KeyFontLight, FontSizeLight); + } - LINFO("Initializing Log"); - std::unique_ptr log = std::make_unique(ScreenLogTimeToLive); - _log = log.get(); - ghoul::logging::LogManager::ref().addLog(std::move(log)); + { + ZoneScopedN("Log") + LINFO("Initializing Log"); + std::unique_ptr log = std::make_unique(ScreenLogTimeToLive); + _log = log.get(); + ghoul::logging::LogManager::ref().addLog(std::move(log)); + } LINFO("Finished initializing GL"); LTRACE("RenderEngine::initializeGL(end)"); @@ -1101,6 +1118,8 @@ void RenderEngine::postRaycast(ghoul::opengl::ProgramObject& programObject) { * Set renderer */ void RenderEngine::setRenderer(std::unique_ptr renderer) { + ZoneScoped + if (_renderer) { _renderer->deinitialize(); } From 15e6b5519fcc11e1494f919a1c0e644a6866f71d Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 21 Aug 2020 14:10:33 +0200 Subject: [PATCH 35/59] Making the documentation generation a bit more performant Outsource the file writing to a second thread to start the rendering earlier --- include/openspace/engine/openspaceengine.h | 3 + include/openspace/properties/propertyowner.h | 2 +- src/documentation/documentationengine.cpp | 3 + src/engine/openspaceengine.cpp | 28 ++- src/interaction/keybindingmanager.cpp | 3 + src/properties/propertyowner.cpp | 171 ++++++++++++------- src/scene/scenelicensewriter.cpp | 4 +- 7 files changed, 151 insertions(+), 63 deletions(-) diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index 967629e94b..6ccae1f19a 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -127,6 +128,8 @@ private: //grabs json from each module to pass to the documentation engine. std::string _documentationJson; + std::future _writeDocumentationTask; + ShutdownInformation _shutdown; // The first frame might take some more time in the update loop, so we need to know to diff --git a/include/openspace/properties/propertyowner.h b/include/openspace/properties/propertyowner.h index 5b4b9bd038..48a26bb079 100644 --- a/include/openspace/properties/propertyowner.h +++ b/include/openspace/properties/propertyowner.h @@ -291,7 +291,7 @@ public: */ void removeTag(const std::string& tag); - //Generate JSON for documentation + // Generate JSON for documentation std::string generateJson() const override; diff --git a/src/documentation/documentationengine.cpp b/src/documentation/documentationengine.cpp index 06456dca21..174fa7f05a 100644 --- a/src/documentation/documentationengine.cpp +++ b/src/documentation/documentationengine.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -194,6 +195,8 @@ std::vector DocumentationEngine::documentations() const { void DocumentationEngine::writeDocumentationHtml(const std::string& path, std::string data) { + ZoneScoped + std::ifstream handlebarsInput; handlebarsInput.exceptions(~std::ofstream::goodbit); handlebarsInput.open(absPath(HandlebarsFilename)); diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 2ec63240ae..1d00963da3 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -83,6 +83,7 @@ #include #include #include +#include #include #include @@ -852,7 +853,7 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { runGlobalCustomizationScripts(); - writeSceneDocumentation(); + _writeDocumentationTask = std::async(&OpenSpaceEngine::writeSceneDocumentation, this); LTRACE("OpenSpaceEngine::loadSingleAsset(end)"); } @@ -1013,6 +1014,18 @@ void OpenSpaceEngine::writeSceneDocumentation() { std::string path = global::configuration.documentation.path; if (!path.empty()) { + std::future root = std::async( + &properties::PropertyOwner::generateJson, + &global::rootPropertyOwner + ); + + std::future scene = std::async( + &properties::PropertyOwner::generateJson, + _scene.get() + ); + + + path = absPath(path) + "/"; _documentationJson += "{\"name\":\"Keybindings\",\"identifier\":\""; _documentationJson += global::keybindingManager.jsonName() + "\","; @@ -1026,11 +1039,11 @@ void OpenSpaceEngine::writeSceneDocumentation() { _documentationJson += "},"; _documentationJson += "{\"name\":\"Scene Properties\","; _documentationJson += "\"identifier\":\"propertylist";// + _scene->jsonName(); - _documentationJson += "\",\"data\":" + global::rootPropertyOwner.generateJson(); + _documentationJson += "\",\"data\":" + root.get(); _documentationJson += "},"; _documentationJson += "{\"name\":\"Scene Graph Information\","; _documentationJson += "\"identifier\":\"propertylist"; - _documentationJson += "\",\"data\":" + _scene->generateJson(); + _documentationJson += "\",\"data\":" + scene.get(); _documentationJson += "}"; //add templates for the jsons we just registered @@ -1149,7 +1162,14 @@ void OpenSpaceEngine::postSynchronizationPreDraw() { const bool updated = _assetManager->update(); if (updated) { - writeSceneDocumentation(); + if (_writeDocumentationTask.valid()) { + // If there still is a documentation creation task the previous frame, we need + // to wait for it to finish first, or else we might write to the same file + _writeDocumentationTask.wait(); + } + _writeDocumentationTask = std::async( + &OpenSpaceEngine::writeSceneDocumentation, this + ); } if (!global::windowDelegate.isMaster()) { diff --git a/src/interaction/keybindingmanager.cpp b/src/interaction/keybindingmanager.cpp index e34aa0e6ed..aae26742b6 100644 --- a/src/interaction/keybindingmanager.cpp +++ b/src/interaction/keybindingmanager.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -170,6 +171,8 @@ KeybindingManager::keyBindings() const } std::string KeybindingManager::generateJson() const { + ZoneScoped + std::stringstream json; json << "["; bool first = true; diff --git a/src/properties/propertyowner.cpp b/src/properties/propertyowner.cpp index b1c00328c8..4fedbd95d2 100644 --- a/src/properties/propertyowner.cpp +++ b/src/properties/propertyowner.cpp @@ -35,6 +35,111 @@ namespace { constexpr const char* _loggerCat = "PropertyOwner"; + + std::string escapedJson(const std::string& text) { + std::string jsonString; + for (const char& c : text) { + switch (c) { + case '\t': + jsonString += "\\t"; // Replace tab with \t. + break; + case '"': + jsonString += "\\\""; // Replace " with \". + break; + case '\\': + jsonString += "\\\\"; // Replace \ with \\. + break; + case '\n': + jsonString += "\\\\n"; // Replace newline with \n. + break; + case '\r': + jsonString += "\\r"; // Replace carriage return with \r. + break; + default: + jsonString += c; + } + } + return jsonString; + } + + void createJson(openspace::properties::PropertyOwner* owner, std::vector& buf) { + ZoneScoped + + using namespace openspace; + + constexpr const char* replStr = R"("{}": "{}")"; + + //std::stringstream json; + //json << "{"; + buf.push_back('{'); + //json << fmt::format(replStr, "name", owner->identifier()) << ","; + fmt::format_to(std::back_inserter(buf), replStr, "name", owner->identifier()); + buf.push_back(','); + + constexpr const char propertiesText[] = "\"properties\": ["; + //constexpr const std::array propertiesText = { "\"properties\": [" }; + buf.insert(buf.end(), std::begin(propertiesText), std::end(propertiesText) - 1); + //json << "\"properties\": ["; + const std::vector& properties = owner->properties(); + for (properties::Property* p : properties) { + //json << "{"; + buf.push_back('{'); + //json << fmt::format(replStr, "id", p->identifier()) << ","; + fmt::format_to(std::back_inserter(buf), replStr, "id", p->identifier()); + buf.push_back(','); + //json << fmt::format(replStr, "type", p->className()) << ","; + fmt::format_to(std::back_inserter(buf), replStr, "type", p->className()); + buf.push_back(','); + + //json << fmt::format( + // replStr, "fullyQualifiedId", p->fullyQualifiedIdentifier() + //) << ","; + fmt::format_to( + std::back_inserter(buf), + replStr, "fullyQualifiedId", p->fullyQualifiedIdentifier() + ); + buf.push_back(','); + + //json << fmt::format(replStr, "guiName", p->guiName()) << ","; + fmt::format_to(std::back_inserter(buf), replStr, "guiName", p->guiName()); + buf.push_back(','); + + //json << fmt::format(replStr, "description", escapedJson(p->description())); + fmt::format_to( + std::back_inserter(buf), + replStr, "description", escapedJson(p->description()) + ); + //json << "}"; + buf.push_back('}'); + if (p != properties.back()) { + //json << ","; + buf.push_back(','); + } + } + //json << "],"; + buf.push_back(']'); + buf.push_back(','); + + constexpr const char propertyOwnersText[] = "\"propertyOwners\": ["; + //constexpr const std::array propertyOwnersText = { "\"propertyOwners\": [" }; + //json << "\"propertyOwners\": ["; + buf.insert(buf.end(), std::begin(propertyOwnersText), std::end(propertyOwnersText) - 1); + auto propertyOwners = owner->propertySubOwners(); + for (properties::PropertyOwner* o : propertyOwners) { + createJson(o, buf); + //json << createJson(o); + if (o != propertyOwners.back()) { + //json << ","; + buf.push_back(','); + } + } + //json << "]"; + buf.push_back(']'); + //json << "}"; + buf.push_back('}'); + + //return json.str(); + }; } // namespace namespace openspace::properties { @@ -356,67 +461,19 @@ void PropertyOwner::removeTag(const std::string& tag) { } std::string PropertyOwner::generateJson() const { - std::function createJson = - [&createJson](properties::PropertyOwner* owner) -> std::string - { - constexpr const char* replStr = R"("{}": "{}")"; + ZoneScoped - std::stringstream json; - json << "{"; - json << fmt::format(replStr, "name", owner->identifier()) << ","; - - json << "\"properties\": ["; - const std::vector& properties = owner->properties(); - for (properties::Property* p : properties) { - json << "{"; - json << fmt::format(replStr, "id", p->identifier()) << ","; - json << fmt::format(replStr, "type", p->className()) << ","; - json << fmt::format( - replStr, "fullyQualifiedId", p->fullyQualifiedIdentifier() - ) << ","; - json << fmt::format(replStr, "guiName", p->guiName()) << ","; - json << fmt::format(replStr, "description", escapedJson(p->description())); - json << "}"; - if (p != properties.back()) { - json << ","; - } - } - json << "],"; - - json << "\"propertyOwners\": ["; - auto propertyOwners = owner->propertySubOwners(); - for (properties::PropertyOwner* o : propertyOwners) { - json << createJson(o); - if (o != propertyOwners.back()) { - json << ","; - } - } - json << "]"; - json << "}"; - - return json.str(); - }; - - - std::stringstream json; - json << "["; + std::vector res; + res.reserve(5 * 51024 * 1024); // 5 MB + res.push_back('['); std::vector subOwners = propertySubOwners(); - if (!subOwners.empty()) { - json << std::accumulate( - std::next(subOwners.begin()), - subOwners.end(), - createJson(*subOwners.begin()), - [createJson](std::string a, PropertyOwner* n) { - //TODO figure out how to ignore scene when its not the root - //right now will be done on client side - return a + "," + createJson(n); - } - ); + for (PropertyOwner* owner : subOwners) { + createJson(owner, res); + res.push_back(','); } + res.back() = ']'; - json << "]"; - - return json.str(); + return std::string(res.begin(), res.end()); } } // namespace openspace::properties diff --git a/src/scene/scenelicensewriter.cpp b/src/scene/scenelicensewriter.cpp index bd2e2ff8ec..eb3065e9aa 100644 --- a/src/scene/scenelicensewriter.cpp +++ b/src/scene/scenelicensewriter.cpp @@ -28,8 +28,8 @@ #include #include #include - #include +#include #include namespace openspace { @@ -45,6 +45,8 @@ SceneLicenseWriter::SceneLicenseWriter() {} std::string SceneLicenseWriter::generateJson() const { + ZoneScoped + std::stringstream json; json << "["; From aa4d68aac9167ee9021c2a8b17a8568150b78c72 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 21 Aug 2020 14:39:54 +0200 Subject: [PATCH 36/59] Adding some zones to RenderableBillboardClouds --- .../rendering/renderablebillboardscloud.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index a25018ceef..74e7ad329f 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -1048,7 +1048,11 @@ void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) { } void RenderableBillboardsCloud::update(const UpdateData&) { + ZoneScoped + if (_dataIsDirty && _hasSpeckFile) { + ZoneScopedN("Data dirty") + TracyGpuZone("Data dirty") LDEBUG("Regenerating data"); createDataSlice(); @@ -1170,6 +1174,9 @@ void RenderableBillboardsCloud::update(const UpdateData&) { if (_hasSpriteTexture && _spriteTextureIsDirty && !_spriteTexturePath.value().empty()) { + ZoneScopedN("Sprite texture") + TracyGpuZone("Sprite texture") + ghoul::opengl::Texture* t = _spriteTexture; unsigned int hash = ghoul::hashCRC32File(_spriteTexturePath); @@ -1619,6 +1626,8 @@ bool RenderableBillboardsCloud::saveCachedFile(const std::string& file) const { } void RenderableBillboardsCloud::createDataSlice() { + ZoneScoped + _slicedData.clear(); if (_hasColorMapFile) { _slicedData.reserve(8 * (_fullData.size() / _nValuesPerAstronomicalObject)); From f1b05c23e7760b4d812531511b7451afdc4d25f2 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 21 Aug 2020 15:40:52 +0200 Subject: [PATCH 37/59] Prevent Stack corruption --- include/openspace/util/spicemanager.h | 2 +- modules/globebrowsing/src/timequantizer.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/openspace/util/spicemanager.h b/include/openspace/util/spicemanager.h index 0c6be16e2c..c264db3a7c 100644 --- a/include/openspace/util/spicemanager.h +++ b/include/openspace/util/spicemanager.h @@ -499,7 +499,7 @@ public: const char (&format)[N] = "YYYY MON DDTHR:MN:SC.### ::RND") const { static_assert(N != 0, "Format must not be empty"); - ghoul_assert(N > bufferSize - 1, "Buffer size too small"); + ghoul_assert(N >= bufferSize - 1, "Buffer size too small"); timout_c(ephemerisTime, format, bufferSize, outBuf); if (failed_c()) { diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index 78e58e1f25..e891cd2f74 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -577,9 +577,9 @@ void TimeQuantizer::doFirstApproximation(DateTime& quantized, DateTime& unQ, dou const double addToTime = std::round(error) * 86400; Time testDay(quantized.J2000() + addToTime); - char Buffer[24]; + char Buffer[25]; testDay.ISO8601(Buffer); - quantized.setTime(std::string_view(Buffer, 24)); + quantized.setTime(std::string_view(Buffer, 25)); quantized.setHour(originalHour); quantized.setMinute(originalMinute); quantized.setSecond(originalSecond); From c1fef73faf0f8fbd069ef71f3d0a6626a0d780b1 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 21 Aug 2020 17:08:52 +0200 Subject: [PATCH 38/59] Fix for crash when changing number of layers in GlobeBrowsing --- modules/globebrowsing/src/renderableglobe.cpp | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 4cf67df702..86ef86bd2e 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -923,21 +923,6 @@ void RenderableGlobe::update(const UpdateData& data) { _shadowComponent.update(data); } - _layerManager.update(); - - if (_nLayersIsDirty) { - std::array lgs = - _layerManager.layerGroups(); - _generalProperties.nActiveLayers = std::accumulate( - lgs.begin(), - lgs.end(), - 0, - [](int lhs, LayerGroup* lg) { - return lhs + static_cast(lg->activeLayers().size()); - } - ); - _nLayersIsDirty = false; - } } bool RenderableGlobe::renderedWithDesiredData() const { @@ -970,6 +955,22 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, { ZoneScoped + _layerManager.update(); + + if (_nLayersIsDirty) { + std::array lgs = + _layerManager.layerGroups(); + _generalProperties.nActiveLayers = std::accumulate( + lgs.begin(), + lgs.end(), + 0, + [](int lhs, LayerGroup* lg) { + return lhs + static_cast(lg->activeLayers().size()); + } + ); + _nLayersIsDirty = false; + } + if (_shadersNeedRecompilation) { recompileShaders(); } From 7ddb5e8d3618048abe2d4e84ca8aee8505967ac7 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 21 Aug 2020 17:17:19 +0200 Subject: [PATCH 39/59] Add a dirty flag to only update the layermanager once per frame --- modules/globebrowsing/src/renderableglobe.cpp | 20 ++++++++++++++++++- modules/globebrowsing/src/renderableglobe.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 86ef86bd2e..f8455e5ca8 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -923,6 +923,20 @@ void RenderableGlobe::update(const UpdateData& data) { _shadowComponent.update(data); } + // abock (2020-08-21) + // This is a bit nasty every since we removed the second update call from the render + // loop. The problem is when we enable a new layer, the dirty flags above will be set + // to true, but the update method hasn't run yet. So we need to move the layerManager + // update method to the render function call, but we don't want to *actually* update + // the layers once per render call; hence this nasty dirty flag + // + // How it is without in the frame when we enable a layer: + // + // RenderableGlobe::update() // updated with the old number of layers + // // Lua script to enable layer is executed and sets the dirty flags + // RenderableGlobe::render() // rendering with the new number of layers but the + // // LayerManager hasn't updated yet :o + _layerManagerDirty = true; } bool RenderableGlobe::renderedWithDesiredData() const { @@ -955,7 +969,11 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, { ZoneScoped - _layerManager.update(); + + if (_layerManagerDirty) { + _layerManager.update(); + _layerManagerDirty = false; + } if (_nLayersIsDirty) { std::array lgs = diff --git a/modules/globebrowsing/src/renderableglobe.h b/modules/globebrowsing/src/renderableglobe.h index 6e7386cd84..4304bc7c60 100644 --- a/modules/globebrowsing/src/renderableglobe.h +++ b/modules/globebrowsing/src/renderableglobe.h @@ -289,6 +289,7 @@ private: bool _chunkCornersDirty = true; bool _nLayersIsDirty = true; bool _allChunksAvailable = true; + bool _layerManagerDirty = true; size_t _iterationsOfAvailableData = 0; size_t _iterationsOfUnavailableData = 0; Layer* _lastChangedLayer = nullptr; From 406690d37c721c57885064d8d25f0525e8a9f46c Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 23 Aug 2020 17:54:58 +0200 Subject: [PATCH 40/59] Remove some recurring calculations from frustum culling code --- modules/globebrowsing/src/renderableglobe.cpp | 48 ++++++++++--------- modules/globebrowsing/src/renderableglobe.h | 8 ++-- modules/globebrowsing/src/tileprovider.cpp | 9 +++- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index f8455e5ca8..a623939cc4 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -1076,20 +1076,22 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, _localRenderer.updatedSinceLastCall = false; } + // Calculate the MVP matrix + const glm::dmat4& viewTransform = data.camera.combinedViewMatrix(); + const glm::dmat4 vp = glm::dmat4(data.camera.sgctInternal.projectionMatrix()) * + viewTransform; + const glm::dmat4 mvp = vp * _cachedModelTransform; + _allChunksAvailable = true; - updateChunkTree(_leftRoot, data); - updateChunkTree(_rightRoot, data); + updateChunkTree(_leftRoot, data, mvp); + updateChunkTree(_rightRoot, data, mvp); _chunkCornersDirty = false; _iterationsOfAvailableData = (_allChunksAvailable ? _iterationsOfAvailableData + 1 : 0); _iterationsOfUnavailableData = (_allChunksAvailable ? 0 : _iterationsOfUnavailableData + 1); - // Calculate the MVP matrix - const glm::dmat4& viewTransform = data.camera.combinedViewMatrix(); - const glm::dmat4 vp = glm::dmat4(data.camera.sgctInternal.projectionMatrix()) * - viewTransform; - const glm::dmat4 mvp = vp * _cachedModelTransform; + // // Setting uniforms that don't change between chunks but are view dependent @@ -1885,12 +1887,13 @@ SurfacePositionHandle RenderableGlobe::calculateSurfacePositionHandle( bool RenderableGlobe::testIfCullable(const Chunk& chunk, const RenderData& renderData, - const BoundingHeights& heights) const + const BoundingHeights& heights, + const glm::dmat4& mvp) const { ZoneScoped return (PreformHorizonCulling && isCullableByHorizon(chunk, renderData, heights)) || - (PerformFrustumCulling && isCullableByFrustum(chunk, renderData)); + (PerformFrustumCulling && isCullableByFrustum(chunk, renderData, mvp)); } int RenderableGlobe::desiredLevel(const Chunk& chunk, const RenderData& renderData, @@ -2370,22 +2373,17 @@ int RenderableGlobe::desiredLevelByAvailableTileData(const Chunk& chunk) const { ////////////////////////////////////////////////////////////////////////////////////////// bool RenderableGlobe::isCullableByFrustum(const Chunk& chunk, - const RenderData& renderData) const + const RenderData& renderData, + const glm::dmat4& mvp) const { ZoneScoped - // Calculate the MVP matrix - const glm::dmat4 viewTransform = glm::dmat4(renderData.camera.combinedViewMatrix()); - const glm::dmat4 modelViewProjectionTransform = glm::dmat4( - renderData.camera.sgctInternal.projectionMatrix() - ) * viewTransform * _cachedModelTransform; - const std::array& corners = chunk.corners; // Create a bounding box that fits the patch corners AABB3 bounds; // in screen space for (size_t i = 0; i < 8; ++i) { - const glm::dvec4 cornerClippingSpace = modelViewProjectionTransform * corners[i]; + const glm::dvec4 cornerClippingSpace = mvp * corners[i]; const glm::dvec3 ndc = glm::dvec3( (1.f / glm::abs(cornerClippingSpace.w)) * cornerClippingSpace ); @@ -2523,7 +2521,9 @@ void RenderableGlobe::mergeChunkNode(Chunk& cn) { cn.children.fill(nullptr); } -bool RenderableGlobe::updateChunkTree(Chunk& cn, const RenderData& data) { +bool RenderableGlobe::updateChunkTree(Chunk& cn, const RenderData& data, + const glm::dmat4& mvp) +{ ZoneScoped // abock: I tried turning this into a queue and use iteration, rather than recursion @@ -2533,7 +2533,7 @@ bool RenderableGlobe::updateChunkTree(Chunk& cn, const RenderData& data) { // In addition, this didn't even improve performance --- 2018-10-04 if (isLeaf(cn)) { ZoneScopedN("leaf") - updateChunk(cn, data); + updateChunk(cn, data, mvp); if (cn.status == Chunk::Status::WantSplit) { splitChunkNode(cn, 1); @@ -2549,13 +2549,13 @@ bool RenderableGlobe::updateChunkTree(Chunk& cn, const RenderData& data) { ZoneScopedN("!leaf") char requestedMergeMask = 0; for (int i = 0; i < 4; ++i) { - if (updateChunkTree(*cn.children[i], data)) { + if (updateChunkTree(*cn.children[i], data, mvp)) { requestedMergeMask |= (1 << i); } } const bool allChildrenWantsMerge = requestedMergeMask == 0xf; - updateChunk(cn, data); + updateChunk(cn, data, mvp); if (allChildrenWantsMerge && (cn.status != Chunk::Status::WantSplit)) { mergeChunkNode(cn); @@ -2571,7 +2571,9 @@ bool RenderableGlobe::updateChunkTree(Chunk& cn, const RenderData& data) { } } -void RenderableGlobe::updateChunk(Chunk& chunk, const RenderData& data) const { +void RenderableGlobe::updateChunk(Chunk& chunk, const RenderData& data, + const glm::dmat4& mvp) const +{ ZoneScoped const BoundingHeights& heights = boundingHeightsForChunk(chunk, _layerManager); @@ -2584,7 +2586,7 @@ void RenderableGlobe::updateChunk(Chunk& chunk, const RenderData& data) const { // The flag gets set to false globally after the updateChunkTree calls } - if (testIfCullable(chunk, data, heights)) { + if (testIfCullable(chunk, data, heights, mvp)) { chunk.isVisible = false; chunk.status = Chunk::Status::WantMerge; } diff --git a/modules/globebrowsing/src/renderableglobe.h b/modules/globebrowsing/src/renderableglobe.h index 4304bc7c60..f632d38e59 100644 --- a/modules/globebrowsing/src/renderableglobe.h +++ b/modules/globebrowsing/src/renderableglobe.h @@ -160,7 +160,7 @@ private: * allows culling of the Chunks in question. */ bool testIfCullable(const Chunk& chunk, const RenderData& renderData, - const BoundingHeights& heights) const; + const BoundingHeights& heights, const glm::dmat4& mvp) const; /** * Gets the desired level which can be used to determine if a chunk should split @@ -222,7 +222,7 @@ private: void debugRenderChunk(const Chunk& chunk, const glm::dmat4& mvp, bool renderBounds, bool renderAABB) const; - bool isCullableByFrustum(const Chunk& chunk, const RenderData& renderData) const; + bool isCullableByFrustum(const Chunk& chunk, const RenderData& renderData, const glm::dmat4& mvp) const; bool isCullableByHorizon(const Chunk& chunk, const RenderData& renderData, const BoundingHeights& heights) const; @@ -245,8 +245,8 @@ private: void splitChunkNode(Chunk& cn, int depth); void mergeChunkNode(Chunk& cn); - bool updateChunkTree(Chunk& cn, const RenderData& data); - void updateChunk(Chunk& chunk, const RenderData& data) const; + bool updateChunkTree(Chunk& cn, const RenderData& data, const glm::dmat4& mvp); + void updateChunk(Chunk& chunk, const RenderData& data, const glm::dmat4& mvp) const; void freeChunkNode(Chunk* n); Ellipsoid _ellipsoid; diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index 39cb0e2381..f639424ab6 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -939,10 +939,11 @@ Tile tile(TileProvider& tp, const TileIndex& tileIndex) { switch (tp.type) { case Type::DefaultTileProvider: { + ZoneScopedN("Type::DefaultTileProvider") DefaultTileProvider& t = static_cast(tp); if (t.asyncTextureDataProvider) { if (tileIndex.level > maxLevel(t)) { - return Tile{ nullptr, std::nullopt, Tile::Status::OutOfRange }; + return Tile { nullptr, std::nullopt, Tile::Status::OutOfRange }; } const cache::ProviderTileKey key = { tileIndex, t.uniqueIdentifier }; Tile tile = t.tileCache->get(key); @@ -958,10 +959,12 @@ Tile tile(TileProvider& tp, const TileIndex& tileIndex) { } } case Type::SingleImageTileProvider: { + ZoneScopedN("Type::SingleImageTileProvider") SingleImageProvider& t = static_cast(tp); return t.tile; } case Type::SizeReferenceTileProvider: { + ZoneScopedN("Type::SizeReferenceTileProvider") SizeReferenceTileProvider& t = static_cast(tp); const GeodeticPatch patch(tileIndex); @@ -1002,6 +1005,7 @@ Tile tile(TileProvider& tp, const TileIndex& tileIndex) { return tile(t, tileIndex); } case Type::TileIndexTileProvider: { + ZoneScopedN("Type::TileIndexTileProvider") TileIndexTileProvider& t = static_cast(tp); t.text = fmt::format( "level: {}\nx: {}\ny: {}", tileIndex.level, tileIndex.x, tileIndex.y @@ -1016,12 +1020,14 @@ Tile tile(TileProvider& tp, const TileIndex& tileIndex) { return tile(t, tileIndex); } case Type::ByIndexTileProvider: { + ZoneScopedN("Type::ByIndexTileProvider") TileProviderByIndex& t = static_cast(tp); const auto it = t.tileProviderMap.find(tileIndex.hashKey()); const bool hasProvider = it != t.tileProviderMap.end(); return hasProvider ? tile(*it->second, tileIndex) : Tile(); } case Type::ByLevelTileProvider: { + ZoneScopedN("Type::ByLevelTileProvider") TileProviderByLevel& t = static_cast(tp); TileProvider* provider = levelProvider(t, tileIndex.level); if (provider) { @@ -1032,6 +1038,7 @@ Tile tile(TileProvider& tp, const TileIndex& tileIndex) { } } case Type::TemporalTileProvider: { + ZoneScopedN("Type::TemporalTileProvider") TemporalTileProvider& t = static_cast(tp); if (t.successfulInitialization) { ensureUpdated(t); From 84706aa120371c2836e6d843ffd90f2e05253546 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 23 Aug 2020 17:57:43 +0200 Subject: [PATCH 41/59] Add missing zone --- modules/globebrowsing/src/asynctiledataprovider.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/globebrowsing/src/asynctiledataprovider.cpp b/modules/globebrowsing/src/asynctiledataprovider.cpp index e6795dc4df..0f1a949ee8 100644 --- a/modules/globebrowsing/src/asynctiledataprovider.cpp +++ b/modules/globebrowsing/src/asynctiledataprovider.cpp @@ -59,6 +59,8 @@ const RawTileDataReader& AsyncTileDataProvider::rawTileDataReader() const { } bool AsyncTileDataProvider::enqueueTileIO(const TileIndex& tileIndex) { + ZoneScoped + if (_resetMode == ResetMode::ShouldNotReset && satisfiesEnqueueCriteria(tileIndex)) { auto job = std::make_unique(*_rawTileDataReader, tileIndex); _concurrentJobManager.enqueueJob(std::move(job), tileIndex.hashKey()); @@ -97,6 +99,8 @@ std::optional AsyncTileDataProvider::popFinishedRawTile() { } bool AsyncTileDataProvider::satisfiesEnqueueCriteria(const TileIndex& tileIndex) { + ZoneScoped + // Only satisfies if it is not already enqueued. Also bumps the request to the top. const bool alreadyEnqueued = _concurrentJobManager.touch(tileIndex.hashKey()); // Early out so we don't need to check the already enqueued requests From 457dabe9b7497dcf306442bfd6d14df57ab78a1a Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Thu, 6 Aug 2020 11:23:31 +0200 Subject: [PATCH 42/59] Add list of delta time steps, stepping functions and keybindings --- data/assets/util/default_keybindings.asset | 16 +++ include/openspace/scene/profile.h | 1 + include/openspace/util/timemanager.h | 10 ++ src/scene/profile.cpp | 31 ++++++ src/util/time.cpp | 27 ++++++ src/util/time_lua.inl | 107 +++++++++++++++++++++ src/util/timemanager.cpp | 36 +++++++ 7 files changed, 228 insertions(+) diff --git a/data/assets/util/default_keybindings.asset b/data/assets/util/default_keybindings.asset index cd8559d306..b10c1d703b 100644 --- a/data/assets/util/default_keybindings.asset +++ b/data/assets/util/default_keybindings.asset @@ -109,6 +109,22 @@ openspace.setPropertyValueSingle("RenderEngine.ShowCamera", not isEnabled)]], Documentation = "Toggles the rendering on master", GuiPath = "/Rendering", Local = true + }, + { + Key = "Right", + Name = "Next Delta Time Step (Interpolate)", + Command = "openspace.time.interpolateNextDeltaTimeStep()", + Documentation = "Smoothly interpolates the simulation speed to the next value in the list of delta time steps, if one exists.", + GuiPath = "/Simulation Speed", + Local = true + }, + { + Key = "Left", + Name = "Previous Delta Time Step (Interpolate)", + Command = "openspace.time.interpolatePreviousDeltaTimeStep()", + Documentation = "Smoothly interpolates the simulation speed to the previous value in the list of delta time steps, if one exists.", + GuiPath = "/Simulation Speed", + Local = true } } diff --git a/include/openspace/scene/profile.h b/include/openspace/scene/profile.h index 71473693ee..2e8382f709 100644 --- a/include/openspace/scene/profile.h +++ b/include/openspace/scene/profile.h @@ -151,6 +151,7 @@ private: std::vector properties; std::vector keybindings; std::optional