commit 48fec01e589e0ae5384e88c2f1dc7c0792d6cac9
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Sep 7 00:48:31 2021 +0200

    Remove statics from the Pyraminx class.

diff --git a/src/main/java/org/distorted/objects/TwistyJing.java b/src/main/java/org/distorted/objects/TwistyJing.java
index 497a9648..70e90fb1 100644
--- a/src/main/java/org/distorted/objects/TwistyJing.java
+++ b/src/main/java/org/distorted/objects/TwistyJing.java
@@ -190,7 +190,7 @@ public class TwistyJing extends TwistyObject
 
   float getScreenRatio()
     {
-    return 2*TwistyPyraminx.SCREEN_RATIO;
+    return 1.76f;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/objects/TwistyPyraminx.java b/src/main/java/org/distorted/objects/TwistyPyraminx.java
index 825fe8f6..3b74cdc1 100644
--- a/src/main/java/org/distorted/objects/TwistyPyraminx.java
+++ b/src/main/java/org/distorted/objects/TwistyPyraminx.java
@@ -37,8 +37,6 @@ import java.util.Random;
 
 public class TwistyPyraminx extends TwistyObject
 {
-  static final float SCREEN_RATIO = 0.88f;
-
   static final Static3D[] ROT_AXIS = new Static3D[]
          {
            new Static3D(     0,-SQ3/3,-SQ6/3),
@@ -47,90 +45,20 @@ public class TwistyPyraminx extends TwistyObject
            new Static3D(-SQ6/3,+SQ3/3,     0),
          };
 
-  private static final int[] BASIC_ANGLE = new int[] { 3,3,3,3 };
-
   private static final int[] FACE_COLORS = new int[]
          {
            COLOR_GREEN , COLOR_YELLOW,
            COLOR_BLUE  , COLOR_RED
          };
 
-  // computed with res/raw/compute_quats.c
-  private static final Static4D[] QUATS = new Static4D[]
-         {
-           new Static4D(  0.0f,   0.0f,   0.0f,  1.0f),
-           new Static4D(  0.0f,   1.0f,   0.0f,  0.0f),
-           new Static4D( SQ2/2,   0.5f,   0.0f,  0.5f),
-           new Static4D(-SQ2/2,   0.5f,   0.0f,  0.5f),
-           new Static4D(  0.0f,  -0.5f, -SQ2/2,  0.5f),
-           new Static4D(  0.0f,  -0.5f,  SQ2/2,  0.5f),
-           new Static4D( SQ2/2,   0.5f,   0.0f, -0.5f),
-           new Static4D(-SQ2/2,   0.5f,   0.0f, -0.5f),
-           new Static4D(  0.0f,  -0.5f, -SQ2/2, -0.5f),
-           new Static4D(  0.0f,  -0.5f,  SQ2/2, -0.5f),
-           new Static4D( SQ2/2,   0.0f,  SQ2/2,  0.0f),
-           new Static4D(-SQ2/2,   0.0f,  SQ2/2,  0.0f)
-         };
-
-  private static final double[][] VERTICES_TETRA = new double[][]
-          {
-             {-0.5, SQ2/4, 0.0},
-             { 0.5, SQ2/4, 0.0},
-             { 0.0,-SQ2/4, 0.5},
-             { 0.0,-SQ2/4,-0.5}
-          };
-
-  private static final int[][] VERT_INDEXES_TETRA = new int[][]
-          {
-             {2,1,0},   // counterclockwise!
-             {3,0,1},
-             {3,2,0},
-             {2,3,1}
-          };
-
-  private static final double[][] VERTICES_OCTA = new double[][]
-          {
-             { 0.5,   0.0, 0.5},
-             { 0.5,   0.0,-0.5},
-             {-0.5,   0.0,-0.5},
-             {-0.5,   0.0, 0.5},
-             { 0.0, SQ2/2, 0.0},
-             { 0.0,-SQ2/2, 0.0}
-          };
-
-  private static final int[][] VERT_INDEXES_OCTA = new int[][]
-          {
-             {3,0,4},   // counterclockwise!
-             {0,1,4},
-             {1,2,4},
-             {2,3,4},
-             {5,0,3},
-             {5,1,0},
-             {5,2,1},
-             {5,3,2}
-          };
-
-  private static final float[][] STICKERS = new float[][]
-          {
-             { -0.4330127f, -0.25f, 0.4330127f, -0.25f, 0.0f, 0.5f }
-          };
-
-  private static final ObjectSticker[] mStickers;
-
-  static
-    {
-    mStickers = new ObjectSticker[STICKERS.length];
-    final float stroke = 0.08f;
-    final float radius = 0.06f;
-    final float[] radii= {radius,radius,radius};
-    mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
-    }
-
   private int mCurrState;
   private int mIndexExcluded;
   private ScrambleState[] mStates;
   private int[][] mScrambleTable;
   private int[] mNumOccurences;
+  private int[] mBasicAngle;
+  private Static4D[] mQuats;
+  private ObjectSticker[] mStickers;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -142,6 +70,27 @@ public class TwistyPyraminx extends TwistyObject
     initializeScrambleStates(size);
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void initializeQuats()
+    {
+    mQuats = new Static4D[]
+         {
+         new Static4D(  0.0f,   0.0f,   0.0f,  1.0f),
+         new Static4D(  0.0f,   1.0f,   0.0f,  0.0f),
+         new Static4D( SQ2/2,   0.5f,   0.0f,  0.5f),
+         new Static4D(-SQ2/2,   0.5f,   0.0f,  0.5f),
+         new Static4D(  0.0f,  -0.5f, -SQ2/2,  0.5f),
+         new Static4D(  0.0f,  -0.5f,  SQ2/2,  0.5f),
+         new Static4D( SQ2/2,   0.5f,   0.0f, -0.5f),
+         new Static4D(-SQ2/2,   0.5f,   0.0f, -0.5f),
+         new Static4D(  0.0f,  -0.5f, -SQ2/2, -0.5f),
+         new Static4D(  0.0f,  -0.5f,  SQ2/2, -0.5f),
+         new Static4D( SQ2/2,   0.0f,  SQ2/2,  0.0f),
+         new Static4D(-SQ2/2,   0.0f,  SQ2/2,  0.0f)
+         };
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private int[][] generateState(int start, int end)
@@ -182,8 +131,9 @@ public class TwistyPyraminx extends TwistyObject
 
   int[] getSolvedQuats(int cubit, int numLayers)
     {
+    if( mQuats==null ) initializeQuats();
     int status = retCubitSolvedStatus(cubit,numLayers);
-    return status<0 ? null : buildSolvedQuats(MovementPyraminx.FACE_AXIS[status],QUATS);
+    return status<0 ? null : buildSolvedQuats(MovementPyraminx.FACE_AXIS[status],mQuats);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -242,7 +192,8 @@ public class TwistyPyraminx extends TwistyObject
 
   Static4D[] getQuats()
     {
-    return QUATS;
+    if( mQuats==null ) initializeQuats();
+    return mQuats;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -263,7 +214,7 @@ public class TwistyPyraminx extends TwistyObject
 
   int getNumStickerTypes(int numLayers)
     {
-    return STICKERS.length;
+    return 1;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -295,7 +246,7 @@ public class TwistyPyraminx extends TwistyObject
 
   float getScreenRatio()
     {
-    return SCREEN_RATIO;
+    return 0.88f;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -348,6 +299,8 @@ public class TwistyPyraminx extends TwistyObject
 
     if( variant==0 )
       {
+      double[][] vertices = new double[][] { { 0.5,0.0,0.5},{ 0.5,0.0,-0.5},{-0.5,0.0,-0.5},{-0.5,0.0,0.5},{ 0.0,SQ2/2,0.0},{ 0.0,-SQ2/2,0.0} };
+      int[][] vert_indices = new int[][] { {3,0,4},{0,1,4},{1,2,4},{2,3,4},{5,0,3},{5,1,0},{5,2,1},{5,3,2} };
       int N = numLayers==3? 6 : 5;
       int E = numLayers==3? 2 : 1;
       float[][] bands     = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} };
@@ -356,10 +309,12 @@ public class TwistyPyraminx extends TwistyObject
       int[] cornerIndices = new int[] { 0,0,0,0,0,0 };
       float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
       int[] centerIndices = new int[] { 0,0,0,0,0,0 };
-      return new ObjectShape(VERTICES_OCTA,VERT_INDEXES_OCTA,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[][] { {-0.5, SQ2/4, 0.0},{ 0.5, SQ2/4, 0.0},{ 0.0,-SQ2/4, 0.5},{ 0.0,-SQ2/4,-0.5} };
+      int[][] vert_indices = new int[][] { {2,1,0},{3,0,1},{3,2,0},{2,3,1} };
       int N = numLayers==3? 6 : 5;
       int E = numLayers==3? 2 : 1;
       float[][] bands     = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} };
@@ -368,7 +323,7 @@ public class TwistyPyraminx extends TwistyObject
       int[] cornerIndices = new int[] { 0,0,0,0 };
       float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
       int[] centerIndices = new int[] { 0,0,0,0 };
-      return new ObjectShape(VERTICES_TETRA,VERT_INDEXES_TETRA,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
+      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
       }
     }
 
@@ -376,7 +331,8 @@ public class TwistyPyraminx extends TwistyObject
 
   Static4D getQuat(int cubit, int numLayers)
     {
-    return QUATS[0];
+    if( mQuats==null ) initializeQuats();
+    return mQuats[0];
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -404,6 +360,16 @@ public class TwistyPyraminx extends TwistyObject
 
   ObjectSticker retSticker(int face)
     {
+    if( mStickers==null )
+      {
+      float[][] STICKERS = new float[][] { { -0.4330127f, -0.25f, 0.4330127f, -0.25f, 0.0f, 0.5f } };
+      final float stroke = 0.08f;
+      final float radius = 0.06f;
+      final float[] radii= {radius,radius,radius};
+      mStickers = new ObjectSticker[STICKERS.length];
+      mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
+      }
+
     return mStickers[face/NUM_FACES];
     }
 
@@ -475,7 +441,8 @@ public class TwistyPyraminx extends TwistyObject
 
   public int[] getBasicAngle()
     {
-    return BASIC_ANGLE;
+    if( mBasicAngle ==null ) mBasicAngle = new int[] { 3,3,3,3 };
+    return mBasicAngle;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
