From 9ef8047a5aa5662cc0a44bfdb3df1e86737caefc Mon Sep 17 00:00:00 2001 From: jun <31910822+ub3132003@users.noreply.github.com> Date: Fri, 20 Aug 2021 21:07:38 +0800 Subject: [PATCH] Update LineSegmentTransformSystem.cs --- Scripts/Systems/LineSegmentTransformSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/Systems/LineSegmentTransformSystem.cs b/Scripts/Systems/LineSegmentTransformSystem.cs index caf1860..614557d 100644 --- a/Scripts/Systems/LineSegmentTransformSystem.cs +++ b/Scripts/Systems/LineSegmentTransformSystem.cs @@ -23,7 +23,7 @@ protected override void OnUpdate () .ForEach( ( ref LocalToWorld ltr , in LineSegment segment ) => { float3 lineVec = segment.to - segment.from; - var rot = quaternion.LookRotation( math.normalize(lineVec) , math.normalize(cameraPosition-segment.from) ); + var rot = quaternion.LookRotationSafe( math.normalize(lineVec) , math.normalize(cameraPosition-segment.from) ); var pos = segment.from; var scale = new float3{ x=segment.lineWidth , y=1f , z=math.length(lineVec) }; ltr.Value = float4x4.TRS( pos , rot , scale ); @@ -37,7 +37,7 @@ protected override void OnUpdate () .ForEach( ( ref LocalToWorld ltr , in LineSegment segment ) => { float3 lineVec = segment.to - segment.from; - var rot = quaternion.LookRotation( math.normalize(lineVec) , math.mul(cameraRotation,new float3{z=-1}) ); + var rot = quaternion.LookRotationSafe( math.normalize(lineVec) , math.mul(cameraRotation,new float3{z=-1}) ); var pos = segment.from; var scale = new float3{ x=segment.lineWidth , y=1f , z=math.length(lineVec) }; ltr.Value = float4x4.TRS( pos , rot , scale );