mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-28 01:52:26 -06:00
61 lines
2 KiB
Java
61 lines
2 KiB
Java
package androidx.media3.exoplayer.video.spherical;
|
|
|
|
import android.opengl.Matrix;
|
|
import androidx.media3.common.util.GlUtil;
|
|
import androidx.media3.common.util.TimedValueQueue;
|
|
|
|
/* loaded from: classes2.dex */
|
|
final class FrameRotationQueue {
|
|
private boolean recenterMatrixComputed;
|
|
private final float[] recenterMatrix = new float[16];
|
|
private final float[] rotationMatrix = new float[16];
|
|
private final TimedValueQueue<float[]> rotations = new TimedValueQueue<>();
|
|
|
|
public void setRotation(long j, float[] fArr) {
|
|
this.rotations.add(j, fArr);
|
|
}
|
|
|
|
public void reset() {
|
|
this.rotations.clear();
|
|
this.recenterMatrixComputed = false;
|
|
}
|
|
|
|
public boolean pollRotationMatrix(float[] fArr, long j) {
|
|
float[] pollFloor = this.rotations.pollFloor(j);
|
|
if (pollFloor == null) {
|
|
return false;
|
|
}
|
|
getRotationMatrixFromAngleAxis(this.rotationMatrix, pollFloor);
|
|
if (!this.recenterMatrixComputed) {
|
|
computeRecenterMatrix(this.recenterMatrix, this.rotationMatrix);
|
|
this.recenterMatrixComputed = true;
|
|
}
|
|
Matrix.multiplyMM(fArr, 0, this.recenterMatrix, 0, this.rotationMatrix, 0);
|
|
return true;
|
|
}
|
|
|
|
public static void computeRecenterMatrix(float[] fArr, float[] fArr2) {
|
|
GlUtil.setToIdentity(fArr);
|
|
float f = fArr2[10];
|
|
float f2 = fArr2[8];
|
|
float sqrt = (float) Math.sqrt((f * f) + (f2 * f2));
|
|
float f3 = fArr2[10];
|
|
fArr[0] = f3 / sqrt;
|
|
float f4 = fArr2[8];
|
|
fArr[2] = f4 / sqrt;
|
|
fArr[8] = (-f4) / sqrt;
|
|
fArr[10] = f3 / sqrt;
|
|
}
|
|
|
|
private static void getRotationMatrixFromAngleAxis(float[] fArr, float[] fArr2) {
|
|
float f = fArr2[0];
|
|
float f2 = -fArr2[1];
|
|
float f3 = -fArr2[2];
|
|
float length = Matrix.length(f, f2, f3);
|
|
if (length != 0.0f) {
|
|
Matrix.setRotateM(fArr, 0, (float) Math.toDegrees(length), f / length, f2 / length, f3 / length);
|
|
} else {
|
|
GlUtil.setToIdentity(fArr);
|
|
}
|
|
}
|
|
}
|