public HeightMapCache(int poolSize)
 {
     sectorsDict = new FastHashSet <int>(16);
     sectorsPool = new HeightMapInfoPoolEntry[poolSize];
     for (int k = 0; k < sectorsPool.Length; k++)
     {
         sectorsPool[k] = new HeightMapInfoPoolEntry();
     }
     lastSector = -1;
 }
        /// <summary>
        /// Toggles on/off hidden voxels.
        /// </summary>
        void ToggleHiddenVoxels(VoxelChunk chunk, bool show)
        {
            if (chunk == null)
            {
                return;
            }

            FastHashSet <VoxelExtraData> data = chunk.voxelsExtraData;

            if (data == null)
            {
                return;
            }

            int count = data.Count;

            Voxel[] voxels = chunk.voxels;

            for (int k = 0; k < count; k++)
            {
                int voxelIndex = data.entries [k].key;
                if (voxelIndex >= 0)
                {
                    if (data.entries [k].value.hidden)
                    {
                        if (show)
                        {
                            voxels [voxelIndex].typeIndex = data.entries [k].value.hiddenTypeIndex;
                            voxels [voxelIndex].opaque    = data.entries [k].value.hiddenOpaque;
                            voxels [voxelIndex].light     = data.entries [k].value.hiddenLight;
                        }
                        else
                        {
                            ushort typeIndex = voxels [voxelIndex].typeIndex;
                            data.entries [k].value.hiddenTypeIndex = typeIndex;
                            data.entries [k].value.hiddenOpaque    = voxels [voxelIndex].opaque;
                            data.entries [k].value.hiddenLight     = voxels [voxelIndex].light;
                            VoxelDefinition vd = voxelDefinitions [typeIndex];
                            switch (vd.seeThroughMode)
                            {
                            case SeeThroughMode.None:
                                voxels [voxelIndex].typeIndex = 0;                                 // null voxel whose renderType = Empty (but genereate colliders)
                                voxels [voxelIndex].opaque    = 0;
                                break;

                            case SeeThroughMode.ReplaceVoxel:
                                voxels [voxelIndex].typeIndex = vd.seeThroughVoxel.index;                                 // null voxel whose renderType = Empty (but genereate colliders)
                                voxels [voxelIndex].opaque    = vd.seeThroughVoxel.opaque;
                                break;

                            case SeeThroughMode.Transparency:
                                voxels [voxelIndex].typeIndex = (ushort)vd.seeThroughVoxelTempTransp;                                 // null voxel whose renderType = Empty (but genereate colliders)
                                voxels [voxelIndex].opaque    = 0;
                                break;
                            }
                            voxels [voxelIndex].light = 15;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 public HeightMapCache()
 {
     heightSectors = new FastHashSet <HeightMapInfo[]> (16);
 }