protected void GridToParticle() { var sampler = new MacVectorGrid2DSampler(); for (var i = 0; i < this.CPUData.Length; ++i) { var pos = this.CPUData[i].position; var vel = sampler.Sample(this.velocity, pos); this.CPUData[i].velocity = vel; } }
protected void MoveParticle(float delta) { delta *= 50; var sampler = new MacVectorGrid2DSampler(); for (var i = 0; i < this.CPUData.Length; ++i) { var pos = this.CPUData[i].position; //var vel = this.velocity.Sample(pos); var vel = this.CPUData[i].velocity; var mid = pos + 0.5f * delta * vel; mid.x = Mathf.Clamp(mid.x, 0, this.gridSize.x); mid.y = Mathf.Clamp(mid.y, 0, this.gridSize.y); vel = sampler.Sample(this.velocity, mid); pos += delta * vel; pos.x = Mathf.Clamp(pos.x, 0, this.gridSize.x); pos.y = Mathf.Clamp(pos.y, 0, this.gridSize.y); this.CPUData[i].position = pos; } }