} // end of Edge NearestNode public void Rotate(Matrix delta) { Node0.Rotate(delta); Node1.Rotate(delta); Path.RecalcHeights(); }
public void ClearEdit() { Moving = false; Edit = false; Select = false; Node0.ClearEdit(); Node1.ClearEdit(); Path.ClearEdit(); }
private void Merge(Node0 node) { __dbg__.AssertBList(this.data.Count + node.data.Count <= ULIMIT && this.parent == node.parent); //%%if IsEx==1||IsEx==2 ( int i = this.data.Count; for (int j = 0, jN = node.data.Count; j < jN; j++) { node.data[j].index = i++; } //%%) this.data.AddRange(node.data); this.weight += node.weight; node.weight = 0; node.data.Clear(); }
public override void Insert(int index, T value) { __dbg__.AssertBList(0 <= index && index <= this.data.Count); if (this.data.Count < ULIMIT) { this.data.Insert(index, value); //%%if IsEx==1||IsEx==2 ( if (value != null) { value.node0 = this; } for (int i = index, iN = this.data.Count; i < iN; i++) { T e = this.data[i]; if (e != null) { e.index = i; } } //%%) this.add_weight(1); } else { Node0 node2 = this.Split(); if (this.list.root == this) { this.list.PushLevel(node2); } else { this.parent.InsertNode(this.index + 1, node2); } int index2 = index - this.data.Count; if (index2 < 0) { this.Insert(index, value); } else { node2.Insert(index2, value); } } }
/// <summary> /// 含まれている要素を全て削除し、空のリストにします。 /// </summary> public void Clear() { if (this.root.weight == 0) { return; } if (this.root.level == 0) { Node0 r = (Node0)this.root; r.data.Clear(); r.weight = 0; } else { this.root = new Node0(); this.root.list = this; } }
/// <summary> /// Renders an edge as a simple line which follows the terrain. /// </summary> /// <param name="camera"></param> /// <param name="color"></param> public void Render(Camera camera, Vector4 color, bool asRoad) { if (Path.Edit || Path.Select || Edit || Select) { float backLength = 0.666f; if (Path.Edit || Edit) { color *= new Vector4(0.5f, 0.5f, 1.0f, 1.0f); } else if (Path.Select || Select) { color *= new Vector4(1.0f, 0.5f, 0.5f, 1.0f); } float scale = 1.0f + 0.1f * (float)(Math.Sin(10.0 * Time.WallClockTotalSeconds) + 1.0); scale *= 0.5f; Vector3 center = HandlePosition; float height = Terrain.GetTerrainAndPathHeight(new Vector3(center.X, center.Y, float.MaxValue)); center.Z = Math.Max(height, center.Z); if ((Dir & Direction.Down) != 0) { Vector3 toEdge0 = Node0.RenderPosition(asRoad) - center; toEdge0.Normalize(); Vector3 p0 = toEdge0 * backLength + center; p0.Z += Node.Radius + Node.SphereHeight; Utils.DrawSolidCone(camera, p0, toEdge0, scale, color); } if ((Dir & Direction.Up) != 0) { Vector3 toEdge1 = Node1.RenderPosition(asRoad) - center; toEdge1.Normalize(); Vector3 p1 = toEdge1 * backLength + center; p1.Z += Node.Radius + Node.SphereHeight; Utils.DrawSolidCone(camera, p1, toEdge1, scale, color); } } } // end of Edge Render()
public System.Collections.Generic.IEnumerator <T> GetEnumerator() { Node n = this.root; for (;;) { if (n.level > 0) { Node1 n1 = (Node1)n; n = n1.data[0]; } else { Node0 n0 = (Node0)n; for (int i = 0, iN = n0.data.Count; i < iN; i++) { yield return(n0.data[i]); } for (;;) { if (n.parent == null) { yield break; } if (n.index + 1 < n.parent.data.Count) { n = n.parent.data[n.index + 1]; break; } else { n = n.parent; } } } } }
private Node0 Split() { Node0 node2 = new Node0(); int c1 = this.data.Count / 2; int c2 = this.data.Count - c1; for (int index = 0; index < c2; index++) { Line nch = this.data[c1 + index]; if (nch != null) { nch.node0 = node2; nch.index = node2.data.Count; } node2.data.Add(nch); node2.weight++; node2.line_height += nch.Height; } this.data.RemoveRange(c1, c2); this.add_weight(-node2.weight, -node2.line_height); return(node2); }
private Node0 Split() { Node0 node2 = new Node0(); int c1 = this.data.Count / 2; int c2 = this.data.Count - c1; for (int index = 0; index < c2; index++) { T nch = this.data[c1 + index]; //%%if IsEx==1||IsEx==2 ( if (nch != null) { nch.node0 = node2; nch.index = node2.data.Count; } //%%) node2.data.Add(nch); node2.weight++; } this.data.RemoveRange(c1, c2); this.add_weight(-node2.weight); return(node2); }
public override float GetResult() => CallOperate(Node0.GetResult(), Node1.GetResult());
public void FinalizeDeserialization() { Node0.AddPath(this); Node1.AddPath(this); }
public override void RemoveAt(int index) { __dbg__.AssertBList(0 <= index && index < this.data.Count); { //%%if IsEx==1||IsEx==2 ( T e = this.data[index]; if (e != null) { e.node0 = null; } //%%) this.data.RemoveAt(index); this.add_weight(-1); } if (this.list.root == this) { return; } __dbg__.AssertBList(this.parent != null && this.parent.data.Count > 1); if (this.data.Count >= LLIMIT) { return; } if (this.index > 0) { Node0 prev = (Node0)this.parent.data[this.index - 1]; if (prev.data.Count > LLIMIT) { T n = prev.data[prev.data.Count - 1]; prev.RemoveAt(prev.data.Count - 1); this.Insert(0, n); return; } } if (this.index + 1 < this.parent.data.Count) { Node0 next = (Node0)this.parent.data[this.index + 1]; if (next.data.Count > LLIMIT) { T n = next.data[0]; next.RemoveAt(0); this.Insert(this.data.Count, n); return; } } // 融合 if (this.index > 0) { Node0 prev = (Node0)this.parent.data[this.index - 1]; prev.Merge(this); this.parent.RemoveAtNode(this.index); } else { Node0 next = (Node0)this.parent.data[this.index + 1]; this.Merge(next); this.parent.RemoveAtNode(this.index + 1); } }