Commit fde55a6f authored by Adam Barth's avatar Adam Barth

Update vector_math (#4201)

The new version has an API change. Also, up our SDK requirements to be a
bit more realistic.
parent 9cfa9660
...@@ -175,14 +175,14 @@ Widget buildTextSelectionHandle( ...@@ -175,14 +175,14 @@ Widget buildTextSelectionHandle(
switch (type) { switch (type) {
case TextSelectionHandleType.left: // points up-right case TextSelectionHandleType.left: // points up-right
return new Transform( return new Transform(
transform: new Matrix4.identity().rotateZ(math.PI / 2.0), transform: new Matrix4.rotationZ(math.PI / 2.0),
child: handle child: handle
); );
case TextSelectionHandleType.right: // points up-left case TextSelectionHandleType.right: // points up-left
return handle; return handle;
case TextSelectionHandleType.collapsed: // points up case TextSelectionHandleType.collapsed: // points up
return new Transform( return new Transform(
transform: new Matrix4.identity().rotateZ(math.PI / 4.0), transform: new Matrix4.rotationZ(math.PI / 4.0),
child: handle child: handle
); );
} }
......
...@@ -192,7 +192,7 @@ class RenderViewportBase extends RenderBox { ...@@ -192,7 +192,7 @@ class RenderViewportBase extends RenderBox {
@override @override
void applyPaintTransform(RenderBox child, Matrix4 transform) { void applyPaintTransform(RenderBox child, Matrix4 transform) {
final Offset effectivePaintOffset = _effectivePaintOffset; final Offset effectivePaintOffset = _effectivePaintOffset;
super.applyPaintTransform(child, transform.translate(effectivePaintOffset.dx, effectivePaintOffset.dy)); super.applyPaintTransform(child, transform..translate(effectivePaintOffset.dx, effectivePaintOffset.dy));
} }
@override @override
......
...@@ -7,7 +7,7 @@ homepage: http://flutter.io ...@@ -7,7 +7,7 @@ homepage: http://flutter.io
dependencies: dependencies:
collection: '>=1.4.0 <2.0.0' collection: '>=1.4.0 <2.0.0'
intl: '>=0.12.4+2 <0.13.0' intl: '>=0.12.4+2 <0.13.0'
vector_math: '>=1.4.5 <2.0.0' vector_math: '>=2.0.3 <3.0.0'
# We need to pin crypto because archive can't handle larger numbers. # We need to pin crypto because archive can't handle larger numbers.
crypto: 0.9.2 crypto: 0.9.2
...@@ -24,4 +24,4 @@ dev_dependencies: ...@@ -24,4 +24,4 @@ dev_dependencies:
path: ../flutter_test path: ../flutter_test
environment: environment:
sdk: '>=1.12.0 <2.0.0' sdk: '>=1.16.0 <2.0.0'
...@@ -29,7 +29,7 @@ void main() { ...@@ -29,7 +29,7 @@ void main() {
width: 100.0, width: 100.0,
height: 100.0, height: 100.0,
child: new Transform( child: new Transform(
transform: new Matrix4.identity().scale(0.5, 0.5), transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
origin: new Offset(100.0, 50.0), origin: new Offset(100.0, 50.0),
child: new GestureDetector( child: new GestureDetector(
onTap: () { onTap: () {
...@@ -78,7 +78,7 @@ void main() { ...@@ -78,7 +78,7 @@ void main() {
width: 100.0, width: 100.0,
height: 100.0, height: 100.0,
child: new Transform( child: new Transform(
transform: new Matrix4.identity().scale(0.5, 0.5), transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
alignment: new FractionalOffset(1.0, 0.5), alignment: new FractionalOffset(1.0, 0.5),
child: new GestureDetector( child: new GestureDetector(
onTap: () { onTap: () {
...@@ -127,7 +127,7 @@ void main() { ...@@ -127,7 +127,7 @@ void main() {
width: 100.0, width: 100.0,
height: 100.0, height: 100.0,
child: new Transform( child: new Transform(
transform: new Matrix4.identity().scale(0.5, 0.5), transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0),
origin: new Offset(100.0, 0.0), origin: new Offset(100.0, 0.0),
alignment: new FractionalOffset(0.0, 0.5), alignment: new FractionalOffset(0.0, 0.5),
child: new GestureDetector( child: new GestureDetector(
......
...@@ -5,7 +5,7 @@ homepage: http://flutter.io ...@@ -5,7 +5,7 @@ homepage: http://flutter.io
author: Flutter Authors <flutter-dev@googlegroups.com> author: Flutter Authors <flutter-dev@googlegroups.com>
environment: environment:
sdk: '>=1.12.0 <2.0.0' sdk: '>=1.16.0 <2.0.0'
dependencies: dependencies:
file: '^0.1.0' file: '^0.1.0'
......
...@@ -413,10 +413,10 @@ class Node { ...@@ -413,10 +413,10 @@ class Node {
if (_parent == null) { if (_parent == null) {
// Base case, we are at the top // Base case, we are at the top
assert(this == _spriteBox.rootNode); assert(this == _spriteBox.rootNode);
_transformMatrixNodeToBox = new Matrix4.copy(_spriteBox.transformMatrix).multiply(transformMatrix); _transformMatrixNodeToBox = _spriteBox.transformMatrix.clone()..multiply(transformMatrix);
} }
else { else {
_transformMatrixNodeToBox = new Matrix4.copy(_parent._nodeToBoxMatrix()).multiply(transformMatrix); _transformMatrixNodeToBox = _parent._nodeToBoxMatrix().clone()..multiply(transformMatrix);
} }
return _transformMatrixNodeToBox; return _transformMatrixNodeToBox;
} }
......
...@@ -52,7 +52,7 @@ class Node3D extends Node { ...@@ -52,7 +52,7 @@ class Node3D extends Node {
0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, -1.0/_projectionDepth, 0.0, 0.0, 1.0, -1.0/_projectionDepth,
0.0, 0.0, 0.0, 1.0); 0.0, 0.0, 0.0, 1.0);
matrix = matrix.multiply(projection); matrix.multiply(projection);
// Rotate around x and y axis // Rotate around x and y axis
matrix.rotateY(radians(_rotationY)); matrix.rotateY(radians(_rotationY));
......
...@@ -261,7 +261,7 @@ class ParticleSystem extends Node { ...@@ -261,7 +261,7 @@ class ParticleSystem extends Node {
// Radial acceleration // Radial acceleration
Vector2 radial; Vector2 radial;
if (particle.pos[0] != 0 || particle.pos[1] != 0) { if (particle.pos[0] != 0 || particle.pos[1] != 0) {
radial = new Vector2.copy(particle.pos).normalize(); radial = new Vector2.copy(particle.pos)..normalize();
} else { } else {
radial = new Vector2.zero(); radial = new Vector2.zero();
} }
...@@ -275,11 +275,11 @@ class ParticleSystem extends Node { ...@@ -275,11 +275,11 @@ class ParticleSystem extends Node {
tangential.scale(particle.accelerations.tangentialAccel); tangential.scale(particle.accelerations.tangentialAccel);
// (gravity + radial + tangential) * dt // (gravity + radial + tangential) * dt
final Vector2 accel = (_gravity + radial + tangential).scale(dt); final Vector2 accel = (_gravity + radial + tangential)..scale(dt);
particle.dir += accel; particle.dir += accel;
} else if (_gravity[0] != 0.0 || _gravity[1] != 0) { } else if (_gravity[0] != 0.0 || _gravity[1] != 0) {
// gravity // gravity
final Vector2 accel = new Vector2.copy(_gravity).scale(dt); final Vector2 accel = _gravity.clone()..scale(dt);
particle.dir += accel; particle.dir += accel;
} }
...@@ -334,7 +334,7 @@ class ParticleSystem extends Node { ...@@ -334,7 +334,7 @@ class ParticleSystem extends Node {
double dirRadians = convertDegrees2Radians(direction + directionVar * randomSignedDouble()); double dirRadians = convertDegrees2Radians(direction + directionVar * randomSignedDouble());
Vector2 dirVector = new Vector2(math.cos(dirRadians), math.sin(dirRadians)); Vector2 dirVector = new Vector2(math.cos(dirRadians), math.sin(dirRadians));
double speedFinal = speed + speedVar * randomSignedDouble(); double speedFinal = speed + speedVar * randomSignedDouble();
particle.dir = dirVector.scale(speedFinal); particle.dir = dirVector..scale(speedFinal);
// Accelerations // Accelerations
if (radialAcceleration != 0.0 || radialAccelerationVar != 0.0 || if (radialAcceleration != 0.0 || radialAccelerationVar != 0.0 ||
......
...@@ -271,14 +271,12 @@ Vector2 _computeMiter(Vector2 lineA, Vector2 lineB) { ...@@ -271,14 +271,12 @@ Vector2 _computeMiter(Vector2 lineA, Vector2 lineB) {
double dot = dot2(miter, new Vector2(-lineA[1], lineA[0])); double dot = dot2(miter, new Vector2(-lineA[1], lineA[0]));
if (dot.abs() < 0.1) { if (dot.abs() < 0.1) {
miter = _vectorNormal(lineA).normalize(); miter = _vectorNormal(lineA)..normalize();
return miter; return miter;
} }
double miterLength = 1.0 / dot; double miterLength = 1.0 / dot;
miter = miter.scale(miterLength); return miter..scale(miterLength);
return miter;
} }
Vector2 _vectorNormal(Vector2 v) { Vector2 _vectorNormal(Vector2 v) {
...@@ -287,7 +285,7 @@ Vector2 _vectorNormal(Vector2 v) { ...@@ -287,7 +285,7 @@ Vector2 _vectorNormal(Vector2 v) {
Vector2 _vectorDirection(Vector2 a, Vector2 b) { Vector2 _vectorDirection(Vector2 a, Vector2 b) {
Vector2 result = a - b; Vector2 result = a - b;
return result.normalize(); return result..normalize();
} }
List<Vector2> _computeMiterList(List<Vector2> points, bool closed) { List<Vector2> _computeMiterList(List<Vector2> points, bool closed) {
......
...@@ -5,7 +5,7 @@ author: Flutter Authors <flutter-dev@googlegroups.com> ...@@ -5,7 +5,7 @@ author: Flutter Authors <flutter-dev@googlegroups.com>
homepage: http://flutter.io homepage: http://flutter.io
dependencies: dependencies:
box2d: '>=0.2.0 <0.3.0' box2d: '>=0.3.0 <0.4.0'
flutter: flutter:
path: ../flutter path: ../flutter
......
...@@ -5,7 +5,7 @@ homepage: http://flutter.io ...@@ -5,7 +5,7 @@ homepage: http://flutter.io
author: Flutter Authors <flutter-dev@googlegroups.com> author: Flutter Authors <flutter-dev@googlegroups.com>
environment: environment:
sdk: '>=1.12.0 <2.0.0' sdk: '>=1.16.0 <2.0.0'
dependencies: dependencies:
archive: ^1.0.20 archive: ^1.0.20
......
...@@ -10,7 +10,7 @@ dependencies: ...@@ -10,7 +10,7 @@ dependencies:
crypto: 0.9.2 crypto: 0.9.2
environment: environment:
sdk: '>=1.12.0 <2.0.0' sdk: '>=1.16.0 <2.0.0'
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
......
...@@ -13,4 +13,4 @@ dev_dependencies: ...@@ -13,4 +13,4 @@ dev_dependencies:
path: ../flutter_test path: ../flutter_test
environment: environment:
sdk: '>=1.12.0 <2.0.0' sdk: '>=1.16.0 <2.0.0'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment