use crate::grid::grid::{GpuGrid, indirect_dispatch_tensor};
use crate::mpm_shaders::solver::grid_update_cdf::GpuGridUpdateCdf;
use khal::Shader;
use khal::backend::{GpuBackendError, GpuPass};
use nexus_rbd::dynamics::GpuBodySet;
#[derive(Shader)]
pub struct WgGridUpdateCdf {
grid_update: GpuGridUpdateCdf,
}
impl WgGridUpdateCdf {
pub fn launch(
&self,
pass: &mut GpuPass,
grid: &mut GpuGrid,
bodies: &GpuBodySet,
) -> Result<(), GpuBackendError> {
if bodies.is_empty() {
return Ok(());
}
self.grid_update.call(
pass,
indirect_dispatch_tensor(&grid.indirect_n_g2p_p2g_groups),
&grid.meta,
&grid.active_blocks,
&bodies.shapes,
&bodies.poses,
&mut grid.nodes,
)
}
}