Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into…
Browse files Browse the repository at this point in the history
… dev
  • Loading branch information
luigi-rosso committed May 20, 2019
2 parents c51192d + 850ea83 commit 006d85b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion example/teddy/lib/teddy_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class TeddyController extends FlareControls {
play("idle");
}

// Called every frame by the wrapping [FlareActor].
// Called by [FlareActor] when the view transform changes.
// Updates the matrix that transforms Global-Flutter-coordinates into Flare-World-coordinates.
@override
void setViewTransform(Mat2D viewTransform) {
Expand Down
4 changes: 4 additions & 0 deletions flare_dart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.4.1] - 2019-05-20 10:40:04

Adding an areEquals method to Mat2D.

## [1.4.0] - 2019-04-23 19:43:01

Improving load times by using ByteData views when possible in favor of reading data in tight loops.
Expand Down
9 changes: 9 additions & 0 deletions flare_dart/lib/math/mat2d.dart
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ class Mat2D {
}
}

static bool areEqual(Mat2D a, Mat2D b) {
return a[0] == b[0] &&
a[1] == b[1] &&
a[2] == b[2] &&
a[3] == b[3] &&
a[4] == b[4] &&
a[5] == b[5];
}

@override
String toString() {
return _buffer.toString();
Expand Down
6 changes: 3 additions & 3 deletions flare_dart/lib/math/vec2d.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "dart:typed_data";
import "dart:math";
import "mat2d.dart";
import 'dart:math';
import 'dart:typed_data';
import 'mat2d.dart';

class Vec2D {
Float32List _buffer;
Expand Down
2 changes: 1 addition & 1 deletion flare_dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flare_dart
description: Vector design and runtime animation.
version: 1.4.0
version: 1.4.1
author: "2Dimensions Team <[email protected]>"
homepage: https://github.com/2d-inc/Flare-Flutter
environment:
Expand Down
4 changes: 4 additions & 0 deletions flare_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.5.1] - 2019-05-20 10:38:30

Added missing call to setViewTransform for controllers. This is now done more efficiently as it is only called when the view transform changes.

## [1.5.0] - 2019-04-23 19:41:56

- New system in place to prevent breaking stable builds.
Expand Down
11 changes: 8 additions & 3 deletions flare_flutter/lib/flare_actor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ import 'dart:math';
import 'dart:typed_data';
import 'package:flare_flutter/flare_render_box.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:flutter/rendering.dart';
import 'package:flare_dart/actor_drawable.dart';
import 'package:flare_dart/math/mat2d.dart';
import 'package:flare_dart/math/vec2d.dart';
import 'package:flare_dart/math/aabb.dart';
import 'flare.dart';
import 'flare_controller.dart';
Expand Down Expand Up @@ -91,6 +88,7 @@ class FlareAnimationLayer {
}

class FlareActorRenderObject extends FlareRenderBox {
Mat2D _lastControllerViewTransform;
String _filename;
String _animationName;
String _boundsNodeName;
Expand Down Expand Up @@ -181,6 +179,7 @@ class FlareActorRenderObject extends FlareRenderBox {
FlareController get controller => _controller;
set controller(FlareController c) {
if (_controller != c) {
_lastControllerViewTransform = c == null ? null : Mat2D();
_controller?.isActive?.removeListener(onControllerActiveChange);
_controller = c;
_controller?.isActive?.addListener(onControllerActiveChange);
Expand Down Expand Up @@ -326,6 +325,12 @@ class FlareActorRenderObject extends FlareRenderBox {
if (_artboard == null) {
return;
}
if (controller != null &&
!Mat2D.areEqual(_lastControllerViewTransform, viewTransform)) {
Mat2D.copy(_lastControllerViewTransform, viewTransform);
controller?.setViewTransform(viewTransform);
}

_artboard.draw(canvas);
}

Expand Down

0 comments on commit 006d85b

Please sign in to comment.