Exemple #1
0
    public override void GetSelection(MegaModifiers mc)
    {
        if (modselection == null || modselection.Length != mc.verts.Length)
        {
            modselection = new float[mc.verts.Length];
        }

        // we dont need to update if nothing changes
        if (useCurrentVerts)
        {
            for (int i = 0; i < verts.Length; i++)
            {
                float d = Vector3.Distance(origin, verts[i]) - radius;

                if (d < 0.0f)
                {
                    modselection[i] = 1.0f;
                }
                else
                {
                    float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                    modselection[i] = w;                        //mc.cols[i][c];
                }
            }
        }
        else
        {
            for (int i = 0; i < verts.Length; i++)
            {
                float d = Vector3.Distance(origin, verts[i]) - radius;

                if (d < 0.0f)
                {
                    modselection[i] = 1.0f;
                }
                else
                {
                    float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                    modselection[i] = w;                        //mc.cols[i][c];
                }
            }
        }
        //if ( weight == 1.0f )
        //	mc.selection = null;	// Normal system

        // We only need the copy if we are first mod
        if ((mc.dirtyChannels & MegaModChannel.Verts) == 0)
        {
            mc.InitVertSource();
            //verts.CopyTo(sverts, 0);
            //mc.UpdateMesh = 1;
        }

        //Debug.Log("sel " + modselection.Length);
        mc.selection = modselection;
    }
Exemple #2
0
    public override void GetSelection(MegaModifiers mc)
    {
        if ( modselection == null || modselection.Length != mc.verts.Length )
        {
            modselection = new float[mc.verts.Length];
        }

        // we dont need to update if nothing changes
        if ( useCurrentVerts )
        {
            for ( int i = 0; i < verts.Length; i++ )
            {
                float d = Vector3.Distance(origin, verts[i]) - radius;

                if ( d < 0.0f )
                    modselection[i] = 1.0f;
                else
                {
                    float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                    modselection[i] = w;	//mc.cols[i][c];
                }
            }
        }
        else
        {
            for ( int i = 0; i < verts.Length; i++ )
            {
                float d = Vector3.Distance(origin, verts[i]) - radius;

                if ( d < 0.0f )
                    modselection[i] = 1.0f;
                else
                {
                    float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                    modselection[i] = w;	//mc.cols[i][c];
                }
            }
        }
        //if ( weight == 1.0f )
        //	mc.selection = null;	// Normal system

        // We only need the copy if we are first mod
        if ( (mc.dirtyChannels & MegaModChannel.Verts) == 0 )
        {
            mc.InitVertSource();
            //verts.CopyTo(sverts, 0);
            //mc.UpdateMesh = 1;
        }

        //Debug.Log("sel " + modselection.Length);
        mc.selection = modselection;
    }
Exemple #3
0
    public override void GetSelection(MegaModifiers mc)
    {
        if (target)
        {
            origin = transform.worldToLocalMatrix.MultiplyPoint(target.position);
        }

        if (modselection == null || modselection.Length != mc.verts.Length)
        {
            modselection = new float[mc.verts.Length];
        }

        if (freezeSelection)
        {
            mc.selection = modselection;
            return;
        }

        // we dont need to update if nothing changes
        if (volType == MegaVolumeType.Sphere)
        {
            if (useCurrentVerts)
            {
                for (int i = 0; i < verts.Length; i++)
                {
                    float d = Vector3.Distance(origin, verts[i]) - radius;

                    if (d < 0.0f)
                    {
                        modselection[i] = weight;
                    }
                    else
                    {
                        float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                        modselection[i] = w * weight;                           //mc.cols[i][c];
                    }
                }
            }
            else
            {
                for (int i = 0; i < verts.Length; i++)
                {
                    float d = Vector3.Distance(origin, verts[i]) - radius;

                    if (d < 0.0f)
                    {
                        modselection[i] = weight;
                    }
                    else
                    {
                        float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                        modselection[i] = w * weight;                           //mc.cols[i][c];
                    }
                }
            }
        }
        else
        {
            if (useCurrentVerts)
            {
                for (int i = 0; i < verts.Length; i++)
                {
                    float d = GetDistBox(verts[i]);

                    if (d < 0.0f)
                    {
                        modselection[i] = weight;
                    }
                    else
                    {
                        float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                        modselection[i] = w * weight;                           //mc.cols[i][c];
                    }
                }
            }
            else
            {
                for (int i = 0; i < verts.Length; i++)
                {
                    float d = GetDistBox(verts[i]);

                    if (d < 0.0f)
                    {
                        modselection[i] = weight;
                    }
                    else
                    {
                        float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                        modselection[i] = w * weight;                           //mc.cols[i][c];
                    }
                }
            }
        }
        //if ( weight == 1.0f )
        //	mc.selection = null;	// Normal system

        // We only need the copy if we are first mod
        if ((mc.dirtyChannels & MegaModChannel.Verts) == 0)
        {
            mc.InitVertSource();
            //verts.CopyTo(sverts, 0);
            //mc.UpdateMesh = 1;
        }

        //Debug.Log("sel " + modselection.Length);
        mc.selection = modselection;
    }
Exemple #4
0
    public override void GetSelection(MegaModifiers mc)
    {
        if (modselection == null || modselection.Length != mc.verts.Length)
        {
            modselection = new float[mc.verts.Length];
        }

        int volcount = 0;

        if (!freezeSelection)
        {
            if (volumes != null && volumes.Count > 0)
            {
                for (int v = 0; v < volumes.Count; v++)
                {
                    MegaVolume vol = volumes[v];

                    if (vol.enabled)
                    {
                        Vector3 origin = Vector3.zero;

                        if (vol.target)
                        {
                            origin = transform.worldToLocalMatrix.MultiplyPoint(vol.target.position);
                        }
                        else
                        {
                            origin = vol.origin;
                        }

                        vol.origin = origin;

                        if (volcount == 0)
                        {
                            if (vol.volType == MegaVolumeType.Sphere)
                            {
                                if (useCurrentVerts)
                                {
                                    for (int i = 0; i < verts.Length; i++)
                                    {
                                        float d = Vector3.Distance(origin, verts[i]) - vol.radius;

                                        if (d < 0.0f)
                                        {
                                            modselection[i] = vol.weight;
                                        }
                                        else
                                        {
                                            float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                            modselection[i] = w * vol.weight;                                                   //mc.cols[i][c];
                                        }
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < verts.Length; i++)
                                    {
                                        float d = Vector3.Distance(origin, verts[i]) - vol.radius;

                                        if (d < 0.0f)
                                        {
                                            modselection[i] = vol.weight;
                                        }
                                        else
                                        {
                                            float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                            modselection[i] = w * vol.weight;                                                   //mc.cols[i][c];
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (useCurrentVerts)
                                {
                                    for (int i = 0; i < verts.Length; i++)
                                    {
                                        float d = GetDistBox(vol, verts[i]);

                                        if (d < 0.0f)
                                        {
                                            modselection[i] = vol.weight;
                                        }
                                        else
                                        {
                                            float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                            if (w > 1.0f)
                                            {
                                                w = 1.0f;
                                            }
                                            modselection[i] = w * vol.weight;                                                   //mc.cols[i][c];
                                        }
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < verts.Length; i++)
                                    {
                                        float d = GetDistBox(vol, verts[i]);

                                        //float wg = modselection[i];

                                        if (d < 0.0f)
                                        {
                                            modselection[i] = vol.weight;
                                        }
                                        else
                                        {
                                            float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                            if (w > 1.0f)
                                            {
                                                w = 1.0f;
                                            }
                                            modselection[i] = w * vol.weight;                                                   //mc.cols[i][c];
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (vol.volType == MegaVolumeType.Box)
                            {
                                if (useCurrentVerts)
                                {
                                    for (int i = 0; i < verts.Length; i++)
                                    {
                                        float d = GetDistBox(vol, verts[i]);

                                        float wg = modselection[i];
                                        if (d < 0.0f)
                                        {
                                            wg += vol.weight;
                                        }
                                        else
                                        {
                                            float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                            wg += w * vol.weight;                                               //mc.cols[i][c];
                                        }

                                        if (wg > 1.0f)
                                        {
                                            modselection[i] = 1.0f;
                                        }
                                        else
                                        {
                                            modselection[i] = wg;
                                        }
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < verts.Length; i++)
                                    {
                                        float d = GetDistBox(vol, verts[i]);

                                        float wg = modselection[i];

                                        if (d < 0.0f)
                                        {
                                            wg += vol.weight;
                                        }
                                        else
                                        {
                                            float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                            wg += w * vol.weight;                                               //mc.cols[i][c];
                                        }

                                        if (wg > 1.0f)
                                        {
                                            modselection[i] = 1.0f;
                                        }
                                        else
                                        {
                                            modselection[i] = wg;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (useCurrentVerts)
                                {
                                    for (int i = 0; i < verts.Length; i++)
                                    {
                                        float d = Vector3.Distance(origin, verts[i]) - vol.radius;

                                        float wg = modselection[i];
                                        if (d < 0.0f)
                                        {
                                            wg += vol.weight;
                                        }
                                        else
                                        {
                                            float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                            wg += w * vol.weight;                                               //mc.cols[i][c];
                                        }

                                        if (wg > 1.0f)
                                        {
                                            modselection[i] = 1.0f;
                                        }
                                        else
                                        {
                                            modselection[i] = wg;
                                        }
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < verts.Length; i++)
                                    {
                                        float d = Vector3.Distance(origin, verts[i]) - vol.radius;

                                        float wg = modselection[i];

                                        if (d < 0.0f)
                                        {
                                            wg += vol.weight;
                                        }
                                        else
                                        {
                                            float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                            wg += w * vol.weight;                                               //mc.cols[i][c];
                                        }

                                        if (wg > 1.0f)
                                        {
                                            modselection[i] = 1.0f;
                                        }
                                        else
                                        {
                                            modselection[i] = wg;
                                        }
                                    }
                                }
                            }
                        }

                        volcount++;
                    }
                }
            }

            if (volcount == 0)
            {
                for (int i = 0; i < verts.Length; i++)
                {
                    modselection[i] = 0.0f;
                }
            }
        }

        if ((mc.dirtyChannels & MegaModChannel.Verts) == 0)
        {
            mc.InitVertSource();
        }

        mc.selection = modselection;
    }
    public override void GetSelection(MegaModifiers mc)
    {
        if ( target )
        {
            origin = transform.worldToLocalMatrix.MultiplyPoint(target.position);
        }

        if ( modselection == null || modselection.Length != mc.verts.Length )
        {
            modselection = new float[mc.verts.Length];
        }

        if ( freezeSelection )
        {
            mc.selection = modselection;
            return;
        }

        // we dont need to update if nothing changes
        if ( volType == MegaVolumeType.Sphere )
        {
            if ( useCurrentVerts )
            {
                for ( int i = 0; i < verts.Length; i++ )
                {
                    float d = Vector3.Distance(origin, verts[i]) - radius;

                    if ( d < 0.0f )
                        modselection[i] = weight;
                    else
                    {
                        float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                        modselection[i] = w * weight;	//mc.cols[i][c];
                    }
                }
            }
            else
            {
                for ( int i = 0; i < verts.Length; i++ )
                {
                    float d = Vector3.Distance(origin, verts[i]) - radius;

                    if ( d < 0.0f )
                        modselection[i] = weight;
                    else
                    {
                        float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                        modselection[i] = w * weight;	//mc.cols[i][c];
                    }
                }
            }
        }
        else
        {
            if ( useCurrentVerts )
            {
                for ( int i = 0; i < verts.Length; i++ )
                {
                    float d = GetDistBox(verts[i]);

                    if ( d < 0.0f )
                        modselection[i] = weight;
                    else
                    {
                        float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                        modselection[i] = w * weight;	//mc.cols[i][c];
                    }
                }
            }
            else
            {
                for ( int i = 0; i < verts.Length; i++ )
                {
                    float d = GetDistBox(verts[i]);

                    if ( d < 0.0f )
                        modselection[i] = weight;
                    else
                    {
                        float w = Mathf.Exp(-falloff * Mathf.Abs(d));
                        modselection[i] = w * weight;	//mc.cols[i][c];
                    }
                }
            }
        }
        //if ( weight == 1.0f )
        //	mc.selection = null;	// Normal system

        // We only need the copy if we are first mod
        if ( (mc.dirtyChannels & MegaModChannel.Verts) == 0 )
        {
            mc.InitVertSource();
            //verts.CopyTo(sverts, 0);
            //mc.UpdateMesh = 1;
        }

        //Debug.Log("sel " + modselection.Length);
        mc.selection = modselection;
    }
    public override void GetSelection(MegaModifiers mc)
    {
        if ( modselection == null || modselection.Length != mc.verts.Length )
        {
            modselection = new float[mc.verts.Length];
        }

        if ( !freezeSelection )
        {
            for ( int v = 0; v < volumes.Count; v++ )
            {
                MegaVolume vol = volumes[v];

                Vector3 origin = Vector3.zero;

                if ( vol.target )
                    origin = transform.worldToLocalMatrix.MultiplyPoint(vol.target.position);
                else
                    origin = vol.origin;

                vol.origin = origin;

                if ( v == 0 )
                {
                    if ( vol.volType == MegaVolumeType.Sphere )
                    {
                        if ( useCurrentVerts )
                        {
                            for ( int i = 0; i < verts.Length; i++ )
                            {
                                float d = Vector3.Distance(origin, verts[i]) - vol.radius;

                                if ( d < 0.0f )
                                    modselection[i] = vol.weight;
                                else
                                {
                                    float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                    modselection[i] = w * vol.weight;	//mc.cols[i][c];
                                }
                            }
                        }
                        else
                        {
                            for ( int i = 0; i < verts.Length; i++ )
                            {
                                float d = Vector3.Distance(origin, verts[i]) - vol.radius;

                                if ( d < 0.0f )
                                    modselection[i] = vol.weight;
                                else
                                {
                                    float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                    modselection[i] = w * vol.weight;	//mc.cols[i][c];
                                }
                            }
                        }
                    }
                    else
                    {
                        if ( useCurrentVerts )
                        {
                            for ( int i = 0; i < verts.Length; i++ )
                            {
                                float d = GetDistBox(vol, verts[i]);

                                if ( d < 0.0f )
                                    modselection[i] = vol.weight;
                                else
                                {
                                    float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                    modselection[i] += w * vol.weight;	//mc.cols[i][c];
                                }
                            }
                        }
                        else
                        {
                            for ( int i = 0; i < verts.Length; i++ )
                            {
                                float d = GetDistBox(vol, verts[i]);

                                //float wg = modselection[i];

                                if ( d < 0.0f )
                                    modselection[i] = vol.weight;
                                else
                                {
                                    float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                    modselection[i] += w * vol.weight;	//mc.cols[i][c];
                                }
                            }
                        }
                    }
                }
                else
                {
                    if ( vol.volType == MegaVolumeType.Box )
                    {
                        if ( useCurrentVerts )
                        {
                            for ( int i = 0; i < verts.Length; i++ )
                            {
                                float d = GetDistBox(vol, verts[i]);

                                float wg = modselection[i];
                                if ( d < 0.0f )
                                    wg += vol.weight;
                                else
                                {
                                    float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                    wg += w * vol.weight;	//mc.cols[i][c];
                                }

                                if ( wg > 1.0f )
                                    modselection[i] = 1.0f;
                                else
                                    modselection[i] = wg;
                            }
                        }
                        else
                        {
                            for ( int i = 0; i < verts.Length; i++ )
                            {
                                float d = GetDistBox(vol, verts[i]);

                                float wg = modselection[i];

                                if ( d < 0.0f )
                                    wg += vol.weight;
                                else
                                {
                                    float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                    wg += w * vol.weight;	//mc.cols[i][c];
                                }

                                if ( wg > 1.0f )
                                    modselection[i] = 1.0f;
                                else
                                    modselection[i] = wg;
                            }
                        }
                    }
                    else
                    {
                        if ( useCurrentVerts )
                        {
                            for ( int i = 0; i < verts.Length; i++ )
                            {
                                float d = Vector3.Distance(origin, verts[i]) - vol.radius;

                                float wg = modselection[i];
                                if ( d < 0.0f )
                                    wg += vol.weight;
                                else
                                {
                                    float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                    wg += w * vol.weight;	//mc.cols[i][c];
                                }

                                if ( wg > 1.0f )
                                    modselection[i] = 1.0f;
                                else
                                    modselection[i] = wg;
                            }
                        }
                        else
                        {
                            for ( int i = 0; i < verts.Length; i++ )
                            {
                                float d = Vector3.Distance(origin, verts[i]) - vol.radius;

                                float wg = modselection[i];

                                if ( d < 0.0f )
                                    wg += vol.weight;
                                else
                                {
                                    float w = Mathf.Exp(-vol.falloff * Mathf.Abs(d));
                                    wg += w * vol.weight;	//mc.cols[i][c];
                                }

                                if ( wg > 1.0f )
                                    modselection[i] = 1.0f;
                                else
                                    modselection[i] = wg;
                            }
                        }
                    }
                }
            }
        }

        if ( (mc.dirtyChannels & MegaModChannel.Verts) == 0 )
        {
            mc.InitVertSource();
        }

        mc.selection = modselection;
    }