Trigger doesn't detect Character

Night Elf

24-08-2007 17:40:05

I'm using triggers (NxOgre::Trigger) and they seem to detect normal bodies perfectly, but don't generate a callback when the character (NxOgre::Character) collides. What should I do to make triggers detect my character?

betajaen

24-08-2007 17:43:51

Nothing. Characters are exempt from Triggers, as is all kinematic actors (I think).

I have an idea on how to make a Trigger for Characters only though, it involves a CharacterHitReport and an Actor.

Night Elf

24-08-2007 19:17:03

I guess you mean using CharacterHitReport::onActor() and RS_PassThrough...

Does onActor() get called only the first time there's a collision (like TriggerCallback::onEnter()) or all the time they're colliding (like TriggerCallback::onInside())?

I'm guessing the second one... In that case, how would you implement onEnter and onExit?

BTW, in the Ageia forums there's a similar question about character controller and triggers and someone from Ageia says "the character should work with the trigger system without any special setting". Could this be a bug?

betajaen

24-08-2007 19:49:58

Yep you've got it. To handle onEnter and onExit. It would a simple list of all the current characters within the Actor. To handle an onEnter it would just check if the new character is within the Actor, and onExit probably some callback system to check now and again if the character is actually inside the thing.

I suspect it is a bug.

Night Elf

24-08-2007 23:29:28

I suspect it is a bug.
Just to clarify, you mean a bug in PhysX, right?

It would a simple list of all the current characters within the Actor. To handle an onEnter it would just check if the new character is within the Actor, and onExit probably some callback system to check now and again if the character is actually inside the thing.

I think I'll have to implement something like this. Probably will do it around NxOgre as I'm not confident enough to mess with the NxOgre code. Two questions:

1) What can I use to check a static collision between a character and an actor?

2) I have an update() function in my trigger manager that gets called every frame. Do you think that'd be a good place to check for onExit event? Or is there a better way? (For example, can I have a callback after a physics simulation step has finished?)

Night Elf

25-08-2007 00:51:29

I've looked into the character/trigger collision detection a bit, and it appears to be a bug in NxOgre. :(

The collision is detected, but it doesn't pass the following test in SceneTriggerController::onTrigger(), so it always executes the return:

if (ts.getActor().userData && as.getActor().userData) {
...
}
else {
return;
}


I guess it's probably because the actor associated with the character doesn't have an initialised userData. Any idea what can be done about this, betajaen? Perhaps there's some way to tell if the actor is in fact a character?

betajaen

25-08-2007 09:42:21

Really? In earlier versions of NxOgre it never ever worked so I assumed Characters was exempt from Triggers, perhaps Ageia snuck it in and I didn't notice it in the changes.

In my copy of NxOgre, I've added NxUserData to the Character's Actor so in theory that trigger should fire now (but then crash because it's casting it into an Actor and not a Character). There is a similar fix to this here[/ur] , which you can try out; minus all of the ray caster stuff.

I shall investigate this today, and if it works. Change the trigger to handle character's as well. ;)

betajaen

25-08-2007 10:33:51

Alright, that saved me a ton of work there than implementing my own:

class myTrigger : public TriggerCallback::InheritedCallback {

public:

void onEnter(Trigger*, Actor* a) {
}

void onLeave(Trigger*, Actor* a) {
}

void onInside(Trigger*, Actor* a) {
}

void onEnter(Trigger*, Character* a) {
}

void onLeave(Trigger*, Character* a) {
}

void onInside(Trigger*, Character* a) {
}
};


It should work with the MethodPointer style method as well, but I haven't tested it yet. You'll be able to play with this in the next SVN commit.