onEndTouch does not seem to recieving a callback [Solved]

dinvog

26-12-2007 18:13:43

Hi,

I am using the inherited class method for my contact reporter. One group has an actor of triangleMesh type while the other is compound shape as given below:

Compound Mesh


gCar = mScene->createActorGroup("Car");
nxcar = mScene->createBody
(
"final_car.mesh",
new CapsuleShape(..),
...
"mass: 400, Group: Car");

nxcar->addShape(
new CapsuleShape(..)
);

nxcar->addShape(
new CapsuleShape(..)
);

Triangle Mesh

gTunnel= mScene->createActorGroup("Tunnel");
tunnel = mScene->createBody
(
"tuneel_final.mesh",
new TriangleMeshShape("tuneel_final.mesh"),
...
"Static: Yes, Group: Tunnel"
);

ContactReporter Class
class myCallback : public GroupCallback::InheritedCallback
{
public :
bool air_borne;
myCallback()
{
air_borne = false;
}
void onStartTouch(Actor *a, Actor *b)
{
Body * bd = static_cast<Body*>(b);
bd->getEntity()->setMaterialName("arrow");
air_borne = false;
}
void onEndTouch(Actor *a, Actor *b)
{
Body * bd = static_cast<Body*>(b);
bd->getEntity()->setMaterialName("ball_mesh_material");
air_borne = true;

}
void onTouch(Actor *a, Actor *b)
{
Body * bd = static_cast<Body*>(b);
bd->getEntity()->setMaterialName("arrow");
air_borne = false;
}
};


Setting up the GroupCallBack

mCar_Tun = new myCallback();
gTunnel->setCallback<myCallback>(mCar_Tun,&myCallback::onStartTouch,&myCallback::onEndTouch,&myCallback::onTouch);
gTunnel->setCollisionCallback(gCar,NX_NOTIFY_ALL,true);


The callback to onstarttouch and ontouch seem to work fine. However the onEndTouch does not seem to work. Is there something wrong with my code.

I also tried to change the NX_NOTIFY_ALL flag to NX_NOTIFY_ON_END_TOUCH but that did not help.

I had used similar code in NxOgre0.4 by declaring contactpairs and it had worked. I had a few more questions about using ActorGroups; If a collision is detected for an actor of group, will code in the callback function affect all actors in the group or just the one for which the collision occurred?

If trianglemesh is what is causing the problem than is there anyway I can convert it into a convexmesh?

dinvog

27-12-2007 18:29:08

Now I have also tried with primitive shapes and I am not getting a callback on the onendtouch in this case either. I got the latest SVN code and I am running against the latest nxogre dll.

I had a look at what the debugger is showing and it properly indicates the points of contact between the bodies.

Should I change the way I initialise the Nxogre world. Should I not pass the framelistener and instead use simulate/render? Will that help in any way?

betajaen

27-12-2007 18:56:39

No that won't affect it. Sounds like a problem with PhysX or the use of it. Have you tried doing the code in old fashioned PhysX code?

dinvog

27-12-2007 20:36:03

Have you tried doing the code in old fashioned PhysX code?

By this do you mean the method of using contactpairs as in 0.4? I assumed it meant to replicate what was done in 0.4.

I was in the process of copying the code from the 0.4 release with some help
http://www.ogre3d.org/phpBB2addons/viewtopic.php?p=26498, but noticed that both the classes SceneContactController (0.9) and contactReporter (0.4) both have functions onContactNotify that use NxU32 events and pretty much have the same code.

There was no real difference ( 0.4 uses if and 0.9 uses switch :? ), unless like you said PhysX is not reporting properly, however the debugger does show the contact points properly.

0.4
void contactReporter::onContactNotify(NxContactPair& pair, NxU32 events)
{
if (!pair.actors[0] || !pair.actors[1]) return;
Body *a = static_cast<NxOgre::Body*>(pair.actors[0]->userData);
Body *b = static_cast<NxOgre::Body*>(pair.actors[1]->userData);
if(events & NX_NOTIFY_ON_START_TOUCH)
{
onStartTouch(a, b); return;
}
if(events & NX_NOTIFY_ON_TOUCH)
{
onTouch(a, b); return;
}
if(events & NX_NOTIFY_ON_END_TOUCH)
{
onEndTouch(a, b); return;
}
}

0.9
void SceneContactController::onContactNotify(NxContactPair &pair, NxU32 events) {

Actor *a, *b;

if (pair.actors[0]->userData && pair.actors[1]->userData) {
a = (static_cast<NxActorUserData*>(pair.actors[0]->userData))->toActor();
b = (static_cast<NxActorUserData*>(pair.actors[1]->userData))->toActor();
}
else {
return;
}

NxActorGroup agid = pair.actors[0]->getGroup();
NxActorGroup bgid = pair.actors[1]->getGroup();

ActorGroup *ag, *bg;

switch(events) {

case NX_NOTIFY_ON_TOUCH:

ag = mActorGroupsIndexed->get(agid);
bg = mActorGroupsIndexed->get(bgid);

if (ag)
ag->onTouch(a, b);

if (bg)
bg->onTouch(b, a);

break;
case NX_NOTIFY_ON_START_TOUCH:
ag = mActorGroupsIndexed->get(agid);
bg = mActorGroupsIndexed->get(bgid);
if (ag)
ag->onStartTouch(a, b);
if (bg)
bg->onStartTouch(b, a);

break;
case NX_NOTIFY_ON_END_TOUCH:
ag = mActorGroupsIndexed->get(agid);
bg = mActorGroupsIndexed->get(bgid);
if (ag)
ag->onEndTouch(a, b);
if (bg)
bg->onEndTouch(b, a);
break;
}
}


I will try to implement the 0.4 method tomorrow morning.

Aiursrage2k

27-12-2007 20:57:11

Seems strange its not fixed in 2.73 but... looks like you are going to have go back to 2.7 because 2.7x doesnt seem to have NX_NOTIFY_ON_END_TOUCH


alessio quaglino


Registered: 9/3/2007
0 Trust Points.



I'm trying to use the flag NX_NOTIFY_ON_END_TOUCH inside my class ContactReport but it seems that physX never detect an ending for the contacts. To be sure of this, I tried to raise the actor flag NX_NOTIFY_ALL and what I get is that the starting moment is detected correctly, then the event returned is always of the type NX_NOTIFY_ON_TOUCH, so that the collision never ends.

I'm using simple shapes and In my code this problem appears both when trying to set the flag for a pair and for a group (which is what I want) and also with or without the DISABLE_RESPONSE flag (which, again, is what I need). The error has been replicated also by another person, who is using his version of ContactReport, so I guess there might be a bug.



Quan Chen


Registered: 7/2/2007
10 Trust Points.


AGEIA

Re: contact report bug
Posted on 9/17/2007 3:48 AM
Are you using 2.7.2 version of SDK? We've found a regression bug about NX_NOTIFY_ON_END_TOUCH can't work in this version. In 2.7.0, it should be OK.
And we may integrate the fix for this bug in the next release. Thank you for reporting.


Thibaut Tollemer


Registered: 11/14/2007
0 Trust Points.



Re: contact report bug
Posted on 11/14/2007 1:46 AM
Quoting Quan Chen:
Are you using 2.7.2 version of SDK? We've found a regression bug about NX_NOTIFY_ON_END_TOUCH can't work in this version. In 2.7.0, it should be OK.
And we may integrate the fix for this bug in the next release. Thank you for reporting.


Had the same problem as the poster, switched back to 2.7.0 and I confirm it works.

http://devsupport.ageia.com/ics/support ... eptID=1949

betajaen

27-12-2007 22:52:56

I told you it was PhysX! ;)

dinvog

28-12-2007 12:56:46

Yup.. you were right. Oh and I was using 2.7.2 and so I am not sure if 2.7.3 also has this bug ( :oops: just in case the assumption was made on my behalf).

AngryZealot

12-01-2008 21:59:46

Sorry for the bump, but I've encountered the same problem. I was wondering if there is a trick to get NxOgre to compile for 2.7.0. Right now I get slammed with 36 errors, mostly relating to force fields, but some other things as well. For example, Scene::~Scene makes reference to mDominanceGroups, but mDominanceGroups is not defined unless NX_SDK_VERSION_NUMBER >= 272. I'm currently using NxOgre 0.9'38.