Project

General

Profile

« Previous | Next » 

Revision bc008758

Added by Leszek Koltunski about 2 years ago

Crazy Planets: progress

View differences:

src/main/java/org/distorted/objectlib/main/TwistyObject.java
151 151
  private int[][] mBasicAngles;
152 152
  private int mIconMode;
153 153
  private final InitData mInitData;
154
  private float[][] mRowOffset;
154 155

  
155 156
  //////////////////// SOLVED1 ////////////////////////
156 157

  
......
209 210
    mNumCubits = mOrigPos.length;
210 211
    mNumFaceColors = getNumFaceColors();
211 212
    mNumAxis = mAxis.length;
213
    mRowOffset = getRowOffset();
212 214

  
213 215
    int scramblingType = getScrambleType();
214 216
    ScrambleState[] states = getScrambleStates();
......
409 411

  
410 412
    for(int i=0; i<mNumCubits; i++)
411 413
      {
412
      mCubits[i] = new Cubit(this,mOrigPos[i], mNumAxis);
414
      mCubits[i] = new Cubit(this,mOrigPos[i], mNumAxis,i);
413 415
      setCubitQuat(i,mCubits[i].computeAssociation(),0);
414 416
      }
415 417
    }
......
711 713
    return null;
712 714
    }
713 715

  
716
///////////////////////////////////////////////////////////////////////////////////////////////////
717

  
718
  public float[][] getRowOffset()
719
    {
720
    return new float[mNumCubits][3];
721
    }
722

  
714 723
///////////////////////////////////////////////////////////////////////////////////////////////////
715 724

  
716 725
  public int[][] getSolvedQuats()
......
932 941

  
933 942
///////////////////////////////////////////////////////////////////////////////////////////////////
934 943

  
935
  int computeRow(float[] pos, int axisIndex)
944
  int computeRow(float[] pos, int axisIndex, int cubitIndex)
936 945
    {
937 946
    int ret=0;
938 947
    int len = pos.length / 3;
......
942 951
    float axisZ = axis.get2();
943 952
    float casted;
944 953

  
954
    float xoff = mRowOffset[cubitIndex][0];
955
    float yoff = mRowOffset[cubitIndex][1];
956
    float zoff = mRowOffset[cubitIndex][2];
957

  
945 958
    for(int i=0; i<len; i++)
946 959
      {
947
      casted = pos[3*i]*axisX + pos[3*i+1]*axisY + pos[3*i+2]*axisZ;
960
      casted = (pos[3*i]+xoff)*axisX + (pos[3*i+1]+yoff)*axisY + (pos[3*i+2]+zoff)*axisZ;
948 961
      ret |= computeSingleRow(axisIndex,casted);
949 962
      }
950 963

  
......
1076 1089
// Clamp all rotated positions to one of those original ones to avoid accumulating errors.
1077 1090
// Do so only if minimal Error is appropriately low (shape-shifting puzzles - Square-1)
1078 1091

  
1079
  void clampPos(float[] pos, int offset)
1092
  int clampPos(float[] pos, int offset)
1080 1093
    {
1081 1094
    float currError, minError = Float.MAX_VALUE;
1082 1095
    int minErrorIndex1 = -1;
......
1114 1127
      pos[offset  ] = mOrigPos[minErrorIndex1][3*minErrorIndex2  ];
1115 1128
      pos[offset+1] = mOrigPos[minErrorIndex1][3*minErrorIndex2+1];
1116 1129
      pos[offset+2] = mOrigPos[minErrorIndex1][3*minErrorIndex2+2];
1130
      return minErrorIndex1;
1117 1131
      }
1132

  
1133
    return 0;
1118 1134
    }
1119 1135

  
1120 1136
///////////////////////////////////////////////////////////////////////////////////////////////////
......
1467 1483

  
1468 1484
      for(int s=0; s<numStickers; s++)
1469 1485
        {
1470
        float scale = mStickerScales[s];
1486
        float scale = mStickerScales.length>s ? mStickerScales[s] : 1.0f;
1471 1487
        float radius = rad / scale;
1472 1488
        float stroke = str / scale;
1473 1489
        int len = mStickerCoords[s].length/2;

Also available in: Unified diff