private void ComputeStepFrame() { int kernelHandle = computer.FindKernel("CSMain"); computer.SetBuffer(kernelHandle, "RangeBuffer", particleBuffer); computer.SetFloat("MaxDist", maxDist); computer.Dispatch(kernelHandle, particleBuffer.count / 10, 1, 1); particleBuffer.GetData(checkArray); /*for (int i = lines.Count - 1; i >= 0; i--) { * GameObject thisLine = lines [i].gameObject; * lines.RemoveAt(i); * Destroy (thisLine); * }*/ foreach (RangeCheck check in checkArray) { int loId = Mathf.Min(check.p1_id, check.p2_id); int hiId = Mathf.Max(check.p1_id, check.p2_id); ParticlePair thisPair = new ParticlePair(loId, hiId); LineRenderer thisLine; bool lineExists = lrLookup.TryGetValue(thisPair, out thisLine); if (check.inRange == 1) { if (!lineExists) { thisLine = Instantiate(lineTemplate, transform, false); lrLookup [thisPair] = thisLine; } thisLine.SetPosition(0, check.pos1); thisLine.SetPosition(1, check.pos2); } else { if (lineExists) { lrLookup.Remove(thisPair); Destroy(thisLine.gameObject); } } } }
void AddParticle(int id) { ParticlePair pp = new ParticlePair((GameObject)(Instantiate(prefabs[id], transform.position, Quaternion.Euler(36, 0, 0), transform)), id); instances.Add(pp); }