NewtonCollisionSetCollisionMode behavior change

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: NewtonCollisionSetCollisionMode behavior change

Postby Bird » Tue Jul 15, 2014 2:11 pm

That seems to work ok but it only finds contacts while the engine is running. I need something that works while the engine is not updating too.


Oops. On closer look I spoke too soon. There's no contacts generated if NewtonCollisionSetCollisionMode is 0 so my "phantom" body is not detecting collision like it needs to.

Julio Jerez wrote:would it help is I add a broaphase update?


It would if it will let me detect contacts without a NewtonUpdate call with a body that doesn't interact with other bodies in the scene. That's what I need.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: NewtonCollisionSetCollisionMode behavior change

Postby Julio Jerez » Tue Jul 15, 2014 2:29 pm

My impression was that In the code you show me, you use the NewtonWorldForEachBodyInAABBDo
Impression to scan all bodies sin the vicinity of the of the Phamton object

The call back was the one doing the collision test with the between the two shapes.

You can do two things,
1-Call the same function you were using in the call back when the call to
int isActive = NewtonJointIsActive (joint) returns true

Code: Select all
 if( NewtonCollisionIntersectionTest(world, collisionA, &poseA[0][0], collisionB, &poseB[0][0],0) )
   {
      // ignore contact with no penetration
      const int maxSize = 2;
      dFloat contacts[maxSize * 3];
      dFloat normals[maxSize * 3];
      dFloat penetrations[maxSize];
      dLong attrbA[maxSize * 3];
      dLong attrbB[maxSize * 3];
      int contactCount = NewtonCollisionCollide(world, maxSize,
                                      collisionA, &poseA[0][0],
                                      collisionB, &poseB[0][0],
                                      &contacts[0],
                                      &normals[0],
                                      &penetrations[0],
                                      &attrbA[0],
                                      &attrbB[0],
                                      0);
      if(contactCount)
         entity->bodyDesc.collisionInfo.collisionList.push_back( (PhysicsBody*)(otherEntity) );
   }

2-secund, for this I need to add another interface, the joint already has the collision deepest penetrationn contact, it just does calculate the contacts, bu that si exactly what NewtonCollisionIntersectionTest does, so I can add an interface to get that contact and yo ucna use it.
Something like
Code: Select all
void NewtonMaterialGetContactFisrtPositionAndNormal (const NewtonMaterial* const material, NewtonBody* const body, dFloat* const posit, dFloat* const normal);

Ok way until tonight I will add those to funtion and I will write a more format function for you.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCollisionSetCollisionMode behavior change

Postby Bird » Tue Jul 15, 2014 2:44 pm

1-Call the same function you were using in the call back when the call to
int isActive = NewtonJointIsActive (joint) returns true


But isActive is never true when the passed in body has NewtonCollisionSetCollisionMode 0. Is that something you can change with a new mode for NewtonCollisionSetCollisionMode?

Ok way until tonight I will add those to funtion and I will write a more format function for you.


Great! Thanks

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: NewtonCollisionSetCollisionMode behavior change

Postby Julio Jerez » Tue Jul 15, 2014 3:39 pm

Bird wrote:But isActive is never true when the passed in body has NewtonCollisionSetCollisionMode 0. Is that something you can change with a new mode for NewtonCollisionSetCollisionMode?
-Bird


it does it if the engine is updating, this is who the collision trigger works now, before I has to do almost what you are doing and it was hard and err prone to keep track of what was in the trigger or not
now the rule is: object are intersecting if they have active contact joint.
anyway just way until tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCollisionSetCollisionMode behavior change

Postby Julio Jerez » Wed Jul 16, 2014 12:17 am

ok I thought more about this and I think I is better to just make you function work as you wrote it.
It does not seem a good idea to fix a broken functionality by adding another functionality.
so I wrote you function and I poste bellow, pleas etake a llok and tell he if this is hwo you wrote it.
Code: Select all
static int aabbCollisionCallback (const NewtonBody * const otherBody, void * const userData)
{   
   NewtonBody* const myBody = (NewtonBody*)userData;
   dAssert (myBody);

   // not interested in self collision
   if ( myBody == otherBody ) {
      return 1;
   }

   NewtonWorld* const world = NewtonBodyGetWorld(myBody);
   NewtonCollision* const collisionA = NewtonBodyGetCollision(myBody);
   NewtonCollision* const collisionB = NewtonBodyGetCollision(otherBody);
   
   dMatrix poseA;
   NewtonBodyGetMatrix(myBody, &poseA[0][0]);

   dMatrix poseB;
   NewtonBodyGetMatrix(otherBody,&poseB[0][0]);

   if( NewtonCollisionIntersectionTest(world, collisionA, &poseA[0][0], collisionB, &poseB[0][0],0) )
   {
      // ignore contact with no penetration
      const int maxSize = 2;
      dFloat contacts[maxSize * 3];
      dFloat normals[maxSize * 3];
      dFloat penetrations[maxSize];
      dLong attrbA[maxSize * 3];
      dLong attrbB[maxSize * 3];
      int contactCount = NewtonCollisionCollide(world, maxSize,
         collisionA, &poseA[0][0],
         collisionB, &poseB[0][0],
         &contacts[0],
         &normals[0],
         &penetrations[0],
         &attrbA[0],
         &attrbB[0],
         0);
      if(contactCount) {
         dAssert (0);
         //entity->bodyDesc.collisionInfo.collisionList.push_back( (PhysicsBody*)(otherEntity) );

      }
   }

   return 1;
}


static bool testForCollision (NewtonBody * const pBody)
{
   // this body has NewtonCollisionSetCollisonMode set to 0
   dVector min;
   dVector max;
   NewtonBodyGetAABB (pBody, &min.m_x, &max.m_x);
   NewtonWorld* const world = NewtonBodyGetWorld(pBody);
   NewtonWorldForEachBodyInAABBDo(world, &min.m_x, &max.m_x, aabbCollisionCallback, pBody);
   return true;
}


basically the bug is that int contactCount = NewtonCollisionCollide(world, maxSize, ... is no calculation any contacts because the collision has a collision flag set to false.
please tell me my deduction are correct before I continue.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCollisionSetCollisionMode behavior change

Postby Julio Jerez » Wed Jul 16, 2014 12:38 am

Ok since I am more than 95% sure that was the bug, I just fixed.
If you sync to github it should just work.

also see if you can verify If the NewtonCollisionClosestPoint() is working , I am pretty sure I fixed.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCollisionSetCollisionMode behavior change

Postby Bird » Wed Jul 16, 2014 8:57 am

Ok since I am more than 95% sure that was the bug, I just fixed.
If you sync to github it should just work

The new version does find intersections now and it works fine for me if the engine is not updating. But with the engine running this won't work because now the "phantom"( with NewtonCollisionSetCollisionMode 0.) interacts with other bodies on contact, causing them to move away while the user drags the "phantom" around. I need to "phantom" to move around the scene and detect collisions but not cause any other bodies to move.
also see if you can verify If the NewtonCollisionClosestPoint() is working , I am pretty sure I fixed.

Not fixed yet.
Herre's line 434 in dgNarrowPhaseCollision.cpp
if (collisionA.IsType (dgCollision::dgCollisionCompound_RTTI)) {
dgAssert (0);
/*
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: NewtonCollisionSetCollisionMode behavior change

Postby Julio Jerez » Wed Jul 16, 2014 10:42 am

I am sure the phantom does no collide with other object when the collision is set to 0
if you play the Archimedes buoyancy or the advance player controller demo and you click show collision, you will see that the swimming pool is a kinematic body with collision set to 0

moving the object should have not impact at all in the scene, can you should me a video of what is doing now?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCollisionSetCollisionMode behavior change

Postby Bird » Wed Jul 16, 2014 11:14 am

Julio Jerez wrote:I am sure the phantom does no collide with other object when the collision is set to 0
if you play the Archimedes buoyancy or the advance player controller demo and you click show collision, you will see that the swimming pool is a kinematic body with collision set to 0

moving the object should have not impact at all in the scene, can you should me a video of what is doing now?

This is what I'm seeing with the new version.
http://hurleyworks.com/media/flash/AP_PhantomCollision/AP_PhantomCollision.html

One weird thing is if you look closely, it appears to work fine for awhile after the initial instance creation.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: NewtonCollisionSetCollisionMode behavior change

Postby Julio Jerez » Wed Jul 16, 2014 11:58 am

I see. when you spawn the cow, the Phamton pushes the cow away from it interior.

In the video, I assume the phanton is the convex hull of the cow.
when you spawn the Cow, is the Cow a single convex or a compound?

Also I see some glitches at the beginning is that part of the problem.

Let us do this, tonight I will add a new demo Object placement demo to eth sand box and then we can try all these things
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCollisionSetCollisionMode behavior change

Postby Bird » Wed Jul 16, 2014 12:05 pm

I see. when you spawn the cow, the Phamton pushes the cow away from it interior.

Yes, and that's not supposed to happen and didn't happen in the previous version of Newton that I was using.

In the video, I assume the phanton is the convex hull of the cow.
when you spawn the Cow, is the Cow a single convex or a compound?

It's s single convex.
The phantom collision shape is always the same collision shape as the body being instanced. In this case it is the convex hull but it could be anything.

Let us do this, tonight I will add a new demo Object placement demo to eth sand box and then we can try all these things

Sounds like a plan. Thank you for your help!

-Bird

-
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: NewtonCollisionSetCollisionMode behavior change

Postby Julio Jerez » Wed Jul 16, 2014 12:16 pm

yes of course it could be anything, I am asking for testing

Let me set the demo so that we can test everything, to me it make sense that it works at first and the start malfunction,
that will be a bug and will require more testing. The demo should expose it.
maybe it is because in all my test I never move the phamton and the bug is on that part of the code.

How do to move the phamton, you just set the matrix?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCollisionSetCollisionMode behavior change

Postby Bird » Wed Jul 16, 2014 12:42 pm

How do to move the phamton, you just set the matrix

Yes, I just call NewtonBodySetMatrix

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: NewtonCollisionSetCollisionMode behavior change

Postby Julio Jerez » Wed Jul 16, 2014 1:02 pm

One more thing, can you briefly describe the technique you use to frag around the phantom?
do you cast the phantom shape from the EYE point or you use some ray cast and then try to place the shape, or something else?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCollisionSetCollisionMode behavior change

Postby Bird » Wed Jul 16, 2014 1:51 pm

do you cast the phantom shape from the EYE point or you use some ray cast and then try to place the shape

I use NewtonWorldRayCast from the EYE origin through the mouse position to place it on the ground. Since the phantom will be resting on the ground, you'll need to filter out the ground from the phantom's collision tests too.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron