Revision 517f9fb9
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/magic/RubikSurfaceView.java | ||
---|---|---|
238 | 238 |
Static4D rotatedTouchPoint1= rotateVectorByInvertedQuat(touchPoint1, mQuatAccumulated); |
239 | 239 |
Static4D rotatedCamera= rotateVectorByInvertedQuat(CAMERA_POINT, mQuatAccumulated); |
240 | 240 |
|
241 |
if( mMovement.faceTouched(rotatedTouchPoint1,rotatedCamera) ) |
|
241 |
if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint1,rotatedCamera) )
|
|
242 | 242 |
{ |
243 | 243 |
mDragging = false; |
244 | 244 |
mBeginningRotation = mRenderer.canRotate(); |
... | ... | |
251 | 251 |
mContinuingRotation = false; |
252 | 252 |
} |
253 | 253 |
break; |
254 |
case MotionEvent.ACTION_MOVE: if( mDragging ) |
|
255 |
{ |
|
256 |
mTempCurrent.set(quatFromDrag(mX-x,y-mY)); |
|
257 |
mRenderer.setQuatCurrentOnNextRender(); |
|
258 |
|
|
259 |
if( (mX-x)*(mX-x) + (mY-y)*(mY-y) > 1.0f/(DIRECTION_SENSITIVITY*DIRECTION_SENSITIVITY) ) |
|
260 |
{ |
|
261 |
mX = x; |
|
262 |
mY = y; |
|
263 |
mTempAccumulated.set(quatMultiply(mQuatCurrent, mQuatAccumulated)); |
|
264 |
mTempCurrent.set(0f, 0f, 0f, 1f); |
|
265 |
mRenderer.setQuatCurrentOnNextRender(); |
|
266 |
mRenderer.setQuatAccumulatedOnNextRender(); |
|
267 |
} |
|
268 |
} |
|
269 |
if( mBeginningRotation ) |
|
254 |
case MotionEvent.ACTION_MOVE: if( mBeginningRotation ) |
|
270 | 255 |
{ |
271 | 256 |
if( (mX-x)*(mX-x)+(mY-y)*(mY-y) > 1.0f/(ROTATION_SENSITIVITY*ROTATION_SENSITIVITY) ) |
272 | 257 |
{ |
... | ... | |
296 | 281 |
float angle = mMovement.continueRotation(rotatedTouchPoint3); |
297 | 282 |
mRenderer.getObject().continueRotation(SWIPING_SENSITIVITY*angle); |
298 | 283 |
} |
284 |
else if( mDragging || mRenderer.canDrag() ) |
|
285 |
{ |
|
286 |
mDragging = true; |
|
287 |
mTempCurrent.set(quatFromDrag(mX-x,y-mY)); |
|
288 |
mRenderer.setQuatCurrentOnNextRender(); |
|
289 |
|
|
290 |
if( (mX-x)*(mX-x) + (mY-y)*(mY-y) > 1.0f/(DIRECTION_SENSITIVITY*DIRECTION_SENSITIVITY) ) |
|
291 |
{ |
|
292 |
mX = x; |
|
293 |
mY = y; |
|
294 |
mTempAccumulated.set(quatMultiply(mQuatCurrent, mQuatAccumulated)); |
|
295 |
mTempCurrent.set(0f, 0f, 0f, 1f); |
|
296 |
mRenderer.setQuatCurrentOnNextRender(); |
|
297 |
mRenderer.setQuatAccumulatedOnNextRender(); |
|
298 |
} |
|
299 |
} |
|
299 | 300 |
break; |
300 | 301 |
case MotionEvent.ACTION_UP : if( mDragging ) |
301 | 302 |
{ |
Also available in: Unified diff
Improve the way we handle the cube.
Before if we touched the screen during any of the transitions, this touch and resulting draw would result in no action (confusing).
Now it seamlessly becomes a drag (even if we, during a transition, touched inside the cube)