Project

General

Profile

« Previous | Next » 

Revision 59a971c1

Added by Leszek Koltunski over 2 years ago

Remove the need to provide the number of outer faces of a ObjectShape.

View differences:

src/main/java/org/distorted/objectlib/main/TwistyObject.java
143 143
  private ObjectShape[] mShapes;
144 144
  private int mNumCubitVariants;
145 145
  private int[][] mCubitFaceColors;
146
  private int[][] mVariantFaceIsOuter;
146 147

  
147 148
  //////////////////// SOLVED1 ////////////////////////
148 149

  
......
278 279
    return new Static3D(sumX,sumY,sumZ);
279 280
    }
280 281

  
282
///////////////////////////////////////////////////////////////////////////////////////////////////
283

  
284
  private void createOuterFaces()
285
    {
286
    for(int v=0; v<mNumCubitVariants; v++)
287
      {
288
      int[][] indices = mShapes[v].getVertIndices();
289
      int faces = indices.length;
290
      mVariantFaceIsOuter[v] = new int[faces];
291
      }
292

  
293
    for(int cubit=0; cubit<NUM_CUBITS; cubit++)
294
      {
295
      int variant = getCubitVariant(cubit,mNumLayers);
296
      int[][] indices = mShapes[variant].getVertIndices();
297
      int numFaces = indices.length;
298

  
299
      for(int face=0; face<numFaces; face++)
300
        if( getCubitFaceColor(cubit,face,mNumLayers)>=0 )
301
          {
302
          mVariantFaceIsOuter[variant][face] = 1;
303
          }
304
      }
305
    }
306

  
281 307
///////////////////////////////////////////////////////////////////////////////////////////////////
282 308

  
283 309
  private void getQuatsAndShapes(boolean fromDMESH, boolean fromJSON)
......
295 321
      mShapes = new ObjectShape[mNumCubitVariants];
296 322
      for(int i=0; i<mNumCubitVariants; i++) mShapes[i] = getObjectShape(i);
297 323
      mNumCubitFaces = ObjectShape.computeNumComponents(mShapes);
324
      mVariantFaceIsOuter = new int[mNumCubitVariants][];
298 325

  
299
      if( fromDMESH )
326
      if( !fromJSON )
300 327
        {
301
        for(int i=0; i<mNumCubitVariants; i++) factory.createNewFaceTransform(mShapes[i]);
328
        mCubitFaceColors = ObjectShape.computeColors(mShapes,mOrigPos,mOrigQuat,this);
329
        createOuterFaces();
302 330
        }
303 331

  
304
      if( !fromJSON )
332
      if( fromDMESH )
305 333
        {
306
        mCubitFaceColors = ObjectShape.computeColors(mShapes,mOrigPos,mOrigQuat,this);
334
        for(int i=0; i<mNumCubitVariants; i++) factory.createNewFaceTransform(mShapes[i], mVariantFaceIsOuter[i]);
307 335
        }
308 336
      }
309 337
    }
......
363 391
      {
364 392
      ObjectFaceShape faceShape = getObjectFaceShape(variant);
365 393
      FactoryCubit factory = FactoryCubit.getInstance();
366
      factory.createNewFaceTransform(mShapes[variant]);
394
      factory.createNewFaceTransform(mShapes[variant],mVariantFaceIsOuter[variant]);
367 395
      mMeshes[variant] = factory.createRoundedSolid(mShapes[variant],faceShape,meshState, numComponents);
368 396
      }
369 397

  
......
1064 1092
  public int getCubitFaceColor(int cubit, int face, int[] numLayers)
1065 1093
    {
1066 1094
    int numFaces = mCubitFaceColors[cubit].length;
1067
    int newColor = face<numFaces ? mCubitFaceColors[cubit][face] : -1;
1095
    int color = face<numFaces ? mCubitFaceColors[cubit][face] : -1;
1068 1096

  
1069
    return newColor<0 ? -1 : newColor%NUM_FACE_COLORS;
1097
    return color<0 ? -1 : color%NUM_FACE_COLORS;
1070 1098
    }
1071 1099

  
1072 1100
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff