Revision 19595510
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/main/TwistyObject.java | ||
---|---|---|
234 | 234 |
getQuatsAndShapes(fromDMESH,fromJSON); |
235 | 235 |
createMeshAndCubits(stream,meshState,fromDMESH); |
236 | 236 |
setUpTextures(fromDMESH,fromJSON); |
237 |
createDataStructuresForSolved(mNumLayers);
|
|
237 |
createDataStructuresForSolved(); |
|
238 | 238 |
|
239 | 239 |
mEffects = new DistortedEffects(); |
240 | 240 |
|
... | ... | |
429 | 429 |
setTexture(); |
430 | 430 |
} |
431 | 431 |
|
432 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
433 |
|
|
434 |
private void createDataStructuresForSolved(int[] numLayers) |
|
435 |
{ |
|
436 |
mTmpQuats = new int[mNumQuats]; |
|
437 |
mSolvedQuats = new int[mNumCubits][]; |
|
438 |
|
|
439 |
for(int c=0; c<mNumCubits; c++) |
|
440 |
{ |
|
441 |
mSolvedQuats[c] = getSolvedQuats(c,numLayers); |
|
442 |
} |
|
443 |
} |
|
444 |
|
|
445 | 432 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
446 | 433 |
|
447 | 434 |
private int getMultQuat(int index1, int index2) |
... | ... | |
469 | 456 |
return face>=mStickerVariants[variant].length ? -1 : mStickerVariants[variant][face]; |
470 | 457 |
} |
471 | 458 |
|
459 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
460 |
|
|
461 |
public boolean shouldResetTextureMaps() |
|
462 |
{ |
|
463 |
return false; |
|
464 |
} |
|
465 |
|
|
466 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
467 |
|
|
468 |
private void createDataStructuresForSolved() |
|
469 |
{ |
|
470 |
mTmpQuats = new int[mNumQuats]; |
|
471 |
mSolvedQuats = getSolvedQuats(); |
|
472 |
} |
|
473 |
|
|
472 | 474 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
473 | 475 |
// This is used to build internal data structures for the generic 'isSolved()' |
474 | 476 |
// |
... | ... | |
477 | 479 |
// Color index, i.e. the index into the 'FACE_COLORS' table. |
478 | 480 |
// else (edge or corner cubit, more than one non-black face): return -2. |
479 | 481 |
|
480 |
protected int retCubitSolvedStatus(int cubit, int[] numLayers)
|
|
482 |
protected int retCubitSolvedStatus(int cubit) |
|
481 | 483 |
{ |
482 | 484 |
int numNonBlack=0, nonBlackIndex=-1, varColor, cubColor; |
483 |
int variant = getCubitVariant(cubit,numLayers);
|
|
485 |
int variant = getCubitVariant(cubit,mNumLayers);
|
|
484 | 486 |
|
485 | 487 |
for(int face=0; face<mNumCubitFaces; face++) |
486 | 488 |
{ |
... | ... | |
502 | 504 |
|
503 | 505 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
504 | 506 |
|
505 |
public boolean shouldResetTextureMaps() |
|
506 |
{ |
|
507 |
return false; |
|
508 |
} |
|
509 |
|
|
510 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
511 |
|
|
512 |
protected int[] buildSolvedQuats(Static3D faceAx, Static4D[] quats) |
|
507 |
protected int[] buildSolvedQuats(Static3D faceAx) |
|
513 | 508 |
{ |
514 | 509 |
final float MAXD = 0.0001f; |
515 | 510 |
float x = faceAx.get0(); |
... | ... | |
517 | 512 |
float z = faceAx.get2(); |
518 | 513 |
float a,dx,dy,dz,qx,qy,qz; |
519 | 514 |
Static4D quat; |
520 |
|
|
521 |
int len = quats.length; |
|
522 | 515 |
int place = 0; |
523 | 516 |
|
524 |
for(int q=1; q<len; q++)
|
|
517 |
for(int q=1; q<mNumQuats; q++)
|
|
525 | 518 |
{ |
526 |
quat = quats[q];
|
|
519 |
quat = mObjectQuats[q];
|
|
527 | 520 |
qx = quat.get0(); |
528 | 521 |
qy = quat.get1(); |
529 | 522 |
qz = quat.get2(); |
... | ... | |
554 | 547 |
|
555 | 548 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
556 | 549 |
|
557 |
public int[] getSolvedQuats(int cubit, int[] numLayers)
|
|
550 |
public int[][] getSolvedQuats()
|
|
558 | 551 |
{ |
559 |
int status = retCubitSolvedStatus(cubit,numLayers);
|
|
552 |
int[][] solvedQuats = new int[mNumCubits][];
|
|
560 | 553 |
|
561 |
if( status>=0 )
|
|
554 |
for(int cubit=0; cubit<mNumCubits; cubit++)
|
|
562 | 555 |
{ |
563 |
Static3D[] axis = getFaceAxis(); |
|
564 |
return buildSolvedQuats(axis[status],mObjectQuats); |
|
556 |
int status = retCubitSolvedStatus(cubit); |
|
557 |
|
|
558 |
if( status>=0 ) |
|
559 |
{ |
|
560 |
Static3D[] axis = getFaceAxis(); |
|
561 |
solvedQuats[cubit] = buildSolvedQuats(axis[status]); |
|
562 |
} |
|
565 | 563 |
} |
566 | 564 |
|
567 |
return null;
|
|
565 |
return solvedQuats;
|
|
568 | 566 |
} |
569 | 567 |
|
570 | 568 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Preparation for further unification of the isSolved() routine.