MCPcopy Create free account
hub / github.com/MyGUI/mygui / detectClash

Function detectClash

MyGUIEngine/src/msdfgen/core/msdf-error-correction.cpp:115–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113// Legacy version
114
115inline static bool detectClash(const float *a, const float *b, double threshold) {
116 // Sort channels so that pairs (a0, b0), (a1, b1), (a2, b2) go from biggest to smallest absolute difference
117 float a0 = a[0], a1 = a[1], a2 = a[2];
118 float b0 = b[0], b1 = b[1], b2 = b[2];
119 float tmp;
120 if (fabsf(b0-a0) < fabsf(b1-a1)) {
121 tmp = a0, a0 = a1, a1 = tmp;
122 tmp = b0, b0 = b1, b1 = tmp;
123 }
124 if (fabsf(b1-a1) < fabsf(b2-a2)) {
125 tmp = a1, a1 = a2, a2 = tmp;
126 tmp = b1, b1 = b2, b2 = tmp;
127 if (fabsf(b0-a0) < fabsf(b1-a1)) {
128 tmp = a0, a0 = a1, a1 = tmp;
129 tmp = b0, b0 = b1, b1 = tmp;
130 }
131 }
132 return (fabsf(b1-a1) >= threshold) &&
133 !(b0 == b1 && b0 == b2) && // Ignore if other pixel has been equalized
134 fabsf(a2-.5f) >= fabsf(b2-.5f); // Out of the pair, only flag the pixel farther from a shape edge
135}
136
137template <int N>
138static void msdfErrorCorrectionInner_legacy(const BitmapSection<float, N> &output, const Vector2 &threshold) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected