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/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