| 270 | */ |
| 271 | template<typename T> |
| 272 | inline T clamp(T v, T mn, T mx) |
| 273 | { |
| 274 | // Do not reorder; correct NaN handling relies on the fact that comparison |
| 275 | // with NaN returns false and will fall-through to the "min" value. |
| 276 | if (v > mx) return mx; |
| 277 | if (v > mn) return v; |
| 278 | return mn; |
| 279 | } |
| 280 | |
| 281 | /** |
| 282 | * @brief Clamp a float value between 0.0f and 1.0f. |
no outgoing calls