Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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;
        }