From 38cb01d19288164498f10f2956aa99a489f2fd09 Mon Sep 17 00:00:00 2001 From: Luigi Rosso Date: Tue, 23 Mar 2021 15:34:51 -0700 Subject: [PATCH] Getting state machine and bones working with nnbd. --- lib/src/core/importers/state_machine_layer_importer.dart | 3 +-- lib/src/rive_core/animation/animation_state.dart | 8 -------- lib/src/rive_core/bones/skin.dart | 6 ++++++ lib/src/rive_core/bones/tendon.dart | 8 +++++++- lib/src/rive_core/shapes/points_path.dart | 2 -- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/src/core/importers/state_machine_layer_importer.dart b/lib/src/core/importers/state_machine_layer_importer.dart index 2c0db20..ff358db 100644 --- a/lib/src/core/importers/state_machine_layer_importer.dart +++ b/lib/src/core/importers/state_machine_layer_importer.dart @@ -27,8 +27,7 @@ class StateMachineLayerImporter extends ImportStackObject { int artboardAnimationIndex = state.animationId; assert(artboardAnimationIndex >= 0 && artboardAnimationIndex < artboardImporter.animations.length); - state.animationId = - artboardImporter.animations[artboardAnimationIndex].id; + state.animation = artboardImporter.animations[artboardAnimationIndex]; } for (final transition in state.transitions) { // At import time the stateToId is an index relative to the entire layer diff --git a/lib/src/rive_core/animation/animation_state.dart b/lib/src/rive_core/animation/animation_state.dart index e5e66fe..5cb2c3f 100644 --- a/lib/src/rive_core/animation/animation_state.dart +++ b/lib/src/rive_core/animation/animation_state.dart @@ -23,12 +23,4 @@ class AnimationState extends AnimationStateBase { void animationIdChanged(int from, int to) { animation = id == Core.missingId ? null : context.resolve(to); } - - @override - void onAddedDirty() { - super.onAddedDirty(); - if (animationId != Core.missingId) { - animation = context.resolve(animationId); - } - } } diff --git a/lib/src/rive_core/bones/skin.dart b/lib/src/rive_core/bones/skin.dart index ee2cec9..a16bab5 100644 --- a/lib/src/rive_core/bones/skin.dart +++ b/lib/src/rive_core/bones/skin.dart @@ -56,6 +56,12 @@ class Skin extends SkinBase { (parent as Skinnable).addSkin(this); parent!.markRebuildDependencies(); } + _worldTransform[0] = xx; + _worldTransform[1] = xy; + _worldTransform[2] = yx; + _worldTransform[3] = yy; + _worldTransform[4] = tx; + _worldTransform[5] = ty; } @override diff --git a/lib/src/rive_core/bones/tendon.dart b/lib/src/rive_core/bones/tendon.dart index 69409df..b332714 100644 --- a/lib/src/rive_core/bones/tendon.dart +++ b/lib/src/rive_core/bones/tendon.dart @@ -5,7 +5,7 @@ export 'package:rive/src/generated/bones/tendon_base.dart'; class Tendon extends TendonBase { final Mat2D _bind = Mat2D(); - Mat2D? _inverseBind = Mat2D(); + Mat2D? _inverseBind; SkeletalComponent _bone = SkeletalComponent.unknown; SkeletalComponent get bone => _bone; Mat2D get inverseBind { @@ -22,6 +22,12 @@ class Tendon extends TendonBase { void onAddedDirty() { super.onAddedDirty(); _bone = context.resolveWithDefault(boneId, SkeletalComponent.unknown); + _bind[0] = xx; + _bind[1] = xy; + _bind[2] = yx; + _bind[3] = yy; + _bind[4] = tx; + _bind[5] = ty; } @override diff --git a/lib/src/rive_core/shapes/points_path.dart b/lib/src/rive_core/shapes/points_path.dart index d04f3c0..81b4468 100644 --- a/lib/src/rive_core/shapes/points_path.dart +++ b/lib/src/rive_core/shapes/points_path.dart @@ -6,8 +6,6 @@ import 'package:rive/src/rive_core/shapes/path_vertex.dart'; import 'package:rive/src/generated/shapes/points_path_base.dart'; export 'package:rive/src/generated/shapes/points_path_base.dart'; -enum PointsPathEditMode { off, creating, editing } - class PointsPath extends PointsPathBase with Skinnable { final List _vertices = []; PointsPath() {