Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Matrix4f Mapped optimized

By: a guest on Jul 24th, 2011  |  syntax: Java 5  |  size: 1.95 KB  |  views: 135  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public void mul4f(Matrix4fMapped left, Matrix4fMapped right) {
  2.         float rmX3 = right.m03;
  3.         float rmX2 = right.m02;
  4.         float rmX1 = right.m01;
  5.         float rmX0 = right.m00;
  6.  
  7.         final float lm03 = left.m03;
  8.         this.m03 = lm03 * rmX0 + left.m13 * rmX1 + left.m23 * rmX2 + left.m33 * rmX3;
  9.         final float lm02 = left.m02;
  10.         this.m02 = lm02 * rmX0 + left.m12 * rmX1 + left.m22 * rmX2 + left.m32 * rmX3;
  11.         final float lm01 = left.m01;
  12.         this.m01 = lm01 * rmX0 + left.m11 * rmX1 + left.m21 * rmX2 + left.m31 * rmX3;
  13.         final float lm00 = left.m00;
  14.         this.m00 = lm00 * rmX0 + left.m10 * rmX1 + left.m20 * rmX2 + left.m30 * rmX3;
  15.  
  16.         rmX3 = right.m13;
  17.         rmX2 = right.m12;
  18.         rmX1 = right.m11;
  19.         rmX0 = right.m10;
  20.  
  21.         final float lm13 = left.m13;
  22.         final float lm12 = left.m12;
  23.         final float lm11 = left.m11;
  24.         final float lm10 = left.m10;
  25.  
  26.         this.m13 = lm03 * rmX0 + lm13 * rmX1 + left.m23 * rmX2 + left.m33 * rmX3;
  27.         this.m12 = lm02 * rmX0 + lm12 * rmX1 + left.m22 * rmX2 + left.m32 * rmX3;
  28.         this.m11 = lm01 * rmX0 + lm11 * rmX1 + left.m21 * rmX2 + left.m31 * rmX3;
  29.         this.m10 = lm00 * rmX0 + lm10 * rmX1 + left.m20 * rmX2 + left.m30 * rmX3;
  30.  
  31.         rmX3 = right.m23;
  32.         rmX2 = right.m22;
  33.         rmX1 = right.m21;
  34.         rmX0 = right.m20;
  35.  
  36.         final float lm23 = left.m23;
  37.         final float lm22 = left.m22;
  38.         final float lm21 = left.m21;
  39.         final float lm20 = left.m20;
  40.  
  41.         this.m23 = lm03 * rmX0 + lm13 * rmX1 + lm23 * rmX2 + left.m33 * rmX3;
  42.         this.m22 = lm02 * rmX0 + lm12 * rmX1 + lm22 * rmX2 + left.m32 * rmX3;
  43.         this.m21 = lm01 * rmX0 + lm11 * rmX1 + lm21 * rmX2 + left.m31 * rmX3;
  44.         this.m20 = lm00 * rmX0 + lm10 * rmX1 + lm20 * rmX2 + left.m30 * rmX3;
  45.  
  46.         rmX3 = right.m33;
  47.         rmX2 = right.m32;
  48.         rmX1 = right.m31;
  49.         rmX0 = right.m30;
  50.  
  51.         this.m33 = lm03 * rmX0 + lm13 * rmX1 + lm23 * rmX2 + left.m33 * rmX3;
  52.         this.m32 = lm02 * rmX0 + lm12 * rmX1 + lm22 * rmX2 + left.m32 * rmX3;
  53.         this.m31 = lm01 * rmX0 + lm11 * rmX1 + lm21 * rmX2 + left.m31 * rmX3;
  54.         this.m30 = lm00 * rmX0 + lm10 * rmX1 + lm20 * rmX2 + left.m30 * rmX3;
  55. }