HairyPlotterTriangle RaycastTriangle() { // This transform from GUI space to scene camera ray Ray r = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); Transform t = plotter.transform; // this for position gizmo vertices and triangles according parent game object world coordinates // Iterate over each triangle in plotter for (int i = 0; i < plotter.TriangleCount; ++i) { // Grab triangle HairyPlotterTriangle triangle = plotter.GetTriangle(i); // Intersect ray if (HairyPlotter.RayIntersectsTriangle( r, t.TransformPoint(triangle.GetVertex(0).Position), t.TransformPoint(triangle.GetVertex(1).Position), t.TransformPoint(triangle.GetVertex(2).Position) )) { // Found! plotter.CurrentAction = HairyPlotterActions.None; return(triangle); } } return(null); }
HairyPlotterTriangle RaycastTriangle() { // This transform from GUI space to scene camera ray Ray r = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); // Iterate over each triangle in plotter for (int i = 0; i < plotter.TriangleCount; ++i) { // Grab triangle HairyPlotterTriangle triangle = plotter.GetTriangle(i); // Intersect ray if (HairyPlotter.RayIntersectsTriangle( r, triangle.GetVertex(0).Position, triangle.GetVertex(1).Position, triangle.GetVertex(2).Position )) { // Found! plotter.CurrentAction = HairyPlotterActions.None; // Destroy triangle return(triangle); } } return(null); }