Пример #1
0
    public static void InnerDistanceToBoundary(Ray ray, GridStep steps, Vector3 min, Vector3 max, ref RayHit rayHitX, ref RayHit rayHitY, ref RayHit rayHitZ)
    {
        if (steps.x >= 0)
        {
            rayHitX = RayPlaneIntersectionCompute.RayPlaneIntersection(ray, GridNormalLeft, max);
        }
        else
        {
            rayHitX = RayPlaneIntersectionCompute.RayPlaneIntersection(ray, GridNormalRight, min);
        }

        if (steps.y >= 0)
        {
            rayHitY = RayPlaneIntersectionCompute.RayPlaneIntersection(ray, GridNormalDown, max);
        }
        else
        {
            rayHitY = RayPlaneIntersectionCompute.RayPlaneIntersection(ray, GridNormalUp, min);
        }

        if (steps.z >= 0)
        {
            rayHitZ = RayPlaneIntersectionCompute.RayPlaneIntersection(ray, GridNormalBack, max);
        }
        else
        {
            rayHitZ = RayPlaneIntersectionCompute.RayPlaneIntersection(ray, GridNormalForward, min);
        }
    }
Пример #2
0
    public static void DistanceBetweenBoundary(Ray ray, GridStep steps, SpatialGridIndex entryGridIndex, SpatialGrid grids, Vector3 firstHitX, Vector3 firstHitY, Vector3 firstHitZ, ref RayHit rayHitX, ref RayHit rayHitY, ref RayHit rayHitZ)
    {
        Vector3 min = GetGridLocalMin(grids, entryGridIndex);
        Vector3 max = GetGridLocalMax(grids, entryGridIndex);

        Ray rX = SpatialGridTrace.CreateRay(firstHitX, ray.direction);
        Ray rY = SpatialGridTrace.CreateRay(firstHitY, ray.direction);
        Ray rZ = SpatialGridTrace.CreateRay(firstHitZ, ray.direction);

        if (steps.x >= 0)
        {
            rayHitX = RayPlaneIntersectionCompute.RayPlaneIntersection(rX, GridNormalLeft, max + GridNormalRight);
        }
        else
        {
            rayHitX = RayPlaneIntersectionCompute.RayPlaneIntersection(rX, GridNormalRight, min + GridNormalLeft);
        }

        if (steps.y >= 0)
        {
            rayHitY = RayPlaneIntersectionCompute.RayPlaneIntersection(rY, GridNormalDown, max + GridNormalUp);
        }
        else
        {
            rayHitY = RayPlaneIntersectionCompute.RayPlaneIntersection(rY, GridNormalUp, min + GridNormalDown);
        }

        if (steps.z >= 0)
        {
            rayHitZ = RayPlaneIntersectionCompute.RayPlaneIntersection(rZ, GridNormalBack, max + GridNormalForward);
        }
        else
        {
            rayHitZ = RayPlaneIntersectionCompute.RayPlaneIntersection(rZ, GridNormalForward, min + GridNormalBack);
        }
    }