Project

General

Profile

« Previous | Next » 

Revision 66cbdd21

Added by Leszek Koltunski about 4 years ago

Some fixes for the Pyraminx.

View differences:

src/main/java/org/distorted/object/RubikObject.java
136 136
      {
137 137
      for(int i=0; i<numFaces; i++)
138 138
        {
139
        belongs = belongsToRotation(cubit, i/2, i%2==0 ? mSize-1:0 );
139
        belongs = isOnFace(cubit, i/2, i%2==0 ? mSize-1:0 );
140 140
        maps[i] = new Static4D( (belongs?i:6)*ratio, 0.0f, ratio, 1.0f);
141 141
        }
142 142
      }
......
144 144
      {
145 145
      for(int i=0; i<numFaces; i++)
146 146
        {
147
        belongs = belongsToRotation(cubit, i, 0 );
147
        belongs = isOnFace(cubit, i, 0 );
148 148
        maps[i] = new Static4D( (belongs?i:6)*ratio, 0.0f, ratio, 1.0f);
149 149
        }
150 150
      }
......
185 185

  
186 186
  private boolean belongsToRotation( int cubit, int axis, int row)
187 187
    {
188
    return mCubits[cubit].mRotationRow[axis]==row;
188
    return ((int)(mCubits[cubit].mRotationRow[axis]+0.5f))==row;
189
    }
190

  
191
///////////////////////////////////////////////////////////////////////////////////////////////////
192
// we cannot use belongsToRotation for deciding if to texture a face. Counterexample: the 'rotated'
193
// tetrahedrons of Pyraminx nearby the edge: they belong to rotation but their face which is rotated
194
// away from the face of the Pyraminx shouldn't be textured.
195

  
196
  private boolean isOnFace( int cubit, int axis, int row)
197
    {
198
    final float MAX_ERROR = 0.0001f;
199
    float diff = mCubits[cubit].mRotationRow[axis] - row;
200
    return diff*diff < MAX_ERROR;
189 201
    }
190 202

  
191 203
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff