Chlumsky / msdfgen

Multi-channel signed distance field generator
MIT License
3.9k stars 404 forks source link

Confusing SignedDistance calculation in QuadraticSegment::signedDistance #174

Closed jkb0o closed 1 year ago

jkb0o commented 1 year ago

Hello! I'm trying to port you amazing library to the pure rust (almost brainlessly) and I found confusing part in the SignedDistance calculation:

https://github.com/Chlumsky/msdfgen/blob/eeec8f222d0b06f2636ccb3b9dda3f6c3f00d25c/core/edge-segments.cpp#L183-L188

There are cross if/else conditions. Looks like the first if should test for the outer bounds of 0..1 or the second if should test against 0/1. The same is valid for the QubicSegment as well.

I not really deep into math, I do not understand everything, so I would appreciate any explanation of this condition.

Thank you for a great job!