public PositionSimulation(ComputeShader compute, VelocityService v, PositionService p) { _kernelSimulate = compute.FindKernel(ShaderConst.KERNEL_SIMULATE_POSITION); _compute = compute; _velocities = v; _positions = p; }
public BoundsChecker(ComputeShader compute, LifeService l, PositionService p) { _kernel = compute.FindKernel(ShaderConst.KERNEL_CHECK_BOUNDS); _compute = compute; _lifes = l; _positions = p; }
void Start() { Positions = new PositionService(compute, capacity); Velocities = new VelocityService(compute, capacity); Lifes = new LifeService(compute, capacity); Constants = new ConstantService(constants); VelSimulation = new VelocitySimulation(compute, Velocities); PosSimulation = new PositionSimulation(compute, Velocities, Positions); Broadphase = new BroadPhase(compute, computeSort, Lifes, Positions); ParticleSolver = new ParticleCollisionSolver(compute, Velocities, Positions, Lifes, Broadphase); BoundsChecker = new BoundsChecker(compute, Lifes, Positions); Walls = BuildWalls(wallColliders); WallSolver = new WallCollisionSolver(compute, Velocities, Positions, Walls); var particles = new GameObject[capacity]; foreach (var p in particlefabs) { p.transform.localScale = 2f * constants.radius * Vector3.one; } for (var i = 0; i < capacity; i++) { particles[i] = particlefabs[Random.Range(0, particlefabs.Length)]; } Combiner = new MeshCombiner(containerfab); Combiner.Rebuild(particles); Combiner.SetParent(transform, false); UpdateConstantData(); }
public WallCollisionSolver(ComputeShader compute, VelocityService v, PositionService p, WallService w) { _kernel = compute.FindKernel(ShaderConst.KERNEL_SOLVE_WALL_COLLISION); _compute = compute; _velocities = v; _positions = p; _walls = w; }
void Start() { _positions = new PositionService(compute, capacity); _velocities = new VelocityService(compute, capacity); _lifes = new LifeService(compute, capacity); _velSimulation = new VelocitySimulation(compute, _velocities); _posSimulation = new PositionSimulation(compute, _velocities, _positions); }
public ParticleCollisionSolver(ComputeShader compute, VelocityService v, PositionService p, LifeService l, ICollisionDetection b) { _kernel = compute.FindKernel(ShaderConst.KERNEL_SOLVE_PARTICLE_COLLISION); _compute = compute; _velocities = v; _positions = p; _lifes = l; _broadphase = b; }
public ParticleCollisionSolver(ComputeShader compute, VelocityService v, PositionService p, LifeService l, BroadPhase b) { _kernel = compute.FindKernel(ShaderConst.KERNEL_SOLVE_PARTICLE_COLLISION); _compute = compute; _velocities = v; _positions = p; _lifes = l; _broadphase = b; }
public PolygonCollisionSolver(ComputeShader c, VelocityService v, PositionService p, LifeService l, PolygonColliderService poly) { _compute = c; _kernel = c.FindKernel(ShaderConst.KERNEL_SOLVE_POLYGON_COLLISION); _velocities = v; _positions = p; _lifes = l; _polygons = poly; }
public HashService(ComputeShader compute, LifeService l, PositionService p) { _compute = compute; _lifes = l; _positions = p; _kernelInitHashes = compute.FindKernel(ShaderConst.KERNEL_INIT_HASHES); HashData = new int[l.Lifes.count]; Hashes = new ComputeBuffer(l.Lifes.count, Marshal.SizeOf(typeof(int))); Hashes.SetData(HashData); }
public HashService(ComputeShader compute, LifeService l, PositionService p) { _compute = compute; _lifes = l; _positions = p; _kernelInitHashes = compute.FindKernel(ShaderConst.KERNEL_INIT_HASHES); HashData = new int[l.Lifes.count]; Hashes = new ComputeBuffer(l.Lifes.count, Marshal.SizeOf(typeof(int))); Hashes.SetData (HashData); }
public BroadPhase(ComputeShader compute, ComputeShader computeSort, LifeService l, PositionService p) { var capacity = l.Lifes.count; _lifes = l; _positions = p; _kernelInitYs = compute.FindKernel(ShaderConst.KERNEL_INIT_BROADPHASE); _kernelSolve = compute.FindKernel (ShaderConst.KERNEL_SOVLE_BROADPHASE); _compute = compute; _sort = new BitonicMergeSort(computeSort); Keys = new ComputeBuffer(capacity, Marshal.SizeOf(typeof(uint))); _ys = new ComputeBuffer(capacity, Marshal.SizeOf(typeof(float))); Bands = new ComputeBuffer(capacity, Marshal.SizeOf(typeof(Band))); }
public BroadPhase(ComputeShader compute, ComputeShader computeSort, LifeService l, PositionService p) { var capacity = l.Lifes.count; _lifes = l; _positions = p; _kernelInitYs = compute.FindKernel(ShaderConst.KERNEL_INIT_BROADPHASE); _kernelSolve = compute.FindKernel(ShaderConst.KERNEL_SOVLE_BROADPHASE); _compute = compute; _sort = new BitonicMergeSort(computeSort); Keys = new ComputeBuffer(capacity, Marshal.SizeOf(typeof(uint))); _ys = new ComputeBuffer(capacity, Marshal.SizeOf(typeof(float))); Bands = new ComputeBuffer(capacity, Marshal.SizeOf(typeof(Band))); }
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); }
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); }
void Start() { capacity = ShaderUtil.PowerOfTwo(capacity); Positions = new PositionService(compute, capacity); Velocities = new VelocityService(compute, capacity); Lifes = new LifeService(compute, capacity); Constants = new ConstantService(capacity, constants); VelSimulation = new VelocitySimulation(compute, Velocities, Constants); PosSimulation = new PositionSimulation(compute, Velocities, Positions); Collisions = new HashGrid(compute, computeSort, Lifes, Positions, GenerateGrid()); ParticleSolver = new ParticleCollisionSolver(compute, Velocities, Positions, Lifes, Collisions); BoundsChecker = new BoundsChecker(compute, Lifes, Positions); Polygons = new PolygonColliderService(); PolygonSolver = new PolygonCollisionSolver(compute, Velocities, Positions, Lifes, Polygons); var particles = new GameObject[capacity]; foreach (var pfab in particlefabs) { pfab.transform.localScale = 2f * constants.radius * Vector3.one; } Profiler.BeginSample("Instantiate Particles"); for (var i = 0; i < capacity; i++) { var pfab = particlefabs[Random.Range(0, particlefabs.Length)]; particles[i] = (GameObject)Instantiate(pfab, Vector3.zero, Random.rotationUniform); } Profiler.EndSample(); Combiner = new MeshCombiner(containerfab); Combiner.Rebuild(particles); Combiner.SetParent(transform, false); for (var i = 0; i < capacity; i++) { Destroy(particles[i]); } UpdateConstantData(); _initialized = true; }
void Start() { _positions = new PositionService (compute, capacity); _lifes = new LifeService(compute, capacity); }
void Start() { capacity = ShaderUtil.PowerOfTwo(capacity); Positions = new PositionService(compute, capacity); Velocities = new VelocityService(compute, capacity); Lifes = new LifeService(compute, capacity); Constants = new ConstantService(capacity, constants); VelSimulation = new VelocitySimulation(compute, Velocities, Constants); PosSimulation = new PositionSimulation(compute, Velocities, Positions); Collisions = new HashGrid(compute, computeSort, Lifes, Positions, GenerateGrid()); ParticleSolver = new ParticleCollisionSolver(compute, Velocities, Positions, Lifes, Collisions); BoundsChecker = new BoundsChecker(compute, Lifes, Positions); Polygons = new PolygonColliderService(); PolygonSolver = new PolygonCollisionSolver(compute, Velocities, Positions, Lifes, Polygons); var particles = new GameObject[capacity]; foreach (var pfab in particlefabs) pfab.transform.localScale = 2f * constants.radius * Vector3.one; Profiler.BeginSample("Instantiate Particles"); for (var i = 0; i < capacity; i++) { var pfab = particlefabs[Random.Range(0, particlefabs.Length)]; particles[i] = (GameObject)Instantiate(pfab, Vector3.zero, Random.rotationUniform); } Profiler.EndSample(); Combiner = new MeshCombiner(containerfab); Combiner.Rebuild(particles); Combiner.SetParent(transform, false); for (var i = 0; i < capacity; i++) Destroy(particles[i]); UpdateConstantData(); _initialized = true; }
void Start() { Positions = new PositionService(compute, capacity); Velocities = new VelocityService(compute, capacity); Lifes = new LifeService(compute, capacity); Constants = new ConstantService(constants); VelSimulation = new VelocitySimulation(compute, Velocities); PosSimulation = new PositionSimulation(compute, Velocities, Positions); Broadphase = new BroadPhase(compute, computeSort, Lifes, Positions); ParticleSolver = new ParticleCollisionSolver(compute, Velocities, Positions, Lifes, Broadphase); BoundsChecker = new BoundsChecker(compute, Lifes, Positions); Walls = BuildWalls(wallColliders); WallSolver = new WallCollisionSolver(compute, Velocities, Positions, Walls); var particles = new GameObject[capacity]; foreach (var p in particlefabs) p.transform.localScale = 2f * constants.radius * Vector3.one; for (var i = 0; i < capacity; i++) particles[i] = particlefabs[Random.Range(0, particlefabs.Length)]; Combiner = new MeshCombiner(containerfab); Combiner.Rebuild(particles); Combiner.SetParent(transform, false); UpdateConstantData(); }