Archived post by SniperJake945

it was the mouse yee. Okay so basically the procedure is this:
starting from some triangle`T`, at some point `u` (in the triangle not on an edge or at one of the vertices of the triangle, those are special cases), trace a vector `v` over the surface of your mesh.
first rotate `u` into 2d using the dihedral between `T`’s normal and one of your coordinate axes, do the same for `v`.
Convert the 2d `u` into barycentric coordinates. convert the 2d `u + v` into barycentric coordinates.
using some barycentric fuckery (math.stackexchange.com/questions/2382016/determine-if-a-line-segment-passes-through-a-triangle/2385307#2385307) determine which edge the line `u, u + v` crosses.
keep in mind that if `u + v` is somewhere in your triangle you should break, because that means your tracing position is inside this triangle `T`.
convert back to 2d from barycentric. find the angle of intersection `theta`.
grab the intersected edge.
subtract the distance traveled from the length of the original vector and store it as like some float named `length_left`
store the hit position as a 1d value `g` along the hit edge for efficiency.
Flip over this edge.
rotate this edge into 2d space of the new triangle.
find the new `u` by scaling this rotated edge by `g`
then rotate this edge, from `u` to equal `180 – theta`, and scale it to be equal to `length left`.
repeat the above intersection process but like omit the edge that you just crossed from the test.
Continue until you’ve traced the full length of the initial vector.
Nice.

Caveats:
if you hit a vertex of a triangle you need to follow the keenan crane paper, which basically gives you a guide for figuring out which triangle u want to start tracing from, given the previous trace vector
if your vector is perfectly parallel with an edge, you might run into numerical issues and will have to have a catch for that.
Starting your trace from anywhere on the edge of the triangle is annoying to deal with if you dont know which triangle your current trace vector is pointing into.
I havent proof read any of this, so if it’s incoherent, sorry.

its a lot of work to do this efficiently, but once you get it working you can do a lot of really crazy things

i have faith that any and all of you can do this too!!!! i believe in you!!!!!!!!!