Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 16ed37a8 authored by Trevor Black's avatar Trevor Black Committed by Trevor David Black
Browse files

Revert "Revert "Deprecate setRotateEulerM and replace with setRo..."

Revert submission 2382753-revert-2208281-opengl-matrix-VRTQUTHPDK

Reason for revert: Revert-Revert-with-fix

Reverted changes: /q/submissionid:2382753-revert-2208281-opengl-matrix-VRTQUTHPDK

Change-Id: Ie6b4eee4f06c1b8b6b8e97bdbce76d01e05f15d1
parent 449f4269
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -30768,7 +30768,8 @@ package android.opengl {
    method public static void scaleM(float[], int, float, float, float);
    method public static void scaleM(float[], int, float, float, float);
    method public static void setIdentityM(float[], int);
    method public static void setIdentityM(float[], int);
    method public static void setLookAtM(float[], int, float, float, float, float, float, float, float, float, float);
    method public static void setLookAtM(float[], int, float, float, float, float, float, float, float, float, float);
    method public static void setRotateEulerM(float[], int, float, float, float);
    method @Deprecated public static void setRotateEulerM(float[], int, float, float, float);
    method public static void setRotateEulerM2(@NonNull float[], int, float, float, float);
    method public static void setRotateM(float[], int, float, float, float, float);
    method public static void setRotateM(float[], int, float, float, float, float);
    method public static void translateM(float[], int, float[], int, float, float, float);
    method public static void translateM(float[], int, float[], int, float, float, float);
    method public static void translateM(float[], int, float, float, float);
    method public static void translateM(float[], int, float, float, float);
+66 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.opengl;
package android.opengl;


import androidx.annotation.NonNull;

/**
/**
 * Matrix math utilities. These methods operate on OpenGL ES format
 * Matrix math utilities. These methods operate on OpenGL ES format
 * matrices and vectors stored in float arrays.
 * matrices and vectors stored in float arrays.
@@ -807,9 +809,14 @@ public class Matrix {
     * @param rm returns the result
     * @param rm returns the result
     * @param rmOffset index into rm where the result matrix starts
     * @param rmOffset index into rm where the result matrix starts
     * @param x angle of rotation, in degrees
     * @param x angle of rotation, in degrees
     * @param y angle of rotation, in degrees
     * @param y is broken, do not use
     * @param z angle of rotation, in degrees
     * @param z angle of rotation, in degrees
     *
     * @deprecated This method is incorrect around the y axis. This method is
     *             deprecated and replaced (below) by setRotateEulerM2 which
     *             behaves correctly
     */
     */
    @Deprecated
    public static void setRotateEulerM(float[] rm, int rmOffset,
    public static void setRotateEulerM(float[] rm, int rmOffset,
            float x, float y, float z) {
            float x, float y, float z) {
        x *= (float) (Math.PI / 180.0f);
        x *= (float) (Math.PI / 180.0f);
@@ -845,6 +852,64 @@ public class Matrix {
        rm[rmOffset + 15] =  1.0f;
        rm[rmOffset + 15] =  1.0f;
    }
    }


    /**
     * Converts Euler angles to a rotation matrix.
     *
     * @param rm returns the result
     * @param rmOffset index into rm where the result matrix starts
     * @param x angle of rotation, in degrees
     * @param y angle of rotation, in degrees
     * @param z angle of rotation, in degrees
     *
     * @throws IllegalArgumentException if rm is null;
     * or if rmOffset + 16 > rm.length;
     * rmOffset < 0
     */
    public static void setRotateEulerM2(@NonNull float[] rm, int rmOffset,
            float x, float y, float z) {
        if (rm == null) {
            throw new IllegalArgumentException("rm == null");
        }
        if (rmOffset < 0) {
            throw new IllegalArgumentException("rmOffset < 0");
        }
        if (rm.length < rmOffset + 16) {
            throw new IllegalArgumentException("rm.length < rmOffset + 16");
        }

        x *= (float) (Math.PI / 180.0f);
        y *= (float) (Math.PI / 180.0f);
        z *= (float) (Math.PI / 180.0f);
        float cx = (float) Math.cos(x);
        float sx = (float) Math.sin(x);
        float cy = (float) Math.cos(y);
        float sy = (float) Math.sin(y);
        float cz = (float) Math.cos(z);
        float sz = (float) Math.sin(z);
        float cxsy = cx * sy;
        float sxsy = sx * sy;

        rm[rmOffset + 0]  =  cy * cz;
        rm[rmOffset + 1]  = -cy * sz;
        rm[rmOffset + 2]  =  sy;
        rm[rmOffset + 3]  =  0.0f;

        rm[rmOffset + 4]  =  sxsy * cz + cx * sz;
        rm[rmOffset + 5]  = -sxsy * sz + cx * cz;
        rm[rmOffset + 6]  = -sx * cy;
        rm[rmOffset + 7]  =  0.0f;

        rm[rmOffset + 8]  = -cxsy * cz + sx * sz;
        rm[rmOffset + 9]  =  cxsy * sz + sx * cz;
        rm[rmOffset + 10] =  cx * cy;
        rm[rmOffset + 11] =  0.0f;

        rm[rmOffset + 12] =  0.0f;
        rm[rmOffset + 13] =  0.0f;
        rm[rmOffset + 14] =  0.0f;
        rm[rmOffset + 15] =  1.0f;
    }

    /**
    /**
     * Defines a viewing transformation in terms of an eye point, a center of
     * Defines a viewing transformation in terms of an eye point, a center of
     * view, and an up vector.
     * view, and an up vector.