Revision 605f319b
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/objectlib/main/TwistyObject.java | ||
---|---|---|
78 | 78 |
public static final int COLOR_STROKE = 0xff000000; |
79 | 79 |
public static final int COLOR_INTERNAL = 0xff000000; |
80 | 80 |
|
81 |
private static final int STATE_NOTHING = 0; |
|
82 |
private static final int STATE_ROTATE = 1; |
|
83 |
private static final int STATE_FINISH = 2; |
|
84 |
|
|
81 | 85 |
public static final int TEXTURE_HEIGHT = 256; |
82 | 86 |
static final int NUM_STICKERS_IN_ROW = 4; |
83 | 87 |
|
... | ... | |
153 | 157 |
private int mMaxNumLayers; |
154 | 158 |
private int mNumAxis; |
155 | 159 |
private int mPointNum; |
160 |
private int mRotationState; |
|
156 | 161 |
|
157 | 162 |
//////////////////// SOLVED1 //////////////////////// |
158 | 163 |
|
... | ... | |
212 | 217 |
|
213 | 218 |
private void initialize(int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream meshStream, boolean fromJSON) |
214 | 219 |
{ |
220 |
mRotationState = STATE_NOTHING; |
|
215 | 221 |
mIconMode = iconMode; |
216 | 222 |
mQuat = quat; |
217 | 223 |
mAxis = getRotationAxis(); |
... | ... | |
1456 | 1462 |
setCubitQuat(i,mCubits[i].computeAssociation(),mCubits[i].mQuatIndex); |
1457 | 1463 |
} |
1458 | 1464 |
} |
1465 |
|
|
1466 |
mRotationState = STATE_NOTHING; |
|
1459 | 1467 |
} |
1460 | 1468 |
|
1461 | 1469 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
1486 | 1494 |
{ |
1487 | 1495 |
if( wasRotateApplied() ) |
1488 | 1496 |
{ |
1497 |
mRotationState = STATE_FINISH; |
|
1489 | 1498 |
float angle = getAngle(); |
1490 | 1499 |
mRotationAngleStatic.set0(angle); |
1491 | 1500 |
mRotationAngleFinal.set0(nearestAngleInDegrees); |
... | ... | |
1509 | 1518 |
|
1510 | 1519 |
synchronized long addNewRotation( int axis, int rowBitmap, int angle, long durationMillis, EffectListener listener ) |
1511 | 1520 |
{ |
1521 |
int mult = 1; |
|
1522 |
|
|
1512 | 1523 |
if( wasRotateApplied() ) |
1513 | 1524 |
{ |
1525 |
if( mRotationState==STATE_ROTATE ) |
|
1526 |
{ |
|
1527 |
return 0; |
|
1528 |
} |
|
1529 |
if( mRotationState==STATE_FINISH ) |
|
1530 |
{ |
|
1531 |
removeRotationNow(); |
|
1532 |
mult = -1; |
|
1533 |
} |
|
1534 |
|
|
1535 |
mRotationState = STATE_ROTATE; |
|
1514 | 1536 |
mCurrentRotAxis = axis; |
1515 | 1537 |
mRotRowBitmap= computeBitmapFromRow( rowBitmap,axis ); |
1516 | 1538 |
mRotationAngleStatic.set0(0.0f); |
... | ... | |
1521 | 1543 |
mRotationAngle.add(new Static1D(angle)); |
1522 | 1544 |
mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*mMaxNumLayers) , -1); |
1523 | 1545 |
mRotateEffect.notifyWhenFinished(listener); |
1524 |
return mRotateEffect.getID(); |
|
1546 |
return mult*mRotateEffect.getID();
|
|
1525 | 1547 |
} |
1526 | 1548 |
|
1527 | 1549 |
return 0; |
... | ... | |
1536 | 1558 |
|
1537 | 1559 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1538 | 1560 |
|
1539 |
synchronized void beginNewRotation(int axis, int row )
|
|
1561 |
synchronized boolean beginNewRotation(int axis, int row )
|
|
1540 | 1562 |
{ |
1563 |
if( mRotationState==STATE_ROTATE ) |
|
1564 |
{ |
|
1565 |
return false; |
|
1566 |
} |
|
1567 |
if( mRotationState==STATE_FINISH ) |
|
1568 |
{ |
|
1569 |
removeRotationNow(); |
|
1570 |
} |
|
1571 |
|
|
1541 | 1572 |
if( axis<0 || axis>=mNumAxis ) |
1542 | 1573 |
{ |
1543 | 1574 |
android.util.Log.e("object", "invalid rotation axis: "+axis); |
1544 |
return; |
|
1575 |
return false;
|
|
1545 | 1576 |
} |
1546 | 1577 |
if( row<0 || row>=mNumLayers[axis] ) |
1547 | 1578 |
{ |
1548 | 1579 |
android.util.Log.e("object", "invalid rotation row: "+row); |
1549 |
return; |
|
1580 |
return false;
|
|
1550 | 1581 |
} |
1551 | 1582 |
|
1583 |
mRotationState = STATE_ROTATE; |
|
1552 | 1584 |
mCurrentRotAxis = axis; |
1553 | 1585 |
mRotRowBitmap= computeBitmapFromRow( (1<<row),axis ); |
1554 | 1586 |
mRotationAngleStatic.set0(0.0f); |
1555 | 1587 |
mRotationAxis.set( mAxis[axis] ); |
1556 | 1588 |
mRotationAngle.add(mRotationAngleStatic); |
1557 | 1589 |
mRotateEffect.setMeshAssociation( mRotRowBitmap<<(axis*mMaxNumLayers) , -1); |
1590 |
|
|
1591 |
return true; |
|
1558 | 1592 |
} |
1559 | 1593 |
|
1560 | 1594 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Bugfixes for touch control - specifically for furious swiping and concurrect backing of moves.