コード例 #1
0
            private Vector3[] m_CachedVertPos; //used in dragging handle, cache the starting position of verts

            #endregion "data"

            #region "public method"
            // public method

            public void Init(EditableMesh m, MeshSelection sel, Pivotor p)
            {
                m_Mesh      = m;
                m_Selection = sel;
                m_Pivot     = p;
                Dbg.Assert(m_Pivot != null, "SoftSelection.Init: pivotor is null");

                m_Range = 1f;

                m_Cont = new _Data[m.mesh.vertexCount];
                for (int i = 0; i < m_Cont.Length; ++i)
                {
                    m_Cont[i] = new _Data();
                }

                m_EffectVertIdxLst = new VLst();

                m_Mode        = Mode.Off;
                m_PrepareMode = PrepareMode.Always;

                // atten curve
                var res = (SoftSelectionRes)AssetDatabase.LoadAssetAtPath(SOFTSEL_ATTEN_CURVE_PATH, typeof(SoftSelectionRes));

                if (res == null)
                {
                    res = ScriptableObject.CreateInstance <SoftSelectionRes>();
                    AssetDatabase.CreateAsset(res, SOFTSEL_ATTEN_CURVE_PATH);
                    res = (SoftSelectionRes)AssetDatabase.LoadAssetAtPath(SOFTSEL_ATTEN_CURVE_PATH, typeof(SoftSelectionRes));
                    Dbg.Assert(res != null, "SoftSelection.Init: failed to create curve asset for SoftSelection");
                }
                m_Atten = res.attenCurve;

                MeshManipulator.evtHandleDraggingStateChanged += this._OnHandleDraggingStateChanged;
            }
コード例 #2
0
            public void Prepare()
            {
                if (m_PrepareMode == PrepareMode.Stop)
                {
                    return;
                }
                else if (m_PrepareMode == PrepareMode.OnlyOnce)
                {
                    m_PrepareMode = PrepareMode.Stop;
                }

                m_CachedVertPos = m_Mesh.mesh.vertices; //cache as starting pos, useful when dynamically change range
                VLst selectedVerts = m_Selection.GetVertices();

                //1. set the initial effect percentage
                Reset();
                //1.1 set the seeds
                for (int i = 0; i < selectedVerts.Count; ++i)
                {
                    int vidx = selectedVerts[i];
                    m_Cont[vidx].AsSeed();
                }

                //2. calculate nearest distance for every vert,
                _CalcDist(selectedVerts);

                //3. calc the percentage
                _CalcPercentage();
            }
コード例 #3
0
 private void _OnHandleDraggingStateChanged(bool bDragging)
 {
     if (bDragging)
     {
         m_PrepareMode = PrepareMode.OnlyOnce;
     }
     else
     {
         m_PrepareMode = PrepareMode.Always;
     }
 }
コード例 #4
0
ファイル: ValueItems.cs プロジェクト: srijken/turtlebuild
        public ItemValueItem(string item, string key, string separator, PrepareMode mode)
            : base(item, key)
        {
            if (string.IsNullOrEmpty(item))
            {
                throw new ArgumentNullException("item");
            }

            _separator = separator;
            _mode      = mode;
        }
コード例 #5
0
        protected internal ValueItem[] PrepareString(TagBatchDefinition batchDefinition, string definition, PrepareMode mode)
        {
            int lastOffset = 0;
            int offset     = 0;

            List <ValueItem> list            = new List <ValueItem>();
            List <string>    freeConstraints = new List <string>();

            string flat = TagExpander.ItemKeyOrPropertyRegex.Replace(definition, delegate(Match match)
            {
                if (offset > lastOffset)
                {
                    list.Add(new StringValueItem(definition.Substring(lastOffset, offset - lastOffset)));
                }
                int ofs    = match.Index - offset;
                offset     = match.Index + match.Length;
                lastOffset = offset;

                Group g, gp, gs;
                if (null != (g = match.Groups[TagExpander.RegexGroupItem]) && g.Success)
                {
                    gp = match.Groups[TagExpander.RegexGroupTransform];
                    gs = match.Groups[TagExpander.RegexGroupSeparator];

                    batchDefinition.AddUsedItem(this, g.Value);

                    list.Add(new ItemValueItem(g.Value, gp.Success ? gp.Value : null, gs.Success ? gs.Value : null, mode));
                }
                else if (null != (g = match.Groups[TagExpander.RegexGroupKey]) && g.Success)
                {
                    gp = match.Groups[TagExpander.RegexGroupItemPrefix];

                    list.Add(new TagValueItem(gp.Success ? gp.Value : null, g.Value));
                }
                else if (null != (g = match.Groups[TagExpander.RegexGroupProperty]) && g.Success)
                {
                    list.Add(new PropertyValueItem(g.Value));
                }
                return("");
            });

            offset = definition.Length;
            if (offset > lastOffset)
            {
                list.Add(new StringValueItem(definition.Substring(lastOffset, offset - lastOffset)));
            }

            return(list.ToArray());
        }