internal void CompleteRayCastHits()
        {
            m_Normals.Clear();

            var scaledMinimumDistance = m_MinHitDistance * m_DistanceScale;

            var length = m_Raycasts.Length;

            m_Normals.EnsureCapacity(length);
            NativeArrayUtils.EnsureCapacity(ref m_Identifiers, length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
            NativeArrayUtils.EnsureCapacity(ref m_Positions, length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
            NativeArrayUtils.EnsureCapacity(ref m_ConfidenceValues, length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);

            var hitCount = 0;

            for (var i = 0; i < length; i++)
            {
                var result = m_RaycastHits[i];
                if (result.collider == null)
                {
                    continue;
                }

                if (result.distance < scaledMinimumDistance)
                {
                    continue;
                }

                m_Normals.Add(this.ApplyInverseOffsetToDirection(result.normal));
                m_Identifiers[hitCount]      = (ulong)i;
                m_Positions[hitCount]        = this.ApplyInverseOffsetToPosition(result.point);
                m_ConfidenceValues[hitCount] = Random.Range(0f, 1f);
                hitCount++;
            }

            var data = new PointCloudData
            {
                Identifiers      = new NativeSlice <ulong>(m_Identifiers, 0, hitCount),
                Positions        = new NativeSlice <Vector3>(m_Positions, 0, hitCount),
                ConfidenceValues = new NativeSlice <float>(m_ConfidenceValues, 0, hitCount)
            };

            m_Data[m_TrackableId] = data;

            if (PointCloudUpdated != null)
            {
                PointCloudUpdated(GetPoints());
            }
        }
        void ProcessPointCloudEvent(PointCloudEventMarker pointCloudEvent)
        {
            var idCount              = 0;
            var positionCount        = 0;
            var confidenceValueCount = 0;

            foreach (var pointCloud in pointCloudEvent.Data)
            {
                var identifiers = pointCloud.Identifiers;
                if (identifiers != null)
                {
                    idCount += identifiers.Length;
                }

                var positions = pointCloud.Positions;
                if (positions != null)
                {
                    positionCount += positions.Length;
                }

                var confidenceValues = pointCloud.ConfidenceValues;
                if (confidenceValues != null)
                {
                    confidenceValueCount += confidenceValues.Length;
                }
            }

            NativeArrayUtils.EnsureCapacity(ref m_Identifiers, idCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
            NativeArrayUtils.EnsureCapacity(ref m_Positions, idCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
            NativeArrayUtils.EnsureCapacity(ref m_ConfidenceValues, idCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);

            idCount              = 0;
            positionCount        = 0;
            confidenceValueCount = 0;
            m_Data.Clear();
            foreach (var pointCloud in pointCloudEvent.Data)
            {
                var data      = new PointCloudData();
                var positions = pointCloud.Positions;
                if (positions == null)
                {
                    continue;
                }

                var length = positions.Length;
                for (var i = 0; i < length; i++)
                {
                    m_Positions[i + positionCount] = positions[i];
                }

                data.Positions = new NativeSlice <Vector3>(m_Positions, positionCount, length);
                positionCount += length;

                var identifiers = pointCloud.Identifiers;
                if (identifiers != null && identifiers.Length == length)
                {
                    for (var i = 0; i < length; i++)
                    {
                        m_Identifiers[i + idCount] = identifiers[i];
                    }

                    data.Identifiers = new NativeSlice <ulong>(m_Identifiers, idCount, length);
                    idCount         += length;
                }

                var confidenceValues = pointCloud.ConfidenceValues;
                if (confidenceValues != null && confidenceValues.Length == length)
                {
                    for (var i = 0; i < length; i++)
                    {
                        m_ConfidenceValues[i + confidenceValueCount] = confidenceValues[i];
                    }

                    data.ConfidenceValues = new NativeSlice <float>(m_ConfidenceValues, confidenceValueCount, length);
                    confidenceValueCount += length;
                }

                m_Data[pointCloud.Id] = data;
            }

            PointCloudUpdated?.Invoke(GetPoints());
        }