/// <summary> /// Finds the width and height of the quad at the given position. /// </summary> /// <param name="q">The quad position.</param> /// <param name="w">The quad width to write to.</param> /// <param name="h">The quad height to write to.</param> private void FindNextQuad(QuadPos q, out int w, out int h) { int maxH = m_ChunkSize - 1; for (w = q.X; ; w++) { for (h = q.Y; ; h++) { if (h == maxH || !GetQuad(w, h + 1).Equals(q.Quad)) { break; } } if (h < maxH) { maxH = h; } if (w == m_ChunkSize - 1 || !GetQuad(w + 1, q.Y).Equals(q.Quad)) { break; } } }
/// <summary> /// Resets the data within the quad to default. /// </summary> /// <param name="q">The quad position.</param> /// <param name="w">The quad width.</param> /// <param name="h">The quad height.</param> private void ClearQuad(QuadPos q, int w, int h) { for (int a = w; a >= q.X; a--) { for (int b = h; b >= q.Y; b--) { SetQuad(a, b, default); } } }
private void CalculateHotFixParameters(Quad quad) { List <Single> list = new List <Single>(); List <Single> list2 = new List <Single>(); QuadPos[] q = quad.q; for (Int32 i = 0; i < (Int32)q.Length; i++) { QuadPos quadPos = q[i]; if (quadPos.Vector3Val.x != 0f || quadPos.Vector3Val.z != 0f) { list.Add(quadPos.Vector3Val.x); list2.Add(quadPos.Vector3Val.z); } } Single num = list.Max(); Single num2 = list.Min(); Single num3 = list2.Max(); Single num4 = list2.Min(); Vector3 vector = new Vector3(Mathf.Abs((num - num2) / 2f), 0f, Mathf.Abs((num3 - num4) / 2f)); this.hotFixCenter = new Vector3(list.Average(), this.offsetY, list2.Average()); this.hotFixRadiant = ((vector.x <= vector.z) ? vector.x : vector.z); }
public static int to_idx(this QuadPos pos) { return((int)pos - 1); }
public Quad get_child(QuadPos pos) { return((this.children != null) ? this.children[pos.to_idx()] : null); }