Project

General

Profile

« Previous | Next » 

Revision 935f3663

Added by Leszek Koltunski over 3 years ago

Fix the way we continue rotation: when rotating a layer, we need to be doing it with respect to the RotAxis which has been first casted to the touched face, and only then this casted one is casted to the surface of the screen.

Before we were casting the rotAxis directly to the screen without the intermediate casting to the face, which doesn't really work in case of the Dino: if the touched face is rotated away by quite a lot, the rotAxis is then completely counterintuitive.

View differences:

src/main/java/org/distorted/main/RubikSurfaceView.java
164 164
      }
165 165

  
166 166
///////////////////////////////////////////////////////////////////////////////////////////////////
167
// cast the 3D axis we are currently rotating along to the 2D in-screen-surface axis
167
// cast the 3D axis we are currently rotating along (which is already casted to the surface of the
168
// currently touched face AND converted into a 4D vector - fourth 0) to a 2D in-screen-surface axis
168 169

  
169
    private void computeCurrentAxis(Static3D axis)
170
    private void computeCurrentAxis(Static4D axis)
170 171
      {
171
      Static4D axis4D = new Static4D(axis.get0(), axis.get1(), axis.get2(), 0);
172
      Static4D result = rotateVectorByQuat(axis4D, mQuat);
172
      Static4D result = rotateVectorByQuat(axis, mQuat);
173 173

  
174 174
      mAxisX =result.get0();
175 175
      mAxisY =result.get1();
......
468 468
      float offset = res.get1();
469 469
      mCurrentRow  = object.computeRowFromOffset(offset);
470 470

  
471
      computeCurrentAxis( object.getRotationAxis()[mCurrentAxis] );
471
      computeCurrentAxis( mMovement.getCastedRotAxis(mCurrentAxis) );
472 472
      mRotationFactor = object.returnRotationFactor(offset);
473 473

  
474 474
      object.beginNewRotation( mCurrentAxis, mCurrentRow );

Also available in: Unified diff