Commit d3f9e17
susan101566
libraries: serialize library artboards as local artboards
Fixes https://github.com/orgs/rive-app/projects/15/views/1?pane=issue&itemId=104718681&issue=rive-app%7Crive%7C9356
Fixes https://github.com/rive-app/rive/issues/9324#issue-2966381868
### Overview
Currently we do not export LibraryArtboards to runtime, as C++ won't understand them. As such, currently, if you have ArtboardX that contains NestedArtboard_ofALibraryArtboard, a NestedArtboard that points to ArtboardX won't work.
This PR makes it such that a NestedArtboard to ArtboardX would show. Moreover, its statemachine will play too.
### There are a few main changes
1. LibraryAsset: cached library artboards in LibraryAsset are referenced by ID instead of by name. This ID is the original artboard's ID in the library asset file, and is persisted in our schema as LibraryArtboard.artboardId. Same same with caching statemachines and linear animations. I've added LibraryStateMachine.animationId and LibraryLinearAnimation.animationId.
2. NestedArtboard: before this PR, there was logic that checks whether the source artboard was a LibraryArtboard or just an Artboard. Now, it's just Artboard, because the runtime exporter only exports Artboards.
3. Runtime exporter: I've created the idea of MappedContext, which maps a library identifier to its various remaps, like globalIndexMapper, nestedIds, eventIds, etc.
### The mapping
NestedArtboard.artboardId -> LibraryArtboard.id
LibraryArtboard.artboardId -> LibraryAsset's rev file's Artboard.id
NestedStateMachine.animationId -> LibraryStateMachine.id
LibraryStateMachine.animationId -> LibraryAsset's rev file's State Machine.id
### Order of export
Currently, when we export we only go over the host file, and the order looks like
Backboard_ofHost
FileAssets_ofHost
DataModels_ofHost
Artboard1_ofHost
Artboard1_components_ofHost (e.g. paints, nested artboards, state machines, etc.)
Now, I'm recursively also exporting the library files. So the order looks like
Backboard_ofHost
[XXX]
**--FileAssets_ofLibrary
--DataModels_ofLibrary
--Artboard1_ofLibrary
--Artboard1_components_ofLibrary**
FileAssets_ofHost
DataModels_ofHost
Artboard1_ofHost
Artboard1_components_ofHost
Basically, we insert the indented section, which represents the library file. And if Library uses other library assets, it should go into the [XXX] section. Tho we currently don't support this, as we don't decode library assets used from a library asset.
If we aggregate all the artboards, [0, total count) is the range of valid artboard indices in C++.
### Tests
I'll fix the TODO's in the tests
Diffs=
e75974b896 libraries: serialize library artboards as local artboards (#9419)1 parent 27b2c27 commit d3f9e17
2 files changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
Submodule rive-runtime updated 10 files
- .rive_head+1-1
- include/rive/nested_artboard.hpp+2-1
- renderer/path_fiddle/path_fiddle.cpp+2
- src/nested_artboard.cpp+2-1
- tests/unit_tests/assets/double_library_with_image.riv
- tests/unit_tests/assets/library_export_animation_test.riv
- tests/unit_tests/assets/library_export_state_machine_test.riv
- tests/unit_tests/assets/library_export_test.riv
- tests/unit_tests/assets/library_with_image.riv
- tests/unit_tests/runtime/library_asset_test.cpp+78-37
0 commit comments