Revision 4946b635
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/Movement8.java | ||
---|---|---|
39 | 39 |
new Static3D( 0,+SQ3/3,-SQ6/3), new Static3D( 0,-SQ3/3,+SQ6/3) |
40 | 40 |
}; |
41 | 41 |
|
42 |
private final float[][] mTouchBorders; |
|
43 |
|
|
44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
45 |
|
|
46 |
Movement8(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, int numLayers) |
|
47 |
{ |
|
48 |
super(rotAxis, FACE_AXIS, DIST3D, DIST2D); |
|
49 |
float scale = (3*SQ2/4)/numLayers; // 3*SQ2/4 is 1/cos(dihedral-90) |
|
50 |
mTouchBorders = computeBorders(scale,cuts,rotatable); |
|
51 |
} |
|
52 |
|
|
53 | 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
54 |
// We have either one of the four faces (1,3,4,6) which, when the retAxis are cast onto it, they |
|
55 |
// point the right way (and so the triangle then spans from offset=-SQ3/6 to offset=+SQ3/3 with |
|
56 |
// midpoint at SQ3/12) or one of the other face when the cast rotAxis are the wrong way round (and |
|
57 |
// the triangle spans then from 0 to SQ3/2 with midpoint at SQ3/4). |
|
58 |
// |
|
59 |
// This is only true if the rotAxis connect the centers of opposing faces! |
|
60 | 43 |
|
61 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
|
|
44 |
Movement8(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, int size)
|
|
62 | 45 |
{ |
63 |
float off = ( face==1 || face==3 || face==4 || face==6 ) ? DIST2D/2 : -DIST2D/2; |
|
64 |
float[] borders = mTouchBorders[axisIndex]; |
|
65 |
int len = borders.length; |
|
66 |
|
|
67 |
for(int i=0; i<len; i++) |
|
68 |
{ |
|
69 |
if( offset+off<borders[i] ) return i; |
|
70 |
} |
|
71 |
|
|
72 |
return len; |
|
46 |
super(rotAxis, FACE_AXIS, cuts, rotatable, DIST3D, size); |
|
73 | 47 |
} |
74 | 48 |
|
75 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Major abstraction - automatically compute the 'computeRowFromOffset()' function from CUTS.
Still one thing left: it appears like the CUTS of Mega/Kilominxes are not correct.