So there is a paper [A Hybrid GPU Rendering Pipeline for Alias-Free Hard Shadows][1]


  [1]: http://wwwcg.in.tum.de/research/research/publications/2009/a-hybrid-gpu-rendering-pipeline-for-alias-free-hard-shadows.html

That claims to calculate the distance to a triangle $d(\omega,T)$ efficiently, they 

> resort to some tricks based on the concepts of
> *barycentric coordinates*

they describe the squared distance between a point $w$ and some vertex $v_i$ of the triangle $T$ as

$d(\omega,v_i)^2=\left\Vert \omega-v_{i}\right\Vert=\lambda_{i-1}^{2}\left\Vert e_{i-1}\right\Vert ^{2}+\lambda_{i+1}^{2}\left\Vert e_{i+1}\right\Vert ^{2}-2\lambda_{i-1}\lambda_{i+1}\left(e_{i-1}\cdot e_{i}\right)$

There is a derivation in the paper.