Original Post
Hello, first time posting, but here it is.
I have recently gone from programming in 2D Allegro to programming 3D DirectX. I have been trying to get a simple collision engine running for quite some time, my primary goal to make a sphere smoothly travel over angled terrain. So far, I have been mildly successful, and this works:

The ball successfully checks for the intersection of the planes normal from it's center, and slides down accordingly. No problem there.
However, I cannot get the ball to move accordingly when moving over the seam of two triangles, since it can no longer use the planes normal as calculation. I have tried this, but all it has accomplished is making the ball "spaz" whenever it gets near a seam and clip through:

The above diagram depicts the ball outside of a triangles area (the triangle is facing directly towards the screen). A vector is made from each of the points of the triangle to the sphere (only one is shown), and projected on the corresponding edge. If the vector from the end of the edge projection to the sphere (blue vector) is smaller than the radius of the Sphere, move it by the amount of the intersection multiplied by the unit vector of blue.
I have managed to implement the above method in 2D, and it works fine, however, in 3D, the ball doesn't even need to be anywhere near the edge before it begins to "spaz" out. I'm wondering if it's a mathematical error rather than a coding one, would I be correct? Or is there an easier/different method I could use for this.
I understand this is asking for a lot. Thankyou very much for your help.
I have recently gone from programming in 2D Allegro to programming 3D DirectX. I have been trying to get a simple collision engine running for quite some time, my primary goal to make a sphere smoothly travel over angled terrain. So far, I have been mildly successful, and this works:

The ball successfully checks for the intersection of the planes normal from it's center, and slides down accordingly. No problem there.
However, I cannot get the ball to move accordingly when moving over the seam of two triangles, since it can no longer use the planes normal as calculation. I have tried this, but all it has accomplished is making the ball "spaz" whenever it gets near a seam and clip through:

The above diagram depicts the ball outside of a triangles area (the triangle is facing directly towards the screen). A vector is made from each of the points of the triangle to the sphere (only one is shown), and projected on the corresponding edge. If the vector from the end of the edge projection to the sphere (blue vector) is smaller than the radius of the Sphere, move it by the amount of the intersection multiplied by the unit vector of blue.
I have managed to implement the above method in 2D, and it works fine, however, in 3D, the ball doesn't even need to be anywhere near the edge before it begins to "spaz" out. I'm wondering if it's a mathematical error rather than a coding one, would I be correct? Or is there an easier/different method I could use for this.
I understand this is asking for a lot. Thankyou very much for your help.