Пример #1
0
            public FoundWave(WaterWavesSpectrumData spectrum, WaterWave wave)
            {
                this.spectrum = spectrum;
                this.wave     = wave;

                importance = wave.cpuPriority * spectrum.Weight;
            }
Пример #2
0
        public bool SetResolveMode(bool resolveByFFT, int resolution)
        {
            if (this.resolveByFFT != resolveByFFT || (this.resolveByFFT && this.resolutionFFT != resolution))
            {
                if (resolveByFFT)
                {
                    lock (this)
                    {
                        this.resolutionFFT = resolution;
                        this.mipIndexFFT   = WaterWavesSpectrumData.GetMipIndex(resolution);
                        int resolutionSquared = resolution * resolution;
                        directionalSpectrum      = new Vector2[resolutionSquared];
                        displacements            = new Vector2[4][];
                        forceAndHeight           = new vector4[4][];
                        resultsTiming            = new float[4];
                        directionalSpectrumDirty = 2;
                        cachedTime = float.NegativeInfinity;

                        for (int i = 0; i < 4; ++i)
                        {
                            displacements[i]  = new Vector2[resolutionSquared];
                            forceAndHeight[i] = new vector4[resolutionSquared];
                        }

                        if (this.resolveByFFT == false)
                        {
                            WaterAsynchronousTasks.Instance.AddFFTComputations(this);
                            this.resolveByFFT = true;
                        }
                    }
                }
                else
                {
                    WaterAsynchronousTasks.Instance.RemoveFFTComputations(this);
                    this.resolveByFFT = false;
                }

                return(true);
            }

            return(false);
        }
Пример #3
0
        public WaterWavesSpectrumData GetSpectrumData(WaterWavesSpectrum spectrum)
        {
            WaterWavesSpectrumData spectrumData;

            if (!spectraDataCache.TryGetValue(spectrum, out spectrumData))
            {
                lock (spectraDataCache)
                {
                    spectraDataCache[spectrum] = spectrumData = new WaterWavesSpectrumData(water, spectrum);
                }

                spectrumData.ValidateSpectrumData();
                cpuWavesDirty = true;

                lock (spectraDataList)
                {
                    spectraDataList.Add(spectrumData);
                }
            }

            return(spectrumData);
        }