Revision f0450fcc
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyObject.java | ||
---|---|---|
290 | 290 |
|
291 | 291 |
for(int i=0; i<NUM_CUTS; i++) |
292 | 292 |
{ |
293 |
if( tmp<CUTS[i] ) return i;
|
|
293 |
if( tmp<CUTS[i] ) return (1<<i);
|
|
294 | 294 |
} |
295 | 295 |
|
296 |
return NUM_CUTS;
|
|
296 |
return (1<<NUM_CUTS);
|
|
297 | 297 |
} |
298 | 298 |
|
299 | 299 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
307 | 307 |
|
308 | 308 |
private boolean belongsToRotation( int cubit, int axis, int rowBitmap) |
309 | 309 |
{ |
310 |
return ((1<<CUBITS[cubit].mRotationRow[axis]) & rowBitmap) != 0;
|
|
310 |
return (CUBITS[cubit].mRotationRow[axis] & rowBitmap) != 0;
|
|
311 | 311 |
} |
312 | 312 |
|
313 | 313 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
411 | 411 |
if ( cubit.mQuatIndex == quatIndex ) return false; |
412 | 412 |
|
413 | 413 |
int belongsToHowManyFaces = 0; |
414 |
int lastLayer = getNumLayers()-1; |
|
415 |
int row; |
|
414 |
int bitmap = (1<<(getNumLayers()-1)) + 1; |
|
416 | 415 |
|
417 | 416 |
for(int i=0; i<NUM_AXIS; i++) |
418 | 417 |
{ |
419 |
row = cubit.mRotationRow[i]; |
|
420 |
if( row==0 || row==lastLayer ) belongsToHowManyFaces++; |
|
418 |
if( (cubit.mRotationRow[i] & bitmap) != 0 ) belongsToHowManyFaces++; |
|
421 | 419 |
} |
422 | 420 |
|
423 | 421 |
switch(belongsToHowManyFaces) |
... | ... | |
432 | 430 |
Static4D rotated1 = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat1 ); |
433 | 431 |
Static4D rotated2 = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat2 ); |
434 | 432 |
|
435 |
float row1, row2;
|
|
433 |
int row1, row2;
|
|
436 | 434 |
float x1 = rotated1.get0(); |
437 | 435 |
float y1 = rotated1.get1(); |
438 | 436 |
float z1 = rotated1.get2(); |
... | ... | |
445 | 443 |
row1 = computeRow(x1,y1,z1,i); |
446 | 444 |
row2 = computeRow(x2,y2,z2,i); |
447 | 445 |
|
448 |
if( (row1==0 && row2==0) || (row1==lastLayer && row2==lastLayer) ) return false;
|
|
446 |
if( ((row1 & row2) & bitmap) != 0 ) return false;
|
|
449 | 447 |
} |
450 | 448 |
return true; |
451 | 449 |
|
Also available in: Unified diff
Change Cubit.mRotationRow[] from an index pointing at a single rotating layer to a bitmap potentially pointing at several layers.
(in preparation for bandaged objects)