Project

General

Profile

« Previous | Next » 

Revision 123d6172

Added by Leszek Koltunski over 4 years ago

Further simplifications for object movement.

View differences:

src/main/java/org/distorted/magic/RubikSurfaceView.java
61 61

  
62 62
    private boolean mDragging, mBeginningRotation, mContinuingRotation;
63 63
    private float mX, mY;
64
    private int mLastTouchedFace;
65
    private float mCameraDistance;
66 64
    private int mScreenWidth, mScreenHeight, mScreenMin;
67 65

  
68 66
    private static Static4D mQuatCurrent    = new Static4D(0,0,0,1);
......
135 133
      mScreenMin = width<height ? width:height;
136 134
      }
137 135

  
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

  
140
    void setCameraDist(float distance)
141
      {
142
      mCameraDistance = distance;
143
      }
144

  
145 136
///////////////////////////////////////////////////////////////////////////////////////////////////
146 137

  
147 138
    RubikRenderer getRenderer()
......
359 350
         {
360 351
         case MotionEvent.ACTION_DOWN: mX = x;
361 352
                                       mY = y;
362
                                       mLastTouchedFace = mMovement.faceTouched(mQuatAccumulated,mCameraDistance/mScreenMin, x, y);
363 353

  
364
                                       if( mLastTouchedFace != RubikCubeMovement.NONE )
354
                                       if( mMovement.faceTouched(mQuatAccumulated, x, y) )
365 355
                                         {
366 356
                                         mDragging           = false;
367 357
                                         mBeginningRotation  = mRenderer.canRotate();
......
393 383
                                         {
394 384
                                         if( (mX-x)*(mX-x)+(mY-y)*(mY-y) > 1.0f/(ROTATION_SENSITIVITY*ROTATION_SENSITIVITY) )
395 385
                                           {
396
                                           Static2D rot = mMovement.newRotation(mQuatAccumulated,mLastTouchedFace, x, y);
386
                                           Static2D rot = mMovement.newRotation(mQuatAccumulated, x, y);
397 387
                                           RubikCube cube = mRenderer.getCube();
398 388

  
399 389
                                           cube.addNewRotation( (int)rot.get1(), (int)(cube.getSize()*rot.get2()) );
......
404 394
                                         }
405 395
                                       else if( mContinuingRotation )
406 396
                                         {
407
                                         float angle = mMovement.continueRotation(mQuatAccumulated,mLastTouchedFace, x, y);
408

  
397
                                         float angle = mMovement.continueRotation(mQuatAccumulated, x, y);
409 398
                                         mRenderer.getCube().continueRotation(SWIPING_SENSITIVITY*angle);
410 399
                                         }
411 400
                                       break;

Also available in: Unified diff