MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / fastfloor

Function fastfloor

Source/Utils/SimplexNoise.cpp:46–49  ·  view source on GitHub ↗

* Computes the largest integer value not greater than the float one * * This method is faster than using (int32_t)std::floor(fp). * * I measured it to be approximately twice as fast: * float: ~18.4ns instead of ~39.6ns on an AMD APU), * double: ~20.6ns instead of ~36.6ns on an AMD APU), * Reference: http://www.codeproject.com/Tips/700780/Fast-floor-ceiling-functions * * @param[in] fp

Source from the content-addressed store, hash-verified

44 * @return largest integer value not greater than fp
45 */
46static inline int32_t fastfloor(float fp) {
47 int32_t i = static_cast<int32_t>(fp);
48 return (fp < i) ? (i - 1) : (i);
49}
50
51/**
52 * Permutation table. This is just a random jumble of all numbers 0-255.

Callers 4

noiseXMethod · 0.85
noiseXYMethod · 0.85
noiseXYZMethod · 0.85
noiseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected