From 99c995565b13078e6727b092900a516179eec647 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Fri, 13 Dec 2019 07:47:05 -0700 Subject: [PATCH] Fix for issue 1023: prevents crash when using satellites and changing segments property, and fixes rendering errors. (#1028) --- .../earth/satellites/satellites_shared.asset | 2 +- .../space/rendering/renderablesatellites.cpp | 25 ++++++------------- .../space/rendering/renderablesatellites.h | 2 -- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_shared.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_shared.asset index 58b3e35ec4..e5fde6d30c 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_shared.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_shared.asset @@ -56,7 +56,7 @@ local registerSatelliteGroupObjects = function(containingAsset, group, tleFolder Renderable = { Type = "RenderableSatellites", Path = file, - Segments = 160, + Segments = 120, Color = color, Fade = 0.5 }, diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index 7453ff44f5..5476bf828f 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -66,13 +66,6 @@ namespace { "method includes lines. If the rendering mode is set to Points, this value is " "ignored." }; - constexpr openspace::properties::Property::PropertyInfo FadeInfo = { - "Fade", - "Line fade", - "The fading factor that is applied to the trail if the 'EnableFade' value is " - "'true'. If it is 'false', this setting has no effect. The higher the number, " - "the less fading is applied." - }; constexpr openspace::properties::Property::PropertyInfo LineColorInfo = { "Color", "Color", @@ -301,12 +294,6 @@ documentation::Documentation RenderableSatellites::Documentation() { Optional::Yes, LineWidthInfo.description }, - { - FadeInfo.identifier, - new DoubleVerifier, - Optional::Yes, - FadeInfo.description - }, { LineColorInfo.identifier, new DoubleVector3Verifier, @@ -320,8 +307,7 @@ documentation::Documentation RenderableSatellites::Documentation() { RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _path(PathInfo) - , _nSegments(SegmentsInfo) - , _lineFade(FadeInfo) + , _nSegments(SegmentsInfo, 120, 4, 1024) { documentation::testSpecificationAndThrow( @@ -332,16 +318,21 @@ RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary) _path = dictionary.value(PathInfo.identifier); _nSegments = static_cast(dictionary.value(SegmentsInfo.identifier)); - _lineFade = static_cast(dictionary.value(FadeInfo.identifier)); if (dictionary.hasKeyAndValue(LineColorInfo.identifier)) { _appearance.lineColor = dictionary.value(LineColorInfo.identifier); } + auto reinitializeTrailBuffers = [this]() { + initializeGL(); + }; + + _path.onChange(reinitializeTrailBuffers); + _nSegments.onChange(reinitializeTrailBuffers); + addPropertySubOwner(_appearance); addProperty(_path); addProperty(_nSegments); - addProperty(_lineFade); } diff --git a/modules/space/rendering/renderablesatellites.h b/modules/space/rendering/renderablesatellites.h index e052683cfc..b2bf0864a0 100644 --- a/modules/space/rendering/renderablesatellites.h +++ b/modules/space/rendering/renderablesatellites.h @@ -113,8 +113,6 @@ private: properties::StringProperty _path; properties::UIntProperty _nSegments; - properties::DoubleProperty _lineFade; - RenderableTrail::Appearance _appearance; glm::vec3 _position;