First, find the average, minimum and maximum distance all vertices in the shirt mesh. Let those be Da, Di and Dx, respectively.
Also let Dai = Di/Da and Dax = Dx/Da.
Then, you test each point of your shirt mesh Ms to know if it's inside the body mesh Mb, possibly using the Jordan Curve Theorem, which is based on raycasting. Store all vertices which are found to be inside the mesh in a list, then for each vertex Vc:
- Get the nearest vertex Vn of Mb, trace a ray from Vc to Vn, store the contact point Pc
- Move Vc to Pc
After this, you should have a relatively distorted model of your shirt. You then loop again on each Vc:
- For each vertex Vx connected to Vc:
- Get the distance of Vc to Vx
- If it's greater than Dx, move Vx to a point Dax units away from Vc
- If it's smaller than Di, move Vx to a point Dai units away from Vc
- Repeat step 3 for all the vertices connected to Vx
I assume you know how to find the distance between vertices, and how to get a new vertex from a vertex, direction and distance. If not, it would be great to learn that.
This should work for most meshes, but it's quite expensive, so I don't recommend doing this at runtime. If possible, run it once just and save the final mesh somewhere you can keep using it without recalculating.
This works the best for meshes with relatively close edge lengths, that is, a even distribution of vertices along the surface, though it works OK for other meshes too.
I hope this is clearer than the discussion in the comments.