Beispiel #1
0
        private unsafe void DisableOtherItemsInVMap(MyVoxelBase voxelMap)
        {
            MyOrientedBoundingBoxD obb = MyOrientedBoundingBoxD.Create((BoundingBoxD)voxelMap.PositionComp.LocalAABB, voxelMap.PositionComp.WorldMatrix);
            var center = obb.Center;

            var box = voxelMap.PositionComp.WorldAABB;

            m_entities.Clear();
            MyGamePruningStructure.GetAllEntitiesInBox(ref box, m_entities, MyEntityQueryType.Static);

            for (int eIndex = 0; eIndex < m_entities.Count; ++eIndex)
            {
                var sector = m_entities[eIndex] as MyEnvironmentSector;

                if (sector == null || sector.DataView == null)
                {
                    continue;
                }

                obb.Center = center - sector.SectorCenter;

                for (int sectorInd = 0; sectorInd < sector.DataView.LogicalSectors.Count; sectorInd++)
                {
                    var logicalSector = sector.DataView.LogicalSectors[sectorInd];
                    var logicalItems  = logicalSector.Items;
                    var cnt           = logicalItems.Count;

                    fixed(ItemInfo *items = logicalItems.GetInternalArray())
                    for (int i = 0; i < cnt; ++i)
                    {
                        var point = items[i].Position + sector.SectorCenter;

                        if (items[i].DefinitionIndex >= 0 && obb.Contains(ref items[i].Position) &&
                            voxelMap.CountPointsInside(&point, 1) > 0 && !IsVoxelItem(sector, items[i].DefinitionIndex))
                        {
                            logicalSector.EnableItem(i, false);
                        }
                    }
                }
            }
        }