private void AddSites(List <Bubbles.Node> nodes) //jf { Vector2 p = new Vector2(); for (int i = 0; i < nodes.Count; ++i) { Bubbles.Node node = nodes[i]; p.x = node.x; p.y = node.y; //move toward zero, so stay within plotBounds. Guarantee unique position of all nodes while (_sitesIndexedByLocation.ContainsKey(p)) { p.x += (p.x < 0)? UnityEngine.Random.Range(0, 0.000001f): -UnityEngine.Random.Range(0, 0.000001f); } if (node.site == null) { node.site = Site.Create(p, (uint)i, node); } else { node.site.Init(p, (uint)i, node); // both node and site reference each other } if (i >= _sites.Count) { _sites.Add(node.site); } else { _sites.Plant(node.site, i); } _sitesIndexedByLocation [p] = node.site; } }
private void AddSite(Vector2f p, int index) { float weigth = (float)weigthDistributor.NextDouble() * 100; Site site = Site.Create(p, index, weigth); sites.Add(site); sitesIndexedByLocation[p] = site; }
private void AddSite(Vector2 p, uint color, int index) { if (!_sitesIndexedByLocation.ContainsKey(p)) { float weight = Random.value * 100f; Site site = Site.Create(p, (uint)index, weight, color); _sites.Add(site); _sitesIndexedByLocation[p] = site; } }
private void AddSite(Vector2 p, uint color, int index) { if (_sitesIndexedByLocation.ContainsKey(p)) { return; // Prevent duplicate site! (Adapted from https://github.com/nodename/as3delaunay/issues/1) } float weight = UnityEngine.Random.value * 100f; Site site = Site.Create(p, (uint)index, weight, color); _sites.Add(site); _sitesIndexedByLocation [p] = site; }
private void AddSite(Point p, Color color, int index) { if (_sitesIndexedByLocation.ContainsKey(p)) { return; // Prevent duplicate site! (Adapted from https://github.com/nodename/as3delaunay/issues/1) } double weight = (double)r.NextDouble() * 100f; Site site = Site.Create(p, (uint)index, weight, color); _sites.Add(site); _sitesIndexedByLocation[p] = site; }
private void AddSite(Vector2 p, uint color, int index, float weight = 1f) { if (!_sitesIndexedByLocation.ContainsKey(p)) { Site site = Site.Create(p, (uint)index, weight, color); min_weight = Mathf.Min(min_weight, weight); max_weight = Mathf.Max(max_weight, weight); _sitesIndexedByLocation[p] = site; _sites.Add(site); weightSum += site.weight; } }