Revision da178c88
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/Movement.java | ||
---|---|---|
152 | 152 |
} |
153 | 153 |
|
154 | 154 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
155 |
// in the center of the face offset is always 0 regardless of the axis |
|
155 | 156 |
|
156 | 157 |
private float computeOffset(float[] point, float[] axis) |
157 | 158 |
{ |
158 |
return point[0]*axis[0] + point[1]*axis[1] + mDistanceCenterFace2D;
|
|
159 |
return point[0]*axis[0] + point[1]*axis[1]; |
|
159 | 160 |
} |
160 | 161 |
|
161 | 162 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementCube.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
34 | 34 |
{ |
35 |
return (int)(numLayers*offset);
|
|
35 |
return (int)(numLayers*(offset+DIST2D));
|
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementDiamond.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
38 | 38 |
{ |
39 |
float off = ( face==1 || face==3 || face==4 || face==6 ) ? offset/SQ3 + 1.0f/6 : offset/SQ3;
|
|
40 |
return (int)(2*numLayers*off);
|
|
39 |
float off = ( face==1 || face==3 || face==4 || face==6 ) ? (offset+2*DIST2D) : (offset+DIST2D);
|
|
40 |
return (int)(numLayers*off/(3*DIST2D));
|
|
41 | 41 |
} |
42 | 42 |
|
43 | 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementDino.java | ||
---|---|---|
33 | 33 |
|
34 | 34 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
35 | 35 |
{ |
36 |
return offset<DIST2D ? 0:2;
|
|
36 |
return offset<0 ? 0:2;
|
|
37 | 37 |
} |
38 | 38 |
|
39 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementHelicopter.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
34 | 34 |
{ |
35 |
return offset<DIST2D ? 0:2;
|
|
35 |
return offset<0 ? 0:2;
|
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementIvy.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
34 | 34 |
{ |
35 |
return offset<DIST2D ? 0:1;
|
|
35 |
return offset<0 ? 0:1;
|
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementJing.java | ||
---|---|---|
34 | 34 |
|
35 | 35 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
36 | 36 |
{ |
37 |
return offset < (SQ3/4)*F ? 0:1; |
|
37 |
return offset+DIST2D < (SQ3/4)*F ? 0:1;
|
|
38 | 38 |
} |
39 | 39 |
|
40 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementMinx.java | ||
---|---|---|
34 | 34 |
{ |
35 | 35 |
if( numLayers==3 ) |
36 | 36 |
{ |
37 |
return offset<DIST2D ? 0:2;
|
|
37 |
return offset<0 ? 0:2;
|
|
38 | 38 |
} |
39 | 39 |
if( numLayers==5 ) |
40 | 40 |
{ |
41 | 41 |
float quot = offset / DIST2D; |
42 | 42 |
|
43 |
if( quot>0.00f && quot<=0.34f ) return 0;
|
|
44 |
if( quot>0.34f && quot<=1.00f ) return 1;
|
|
45 |
if( quot>1.00f && quot<=1.66f ) return 3;
|
|
46 |
if( quot>1.66f && quot<=2.00f ) return 4;
|
|
43 |
if( quot>-1.00f && quot<=-0.66f ) return 0;
|
|
44 |
if( quot>-0.66f && quot<= 0.00f ) return 1;
|
|
45 |
if( quot> 0.00f && quot<= 0.66f ) return 3;
|
|
46 |
if( quot> 0.66f && quot<= 1.00f ) return 4;
|
|
47 | 47 |
} |
48 | 48 |
|
49 | 49 |
return 0; |
src/main/java/org/distorted/objects/MovementPyraminx.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
34 | 34 |
{ |
35 |
return (int)(numLayers*offset/(SQ6/3));
|
|
35 |
return (int)(numLayers*(offset+DIST2D)/(3*DIST2D));
|
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementRedi.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
34 | 34 |
{ |
35 |
return offset<DIST2D ? 0:2;
|
|
35 |
return offset<0 ? 0:2;
|
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementRex.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
34 | 34 |
{ |
35 |
return offset<DIST2D ? 0:2;
|
|
35 |
return offset<0 ? 0:2;
|
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementSkewb.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
34 | 34 |
{ |
35 |
return offset<DIST2D ? 0:numLayers-1;
|
|
35 |
return offset<0 ? 0:numLayers-1;
|
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementSquare.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
34 | 34 |
{ |
35 |
return offset<DIST2D? 0 : 2-axisIndex;
|
|
35 |
return offset<0 ? 0 : 2-axisIndex;
|
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/MovementUltimate.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
34 | 34 |
{ |
35 |
return offset<DIST2D ? 0:1;
|
|
35 |
return offset<0 ? 0:1;
|
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Make computing the offset in the Movement class more correct. From now on, in the center of the face the offset if always 0 regardless of the axis.
Before it would always assume that we can add DIST2D to the offset which is originated at the center of the face and this way get an offset which spans from 0 to height of the face. This is not always true - conterexample: half of the triangluar faces of an octahedron which are 'upside down'