shanefarris
30-03-2011 19:41:05
I am trying to do a ray cast on my character controller, but I can't get anything returned. Is there something specific we are suppose to do to run a ray cast on a character controller? I changed my custom one to the one built in 1.6, but it still doesn't work.
Thanks.
betajaen
30-03-2011 19:52:18
PhysX likes to use the userData for it's own nefarious purposes in the character controller. However, NxOgre uses a "PhysXPointer", the userData to identify NxOgre classes from raycasts, and scene queries. I'm surprised the code didn't crash for you, it used to in the past because of wrong a casting.
The only thing I can think of is to do a stack trace the Scene raycast function and post back what it does.
shanefarris
30-03-2011 20:12:47
I don't understand, isn't the userData stored in the actor class? If so then the RaycastHit class that is returned will not do any good because we don't get a rigidBody back right?
Also, I added this to set shape and rigid body to NULL otherwise you will get an invalid pointer if you try to access the mRigidBody member:
// NxOgreRaycastHit.h
struct NxOgrePublicClass RaycastHit
{
RaycastHit()
{
mRigidBody = NULL;
mShape = NULL;
}
...
This raycast callback will not fail now, in fact it won't do anything because it won't ever get a rigid body.
bool onHitEvent(const NxOgre::RaycastHit& hit)
{
if(hit.mRigidBody)
{
}
return false;
}
So the only way is to use "userData"?
betajaen
30-03-2011 21:15:34
AKAIK (or can remember):
The NxCharacterController, stores a 4 char 'NXCC' as a void* in the userData of the attached NxShape, typically NxOgre expects this to be a pointer to a PhysXPointer class (which contains the pointer to the parent RigidBody and the NxOgre Shape representation in question). Unfortunately, NxOgre expects this to be a PhysXPointer - because there is no extra userData to determine the type of userData in question. If it's null or NXCC it should return early, because there is no RigidBody representative. 'NXCC' is literally converted into a memory address, a nasty hack but it works for PhysX.
This is something I hope to address in BuggySwires, when I continue on with the CC. But it has been a while since I've looked at the shape code so my memory is quite foggy.