Project

General

Profile

« Previous | Next » 

Revision 495463cc

Added by Leszek Koltunski 9 months ago

improvements to the API

View differences:

src/main/java/org/distorted/objectlib/helpers/ObjectLibInterface.java
17 17
  void onWinEffectFinished(long startTime, long endTime, int scrambleNum);
18 18
  void onScrambleEffectFinished();
19 19
  void onBeginRotation();
20
  void onRemoveRotation(int axis, int row, int angle);
20
  void onRemoveRotation(int axis, int rowBitmap, int angle);
21 21
  void failedToDrag();
22 22
  void onSolved();
23 23
  void onObjectCreated(long time);
src/main/java/org/distorted/objectlib/helpers/ObjectMove.java
69 69

  
70 70
///////////////////////////////////////////////////////////////////////////////////////////////////
71 71

  
72
  public boolean isEqual(int ax, int rw, int an, int[][] basicAngles)
72
  public boolean isEqual(int ax, int rb, int an, int[][] basicAngles)
73 73
    {
74
    if( axis==ax && rowBitmap==(1<<rw) )
74
    if( axis==ax && rowBitmap==rb )
75 75
      {
76 76
      if( row<0 ) row = computeRowFromBitmap(rowBitmap);
77 77
      return ((angle-an) % basicAngles[axis][row]) == 0;
......
82 82

  
83 83
///////////////////////////////////////////////////////////////////////////////////////////////////
84 84

  
85
  public boolean isInvert(int ax, int rw, int an, int[][] basicAngles)
85
  public boolean isInvert(int ax, int rb, int an, int[][] basicAngles)
86 86
    {
87
    if( axis==ax && rowBitmap==(1<<rw) )
87
    if( axis==ax && rowBitmap==rb )
88 88
      {
89 89
      if( row<0 ) row = computeRowFromBitmap(rowBitmap);
90 90
      return ((angle+an) % basicAngles[axis][row]) == 0;
......
129 129
    return angle*(360/basic);
130 130
    }
131 131

  
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

  
134
  public int getBasicAngle(int[][] basicAngle)
135
    {
136
    if( row<0 ) row = computeRowFromBitmap(rowBitmap);
137
    return basicAngle[axis][row];
138
    }
139

  
132 140
///////////////////////////////////////////////////////////////////////////////////////////////////
133 141

  
134 142
  public boolean isNonempty()
src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
189 189
      int[][] basicAngles = mNewObject.getBasicAngles();
190 190
      int basic = basicAngles[mFinishAxis][mFinishRow];
191 191
      int realAngle = (int)((angle*basic)/360);
192
      mInterface.onRemoveRotation(mFinishAxis,mFinishRow,realAngle);
192
      mInterface.onRemoveRotation(mFinishAxis,1<<mFinishRow,realAngle);
193 193
      }
194 194

  
195 195
    mIsSolved = solved;
src/main/java/org/distorted/objectlib/solvers/algorithmic/SolvedObject.java
59 59

  
60 60
///////////////////////////////////////////////////////////////////////////////////////////////////
61 61

  
62
  public int findMove(int ax, int row, int angle)
62
  public int findMove(int ax, int rowBitmap, int angle)
63 63
    {
64 64
    int num = mMoveTable.length;
65 65

  
66 66
    for( int m=0; m<num; m++)
67
      if( mMoveTable[m].isEqual(ax,row,angle,mBasicAngles) ) return m;
67
      if( mMoveTable[m].isEqual(ax,rowBitmap,angle,mBasicAngles) ) return m;
68 68

  
69 69
    return -1;
70 70
    }
......
302 302
      ObjectMove m1 = mMoveTable[moves[start]];
303 303
      int totalAngle = m1.getAngle();
304 304
      int ax = m1.getAxis();
305
      int row= m1.getRow();
305
      int rowBitmap= m1.getRowBitmap();
306 306

  
307 307
      for(end=start+1; end<len; end++)
308 308
        {
309 309
        ObjectMove m2 = mMoveTable[moves[end]];
310
        if( ax!=m2.getAxis() || row!=m2.getRow() ) break;
310
        if( ax!=m2.getAxis() || rowBitmap!=m2.getRowBitmap() ) break;
311 311
        totalAngle += m2.getAngle();
312 312
        }
313 313

  
314 314
      if( end>start+1 )
315 315
        {
316
        int basicAngle = mBasicAngles[ax][row];
316
        int basicAngle = m1.getBasicAngle(mBasicAngles);
317 317
        totalAngle %= basicAngle;
318 318
        if( totalAngle> basicAngle/2 ) totalAngle -= basicAngle;
319 319
        if( totalAngle<-basicAngle/2 ) totalAngle += basicAngle;
......
324 324
          }
325 325
        else
326 326
          {
327
          moves[start] = findMove(ax,row,totalAngle);
327
          moves[start] = findMove(ax,rowBitmap,totalAngle);
328 328
          return collapseMoves(moves,start+1,end);
329 329
          }
330 330
        }
......
412 412
      {
413 413
      ObjectMove move = mMoveTable[i];
414 414
      int ax = move.getAxis();
415
      int row= move.getRow();
415
      int rb = move.getRowBitmap();
416 416
      int ang= move.getAngle();
417 417

  
418 418
      for(int j=0; j<mBranchingFactor; j++)
419
        if( mMoveTable[j].isInvert(ax,row,ang,mBasicAngles) )
419
        if( mMoveTable[j].isInvert(ax,rb,ang,mBasicAngles) )
420 420
          {
421 421
          ret[i] = j;
422 422
          break;

Also available in: Unified diff