Closed JackRainy closed 2 years ago
This is nice and simple, does the job it should, and only improves test quality, so I'll merge this.
@tommyettinger, thank you for the review. At some point I thought the project was already "dead" and not maintained; good to know it's still alive and I can contribute more. :)
While playing with SteeringBehavior tests, I have noticed that some of the sliders allow to set the zero value for "Time to target". However, the behavior utilizes this value as
targetVelocity.sub(owner.getLinearVelocity()).scl(1f / timeToTarget).limit(actualLimiter.getMaxLinearAcceleration());
where 0-value leads to division by zero and silent crash (in the tests the character just disappear and can't be restored).I come with two options to fix that: 1) correct the behavior code: to perform a check for such wrong input, and when it happens to use some non-zero value. 2) correct the tests and do not allow to enter the wrong values.
This PR implements 2nd option. I suggest leaving for user's own responsibility providing the correct values to the behavior algorithms in one's code; rather than slowing down the algorithm by excessive sanity checks and providing the behavior different from the input (though invalid input) parameters.