| 9 | |
| 10 | namespace CesiumGltf { |
| 11 | double applySamplerWrapS(const double u, const int32_t wrapS) { |
| 12 | if (wrapS == Sampler::WrapS::REPEAT) { |
| 13 | double integral = 0; |
| 14 | double fraction = std::modf(u, &integral); |
| 15 | return fraction < 0 ? fraction + 1.0 : fraction; |
| 16 | } |
| 17 | |
| 18 | if (wrapS == Sampler::WrapS::MIRRORED_REPEAT) { |
| 19 | double integral = 0; |
| 20 | double fraction = std::abs(std::modf(u, &integral)); |
| 21 | int64_t integer = static_cast<int64_t>(std::abs(integral)); |
| 22 | // If the integer part is odd, the direction is reversed. |
| 23 | return integer % 2 == 1 ? 1.0 - fraction : fraction; |
| 24 | } |
| 25 | |
| 26 | return glm::clamp(u, 0.0, 1.0); |
| 27 | } |
| 28 | |
| 29 | double applySamplerWrapT(const double v, const int32_t wrapT) { |
| 30 | if (wrapT == Sampler::WrapT::REPEAT) { |
no test coverage detected