private void IncrementSolution(int index, float amount) { WaveSolution v = GetSolution(index); v.Pos.Y += amount; SetSolution(index, v); }
private void SetSolution(int index, WaveSolution v) { OpenCurrentBuffer(); int pos = WaveSolution.Stride * index; rippleWriteBuffer.Position = pos; rippleWriteBuffer.Write <WaveSolution>(v); }
private WaveSolution GetSolution(int index) { OpenCurrentBuffer(); int pos = WaveSolution.Stride * index; rippleWriteBuffer.Position = pos; WaveSolution v = rippleWriteBuffer.Read <WaveSolution>(); return(v); }
private void FillBuffers() { float speed = _waveSpeed; float dx = _wavesCB._spatialStep; float dt = _waveTimeStep; uint m = _wavesCB.RowCount; uint n = _wavesCB.ColumnCount; var d = _waveDamping * dt + 2.0f; var e = (speed * speed) * (dt * dt) / (dx * dx); var w2 = (n - 1) * dx * 0.5f; var d2 = (m - 1) * dx * 0.5f; var WaveSolutions = new WaveSolution[m * n]; for (var i = 0; i < m; i++) { var z = d2 - i * dx; for (var j = 0; j < n; j++) { var x = -w2 + j * dx; WaveSolutions[i * n + j] = new WaveSolution(); WaveSolutions[i * n + j].Pos = new Vector4(x, 0, z, 0); WaveSolutions[i * n + j].Normal = new Vector4(0, 1, 0, 1); WaveSolutions[i * n + j].Tangent = new Vector4(1.0f, 0, 0, 1); } } ImmediateContext.UpdateSubresource <WaveSolution>(WaveSolutions, _inputBuf1); WaveSolutions = new WaveSolution[m * n]; for (var i = 0; i < m; i++) { var z = d2 - i * dx; for (var j = 0; j < n; j++) { var x = -w2 + j * dx; WaveSolutions[i * n + j] = new WaveSolution(); WaveSolutions[i * n + j].Pos = new Vector4(x, 0, z, 0); WaveSolutions[i * n + j].Normal = new Vector4(0, 1, 0, 1); WaveSolutions[i * n + j].Tangent = new Vector4(1.0f, 0, 0, 1); } } ImmediateContext.UpdateSubresource <WaveSolution>(WaveSolutions, _inputBuf2); }