mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 20:23:06 +02:00
fix crash for computing inertia for btBvhTriangleMeshShape
This commit is contained in:
parent
551bfac85e
commit
670e07bbf5
1 changed files with 5 additions and 3 deletions
|
@ -92,7 +92,7 @@ void ObjectMotionState::setMass(float mass) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float ObjectMotionState::getMass() const {
|
float ObjectMotionState::getMass() const {
|
||||||
if (_shape) {
|
if (_shape && _shape->getShapeType() != TRIANGLE_MESH_SHAPE_PROXYTYPE) {
|
||||||
// scale the density by the current Aabb volume to get mass
|
// scale the density by the current Aabb volume to get mass
|
||||||
btTransform transform;
|
btTransform transform;
|
||||||
transform.setIdentity();
|
transform.setIdentity();
|
||||||
|
@ -348,8 +348,10 @@ void ObjectMotionState::updateLastKinematicStep() {
|
||||||
|
|
||||||
void ObjectMotionState::updateBodyMassProperties() {
|
void ObjectMotionState::updateBodyMassProperties() {
|
||||||
float mass = getMass();
|
float mass = getMass();
|
||||||
btVector3 inertia(0.0f, 0.0f, 0.0f);
|
btVector3 inertia(1.0f, 1.0f, 1.0f);
|
||||||
_body->getCollisionShape()->calculateLocalInertia(mass, inertia);
|
if (mass > 0.0f) {
|
||||||
|
_body->getCollisionShape()->calculateLocalInertia(mass, inertia);
|
||||||
|
}
|
||||||
_body->setMassProps(mass, inertia);
|
_body->setMassProps(mass, inertia);
|
||||||
_body->updateInertiaTensor();
|
_body->updateInertiaTensor();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue