private void NextButton_OnClick(object sender, RoutedEventArgs e) { m_holeLocation.X++; m_holeLocation.Y++; SandTable.ClearHeightLimits(m_sand); SandTable.ApplyHeightLimitPattern(m_sand, m_spherePattern, m_holeLocation); SandTable.SettleMapTwoPass(m_sand); }
private void Clear_Click(object sender, RoutedEventArgs e) { m_sand = SandTable.CreateSandTable(Size, Size, SandLevel); ApplyBallAndDisplaySand(); }
private void DoWork() { Dispatcher.BeginInvoke(new Action(() => { foreach (var control in ButtonGrid.Children) { if (control is Button button) { button.IsEnabled = false; } } Stop.IsEnabled = true; })); while (!m_closed) { // update var nextMove = m_animator?.GetNext(); m_animator?.CheckPosition(m_holeLocation, m_sand); if (nextMove != null) { m_holeLocation.X += nextMove.Value.X; m_holeLocation.Y += nextMove.Value.Y; m_holeLocation.Height += nextMove.Value.Depth; } // physics Dispatcher.BeginInvoke(new Action(() => { StatusTextBox.Text = "Doing Physics"; })); SandTable.ClearHeightLimits(m_sand); SandTable.ApplyHeightLimitPattern(m_sand, m_spherePattern, m_holeLocation); SandTable.SettleMapTwoPassMinimally(m_sand); // render Dispatcher.BeginInvoke(new Action(() => { ((MainViewModel)DataContext).Clear(); StatusTextBox.Text = "Rendering"; ((MainViewModel)DataContext).AddMeshHeights(m_sand); ((MainViewModel)DataContext).AddSphere(new Point3D(m_holeLocation.X + Radius, m_holeLocation.Y + Radius, m_holeLocation.Height), Radius); ((MainViewModel)DataContext).AddContainer(Size, Size, SandLevel); StatusTextBox.Text = "Done"; m_drawSync.SignalAndWait(); })); m_drawSync.SignalAndWait(); if (nextMove == null || m_animator == null) { break; } } m_animator = null; Dispatcher.BeginInvoke(new Action(() => { foreach (var control in ButtonGrid.Children) { if (control is Button button) { button.IsEnabled = true; } } })); }