Several issues with PhysX (PxControllers and PxScene::overlap)

Started by
3 comments, last by Silverlan 10 years, 4 months ago

Sorry for the undescriptive title, couldn't really describe it in one sentence.

I'm having a lot of trouble with physx and to be honest, the documentation is rather lacking.

I've tried to ask on the official forums, but they're more or less a ghost town.

I'm currently having 3 problems I can't find a solution for:

1) PxScene::overlap always returns true

According to the documentation, it's supposed to return 'True if a blocking hit was found or any hit was found in case PxQueryFlag::eANY_HIT flag was specified.'.

In my trials it always returned true, whether there was an overlap or not:


physx::PxCapsuleController *controller = static_cast<physx::PxCapsuleController*>(physController->GetController());
physx::PxScene *scene = controller->getScene();
physx::PxSceneReadLock scopedLock(*scene);

physx::PxCapsuleGeometry geom(1,1); // Radius and height = 1, just for testing

physx::PxVec3 pos(0,0,0);
physx::PxQuat orientation(physx::PxHalfPi,physx::PxVec3(0.0f,0.0f,1.0f));
physx::PxOverlapBuffer hit;
if(scene->overlap(geom,physx::PxTransform(pos,orientation),hit,physx::PxQueryFilterData(physx::PxQueryFlag::eANY_HIT)));
{
	Con::cerr<<"getNbAnyHits: "<<hit.getNbAnyHits()<<Con::endl;
	Con::cerr<<"getNbTouches: "<<hit.getNbTouches()<<Con::endl;
	Con::cerr<<"hasBlock: "<<hit.hasBlock<<Con::endl;
	return false;
}

This creates a tiny capsule at the origin, there's no way there could be a collision with anything, yet the output is this:


getNbAnyHits: 0
getNbTouches: 0
hasBlock: 0

Why does it return true if it hasn't found anything blocking it? Am I missing something?

This is the scene as shown through the PVD:

http://i.imgur.com/in6hnse.jpg

If there IS a collision, it still returns true, but hasBlock is != 0.

2) PxControllers collide prematurely

Both PxBoxController and PxCapsuleController objects collide with my static world before they actually touch it:

http://filesmelt.com/dl/physxcontactoff.jpg

(The capsule was getting pushed down by gravity and towards the wall, but stopped at the position shown here)

PxRigidDynamic objects collide with the world as they should.

At first I thought this has something to do with the contact offset, but I've tried setting that to 0, or a value very close to 0, and it made no difference.

3) Pushing PxControllers

I'd like to implement a simple jump functionality for a playable character (PxCapsuleController).

Problem is, PxController objects 'stick' to the world until they receive a certain force. So if my character is currently standing on solid ground, and is getting pushed upwards by a small force, he will stick to the ground and not move at all.

How can I disable this for a controller temporarily?

Thanks in advance.

Advertisement

Which PhysX version is this?

I'm using PhysX-3.3.0_Beta-2 (16402319)

Hi,

The first problem, where the scene query always returns true, sounds like a bug. I'll try to reproduce it.

The second issue is probably a rendering artifact. The character controller docs state:

"A small skin is maintained around the character's volume, to avoid numerical issues that would otherwise happen if we let it touch other shapes. The size of this skin is user-defined. If you render the character's volume for debug purpose, remember to expand the volume by the size of this skin to get accurate debug visualization."

I think that there may still some minimum contact offset, even when you set contact offset to zero, and the PVD rendering doesn't take that into account.

Regarding the third question, " if my character is currently standing on solid ground, and is getting pushed upwards by a small force, he will stick to the ground and not move at all."

A kinematic rigid body underlies the character controller, therefore forces won't have any effect on it. You have to use the move() function.

Hope this helps, and sorry for the lack of response on the PhysX forum. We'll try harder!

Mike

Thanks for your response.

2) I'm not entirely convinced, the collision offset is fairly large:

uknF1kQ.jpg

(To put this into perspective, the upper capsule has a radius of 32 and a half-height of 18)

3) My mistake, I WAS using the move function, but I think I merely set the gravity too high.

Still, I'm not quite sure I understand how PxControllers actually work. I'm keeping the velocity of my character seperate from the controller, but after I call move() and simulate the scene, the velocity could change due to collisions. So I have to retrieve the new velocity directly from the controller's actor after fetchResulsts.

If I do that however, the velocity I get is entirely different from the displacement vector I've used, even though there haven't been any collisions and it moves exactly the way it should. Shouldn't the actor's velocity be exactly the same as the displacement vector in this case?

// Update:

According to the PVD, the contact offset for the capsule controllers is definitely 0.02. Everthing else seems fine, although I noticed the radius / half-height shown in the PVD don't match up with the values I've given it. (It's showing 25.6 as radius and 7.2 as half-height, which can't be right?)

This topic is closed to new replies.

Advertisement