Project

General

Profile

« Previous | Next » 

Revision f0450fcc

Added by Leszek Koltunski about 3 years ago

Change Cubit.mRotationRow[] from an index pointing at a single rotating layer to a bitmap potentially pointing at several layers.
(in preparation for bandaged objects)

View differences:

src/main/java/org/distorted/objects/Cubit.java
159 159

  
160 160
    for(int axis=0; axis<mNumAxis; axis++)
161 161
      {
162
      result += (1<<(mRotationRow[axis]+accumulativeShift));
162
      result += (mRotationRow[axis]<<accumulativeShift);
163 163
      accumulativeShift += ObjectList.MAX_OBJECT_SIZE;
164 164
      }
165 165

  
src/main/java/org/distorted/objects/TwistyBandagedAbstract.java
306 306
    int dimIndex     = mAxisMap[posIndex][quatIndex];
307 307
    boolean reaches  = multiplier*pos[posIndex] + dim[dimIndex]*0.5f > (numLayers-1)*0.5f;
308 308

  
309
    int ret=  reaches ? stickerIndex*NUM_FACES + face : NUM_STICKERS*NUM_FACES;
310

  
311
if( cubit==0 )
312
  {
313
android.util.Log.e("DISTORTED", "cubit="+cubit+" cubitface="+cubitface+" ret="+ret+" stickerIndex="+stickerIndex+" face="+face);
314
android.util.Log.e("DISTORTED", "reaches="+reaches+" border="+((numLayers-1)*0.5f)+" left="+(multiplier*pos[posIndex] + dim[dimIndex]*0.5f));
315
android.util.Log.e("DISTORTED", "posIndex="+posIndex+" dimIndex="+dimIndex);
316

  
317
  }
318
    return ret;
309
    return reaches ? stickerIndex*NUM_FACES + face : NUM_STICKERS*NUM_FACES;
319 310
    }
320 311

  
321 312
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyCube.java
215 215

  
216 216
  int getFaceColor(int cubit, int cubitface, int size)
217 217
    {
218
    return CUBITS[cubit].mRotationRow[cubitface/2] == (cubitface%2==0 ? size-1:0) ? cubitface : NUM_FACES;
218
    return CUBITS[cubit].mRotationRow[cubitface/2] == (cubitface%2==0 ? 1<<(size-1):1) ? cubitface : NUM_FACES;
219 219
    }
220 220

  
221 221
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyObject.java
290 290

  
291 291
    for(int i=0; i<NUM_CUTS; i++)
292 292
      {
293
      if( tmp<CUTS[i] ) return i;
293
      if( tmp<CUTS[i] ) return (1<<i);
294 294
      }
295 295

  
296
    return NUM_CUTS;
296
    return (1<<NUM_CUTS);
297 297
    }
298 298

  
299 299
///////////////////////////////////////////////////////////////////////////////////////////////////
......
307 307

  
308 308
  private boolean belongsToRotation( int cubit, int axis, int rowBitmap)
309 309
    {
310
    return ((1<<CUBITS[cubit].mRotationRow[axis]) & rowBitmap) != 0;
310
    return (CUBITS[cubit].mRotationRow[axis] & rowBitmap) != 0;
311 311
    }
312 312

  
313 313
///////////////////////////////////////////////////////////////////////////////////////////////////
......
411 411
    if ( cubit.mQuatIndex == quatIndex ) return false;
412 412

  
413 413
    int belongsToHowManyFaces = 0;
414
    int lastLayer = getNumLayers()-1;
415
    int row;
414
    int bitmap = (1<<(getNumLayers()-1)) + 1;
416 415

  
417 416
    for(int i=0; i<NUM_AXIS; i++)
418 417
      {
419
      row = cubit.mRotationRow[i];
420
      if( row==0 || row==lastLayer ) belongsToHowManyFaces++;
418
      if( (cubit.mRotationRow[i] & bitmap) != 0 ) belongsToHowManyFaces++;
421 419
      }
422 420

  
423 421
    switch(belongsToHowManyFaces)
......
432 430
               Static4D rotated1 = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat1 );
433 431
               Static4D rotated2 = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat2 );
434 432

  
435
               float row1, row2;
433
               int row1, row2;
436 434
               float x1 = rotated1.get0();
437 435
               float y1 = rotated1.get1();
438 436
               float z1 = rotated1.get2();
......
445 443
                 row1 = computeRow(x1,y1,z1,i);
446 444
                 row2 = computeRow(x2,y2,z2,i);
447 445

  
448
                 if( (row1==0 && row2==0) || (row1==lastLayer && row2==lastLayer) ) return false;
446
                 if( ((row1 & row2) & bitmap) != 0 ) return false;
449 447
                 }
450 448
               return true;
451 449

  
src/main/java/org/distorted/objects/TwistyPyraminx.java
192 192

  
193 193
  private int faceColor(int cubit, int axis)
194 194
    {
195
    return CUBITS[cubit].mRotationRow[axis] == 0 ? axis : NUM_FACES;
195
    return CUBITS[cubit].mRotationRow[axis] == 1 ? axis : NUM_FACES;
196 196
    }
197 197

  
198 198
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff