MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / approach

Function approach

source/core/StarMathCommon.hpp:279–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277// change. Rate should always be a positive value. (T must be signed).
278template <typename T>
279T approach(T goal, T current, T rate) {
280 if (goal < current) {
281 return max(current - rate, goal);
282 } else if (goal > current) {
283 return min(current + rate, goal);
284 } else {
285 return current;
286 }
287}
288
289// Same as approach, specialied for angles, and always approaches from the
290// closest absolute direction.

Callers 3

tickMethod · 0.85
updateMethod · 0.85
readMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected