public void DetermineInsertNodes(){ int iCount = GSDSpline.mNodes.Count; if(iCount < 2){ return; } GSDSplineIN tNode; GSDSplineN xNode; mNodes.Clear(); float tParam = GSDSpline.GetClosestParam(MousePos,false,true); bool bEndInsert = false; bool bZeroInsert = false; int iStart = 0; if(Mathf.Approximately(tParam,0f)){ bZeroInsert = true; iStart = 0; }else if(Mathf.Approximately(tParam,1f)){ bEndInsert = true; } for(int i=0;i<iCount;i++){ xNode = GSDSpline.mNodes[i]; tNode = new GSDSplineIN(); tNode.pos = xNode.pos; tNode.idOnSpline = xNode.idOnSpline; tNode.tTime = xNode.tTime; if(!bZeroInsert && !bEndInsert){ if(tParam > tNode.tTime){ iStart = tNode.idOnSpline+1; } } mNodes.Add(tNode); } mNodes.Sort(CompareListByName); int cCount = mNodes.Count; if(bEndInsert){ iStart = cCount; }else{ for(int i=iStart;i<cCount;i++){ mNodes[i].idOnSpline+=1; } } tNode = new GSDSplineIN(); tNode.pos = MousePos; tNode.idOnSpline = iStart; tNode.tTime = tParam; tNode.bPreviewNode = true; if(bEndInsert){ mNodes.Add(tNode); }else{ mNodes.Insert(iStart,tNode); } Setup_SplineLength(); ActionNode = tNode; }
public void DetermineInsertNodes() { int iCount = GSDSpline.mNodes.Count; if (iCount < 2) { return; } GSDSplineIN tNode; GSDSplineN xNode; mNodes.Clear(); float tParam = GSDSpline.GetClosestParam(MousePos, false, true); bool bEndInsert = false; bool bZeroInsert = false; int iStart = 0; if (Mathf.Approximately(tParam, 0f)) { bZeroInsert = true; iStart = 0; } else if (Mathf.Approximately(tParam, 1f)) { bEndInsert = true; } for (int index = 0; index < iCount; index++) { xNode = GSDSpline.mNodes[index]; tNode = new GSDSplineIN(); tNode.pos = xNode.pos; tNode.idOnSpline = xNode.idOnSpline; tNode.tTime = xNode.tTime; if (!bZeroInsert && !bEndInsert) { if (tParam > tNode.tTime) { iStart = tNode.idOnSpline + 1; } } mNodes.Add(tNode); } mNodes.Sort(CompareListByName); int cCount = mNodes.Count; if (bEndInsert) { iStart = cCount; } else { for (int index = iStart; index < cCount; index++) { mNodes[index].idOnSpline += 1; } } tNode = new GSDSplineIN(); tNode.pos = MousePos; tNode.idOnSpline = iStart; tNode.tTime = tParam; tNode.bPreviewNode = true; if (bEndInsert) { mNodes.Add(tNode); } else { mNodes.Insert(iStart, tNode); } Setup_SplineLength(); ActionNode = tNode; }
private int CompareListByName(GSDSplineIN i1, GSDSplineIN i2){ return i1.idOnSpline.CompareTo(i2.idOnSpline); }
private int CompareListByName(GSDSplineIN i1, GSDSplineIN i2) { return(i1.idOnSpline.CompareTo(i2.idOnSpline)); }