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/TwistyJing.java
51 51
  private int[] mBasicAngle;
52 52
  private int[] mRotQuat;
53 53
  private Static4D[] mQuats;
54
  private float[][] mCuts;
55
  private boolean[][] mLayerRotatable;
54 56
  private float[][] mCenters;
55 57
  private int[][] mFaceMap;
56 58
  private ObjectSticker[] mStickers;
......
167 169

  
168 170
  float[][] getCuts(int size)
169 171
    {
170
    float[] cut = { (F-0.5f)*(SQ6/3) };
171
    return new float[][] { cut,cut,cut,cut };
172
    if( mCuts==null )
173
      {
174
      float[] cut = { (F-0.5f)*(SQ6/3) };
175
      mCuts = new float[][] { cut,cut,cut,cut };
176
      }
177

  
178
    return mCuts;
179
    }
180

  
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182

  
183
  private void getLayerRotatable(int numLayers)
184
    {
185
    if( mLayerRotatable==null )
186
      {
187
      int numAxis = ROT_AXIS.length;
188
      boolean[] tmp = new boolean[numLayers];
189
      for(int i=0; i<numLayers; i++) tmp[i] = true;
190
      mLayerRotatable = new boolean[numAxis][];
191
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
192
      }
172 193
    }
173 194

  
174 195
///////////////////////////////////////////////////////////////////////////////////////////////////
......
384 405

  
385 406
  public Movement getMovement()
386 407
    {
387
    if( mMovement==null ) mMovement = new MovementJing();
408
    if( mMovement==null )
409
      {
410
      int numLayers = getNumLayers();
411
      if( mCuts==null ) getCuts(numLayers);
412
      getLayerRotatable(numLayers);
413

  
414
      mMovement = new MovementJing(mCuts,mLayerRotatable,numLayers);
415
      }
388 416
    return mMovement;
389 417
    }
390 418

  

Also available in: Unified diff