public MetaballCell AddCell(
        Vector3 position,
        float minDistanceCoef = 1f,
        float?radius          = null,
        string tag            = null)
    {
        MetaballCell cell = new MetaballCell();

        cell.baseColor     = this._baseColor;
        cell.radius        = radius.HasValue ? radius.Value : this._baseRadius;
        cell.modelPosition = position;
        cell.tag           = tag;
        bool bFail = false;

        this.DoForeachCell((ForeachCellDeleg)(c =>
        {
            Vector3 vector3 = Vector3.op_Subtraction(cell.modelPosition, c.modelPosition);
            if ((double)((Vector3) ref vector3).get_sqrMagnitude() >= (double)cell.radius * (double)cell.radius * (double)minDistanceCoef * (double)minDistanceCoef)
            {
                return;
            }
            bFail = true;
        }));
        if (!bFail)
        {
            this._cells.Add(cell);
        }
        return(bFail ? (MetaballCell)null : cell);
    }
Пример #2
0
    public MetaballCell AddCell(Vector3 position, float minDistanceCoef = 1.0f, float?radius = null, string tag = null)
    {
        MetaballCell cell = new MetaballCell();

        cell.baseColor     = _baseColor;
        cell.radius        = (radius == null) ? _baseRadius : radius.Value;
        cell.modelPosition = position;
        cell.tag           = tag;

        bool bFail = false;

        DoForeachCell((c) =>
        {
            if ((cell.modelPosition - c.modelPosition).sqrMagnitude < cell.radius * cell.radius * minDistanceCoef * minDistanceCoef)
            {
                bFail = true;
            }
        });

        if (!bFail)
        {
            _cells.Add(cell);
        }

        return(bFail ? null : cell);
    }
 public int FindCell(MetaballCell cell)
 {
     for (int index = 0; index < this._cells.Count; ++index)
     {
         if (this._cells[index] == cell)
         {
             return(index);
         }
     }
     return(-1);
 }
Пример #4
0
    public int FindCell(MetaballCell cell)
    {
        for (int i = 0; i < _cells.Count; ++i)
        {
            if (_cells[i] == cell)
            {
                return(i);
            }
        }

        return(-1);
    }
Пример #5
0
    void ConstructCellCluster(MetaballCellCluster cluster, Transform parentNode, Matrix4x4 toLocalMtx)
    {
        for (int i = 0; i < parentNode.childCount; ++i)
        {
            Transform c = parentNode.GetChild(i);

            MetaballNode n = c.GetComponent <MetaballNode>();

            if (n != null)
            {
                MetaballCell cell = _cellCluster.AddCell(toLocalMtx * (c.position - transform.position), 0.0f, n.Radius, c.gameObject.name);
                cell.density = n.Density;
            }

            ConstructCellCluster(cluster, c, toLocalMtx);
        }
    }
Пример #6
0
 public virtual void Setup(MetaballCell cell)
 {
     _cell = cell;
 }
 public void RemoveCell(MetaballCell cell)
 {
     this._cells.Remove(cell);
 }