Exemple #1
0
        void BroadPhaseUpdate()
        {
            var bc = SimElementHelper.ComputeParticlesBoundingCircle(particles, particleRadius);

            trigger.radius = bc.radius;
            trigger.offset = bc.center;
        }
Exemple #2
0
        void LateUpdate()
        {
            Vector3 pos = Input.mousePosition;

            pos.z = -Camera.main.transform.position.z;
            pos   = Camera.main.ScreenToWorldPoint(pos);

            if (!_isDragging)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    int       idx;
                    Matrix4x4 mat = transform.localToWorldMatrix;
                    if (SimElementHelper.FindOverlapParticleIdx(_particles, mat, pos, _particleRadius, out idx))
                    {
                        _isDragging      = true;
                        _draggedParticle = _particles[idx];
                    }
                }
            }
            else
            {
                if (Input.GetMouseButtonUp(0))
                {
                    _isDragging = false;
                }
                else if (Input.GetMouseButton(0))
                {
                    _draggedParticle.pos = transform.worldToLocalMatrix.MultiplyPoint3x4(pos);
                }
            }
        }
Exemple #3
0
 public List <int> GetSimElemIndices <T>() where T : SimElement
 {
     return(SimElementHelper.GetSimElemIndices <T>(_simElements));
 }
Exemple #4
0
 public List <T> GetSimElems <T>() where T : SimElement
 {
     return(SimElementHelper.GetSimElems <T>(_simElements));
 }