Revision 0bda7e06
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/TwistyObject.java | ||
---|---|---|
927 | 927 |
|
928 | 928 |
public int computeNearestAngle(int axis, float angle, float speed) |
929 | 929 |
{ |
930 |
final int NEAREST = 360/getBasicAngle()[axis]; |
|
930 |
int[] basicArray = getBasicAngle(); |
|
931 |
int basicAngle = basicArray[axis>basicArray.length ? 0 : axis]; |
|
932 |
int nearestAngle = 360/basicAngle; |
|
931 | 933 |
|
932 |
int tmp = (int)((angle+NEAREST/2)/NEAREST);
|
|
933 |
if( angle< -(NEAREST*0.5) ) tmp-=1;
|
|
934 |
int tmp = (int)((angle+nearestAngle/2)/nearestAngle);
|
|
935 |
if( angle< -(nearestAngle*0.5) ) tmp-=1;
|
|
934 | 936 |
|
935 |
if( tmp!=0 ) return NEAREST*tmp;
|
|
937 |
if( tmp!=0 ) return nearestAngle*tmp;
|
|
936 | 938 |
|
937 |
return speed> 1.2f ? NEAREST*(angle>0 ? 1:-1) : 0;
|
|
939 |
return speed> 1.2f ? nearestAngle*(angle>0 ? 1:-1) : 0;
|
|
938 | 940 |
} |
939 | 941 |
|
940 | 942 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Workaround for a crash.