Project

General

Profile

« Previous | Next » 

Revision bcdecc9f

Added by Leszek Koltunski over 1 year ago

Make it impossible to addNewRotation() (i.e. the automatic rotations triggered from backMove, scrambleEffect etc) or beginNewRotation() (by swiping a finger) when we are currently finishing a previous rotation and haven't removed it yet.

View differences:

src/main/java/org/distorted/objectlib/main/ObjectControl.java
280 280

  
281 281
    private void beginRotation(float x, float y)
282 282
      {
283
      mStartRotX = x;
284
      mStartRotY = y;
285

  
286 283
      TwistyObject object = mPreRender.getObject();
287 284
      int[] numLayers = object.getNumLayers();
288 285

  
......
290 287
      Static4D rotatedTouchPoint= QuatHelper.rotateVectorByInvertedQuat(touchPoint, mQuat);
291 288
      mTouchControl.newRotation(mBuffer,rotatedTouchPoint,mQuat);
292 289

  
293
      mCurrentAxis = mBuffer[0];
294
      mCurrentRow  = mBuffer[1];
295

  
296
      mTouchControl.getCastedRotAxis(mAxis,mQuat,mCurrentAxis);
297
      mRotationFactor = mTouchControl.returnRotationFactor(numLayers,mCurrentRow);
290
      int currentAxis = mBuffer[0];
291
      int currentRow  = mBuffer[1];
298 292

  
299
      object.beginNewRotation( mCurrentAxis, mCurrentRow );
293
      mTouchControl.getCastedRotAxis(mAxis,mQuat,currentAxis);
294
      mRotationFactor = mTouchControl.returnRotationFactor(numLayers,currentRow);
300 295

  
301
      mInterface.onBeginRotation();
296
      if( object.beginNewRotation( currentAxis, currentRow ) )
297
        {
298
        mInterface.onBeginRotation();
302 299

  
303
      addSpeedProbe(x,y);
300
        addSpeedProbe(x,y);
304 301

  
305
      mBeginningRotation = false;
306
      mContinuingRotation= true;
302
        mBeginningRotation = false;
303
        mContinuingRotation= true;
304
        mStartRotX = x;
305
        mStartRotY = y;
306
        mCurrentAxis = currentAxis;
307
        mCurrentRow  = currentRow;
308
        }
307 309
      }
308 310

  
309 311
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
224 224
      mAddRotationID = mNewObject.addNewRotation( mAddRotationAxis, mAddRotationRowBitmap,
225 225
                                                  mAddRotationAngle, mAddRotationDuration, this);
226 226

  
227
      if( mAddRotationID==0 ) // failed to add effect - should never happen
228
        {
227
      if( mAddRotationID==0 ) // failed to add effect - can happen if we are finishing
228
        {                     // previous rotation and haven't removed it yet
229 229
        unblockEverything();
230 230
        }
231 231
      }
src/main/java/org/distorted/objectlib/main/TwistyObject.java
1436 1436
    float axisZ = mAxis[mCurrentRotAxis].get2();
1437 1437
    Static4D quat = new Static4D( axisX*sinA, axisY*sinA, axisZ*sinA, cosA);
1438 1438

  
1439
    mRotationAngle.removeAll();
1440
    mRotationAngleStatic.set0(0);
1441

  
1442 1439
    for(int i=0; i<mNumCubits; i++)
1443 1440
      {
1444 1441
      mBelongs[i] = belongsToRotation(i, mCurrentRotAxis,mRotRowBitmap);
......
1464 1461
        setCubitQuat(i,mCubits[i].computeAssociation(),mCubits[i].mQuatIndex);
1465 1462
        }
1466 1463
      }
1464

  
1465
    mRotationAngleStatic.set0(0);
1466
    mRotationAngle.removeAll();
1467 1467
    }
1468 1468

  
1469 1469
///////////////////////////////////////////////////////////////////////////////////////////////////
......
1519 1519
    {
1520 1520
    if( wasRotateApplied() )
1521 1521
      {
1522
      mCurrentRotAxis = axis;
1523
      mRotRowBitmap= computeBitmapFromRow( rowBitmap,axis );
1524

  
1525
      mRotationAngleStatic.set0(0.0f);
1526
      mRotationAxis.set( mAxis[axis] );
1527
      mRotationAngle.setDuration(durationMillis);
1528
      mRotationAngle.resetToBeginning();
1529
      mRotationAngle.add(new Static1D(0));
1530
      mRotationAngle.add(new Static1D(angle));
1531
      mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*mMaxNumLayers) , -1);
1532
      mRotateEffect.notifyWhenFinished(listener);
1522
      int numPoints = mRotationAngle.getNumPoints();
1533 1523

  
1534
      return mRotateEffect.getID();
1524
      if( numPoints==0 )
1525
        {
1526
        mCurrentRotAxis = axis;
1527
        mRotRowBitmap= computeBitmapFromRow( rowBitmap,axis );
1528

  
1529
        mRotationAngleStatic.set0(0.0f);
1530
        mRotationAxis.set( mAxis[axis] );
1531
        mRotationAngle.setDuration(durationMillis);
1532
        mRotationAngle.resetToBeginning();
1533
        mRotationAngle.add(new Static1D(0));
1534
        mRotationAngle.add(new Static1D(angle));
1535
        mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*mMaxNumLayers) , -1);
1536
        mRotateEffect.notifyWhenFinished(listener);
1537

  
1538
        return mRotateEffect.getID();
1539
        }
1535 1540
      }
1536 1541

  
1537 1542
    return 0;
......
1546 1551

  
1547 1552
///////////////////////////////////////////////////////////////////////////////////////////////////
1548 1553

  
1549
  synchronized void beginNewRotation(int axis, int row )
1554
  synchronized boolean beginNewRotation(int axis, int row )
1550 1555
    {
1551 1556
    if( axis<0 || axis>=mNumAxis )
1552 1557
      {
1553 1558
      android.util.Log.e("object", "invalid rotation axis: "+axis);
1554
      return;
1559
      return false;
1555 1560
      }
1556 1561
    if( row<0 || row>=mNumLayers[axis] )
1557 1562
      {
1558 1563
      android.util.Log.e("object", "invalid rotation row: "+row);
1559
      return;
1564
      return false;
1560 1565
      }
1561 1566

  
1562
    mCurrentRotAxis = axis;
1563
    mRotRowBitmap= computeBitmapFromRow( (1<<row),axis );
1564
    mRotationAngleStatic.set0(0.0f);
1565
    mRotationAxis.set( mAxis[axis] );
1566
    mRotationAngle.add(mRotationAngleStatic);
1567
    mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*mMaxNumLayers) , -1);
1567
    int numPoints = mRotationAngle.getNumPoints();
1568

  
1569
    if( numPoints==0 )
1570
      {
1571
      mCurrentRotAxis = axis;
1572
      mRotRowBitmap= computeBitmapFromRow( (1<<row),axis );
1573
      mRotationAngleStatic.set0(0.0f);
1574
      mRotationAxis.set( mAxis[axis] );
1575
      mRotationAngle.add(mRotationAngleStatic);
1576
      mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*mMaxNumLayers) , -1);
1577
      return true;
1578
      }
1579
    return false;
1568 1580
    }
1569 1581

  
1570 1582
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff