commit 45f63f178fb16079dd157f5d9da139ae33754a4b
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Thu Aug 19 22:44:27 2021 +0200

    Introduce ObjectShape - a class encapsulating a shape of a Cubit.
    Make the Megaminx cubit creation a bit more standard.

diff --git a/src/main/java/org/distorted/helpers/ObjectShape.java b/src/main/java/org/distorted/helpers/ObjectShape.java
new file mode 100644
index 00000000..6aa14515
--- /dev/null
+++ b/src/main/java/org/distorted/helpers/ObjectShape.java
@@ -0,0 +1,124 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2021 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Magic Cube.                                                              //
+//                                                                                               //
+// Magic Cube is free software: you can redistribute it and/or modify                            //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Magic Cube is distributed in the hope that it will be useful,                                 //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.helpers;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public class ObjectShape
+  {
+  private final double[][] mVertices;
+  private final int[][] mVertIndices;
+  private final float[][] mBands;
+  private final int[][] mBandIndices;
+  private final float[][] mCorners;
+  private final int[][] mCornerIndices;
+  private final float[][] mCenters;
+  private final int[][] mCenterIndices;
+  private final int mNumComponents;
+  private final float[] mConvexityCenter;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public ObjectShape(double[][] vertices, int[][] vertIndices, float[][] bands, int[][] bandIndices,
+                     float[][] corners, int[][] cornIndices, float[][] centers, int[][] centIndices,
+                     int numComponents, float[] convexityCenter)
+    {
+    mVertices        = vertices;
+    mVertIndices     = vertIndices;
+    mBands           = bands;
+    mBandIndices     = bandIndices;
+    mCorners         = corners;
+    mCornerIndices   = cornIndices;
+    mCenters         = centers;
+    mCenterIndices   = centIndices;
+    mNumComponents   = numComponents;
+    mConvexityCenter = convexityCenter;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public double[][] getVertices()
+    {
+    return mVertices;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int[][] getVertIndices()
+    {
+    return mVertIndices;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public float[][] getBands()
+    {
+    return mBands;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int[][] getBandIndices()
+    {
+    return mBandIndices;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public float[][] getCorners()
+    {
+    return mCorners;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int[][] getCornerIndices()
+    {
+    return mCornerIndices;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public float[][] getCenters()
+    {
+    return mCenters;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int[][] getCenterIndices()
+    {
+    return mCenterIndices;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int getNumComponents()
+    {
+    return mNumComponents;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public float[] getConvexityCenter()
+    {
+    return mConvexityCenter;
+    }
+  }
diff --git a/src/main/java/org/distorted/objects/TwistyMegaminx.java b/src/main/java/org/distorted/objects/TwistyMegaminx.java
index 83908535..fe67e9d9 100644
--- a/src/main/java/org/distorted/objects/TwistyMegaminx.java
+++ b/src/main/java/org/distorted/objects/TwistyMegaminx.java
@@ -44,8 +44,7 @@ public class TwistyMegaminx extends TwistyMinx
         16, 18, 22,  1, 20, 13, 14, 15,  0, 12,  2,  3
       };
 
-  private static MeshBase[] mCenterMeshes, mCornerMeshes;
-  private static MeshBase[][] mEdgeMeshes;
+  private static MeshBase[][] mMeshes;
 
   private static final float[][] STICKERS = new float[][]
       {
@@ -415,44 +414,42 @@ public class TwistyMegaminx extends TwistyMinx
     int index = (numLayers-3)/2;
     int[] sizes = ObjectList.MEGA.getSizes();
     int variants = sizes.length;
+    int numShapes = 2+(sizes[variants-1]-1)/2;
     MeshBase mesh;
 
-    if( mCornerMeshes==null ) mCornerMeshes = new MeshBase[variants];
-    if( mEdgeMeshes  ==null ) mEdgeMeshes   = new MeshBase[variants][(sizes[variants-1]-1)/2];
-    if( mCenterMeshes==null ) mCenterMeshes = new MeshBase[variants];
+    if( mMeshes==null ) mMeshes = new MeshBase[variants][numShapes];
 
     if( cubit < NUM_CORNERS*numCubitsPerCorner )
       {
-      if( mCornerMeshes[index]==null )
+      if( mMeshes[index][0]==null )
         {
         float width = (numLayers/3.0f)*(0.5f-MEGA_D)/(0.5f*(numLayers-1));
-        mCornerMeshes[index] = createCornerMesh(numLayers, width);
+        mMeshes[index][0] = createCornerMesh(numLayers, width);
         }
-      mesh = mCornerMeshes[index].copy(true);
+      mesh = mMeshes[index][0].copy(true);
       }
     else if( cubit<NUM_CORNERS*numCubitsPerCorner + NUM_EDGES*numCubitsPerEdge )
       {
       int type = computeEdgeType(cubit,numCubitsPerCorner,numCubitsPerEdge);
 
-      if( mEdgeMeshes[index][type]==null )
+      if( mMeshes[index][1+type]==null )
         {
         float height= (numLayers/3.0f)*(0.5f-MEGA_D)*COS18/((numLayers-1)*0.5f);
         float width = (numLayers/3.0f)*2*MEGA_D + 2*type*height*SIN18/COS18;
 
-        mEdgeMeshes[index][type] = createEdgeMesh(numLayers,width,height);
+        mMeshes[index][1+type] = createEdgeMesh(numLayers,width,height);
         }
-
-      mesh = mEdgeMeshes[index][type].copy(true);
+      mesh = mMeshes[index][1+type].copy(true);
       }
     else
       {
-      if( mCenterMeshes[index]==null )
+      if( mMeshes[index][numShapes-1]==null )
         {
         float width = 2 * (numLayers/3.0f) * (MEGA_D+(0.5f-MEGA_D)*SIN18);
-        mCenterMeshes[index] = createCenterMesh(numLayers,width);
+        mMeshes[index][numShapes-1] = createCenterMesh(numLayers,width);
         }
 
-      mesh = mCenterMeshes[index].copy(true);
+      mesh = mMeshes[index][numShapes-1].copy(true);
       }
 
     Static4D q = QUATS[getQuat(cubit,numCubitsPerCorner,numCubitsPerEdge)];
