chore: add more comments

This commit is contained in:
Sébastien Crozet
2024-06-09 10:57:37 +02:00
committed by Sébastien Crozet
parent cfddaa3c46
commit edaa36ac7e
41 changed files with 897 additions and 202 deletions

View File

@@ -13,7 +13,6 @@ pub struct TOIEntry {
// We call this "pseudo" intersection because this also
// includes colliders pairs with mismatching solver_groups.
pub is_pseudo_intersection_test: bool,
pub timestamp: usize,
}
impl TOIEntry {
@@ -24,7 +23,6 @@ impl TOIEntry {
c2: ColliderHandle,
b2: Option<RigidBodyHandle>,
is_pseudo_intersection_test: bool,
timestamp: usize,
) -> Self {
Self {
toi,
@@ -33,7 +31,6 @@ impl TOIEntry {
c2,
b2,
is_pseudo_intersection_test,
timestamp,
}
}
@@ -149,7 +146,6 @@ impl TOIEntry {
ch2,
co2.parent.map(|p| p.handle),
is_pseudo_intersection_test,
0,
))
}

View File

@@ -569,8 +569,6 @@ impl Multibody {
return; // Nothing to do.
}
let mut kinematic_ndofs = 0;
if self.augmented_mass.ncols() != self.ndofs {
// TODO: do a resize instead of a full reallocation.
self.augmented_mass = DMatrix::zeros(self.ndofs, self.ndofs);
@@ -1058,7 +1056,7 @@ impl Multibody {
bodies: &RigidBodySet,
link_id: usize,
displacement: Option<&[Real]>,
mut out_jacobian: Option<&mut Jacobian<Real>>,
out_jacobian: Option<&mut Jacobian<Real>>,
) -> Isometry<Real> {
let branch = self.kinematic_branch(link_id);
self.forward_kinematics_single_branch(bodies, &branch, displacement, out_jacobian)

View File

@@ -17,6 +17,10 @@ use na::{UnitQuaternion, Vector3};
pub struct MultibodyJoint {
/// The joints description.
pub data: GenericJoint,
/// Is the joint a kinematic joint?
///
/// Kinematic joint velocities are never changed by the physics engine. This gives the user
/// total control over the values of their degrees of freedoms.
pub kinematic: bool,
pub(crate) coords: SpacialVector<Real>,
pub(crate) joint_rot: Rotation<Real>,

View File

@@ -158,7 +158,6 @@ impl MultibodyJointSet {
kinematic: bool,
wake_up: bool,
) -> Option<MultibodyJointHandle> {
println!("Inserting kinematic: {}", kinematic);
let link1 = self.rb2mb.get(body1.0).copied().unwrap_or_else(|| {
let mb_handle = self.multibodies.insert(Multibody::with_root(body1, true));
MultibodyLinkId {

View File

@@ -28,6 +28,7 @@ use {
#[derive(Debug)]
pub struct ConstraintsCounts {
pub num_constraints: usize,
#[allow(dead_code)] // Keep this around for now. Might be useful once we rework parallelism.
pub num_jacobian_lines: usize,
}

View File

@@ -9,11 +9,11 @@ use crate::dynamics::{GenericJoint, ImpulseJoint, IntegrationParameters, JointIn
use crate::math::{AngVector, Isometry, Matrix, Point, Real, Rotation, Vector, ANG_DIM, DIM};
use crate::prelude::RigidBodySet;
use crate::utils;
use crate::utils::{IndexMut2, SimdCrossMatrix, SimdDot, SimdQuat, SimdRealCopy};
use crate::utils::{IndexMut2, SimdCrossMatrix, SimdDot, SimdRealCopy};
use na::SMatrix;
#[cfg(feature = "dim3")]
use crate::utils::SimdBasis;
use crate::utils::{SimdBasis, SimdQuat};
#[cfg(feature = "simd-is-enabled")]
use crate::math::{SimdReal, SIMD_WIDTH};
@@ -345,9 +345,11 @@ impl JointOneBodyConstraintBuilderSimd {
#[derive(Debug, Copy, Clone)]
pub struct JointTwoBodyConstraintHelper<N: SimdRealCopy> {
pub basis: Matrix<N>,
#[cfg(feature = "dim3")]
pub basis2: Matrix<N>, // TODO: used for angular coupling. Can we avoid storing this?
pub cmat1_basis: SMatrix<N, ANG_DIM, DIM>,
pub cmat2_basis: SMatrix<N, ANG_DIM, DIM>,
#[cfg(feature = "dim3")]
pub ang_basis: SMatrix<N, ANG_DIM, ANG_DIM>,
pub lin_err: Vector<N>,
pub ang_err: Rotation<N>,
@@ -387,7 +389,7 @@ impl<N: SimdRealCopy> JointTwoBodyConstraintHelper<N> {
let cmat1 = r1.gcross_matrix();
let cmat2 = r2.gcross_matrix();
#[allow(unused_mut)] // The mut is needed for 3D
#[cfg(feature = "dim3")]
let mut ang_basis = frame1.rotation.diff_conj1_2(&frame2.rotation).transpose();
#[allow(unused_mut)] // The mut is needed for 3D
let mut ang_err = frame1.rotation.inverse() * frame2.rotation;
@@ -401,9 +403,11 @@ impl<N: SimdRealCopy> JointTwoBodyConstraintHelper<N> {
Self {
basis,
#[cfg(feature = "dim3")]
basis2: frame2.rotation.to_rotation_matrix().into_inner(),
cmat1_basis: cmat1 * basis,
cmat2_basis: cmat2 * basis,
#[cfg(feature = "dim3")]
ang_basis,
lin_err,
ang_err,

View File

@@ -1,6 +1,8 @@
use parry::bounding_volume;
use parry::math::{Isometry, Point, Real, DIM};
use parry::math::{Isometry, Point, Real};
use parry::shape::{Cuboid, SharedShape, TriMeshFlags};
#[cfg(feature = "dim3")]
use parry::transformation::vhacd::VHACDParameters;
/*
@@ -9,8 +11,10 @@ use parry::transformation::vhacd::VHACDParameters;
*
*/
/// Error that can be generated by the [`MeshConverter`].
#[derive(thiserror::Error, Debug)]
pub enum MeshConverterError {
/// The convex hull calculation carried out by the [`MeshConverter::ConvexHull`] failed.
#[error("convex-hull computation failed")]
ConvexHullFailed,
}
@@ -47,6 +51,8 @@ pub enum MeshConverter {
}
impl MeshConverter {
/// Applies the conversion rule described by this [`MeshConverter`] to build a shape from
/// the given vertex and index buffers.
pub fn convert(
&self,
vertices: Vec<Point<Real>>,

View File

@@ -11,7 +11,7 @@
//! User documentation for Rapier is on [the official Rapier site](https://rapier.rs/docs/).
#![deny(bare_trait_objects)]
#![warn(missing_docs)] // FIXME: deny that
#![warn(missing_docs)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::needless_range_loop)] // TODO: remove this? I find that in the math code using indices adds clarity.
#![allow(clippy::module_inception)]