MCPcopy Create free account
hub / github.com/CesiumGS/cesium-native / applySamplerWrapT

Function applySamplerWrapT

CesiumGltf/src/SamplerUtility.cpp:29–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29double 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

Callers 1

sampleNearestPixelMethod · 0.85

Calls 1

clampFunction · 0.85

Tested by

no test coverage detected