Deal with LinearAnimationInstance with no backing Animation. #270
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At design time, a designer can create a Blend state which references multiple animations. If those animations values are not set (via a dropdown in the Blend State inspector) they will be exported with a "default/missing id".
I provide a fix here, but I strongly suspect this is the wrong approach as it bloats the code and makes it have to deal with these ugly conditions.
When the blend animation currently imports, we don't check if its id is equal to the "missing id":
https://github.com/rive-app/rive-cpp/blob/a3f7e84568498ad99a24239987447b69e743becb/src/animation/blend_animation.cpp#L24-L26
What could do here is check if
animationId() == -1
(or a helper isMissingId()) we could return an invalid status code likeStatusCode::InvalidObject
and fail the import. Something like:Currently, this results in a nullptr m_Animation. So when the BlendState becomes active, it attempts to make an instance of the null animation. Our AnimationInstance class does not deal currently deal with a null backing animation. This PR adds that messy logic and fixes the issue by attempting to let the file limp along and play without applying the missing animation.
I think the right thing to do is (pinging @neurowave and @alxgibsn for these considerations):