示例#1
0
    public void Update()
    {
        var point = UnityEngine.Random.insideUnitSphere * 100f;

        // check if a point intersects any of the cube's bounds
        m_Job = new BoundsContainsPointJob()
        {
            point       = point,
            boundsArray = m_NativeBounds,
        };

        // check if a bounding box outside that point intersects any cubes
        m_IntersectionJob = new BoundsIntersectionJob()
        {
            boundsToCheck = new Bounds(point, Vector3.one),
            boundsArray   = m_NativeBounds
        };

        var randomVec = UnityEngine.Random.insideUnitSphere;
        var testRay   = new Ray(Vector3.zero - randomVec, Vector3.right + Vector3.up + randomVec);

        m_RayIntersectionJob = new RayIntersectionJob()
        {
            ray         = testRay,
            results     = m_RayIntersectionResults,
            boundsArray = m_NativeBounds
        };

        m_Results = new NativeArray <Bounds>(new Bounds[20], Allocator.TempJob);

        m_RayIntersectionListJob = new RayIntersectionListJob()
        {
            boundsIntersected = m_RayIntersectionResults,
            boundsArray       = m_NativeBounds,
            results           = m_Results
        };

        m_RayIntersectionJobHandle     = m_RayIntersectionJob.Schedule(m_NativeBounds.Length, 64);
        m_RayIntersectionListJobHandle = m_RayIntersectionListJob.Schedule(m_RayIntersectionJobHandle);

        m_JobHandle             = m_Job.Schedule(m_Positions.Length, 64);
        m_IntersectionJobHandle = m_IntersectionJob.Schedule(m_NativeBounds.Length, 64);
    }
    public void Update()
    {
        var point = Random.insideUnitSphere * 100f;

        // check if a point intersects any of the cube's bounds
        m_Job = new BoundsContainsPointJob()
        {
            point       = point,
            boundsArray = m_NativeBounds,
        };

        // check if a bounding box outside that point intersects any cubes
        m_IntersectionJob = new BoundsIntersectionJob()
        {
            boundsToCheck = new Bounds(point, Vector3.one),
            boundsArray   = m_NativeBounds
        };

        m_JobHandle             = m_Job.Schedule(m_Positions.Length, 64);
        m_IntersectionJobHandle = m_IntersectionJob.Schedule(m_NativeBounds.Length, 64);
    }