xxxxxxxxxx
static bool IsInsideTriangle(const Vec2 p, const Vec2 t0, const Vec2 t1, const Vec2 t2)
{
float det = (t1.x - t0.x) * (t2.y - t0.y) - (t1.y - t0.y) * (t2.x - t0.x);
return det * ((t1.x - t0.x) * (p.y - t0.y) - (t1.y - t0.y) * (p.x - t0.x)) >= 0.f &&
det * ((t2.x - t1.x) * (p.y - t1.y) - (t2.y - t1.y) * (p.x - t1.x)) >= 0.f &&
det * ((t0.x - t2.x) * (p.y - t2.y) - (t0.y - t2.y) * (p.x - t2.x)) >= 0.f;
}