... is kicking my butt this morning. trying to use it in 2 different scenarios, and they are both failing
first scenario. i've got a sphere mesh on a plane mesh. the plane mesh is 10 units by 10 units, and the sphere unit is 1 unit large. everything is centered at the origin. using the directional keys, i can move the sphere mesh over the plane. it goes from 5 to 5 along the X axis and 5 to 5 along the Y axis as expected. the task i'd like Mesh.Intersect to handle is when the ball rolls off the plane. the rays origin is the x,y coordinate of the sphere mesh, and its height is above the plane. the rays direction is the x,y coordinate of the sphere mesh, and its height is below the plane. so the ray used to test for intersection is perpendicular to the plane and coincides to the center location of the sphere. so it should report that there is an intersect whenever the sphere is on the plane ... right? wrong. instead it only identifies hits towards the center of the plane. from 2.5 to 2.5 along the X and 2.5 to 2.5 along the Y. anything closer to the edges does not register an intersect, even though the sphere is still visibly on the plane. for debugging, i render the ray, and it shows up exactly as expected (spearing the sphere perpendicular to the plane). my only guess as to what is happening is that somehow my mesh is being scaled without my knowledge? looking at the plane.x, it seems to represent the units from 5 to 5 as expected. also, nowhere in my code am i scaling or translating the plane mesh. all i'm doing is translating the sphere mesh. no clue ...
second scenario. i've got a sphere mesh inside a cube mesh. the cube mesh is 10 units by 10 units by 10 units, and the sphere is 1 unit large. using the directional keys, i can move the sphere mesh along the X and Y axis (depth is ignored, so basically the sphere is contained in a rectangular wall). everything is centered at the origin again. this time i'd like Mesh.Intersect to to let me know when the sphere hits a wall of the cube. the origin of the ray is the cubes position. the direction of the ray is the direction that the sphere is heading. i shoot the ray out something like 100 units. the expected behavior is that as the sphere moves, it is always reporting a hit, because the ray is passing through some wall of the cube. this does work. then, i check the distance of the IntersectInformation for the closest hit. this should decrease to 0, which specifies actually hitting the wall (taking into account the radius of the sphere). this also works. the thing that is messing with me is that it specifies a hit depending on the speed that the sphere is heading towards the wall. if the sphere is moving slow, then the sphere will be right up against the wall before the distance is 0 (as expected). but if the sphere is moving fast, the sphere will be something like 1 unit away from the wall when the distance becomes 0 (not expected). rendering the ray for debugging shows it positioned as expected. no clue ...
