Project

General

Profile

« Previous | Next » 

Revision 074a0284

Added by Leszek Koltunski 4 months ago

Support for the new default detection of solved state done. Something seems to be working.

View differences:

src/main/java/org/distorted/objectlib/objects/TwistyBandagedAbstract.java
109 109
    return mPosition;
110 110
    }
111 111

  
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113
// If we have a flat cuboid than retCubitSolvedStatus() wrongly reports that the internal cubits
114
// are edges (they do have two non-black faces after all!) which leads to wrong solvedQuats and
115
// mis-detection of a solved status. Correct this manually here.
116
//
117
// Note that this is still not completely good in case of bandaged cuboids - there can be a 4x4x2
118
// bandaged cuboid whose 4 'internal' cubits from the 4x4 face are fused with the other 4 internal
119
// cubits from the other 4x4 face - and those would again get mis-detected as edges...
120

  
121
  @Override
122
  public int[][] getSolvedQuats()
123
    {
124
    if( mSolvedQuatsAbstract==null )
125
      {
126
      int[] numLayers = getNumLayers();
127
      float dx = 0.5f*(numLayers[0]-1) - 0.1f;
128
      float dy = 0.5f*(numLayers[1]-1) - 0.1f;
129
      float dz = 0.5f*(numLayers[2]-1) - 0.1f;
130

  
131
      float[][] pos = getPositions();
132
      int numTotal = pos.length;
133
      boolean[] isExternal = new boolean[numTotal];
134
      int[] internalQuat = new int[numTotal];
135
      int numExternal = 0;
136
      int pointer = 0;
137

  
138
      for(int cubit=0; cubit<numTotal; cubit++)
139
        {
140
        int q = cubitIsExternal(pos[cubit],dx,dy,dz);
141

  
142
        if( q<=0 )
143
          {
144
          isExternal[cubit] = true;
145
          numExternal++;
146
          }
147
        else
148
          {
149
          isExternal[cubit] = false;
150
          internalQuat[pointer] = q;
151
          pointer++;
152
          }
153
        }
154

  
155
      int numInternal = numTotal - numExternal;
156

  
157
      mSolvedQuatsAbstract = new int[numInternal+1][];
158
      mSolvedQuatsAbstract[0] = new int[numExternal+1];
159
      mSolvedQuatsAbstract[0][0] = numExternal;
160

  
161
      for(int i=0; i<numInternal; i++)
162
        {
163
        int q = internalQuat[i];
164
        mSolvedQuatsAbstract[i+1] = new int[5];
165
        mSolvedQuatsAbstract[i+1][0] = 1;
166
        mSolvedQuatsAbstract[i+1][2] = q;
167
        mSolvedQuatsAbstract[i+1][3] = q+1;
168
        mSolvedQuatsAbstract[i+1][4] = q+2;
169
        }
170

  
171
      int pointerExternal = 1;
172
      int pointerInternal = 1;
173

  
174
      for(int cubit=0; cubit<numTotal; cubit++)
175
        {
176
        if( isExternal[cubit] ) mSolvedQuatsAbstract[0][pointerExternal++] = cubit;
177
        else                    mSolvedQuatsAbstract[pointerInternal++][1] = cubit;
178
        }
179
      }
180

  
181
    return mSolvedQuatsAbstract;
182
    }
183

  
184 112
///////////////////////////////////////////////////////////////////////////////////////////////////
185 113

  
186 114
  public float[][] getCuts(int[] numLayers)

Also available in: Unified diff