commit acf165d970d69f268f5d60cf554eb2cbfd729dd6
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Aug 23 14:15:05 2021 +0200

    Convert the last object, Skewb Ultimate, to the new scheme.

diff --git a/src/main/java/org/distorted/objects/TwistyUltimate.java b/src/main/java/org/distorted/objects/TwistyUltimate.java
index d15010c7..cd9c2f8e 100644
--- a/src/main/java/org/distorted/objects/TwistyUltimate.java
+++ b/src/main/java/org/distorted/objects/TwistyUltimate.java
@@ -22,6 +22,7 @@ package org.distorted.objects;
 import android.content.res.Resources;
 
 import org.distorted.helpers.FactoryCubit;
+import org.distorted.helpers.ObjectShape;
 import org.distorted.helpers.ObjectSticker;
 import org.distorted.library.effect.MatrixEffectQuaternion;
 import org.distorted.library.main.DistortedEffects;
@@ -244,113 +245,97 @@ class TwistyUltimate extends TwistyObject
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  MeshBase createCubitMesh(int cubit, int numLayers)
+  ObjectShape getObjectShape(int cubit, int numLayers)
     {
-    if( mMeshes==null )
-      {
-      FactoryCubit factory = FactoryCubit.getInstance();
-      factory.clear();
-      mMeshes = new MeshBase[3];
-      }
+    int variant = getCubitVariant(cubit,numLayers);
 
-    MeshBase mesh;
-
-    if( cubit<4 )
+    if( variant==0 )
       {
-      if( mMeshes[0]==null )
-        {
-        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[] bandIndexes   = new int[] { 0,0,0,1,1,1 };
-        float[][] corners   = new float[][] {  { 0.013f, 0.08f } };
-        int[] cornerIndexes = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 };
-        float[][] centers   = new float[][] { { 0.0f,-0.5f, -(SQ5+3)/4 } };
-        int[] centerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
-
-        FactoryCubit factory = FactoryCubit.getInstance();
-        factory.createNewFaceTransform(VERTICES_SMALL_RIGHT,VERT_INDEXES_SMALL_RIGHT);
-        mMeshes[0] = factory.createRoundedSolid(VERTICES_SMALL_RIGHT, VERT_INDEXES_SMALL_RIGHT,
-                                                bands, bandIndexes,
-                                                corners, cornerIndexes,
-                                                centers, centerIndexes,
-                                                getNumCubitFaces(), null );
-        }
-      mesh = mMeshes[0].copy(true);
+      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);
       }
-    else if( cubit<8 )
+    else if( variant==1 )
       {
-      if( mMeshes[1]==null )
-        {
-        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[] bandIndexes   = new int[] { 0,0,0,1,1,1 };
-        float[][] corners   = new float[][] {  { 0.013f, 0.08f } };
-        int[] cornerIndexes = new int[] { 0, 0, 0, 0,-1, 0, 0, 0 };
-        float[][] centers   = new float[][] { { 0.0f,-0.5f, -(SQ5+3)/4 } };
-        int[] centerIndexes = new int[] { 0,0,0,0,0,0,0,0 };
-
-        FactoryCubit factory = FactoryCubit.getInstance();
-        factory.createNewFaceTransform(VERTICES_SMALL_LEFT,VERT_INDEXES_SMALL_LEFT);
-        mMeshes[1] = factory.createRoundedSolid(VERTICES_SMALL_LEFT, VERT_INDEXES_SMALL_LEFT,
-                                                bands, bandIndexes,
-                                                corners, cornerIndexes,
-                                                centers, centerIndexes,
-                                                getNumCubitFaces(), null );
-        }
-      mesh = mMeshes[1].copy(true);
+      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);
       }
     else
       {
-      if( mMeshes[2]==null )
-        {
-        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[] bandIndexes   = new int[] { 0,0,1,1,2,2,2,2 };
-        float[][] corners   = new float[][] { { 0.013f, 0.08f } };
-        int[] cornerIndexes = 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[] centerIndexes = new int[] { 0,0,0,0,0,0,0,0,0,0,0 };
-
-        FactoryCubit factory = FactoryCubit.getInstance();
-        factory.createNewFaceTransform(VERTICES_BIG,VERT_INDEXES_BIG);
-        mMeshes[2] = factory.createRoundedSolid(VERTICES_BIG, VERT_INDEXES_BIG,
-                                                bands, bandIndexes,
-                                                corners, cornerIndexes,
-                                                centers, centerIndexes,
-                                                getNumCubitFaces(), null );
-        }
-      mesh = mMeshes[2].copy(true);
+      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);
       }
+    }
 
-    Static4D q = QUATS[getQuatIndex(cubit)];
-    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( q, new Static3D(0,0,0) );
-    mesh.apply(quat,0xffffffff,0);
+///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    return mesh;
+  private Static4D getQuat(int cubit, int numLayers)
+    {
+    return QUATS[QUAT_INDEX[cubit]];
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  float[][] getCubitPositions(int numLayers)
+  private int getNumCubitVariants(int numLayers)
     {
-    return CENTERS;
+    return 3;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  int getCubitVariant(int cubit, int numLayers)
+    {
+    return cubit<4 ? 0 : (cubit<8 ? 1:2);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  private int getQuatIndex(int cubit)
+  MeshBase createCubitMesh(int cubit, int numLayers)
     {
-    return QUAT_INDEX[cubit];
+    int variant = getCubitVariant(cubit,numLayers);
+
+    if( mMeshes==null )
+      {
+      FactoryCubit factory = FactoryCubit.getInstance();
+      factory.clear();
+      mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
+      }
+
+    if( mMeshes[variant]==null )
+      {
+      ObjectShape shape = getObjectShape(cubit,numLayers);
+      FactoryCubit factory = FactoryCubit.getInstance();
+      factory.createNewFaceTransform(shape);
+      mMeshes[variant] = factory.createRoundedSolid(shape);
+      }
+
+    MeshBase mesh = mMeshes[variant].copy(true);
+    MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
+    mesh.apply(quat,0xffffffff,0);
+
+    return mesh;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  float[][] getCubitPositions(int numLayers)
+    {
+    return CENTERS;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
