public static Vector3 RepairHitSurfaceNormal(RaycastHit hit) { var collider = hit.collider; var meshCollider = collider as MeshCollider; if (meshCollider != null) { Profiler.BeginSample("Get things"); var mesh = meshCollider.sharedMesh; var triangles = PhysicMeshTool.GetTriangles(mesh); var vertices = PhysicMeshTool.GetVertices(mesh); Profiler.EndSample(); var job = new JobRepairHitSurfaceNormal() { TriangleIndex = hit.triangleIndex, Triangles = triangles, Vertices = vertices, ResultNormal = s_RepairNormalResult }; job.Run(); Profiler.BeginSample("Get direction"); var dir = hit.transform.TransformDirection(s_RepairNormalResult[0]); Profiler.EndSample(); return(dir); } return(hit.normal); }
public static Vector3 RepairHitSurfaceNormal(RaycastHit hit) { var collider = hit.collider; var meshCollider = collider as MeshCollider; if (meshCollider != null) { var mesh = meshCollider.sharedMesh; var triangles = PhysicMeshTool.GetTriangles(mesh); var vertices = PhysicMeshTool.GetVertices(mesh); new JobRepairHitSurfaceNormal() { TriangleIndex = hit.triangleIndex, Triangles = triangles, Vertices = vertices, ResultNormal = s_RepairNormalResult }.Run(); return(hit.transform.TransformDirection(s_RepairNormalResult[0])); } return(hit.normal); }