aboutsummaryrefslogtreecommitdiff
path: root/advtrains/models/advtrains_dtrack_vst1_45.obj
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-06-14 17:11:38 +0200
committerorwell96 <orwell@bleipb.de>2018-06-14 17:39:42 +0200
commit712db5bd7f0c5cab71ccdc93b5d5220b1c99173b (patch)
tree6be4de3b09be454a8275c7a7250fc942bf099f3e /advtrains/models/advtrains_dtrack_vst1_45.obj
parentb8f2ccc63882c77832e99bb692a7c25d2cd3a6ab (diff)
downloadadvtrains-712db5bd7f0c5cab71ccdc93b5d5220b1c99173b.tar.gz
advtrains-712db5bd7f0c5cab71ccdc93b5d5220b1c99173b.tar.bz2
advtrains-712db5bd7f0c5cab71ccdc93b5d5220b1c99173b.zip
Draft of interlocking system
Diffstat (limited to 'advtrains/models/advtrains_dtrack_vst1_45.obj')
0 files changed, 0 insertions, 0 deletions
rge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "ieee_float.h" #include "log.h" #include "porting.h" #include <limits> #include <cmath> // Given an unsigned 32-bit integer representing an IEEE-754 single-precision // float, return the float. f32 u32Tof32Slow(u32 i) { // clang-format off int exp = (i >> 23) & 0xFF; u32 sign = i & 0x80000000UL; u32 imant = i & 0x7FFFFFUL; if (exp == 0xFF) { // Inf/NaN if (imant == 0) { if (std::numeric_limits<f32>::has_infinity) return sign ? -std::numeric_limits<f32>::infinity() : std::numeric_limits<f32>::infinity(); return sign ? std::numeric_limits<f32>::max() : std::numeric_limits<f32>::lowest(); } return std::numeric_limits<f32>::has_quiet_NaN ? std::numeric_limits<f32>::quiet_NaN() : -0.f; } if (!exp) { // Denormal or zero return sign ? -ldexpf((f32)imant, -149) : ldexpf((f32)imant, -149); } return sign ? -ldexpf((f32)(imant | 0x800000UL), exp - 150) : ldexpf((f32)(imant | 0x800000UL), exp - 150); // clang-format on } // Given a float, return an unsigned 32-bit integer representing the f32 // in IEEE-754 single-precision format. u32 f32Tou32Slow(f32 f) { u32 signbit = std::copysign(1.0f, f) == 1.0f ? 0 : 0x80000000UL; if (f == 0.f) return signbit; if (std::isnan(f)) return signbit | 0x7FC00000UL; if (std::isinf(f)) return signbit | 0x7F800000UL; int exp = 0; // silence warning f32 mant = frexpf(f, &exp); u32 imant = (u32)std::floor((signbit ? -16777216.f : 16777216.f) * mant); exp += 126; if (exp <= 0) { // Denormal