From 5d1acbfa15168d6226c1a0c8ff12eb7652d9ef98 Mon Sep 17 00:00:00 2001 From: Sherif Nafee Date: Thu, 9 Apr 2026 10:58:18 +0300 Subject: [PATCH] Remove scale from raycast direction calculation --- .../Sensors/LiDAR/RaycastLiDAR/IUpdateRaycastCommandsJob.cs | 4 ++-- .../Scripts/Sensors/LiDAR/RaycastLiDAR/RaycastLiDARSensor.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Packages/UnitySensors/Runtime/Scripts/Sensors/LiDAR/RaycastLiDAR/IUpdateRaycastCommandsJob.cs b/Packages/UnitySensors/Runtime/Scripts/Sensors/LiDAR/RaycastLiDAR/IUpdateRaycastCommandsJob.cs index 2a9cb8dd..e2242ff2 100644 --- a/Packages/UnitySensors/Runtime/Scripts/Sensors/LiDAR/RaycastLiDAR/IUpdateRaycastCommandsJob.cs +++ b/Packages/UnitySensors/Runtime/Scripts/Sensors/LiDAR/RaycastLiDAR/IUpdateRaycastCommandsJob.cs @@ -14,7 +14,7 @@ public struct IUpdateRaycastCommandsJob : IJobParallelFor [ReadOnly] public Vector3 origin; [ReadOnly] - public Matrix4x4 localToWorldMatrix; + public quaternion rotation; [ReadOnly] public float maxRange; [ReadOnly] @@ -28,7 +28,7 @@ public struct IUpdateRaycastCommandsJob : IJobParallelFor public void Execute(int index) { - raycastCommands[index] = new(origin, localToWorldMatrix * (Vector3)directions[index + indexOffset], queryParameters, maxRange); + raycastCommands[index] = new(origin, math.normalize(math.mul(rotation, directions[index + indexOffset])), queryParameters, maxRange); } } } \ No newline at end of file diff --git a/Packages/UnitySensors/Runtime/Scripts/Sensors/LiDAR/RaycastLiDAR/RaycastLiDARSensor.cs b/Packages/UnitySensors/Runtime/Scripts/Sensors/LiDAR/RaycastLiDAR/RaycastLiDARSensor.cs index d37696ae..65563820 100644 --- a/Packages/UnitySensors/Runtime/Scripts/Sensors/LiDAR/RaycastLiDAR/RaycastLiDARSensor.cs +++ b/Packages/UnitySensors/Runtime/Scripts/Sensors/LiDAR/RaycastLiDAR/RaycastLiDARSensor.cs @@ -67,7 +67,7 @@ private void SetupJobs() _updateRaycastCommandsJob = new IUpdateRaycastCommandsJob() { origin = _transform.position, - localToWorldMatrix = _transform.localToWorldMatrix, + rotation = _transform.rotation, maxRange = maxRange, queryParameters = new() { layerMask = _raycastLayerMask }, directions = _directions, @@ -100,7 +100,7 @@ private void SetupJobs() protected override IEnumerator UpdateSensor() { _updateRaycastCommandsJob.origin = _transform.position; - _updateRaycastCommandsJob.localToWorldMatrix = _transform.localToWorldMatrix; + _updateRaycastCommandsJob.rotation = _transform.rotation; JobHandle updateRaycastCommandsJobHandle = _updateRaycastCommandsJob.Schedule(pointsNum, 1024); JobHandle updateGaussianNoisesJobHandle = _updateGaussianNoisesJob.Schedule(pointsNum, 1, updateRaycastCommandsJobHandle);