commit c7c83fb7d7c9acf8d81a63296b414274f8efa0ed
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Jul 30 01:27:05 2021 +0200

    TwistyObject's ObejctScreenRatio and InitScreenRatio shouldn't be static. Make them non-static.
    Otherwise, if the current object is, say, a cube (initSR=0.5), we fire up tutorials and start a tutorial for something with vastly different ObjectScreenRatio (Jing- initSR=1.64), then come back to the Main Activity - so there's a cube on the screen again - the ratios stay at their Jing values, which screws up detection of rotations.

diff --git a/src/main/java/org/distorted/main/RubikSurfaceView.java b/src/main/java/org/distorted/main/RubikSurfaceView.java
index 7d520af5..b68fe2e5 100644
--- a/src/main/java/org/distorted/main/RubikSurfaceView.java
+++ b/src/main/java/org/distorted/main/RubikSurfaceView.java
@@ -234,7 +234,7 @@ public class RubikSurfaceView extends GLSurfaceView
         Static4D rotatedTouchPoint= QuatHelper.rotateVectorByInvertedQuat(touchPoint, mQuat);
         Static4D rotatedCamera= QuatHelper.rotateVectorByInvertedQuat(CAMERA_POINT, mQuat);
 
-        if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint,rotatedCamera) )
+        if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint,rotatedCamera,object.getObjectRatio() ) )
           {
           mDragging           = false;
           mContinuingRotation = false;
@@ -394,7 +394,7 @@ public class RubikSurfaceView extends GLSurfaceView
 
       Static4D touchPoint2 = new Static4D(x, y, 0, 0);
       Static4D rotatedTouchPoint2= QuatHelper.rotateVectorByInvertedQuat(touchPoint2, mQuat);
-      Static2D res = mMovement.newRotation(numLayers,rotatedTouchPoint2);
+      Static2D res = mMovement.newRotation(numLayers,rotatedTouchPoint2,object.getObjectRatio());
 
       mCurrentAxis = (int)res.get0();
       mCurrentRow  = (int)res.get1();
diff --git a/src/main/java/org/distorted/objects/Movement.java b/src/main/java/org/distorted/objects/Movement.java
index 263553d8..b3ade897 100644
--- a/src/main/java/org/distorted/objects/Movement.java
+++ b/src/main/java/org/distorted/objects/Movement.java
@@ -250,10 +250,8 @@ public abstract class Movement
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public boolean faceTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera)
+  public boolean faceTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera, float objectRatio)
     {
-    float objectRatio = TwistyObject.getObjectRatio();
-
     mPoint[0]  = rotatedTouchPoint.get0()/objectRatio;
     mPoint[1]  = rotatedTouchPoint.get1()/objectRatio;
     mPoint[2]  = rotatedTouchPoint.get2()/objectRatio;
@@ -277,10 +275,8 @@ public abstract class Movement
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public Static2D newRotation(int numLayers, Static4D rotatedTouchPoint)
+  public Static2D newRotation(int numLayers, Static4D rotatedTouchPoint, float objectRatio)
     {
-    float objectRatio = TwistyObject.getObjectRatio();
-
     mPoint[0] = rotatedTouchPoint.get0()/objectRatio;
     mPoint[1] = rotatedTouchPoint.get1()/objectRatio;
     mPoint[2] = rotatedTouchPoint.get2()/objectRatio;
diff --git a/src/main/java/org/distorted/objects/TwistyObject.java b/src/main/java/org/distorted/objects/TwistyObject.java
index 0ec57f5c..c90d3f19 100644
--- a/src/main/java/org/distorted/objects/TwistyObject.java
+++ b/src/main/java/org/distorted/objects/TwistyObject.java
@@ -91,8 +91,6 @@ public abstract class TwistyObject extends DistortedNode
   final int NUM_CUBITS;
   final int NUM_AXIS;
 
-  private static float mInitScreenRatio;
-  private static float mObjectScreenRatio = 1.0f;
   private static final float[] mTmp1 = new float[4];
   private static final float[] mTmp2 = new float[4];
 
@@ -115,6 +113,8 @@ public abstract class TwistyObject extends DistortedNode
   private final float mCameraDist;
   private final Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal;
   private final DistortedTexture mTexture;
+  private final float mInitScreenRatio;
+  private float mObjectScreenRatio;
   private int mNumTexRows, mNumTexCols;
   private int mRotRowBitmap;
   private int mRotAxis;
@@ -137,6 +137,7 @@ public abstract class TwistyObject extends DistortedNode
     mOrigPos = getCubitPositions(mNumLayers);
     mAxis = getRotationAxis();
     mInitScreenRatio = getScreenRatio();
+    mObjectScreenRatio = 1.0f;
     mNumCubitFaces = getNumCubitFaces();
 
     mCuts = getCuts(mNumLayers);
@@ -298,7 +299,7 @@ public abstract class TwistyObject extends DistortedNode
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  static float getObjectRatio()
+  public float getObjectRatio()
     {
     return mObjectScreenRatio*mInitScreenRatio;
     }
diff --git a/src/main/java/org/distorted/tutorials/TutorialSurfaceView.java b/src/main/java/org/distorted/tutorials/TutorialSurfaceView.java
index d4aec5a6..578a99c3 100644
--- a/src/main/java/org/distorted/tutorials/TutorialSurfaceView.java
+++ b/src/main/java/org/distorted/tutorials/TutorialSurfaceView.java
@@ -206,7 +206,7 @@ public class TutorialSurfaceView extends GLSurfaceView
       Static4D rotatedTouchPoint= QuatHelper.rotateVectorByInvertedQuat(touchPoint, mQuat);
       Static4D rotatedCamera= QuatHelper.rotateVectorByInvertedQuat(CAMERA_POINT, mQuat);
 
-      if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint,rotatedCamera) )
+      if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint,rotatedCamera,object.getObjectRatio()) )
         {
         mDragging           = false;
         mContinuingRotation = false;
@@ -339,7 +339,7 @@ public class TutorialSurfaceView extends GLSurfaceView
 
       Static4D touchPoint2 = new Static4D(x, y, 0, 0);
       Static4D rotatedTouchPoint2= QuatHelper.rotateVectorByInvertedQuat(touchPoint2, mQuat);
-      Static2D res = mMovement.newRotation(numLayers,rotatedTouchPoint2);
+      Static2D res = mMovement.newRotation(numLayers,rotatedTouchPoint2,object.getObjectRatio());
 
       mCurrentAxis = (int)res.get0();
       mCurrentRow  = (int)res.get1();
