Exemplo n.º 1
0
        public void CopyAndCreateDisplacements(out IList <InterpolatedArray2f> displacements)
        {
            //Debug.Log("Copy and create");

            InterpolatedArray2f[] source = GetReadDisplacements();
            QueryDisplacements.CopyAndCreateDisplacements(source, out displacements);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Run the task.
        /// Warning - this will not run on the main thread.
        /// </summary>
        public override IEnumerator Run()
        {
            var e = Querys.GetEnumerator();

            while (e.MoveNext())
            {
                //Task has been cancelled. Stop and return.
                if (Cancelled)
                {
                    break;
                }

                WaveQuery query = e.Current;

                query.result.Clear();

                //Sample the spectrum waves.
                if (Displacements != null)
                {
                    QueryDisplacements.QueryWaves(query, EnabledBuffers, Displacements, Scaling);
                }

                query.result.height += OceanLevel;
            }

            FinishedRunning();
            return(null);
        }
Exemplo n.º 3
0
        public override IEnumerator Run()
        {
            m_max = QueryDisplacements.MaxRange(m_displacements, m_choppyness, m_gridScale, this);

            FinishedRunning();
            return(null);
        }
Exemplo n.º 4
0
        public void QueryWaves(WaveQuery query, QueryGridScaling scaling)
        {
            int num = this.EnabledBuffers();

            if (num == 0)
            {
                return;
            }
            QueryDisplacements.QueryWaves(query, num, this.m_displacements, scaling);
        }
Exemplo n.º 5
0
        public void QueryWaves(WaveQuery query, QueryGridScaling scaling)
        {
            int num = this.EnabledBuffers();

            if (num == 0)
            {
                return;
            }
            InterpolatedArray2f[] readDisplacements = this.GetReadDisplacements();
            QueryDisplacements.QueryWaves(query, num, readDisplacements, scaling);
        }
Exemplo n.º 6
0
        public void QueryWaves(WaveQuery query, QueryGridScaling scaling)
        {
            int enabled = EnabledBuffers();

            //If no buffers are enabled there is nothing to sample.
            if (enabled == 0)
            {
                return;
            }

            QueryDisplacements.QueryWaves(query, enabled, m_displacements, scaling);
        }
Exemplo n.º 7
0
        public void QueryWaves(WaveQuery query, QueryGridScaling scaling)
        {
            int enabled = EnabledBuffers();

            //If no buffers are enabled there is nothing to sample.
            if (enabled == 0)
            {
                return;
            }

            InterpolatedArray2f[] displacements = GetReadDisplacements();

            QueryDisplacements.QueryWaves(query, enabled, displacements, scaling);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Run the task.
        /// This will run on the main thread.
        /// </summary>
        public override IEnumerator Run()
        {
            int count = 0;
            int querysPerIteration = Math.Max(1, QuerysPerIteration);

            var e = Querys.GetEnumerator();

            while (e.MoveNext())
            {
                //Task has been cancelled. Stop and return.
                if (Cancelled)
                {
                    yield break;
                }

                WaveQuery query = e.Current;

                query.result.Clear();

                //Sample the spectrum waves.
                if (Displacements != null)
                {
                    QueryDisplacements.QueryWaves(query, EnabledBuffers, Displacements, Scaling);
                }

                //Sample the overlay waves.
                if (OverlaySampler != null)
                {
                    OverlaySampler.QueryWaves(query);
                }

                query.result.height += OceanLevel;

                //If count has reached the number of querys to perform
                //each iteration the yield and come back next frame.
                if (count % querysPerIteration == querysPerIteration - 1)
                {
                    yield return(null);
                }

                count++;
            }

            FinishedRunning();
            yield break;
        }
Exemplo n.º 9
0
        private void RunQueries()
        {
            IEnumerator <WaveQuery> enumerator = this.m_querys.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (this.Cancelled)
                {
                    return;
                }
                WaveQuery current = enumerator.Current;
                current.result.Clear();
                if (current.mode == QUERY_MODE.DISPLACEMENT || current.mode == QUERY_MODE.POSITION)
                {
                    QueryDisplacements.QueryWaves(current, this.m_enabled, this.m_displacements, this.m_scaling);
                }
                WaveQuery expr_64_cp_0 = current;
                expr_64_cp_0.result.height = expr_64_cp_0.result.height + this.m_level;
            }
        }
Exemplo n.º 10
0
        private void RunQueries()
        {
            IEnumerator <WaveQuery> enumerator = this.m_querys.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (base.Cancelled)
                {
                    return;
                }
                WaveQuery waveQuery = enumerator.Current;
                waveQuery.result.Clear();
                if (waveQuery.mode == QUERY_MODE.DISPLACEMENT || waveQuery.mode == QUERY_MODE.POSITION)
                {
                    QueryDisplacements.QueryWaves(waveQuery, this.m_enabled, this.m_displacements, this.m_scaling);
                }
                WaveQuery waveQuery2 = waveQuery;
                waveQuery2.result.height = waveQuery2.result.height + this.m_level;
            }
        }
        void RunQueries()
        {
            var e = m_querys.GetEnumerator();

            while (e.MoveNext())
            {
                if (Cancelled)
                {
                    return;
                }

                WaveQuery query = e.Current;

                query.result.Clear();

                //Only these modes are relevant to this code.
                if (query.mode == QUERY_MODE.DISPLACEMENT || query.mode == QUERY_MODE.POSITION)
                {
                    QueryDisplacements.QueryWaves(query, m_enabled, m_displacements, m_scaling);
                }

                query.result.height += m_level;
            }
        }
Exemplo n.º 12
0
        public Vector4 MaxRange(Vector4 choppyness, Vector2 gridScale)
        {
            InterpolatedArray2f[] displacements = GetReadDisplacements();

            return(QueryDisplacements.MaxRange(displacements, choppyness, gridScale, null));
        }
Exemplo n.º 13
0
 public void CopyDisplacements(IList <InterpolatedArray2f> displacements)
 {
     InterpolatedArray2f[] source = GetReadDisplacements();
     QueryDisplacements.CopyDisplacements(source, displacements);
 }
Exemplo n.º 14
0
 public void CopyDisplacements(IList <InterpolatedArray2f> displacements)
 {
     InterpolatedArray2f[] readDisplacements = this.GetReadDisplacements();
     QueryDisplacements.CopyDisplacements(readDisplacements, displacements);
 }
 public void CopyAndCreateDisplacements(out IList <InterpolatedArray2f> displacements)
 {
     InterpolatedArray2f[] source = GetReadDisplacements();
     QueryDisplacements.CopyAndCreateDisplacements(source, out displacements);
 }
Exemplo n.º 16
0
        public static void QueryWaves(WaveQuery query, int enabled, IList <InterpolatedArray2f> displacements, QueryGridScaling scaling)
        {
            if (displacements.Count != QueryDisplacements.GRIDS)
            {
                throw new InvalidOperationException("Query Displacements requires a displacement buffer for each of the " + QueryDisplacements.GRIDS + " grids.");
            }
            if (displacements[0].Channels != QueryDisplacements.CHANNELS)
            {
                throw new InvalidOperationException("Query Displacements requires displacement buffers have " + QueryDisplacements.CHANNELS + " channels.");
            }
            if (query.mode != QUERY_MODE.DISPLACEMENT && query.mode != QUERY_MODE.POSITION)
            {
                return;
            }
            float num  = query.posX + scaling.offset.x;
            float num2 = query.posZ + scaling.offset.z;

            if (enabled == 0)
            {
                return;
            }
            if (enabled == 1 || query.mode == QUERY_MODE.DISPLACEMENT)
            {
                QueryDisplacements.SampleHeightOnly(query.result.displacement, displacements, query.sampleSpectrum, num, num2, scaling, scaling.tmp);
                query.result.height        = query.result.displacement[0].y + query.result.displacement[1].y + query.result.displacement[2].y + query.result.displacement[3].y;
                query.result.displacementX = 0f;
                query.result.displacementZ = 0f;
                query.result.iterations    = 0;
                query.result.error         = 0f;
                query.result.height        = Mathf.Clamp(query.result.height, -40f, 40f);
            }
            else
            {
                float num3 = num;
                float num4 = num2;
                float num5 = num;
                float num6 = num2;
                float num7 = query.minError;
                if (num7 < 0.1f)
                {
                    num7 = 0.1f;
                }
                num7 *= num7;
                int   num8 = 0;
                float num9;
                float num10;
                float num13;
                do
                {
                    num5 += num - num3;
                    num6 += num2 - num4;
                    QueryDisplacements.Sample(query.result.displacement, displacements, query.sampleSpectrum, num5, num6, scaling, scaling.tmp);
                    num9  = query.result.displacement[0].x + query.result.displacement[1].x + query.result.displacement[2].x + query.result.displacement[3].x;
                    num10 = query.result.displacement[0].z + query.result.displacement[1].z + query.result.displacement[2].z + query.result.displacement[3].z;
                    num3  = num5 + num9;
                    num4  = num6 + num10;
                    num8++;
                    float num11 = num - num3;
                    float num12 = num2 - num4;
                    num13 = num11 * num11 + num12 * num12;
                }while (num13 > num7 && num8 <= WaveQuery.MAX_ITERATIONS);
                query.result.height        = query.result.displacement[0].y + query.result.displacement[1].y + query.result.displacement[2].y + query.result.displacement[3].y;
                query.result.displacementX = num9;
                query.result.displacementZ = num10;
                query.result.iterations    = num8;
                query.result.error         = num13;
                query.result.height        = Mathf.Clamp(query.result.height, -40f, 40f);
            }
        }
Exemplo n.º 17
0
 public Vector4 MaxRange(Vector4 choppyness, Vector2 gridScale)
 {
     return(QueryDisplacements.MaxRange(this.m_displacements, choppyness, gridScale, null));
 }
Exemplo n.º 18
0
 public void CopyDisplacements(IList <InterpolatedArray2f> displacements)
 {
     QueryDisplacements.CopyDisplacements(this.m_displacements, displacements);
 }
Exemplo n.º 19
0
 public void CopyAndCreateDisplacements(out IList <InterpolatedArray2f> displacements)
 {
     QueryDisplacements.CopyAndCreateDisplacements(this.m_displacements, out displacements);
 }