Project

General

Profile

« Previous | Next » 

Revision ef018c1b

Added by Leszek Koltunski over 2 years ago

Abstract the next function, computeRowFromOffset(), out of the individual Movement classes.
Still two issues:

1) mysterious 1.5 multiplier in Movement12
2) in Movement8, moving the offset works only if the rotAxis are face-turning, i.e. they connect the centers of the opposing faces of the octahedron.

View differences:

src/main/java/org/distorted/objects/TwistyRex.java
48 48
  private ScrambleState[] mStates;
49 49
  private int[] mBasicAngle;
50 50
  private Static4D[] mQuats;
51
  private float[][] mCuts;
52
  private boolean[][] mLayerRotatable;
51 53
  private int[][] mFaceMap;
52 54
  private ObjectSticker[] mStickers;
53 55
  private Movement mMovement;
......
134 136

  
135 137
  float[][] getCuts(int numLayers)
136 138
    {
137
    float C = SQ3*0.45f; // bit less than 1/2 of the length of the main diagonal
138
    float[] cut = new float[] {-C,+C};
139
    return new float[][] { cut,cut,cut,cut };
139
    if( mCuts==null )
140
      {
141
      float C = SQ3*0.45f; // bit less than 1/2 of the length of the main diagonal
142
      float[] cut = new float[] {-C,+C};
143
      mCuts = new float[][] { cut,cut,cut,cut };
144
      }
145

  
146
    return mCuts;
147
    }
148

  
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150

  
151
  private void getLayerRotatable(int numLayers)
152
    {
153
    if( mLayerRotatable==null )
154
      {
155
      int numAxis = ROT_AXIS.length;
156
      boolean[] tmp = new boolean[] {true,false,true};
157
      mLayerRotatable = new boolean[numAxis][];
158
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
159
      }
140 160
    }
141 161

  
142 162
///////////////////////////////////////////////////////////////////////////////////////////////////
......
424 444

  
425 445
  public Movement getMovement()
426 446
    {
427
    if( mMovement==null ) mMovement = new MovementCornerTwisting();
447
    if( mMovement==null )
448
      {
449
      int numLayers = getNumLayers();
450
      if( mCuts==null ) getCuts(numLayers);
451
      getLayerRotatable(numLayers);
452

  
453
      mMovement = new MovementCornerTwisting(mCuts,mLayerRotatable,numLayers);
454
      }
428 455
    return mMovement;
429 456
    }
430 457

  

Also available in: Unified diff