@@ -844,6 +844,11 @@ internal void SetBounds(Vector3 size)
844844 m_BB_HeightCorner = m_BB_Origin + size ;
845845 }
846846
847+ void UpdatePlaneRotation ( )
848+ {
849+ m_PlaneRotation = Mathf . Approximately ( m_PlaneForward . sqrMagnitude , 0f ) ? Quaternion . identity : Quaternion . LookRotation ( m_PlaneForward , m_Plane . normal ) ;
850+ }
851+
847852 internal void DoDuplicateShapePreviewHandle ( Vector3 position )
848853 {
849854 var evt = Event . current ;
@@ -868,7 +873,7 @@ internal void DoDuplicateShapePreviewHandle(Vector3 position)
868873
869874 m_Bounds . center = cornerPosition + new Vector3 ( size . x / 2f , 0 , size . z / 2f ) + ( size . y / 2f ) * m_Plane . normal ;
870875 var lastPreviewRotation = m_PlaneRotation ;
871- m_PlaneRotation = Quaternion . LookRotation ( m_PlaneForward , m_Plane . normal ) ;
876+ UpdatePlaneRotation ( ) ;
872877 var forceRebuildPreview = ! m_PlaneRotation . Equals ( lastPreviewRotation ) ||
873878 m_LastPreviewPivotLocation != pivotLocation ;
874879 m_LastPreviewPivotLocation = pivotLocation ;
@@ -919,7 +924,7 @@ internal void DoDuplicateShapePreviewHandle(Vector3 position)
919924 pivot += .5f * size . y * m_Plane . normal ;
920925 else
921926 pivot = previewPivotPosition ;
922- m_DuplicateGO . transform . SetPositionAndRotation ( pivot , Quaternion . LookRotation ( m_PlaneForward , m_Plane . normal ) ) ;
927+ m_DuplicateGO . transform . SetPositionAndRotation ( pivot , m_PlaneRotation ) ;
923928
924929 DrawBoundingBox ( preview_BB_Origin , preview_BB_HeightCorner , preview_BB_OppositeCorner , false ) ;
925930 }
@@ -943,7 +948,7 @@ void RecalculateBounds()
943948 if ( Mathf . Abs ( m_Bounds . center . y ) < 0.0001f )
944949 m_Bounds . center = m_Bounds . center + 0.0001f * Vector3 . up ;
945950
946- m_PlaneRotation = Quaternion . LookRotation ( m_PlaneForward , m_Plane . normal ) ;
951+ UpdatePlaneRotation ( ) ;
947952 }
948953
949954 internal void RebuildShape ( )
0 commit comments