Project

General

Profile

« Previous | Next » 

Revision c896c0b3

Added by Leszek Koltunski over 4 years ago

Simplifications for object movement.

View differences:

src/main/java/org/distorted/object/RubikCubeMovement.java
63 63

  
64 64
///////////////////////////////////////////////////////////////////////////////////////////////////
65 65

  
66
    private void convertTouchPointToScreenSpace(Static4D accumulated, int x, int y, int scrW, int scrH)
66
    private void convertTouchPointToScreenSpace(Static4D accumulated, float x, float y)
67 67
      {
68
      float halfScrWidth  = scrW*0.5f;
69
      float halfScrHeight = scrH*0.5f;
70
      Static4D touchPoint = new Static4D(x-halfScrWidth, halfScrHeight-y, 0, 0);
68
      Static4D touchPoint = new Static4D(x, y, 0, 0);
71 69
      Static4D rotatedTouchPoint= RubikSurfaceView.rotateVectorByInvertedQuat(touchPoint, accumulated);
72 70

  
73 71
      mPoint[0] = rotatedTouchPoint.get1();
......
192 190

  
193 191
///////////////////////////////////////////////////////////////////////////////////////////////////
194 192

  
195
    public int faceTouched(Static4D accumulated, float cameraDistance, int x, int y, int scrW, int scrH)
193
    public int faceTouched(Static4D accumulated, float cameraDistance, float x, float y)
196 194
      {
197 195
      float cubeHalfSize= mCube.returnCubeSizeInScreenSpace()*0.5f;
198 196

  
199
      convertTouchPointToScreenSpace(accumulated,x,y, scrW, scrH);
197
      convertTouchPointToScreenSpace(accumulated,x,y);
200 198
      convertCameraPointToScreenSpace(accumulated, cameraDistance);
201 199

  
202 200
      for(int face=FRONT; face<=BOTTOM; face++)
......
218 216

  
219 217
///////////////////////////////////////////////////////////////////////////////////////////////////
220 218

  
221
    public void addNewRotation(Static4D accumulated, int lastTouchedFace, int x, int y, int scrW, int scrH)
219
    public void addNewRotation(Static4D accumulated, int lastTouchedFace, float x, float y)
222 220
      {
223 221
      float cubeHalfSize= mCube.returnCubeSizeInScreenSpace()*0.5f;
224 222

  
225
      convertTouchPointToScreenSpace(accumulated, x,y, scrW, scrH);
223
      convertTouchPointToScreenSpace(accumulated,x,y);
226 224
      castTouchPointOntoFace(lastTouchedFace,cubeHalfSize,mDiff);
227 225

  
228 226
      mDiff[0] -= mTouchPointCastOntoFace[0];
......
243 241

  
244 242
///////////////////////////////////////////////////////////////////////////////////////////////////
245 243

  
246
    public void continueRotation(Static4D accumulated, int lastTouchedFace, int x, int y, int scrW, int scrH)
244
    public void continueRotation(Static4D accumulated, int lastTouchedFace, float x, float y, int scrMin)
247 245
      {
248
      convertTouchPointToScreenSpace(accumulated, x,y, scrW, scrH);
246
      convertTouchPointToScreenSpace(accumulated,x,y);
249 247

  
250 248
      mDiff[0] = mPoint[0]-mTouchPoint[0];
251 249
      mDiff[1] = mPoint[1]-mTouchPoint[1];
......
256 254
      int sign = retFaceRotationSign(lastTouchedFace);
257 255
      float angle = (mRotationVect==xAxis ? mDiff[yAxis] : -mDiff[xAxis]);
258 256

  
259
      int scrMin = scrW<scrH ? scrW:scrH;
260

  
261 257
      mCube.continueRotation(SWIPING_SENSITIVITY*sign*angle/scrMin);
262 258
      }
263 259
}

Also available in: Unified diff