예제 #1
0
        public WaterWave[] FindMostMeaningfulWaves(int waveCount)
        {
            Heap <WaterWave> heap = new Heap <WaterWave>();

            for (int i = this._SpectraDataList.Count - 1; i >= 0; i--)
            {
                WaterWavesSpectrumDataBase waterWavesSpectrumDataBase = this._SpectraDataList[i];
                waterWavesSpectrumDataBase.UpdateSpectralValues(this.WindDirection, this._WindWaves.SpectrumDirectionality);
                object obj = waterWavesSpectrumDataBase;
                lock (obj)
                {
                    float weight = waterWavesSpectrumDataBase.Weight;
                    foreach (WaterWave element in waterWavesSpectrumDataBase.CpuWaves)
                    {
                        element._Amplitude   *= weight;
                        element._CPUPriority *= weight;
                        heap.Insert(element);
                        if (heap.Count > waveCount)
                        {
                            heap.ExtractMax();
                        }
                    }
                }
            }
            return(heap.ToArray <WaterWave>());
        }
예제 #2
0
        public GerstnerWave[] SelectShorelineWaves(int waveCount, float angle, float coincidenceRange)
        {
            Heap <WaterWave> heap = new Heap <WaterWave>();

            for (int i = this._SpectraDataList.Count - 1; i >= 0; i--)
            {
                WaterWavesSpectrumDataBase waterWavesSpectrumDataBase = this._SpectraDataList[i];
                waterWavesSpectrumDataBase.UpdateSpectralValues(this.WindDirection, this._WindWaves.SpectrumDirectionality);
                object obj = waterWavesSpectrumDataBase;
                lock (obj)
                {
                    float weight = waterWavesSpectrumDataBase.Weight;
                    foreach (WaterWave element in waterWavesSpectrumDataBase.ShorelineCandidates)
                    {
                        element._Amplitude   *= weight;
                        element._CPUPriority *= weight;
                        float current = Mathf.Atan2(element._Nkx, element._Nky) * 57.29578f;
                        if (Mathf.Abs(Mathf.DeltaAngle(current, angle)) < coincidenceRange && element._Amplitude > 0.025f)
                        {
                            heap.Insert(element);
                            if (heap.Count > waveCount)
                            {
                                heap.ExtractMax();
                            }
                        }
                    }
                }
            }
            Vector2[] array = new Vector2[4];
            for (int k = 0; k < 4; k++)
            {
                float num = this._WindWaves.TileSizes[k];
                array[k].x = num + 0.5f / (float)this._WindWaves.FinalResolution * num;
                array[k].y = -num + 0.5f / (float)this._WindWaves.FinalResolution * num;
            }
            WaterWave[] array2 = heap.ToArray <WaterWave>();
            int         num2   = Mathf.Min(heap.Count, waveCount);

            GerstnerWave[] array3 = new GerstnerWave[num2];
            for (int l = 0; l < num2; l++)
            {
                array3[l] = new GerstnerWave(array2[heap.Count - l - 1], array);
            }
            return(array3);
        }