commit 66cbdd21f0a4f0963a4e032b22924aeae2210030
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Mar 9 23:11:50 2020 +0000

    Some fixes for the Pyraminx.

diff --git a/src/main/java/org/distorted/object/Cubit.java b/src/main/java/org/distorted/object/Cubit.java
index 12ddf677..98062564 100644
--- a/src/main/java/org/distorted/object/Cubit.java
+++ b/src/main/java/org/distorted/object/Cubit.java
@@ -53,7 +53,7 @@ class Cubit
   DistortedNode mNode;
   DistortedEffects mEffect;
   Static4D mQuatScramble;
-  int[] mRotationRow;
+  float[] mRotationRow;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // Because of quatMultiplication, errors can accumulate - so to avoid this, we
@@ -169,7 +169,7 @@ class Cubit
       {
       axis = mParent.ROTATION_AXIS[i];
       tmp = x*axis.get0() + y*axis.get1() + z*axis.get2();
-      mRotationRow[i] = (int)( (tmp-mParent.mStart)/mParent.mStep + 0.5f );
+      mRotationRow[i] = (tmp-mParent.mStart)/mParent.mStep;
       }
     }
 
@@ -193,7 +193,7 @@ class Cubit
     mRotateEffect    = new MatrixEffectRotate(mRotationAngle, mRotationAxis, matrCenter);
 
     mNumAxis     = mParent.ROTATION_AXIS.length;
-    mRotationRow = new int[mNumAxis];
+    mRotationRow = new float[mNumAxis];
     computeRotationRow();
 
     mEffect = new DistortedEffects();
diff --git a/src/main/java/org/distorted/object/RubikObject.java b/src/main/java/org/distorted/object/RubikObject.java
index f4513b0f..fff5852e 100644
--- a/src/main/java/org/distorted/object/RubikObject.java
+++ b/src/main/java/org/distorted/object/RubikObject.java
@@ -136,7 +136,7 @@ public abstract class RubikObject extends DistortedNode
       {
       for(int i=0; i<numFaces; i++)
         {
-        belongs = belongsToRotation(cubit, i/2, i%2==0 ? mSize-1:0 );
+        belongs = isOnFace(cubit, i/2, i%2==0 ? mSize-1:0 );
         maps[i] = new Static4D( (belongs?i:6)*ratio, 0.0f, ratio, 1.0f);
         }
       }
@@ -144,7 +144,7 @@ public abstract class RubikObject extends DistortedNode
       {
       for(int i=0; i<numFaces; i++)
         {
-        belongs = belongsToRotation(cubit, i, 0 );
+        belongs = isOnFace(cubit, i, 0 );
         maps[i] = new Static4D( (belongs?i:6)*ratio, 0.0f, ratio, 1.0f);
         }
       }
@@ -185,7 +185,19 @@ public abstract class RubikObject extends DistortedNode
 
   private boolean belongsToRotation( int cubit, int axis, int row)
     {
-    return mCubits[cubit].mRotationRow[axis]==row;
+    return ((int)(mCubits[cubit].mRotationRow[axis]+0.5f))==row;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// we cannot use belongsToRotation for deciding if to texture a face. Counterexample: the 'rotated'
+// tetrahedrons of Pyraminx nearby the edge: they belong to rotation but their face which is rotated
+// away from the face of the Pyraminx shouldn't be textured.
+
+  private boolean isOnFace( int cubit, int axis, int row)
+    {
+    final float MAX_ERROR = 0.0001f;
+    float diff = mCubits[cubit].mRotationRow[axis] - row;
+    return diff*diff < MAX_ERROR;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
