Beispiel #1
0
        public void fillOne()
        {
            TTextureParams p = new TTextureParams {
                texMeta  = this,
                tex      = this.Tex,
                localLoc = Vector2.zero,
            };

            TextureController.fillTexture(p);
        }
Beispiel #2
0
        // COMPUTATION HEAVY
        // part of async optimization
        public static void fillTexture(Params par)
        {
            TTextureParams pars = (TTextureParams)par;

            TTexture  t   = pars.texMeta;
            Texture2D tex = pars.tex;

            Vector3 pt = Vector3.zero;

            Color[] colors = tex.GetPixels();

            int v = 0;

            for (int i = 0; i < tex.width; i++)
            {
                for (int j = 0; j < tex.height; j++)
                {
                    pt.x = t.Loc.x + pars.localLoc.x + (float)i / t.resolution;
                    pt.y = t.Loc.z + pars.localLoc.y + (float)j / t.resolution;

                    TextureParams p = new TextureParams {
                        p      = pt,
                        par    = pars,
                        count  = v,
                        colors = colors,
                    };

                    if (optimize)
                    {
                        Job job = new Job {
                            func = textureAsyncFunc,
                            par  = p
                        };
                        newJobs.Add(job);
                    }
                    else
                    {
                        textureAsyncFunc(p);
                    }

                    v++;
                }
            }

            if (optimize)
            {
                OptController.RegisterTasks(newJobs);
            }

            newJobs.Clear();
        }
Beispiel #3
0
        public void fillByTile()
        {
            for (int i = 0; i < density; i++)
            {
                for (int j = 0; j < density; j++)
                {
                    TTextureParams p = new TTextureParams {
                        texMeta  = this,
                        tex      = new Texture2D(resolution, resolution),
                        localLoc = new Vector2(i, j)
                    };

                    Job job = new Job {
                        func = TextureController.fillTexture,
                        par  = p
                    };
                    jobs.Add(job);
                }
            }

            _debug("# of jobs: " + jobs.Count.ToString());
            OptController.RegisterTasks(jobs);
            jobs.Clear();
        }