From 7cd5127086aaeb16c4d99fc447e32d3f085d43eb Mon Sep 17 00:00:00 2001
From: Lukas Werner <lks.werner@fau.de>
Date: Mon, 30 Mar 2020 18:53:20 +0200
Subject: [PATCH] Fixed mass and inertia for some shapes

---
 src/mesa_pd/data/shape/Box.h                 | 3 +++
 src/mesa_pd/data/shape/CylindricalBoundary.h | 7 +++++--
 src/mesa_pd/data/shape/Ellipsoid.h           | 2 ++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/mesa_pd/data/shape/Box.h b/src/mesa_pd/data/shape/Box.h
index 7cc560678..cb67d2d63 100644
--- a/src/mesa_pd/data/shape/Box.h
+++ b/src/mesa_pd/data/shape/Box.h
@@ -61,7 +61,10 @@ void Box::updateMassAndInertia(const real_t density)
          edgeLength_[0]*edgeLength_[0] + edgeLength_[2]*edgeLength_[2] ,
          edgeLength_[0]*edgeLength_[0] + edgeLength_[1]*edgeLength_[1] ) * (m / static_cast<real_t>( 12 ));
 
+   mass_ = m;
    invMass_      = real_t(1.0) / m;
+
+   inertiaBF_ = I;
    invInertiaBF_ = I.getInverse();
 }
 
diff --git a/src/mesa_pd/data/shape/CylindricalBoundary.h b/src/mesa_pd/data/shape/CylindricalBoundary.h
index abe3bca75..81a04d7e4 100644
--- a/src/mesa_pd/data/shape/CylindricalBoundary.h
+++ b/src/mesa_pd/data/shape/CylindricalBoundary.h
@@ -59,8 +59,11 @@ private:
 inline
 void CylindricalBoundary::updateMassAndInertia(const real_t /*density*/)
 {
-   invMass_      = real_t(0.0);
-   invInertiaBF_ = Mat3(real_t(0.0));
+   mass_         = std::numeric_limits<real_t>::infinity();
+   invMass_      = real_t(0);
+
+   inertiaBF_    = Mat3(std::numeric_limits<real_t>::infinity());
+   invInertiaBF_ = Mat3(real_t(0));
 }
 
 inline
diff --git a/src/mesa_pd/data/shape/Ellipsoid.h b/src/mesa_pd/data/shape/Ellipsoid.h
index 8ff941185..7101209cb 100644
--- a/src/mesa_pd/data/shape/Ellipsoid.h
+++ b/src/mesa_pd/data/shape/Ellipsoid.h
@@ -61,7 +61,9 @@ void Ellipsoid::updateMassAndInertia(const real_t density)
          real_c(0.2) * m * (semiAxes_[2] * semiAxes_[2] + semiAxes_[0] * semiAxes_[0]),
          real_c(0.2) * m * (semiAxes_[0] * semiAxes_[0] + semiAxes_[1] * semiAxes_[1]));
 
+   mass_         = m;
    invMass_      = real_t(1.0) / m;
+   inertiaBF_    = I;
    invInertiaBF_ = I.getInverse();
 }
 
-- 
GitLab