Don't collapse child constraints of Solos

Fixes the problem where FollowPathConstraints were not working with Solos in CPP runtime (works only in editor). The proposed solution is to not collapse constraints of the Solo because in the case of FollowPathConstraint, a call to it's update() is required in order to get the path info.

Before the fix:

https://github.com/rive-app/rive/assets/186340/48df0eb5-a422-464c-84c0-4c49412fa90e

After the fix:

https://github.com/rive-app/rive/assets/186340/dbfc8172-217d-4685-92c8-c34c551235ca

Diffs=
a91b1b764 Don't collapse child constraints of Solos - fixes Follow Paths on Solos (#5866)
033489f8b Fix follow path contention with MetricsPath (#5868)

Co-authored-by: Philip Chung <philterdesign@gmail.com>
This commit is contained in:
philter
2023-08-24 05:31:50 +00:00
parent 278695858d
commit 174048e3ee
9 changed files with 64 additions and 1 deletions

View File

@ -1 +1 @@
ad4236501bdf0218046a93c54f2ee4a379747890
a91b1b7647965149bd1b7894fa428f189e57f653

View File

@ -1,5 +1,6 @@
import 'package:rive/src/generated/solo_base.dart';
import 'package:rive/src/rive_core/component.dart';
import 'package:rive/src/rive_core/constraints/constraint.dart';
import 'package:rive/src/rive_core/container_component.dart';
export 'package:rive/src/generated/solo_base.dart';
@ -24,6 +25,9 @@ class Solo extends SoloBase {
@override
void propagateCollapseToChildren(bool collapse) {
for (final child in children) {
if (child is Constraint) {
continue;
}
child.propagateCollapse(collapse || child != _activeComponent);
}
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,59 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:rive/rive.dart';
import '../../src/utils.dart';
import '../golden_comparator.dart';
void main() {
group('Golden - follow path solo tests', () {
testWidgets('Follow path over time', (WidgetTester tester) async {
final riveBytes = loadFile('assets/follow_path_solos.riv');
final file = RiveFile.import(riveBytes);
late Artboard artboard;
final widget = RiveAnimation.direct(
file,
stateMachines: const ['State Machine 1'],
onInit: (a) {
artboard = a;
},
);
await tester.pumpWidget(widget);
await tester.pump();
await expectGoldenMatches(
find.byType(RiveAnimation),
'follow_path_solos_01.png',
reason: 'Follow path should work as animation advances',
);
artboard.advance(1.0, nested: true);
await tester.pump();
await expectGoldenMatches(
find.byType(RiveAnimation),
'follow_path_solos_02.png',
reason: 'Follow path should work as animation advances',
);
artboard.advance(1.5, nested: true);
await tester.pump();
await expectGoldenMatches(
find.byType(RiveAnimation),
'follow_path_solos_03.png',
reason: 'Follow path should work as animation advances',
);
artboard.advance(1.0, nested: true);
await tester.pump();
await expectGoldenMatches(
find.byType(RiveAnimation),
'follow_path_solos_04.png',
reason: 'Follow path should work as animation advances',
);
});
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB