Ejemplo n.º 1
0
            public HKT <ListHKT, B> Map <A, B>(Func <A, B> f, HKT <ListHKT, A> a)
            {
                List <A> aList = ListHKT <A> .Narrow(a).value;

                B[] result = new B[aList.Count];
                for (int i = 0; i < aList.Count; i++)
                {
                    result[i] = f(aList[i]);
                }
                return(new ListHKT <B>(new List <B>(result)));
            }
Ejemplo n.º 2
0
    void Awake()
    {
        /*
         *      Generate initial wave height field (h0k h0minusk) textures
         */
        h0k = new H0K(N, L, amplitude, windSpeed, capillarSupressFactor, direction, noiseTexture1, noiseTexture2, noiseTexture3, noiseTexture4, h0kComputeShader);
        h0k.Run();

        /*
         *      Generate twiddle factors texture
         */
        twiddleFactors = new TwiddleFactors(N, twiddleFactorsComputeShader);
        twiddleFactors.Run();

        /*
         *      Generate wave height field textures at time t (dx/dy/dz displacement)
         */
        hkt = new HKT(N, L, T, ConvertToTexture2D(h0k.h0kOutputRenderTexture, N), ConvertToTexture2D(h0k.h0minuskOutputRenderTexture, N), hktComputeShader);
        hkt.Run();
        outputMaterial.mainTexture = hkt.dyDisplacementOutputRenderTexture;
    }
Ejemplo n.º 3
0
 public HKT <State <S>, B> FlatMap <A, B>(HKT <State <S>, A> a, Func <A, HKT <State <S>, B> > f) =>
Ejemplo n.º 4
0
 public HKT <ListHKT, B> Map <A, B>(Func <A, B> f, HKT <ListHKT, A> a) =>
 new ListHKT <B>(new List <B>(
                     ListHKT <A> .Narrow(a).value.Select(f)));
Ejemplo n.º 5
0
        public HKT <Maybe, B> FlatMap <A, B>(HKT <Maybe, A> a, Func <A, HKT <Maybe, B> > f)
        {
            A value = ((Just <A>)Maybe <A> .Narrow(a)).value;

            return(value == null ? new Nothing <B>() : f(value));
        }
Ejemplo n.º 6
0
 public HKT <ListHKT, B> FlatMap <A, B>(HKT <ListHKT, A> a, Func <A, HKT <ListHKT, B> > f) =>
 ListHKT <A> .Narrow(a).value.Aggregate(new ListHKT <B>(), (result, ele) =>
 {
     result.value.AddRange(ListHKT <B> .Narrow(f(ele)).value);
     return(result);
 });