Skip to content

Commit 3939545

Browse files
authored
Bump min SDK to 3.7, update dependencies, reformat (#348)
1 parent 13f185f commit 3939545

File tree

84 files changed

+3351
-1716
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3351
-1716
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
sdk: [3.1, dev]
17+
sdk: [3.7, dev]
1818

1919
steps:
2020
# These are the latest versions of the github actions; dependabot will

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.2.1-wip
2+
3+
- Require `sdk: ^3.7.0`.
4+
15
## 2.2.0
26

37
- Performance of functions that take `dynamic` arguments improved.

benchmark/matrix_bench.dart

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class Matrix3TransposeMultiplyBenchmark extends BenchmarkBase {
325325

326326
class Matrix4TranslateByDoubleGenericBenchmark extends BenchmarkBase {
327327
Matrix4TranslateByDoubleGenericBenchmark()
328-
: super('Matrix4.translateByDoubleGeneric');
328+
: super('Matrix4.translateByDoubleGeneric');
329329

330330
final temp = Matrix4.zero()..setIdentity();
331331

@@ -343,7 +343,7 @@ class Matrix4TranslateByDoubleGenericBenchmark extends BenchmarkBase {
343343

344344
class Matrix4TranslateByVector3GenericBenchmark extends BenchmarkBase {
345345
Matrix4TranslateByVector3GenericBenchmark()
346-
: super('Matrix4.translateByVector3Generic');
346+
: super('Matrix4.translateByVector3Generic');
347347

348348
final temp = Matrix4.zero()..setIdentity();
349349
final vec = Vector3(10.0, 20.0, 30.0);
@@ -362,7 +362,7 @@ class Matrix4TranslateByVector3GenericBenchmark extends BenchmarkBase {
362362

363363
class Matrix4TranslateByVector4GenericBenchmark extends BenchmarkBase {
364364
Matrix4TranslateByVector4GenericBenchmark()
365-
: super('Matrix4.translateByVector4Generic');
365+
: super('Matrix4.translateByVector4Generic');
366366

367367
final temp = Matrix4.zero()..setIdentity();
368368
final vec = Vector4(10.0, 20.0, 30.0, 40.0);
@@ -395,7 +395,11 @@ class Matrix4TranslateByDoubleBenchmark extends BenchmarkBase {
395395
void setup() {
396396
for (var i = 0; i < 10; i++) {
397397
temp.translateByDouble(
398-
i.toDouble(), (i * 10).toDouble(), (i * 5).toDouble(), 1.0);
398+
i.toDouble(),
399+
(i * 10).toDouble(),
400+
(i * 5).toDouble(),
401+
1.0,
402+
);
399403
}
400404
}
401405

@@ -424,7 +428,8 @@ class Matrix4TranslateByVector3Benchmark extends BenchmarkBase {
424428
void setup() {
425429
for (var i = 0; i < 10; i++) {
426430
temp.translateByVector3(
427-
Vector3(i.toDouble(), (i * 10).toDouble(), (i * 5).toDouble()));
431+
Vector3(i.toDouble(), (i * 10).toDouble(), (i * 5).toDouble()),
432+
);
428433
}
429434
}
430435

@@ -452,8 +457,14 @@ class Matrix4TranslateByVector4Benchmark extends BenchmarkBase {
452457
@override
453458
void setup() {
454459
for (var i = 0; i < 10; i++) {
455-
temp.translateByVector4(Vector4(i.toDouble(), (i * 10).toDouble(),
456-
(i * 5).toDouble(), (i * 20).toDouble()));
460+
temp.translateByVector4(
461+
Vector4(
462+
i.toDouble(),
463+
(i * 10).toDouble(),
464+
(i * 5).toDouble(),
465+
(i * 20).toDouble(),
466+
),
467+
);
457468
}
458469
}
459470

bin/mesh_generator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Map<String, GenerateFunction> generators = <String, GenerateFunction>{
6262
'sphere': generateSphere,
6363
'circle': generateCircle,
6464
'cylinder': generateCylinder,
65-
'ring': generateRing
65+
'ring': generateRing,
6666
};
6767

6868
void main(List<String> args) {

lib/src/vector_math/aabb2.dart

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,23 @@ class Aabb2 {
1717
Vector2 get max => _max;
1818

1919
/// The center of the AABB.
20-
Vector2 get center => _min.clone()
21-
..add(_max)
22-
..scale(0.5);
20+
Vector2 get center =>
21+
_min.clone()
22+
..add(_max)
23+
..scale(0.5);
2324

2425
/// Create a new AABB with [min] and [max] set to the origin.
25-
Aabb2()
26-
: _min = Vector2.zero(),
27-
_max = Vector2.zero();
26+
Aabb2() : _min = Vector2.zero(), _max = Vector2.zero();
2827

2928
/// Create a new AABB as a copy of [other].
3029
Aabb2.copy(Aabb2 other)
31-
: _min = Vector2.copy(other._min),
32-
_max = Vector2.copy(other._max);
30+
: _min = Vector2.copy(other._min),
31+
_max = Vector2.copy(other._max);
3332

3433
/// Create a new AABB with a [min] and [max].
3534
Aabb2.minMax(Vector2 min, Vector2 max)
36-
: _min = Vector2.copy(min),
37-
_max = Vector2.copy(max);
35+
: _min = Vector2.copy(min),
36+
_max = Vector2.copy(max);
3837

3938
/// Create a new AABB with a [center] and [halfExtents].
4039
factory Aabb2.centerAndHalfExtents(Vector2 center, Vector2 halfExtents) =>
@@ -44,9 +43,11 @@ class Aabb2 {
4443
/// starting at [offset]. [offset] has to be multiple of
4544
/// [Float32List.bytesPerElement].
4645
Aabb2.fromBuffer(ByteBuffer buffer, int offset)
47-
: _min = Vector2.fromBuffer(buffer, offset),
48-
_max = Vector2.fromBuffer(
49-
buffer, offset + Float32List.bytesPerElement * 2);
46+
: _min = Vector2.fromBuffer(buffer, offset),
47+
_max = Vector2.fromBuffer(
48+
buffer,
49+
offset + Float32List.bytesPerElement * 2,
50+
);
5051

5152
/// Set the AABB by a [center] and [halfExtents].
5253
void setCenterAndHalfExtents(Vector2 center, Vector2 halfExtents) {
@@ -109,15 +110,17 @@ class Aabb2 {
109110

110111
/// Create a copy of this that is transformed by the transform [t] and store
111112
/// it in [out].
112-
Aabb2 transformed(Matrix3 t, Aabb2 out) => out
113-
..copyFrom(this)
114-
..transform(t);
113+
Aabb2 transformed(Matrix3 t, Aabb2 out) =>
114+
out
115+
..copyFrom(this)
116+
..transform(t);
115117

116118
/// Create a copy of this that is rotated by the rotation matrix [t] and
117119
/// store it in [out].
118-
Aabb2 rotated(Matrix3 t, Aabb2 out) => out
119-
..copyFrom(this)
120-
..rotate(t);
120+
Aabb2 rotated(Matrix3 t, Aabb2 out) =>
121+
out
122+
..copyFrom(this)
123+
..rotate(t);
121124

122125
/// Set the min and max of this so that this is a hull of this and
123126
/// [other].

lib/src/vector_math/aabb3.dart

Lines changed: 81 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,23 @@ class Aabb3 {
1414
Vector3 get max => _max;
1515

1616
/// The center of the AABB.
17-
Vector3 get center => _min.clone()
18-
..add(_max)
19-
..scale(0.5);
17+
Vector3 get center =>
18+
_min.clone()
19+
..add(_max)
20+
..scale(0.5);
2021

2122
/// Create a new AABB with [min] and [max] set to the origin.
22-
Aabb3()
23-
: _min = Vector3.zero(),
24-
_max = Vector3.zero();
23+
Aabb3() : _min = Vector3.zero(), _max = Vector3.zero();
2524

2625
/// Create a new AABB as a copy of [other].
2726
Aabb3.copy(Aabb3 other)
28-
: _min = Vector3.copy(other._min),
29-
_max = Vector3.copy(other._max);
27+
: _min = Vector3.copy(other._min),
28+
_max = Vector3.copy(other._max);
3029

3130
/// Create a new AABB with a [min] and [max].
3231
Aabb3.minMax(Vector3 min, Vector3 max)
33-
: _min = Vector3.copy(min),
34-
_max = Vector3.copy(max);
32+
: _min = Vector3.copy(min),
33+
_max = Vector3.copy(max);
3534

3635
/// Create a new AABB that encloses a [sphere].
3736
factory Aabb3.fromSphere(Sphere sphere) => Aabb3()..setSphere(sphere);
@@ -59,9 +58,11 @@ class Aabb3 {
5958
/// starting at [offset]. [offset] has to be multiple of
6059
/// [Float32List.bytesPerElement].
6160
Aabb3.fromBuffer(ByteBuffer buffer, int offset)
62-
: _min = Vector3.fromBuffer(buffer, offset),
63-
_max = Vector3.fromBuffer(
64-
buffer, offset + Float32List.bytesPerElement * 3);
61+
: _min = Vector3.fromBuffer(buffer, offset),
62+
_max = Vector3.fromBuffer(
63+
buffer,
64+
offset + Float32List.bytesPerElement * 3,
65+
);
6566

6667
/// Set the AABB by a [center] and [halfExtents].
6768
void setCenterAndHalfExtents(Vector3 center, Vector3 halfExtents) {
@@ -86,41 +87,65 @@ class Aabb3 {
8687
/// Set the AABB to enclose a [triangle].
8788
void setTriangle(Triangle triangle) {
8889
_min.setValues(
89-
math.min(triangle._point0.x,
90-
math.min(triangle._point1.x, triangle._point2.x)),
91-
math.min(triangle._point0.y,
92-
math.min(triangle._point1.y, triangle._point2.y)),
93-
math.min(triangle._point0.z,
94-
math.min(triangle._point1.z, triangle._point2.z)));
90+
math.min(
91+
triangle._point0.x,
92+
math.min(triangle._point1.x, triangle._point2.x),
93+
),
94+
math.min(
95+
triangle._point0.y,
96+
math.min(triangle._point1.y, triangle._point2.y),
97+
),
98+
math.min(
99+
triangle._point0.z,
100+
math.min(triangle._point1.z, triangle._point2.z),
101+
),
102+
);
95103
_max.setValues(
96-
math.max(triangle._point0.x,
97-
math.max(triangle._point1.x, triangle._point2.x)),
98-
math.max(triangle._point0.y,
99-
math.max(triangle._point1.y, triangle._point2.y)),
100-
math.max(triangle._point0.z,
101-
math.max(triangle._point1.z, triangle._point2.z)));
104+
math.max(
105+
triangle._point0.x,
106+
math.max(triangle._point1.x, triangle._point2.x),
107+
),
108+
math.max(
109+
triangle._point0.y,
110+
math.max(triangle._point1.y, triangle._point2.y),
111+
),
112+
math.max(
113+
triangle._point0.z,
114+
math.max(triangle._point1.z, triangle._point2.z),
115+
),
116+
);
102117
}
103118

104119
/// Set the AABB to enclose a [quad].
105120
void setQuad(Quad quad) {
106121
_min.setValues(
107-
math.min(quad._point0.x,
108-
math.min(quad._point1.x, math.min(quad._point2.x, quad._point3.x))),
109-
math.min(quad._point0.y,
110-
math.min(quad._point1.y, math.min(quad._point2.y, quad._point3.y))),
111-
math.min(
112-
quad._point0.z,
113-
math.min(
114-
quad._point1.z, math.min(quad._point2.z, quad._point3.z))));
122+
math.min(
123+
quad._point0.x,
124+
math.min(quad._point1.x, math.min(quad._point2.x, quad._point3.x)),
125+
),
126+
math.min(
127+
quad._point0.y,
128+
math.min(quad._point1.y, math.min(quad._point2.y, quad._point3.y)),
129+
),
130+
math.min(
131+
quad._point0.z,
132+
math.min(quad._point1.z, math.min(quad._point2.z, quad._point3.z)),
133+
),
134+
);
115135
_max.setValues(
116-
math.max(quad._point0.x,
117-
math.max(quad._point1.x, math.max(quad._point2.x, quad._point3.x))),
118-
math.max(quad._point0.y,
119-
math.max(quad._point1.y, math.max(quad._point2.y, quad._point3.y))),
120-
math.max(
121-
quad._point0.z,
122-
math.max(
123-
quad._point1.z, math.max(quad._point2.z, quad._point3.z))));
136+
math.max(
137+
quad._point0.x,
138+
math.max(quad._point1.x, math.max(quad._point2.x, quad._point3.x)),
139+
),
140+
math.max(
141+
quad._point0.y,
142+
math.max(quad._point1.y, math.max(quad._point2.y, quad._point3.y)),
143+
),
144+
math.max(
145+
quad._point0.z,
146+
math.max(quad._point1.z, math.max(quad._point2.z, quad._point3.z)),
147+
),
148+
);
124149
}
125150

126151
/// Set the AABB to enclose a [obb].
@@ -238,15 +263,17 @@ class Aabb3 {
238263

239264
/// Create a copy of this that is transformed by the transform [t] and store
240265
/// it in [out].
241-
Aabb3 transformed(Matrix4 t, Aabb3 out) => out
242-
..copyFrom(this)
243-
..transform(t);
266+
Aabb3 transformed(Matrix4 t, Aabb3 out) =>
267+
out
268+
..copyFrom(this)
269+
..transform(t);
244270

245271
/// Create a copy of this that is rotated by the rotation matrix [t] and
246272
/// store it in [out].
247-
Aabb3 rotated(Matrix4 t, Aabb3 out) => out
248-
..copyFrom(this)
249-
..rotate(t);
273+
Aabb3 rotated(Matrix4 t, Aabb3 out) =>
274+
out
275+
..copyFrom(this)
276+
..rotate(t);
250277

251278
void getPN(Vector3 planeNormal, Vector3 outP, Vector3 outN) {
252279
if (planeNormal.x < 0.0) {
@@ -393,8 +420,11 @@ class Aabb3 {
393420
/// be used for the test. If [result] is specified and an intersection is
394421
/// found, result is modified to contain more details about the type of
395422
/// intersection.
396-
bool intersectsWithTriangle(Triangle other,
397-
{double epsilon = 1e-3, IntersectionResult? result}) {
423+
bool intersectsWithTriangle(
424+
Triangle other, {
425+
double epsilon = 1e-3,
426+
IntersectionResult? result,
427+
}) {
398428
double p0, p1, p2, r, len;
399429
double a;
400430

@@ -639,7 +669,8 @@ class Aabb3 {
639669
copyCenterAndHalfExtents(_aabbCenter, _aabbHalfExtents);
640670

641671
// Compute the projection interval radius of b onto L(t) = b.c + t * p.n
642-
final r = _aabbHalfExtents[0] * other.normal[0].abs() +
672+
final r =
673+
_aabbHalfExtents[0] * other.normal[0].abs() +
643674
_aabbHalfExtents[1] * other.normal[1].abs() +
644675
_aabbHalfExtents[2] * other.normal[2].abs();
645676
// Compute distance of box center from plane

0 commit comments

Comments
 (0)