Exemplo n.º 1
0
    public Mesh ApplyHeightFunction(I2DFunction function, Vector2 sampleOffset)
    {
        UnityEngine.Profiling.Profiler.BeginSample("Apply function");
        UnityEngine.Profiling.Profiler.BeginSample("Loop");
        List <Vector3> vertices = new List <Vector3>();

        mGrid.IterateOverPoints((point) =>
        {
            float height = function.Sample(point.Position + sampleOffset);

            vertices.Add(new Vector3()
            {
                x = point.Position.x,
                y = height,
                z = point.Position.y
            });
        });

        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Apply result to mesh");
        mMesh.vertices = vertices.ToArray();
        mMesh.RecalculateNormals();
        UnityEngine.Profiling.Profiler.EndSample();
        UnityEngine.Profiling.Profiler.EndSample();
        return(mMesh);
    }
Exemplo n.º 2
0
 public void AddFunction(Vector2 position, I2DFunction function)
 {
     mPlacedFunctions.Add(new PlacedFunction()
     {
         Position = position,
         Function = function
     });
 }
Exemplo n.º 3
0
 public static float Sample(this I2DFunction function, Vector2 position)
 {
     return(function.Sample(position.x, position.y));
 }