diff --git a/ext/ghoul b/ext/ghoul index 3bd220b9fc..d7db2ad6be 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 3bd220b9fc3d8f05af79c1c5c7594755499b77be +Subproject commit d7db2ad6be22de836b6d7a14b756577dd91d983d diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 1c3033ced4..b2fa4390be 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -60,6 +60,12 @@ namespace { { "Color Adding", ColorAddingBlending } }; + constexpr openspace::properties::Property::PropertyInfo enableAnimationInfo = { + "EnableAnimation", + "Enable Animation", + "Enable Animation" + }; + constexpr const std::array UniformNames = { "opacity", "nLightSources", "lightDirectionsViewSpace", "lightIntensities", "modelViewTransform", "normalTransform", "projectionTransform", @@ -146,6 +152,9 @@ namespace { // should be forced to render or not. std::optional forceRenderInvisible; + // [[codegen::verbatim(enableAnimationInfo.description)]] + std::optional enableAnimation; + // The date and time that the model animation should start. // In format 'YYYY MM DD hh:mm:ss'. std::optional animationStartTime [[codegen::dateTime()]]; @@ -217,6 +226,7 @@ documentation::Documentation RenderableModel::Documentation() { RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) : Renderable(dictionary) + , _enableAnimation(enableAnimationInfo, false) , _ambientIntensity(AmbientIntensityInfo, 0.2f, 0.f, 1.f) , _diffuseIntensity(DiffuseIntensityInfo, 1.f, 0.f, 1.f) , _specularIntensity(SpecularIntensityInfo, 1.f, 0.f, 1.f) @@ -313,6 +323,11 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) }*/ } + if (p.enableAnimation.has_value()) { + _enableAnimation = *p.enableAnimation; + _geometry->enableAnimation(_enableAnimation.value()); + } + if (p.animationTimeScale.has_value()) { if (std::holds_alternative(*p.animationTimeScale)) { _geometry->setTimeScale(std::get(*p.animationTimeScale)); @@ -387,6 +402,10 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) } } + if (_geometry->hasAnimation()) { + addProperty(_enableAnimation); + } + addPropertySubOwner(_lightSourcePropertyOwner); addProperty(_ambientIntensity); addProperty(_diffuseIntensity); @@ -401,6 +420,15 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) _modelTransform = glm::mat4_cast(glm::quat(glm::radians(_rotationVec.value()))); }); + _enableAnimation.onChange([this]() { + if (_enableAnimation.value() && !_geometry->hasAnimation()) { + LWARNING("Attempting to enable animation for a model that does not have any"); + _enableAnimation = false; + } + + _geometry->enableAnimation(_enableAnimation.value()); + }); + if (p.rotationVector.has_value()) { _rotationVec = *p.rotationVector; diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index a8d8ea49f9..225285f58c 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -82,6 +82,7 @@ private: bool _notifyInvisibleDropped = true; std::string _animationStart; AnimationMode _animationMode; + properties::BoolProperty _enableAnimation; properties::FloatProperty _ambientIntensity;