コード例 #1
0
        public HashGrid(ComputeShader compute, ComputeShader computeSort, LifeService l, PositionService p, GridService.Grid g)
        {
            var capacity = l.Lifes.count;
            _compute = compute;
            _lifes = l;
            _positions = p;

            _kernelSolve = compute.FindKernel (ShaderConst.KERNEL_SOVLE_COLLISION_DETECTION);
            _sort = new BitonicMergeSort(computeSort);
            _keys = new ComputeBuffer(capacity, Marshal.SizeOf(typeof(uint)));
            CollisionData = new Collision[capacity];
            Collisions = new ComputeBuffer(capacity, Marshal.SizeOf(typeof(Collision)));
            _hashes = new HashService(compute, l, p);
            _grid = new GridService(compute, g, _hashes);
        }
コード例 #2
0
ファイル: GridService.cs プロジェクト: nobnak/ParticlePhysics
        public GridService(ComputeShader compute, Grid g, HashService h)
        {
            _compute = compute;
            _grid = g;
            _hashes = h;
            _kernelInit = compute.FindKernel(ShaderConst.KERNEL_INIT_GRID);
            _kernelConstruct = compute.FindKernel(ShaderConst.KERNEL_CONSTRUCT_GRID);
            var gridCellCount = g.nx * g.ny;

            StartData = new uint[gridCellCount];
            EndData = new uint[gridCellCount];
            _hashGridStart = new ComputeBuffer(gridCellCount, Marshal.SizeOf(typeof(uint)));
            _hashGridEnd = new ComputeBuffer(gridCellCount, Marshal.SizeOf(typeof(uint)));
            _hashGridStart.SetData (StartData);
            _hashGridEnd.SetData (EndData);
        }