commit 963921af39bfe6a74266daa4da1d36f93111de1b
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Sep 7 02:17:37 2021 +0200

    Remove statics from the Ultimate class.

diff --git a/src/main/java/org/distorted/objects/TwistyObject.java b/src/main/java/org/distorted/objects/TwistyObject.java
index a8bae7ae..079fc2cd 100644
--- a/src/main/java/org/distorted/objects/TwistyObject.java
+++ b/src/main/java/org/distorted/objects/TwistyObject.java
@@ -271,7 +271,7 @@ public abstract class TwistyObject extends DistortedNode
     int sizeIndex = ObjectList.getSizeIndex(list.ordinal(),mNumLayers);
     int resourceID= list.getResourceIDs()[sizeIndex];
 
-    if( false ) // resourceID!=0 )
+    if( resourceID!=0 )
       {
       InputStream is = res.openRawResource(resourceID);
       DataInputStream dos = new DataInputStream(is);
diff --git a/src/main/java/org/distorted/objects/TwistyUltimate.java b/src/main/java/org/distorted/objects/TwistyUltimate.java
index 61e6f570..1c073ac6 100644
--- a/src/main/java/org/distorted/objects/TwistyUltimate.java
+++ b/src/main/java/org/distorted/objects/TwistyUltimate.java
@@ -66,8 +66,6 @@ class TwistyUltimate extends TwistyObject
            new Static3D( 0,C,-B)
          };
 
-  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
-
   private static final int[] FACE_COLORS = new int[]
          {
            MINX_LGREEN, MINX_PINK   , MINX_SANDY , MINX_LBLUE,
@@ -75,169 +73,17 @@ class TwistyUltimate extends TwistyObject
            MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY
          };
 
-  private static final Static4D[] QUATS = new Static4D[]
-         {
-           new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
-           new Static4D(-0.5f, 0.5f, 0.5f, 0.5f ),
-           new Static4D( 0.5f,-0.5f,-0.5f, 0.5f ),
-           new Static4D( 0.0f,    F,   -E, 0.5f ),
-           new Static4D( 0.0f,   -F,    E, 0.5f ),
-           new Static4D(    E, 0.0f,    F, 0.5f ),
-           new Static4D(   -E, 0.0f,   -F, 0.5f ),
-           new Static4D(    F,    E, 0.0f, 0.5f ),
-           new Static4D(   -F,   -E, 0.0f, 0.5f ),
-           new Static4D(    E,    F,-0.5f, 0.0f ),
-           new Static4D( 0.5f,   -E,    F, 0.0f ),
-           new Static4D(    F, 0.5f,    E, 0.0f )
-         };
-
-  // Colors of the faces of cubits.
-  private static final int[][] mFaceMap = new int[][]
-         {
-           { 25,24,35, 36,36,36,36,36 },
-           { 27,28,29, 36,36,36,36,36 },
-           { 31,26,30, 36,36,36,36,36 },
-           { 32,34,33, 36,36,36,36,36 },
-
-           { 31,32,25, 36,36,36,36,36 },
-           { 33,28,24, 36,36,36,36,36 },
-           { 26,35,27, 36,36,36,36,36 },
-           { 30,29,34, 36,36,36,36,36 },
-
-           {  8, 0,13,21, 36,36,36,36 },
-           {  1, 2,19,23, 36,36,36,36 },
-           {  4,11,12,15, 36,36,36,36 },
-           {  3, 6,14,17, 36,36,36,36 },
-           {  5, 9,22,16, 36,36,36,36 },
-           {  7,10,20,18, 36,36,36,36 }
-         };
-
-  // centers of the 14 cubits.
-  static final float[][] CENTERS = new float[][]
-         {
-           { 0.0f,-0.5f,    G },
-           {    E,   -E,   -E },
-           {   -G, 0.0f,-0.5f },
-           { 0.5f,    G, 0.0f },
-
-           {   -E,    E,    E },
-           {    G, 0.0f, 0.5f },
-           {-0.5f,   -G, 0.0f },
-           { 0.0f, 0.5f,   -G },
-
-           {        E/2, (E+0.5f)/2,    (E+G)/2 },
-           {   -(E+G)/2,       -E/2, (E+0.5f)/2 },
-           { (E+0.5f)/2,   -(E+G)/2,        E/2 },
-           {       -E/2,-(E+0.5f)/2,   -(E+G)/2 },
-           {    (E+G)/2,        E/2,-(E+0.5f)/2 },
-           {-(E+0.5f)/2,    (E+G)/2,       -E/2 }
-         };
-
-  private static final double[][] VERTICES_SMALL_LEFT = new double[][]
-         {
-            {         0.000,         0.000,         0.000},
-            {       - 0.250,-SQ5/8 - 0.125,-SQ5/8 - 0.375},
-            { SQ5/8 + 0.125,-SQ5/8 - 0.375,       + 0.250},
-            { SQ5/8 + 0.375,       + 0.250,-SQ5/8 - 0.125},
-            { SQ5/4 + 0.250,-SQ5/4 - 0.250,-SQ5/4 - 0.250},
-            { SQ5/8 - 0.125,       + 0.250,-SQ5/8 - 0.125},
-            {       - 0.250,-SQ5/8 - 0.125,-SQ5/8 + 0.125},
-            { SQ5/8 + 0.125,-SQ5/8 + 0.125,       + 0.250}
-         };
-
-  private static final int[][] VERT_INDEXES_SMALL_LEFT  = new int[][]
-         {
-           {6,0,5,1},   // counterclockwise!
-           {0,7,3,5},
-           {0,6,2,7},
-           {1,5,3,4},
-           {3,7,2,4},
-           {2,6,1,4},
-         };
-
-  private static final double[][] VERTICES_SMALL_RIGHT = new double[][]
-         {
-           { 0.0       ,  0.0      , 0.0       },
-           { -0.5*E    , 0.5*E+0.25, -0.25     },
-           {-0.25      , -E/2      , (-2*E-1)/4},
-           { 0.5*E+0.25, 0.25      , -E/2      },
-           { 0.0       , 0.5       , -E-0.5    },
-           { 0.0       , 0.5       , 0.0       },
-           { -0.5*E    ,-0.5*E+0.25, -0.25     },
-           {  0.5*E    ,-0.5*E+0.25, -0.25     }
-         };
-
-  private static final int[][] VERT_INDEXES_SMALL_RIGHT = new int[][]
-         {
-           {6,0,5,1},   // counterclockwise!
-           {0,7,3,5},
-           {0,6,2,7},
-           {4,3,5,1},
-           {4,2,7,3},
-           {4,1,6,2},
-         };
-
-  private static final double[][] VERTICES_BIG = new double[][]
-         {
-           {-E/2     ,-E/2+0.25,     0.25},
-           { E/2     , E/2-0.25,    -0.25},
-           {-E       ,     0.00,     0.00},
-           {     0.25, E/2     ,-E/2-0.25},
-           {-E/2     ,-E/2-0.25,     0.25},
-           { E/2+0.25,    -0.25,-E/2     },
-           {-E       ,    -0.50,     0.00},
-           {     0.50,     0.00,-E       },
-           {-E  +0.25, E/2     ,-E/2-0.25},
-           {     0.25,-E/2-0.50,-E/2+0.25},
-           {-E/2     ,-E/2-0.25,-E  -0.25}
-         };
-
-  private static final int[][] VERT_INDEXES_BIG = new int[][]
-         {
-           {0,1,3,8,2},   // counterclockwise!
-           {0,4,9,5,1},
-           { 0,2,6,4},
-           { 1,5,7,3},
-           {10,9,4,6},
-           {10,9,5,7},
-           {10,8,3,7},
-           {10,8,2,6}
-         };
-
-  private static final int[] QUAT_INDEX = new int[]
-         {
-           0,6,1,2,0,4,6,5,0,1,4,9,5,2
-         };
-
-  private static final float[][] STICKERS = new float[][]
-         {
-           { -0.14400357f, -0.47894150f, 0.50000000f,-0.011045523f, 0.37700626f, 0.36749030f,-0.26699730f, 0.36749026f, -0.46600536f, -0.24499352f }, // Big cubit 1st
-           {  0.36327127f,  0.26393202f,-0.36327127f, 0.500000000f,-0.36327127f,-0.26393202f, 0.36327127f,-0.50000000f },                             // Big cubit 2nd
-           { -0.29389262f, -0.50000000f, 0.29389262f,-0.309017000f, 0.29389262f, 0.30901700f,-0.29389262f, 0.50000000f },                             // Small cubit 1st
-         };
-
-  private static final ObjectSticker[] mStickers;
-
-  static
-    {
-    mStickers = new ObjectSticker[STICKERS.length];
-    final float R1 = 0.08f;
-    final float R2 = 0.13f;
-    final float R3 = 0.11f;
-    final float[][] radii  = { {R1,R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3} };
-    final float[] strokes = { 0.07f, 0.09f, 0.08f };
-
-    for(int s=0; s<STICKERS.length; s++)
-      {
-      mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
-      }
-    }
-
   private int mCurrState;
   private int mIndexExcluded;
   private final ScrambleState[] mStates;
   private int[][] mScrambleTable;
   private int[] mNumOccurences;
+  private int[] mBasicAngle;
+  private Static4D[] mQuats;
+  private int[][] mFaceMap;
+  private float[][] mCenters;
+  private int[] mQuatIndex;
+  private ObjectSticker[] mStickers;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -254,12 +100,34 @@ class TwistyUltimate extends TwistyObject
       };
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void initializeQuats()
+    {
+    mQuats = new Static4D[]
+         {
+         new Static4D( 0.0f, 0.0f, 0.0f, 1.0f ),
+         new Static4D(-0.5f, 0.5f, 0.5f, 0.5f ),
+         new Static4D( 0.5f,-0.5f,-0.5f, 0.5f ),
+         new Static4D( 0.0f,    F,   -E, 0.5f ),
+         new Static4D( 0.0f,   -F,    E, 0.5f ),
+         new Static4D(    E, 0.0f,    F, 0.5f ),
+         new Static4D(   -E, 0.0f,   -F, 0.5f ),
+         new Static4D(    F,    E, 0.0f, 0.5f ),
+         new Static4D(   -F,   -E, 0.0f, 0.5f ),
+         new Static4D(    E,    F,-0.5f, 0.0f ),
+         new Static4D( 0.5f,   -E,    F, 0.0f ),
+         new Static4D(    F, 0.5f,    E, 0.0f )
+         };
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   int[] getSolvedQuats(int cubit, int numLayers)
     {
+    if( mQuats==null ) initializeQuats();
     int status = retCubitSolvedStatus(cubit,numLayers);
-    return status<0 ? null : buildSolvedQuats(MovementUltimate.FACE_AXIS[status],QUATS);
+    return status<0 ? null : buildSolvedQuats(MovementUltimate.FACE_AXIS[status],mQuats);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -270,33 +138,101 @@ class TwistyUltimate extends TwistyObject
 
     if( variant==0 )
       {
+      double[][] vertices = new double[][]
+         {
+           { 0.0       ,  0.0      , 0.0       },
+           { -0.5*E    , 0.5*E+0.25, -0.25     },
+           {-0.25      , -E/2      , (-2*E-1)/4},
+           { 0.5*E+0.25, 0.25      , -E/2      },
+           { 0.0       , 0.5       , -E-0.5    },
+           { 0.0       , 0.5       , 0.0       },
+           { -0.5*E    ,-0.5*E+0.25, -0.25     },
+           {  0.5*E    ,-0.5*E+0.25, -0.25     }
+         };
+      int[][] vert_indices = new int[][]
+         {
+           {6,0,5,1},
+           {0,7,3,5},
+           {0,6,2,7},
+           {4,3,5,1},
+           {4,2,7,3},
+           {4,1,6,2},
+         };
+
       float[][] bands     = new float[][] { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
       int[] bandIndices   = new int[] { 0,0,0,1,1,1 };
       float[][] corners   = new float[][] {  { 0.013f, 0.08f } };
       int[] cornerIndices = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 };
       float[][] centers   = new float[][] { { 0.0f,-0.5f, -(SQ5+3)/4 } };
       int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
-      return new ObjectShape(VERTICES_SMALL_RIGHT,VERT_INDEXES_SMALL_RIGHT,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
+      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
       }
     else if( variant==1 )
       {
+      double[][] vertices = new double[][]
+         {
+            {         0.000,         0.000,         0.000},
+            {       - 0.250,-SQ5/8 - 0.125,-SQ5/8 - 0.375},
+            { SQ5/8 + 0.125,-SQ5/8 - 0.375,       + 0.250},
+            { SQ5/8 + 0.375,       + 0.250,-SQ5/8 - 0.125},
+            { SQ5/4 + 0.250,-SQ5/4 - 0.250,-SQ5/4 - 0.250},
+            { SQ5/8 - 0.125,       + 0.250,-SQ5/8 - 0.125},
+            {       - 0.250,-SQ5/8 - 0.125,-SQ5/8 + 0.125},
+            { SQ5/8 + 0.125,-SQ5/8 + 0.125,       + 0.250}
+         };
+      int[][] vert_indices  = new int[][]
+         {
+           {6,0,5,1},
+           {0,7,3,5},
+           {0,6,2,7},
+           {1,5,3,4},
+           {3,7,2,4},
+           {2,6,1,4},
+         };
+
       float[][] bands     = new float[][] { {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
       int[] bandIndices   = new int[] { 0,0,0,1,1,1 };
       float[][] corners   = new float[][] {  { 0.013f, 0.08f } };
       int[] cornerIndices = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 };
       float[][] centers   = new float[][] { { 0.0f,-0.5f, -(SQ5+3)/4 } };
       int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 };
-      return new ObjectShape(VERTICES_SMALL_LEFT,VERT_INDEXES_SMALL_LEFT,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
+      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
       }
     else
       {
+      double[][] vertices = new double[][]
+         {
+           {-E/2     ,-E/2+0.25,     0.25},
+           { E/2     , E/2-0.25,    -0.25},
+           {-E       ,     0.00,     0.00},
+           {     0.25, E/2     ,-E/2-0.25},
+           {-E/2     ,-E/2-0.25,     0.25},
+           { E/2+0.25,    -0.25,-E/2     },
+           {-E       ,    -0.50,     0.00},
+           {     0.50,     0.00,-E       },
+           {-E  +0.25, E/2     ,-E/2-0.25},
+           {     0.25,-E/2-0.50,-E/2+0.25},
+           {-E/2     ,-E/2-0.25,-E  -0.25}
+         };
+      int[][] vert_indices = new int[][]
+         {
+           {0,1,3,8,2},   // counterclockwise!
+           {0,4,9,5,1},
+           { 0,2,6,4},
+           { 1,5,7,3},
+           {10,9,4,6},
+           {10,9,5,7},
+           {10,8,3,7},
+           {10,8,2,6}
+         };
+
       float[][] bands     = new float[][] { {0.04f,17,0.5f,0.2f,5,2,2}, {0.03f,17,0.5f,0.2f,5,2,2}, {0.01f, 1,0.5f,0.2f,5,2,2} };
       int[] bandIndices   = new int[] { 0,0,1,1,2,2,2,2 };
       float[][] corners   = new float[][] { { 0.013f, 0.08f } };
       int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0,0,0,-1 };
       float[][] centers   = new float[][] { { -(SQ5+1)/8, 0.25f, -(SQ5+5)/8 } };
       int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0,0,0,0 };
-      return new ObjectShape(VERTICES_BIG,VERT_INDEXES_BIG,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
+      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
       }
     }
 
@@ -304,7 +240,9 @@ class TwistyUltimate extends TwistyObject
 
   Static4D getQuat(int cubit, int numLayers)
     {
-    return QUATS[QUAT_INDEX[cubit]];
+    if( mQuats     ==null ) initializeQuats();
+    if( mQuatIndex ==null ) mQuatIndex = new int[] { 0,6,1,2,0,4,6,5,0,1,4,9,5,2 };
+    return mQuats[mQuatIndex[cubit]];
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -325,13 +263,59 @@ class TwistyUltimate extends TwistyObject
 
   float[][] getCubitPositions(int numLayers)
     {
-    return CENTERS;
+    if( mCenters==null )
+      {
+      mCenters = new float[][]
+         {
+           { 0.0f,-0.5f,    G },
+           {    E,   -E,   -E },
+           {   -G, 0.0f,-0.5f },
+           { 0.5f,    G, 0.0f },
+
+           {   -E,    E,    E },
+           {    G, 0.0f, 0.5f },
+           {-0.5f,   -G, 0.0f },
+           { 0.0f, 0.5f,   -G },
+
+           {        E/2, (E+0.5f)/2,    (E+G)/2 },
+           {   -(E+G)/2,       -E/2, (E+0.5f)/2 },
+           { (E+0.5f)/2,   -(E+G)/2,        E/2 },
+           {       -E/2,-(E+0.5f)/2,   -(E+G)/2 },
+           {    (E+G)/2,        E/2,-(E+0.5f)/2 },
+           {-(E+0.5f)/2,    (E+G)/2,       -E/2 }
+         };
+      }
+
+    return mCenters;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   int getFaceColor(int cubit, int cubitface, int size)
     {
+    if( mFaceMap==null )
+      {
+      mFaceMap = new int[][]
+         {
+           { 25,24,35, 36,36,36,36,36 },
+           { 27,28,29, 36,36,36,36,36 },
+           { 31,26,30, 36,36,36,36,36 },
+           { 32,34,33, 36,36,36,36,36 },
+
+           { 31,32,25, 36,36,36,36,36 },
+           { 33,28,24, 36,36,36,36,36 },
+           { 26,35,27, 36,36,36,36,36 },
+           { 30,29,34, 36,36,36,36,36 },
+
+           {  8, 0,13,21, 36,36,36,36 },
+           {  1, 2,19,23, 36,36,36,36 },
+           {  4,11,12,15, 36,36,36,36 },
+           {  3, 6,14,17, 36,36,36,36 },
+           {  5, 9,22,16, 36,36,36,36 },
+           {  7,10,20,18, 36,36,36,36 }
+         };
+      }
+
     return mFaceMap[cubit][cubitface];
     }
 
@@ -346,6 +330,29 @@ class TwistyUltimate extends TwistyObject
 
   ObjectSticker retSticker(int face)
     {
+    if( mStickers==null )
+      {
+      float[][] STICKERS = new float[][]
+         {
+           { -0.14400357f, -0.47894150f, 0.50000000f,-0.011045523f, 0.37700626f, 0.36749030f,-0.26699730f, 0.36749026f, -0.46600536f, -0.24499352f }, // Big cubit 1st
+           {  0.36327127f,  0.26393202f,-0.36327127f, 0.500000000f,-0.36327127f,-0.26393202f, 0.36327127f,-0.50000000f },                             // Big cubit 2nd
+           { -0.29389262f, -0.50000000f, 0.29389262f,-0.309017000f, 0.29389262f, 0.30901700f,-0.29389262f, 0.50000000f },                             // Small cubit 1st
+         };
+
+      final float R1 = 0.08f;
+      final float R2 = 0.13f;
+      final float R3 = 0.11f;
+      final float[][] radii  = { {R1,R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3} };
+      final float[] strokes = { 0.07f, 0.09f, 0.08f };
+
+      mStickers = new ObjectSticker[STICKERS.length];
+
+      for(int s=0; s<STICKERS.length; s++)
+        {
+        mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
+        }
+      }
+
     return mStickers[face/NUM_FACES];
     }
 
@@ -360,7 +367,8 @@ class TwistyUltimate extends TwistyObject
 
   Static4D[] getQuats()
     {
-    return QUATS;
+    if( mQuats==null ) initializeQuats();
+    return mQuats;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -396,7 +404,7 @@ class TwistyUltimate extends TwistyObject
 
   int getNumStickerTypes(int numLayers)
     {
-    return STICKERS.length;
+    return 3;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -473,7 +481,8 @@ class TwistyUltimate extends TwistyObject
 
   public int[] getBasicAngle()
     {
-    return BASIC_ANGLE;
+    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
+    return mBasicAngle;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
