public void update( int totalPositions, float totalLineLength, GetNode getNode ) { if (totalPositions < 2) { return; } triangles.Clear(); fillVerticesAndUvs(totalPositions, totalLineLength, getNode); m.SetVertices(vertices); m.SetTriangles(triangles, 0); m.SetUVs(0, uvs); m.SetColors(colors); m.RecalculateBounds(); }
void fillVerticesAndUvs( int totalPositions, float totalLineLength, GetNode getNode ) { var idx = 0; var lineLength = 0f; addDataForSegment( findCornersSimpleA(getNode(0).relativePosition, getNode(1).relativePosition, -getWidthForProgress(0f)), colorGradient.Evaluate(0), ref idx, 0f ); for (var i = 1; i < totalPositions - 1; i++) { var curNode = getNode(i); lineLength += curNode.distanceToPrevNode; var progress = lineLength / totalLineLength; var width = getWidthForProgress(progress); var color = colorGradient.Evaluate(progress); var cur = curNode.relativePosition; var prev = getNode(i - 1).relativePosition; var next = getNode(i + 1).relativePosition; if (Vector2.Angle(prev - cur, next - cur) < 90) { addDataForSegment(findCornersSimpleB(prev, cur, -width), color, ref idx, progress); fillTriangle(idx); addDataForSegment(findCornersSimpleA(cur, next, -width), color, ref idx, progress); } else { addDataForSegment( findCorners(prev, cur, next, -width, LINES_PARALLEL_EPS), color, ref idx, progress ); fillTriangle(idx); } } addDataForSegment( findCornersSimpleB( getNode(totalPositions - 2).relativePosition, getNode(totalPositions - 1).relativePosition, -getWidthForProgress(1f) ), colorGradient.Evaluate(1), ref idx, 1f ); fillTriangle(idx); }
// remake private ConversationNode findNode(TreeNode begin, TreeNode end, bool forward, SearchBox.Option option, Module module) { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); // delegate GetNode get_node = null; if (forward) { if (option.expand) { get_node = new GetNode(getNextExpand); } else { get_node = new GetNode(getNext); } } else { if (option.expand) { get_node = new GetNode(getPrevExpand); } else { get_node = new GetNode(getPrev); } } TreeNode current = begin; // ねんのためnullもチェック while (current != end && current != null) { ConversationNode cn = current as ConversationNode; if (cn != null) { if (findWord(cn, option)) { sw.Stop(); System.Console.WriteLine("time: " + sw.ElapsedMilliseconds.ToString() + "ms"); return(cn); } //current = getNext2( current ); } else { switch (( string )current.Tag) { case "dlg": if (current.Nodes.Count == 1 && ( string )current.Nodes[0].Tag == "dummy") { // まだ読んでない current.Nodes.Clear(); //string path = module_directory + "/" + current.Parent.Text + "/" + current.Text + ".txt"; string path = module.directory + "/" + current.FullPath + ".txt"; uint[] start = null; ConversationNode[] nodes = null; loadDlg(path, ref start, ref nodes, module); // error? if (start == null || nodes == null) { continue; } module.tree.SuspendLayout(); createDlgTree(ref start, ref nodes, ref current); module.tree.ResumeLayout(); module.tree.PerformLayout(); } //current = getNext2( current ); break; //case "rim": // preloaded //current = getNext2( current ); //break; default: break; } } current = get_node(current); // delegate } sw.Stop(); System.Console.WriteLine("time: " + sw.ElapsedMilliseconds.ToString() + "ms"); return(null); }