Project

General

Profile

« Previous | Next » 

Revision ef018c1b

Added by Leszek Koltunski about 3 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/Movement.java
247 247
    output[1] = v0*y0 + v1*y1 + v2*y2;
248 248
    }
249 249

  
250
///////////////////////////////////////////////////////////////////////////////////////////////////
251

  
252
  float[] computeBorder(float scale, float[] cuts, boolean[] rotatable)
253
    {
254
    int len = cuts.length;
255
    float[] border = new float[len];
256

  
257
    for(int i=0; i<len; i++)
258
      {
259
      if( !rotatable[i] )
260
        {
261
        border[i] = i>0 ? border[i-1] : -Float.MAX_VALUE;
262
        }
263
      else
264
        {
265
        if( rotatable[i+1] ) border[i] = scale*cuts[i];
266
        else
267
          {
268
          int found = -1;
269

  
270
          for(int j=i+2; j<=len; j++)
271
            {
272
            if( rotatable[j] )
273
              {
274
              found=j;
275
              break;
276
              }
277
            }
278

  
279
          border[i] = found>0 ? scale*(cuts[i]+cuts[found-1])/2 : Float.MAX_VALUE;
280
          }
281
        }
282
      }
283

  
284
    return border;
285
    }
286

  
287
///////////////////////////////////////////////////////////////////////////////////////////////////
288

  
289
  float[][] computeBorders(float coeff, float[][] cuts, boolean[][] rotatable)
290
    {
291
    int numCuts = cuts.length;
292
    float[][] borders = new float[numCuts][];
293

  
294
    for(int i=0; i<numCuts; i++)
295
      {
296
      borders[i] = computeBorder(coeff,cuts[i],rotatable[i]);
297
      }
298

  
299
    return borders;
300
    }
301

  
250 302
///////////////////////////////////////////////////////////////////////////////////////////////////
251 303
// PUBLIC API
252 304
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/Movement12.java
51 51
           new Static3D(-SIN54/LEN,    0     ,   -C2/LEN )
52 52
         };
53 53

  
54
  private final float[][] mTouchBorders;
55

  
54 56
///////////////////////////////////////////////////////////////////////////////////////////////////
55 57

  
56
  Movement12(Static3D[] rotAxis)
58
  Movement12(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, int numLayers)
57 59
    {
58 60
    super(rotAxis, FACE_AXIS, DIST3D, DIST2D);
61
    float scale = (DIST2D*(1.5f)/(2*DIST3D))/numLayers; // SQ5/2 is 1/cos(dihedral-90)
62
    mTouchBorders = computeBorders(scale,cuts,rotatable);
63
    }
64

  
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66

  
67
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
68
    {
69
    float[] borders = mTouchBorders[axisIndex];
70
    int len = borders.length;
71

  
72
    for(int i=0; i<len; i++)
73
      {
74
      if( offset<borders[i] ) return i;
75
      }
76

  
77
    return len;
59 78
    }
60 79

  
61 80
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/Movement4.java
19 19

  
20 20
package org.distorted.objects;
21 21

  
22
import static org.distorted.objects.TwistyObject.SQ2;
23

  
22 24
import org.distorted.library.type.Static3D;
23 25

  
24 26
///////////////////////////////////////////////////////////////////////////////////////////////////
......
37 39
           new Static3D(+SQ6/3,-SQ3/3,     0),
38 40
         };
39 41

  
42
  private final float[][] mTouchBorders;
43

  
40 44
///////////////////////////////////////////////////////////////////////////////////////////////////
41 45

  
42
  Movement4(Static3D[] rotAxis)
46
  Movement4(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable,int numLayers)
43 47
    {
44 48
    super(rotAxis, FACE_AXIS, DIST3D, DIST2D);
49
    float scale = (3*SQ2/4)/numLayers; // 3*SQ2/4 is height(face)/height(tetra)
50
    mTouchBorders = computeBorders(scale,cuts,rotatable);
51
    }
52

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

  
55
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
56
    {
57
    float[] borders = mTouchBorders[axisIndex];
58
    int len = borders.length;
59

  
60
    for(int i=0; i<len; i++)
61
      {
62
      if( offset<borders[i] ) return i;
63
      }
64

  
65
    return len;
45 66
    }
46 67

  
47 68
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/Movement6.java
19 19

  
20 20
package org.distorted.objects;
21 21

  
22
import static org.distorted.objects.TwistyObject.SQ2;
23

  
22 24
import org.distorted.library.type.Static3D;
23 25

  
24 26
///////////////////////////////////////////////////////////////////////////////////////////////////
......
36 38
           new Static3D(0,0,1), new Static3D(0,0,-1)
37 39
         };
38 40

  
41
  private final float[][] mTouchBorders;
42

  
39 43
///////////////////////////////////////////////////////////////////////////////////////////////////
40 44

  
41
  Movement6(Static3D[] rotAxis)
45
  Movement6(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, int numLayers)
42 46
    {
43 47
    super(rotAxis, FACE_AXIS, DIST3D, DIST2D);
48
    float scale = 1.0f/numLayers; // 1.0 is (2*DIST3D)/(2*DIST2D)
49
    mTouchBorders = computeBorders(scale,cuts,rotatable);
50
    }
51

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

  
54
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
55
    {
56
    float[] borders = mTouchBorders[axisIndex];
57
    int len = borders.length;
58

  
59
    for(int i=0; i<len; i++)
60
      {
61
      if( offset<borders[i] ) return i;
62
      }
63

  
64
    return len;
44 65
    }
45 66

  
46 67
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/Movement8.java
19 19

  
20 20
package org.distorted.objects;
21 21

  
22
import static org.distorted.objects.TwistyObject.SQ2;
23

  
22 24
import org.distorted.library.type.Static3D;
23 25

  
24 26
///////////////////////////////////////////////////////////////////////////////////////////////////
......
37 39
           new Static3D(     0,+SQ3/3,-SQ6/3), new Static3D(     0,-SQ3/3,+SQ6/3)
38 40
         };
39 41

  
42
  private final float[][] mTouchBorders;
43

  
40 44
///////////////////////////////////////////////////////////////////////////////////////////////////
41 45

  
42
  Movement8(Static3D[] rotAxis)
46
  Movement8(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, int numLayers)
43 47
    {
44 48
    super(rotAxis, FACE_AXIS, DIST3D, DIST2D);
49
    float scale = (3*SQ2/4)/numLayers; // 3*SQ2/4 is 1/cos(dihedral-90)
50
    mTouchBorders = computeBorders(scale,cuts,rotatable);
51
    }
52

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54
// We have either one of the four faces (1,3,4,6) which, when the retAxis are cast onto it, they
55
// point the right way (and so the triangle then spans from offset=-SQ3/6 to offset=+SQ3/3 with
56
// midpoint at SQ3/12) or one of the other face when the cast rotAxis are the wrong way round (and
57
// the triangle spans then from 0 to SQ3/2 with midpoint at SQ3/4).
58
//
59
// This is only true if the rotAxis connect the centers of opposing faces!
60

  
61
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
62
    {
63
    float off = ( face==1 || face==3 || face==4 || face==6 ) ? DIST2D/2 : -DIST2D/2;
64
    float[] borders = mTouchBorders[axisIndex];
65
    int len = borders.length;
66

  
67
    for(int i=0; i<len; i++)
68
      {
69
      if( offset+off<borders[i] ) return i;
70
      }
71

  
72
    return len;
45 73
    }
46 74

  
47 75
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementCornerTwisting.java
23 23

  
24 24
class MovementCornerTwisting extends Movement6
25 25
{
26
  MovementCornerTwisting()
27
    {
28
    super(TwistySkewb.ROT_AXIS);
29
    }
26
  private static final int[][][] ENABLED = new int[][][]
27
      {
28
          {{2,0,1},{2,3,1},{2,2,3},{2,0,2}},
29
          {{2,2,3},{2,3,1},{2,0,1},{2,0,2}},
30
          {{2,1,2},{2,0,1},{2,0,3},{2,2,3}},
31
          {{2,1,2},{2,2,3},{2,0,3},{2,0,1}},
32
          {{2,0,3},{2,0,2},{2,1,2},{2,1,3}},
33
          {{2,1,2},{2,0,2},{2,0,3},{2,1,3}},
34
      };
30 35

  
31 36
///////////////////////////////////////////////////////////////////////////////////////////////////
32 37

  
33
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
38
  MovementCornerTwisting(float[][] cuts, boolean[][] rotatable, int numLayers)
34 39
    {
35
    return offset<0 ? 0 : numLayers-1;
40
    super(TwistySkewb.ROT_AXIS,cuts,rotatable,numLayers);
36 41
    }
37 42

  
38 43
///////////////////////////////////////////////////////////////////////////////////////////////////
......
44 49
// |  /  2  \  |
45 50
// -------------
46 51

  
47
  private int getQuarter(float[] touchPoint)
52
  void computeEnabledAxis(int face, float[] touchPoint, int[] enabled)
48 53
    {
49 54
    boolean p0 = touchPoint[1] >= touchPoint[0];
50 55
    boolean p1 = touchPoint[1] >=-touchPoint[0];
56
    int quarter = p0 ? (p1 ? 0:3) : (p1 ? 1:2);
51 57

  
52
    if( p0 )  return p1 ? 0:3;
53
    else      return p1 ? 1:2;
54
    }
55

  
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

  
58
  void computeEnabledAxis(int face, float[] touchPoint, int[] enabled)
59
    {
60
    enabled[0] = 2;
61

  
62
    int quarter = getQuarter(touchPoint);
63

  
64
    switch(face)
65
      {
66
      case 0: switch(quarter)
67
                {
68
                case 0: enabled[1]=0; enabled[2]=1; break;
69
                case 1: enabled[1]=3; enabled[2]=1; break;
70
                case 2: enabled[1]=2; enabled[2]=3; break;
71
                case 3: enabled[1]=0; enabled[2]=2; break;
72
                }
73
              break;
74
      case 1: switch(quarter)
75
                {
76
                case 0: enabled[1]=2; enabled[2]=3; break;
77
                case 1: enabled[1]=3; enabled[2]=1; break;
78
                case 2: enabled[1]=0; enabled[2]=1; break;
79
                case 3: enabled[1]=0; enabled[2]=2; break;
80
                }
81
              break;
82
      case 2: switch(quarter)
83
                {
84
                case 0: enabled[1]=1; enabled[2]=2; break;
85
                case 1: enabled[1]=0; enabled[2]=1; break;
86
                case 2: enabled[1]=0; enabled[2]=3; break;
87
                case 3: enabled[1]=2; enabled[2]=3; break;
88
                }
89
              break;
90
      case 3: switch(quarter)
91
                {
92
                case 0: enabled[1]=1; enabled[2]=2; break;
93
                case 1: enabled[1]=2; enabled[2]=3; break;
94
                case 2: enabled[1]=0; enabled[2]=3; break;
95
                case 3: enabled[1]=0; enabled[2]=1; break;
96
                }
97
              break;
98
      case 4: switch(quarter)
99
                {
100
                case 0: enabled[1]=0; enabled[2]=3; break;
101
                case 1: enabled[1]=0; enabled[2]=2; break;
102
                case 2: enabled[1]=1; enabled[2]=2; break;
103
                case 3: enabled[1]=1; enabled[2]=3; break;
104
                }
105
              break;
106
      case 5: switch(quarter)
107
                {
108
                case 0: enabled[1]=1; enabled[2]=2; break;
109
                case 1: enabled[1]=0; enabled[2]=2; break;
110
                case 2: enabled[1]=0; enabled[2]=3; break;
111
                case 3: enabled[1]=1; enabled[2]=3; break;
112
                }
113
              break;
114
      }
58
    enabled[0] = ENABLED[face][quarter][0];
59
    enabled[1] = ENABLED[face][quarter][1];
60
    enabled[2] = ENABLED[face][quarter][2];
115 61
    }
116 62
}
63

  
src/main/java/org/distorted/objects/MovementCube.java
23 23

  
24 24
class MovementCube extends Movement6
25 25
{
26
  MovementCube()
27
    {
28
    super(TwistyCube.ROT_AXIS);
29
    }
26
  private static final int[][][] ENABLED = new int[][][]
27
      {
28
          {{2,1,2}},{{2,1,2}},{{2,0,2}},{{2,0,2}},{{2,0,1}},{{2,0,1}},
29
      };
30 30

  
31 31
///////////////////////////////////////////////////////////////////////////////////////////////////
32 32

  
33
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
33
  MovementCube(float[][] cuts, boolean[][] rotatable, int numLayers)
34 34
    {
35
    return (int)(numLayers*(offset+DIST2D));
35
    super(TwistyCube.ROT_AXIS,cuts,rotatable,numLayers);
36 36
    }
37 37

  
38 38
///////////////////////////////////////////////////////////////////////////////////////////////////
39 39

  
40 40
  void computeEnabledAxis(int face, float[] touchPoint, int[] enabled)
41 41
    {
42
    enabled[0] = 2;
43

  
44
    switch(face/2)
45
      {
46
      case 0: enabled[1]=1; enabled[2]=2; break;
47
      case 1: enabled[1]=0; enabled[2]=2; break;
48
      case 2: enabled[1]=0; enabled[2]=1; break;
49
      }
42
    enabled[0] = ENABLED[face][0][0];
43
    enabled[1] = ENABLED[face][0][1];
44
    enabled[2] = ENABLED[face][0][2];
50 45
    }
51 46
}
src/main/java/org/distorted/objects/MovementDiamond.java
23 23

  
24 24
class MovementDiamond extends Movement8
25 25
{
26
  MovementDiamond()
26
  MovementDiamond(float[][] cuts, boolean[][] rotatable, int numLayers)
27 27
    {
28
    super(TwistyDiamond.ROT_AXIS);
29
    }
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32
// We have either one of the four faces (1,3,4,6) which, when the retAxis are cast onto it, they
33
// point the right way (and so the triangle then spans from offset=-SQ3/6 to offset=+SQ3/3 with
34
// midpoint at SQ3/12) or one of the other face when the cast rotAxis are the wrong way round (and
35
// the triangle spans then from 0 to SQ3/2 with midpoint at SQ3/4).
36

  
37
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
38
    {
39
    float off = ( face==1 || face==3 || face==4 || face==6 ) ? (offset+2*DIST2D) : (offset+DIST2D);
40
    return (int)(numLayers*off/(3*DIST2D));
28
    super(TwistyDiamond.ROT_AXIS,cuts,rotatable, numLayers);
41 29
    }
42 30

  
43 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementHelicopter.java
23 23

  
24 24
class MovementHelicopter extends Movement6
25 25
{
26
  MovementHelicopter()
26
  MovementHelicopter(float[][] cuts, boolean[][] rotatable, int numLayers)
27 27
    {
28
    super(TwistyHelicopter.ROT_AXIS);
29
    }
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

  
33
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
34
    {
35
    return offset<0 ? 0:2;
28
    super(TwistyHelicopter.ROT_AXIS,cuts,rotatable, numLayers);
36 29
    }
37 30

  
38 31
///////////////////////////////////////////////////////////////////////////////////////////////////
......
48 41
    {
49 42
    boolean p0 = touchPoint[0] > 0;
50 43
    boolean p1 = touchPoint[1] > 0;
51

  
52 44
    return p0 ? (p1 ? 0:1) : (p1 ? 3:2);
53 45
    }
54 46

  
src/main/java/org/distorted/objects/MovementIvy.java
23 23

  
24 24
class MovementIvy extends Movement6
25 25
{
26
  MovementIvy()
26
  MovementIvy(float[][] cuts, boolean[][] rotatable, int numLayers)
27 27
    {
28
    super(TwistyIvy.ROT_AXIS);
29
    }
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

  
33
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
34
    {
35
    return offset<0 ? 0:1;
28
    super(TwistyIvy.ROT_AXIS,cuts,rotatable,numLayers);
36 29
    }
37 30

  
38 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementJing.java
19 19

  
20 20
package org.distorted.objects;
21 21

  
22
import static org.distorted.objects.TwistyJing.F;
23

  
24 22
///////////////////////////////////////////////////////////////////////////////////////////////////
25 23

  
26 24
class MovementJing extends Movement4
27 25
{
28
  MovementJing()
29
    {
30
    super(TwistyJing.ROT_AXIS);
31
    }
32

  
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34

  
35
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
26
  MovementJing(float[][] cuts, boolean[][] rotatable, int numLayers)
36 27
    {
37
    return offset+DIST2D < (SQ3/4)*F ? 0:1;
28
    super(TwistyJing.ROT_AXIS,cuts,rotatable,numLayers);
38 29
    }
39 30

  
40 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementMinx.java
23 23

  
24 24
class MovementMinx extends Movement12
25 25
{
26
  MovementMinx()
26
  MovementMinx(float[][] cuts, boolean[][] rotatable, int numLayers)
27 27
    {
28
    super(TwistyMinx.ROT_AXIS);
29
    }
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

  
33
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
34
    {
35
    if( numLayers==3 )
36
      {
37
      return offset<0 ? 0:2;
38
      }
39
    if( numLayers==5 )
40
      {
41
      float quot = offset / DIST2D;
42

  
43
      if( quot>-1.00f && quot<=-0.66f ) return 0;
44
      if( quot>-0.66f && quot<= 0.00f ) return 1;
45
      if( quot> 0.00f && quot<= 0.66f ) return 3;
46
      if( quot> 0.66f && quot<= 1.00f ) return 4;
47
      }
48

  
49
    return 0;
28
    super(TwistyMinx.ROT_AXIS,cuts,rotatable,numLayers);
50 29
    }
51 30

  
52 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementPyraminx.java
23 23

  
24 24
class MovementPyraminx extends Movement4
25 25
{
26
  MovementPyraminx()
26
  MovementPyraminx(float[][] cuts, boolean[][] rotatable,int numLayers)
27 27
    {
28
    super(TwistyPyraminx.ROT_AXIS);
29
    }
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

  
33
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
34
    {
35
    return (int)(numLayers*(offset+DIST2D)/(3*DIST2D));
28
    super(TwistyPyraminx.ROT_AXIS,cuts,rotatable,numLayers);
36 29
    }
37 30

  
38 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementSquare.java
23 23

  
24 24
class MovementSquare extends Movement6
25 25
{
26
  MovementSquare()
26
  MovementSquare(float[][] cuts, boolean[][] rotatable, int numLayers)
27 27
    {
28
    super(TwistySquare.ROT_AXIS);
29
    }
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

  
33
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
34
    {
35
    return offset<0 ? 0 : 2-axisIndex;
28
    super(TwistySquare.ROT_AXIS,cuts,rotatable,numLayers);
36 29
    }
37 30

  
38 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementUltimate.java
23 23

  
24 24
class MovementUltimate extends Movement12
25 25
{
26
  MovementUltimate()
26
  MovementUltimate(float[][] cuts, boolean[][] rotatable, int numLayers)
27 27
    {
28
    super(TwistyUltimate.ROT_AXIS);
29
    }
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

  
33
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
34
    {
35
    return offset<0 ? 0:1;
28
    super(TwistyUltimate.ROT_AXIS,cuts,rotatable,numLayers);
36 29
    }
37 30

  
38 31
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyBandagedAbstract.java
59 59
  private Static4D[] mInitQuats;
60 60
  private int[][] mAxisMap;
61 61
  private int[][] mFaceMap;
62
  private float[][] mCuts;
63
  private boolean[][] mLayerRotatable;
62 64
  private Movement mMovement;
63 65
  ScrambleState[] mStates;
64 66
  float[][] POSITIONS;
......
313 315

  
314 316
  float[][] getCuts(int numLayers)
315 317
    {
316
    float[][] cuts = new float[3][numLayers-1];
318
    if( numLayers<2 ) return null;
317 319

  
318
    for(int i=0; i<numLayers-1; i++)
320
    if( mCuts==null )
319 321
      {
320
      float cut = (2-numLayers)*0.5f + i;
321
      cuts[0][i] = cut;
322
      cuts[1][i] = cut;
323
      cuts[2][i] = cut;
322
      mCuts = new float[3][numLayers-1];
323

  
324
      for(int i=0; i<numLayers-1; i++)
325
        {
326
        float cut = (2-numLayers)*0.5f + i;
327
        mCuts[0][i] = cut;
328
        mCuts[1][i] = cut;
329
        mCuts[2][i] = cut;
330
        }
324 331
      }
325 332

  
326
    return cuts;
333
    return mCuts;
334
    }
335

  
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337

  
338
  private void getLayerRotatable(int numLayers)
339
    {
340
    if( mLayerRotatable==null )
341
      {
342
      int numAxis = ROT_AXIS.length;
343
      boolean[] tmp = new boolean[numLayers];
344
      for(int i=0; i<numLayers; i++) tmp[i] = true;
345
      mLayerRotatable = new boolean[numAxis][];
346
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
347
      }
327 348
    }
328 349

  
329 350
///////////////////////////////////////////////////////////////////////////////////////////////////
......
431 452

  
432 453
  public Movement getMovement()
433 454
    {
434
    if( mMovement==null ) mMovement = new MovementCube();
455
    if( mMovement==null )
456
      {
457
      int numLayers = getNumLayers();
458
      if( mCuts==null ) getCuts(numLayers);
459
      getLayerRotatable(numLayers);
460

  
461
      mMovement = new MovementCube(mCuts,mLayerRotatable,numLayers);
462
      }
435 463
    return mMovement;
436 464
    }
437 465

  
src/main/java/org/distorted/objects/TwistyCube.java
44 44

  
45 45
  private ScrambleState[] mStates;
46 46
  private Static4D[] mQuats;
47
  private float[][] mCuts;
48
  private boolean[][] mLayerRotatable;
47 49
  private int[] mBasicAngle;
48 50
  private ObjectSticker[] mStickers;
49 51
  private Movement mMovement;
......
275 277

  
276 278
  float[][] getCuts(int numLayers)
277 279
    {
278
    float[][] cuts = new float[3][numLayers-1];
280
    if( numLayers<2 ) return null;
279 281

  
280
    for(int i=0; i<numLayers-1; i++)
282
    if( mCuts==null )
281 283
      {
282
      float cut = (2-numLayers)*0.5f + i;
283
      cuts[0][i] = cut;
284
      cuts[1][i] = cut;
285
      cuts[2][i] = cut;
284
      mCuts = new float[3][numLayers-1];
285

  
286
      for(int i=0; i<numLayers-1; i++)
287
        {
288
        float cut = (2-numLayers)*0.5f + i;
289
        mCuts[0][i] = cut;
290
        mCuts[1][i] = cut;
291
        mCuts[2][i] = cut;
292
        }
286 293
      }
287 294

  
288
    return cuts;
295
    return mCuts;
296
    }
297

  
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299

  
300
  private void getLayerRotatable(int numLayers)
301
    {
302
    if( mLayerRotatable==null )
303
      {
304
      int numAxis = ROT_AXIS.length;
305
      boolean[] tmp = new boolean[numLayers];
306
      for(int i=0; i<numLayers; i++) tmp[i] = true;
307
      mLayerRotatable = new boolean[numAxis][];
308
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
309
      }
289 310
    }
290 311

  
291 312
///////////////////////////////////////////////////////////////////////////////////////////////////
......
328 349

  
329 350
  public Movement getMovement()
330 351
    {
331
    if( mMovement==null ) mMovement = new MovementCube();
352
    if( mMovement==null )
353
      {
354
      int numLayers = getNumLayers();
355
      if( mCuts==null ) getCuts(numLayers);
356
      getLayerRotatable(numLayers);
357

  
358
      mMovement = new MovementCube(mCuts,mLayerRotatable,numLayers);
359
      }
332 360
    return mMovement;
333 361
    }
334 362

  
src/main/java/org/distorted/objects/TwistyDiamond.java
47 47
  private ScrambleState[] mStates;
48 48
  private int[] mBasicAngle;
49 49
  private int[] mFaceMap;
50
  private float[][] mCuts;
51
  private boolean[][] mLayerRotatable;
50 52
  private Static4D[] mQuats;
51 53
  private int[] mTetraToFaceMap;
52 54
  private ObjectSticker[] mStickers;
......
143 145

  
144 146
  float[][] getCuts(int numLayers)
145 147
    {
146
    if( numLayers<2 )
147
      {
148
      return null;
149
      }
150
    else
148
    if( numLayers<2 ) return null;
149

  
150
    if( mCuts==null )
151 151
      {
152
      float[][] cuts = new float[4][numLayers-1];
153
      float dist = SQ6/3;
154
      float cut  = 0.5f*dist*(2-numLayers);
152
      mCuts = new float[4][numLayers-1];
153
      float cut = (SQ6/6)*(2-numLayers);
155 154

  
156 155
      for(int i=0; i<numLayers-1; i++)
157 156
        {
158
        cuts[0][i] = cut;
159
        cuts[1][i] = cut;
160
        cuts[2][i] = cut;
161
        cuts[3][i] = cut;
162
        cut += dist;
157
        mCuts[0][i] = cut;
158
        mCuts[1][i] = cut;
159
        mCuts[2][i] = cut;
160
        mCuts[3][i] = cut;
161
        cut += SQ6/3;
163 162
        }
163
      }
164

  
165
    return mCuts;
166
    }
164 167

  
165
      return cuts;
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169

  
170
  private void getLayerRotatable(int numLayers)
171
    {
172
    if( mLayerRotatable==null )
173
      {
174
      int numAxis = ROT_AXIS.length;
175
      boolean[] tmp = new boolean[numLayers];
176
      for(int i=0; i<numLayers; i++) tmp[i] = true;
177
      mLayerRotatable = new boolean[numAxis][];
178
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
166 179
      }
167 180
    }
168 181

  
......
479 492

  
480 493
  public Movement getMovement()
481 494
    {
482
    if( mMovement==null ) mMovement = new MovementDiamond();
495
    if( mMovement==null )
496
      {
497
      int numLayers = getNumLayers();
498
      if( mCuts==null ) getCuts(numLayers);
499
      getLayerRotatable(numLayers);
500

  
501
      mMovement = new MovementDiamond(mCuts,mLayerRotatable,numLayers);
502
      }
483 503
    return mMovement;
484 504
    }
485 505

  
src/main/java/org/distorted/objects/TwistyDino.java
45 45

  
46 46
  private int[] mBasicAngle;
47 47
  private Static4D[] mQuats;
48
  private float[][] mCuts;
49
  private boolean[][] mLayerRotatable;
48 50
  private ObjectSticker[] mStickers;
49 51
  private float[][] mCenters;
50 52
  private Movement mMovement;
......
91 93

  
92 94
  float[][] getCuts(int size)
93 95
    {
94
    float[] cut = new float[] { -SQ3/3, +SQ3/3 };
95
    return new float[][] { cut,cut,cut,cut };
96
    if( mCuts==null )
97
      {
98
      float[] cut = new float[] { -SQ3/3, +SQ3/3 };
99
      mCuts = new float[][] { cut,cut,cut,cut };
100
      }
101

  
102
    return mCuts;
103
    }
104

  
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106

  
107
  private void getLayerRotatable(int numLayers)
108
    {
109
    if( mLayerRotatable==null )
110
      {
111
      int numAxis = ROT_AXIS.length;
112
      boolean[] tmp = new boolean[] {true,false,true};
113
      mLayerRotatable = new boolean[numAxis][];
114
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
115
      }
96 116
    }
97 117

  
98 118
///////////////////////////////////////////////////////////////////////////////////////////////////
......
201 221

  
202 222
  public Movement getMovement()
203 223
    {
204
    if( mMovement==null ) mMovement = new MovementCornerTwisting();
224
    if( mMovement==null )
225
      {
226
      int numLayers = getNumLayers();
227
      if( mCuts==null ) getCuts(numLayers);
228
      getLayerRotatable(numLayers);
229

  
230
      mMovement = new MovementCornerTwisting(mCuts,mLayerRotatable,numLayers);
231
      }
205 232
    return mMovement;
206 233
    }
207 234

  
src/main/java/org/distorted/objects/TwistyHelicopter.java
49 49
  private ScrambleState[] mStates;
50 50
  private int[] mBasicAngle;
51 51
  private Static4D[] mQuats;
52
  private float[][] mCuts;
53
  private boolean[][] mLayerRotatable;
52 54
  private float[][] mCenters;
53 55
  private int[] mQuatIndices;
54 56
  private int[][] mFaceMap;
......
160 162

  
161 163
  float[][] getCuts(int size)
162 164
    {
163
    float[] cut = new float[] { -3*SQ2/4, +3*SQ2/4 };
164
    return new float[][] { cut,cut,cut,cut,cut,cut };
165
    if( mCuts==null )
166
      {
167
      float[] cut = new float[] { -3*SQ2/4, +3*SQ2/4 };
168
      mCuts = new float[][] { cut,cut,cut,cut,cut,cut };
169
      }
170

  
171
    return mCuts;
172
    }
173

  
174
///////////////////////////////////////////////////////////////////////////////////////////////////
175

  
176
  private void getLayerRotatable(int numLayers)
177
    {
178
    if( mLayerRotatable==null )
179
      {
180
      int numAxis = ROT_AXIS.length;
181
      boolean[] tmp = new boolean[] {true,false,true};
182
      mLayerRotatable = new boolean[numAxis][];
183
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
184
      }
165 185
    }
166 186

  
167 187
///////////////////////////////////////////////////////////////////////////////////////////////////
......
394 414

  
395 415
  public Movement getMovement()
396 416
    {
397
    if( mMovement==null ) mMovement = new MovementHelicopter();
417
    if( mMovement==null )
418
      {
419
      int numLayers = getNumLayers();
420
      if( mCuts==null ) getCuts(numLayers);
421
      getLayerRotatable(numLayers);
422

  
423
      mMovement = new MovementHelicopter(mCuts,mLayerRotatable,numLayers);
424
      }
398 425
    return mMovement;
399 426
    }
400 427

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

  
137 139
  float[][] getCuts(int numLayers)
138 140
    {
139
    float[] cut = new float[] {0.0f};
140
    return new float[][] { cut,cut,cut,cut };
141
    if( mCuts==null )
142
      {
143
      float[] cut = new float[] {0.0f};
144
      mCuts = new float[][] { cut,cut,cut,cut };
145
      }
146

  
147
    return mCuts;
148
    }
149

  
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151

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

  
143 164
///////////////////////////////////////////////////////////////////////////////////////////////////
......
420 441

  
421 442
  public Movement getMovement()
422 443
    {
423
    if( mMovement==null ) mMovement = new MovementIvy();
444
    if( mMovement==null )
445
      {
446
      int numLayers = getNumLayers();
447
      if( mCuts==null ) getCuts(numLayers);
448
      getLayerRotatable(numLayers);
449

  
450
      mMovement = new MovementIvy(mCuts,mLayerRotatable,numLayers);
451
      }
424 452
    return mMovement;
425 453
    }
426 454

  
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

  
src/main/java/org/distorted/objects/TwistyKilominx.java
90 90

  
91 91
  float[][] getCuts(int numLayers)
92 92
    {
93
    float[][] cuts = new float[6][numLayers-1];
94
    float D = numLayers*MovementMinx.DIST3D;
95
    float E = 2*SIN54;
96
    float X = 2*D*E/(1+2*E);  // height of the 'upper' part of a dodecahedron, i.e. put it on a table,
97
                              // its height is then D*2*DIST3D, it has one 'lower' part of height X, one
98
                              // 'middle' part of height Y and one upper part of height X again.
99
                              // It's edge length = numLayers/3.0f.
100
    int num = (numLayers-1)/2;
101
    float G = X*0.5f/num;     // height of one Layer
102

  
103
    for(int i=0; i<num; i++)
104
      {
105
      float cut = -D + (i+0.5f)*G;
106
      int j = 2*num-1-i;
107
      cuts[0][i] = +cut;
108
      cuts[0][j] = -cut;
109
      cuts[1][i] = +cut;
110
      cuts[1][j] = -cut;
111
      cuts[2][i] = +cut;
112
      cuts[2][j] = -cut;
113
      cuts[3][i] = +cut;
114
      cuts[3][j] = -cut;
115
      cuts[4][i] = +cut;
116
      cuts[4][j] = -cut;
117
      cuts[5][i] = +cut;
118
      cuts[5][j] = -cut;
119
      }
120

  
121
    return cuts;
93
    return genericGetCuts(numLayers,0.5f);
122 94
    }
123 95

  
124 96
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyMegaminx.java
77 77

  
78 78
  float[][] getCuts(int numLayers)
79 79
    {
80
    float[][] cuts = new float[6][numLayers-1];
81
    float D = numLayers*MovementMinx.DIST3D;
82
    float E = 2*SIN54;
83
    float X = 2*D*E/(1+2*E);  // height of the 'upper' part of a dodecahedron, i.e. put it on a table,
84
                              // its height is then D*2*DIST3D, it has one 'lower' part of height X, one
85
                              // 'middle' part of height Y and one upper part of height X again.
86
                              // It's edge length = numLayers/3.0f.
87
    int num = (numLayers-1)/2;
88
    float G = X*(0.5f-MEGA_D)/num; // height of one Layer
89

  
90
    for(int i=0; i<num; i++)
91
      {
92
      float cut = -D + (i+0.5f)*G;
93
      int j = 2*num-1-i;
94
      cuts[0][i] = +cut;
95
      cuts[0][j] = -cut;
96
      cuts[1][i] = +cut;
97
      cuts[1][j] = -cut;
98
      cuts[2][i] = +cut;
99
      cuts[2][j] = -cut;
100
      cuts[3][i] = +cut;
101
      cuts[3][j] = -cut;
102
      cuts[4][i] = +cut;
103
      cuts[4][j] = -cut;
104
      cuts[5][i] = +cut;
105
      cuts[5][j] = -cut;
106
      }
107

  
108
    return cuts;
80
    return genericGetCuts(numLayers,0.5f-MEGA_D);
109 81
    }
110 82

  
111 83
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyMinx.java
60 60
  private ScrambleState[] mStates;
61 61
  private int[] mBasicAngle;
62 62
  private int[] mFaceMap;
63
  private float[][] mCuts;
64
  private boolean[][] mLayerRotatable;
63 65
  private Movement mMovement;
64 66
  Static4D[] mQuats;
65 67
  float[][] mCenterCoords;
......
504 506
    if( mQuats==null ) initializeQuats();
505 507
    return mQuats;
506 508
    }
509
///////////////////////////////////////////////////////////////////////////////////////////////////
510

  
511
  float[][] genericGetCuts(int numLayers, float dist)
512
    {
513
    if( mCuts==null )
514
      {
515
      mCuts = new float[6][numLayers-1];
516
      float D = numLayers*MovementMinx.DIST3D;
517
      float E = 2*SIN54;
518
      float X = 2*D*E/(1+2*E);  // height of the 'upper' part of a dodecahedron, i.e. put it on a table,
519
                                // its height is then D*2*DIST3D, it has one 'lower' part of height X, one
520
                                // 'middle' part of height Y and one upper part of height X again.
521
                                // It's edge length = numLayers/3.0f.
522
      int num = (numLayers-1)/2;
523
      float G = X*dist/num;     // height of one Layer
524

  
525
      for(int i=0; i<num; i++)
526
        {
527
        float cut = -D + (i+0.5f)*G;
528
        int j = 2*num-1-i;
529
        mCuts[0][i] = +cut;
530
        mCuts[0][j] = -cut;
531
        mCuts[1][i] = +cut;
532
        mCuts[1][j] = -cut;
533
        mCuts[2][i] = +cut;
534
        mCuts[2][j] = -cut;
535
        mCuts[3][i] = +cut;
536
        mCuts[3][j] = -cut;
537
        mCuts[4][i] = +cut;
538
        mCuts[4][j] = -cut;
539
        mCuts[5][i] = +cut;
540
        mCuts[5][j] = -cut;
541
        }
542
      }
543

  
544
    return mCuts;
545
    }
546

  
547
///////////////////////////////////////////////////////////////////////////////////////////////////
548

  
549
  private void getLayerRotatable(int numLayers)
550
    {
551
    if( mLayerRotatable==null )
552
      {
553
      int numAxis = ROT_AXIS.length;
554
      boolean[] tmp = new boolean[numLayers];
555
      for(int i=0; i<numLayers; i++) tmp[i] = true;
556
      tmp[numLayers/2] = false;
557
      mLayerRotatable = new boolean[numAxis][];
558
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
559
      }
560
    }
507 561

  
508 562
///////////////////////////////////////////////////////////////////////////////////////////////////
509 563

  
......
531 585

  
532 586
  public Movement getMovement()
533 587
    {
534
    if( mMovement==null ) mMovement = new MovementMinx();
588
    if( mMovement==null )
589
      {
590
      int numLayers = getNumLayers();
591
      if( mCuts==null ) getCuts(numLayers);
592
      getLayerRotatable(numLayers);
593

  
594
      mMovement = new MovementMinx(mCuts,mLayerRotatable,numLayers);
595
      }
535 596
    return mMovement;
536 597
    }
537 598

  
src/main/java/org/distorted/objects/TwistyMirror.java
49 49

  
50 50
  private ScrambleState[] mStates;
51 51
  private Static4D[] mQuats;
52
  private float[][] mCuts;
53
  private boolean[][] mLayerRotatable;
52 54
  private int[] mBasicAngle;
53 55
  private ObjectSticker[] mStickers;
54 56
  private float[][] mPositions;
......
591 593

  
592 594
  float[][] getCuts(int numLayers)
593 595
    {
594
    float[][] cuts = new float[3][numLayers-1];
595

  
596
    for(int i=0; i<numLayers-1; i++)
596
    if( mCuts==null )
597 597
      {
598
      float cut = (2-numLayers)*0.5f + i;
599
      cuts[0][i] = cut;
600
      cuts[1][i] = cut;
601
      cuts[2][i] = cut;
598
      mCuts = new float[3][numLayers-1];
599

  
600
      for(int i=0; i<numLayers-1; i++)
601
        {
602
        float cut = (2-numLayers)*0.5f + i;
603
        mCuts[0][i] = cut;
604
        mCuts[1][i] = cut;
605
        mCuts[2][i] = cut;
606
        }
602 607
      }
603 608

  
604
    return cuts;
609
    return mCuts;
610
    }
611

  
612
///////////////////////////////////////////////////////////////////////////////////////////////////
613

  
614
  private void getLayerRotatable(int numLayers)
615
    {
616
    if( mLayerRotatable==null )
617
      {
618
      int numAxis = ROT_AXIS.length;
619
      boolean[] tmp = new boolean[numLayers];
620
      for(int i=0; i<numLayers; i++) tmp[i] = true;
621
      mLayerRotatable = new boolean[numAxis][];
622
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
623
      }
605 624
    }
606 625

  
607 626
///////////////////////////////////////////////////////////////////////////////////////////////////
......
630 649

  
631 650
  public Movement getMovement()
632 651
    {
633
    if( mMovement==null ) mMovement = new MovementCube();
652
    if( mMovement==null )
653
      {
654
      int numLayers = getNumLayers();
655
      if( mCuts==null ) getCuts(numLayers);
656
      getLayerRotatable(numLayers);
657

  
658
      mMovement = new MovementCube(mCuts,mLayerRotatable,numLayers);
659
      }
634 660
    return mMovement;
635 661
    }
636 662

  
src/main/java/org/distorted/objects/TwistyPyraminx.java
46 46
  private ScrambleState[] mStates;
47 47
  private int[] mBasicAngle;
48 48
  private Static4D[] mQuats;
49
  private float[][] mCuts;
50
  private boolean[][] mLayerRotatable;
49 51
  private ObjectSticker[] mStickers;
50 52
  private Movement mMovement;
51 53

  
......
214 216

  
215 217
  float[][] getCuts(int numLayers)
216 218
    {
217
    float[][] cuts = new float[4][numLayers-1];
218

  
219
    for(int i=0; i<numLayers-1; i++)
219
    if( mCuts==null )
220 220
      {
221
      float cut = (1.0f+i-numLayers/3.0f)*(SQ6/3);
222
      cuts[0][i] = cut;
223
      cuts[1][i] = cut;
224
      cuts[2][i] = cut;
225
      cuts[3][i] = cut;
221
      mCuts = new float[4][numLayers-1];
222

  
223
      for(int i=0; i<numLayers-1; i++)
224
        {
225
        float cut = (1.0f+i-numLayers/3.0f)*(SQ6/3);
226
        mCuts[0][i] = cut;
227
        mCuts[1][i] = cut;
228
        mCuts[2][i] = cut;
229
        mCuts[3][i] = cut;
230
        }
226 231
      }
227 232

  
228
    return cuts;
233
    return mCuts;
234
    }
235

  
236
///////////////////////////////////////////////////////////////////////////////////////////////////
237

  
238
  private void getLayerRotatable(int numLayers)
239
    {
240
    if( mLayerRotatable==null )
241
      {
242
      int numAxis = ROT_AXIS.length;
243
      boolean[] tmp = new boolean[numLayers];
244
      for(int i=0; i<numLayers; i++) tmp[i] = true;
245
      mLayerRotatable = new boolean[numAxis][];
246
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
247
      }
229 248
    }
230 249

  
231 250
///////////////////////////////////////////////////////////////////////////////////////////////////
......
357 376

  
358 377
  public Movement getMovement()
359 378
    {
360
    if( mMovement==null ) mMovement = new MovementPyraminx();
379
    if( mMovement==null )
380
      {
381
      int numLayers = getNumLayers();
382
      if( mCuts==null ) getCuts(numLayers);
383
      getLayerRotatable(numLayers);
384

  
385
      mMovement = new MovementPyraminx(mCuts,mLayerRotatable,numLayers);
386
      }
361 387
    return mMovement;
362 388
    }
363 389

  
src/main/java/org/distorted/objects/TwistyRedi.java
46 46
  private ScrambleState[] mStates;
47 47
  private int[] mBasicAngle;
48 48
  private Static4D[] mQuats;
49
  private float[][] mCuts;
50
  private boolean[][] mLayerRotatable;
49 51
  private float[][] mCenters;
50 52
  private int[][] mFaceMap;
51 53
  private ObjectSticker[] mStickers;
......
139 141

  
140 142
  float[][] getCuts(int size)
141 143
    {
142
    float C = +SQ3/3 +0.05f;
143
    float[] cut = new float[] {-C,+C};
144
    return new float[][] { cut,cut,cut,cut };
144
    if( mCuts==null )
145
      {
146
      float C = +SQ3/3 +0.05f;
147
      float[] cut = new float[] {-C,+C};
148
      mCuts = new float[][] { cut,cut,cut,cut };
149
      }
150

  
151
    return mCuts;
152
    }
153

  
154
///////////////////////////////////////////////////////////////////////////////////////////////////
155

  
156
  private void getLayerRotatable(int numLayers)
157
    {
158
    if( mLayerRotatable==null )
159
      {
160
      int numAxis = ROT_AXIS.length;
161
      boolean[] tmp = new boolean[] {true,false,true};
162
      mLayerRotatable = new boolean[numAxis][];
163
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
164
      }
145 165
    }
146 166

  
147 167
///////////////////////////////////////////////////////////////////////////////////////////////////
......
391 411

  
392 412
  public Movement getMovement()
393 413
    {
394
    if( mMovement==null ) mMovement = new MovementCornerTwisting();
414
    if( mMovement==null )
415
      {
416
      int numLayers = getNumLayers();
417
      if( mCuts==null ) getCuts(numLayers);
418
      getLayerRotatable(numLayers);
419

  
420
      mMovement = new MovementCornerTwisting(mCuts,mLayerRotatable,numLayers);
421
      }
395 422
    return mMovement;
396 423
    }
397 424

  
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
      }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff