| 27 | } |
| 28 | |
| 29 | double applySamplerWrapT(const double v, const int32_t wrapT) { |
| 30 | if (wrapT == Sampler::WrapT::REPEAT) { |
| 31 | double integral = 0; |
| 32 | double fraction = std::modf(v, &integral); |
| 33 | return fraction < 0 ? fraction + 1.0 : fraction; |
| 34 | } |
| 35 | |
| 36 | if (wrapT == Sampler::WrapT::MIRRORED_REPEAT) { |
| 37 | double integral = 0; |
| 38 | double fraction = std::abs(std::modf(v, &integral)); |
| 39 | int64_t integer = static_cast<int64_t>(std::abs(integral)); |
| 40 | // If the integer part is odd, the direction is reversed. |
| 41 | return integer % 2 == 1 ? 1.0 - fraction : fraction; |
| 42 | } |
| 43 | |
| 44 | return glm::clamp(v, 0.0, 1.0); |
| 45 | } |
| 46 | |
| 47 | } // namespace CesiumGltf |
no test coverage detected