Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix3x3 getInverse assert, v0.7.0 #82

Closed
aliasdevelopment opened this issue Jan 13, 2019 · 9 comments
Closed

Matrix3x3 getInverse assert, v0.7.0 #82

aliasdevelopment opened this issue Jan 13, 2019 · 9 comments
Assignees

Comments

@aliasdevelopment
Copy link

Hi Daniel

This happens when I add addCollisionShape to a BoxShape when the extend is small. Got allot of boxes of different sizes which do not assert, but when I added a somewhat small box I get this assert.

box_extend = {x = 0.100000001, y = 0.0250000004, z = 0.100000001}

GDB output:

(gdb) frame 7
#7 0x0000000000443828 in general::reactphysics::create_box (this=0x9a15e8, object_data=std::shared_ptrgeneral::object_data_t (use count 1, weak count 0) = {...}, extend=..., mass=@0x7fffffffc828: 1,
dynamic=@0x7fffffffc82f: false) at /home/projects/test/applications/general/physics/react.hpp:68
68 body->addCollisionShape( shape.get(), shape_transform, shape_mass );
(gdb) info locals
initPosition_internal = {x = 0, y = 0, z = 0.00999999978}
initOrientation = {x = 0, y = 0, z = 0, w = 1}
transform = {mPosition = {x = 0, y = 0, z = 0.00999999978}, mOrientation = {x = 0, y = 0, z = 0, w = 1}}
pos_transform = @0x7fffffffc660: {x = 0, y = 0, z = 0.00999999978}
orientation_transform = @0x7fffffffc66c: {x = 0, y = 0, z = 0, w = 1}
box_extend = {x = 0.100000001, y = 0.0250000004, z = 0.100000001}
shape = std::unique_ptrreactphysics3d::BoxShape = {get() = 0x12f3120}
shape_mass = 1
shape_transform = {mPosition = {x = 0, y = 0, z = 0}, mOrientation = {x = 0, y = 0, z = 0, w = 1}}
body = std::unique_ptrreactphysics3d::RigidBody = {get() = 0x1310650}
source_position = 0x7fffffffc6e0
destination_position = 0x7fffffffc726
source_orientation = 0x7fffffffc727
destination_orientation = 0xbcab10
(gdb) frame 6
#6 0x000000000061bea8 in reactphysics3d::RigidBody::addCollisionShape (this=0x1310650, collisionShape=0x12f3120, transform=..., mass=1) at /home/projects/reactphysics3d/src/body/RigidBody.cpp:309
309 recomputeMassInformation();
(gdb) info locals
proxyShape = 0x1318670
aabb = {mMinCoordinates = {x = -0.100000001, y = -0.0250000004, z = -0.0900000036}, mMaxCoordinates = {x = 0.100000001, y = 0.0250000004, z = 0.109999999}}
(gdb) frame 5
#5 0x000000000061c854 in reactphysics3d::RigidBody::recomputeMassInformation (this=0x1310650) at /home/projects/reactphysics3d/src/body/RigidBody.cpp:534
534 mInertiaTensorLocalInverse = inertiaTensorLocal.getInverse();
(gdb) info locals
inertiaTensorLocal = {mRows = {{x = 0.00354166701, y = 0, z = 0}, {x = 0, y = 0.00666666729, z = 0}, {x = 0, y = 0, z = 0.00354166701}}}
PRETTY_FUNCTION = "void reactphysics3d::RigidBody::recomputeMassInformation()"
oldCenterOfMass = {x = 0, y = 0, z = 0.00999999978}
(gdb) frame 4
#4 0x0000000000650edf in reactphysics3d::Matrix3x3::getInverse (this=0x7fffffffc3a0) at /home/projects/reactphysics3d/src/mathematics/Matrix3x3.cpp:51
51 assert(std::abs(determinant) > MACHINE_EPSILON);
(gdb) info locals
determinant = 8.36227088e-08
PRETTY_FUNCTION = "reactphysics3d::Matrix3x3 reactphysics3d::Matrix3x3::getInverse() const"
invDeterminant = -nan(0x7fc3a0)
tempMatrix = {mRows = {{x = -nan(0x7fc2e0), y = 4.59163468e-41, z = 8.98691521e-39}, {x = 0, y = 0, z = 0.00354166701}, {x = -nan(0x7fc360), y = 0.00354166701, z = -nan(0x7fc490)}}}
(gdb)

@DanielChappuis DanielChappuis self-assigned this Jan 14, 2019
@DanielChappuis
Copy link
Owner

Can you paste here your code that you use to create the rigid body and to add the collision shapes to it ? This code alone should allow me to reproduce the issue on my side.

@aliasdevelopment
Copy link
Author

`const rp3d::Vector3 initPosition_internal = rp3d::Vector3( object_data->position[0], object_data->position[1], object_data->position[2] );

// Initial position and orientation of the rigid body     
rp3d::Quaternion initOrientation = rp3d::Quaternion::identity(); 
rp3d::Transform transform(initPosition_internal, initOrientation);

//fetch transform for object_data
const rp3d::Vector3& pos_transform = transform.getPosition();
const rp3d::Quaternion& orientation_transform = transform.getOrientation();

const rp3d::Vector3 box_extend( extend[0]*0.5f, extend[1]*0.5f, extend[2]*0.5f ); //0.5f seince extend is half_width

std::unique_ptr< rp3d::BoxShape > shape = std::make_unique< rp3d::BoxShape >( box_extend );
rp3d::decimal shape_mass = rp3d::decimal( mass );
rp3d::Transform shape_transform = rp3d::Transform::identity();

std::unique_ptr< rp3d::RigidBody > body( world->createRigidBody( transform ) );

body->addCollisionShape( shape.get(), shape_transform, shape_mass );`

@DanielChappuis
Copy link
Owner

Thanks but I also need to following values to be able to debug it:

  • extend[0]
  • extend[1]
  • extend[2]
  • initPosition_internal
  • mass

@aliasdevelopment
Copy link
Author

aliasdevelopment commented Jan 16, 2019

From the gdb output, the values are:

initPosition_internal = {x = 0, y = 0, z = 0.00999999978}
box_extend = {x = 0.100000001, y = 0.0250000004, z = 0.100000001}, since the input for extend was (0.2f, 0.05f, 0.2f)
shape_mass = 1

@DanielChappuis
Copy link
Owner

The issue has been fixed in the commit 6ef1773 in the master branch.

Can you try on your side if the issue is now fixed ?

@aliasdevelopment
Copy link
Author

Sure. Hope I will manage to test it this weekend, plus the other issue we talked about.

@DanielChappuis
Copy link
Owner

Have you been able to test this ?

@aliasdevelopment
Copy link
Author

The commit does not produce the assert anymore, and my scene works as expected.
Had the scene where the issue was present, did a update to 6ef1773 and the issue disappeared.

@DanielChappuis
Copy link
Owner

Thanks a lot for the feedback and for reporting the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants