commit e01fa67a07c171c42c1a3d4742db9c9d616ffa38
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Sep 6 23:20:10 2021 +0200

    Remove statics from the Ivy class.

diff --git a/src/main/java/org/distorted/objects/TwistyIvy.java b/src/main/java/org/distorted/objects/TwistyIvy.java
index afeebf0a..b06f2dac 100644
--- a/src/main/java/org/distorted/objects/TwistyIvy.java
+++ b/src/main/java/org/distorted/objects/TwistyIvy.java
@@ -37,11 +37,6 @@ import java.util.Random;
 
 public class TwistyIvy extends TwistyObject
 {
-  public static final float IVY_D = 0.003f;
-  private static final int  IVY_N = 8;
-
-  private static final int FACES_PER_CUBIT =6;
-
   // the four rotation axis of a RubikIvy. Must be normalized.
   static final Static3D[] ROT_AXIS = new Static3D[]
          {
@@ -51,8 +46,6 @@ public class TwistyIvy extends TwistyObject
            new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
          };
 
-  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
-
   private static final int[] FACE_COLORS = new int[]
          {
            COLOR_YELLOW, COLOR_WHITE,
@@ -60,68 +53,20 @@ public class TwistyIvy extends TwistyObject
            COLOR_RED   , COLOR_ORANGE
          };
 
-  // All legal rotation quats of a RubikIvy
-  private static final Static4D[] QUATS = new Static4D[]
-         {
-           new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
-           new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
-           new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
-           new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
-
-           new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
-           new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
-           new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
-           new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
-           new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
-           new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
-           new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
-           new Static4D(  0.5f, -0.5f, -0.5f, -0.5f )
-         };
-
-  private static final int[][] mFaceMap =
-         {
-           {  4, 0, 2, 12,12,12 },
-           {  5, 1, 2, 12,12,12 },
-           {  4, 1, 3, 12,12,12 },
-           {  5, 0, 3, 12,12,12 },
-
-           {  6, 12,12,12,12,12 },
-           {  7, 12,12,12,12,12 },
-           {  8, 12,12,12,12,12 },
-           {  9, 12,12,12,12,12 },
-           { 10, 12,12,12,12,12 },
-           { 11, 12,12,12,12,12 },
-         };
-
-  private static final ObjectSticker[] mStickers;
-
-  private static final float[][] STICKERS = new float[][]
-          {
-             { 0.29258922f, -0.5f, 0.29258922f, 0.29258922f, -0.5f, 0.29258922f },
-             { -0.5f, 0.5f, 0.5f, -0.5f }
-          };
-  private static final int NUM_STICKERS = STICKERS.length;
-
-  static
-    {
-    mStickers = new ObjectSticker[NUM_STICKERS];
-
-    float D = (float)(Math.PI/4);
-    final float[][] angles = { { 0,0,D },{ D,D } };
-    final float[][] radii  = { { 0,0.04f,0 },{ 0.06f,0.06f } };
-    final float[] strokes = { 0.03f, 0.08f };
-
-    for(int s=0; s<NUM_STICKERS; s++)
-      {
-      mStickers[s] = new ObjectSticker(STICKERS[s], angles[s],radii[s],strokes[s]);
-      }
-    }
+  private static final int NUM_STICKERS = 2;
+  public static final float IVY_D = 0.003f;
+  private static final int  IVY_N = 8;
+  private static final int FACES_PER_CUBIT =6;
 
   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 ObjectSticker[] mStickers;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -138,12 +83,35 @@ public class TwistyIvy extends TwistyObject
       };
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void initializeQuats()
+    {
+    mQuats = new Static4D[]
+         {
+         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
+         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
+         new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
+         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
+
+         new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
+         new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
+         new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
+         new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
+         new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
+         new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
+         new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
+         new Static4D(  0.5f, -0.5f, -0.5f, -0.5f )
+         };
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   int[] getSolvedQuats(int cubit, int numLayers)
     {
+    if( mQuats==null ) initializeQuats();
     int status = retCubitSolvedStatus(cubit,numLayers);
-    return status<0 ? null : buildSolvedQuats(MovementIvy.FACE_AXIS[status],QUATS);
+    return status<0 ? null : buildSolvedQuats(MovementIvy.FACE_AXIS[status],mQuats);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -157,7 +125,8 @@ public class TwistyIvy extends TwistyObject
 
   Static4D[] getQuats()
     {
-    return QUATS;
+    if( mQuats==null ) initializeQuats();
+    return mQuats;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -387,22 +356,24 @@ public class TwistyIvy extends TwistyObject
 
   Static4D getQuat(int cubit, int numLayers)
     {
+    if( mQuats==null ) initializeQuats();
+
     switch(cubit)
       {
-      case  0: return QUATS[0];
-      case  1: return QUATS[2];
-      case  2: return QUATS[3];
-      case  3: return QUATS[1];
-
-      case  4: return QUATS[8];
-      case  5: return QUATS[11];
-      case  6: return QUATS[10];
-      case  7: return QUATS[9];
-      case  8: return QUATS[0];
-      case  9: return QUATS[2];
+      case  0: return mQuats[0];
+      case  1: return mQuats[2];
+      case  2: return mQuats[3];
+      case  3: return mQuats[1];
+
+      case  4: return mQuats[8];
+      case  5: return mQuats[11];
+      case  6: return mQuats[10];
+      case  7: return mQuats[9];
+      case  8: return mQuats[0];
+      case  9: return mQuats[2];
       }
 
-    return QUATS[0];
+    return mQuats[0];
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -423,6 +394,24 @@ public class TwistyIvy extends TwistyObject
 
   int getFaceColor(int cubit, int cubitface, int numLayers)
     {
+    if( mFaceMap==null )
+      {
+      mFaceMap = new int[][]
+         {
+           {  4, 0, 2, 12,12,12 },
+           {  5, 1, 2, 12,12,12 },
+           {  4, 1, 3, 12,12,12 },
+           {  5, 0, 3, 12,12,12 },
+
+           {  6, 12,12,12,12,12 },
+           {  7, 12,12,12,12,12 },
+           {  8, 12,12,12,12,12 },
+           {  9, 12,12,12,12,12 },
+           { 10, 12,12,12,12,12 },
+           { 11, 12,12,12,12,12 },
+         };
+      }
+
     return mFaceMap[cubit][cubitface];
     }
 
@@ -437,6 +426,17 @@ public class TwistyIvy extends TwistyObject
 
   ObjectSticker retSticker(int face)
     {
+    if( mStickers==null )
+      {
+      float[][] STICKERS = new float[][] { { 0.29258922f, -0.5f, 0.29258922f, 0.29258922f, -0.5f, 0.29258922f }, { -0.5f, 0.5f, 0.5f, -0.5f } };
+      mStickers = new ObjectSticker[NUM_STICKERS];
+      float D = (float)(Math.PI/4);
+      final float[][] angles = { { 0,0,D },{ D,D } };
+      final float[][] radii  = { { 0,0.04f,0 },{ 0.06f,0.06f } };
+      final float[] strokes = { 0.03f, 0.08f };
+      for(int s=0; s<NUM_STICKERS; s++) mStickers[s] = new ObjectSticker(STICKERS[s], angles[s],radii[s],strokes[s]);
+      }
+
     return mStickers[face/NUM_FACES];
     }
 
@@ -507,7 +507,8 @@ public class TwistyIvy extends TwistyObject
 
   public int[] getBasicAngle()
     {
-    return BASIC_ANGLE;
+    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
+    return mBasicAngle;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
