## Kinematic Cylinder Collision size problem.

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

### Kinematic Cylinder Collision size problem.

Hi Julio,
I get a problem with kinematic cylinder shape collision.
It don't respecting the full size for the collision.
I think more the cylinder is big more the collision is lose on the side border.

Video Exemple:
You search a nice physics solution, if you can read this message you're at the good place
OrionX3D Projects & Demos:

Dave Gravel

Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm

### Re: Kinematic Cylinder Collision size problem.

Wow, you are so far ahead of me, the robot is very cool.

Are the yellow platform, kinematic bodies with velocities to simulate an assembly like?
And the big round cylinder is the one causing the bug.

If so can you make a test with only the big yellow cylinder and the boxes, maybe we can insulted the bug more.
Julio Jerez
Moderator

Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

### Re: Kinematic Cylinder Collision size problem.

What is the size of the cylinder, I will try to recreate it in the sandbox?
Julio Jerez
Moderator

Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

### Re: Kinematic Cylinder Collision size problem.

Hi Julio,
Wow, you are so far ahead of me, the robot is very cool.

Thanks, I don't think that i'm far ahead, My method is pretty simple if I compare with what you are doing.
My method have surely more limitations and less precision.

Here two more long videos exemple about the robot.

What is the size of the cylinder, I will try to recreate it in the sandbox?

The little box is 0.45, 0.45, 0.45
The problem seen more present when the radius is bigger exemple rad1: 5.0, rad2: 5.0, height: 0.5
If the box is exemple 1,1,1 it seen to work better but you can see the problem is present anyway.
Are the yellow platform, kinematic bodies with velocities to simulate an assembly like?
And the big round cylinder is the one causing the bug.

Yes
I use the omega for the kinematic rotation on the cylinder.

Thanks, If you need a demo let's me know.
You search a nice physics solution, if you can read this message you're at the good place
OrionX3D Projects & Demos:

Dave Gravel

Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm

### Re: Kinematic Cylinder Collision size problem.

Here the demo with only the cylinder and the little box.
https://www.mediafire.com/file/0frj114w ... linder.zip

I use a older newton dll version because if I reset the scene with the last dll I get a crash about the listener.
I'm not sure if something have change about the listener and the auto delete.
I need to debug it for find what cause this problem.

I get the same problem with the cylinder and with the last dll build.

Edited:
No sorry the crash with the last dll don't come from the listener auto delete.
It seen to happen too when I only create one box and if I try to reset the scene in runtime.
I need to debug more about it, I surely do something wrong somewhere.
You search a nice physics solution, if you can read this message you're at the good place
OrionX3D Projects & Demos:

Dave Gravel

Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm

### Re: Kinematic Cylinder Collision size problem.

ok I manage to reproduce it wit a large cylinder in the kinematic body demo.
I will fix that tonight.
can you check it out,

also I would like to fix this bug. It seem to happen to few people, and I think is the same bug
No sorry the crash with the last dll don't come from the listener auto delete.
It seen to happen too when I only create one box and if I try to reset the scene in runtime.
I need to debug more about it, I surely do something wrong somewhere.

can this happen in the SandBox, of do you have a demo that can reproduce it?
Julio Jerez
Moderator

Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

### Re: Kinematic Cylinder Collision size problem.

I have find something new about the crash,
The crash seen to happen when I delete a dynamic object and when it is in sleep state.
It don't seen to happen with static object.
I only get it with the dynamic object.

You can see in the video when the body don't sleep I can delete it without problem, When the body is in sleep mode I get the crash.
Video:

I'm not sure about how to reproduce it in newton sdk.
I have try to reset your demo and it don't seen to happen.
I have test with your friction demo.

Here in my system I call NewtonDestroyBody(mBody); when the userdata object is deleted.
After because sometimes I use body without userdata my system call
NewtonWaitForUpdateToFinish(nWorld);
NewtonDestroyAllBodies(nWorld);
You search a nice physics solution, if you can read this message you're at the good place
OrionX3D Projects & Demos:

Dave Gravel

Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm

### Re: Kinematic Cylinder Collision size problem.

ok I figured out the bug with large cylinders, is on this function

Code: Select all
`dgInt32 dgCollisionCylinder::CalculatePlaneIntersection (const dgVector& normal, const dgVector& origin, dgVector* const contactsOut) const `

let me fix that tonight and then we work on the crash bug.
Julio Jerez
Moderator

Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

### Re: Kinematic Cylinder Collision size problem.

Good
In the AnimatedPlayer demo I have add a box with a body pointer.

I use this code for delete the body.
Code: Select all
`if (scene->GetKeyState('C') != false) {  if (abody != NULL) {     NewtonDestroyBody(abody);     abody = NULL;   }}`

I get the same crash by doing this if the box is in sleep mode.
I think when the body sleep and it is deleted, It stay in a list with a null pointer to the body.
You search a nice physics solution, if you can read this message you're at the good place
OrionX3D Projects & Demos:

Dave Gravel

Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm

### Re: Kinematic Cylinder Collision size problem.

ok see if the fixed the collision bug,

now I see what is wrong with the crash

at what line of animatePlayer did you insert this code
Code: Select all
`if (scene->GetKeyState('C') != false) {  if (abody != NULL) {     NewtonDestroyBody(abody);     abody = NULL;   }}`
Julio Jerez
Moderator

Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

### Re: Kinematic Cylinder Collision size problem.

This is the modified file with the test.

Search about abody in the code:

Edited:
From what I see the bug with the cylinder collision size look fixed now.
I need to test more from my demo but it seen to work good.
Thanks.
You search a nice physics solution, if you can read this message you're at the good place
OrionX3D Projects & Demos:

Dave Gravel

Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm

### Re: Kinematic Cylinder Collision size problem.

ah yes this reproduce the crash the moment I hit the C key.

I committed but is not fixed yet, I will work on it late today.
Julio Jerez
Moderator

Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

### Re: Kinematic Cylinder Collision size problem.

Good.
Remember you if the body is not in sleep state it work as supposed. It happen when the body is in sleep state.
You search a nice physics solution, if you can read this message you're at the good place
OrionX3D Projects & Demos:

Dave Gravel

Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm

### Re: Kinematic Cylinder Collision size problem.

ha I see what the bug is. it is on this function
Code: Select all
`void dgBroadPhase::DeleteDeadContact(){   DG_TRACKTIME();   dgInt32 activeCount = 0;   dgContactList& contactList = *m_world;   dgContact** const contactArray = &contactList[0];   dgArray<dgJointInfo>& constraintArray = m_world->m_jointsMemory;   for (dgInt32 i = contactList.m_contactCount - 1; i >= 0; i--) {      dgContact* const contact = contactArray[i];      if (contact->m_killContact) {         m_contactCache.RemoveContactJoint(contact);         m_world->RemoveContact(contact);         contactList.m_contactCount--;         contactArray[i] = contactList[contactList.m_contactCount];         delete contact;      } else if (contact->m_isActive && contact->m_maxDOF) {         constraintArray[activeCount].m_joint = contact;         activeCount++;      }   }   dgAssert(SanityCheck());   contactList.m_activeContactCount = activeCount;   //dgTrace (("%d %d\n", contactList.m_activeContactCount, contactList.m_contactCount));}`

a while back I changed the contact list from a list to an hash array.
that causes that contact can be removed immediately, instead they are flag and killed, then a pass collect the and remove from the list.
the problem is that to fine the contact is the array the use the hash code that is made form the the tow bodies. by killed contact no longer have the bodies, that cases a crash or even worse, a bad hash if the bodies was recycled.

to fixed it need to save the hash with the joint so that is always read it from the joint instead of making from the bodies.
I need to make that change is all the places that the contact list is use to get to find a random contact.

I think this is the the bug that people has reported but I have have luck find it it because the SDK demos do not delete bodies. I's fix tonight.
Julio Jerez
Moderator

Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

### Re: Kinematic Cylinder Collision size problem.

Yes a chance I have seen it by hasard this coming from destroying sleeping bodies.
At the begin I thinking this coming from the listener autodelete but it is not the case.
The way how i'm reseting my scene NewtonDestroyBody() is a important function.
I use NewtonDestroyAllBodies only when I destroy the world or for a total scene cleanup.

I use NewtonDestroyBody when I delete a userdata object in runtime.
I have a flag in the userdata object to check if the world destroying all bodies or if the object is destroy individually to avoid conflics with the world destruction.

I'm going to test more tonight about the cylinder fix, But from what I currently see it seen to work good now.

Thanks a lot.
You search a nice physics solution, if you can read this message you're at the good place
OrionX3D Projects & Demos:

Dave Gravel

Posts: 713
Joined: Sat Apr 01, 2006 9:31 pm