Esempio n. 1
0
        //  Return reference to voxel map that intersects the box. If not voxel map found, null is returned.
        public static MyVoxelMap GetVoxelMapWhoseBoundingBoxIntersectsBox(ref BoundingBox boundingBox)
        {
            for (int i = 0; i < m_voxelMaps.Count; i++)
            {
                MyVoxelMap voxelMap = m_voxelMaps[i];
                if (voxelMap.IsBoxIntersectingBoundingBoxOfThisVoxelMap(ref boundingBox) == true)
                {
                    return(voxelMap);
                }
            }

            //  If we get here, no intersection was found
            return(null);
        }
Esempio n. 2
0
        //  Return reference to a voxel map that intersects with the specified box. If not intersection, null is returned.
        //  We don't look for closest intersection - so we stop on first intersection found.
        //  Params:
        //      localBoundingBox - local bounding box, we transform it to VoxelMap orientation
        //      boundingBoxWorldPosition - position of bounding box in world coordinates
        public static MyVoxelMap GetIntersectionWithBox(ref BoundingBox localBoundingBox, ref Vector3 boundingBoxWorldPosition, MyVoxelMap selected)
        {
            for (int i = 0; i < m_voxelMaps.Count; i++)
            {
                if (selected == null || m_voxelMaps[i] == selected)
                {
                    MyVoxelMap  voxelMap         = m_voxelMaps[i];
                    Matrix      world            = Matrix.CreateWorld(boundingBoxWorldPosition, voxelMap.WorldMatrix.Forward, voxelMap.WorldMatrix.Up);
                    BoundingBox worldBoundingBox = localBoundingBox.Transform(world);
                    if (voxelMap.IsBoxIntersectingBoundingBoxOfThisVoxelMap(ref worldBoundingBox))
                    {
                        return(voxelMap);
                    }
                }
            }

            //  No intersection found
            return(null);
        }