Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeArray extensions for accelerating LiDAR processing #154

Open
Autumn60 opened this issue Mar 1, 2024 · 0 comments
Open

NativeArray extensions for accelerating LiDAR processing #154

Autumn60 opened this issue Mar 1, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Autumn60
Copy link
Contributor

Autumn60 commented Mar 1, 2024

This NativeArray extension could optimize LiDAR calculation.

using System;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;

namespace HOGE_NAMESPACE
{
    public static partial class NativeArrayRefExtensions
    {
        public static ref T GetRef<T>(this NativeArray<T> array, int index)
            where T : struct
        {
            if (index < 0 || index >= array.Length)
                throw new ArgumentOutOfRangeException(nameof(index));
            unsafe
            {
                return ref UnsafeUtility.ArrayElementAsRef<T>(array.GetUnsafePtr(), index);
            }
        }
    }
}
@Autumn60 Autumn60 added the enhancement New feature or request label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant