Updated trace normal

Updated the box and capsule tracers to get normals from a raycast, which fixes some issues with surfing.
This commit is contained in:
Olezen
2020-02-11 16:11:38 +01:00
committed by GitHub
parent 82b7fa731f
commit 5ac50cb460

View File

@@ -66,7 +66,15 @@ namespace Fragsurf.TraceUtil {
result.hitPoint = hit.point;
result.planeNormal = hit.normal;
result.distance = hit.distance;
RaycastHit normalHit;
Ray normalRay = new Ray (hit.point - direction * 0.001f, direction);
if (hit.collider.Raycast (normalRay, out normalHit, 0.002f)) {
result.planeNormal = normalHit.normal;
}
} else
result.fraction = 1;
@@ -105,7 +113,15 @@ namespace Fragsurf.TraceUtil {
result.hitPoint = hit.point;
result.planeNormal = hit.normal;
result.distance = hit.distance;
RaycastHit normalHit;
Ray normalRay = new Ray (hit.point - direction * 0.001f, direction);
if (hit.collider.Raycast (normalRay, out normalHit, 0.002f)) {
result.planeNormal = normalHit.normal;
}
} else
result.fraction = 1;
@@ -114,4 +130,4 @@ namespace Fragsurf.TraceUtil {
}
}
}
}