Skip to content

Commit 78bf57e

Browse files
committed
tests: Use Ruffle approximations in perspective_projection test
Move approximation logic from ActionScript to Ruffle test framework
1 parent 81d3211 commit 78bf57e

File tree

4 files changed

+1215
-1221
lines changed

4 files changed

+1215
-1221
lines changed

tests/tests/swfs/avm2/perspective_projection/Test.as

+11-24
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,15 @@ package {
5050
for (var i: int = 1; i < 180; i++) {
5151
var pp: PerspectiveProjection = new PerspectiveProjection();
5252
pp.fieldOfView = i;
53-
var fl: Number = pp.focalLength;
54-
trace("FOV to FL", i, roundN(fl, 100)); // FIXME: Large numerical errors
53+
trace("FOV to FL", i, pp.focalLength);
5554
}
5655
}
5756

5857
private function TestFLtoFOV(): void {
5958
for (var i: int = 1; i < 1000; i++) {
6059
var pp: PerspectiveProjection = new PerspectiveProjection();
6160
pp.focalLength = i;
62-
var fl: Number = pp.fieldOfView;
63-
trace("FL to FOV", i, roundN(fl, 100000000000));
61+
trace("FL to FOV", i, pp.fieldOfView);
6462
}
6563
}
6664

@@ -108,35 +106,34 @@ package {
108106
}
109107

110108
private function TestToMatrix3D(): void {
111-
var precision: Number = 100;
112109
var pp: PerspectiveProjection = new PerspectiveProjection();
113110

114111
trace("// toMatrix3D(default)");
115-
trace(roundVecN(pp.toMatrix3D().rawData, precision));
112+
trace(pp.toMatrix3D().rawData);
116113

117114
trace("// toMatrix3D(FOV: 1)");
118115
pp.fieldOfView = 1;
119-
trace(roundVecN(pp.toMatrix3D().rawData, precision));
116+
trace(pp.toMatrix3D().rawData);
120117

121118
trace("// toMatrix3D(FOV: 100)");
122119
pp.fieldOfView = 100;
123-
trace(roundVecN(pp.toMatrix3D().rawData, precision));
120+
trace(pp.toMatrix3D().rawData);
124121

125122
trace("// toMatrix3D(FOV: 179)");
126123
pp.fieldOfView = 179;
127-
trace(roundVecN(pp.toMatrix3D().rawData, precision));
124+
trace(pp.toMatrix3D().rawData);
128125

129126
trace("// toMatrix3D(FL: 1)");
130127
pp.focalLength = 1;
131-
trace(roundVecN(pp.toMatrix3D().rawData, precision));
128+
trace(pp.toMatrix3D().rawData);
132129

133130
trace("// toMatrix3D(FL: 10)");
134131
pp.focalLength = 10;
135-
trace(roundVecN(pp.toMatrix3D().rawData, precision));
132+
trace(pp.toMatrix3D().rawData);
136133

137134
trace("// toMatrix3D(FL: 10000)");
138135
pp.focalLength = 10000;
139-
trace(roundVecN(pp.toMatrix3D().rawData, precision));
136+
trace(pp.toMatrix3D().rawData);
140137
}
141138

142139
private function TestTransform(): void {
@@ -179,20 +176,10 @@ package {
179176
private function printProps(pp: PerspectiveProjection): void {
180177
trace(" perspectiveProjection = " + pp);
181178
if (pp) {
182-
trace(" perspectiveProjection.fieldOfView = " + roundN(pp.fieldOfView, 100000000000));
183-
trace(" perspectiveProjection.focalLength = " + roundN(pp.focalLength, 100)); // FIXME: Large numerical errors
179+
trace(" perspectiveProjection.fieldOfView = " + pp.fieldOfView);
180+
trace(" perspectiveProjection.focalLength = " + pp.focalLength);
184181
trace(" perspectiveProjection.projectionCenter = " + pp.projectionCenter);
185182
}
186183
}
187-
188-
private function roundN(n: Number, precision: Number): Number {
189-
return Math.round(n * precision) / precision;
190-
}
191-
192-
private function roundVecN(v: Vector.<Number>, precision: Number): Vector.<Number> {
193-
return v.map(
194-
function (n: Number, _, _): Number {return roundN(n, precision);}
195-
);
196-
}
197184
}
198185
}

0 commit comments

Comments
 (0)