[DEBUG] correct segmentation fault

This commit is contained in:
Edouard DUPIN 2019-04-01 22:07:43 +02:00
parent 640d3fdcbe
commit beba85290c
4 changed files with 39 additions and 9 deletions

View File

@ -23,6 +23,13 @@ CollisionBody::CollisionBody(const etk::Transform3D& _transform, CollisionWorld&
m_contactManifoldsList(null),
m_world(_world) {
EPHY_DEBUG(" set transform: " << _transform);
if (isnan(_transform.getPosition().x()) == true) { // check NAN
EPHY_CRITICAL(" set transform: " << _transform);
}
if (isinf(_transform.getOrientation().z()) == true) {
EPHY_CRITICAL(" set transform: " << _transform);
}
}
CollisionBody::~CollisionBody() {
@ -40,6 +47,17 @@ inline void CollisionBody::setType(BodyType _type) {
}
}
void CollisionBody::setTransform(const etk::Transform3D& _transform) {
EPHY_DEBUG(" set transform: " << m_transform << " ==> " << _transform);
if (isnan(_transform.getPosition().x()) == true) { // check NAN
EPHY_CRITICAL(" set transform: " << m_transform << " ==> " << _transform);
}
if (isinf(_transform.getOrientation().z()) == true) {
EPHY_CRITICAL(" set transform: " << m_transform << " ==> " << _transform);
}
m_transform = _transform;
updateBroadPhaseState();
}
ProxyShape* CollisionBody::addCollisionShape(CollisionShape* _collisionShape,
const etk::Transform3D& _transform) {

View File

@ -106,10 +106,7 @@ namespace ephysics {
* @brief Set the current position and orientation
* @param transform The transformation of the body that transforms the local-space of the body int32_to world-space
*/
void setTransform(const etk::Transform3D& _transform) {
m_transform = _transform;
updateBroadPhaseState();
}
virtual void setTransform(const etk::Transform3D& _transform);
/**
* @brief Add a collision shape to the body. Note that you can share a collision shape between several bodies using the same collision shape instance to
* when you add the shape to the different bodies. Do not forget to delete the collision shape you have created at the end of your program.

View File

@ -182,8 +182,25 @@ void RigidBody::setIsSleeping(bool _isSleeping) {
Body::setIsSleeping(_isSleeping);
}
void RigidBody::updateTransformWithCenterOfMass() {
// Translate the body according to the translation of the center of mass position
m_transform.setPosition(m_centerOfMassWorld - m_transform.getOrientation() * m_centerOfMassLocal);
if (isnan(m_transform.getPosition().x()) == true) {
EPHY_CRITICAL("updateTransformWithCenterOfMass: " << m_transform);
}
if (isinf(m_transform.getOrientation().z()) == true) {
EPHY_CRITICAL(" set transform: " << m_transform);
}
}
void RigidBody::setTransform(const etk::Transform3D& _transform) {
EPHY_DEBUG(" set transform: " << m_transform << " ==> " << _transform);
if (isnan(_transform.getPosition().x()) == true) {
EPHY_CRITICAL(" set transform: " << m_transform << " ==> " << _transform);
}
if (isinf(_transform.getOrientation().z()) == true) {
EPHY_CRITICAL(" set transform: " << m_transform << " ==> " << _transform);
}
m_transform = _transform;
const vec3 oldCenterOfMass = m_centerOfMassWorld;
// Compute the new center of mass in world-space coordinates
@ -258,6 +275,7 @@ void RigidBody::updateBroadPhaseState() const {
// Recompute the world-space AABB of the collision shape
AABB aabb;
EPHY_VERBOSE(" : " << aabb.getMin() << " " << aabb.getMax());
EPHY_VERBOSE(" m_transform: " << m_transform);
shape->getCollisionShape()->computeAABB(aabb, m_transform *shape->getLocalToBodyTransform());
EPHY_VERBOSE(" : " << aabb.getMin() << " " << aabb.getMax());
// Update the broad-phase state for the proxy collision shape

View File

@ -53,10 +53,7 @@ namespace ephysics {
/**
* @brief Update the transform of the body after a change of the center of mass
*/
void updateTransformWithCenterOfMass() {
// Translate the body according to the translation of the center of mass position
m_transform.setPosition(m_centerOfMassWorld - m_transform.getOrientation() * m_centerOfMassLocal);
}
void updateTransformWithCenterOfMass();
void updateBroadPhaseState() const override;
public :
/**
@ -75,7 +72,7 @@ namespace ephysics {
* @brief Set the current position and orientation
* @param[in] _transform The transformation of the body that transforms the local-space of the body int32_to world-space
*/
virtual void setTransform(const etk::Transform3D& _transform);
void setTransform(const etk::Transform3D& _transform) override;
/**
* @brief Get the mass of the body
* @return The mass (in kilograms) of the body