Hello
I'm only translating & rotating objects (no animation is used), Actually objects are rotated only at begining, than the only manipulation done to them is tranlsate... they are also cloned, removed & added to world
I have two threads only. One is rendering thread, while another one pools the database for data. And only the rendering thread is accesing jpct classes.
This is where I calculate on every iteration for how much does the objects need to move. I don't see where i could produce NaN or Infinity value.
start... (x or y or z) coordinate, where object was at begining
start... (x or y or z) coordinate, where object is now
start... (x or y or z) coordinate, where object destination is
fastTrans... translate the object at finish at once.
public static float getDefaultMovementSpeed(float start, float curr,
float end, boolean fastTrans)
{
float iOverallDistance = Math.abs(end - start);
float iDistanceFromStart = Math.abs(curr - start);
float iDistanceToEnd = Math.abs(end - curr);
float nagative = 1f;
if (start > end) {
negative = -1f;
}
if (iDistanceToEnd <= 3.5 || fastTrans) {
return nagative * iDistanceToEnd;
}
if (iOverallDistance <= 300) {
if (iDistanceFromStart <= (iOverallDistance / 2f)) {
return nagative * (0.5f + iDistanceFromStart / 50f);
}
else {
return nagative * (0.5f + iDistanceToEnd / 50f);
}
}
else {
if (iDistanceFromStart <= 150) {
return nagative * (0.5f + iDistanceFromStart / 50f);
}
else if (iDistanceToEnd <= 150) {
return nagative * (0.5f + iDistanceToEnd / 50f);
}
else {
return nagative * (0.5f + 3f);
}
}
}
PS. One thing more.. what happens to a float number if it reaches max value..