@@ -309,6 +309,8 @@ private static bool RayCastIntoModelMulti(CSGModel model,
309309 var gameObject = monoBehaviour . gameObject ;
310310 if ( ( ( 1 << gameObject . layer ) & visibleLayers ) == 0 )
311311 continue ;
312+
313+ var distance = ( __outputIntersections [ i ] . intersection . worldIntersection - worldRayStart ) . magnitude ;
312314
313315 intersectionList . Add ( new LegacyBrushIntersection
314316 {
@@ -322,7 +324,7 @@ private static bool RayCastIntoModelMulti(CSGModel model,
322324 worldPlane = new CSGPlane ( __outputIntersections [ i ] . intersection . worldPlane ) ,
323325 worldIntersection = __outputIntersections [ i ] . intersection . worldIntersection ,
324326 surfaceIntersection = __outputIntersections [ i ] . intersection . surfaceIntersection ,
325- distance = __outputIntersections [ i ] . intersection . distance
327+ distance = distance // __outputIntersections[i].intersection.distance
326328 } ) ;
327329 }
328330
@@ -418,6 +420,8 @@ private static bool RayCastMulti(int modelCount,
418420 var gameObject = monoBehaviour . gameObject ;
419421 if ( ( ( 1 << gameObject . layer ) & visibleLayers ) == 0 )
420422 continue ;
423+
424+ var distance = ( __outputIntersections [ i ] . intersection . worldIntersection - rayStart ) . magnitude ;
421425
422426 __intersectionList . Add ( new LegacyBrushIntersection
423427 {
@@ -431,7 +435,7 @@ private static bool RayCastMulti(int modelCount,
431435 worldPlane = new CSGPlane ( __outputIntersections [ i ] . intersection . worldPlane ) ,
432436 worldIntersection = __outputIntersections [ i ] . intersection . worldIntersection ,
433437 surfaceIntersection = __outputIntersections [ i ] . intersection . surfaceIntersection ,
434- distance = __outputIntersections [ i ] . intersection . distance ,
438+ distance = distance // __outputIntersections[i].intersection.distance,
435439 } ) ;
436440 }
437441 }
@@ -542,6 +546,8 @@ private static bool RayCastIntoBrushSurface(Int32 brushNodeID,
542546 intersection = null ;
543547 return false ;
544548 }
549+
550+ var distance = ( outputSurfaceIntersection . worldIntersection - rayStart ) . magnitude ;
545551
546552 intersection = new LegacySurfaceIntersection
547553 {
@@ -550,7 +556,7 @@ private static bool RayCastIntoBrushSurface(Int32 brushNodeID,
550556 worldPlane = new CSGPlane ( outputSurfaceIntersection . worldPlane ) ,
551557 surfaceIntersection = outputSurfaceIntersection . surfaceIntersection ,
552558 worldIntersection = outputSurfaceIntersection . worldIntersection ,
553- distance = outputSurfaceIntersection . distance
559+ distance = distance // outputSurfaceIntersection.distance
554560 } ;
555561 return true ;
556562 }
0 commit comments