commit a135652b7a429f199e4144cfcfa128248afb4a8e
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Oct 12 11:40:23 2021 +0200

    Improve cuboids: single-layer cuboids should work. 1x1x1 does!

diff --git a/src/main/java/org/distorted/objectlib/main/Movement.java b/src/main/java/org/distorted/objectlib/main/Movement.java
index e7d7bab0..22cbf81c 100644
--- a/src/main/java/org/distorted/objectlib/main/Movement.java
+++ b/src/main/java/org/distorted/objectlib/main/Movement.java
@@ -270,6 +270,8 @@ public abstract class Movement
 
   private float[] computeBorder(float[] cuts, boolean[] rotatable, int size)
     {
+    if( cuts==null ) return null;
+
     int len = cuts.length;
     float[] border = new float[len];
 
@@ -382,6 +384,9 @@ public abstract class Movement
   private int computeRowFromOffset(int face, int axisIndex, float offset)
     {
     float[] borders = mTouchBorders[axisIndex];
+
+    if( borders==null ) return 0;
+
     int len = borders.length;
     float A = mA[face][axisIndex];
 
diff --git a/src/main/java/org/distorted/objectlib/main/ObjectType.java b/src/main/java/org/distorted/objectlib/main/ObjectType.java
index 2983896b..bed283b0 100644
--- a/src/main/java/org/distorted/objectlib/main/ObjectType.java
+++ b/src/main/java/org/distorted/objectlib/main/ObjectType.java
@@ -69,6 +69,9 @@ public enum ObjectType
 
   CU_223 ( new int[] {2,3,2}      , 16, R.drawable.s_cube_2, R.drawable.m_cube_2, R.drawable.b_cube_2, R.drawable.h_cube_2),
   CU_334 ( new int[] {3,4,3}      , 20, R.drawable.s_cube_3, R.drawable.m_cube_3, R.drawable.b_cube_3, R.drawable.h_cube_3),
+  CU_122 ( new int[] {1,2,2}      , 20, R.drawable.s_cube_3, R.drawable.m_cube_3, R.drawable.b_cube_3, R.drawable.h_cube_3),
+  CU_321 ( new int[] {3,2,1}      , 20, R.drawable.s_cube_3, R.drawable.m_cube_3, R.drawable.b_cube_3, R.drawable.h_cube_3),
+  CU_111 ( new int[] {1,1,1}      , 20, R.drawable.s_cube_3, R.drawable.m_cube_3, R.drawable.b_cube_3, R.drawable.h_cube_3),
   ;
 
   public static final int NUM_OBJECTS = values().length;
@@ -203,8 +206,10 @@ public enum ObjectType
       case 31: return new TwistyMirror        (numL, quat, move, texture, mesh, effects, res, scrWidth);
 
       case 32:
-      case 33: return new TwistyCube          (numL, quat, move, texture, mesh, effects, res, scrWidth);
-
+      case 33:
+      case 34:
+      case 35:
+      case 36: return new TwistyCube          (numL, quat, move, texture, mesh, effects, res, scrWidth);
       }
 
     return null;
diff --git a/src/main/java/org/distorted/objectlib/objects/TwistyCube.java b/src/main/java/org/distorted/objectlib/objects/TwistyCube.java
index c3e751f0..07b476a1 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistyCube.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistyCube.java
@@ -309,78 +309,82 @@ public class TwistyCube extends Twisty6
     final float lenY = 0.5f*(Y-1);
     final float lenZ = 0.5f*(Z-1);
 
-    if( X==1 || Y==1 || Z==1 )
+    int curPos = 0;
+
+    if( X==1 )
+      {
+      float[][] pos = new float[X*Y*Z][];
+
+      for(int y=0; y<Y; y++)
+        for(int z=0; z<Z; z++) pos[curPos++] = new float[] {+lenX,y-lenY,z-lenZ};
+
+      return pos;
+      }
+
+    if( Y==1 )
       {
-      int numCubits = X*Y*Z;
-      float[][] tmp = new float[numCubits][];
+      float[][] pos = new float[X*Y*Z][];
+
+      for(int x=0; x<X; x++)
+        for(int z=0; z<Z; z++) pos[curPos++] = new float[] {x-lenX,+lenY,z-lenZ};
+
+      return pos;
+      }
+
+    if( Z==1 )
+      {
+      float[][] pos = new float[X*Y*Z][];
+
+      for(int x=0; x<X; x++)
+        for(int y=0; y<Y; y++) pos[curPos++] = new float[] {x-lenX,y-lenY,+lenZ};
 
-      // TODO ...
+      return pos;
       }
 
     int numCubits = X*Y*Z - (X-2)*(Y-2)*(Z-2);
-    float[][] tmp = new float[numCubits][];
-
-    int currentPosition = 0;
-
-    tmp[currentPosition++] = new float[] {-lenX,-lenY,-lenZ};
-    tmp[currentPosition++] = new float[] {-lenX,-lenY,+lenZ};
-    tmp[currentPosition++] = new float[] {-lenX,+lenY,-lenZ};
-    tmp[currentPosition++] = new float[] {-lenX,+lenY,+lenZ};
-    tmp[currentPosition++] = new float[] {+lenX,-lenY,-lenZ};
-    tmp[currentPosition++] = new float[] {+lenX,-lenY,+lenZ};
-    tmp[currentPosition++] = new float[] {+lenX,+lenY,-lenZ};
-    tmp[currentPosition++] = new float[] {+lenX,+lenY,+lenZ};
-
-    for(int i=1; i<X-1; i++)
-      tmp[currentPosition++] = new float[] { i-lenX,  -lenY,  -lenZ };
-    for(int i=1; i<X-1; i++)
-      tmp[currentPosition++] = new float[] { i-lenX,  -lenY,  +lenZ };
-    for(int i=1; i<X-1; i++)
-      tmp[currentPosition++] = new float[] { i-lenX,  +lenY,  -lenZ };
-    for(int i=1; i<X-1; i++)
-      tmp[currentPosition++] = new float[] { i-lenX,  +lenY,  +lenZ };
-    for(int i=1; i<Y-1; i++)
-      tmp[currentPosition++] = new float[] {  -lenX, i-lenY,  -lenZ };
-    for(int i=1; i<Y-1; i++)
-      tmp[currentPosition++] = new float[] {  -lenX, i-lenY,  +lenZ };
-    for(int i=1; i<Y-1; i++)
-      tmp[currentPosition++] = new float[] {  +lenX, i-lenY,  -lenZ };
-    for(int i=1; i<Y-1; i++)
-      tmp[currentPosition++] = new float[] {  +lenX, i-lenY,  +lenZ };
-    for(int i=1; i<Z-1; i++)
-      tmp[currentPosition++] = new float[] {  -lenX,  -lenY, i-lenZ };
-    for(int i=1; i<Z-1; i++)
-      tmp[currentPosition++] = new float[] {  -lenX,  +lenY, i-lenZ };
-    for(int i=1; i<Z-1; i++)
-      tmp[currentPosition++] = new float[] {  +lenX,  -lenY, i-lenZ };
-    for(int i=1; i<Z-1; i++)
-      tmp[currentPosition++] = new float[] {  +lenX,  +lenY, i-lenZ };
+    float[][] pos = new float[numCubits][];
+
+    pos[curPos++] = new float[] {-lenX,-lenY,-lenZ};
+    pos[curPos++] = new float[] {-lenX,-lenY,+lenZ};
+    pos[curPos++] = new float[] {-lenX,+lenY,-lenZ};
+    pos[curPos++] = new float[] {-lenX,+lenY,+lenZ};
+    pos[curPos++] = new float[] {+lenX,-lenY,-lenZ};
+    pos[curPos++] = new float[] {+lenX,-lenY,+lenZ};
+    pos[curPos++] = new float[] {+lenX,+lenY,-lenZ};
+    pos[curPos++] = new float[] {+lenX,+lenY,+lenZ};
+
+    for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX,  -lenY,  -lenZ };
+    for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX,  -lenY,  +lenZ };
+    for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX,  +lenY,  -lenZ };
+    for(int i=1; i<X-1; i++) pos[curPos++] = new float[] { i-lenX,  +lenY,  +lenZ };
+    for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] {  -lenX, i-lenY,  -lenZ };
+    for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] {  -lenX, i-lenY,  +lenZ };
+    for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] {  +lenX, i-lenY,  -lenZ };
+    for(int i=1; i<Y-1; i++) pos[curPos++] = new float[] {  +lenX, i-lenY,  +lenZ };
+    for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] {  -lenX,  -lenY, i-lenZ };
+    for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] {  -lenX,  +lenY, i-lenZ };
+    for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] {  +lenX,  -lenY, i-lenZ };
+    for(int i=1; i<Z-1; i++) pos[curPos++] = new float[] {  +lenX,  +lenY, i-lenZ };
 
     for(int y=1; y<Y-1; y++)
-      for(int z=1; z<Z-1; z++)
-        tmp[currentPosition++] = new float[] {+lenX,y-lenY,z-lenZ};
+      for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {+lenX,y-lenY,z-lenZ};
 
     for(int y=1; y<Y-1; y++)
-      for(int z=1; z<Z-1; z++)
-        tmp[currentPosition++] = new float[] {-lenX,y-lenY,z-lenZ};
+      for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {-lenX,y-lenY,z-lenZ};
 
     for(int x=1; x<X-1; x++)
-      for(int z=1; z<Z-1; z++)
-        tmp[currentPosition++] = new float[] {x-lenX,+lenY,z-lenZ};
+      for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {x-lenX,+lenY,z-lenZ};
 
     for(int x=1; x<X-1; x++)
-      for(int z=1; z<Z-1; z++)
-        tmp[currentPosition++] = new float[] {x-lenX,-lenY,z-lenZ};
+      for(int z=1; z<Z-1; z++) pos[curPos++] = new float[] {x-lenX,-lenY,z-lenZ};
 
     for(int x=1; x<X-1; x++)
-      for(int y=1; y<Y-1; y++)
-        tmp[currentPosition++] = new float[] {x-lenX,y-lenY,+lenZ};
+      for(int y=1; y<Y-1; y++) pos[curPos++] = new float[] {x-lenX,y-lenY,+lenZ};
 
     for(int x=1; x<X-1; x++)
-      for(int y=1; y<Y-1; y++)
-        tmp[currentPosition++] = new float[] {x-lenX,y-lenY,-lenZ};
+      for(int y=1; y<Y-1; y++) pos[curPos++] = new float[] {x-lenX,y-lenY,-lenZ};
 
-    return tmp;
+    return pos;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
