Project

General

Profile

« Previous | Next » 

Revision a480ee80

Added by Leszek Koltunski over 2 years ago

Standarize the 'isSolved()' method: now all objects, except one (Dino4) have a standard isSolved().
This incidentally also fixes detection of the solved state in case of Diamond4, i.e. a Master FTO.

View differences:

src/main/java/org/distorted/objects/TwistyHelicopter.java
243 243
    super(size, size, quat, texture, mesh, effects, moves, ObjectList.HELI, res, scrWidth);
244 244
    }
245 245

  
246
///////////////////////////////////////////////////////////////////////////////////////////////////
247

  
248
  int[] getSolvedQuats(int cubit, int numLayers)
249
    {
250
    int status = retCubitSolvedStatus(cubit,numLayers);
251
    return status<0 ? null : buildSolvedQuats(MovementHelicopter.FACE_AXIS[status],QUATS);
252
    }
253

  
246 254
///////////////////////////////////////////////////////////////////////////////////////////////////
247 255

  
248 256
  float getScreenRatio()
......
426 434
      }
427 435
    }
428 436

  
429
///////////////////////////////////////////////////////////////////////////////////////////////////
430
// The Helicopter is solved if and only if:
431
//
432
// 1) all of its corner cubits are rotated with the same quat
433
// 2) all its face cubits are rotated with the same quat like the corner ones,
434
//    and optionally they also might be turned by a multiple of 90 degrees along
435
//    a vector perpendicular to the face they lie on.
436
//
437
// i.e.
438
// cubits  8, 9,10,11,12,13,14,15 - might be extra QUAT 1,8,9
439
// cubits 16,17,18,19,20,21,22,23 - might be extra QUAT 2,12,13
440
// cubits 24,25,26,27,28,29,30,31 - might be extra QUAT 3,14,15
441

  
442
  public boolean isSolved()
443
    {
444
    int q = CUBITS[0].mQuatIndex;
445

  
446
    if ( CUBITS[1].mQuatIndex == q &&
447
         CUBITS[2].mQuatIndex == q &&
448
         CUBITS[3].mQuatIndex == q &&
449
         CUBITS[4].mQuatIndex == q &&
450
         CUBITS[5].mQuatIndex == q &&
451
         CUBITS[6].mQuatIndex == q &&
452
         CUBITS[7].mQuatIndex == q  )
453
      {
454
      int q1 = mulQuat(q,1);
455
      int q2 = mulQuat(q,8);
456
      int q3 = mulQuat(q,9);
457

  
458
      for(int index=8; index<16; index++)
459
        {
460
        int qIndex = CUBITS[index].mQuatIndex;
461
        if( qIndex!=q && qIndex!=q1 && qIndex!=q2 && qIndex!=q3 ) return false;
462
        }
463

  
464
      q1 = mulQuat(q, 2);
465
      q2 = mulQuat(q,12);
466
      q3 = mulQuat(q,13);
467

  
468
      for(int index=16; index<24; index++)
469
        {
470
        int qIndex = CUBITS[index].mQuatIndex;
471
        if( qIndex!=q && qIndex!=q1 && qIndex!=q2 && qIndex!=q3 ) return false;
472
        }
473

  
474
      q1 = mulQuat(q, 3);
475
      q2 = mulQuat(q,14);
476
      q3 = mulQuat(q,15);
477

  
478
      for(int index=24; index<32; index++)
479
        {
480
        int qIndex = CUBITS[index].mQuatIndex;
481
        if( qIndex!=q && qIndex!=q1 && qIndex!=q2 && qIndex!=q3 ) return false;
482
        }
483

  
484
      return true;
485
      }
486

  
487
    return false;
488
    }
489

  
490 437
///////////////////////////////////////////////////////////////////////////////////////////////////
491 438

  
492 439
  public int getObjectName(int numLayers)

Also available in: Unified diff