CollisionTree vs. chamfer cylinder collision bug?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

CollisionTree vs. chamfer cylinder collision bug?

Postby Cannos » Tue Jan 18, 2011 2:59 am

I'm not sure if I'm doing something wrong or if this is a bug, but I have a specific case where the penetration amount reported by NewtonCollisionCollide is wrong. I have a penetrating chamfer cylinder and a convex tree collision that is reporting 5 contacts of zero penetration, when there should be at least one penetration amount of around 0.4. I added the following code to the 2.29 build of the BasicFriction demo inside the void Friction(DemoEntityManager* scene) function.

Code: Select all
    // Make collision tree
    NewtonCollision* pCollision = NewtonCreateTreeCollision(world, 0);
    NewtonTreeCollisionBeginBuild(pCollision);

    const int cNumVerts = 8;
    float verts[cNumVerts][3] =
    {
         0.5,    0,    0,
        -0.5,    0,    0,
           0,    0, -2.5,
           0,    0,  2.5,
         0.5, 0.25,    0,
        -0.5, 0.25,    0,
           0, 0.25, -2.5,
           0, 0.25,  2.5
    };
    const int cNumFaces = 12;
    int indices[cNumFaces * 3] =
    {
        0, 1, 2,
        0, 3, 1,
        4, 6, 5,
        4, 5, 7,
        5, 6, 2,
        5, 2, 1,
        7, 5, 1,
        7, 1, 3,
        4, 2, 6,
        4, 0, 2,
        4, 7, 3,
        4, 3, 0
    };

    for (int i = 0; i < cNumFaces; i++)
    {
        int index0 = indices[i * 3];
        int index1 = indices[i * 3 + 1];
        int index2 = indices[i * 3 + 2];

        float faceVerts[3][3];
        faceVerts[0][0] = verts[index0][0];
        faceVerts[0][1] = verts[index0][1];
        faceVerts[0][2] = verts[index0][2];
        faceVerts[1][0] = verts[index1][0];
        faceVerts[1][1] = verts[index1][1];
        faceVerts[1][2] = verts[index1][2];
        faceVerts[2][0] = verts[index2][0];
        faceVerts[2][1] = verts[index2][1];
        faceVerts[2][2] = verts[index2][2];
       
        NewtonTreeCollisionAddFace(pCollision, 3, &(faceVerts[0][0]), 12, 0);
    }
    NewtonTreeCollisionEndBuild(pCollision, 1);

    // Add chamfer cylinder
    float offsetmtx[16] = { 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0.1f, 0, 1 };
    NewtonCollision* pCylCollision = NewtonCreateChamferCylinder(world, 0.5f, 0.2f, 1, offsetmtx);

    // Matrices of collision tree and cylinder
    float treeMtx[16] = { 0.70710677f, 0, 0.70710677f, 0, 0, 1, 0, 0, -0.70710677f, 0, 0.70710677f, 0, 26.652052f, 0.5f, 43.713711f, 1 };
    float cylMtx[16] = { -0.882393219f,      -0.00228729658f,   0.469481796f,   0,
                     -0.00185807608f,    0.999997318f,      0.00137752341f, 0,
                     -0.469483703f,      0.000343936495f,   -0.882941127f,  0,
                     26.0855798f,        0.495723963f,       44.80299f,      1 };

    // Do collision
    const int cMaxContacts = 15;
    float contacts[cMaxContacts][3];
    float normals[cMaxContacts][3];
    float penetrations[cMaxContacts];
    int numContacts = NewtonCollisionCollide(world, cMaxContacts, pCylCollision, cylMtx, pCollision, treeMtx, &(contacts[0][0]), &(normals[0][0]), &(penetrations[0]), 0);


The code above will report numContacts as 5, and all 5 values in the penetrations array are 0.

Is there something wrong in my code, or is there possibly a bug here? Thanks.
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Julio Jerez » Tue Jan 18, 2011 2:02 pm

Ok I will check out.

I had not being able to touch on the engine in the last two weeks because a crunch time at work.
the company is about to release a new Project and can not miss its submition day, but after this week I am back to check out few reported Bugs
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Cannos » Wed Jan 19, 2011 4:22 pm

Thanks Julio, I appreciate it!
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Cannos » Thu Jan 27, 2011 3:27 am

Hey Julio, have you had a chance to look at this yet?
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Julio Jerez » Thu Jan 27, 2011 2:11 pm

I pasted the code in teh frition demo, and I get a Bad Crash in debuig mode

I thonk it is because matrix is no orthonormal
float cylMtx[16] = { -0.882393219f, -0.00228729658f, 0.469481796f, 0,
-0.00185807608f, 0.999997318f, 0.00137752341f, 0,
-0.469483703f, 0.000343936495f, -0.882941127f, 0,
26.0855798f, 0.495723963f, 44.80299f, 1 };

I will debug mre later, by see if tah matris is correct.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Cannos » Thu Jan 27, 2011 3:43 pm

Sorry about that, I must have copied/pasted a bad value. Anyway, the rotation doesn't really matter. Here's a matrix that should work and gives the same results:

float cylMtx[16] = { 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
26.0855798f, 0.495723963f, 44.80299f, 1.0f };
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Julio Jerez » Thu Jan 27, 2011 4:28 pm

the wrong matrix triggered and assert, that all

I will past that matrix and see what happens. are the shapes suppose to collided and report penetration?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Cannos » Thu Jan 27, 2011 4:32 pm

Yes, they are penetrating. I was expecting to see at least one penetration amount around 0.4.
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Julio Jerez » Thu Jan 27, 2011 4:37 pm

Ok I will check it out.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Julio Jerez » Fri Jan 28, 2011 10:22 am

when I run teh test it show thet teh twop shape are colliding bu teh penetration is
+ matrixA {m_front={...} m_up={...} m_right={...} ...} const dgMatrix &
+ contactOut 0x0018a1a0 {m_point={...} m_normal={...} m_body0=0x0018c3c0 ...} dgContactPoint * const
penetration, 5 -0.0041694758 float
count1 8 int
penetration -0.0041694758 float



tha values is smallet that teh threasi use to deside if two shape are in penetrtion state of jys in contact
in the code there si a test that deside is a contact soudl be result bu appliyin an impulse of by applying a resting force

dist = GetMax (- (penetration + DG_IMPULSIVE_CONTACT_PENETRATION), dgFloat32 (0.0f));


DG_IMPULSIVE_CONTACT_PENETRATION is set to 0.00725 of a unit

in your sample the result is positive and the contact is considered zero penetrations.
those are the details a physics engine has to do to unify the treatment of impulse and resting forces in a single solver.
if have not bearing on any physical law, but is enerate goo result on teh limits.

in any case yo usay teh penetartion spuhe be 0.4
that seem to beig to me, how do you decide that, that shoul be the penetration?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Julio Jerez » Fri Jan 28, 2011 12:16 pm

I was tryin to see if I can undenrtand what the tree soudl look like,
but I am confuse, it seem to be a tringulat wedge with two horintal flat thingle,

oen is a at hight of zero and the othe at a high of 0.25 units
the cilynder is on top yet is collides wit the face the is at the bottom and teh contacts point sideways.
It does no make sence to me.

can you make a sketch of how it should look?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Cannos » Fri Jan 28, 2011 1:11 pm

Yes, the collision tree is kind of a diamond shaped solid. Here are 2 screenshots that show how the collision tree and cylinder are penetrating. Almost half of the cylinder is inside the collision tree shape. Since the cylinder radius is 0.5, this is how I was guessing the the penetration would be around 0.4.
Capture.PNG
Capture.PNG (28.13 KiB) Viewed 4367 times
Capture2.PNG
Capture2.PNG (11.01 KiB) Viewed 4367 times
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Julio Jerez » Fri Jan 28, 2011 2:25 pm

It is difficult for mee to see what is i, teh wrie frame does no indicate the penetration depth,
when I step in debug I only see 4 faces, I guess the optimizer compine then.

can you check what happens if you turn optimization of in the collision tree?
what I found in the the only two faces that are colliding are the first two,
I will try again tomorrow and see what it is.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Cannos » Fri Jan 28, 2011 2:41 pm

I turned off optimization and could see the extra faces in the wireframe, but got the same results. 5 contacts, but 0 penetration. Here's another image that might help give you an idea how the objects are overlapping.

Capture3.PNG
Capture3.PNG (31.12 KiB) Viewed 4364 times
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: CollisionTree vs. chamfer cylinder collision bug?

Postby Julio Jerez » Fri Jan 28, 2011 3:07 pm

Ha I see, that's much better, so the cylinnder mesh is hiting one the side faces,

Ok I will see what is going on.
Is the mesh colliding wi the the cylinder the same mesh you post in the code oyu posted?
and are do teh image show the same same position that is in teh code?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron