Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microoptimization opportunities found #7

Open
wants to merge 2 commits into
base: 1.9.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 39 additions & 33 deletions com/watabou/glwrap/Matrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,46 @@
public class Matrix {

public static final float G2RAD = 0.01745329251994329576923690768489f;
public static float[] clone( float[] m ) {

public static float[] clone(float[] m) {

int n = m.length;
float[] res = new float[n];
do {
res[--n] = m[n];
} while (n > 0);

return res;
}
public static void copy( float[] src, float[] dst ) {

public static void copy(float[] src, float[] dst) {

int n = src.length;
do {
dst[--n] = src[n];
} while (n > 0);

}

public static void setIdentity( float[] m ) {
for (int i=0 ; i < 16 ; i++) {
m[i] = 0f;
}
for (int i = 0; i < 16; i += 5) {

public static void setIdentity(float[] m) {
for (int i = 0; i < 15; i += 5) {

m[i] = 1f;

m[i + 1] = 0f;
m[i + 2] = 0f;
m[i + 3] = 0f;
m[i + 4] = 0f;

}

m[15] = 1f;
}

public static void rotate( float[] m, float a ) {
public static void rotate(float[] m, float a) {
a *= G2RAD;
float sin = (float)Math.sin( a );
float cos = (float)Math.cos( a );
float sin = (float) Math.sin(a);
float cos = (float) Math.cos(a);
float m0 = m[0];
float m1 = m[1];
float m4 = m[4];
Expand All @@ -62,21 +68,21 @@ public static void rotate( float[] m, float a ) {
m[1] = m1 * cos + m5 * sin;
m[4] = -m0 * sin + m4 * cos;
m[5] = -m1 * sin + m5 * cos;
}
public static void skewX( float[] m, float a ) {
double t = Math.tan( a * G2RAD );
}

public static void skewX(float[] m, float a) {
double t = Math.tan(a * G2RAD);
m[4] += -m[0] * t;
m[5] += -m[1] * t;
}
public static void skewY( float[] m, float a ) {
double t = Math.tan( a * G2RAD );
}

public static void skewY(float[] m, float a) {
double t = Math.tan(a * G2RAD);
m[0] += m[4] * t;
m[1] += m[5] * t;
}
public static void scale( float[] m, float x, float y ) {
}

public static void scale(float[] m, float x, float y) {
m[0] *= x;
m[1] *= x;
m[2] *= x;
Expand All @@ -85,15 +91,15 @@ public static void scale( float[] m, float x, float y ) {
m[5] *= y;
m[6] *= y;
m[7] *= y;
// android.opengl.Matrix.scaleM( m, 0, x, y, 1 );
// android.opengl.Matrix.scaleM( m, 0, x, y, 1 );
}
public static void translate( float[] m, float x, float y ) {

public static void translate(float[] m, float x, float y) {
m[12] += m[0] * x + m[4] * y;
m[13] += m[1] * x + m[5] * y;
}
public static void multiply( float[] left, float right[], float[] result ) {
android.opengl.Matrix.multiplyMM( result, 0, left, 0, right, 0 );

public static void multiply(float[] left, float right[], float[] result) {
android.opengl.Matrix.multiplyMM(result, 0, left, 0, right, 0);
}
}
Loading