From 5ac50cb4600ef38a08b86baddc1a2f96bba6e498 Mon Sep 17 00:00:00 2001 From: Olezen Date: Tue, 11 Feb 2020 16:11:38 +0100 Subject: [PATCH] Updated trace normal Updated the box and capsule tracers to get normals from a raycast, which fixes some issues with surfing. --- Modified fragsurf/TraceUtil/Tracer.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Modified fragsurf/TraceUtil/Tracer.cs b/Modified fragsurf/TraceUtil/Tracer.cs index a1eb97a..df6743a 100644 --- a/Modified fragsurf/TraceUtil/Tracer.cs +++ b/Modified fragsurf/TraceUtil/Tracer.cs @@ -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 { } } -} \ No newline at end of file +}