use super::super::soft_fem_sparse::{BlockMatrix, ConjugateGradient};
use crate::alloc_prelude::*;
use crate::dynamics::solver::soft_constraint::soft_element_constraint::{
MAX_CONSTRAINT_PARTICLES, StrainMatrix, StrainVector,
};
use crate::math::{Matrix, Real, Rotation, Vector};
pub(super) const CELL_BLOCKS: usize = MAX_CONSTRAINT_PARTICLES * MAX_CONSTRAINT_PARTICLES;
#[derive(Copy, Clone, Debug)]
pub(super) struct FemCell {
pub(super) vertices: [u32; MAX_CONSTRAINT_PARTICLES],
pub(super) coeffs: [Vector; MAX_CONSTRAINT_PARTICLES],
pub(super) inv_rest_matrix: Matrix,
pub(super) mu: Real,
pub(super) lambda: Real,
pub(super) beta: Real,
pub(super) rotation: Rotation,
pub(super) strain: StrainVector,
pub(super) inverted: bool,
pub(super) neo_hookean: bool,
pub(super) tangent: StrainMatrix,
pub(super) tangent_strain: StrainVector,
}
#[derive(Copy, Clone, Debug)]
pub(super) struct FemVolumeCell {
pub(super) cell: u32,
pub(super) rest_volume: Real,
pub(super) stiffness: Real,
pub(super) beta: Real,
}
#[derive(Copy, Clone, Debug)]
pub(super) struct FemSpring {
pub(super) vertices: [u32; 2],
pub(super) blocks: [u32; 4],
pub(super) rest_length: Real,
pub(super) stiffness: Real,
pub(super) beta: Real,
pub(super) tension_only: bool,
}
#[cfg(feature = "dim3")]
#[derive(Copy, Clone, Debug)]
pub(super) struct FemDihedral {
pub(super) vertices: [u32; 4],
pub(super) blocks: [u32; 16],
pub(super) rest_angle: Real,
pub(super) stiffness: Real,
pub(super) beta: Real,
}
#[derive(Clone, Debug, Default)]
pub(crate) struct SoftFemSystem {
pub(super) topology_version: u32,
pub(super) matrix: BlockMatrix,
pub(super) cg: ConjugateGradient,
pub(super) cells: Vec<FemCell>,
pub(super) cell_blocks: Vec<[u32; CELL_BLOCKS]>,
pub(super) volume_cells: Vec<FemVolumeCell>,
pub(super) springs: Vec<FemSpring>,
#[cfg(feature = "dim3")]
pub(super) dihedrals: Vec<FemDihedral>,
pub(super) mass: Vec<Real>,
pub(super) slots: Vec<u32>,
pub(super) pinned: Vec<bool>,
pub(super) position: Vec<Vector>,
pub(super) velocity: Vec<Vector>,
pub(super) force: Vec<Vector>,
pub(super) pinned_coupling: Vec<Vector>,
pub(super) operator_fresh: bool,
pub(super) rhs: Vec<Vector>,
pub(super) delta: Vec<Vector>,
pub(super) step_matrix: BlockMatrix,
pub(super) step_cg: ConjugateGradient,
pub(super) direct: Option<super::super::soft_fem_skyline::SkylineCholesky>,
pub(super) direct_valid: bool,
pub(super) response_rhs: Vec<Vector>,
pub(super) response: Vec<Vector>,
pub(super) columns: Vec<Vector>,
pub(super) column_of: Vec<u32>,
pub(super) num_columns: usize,
}