Advertisement Jump to content
Sign in to follow this  
Silverlan

PhysX - PxRigidDynamic clip through other actors (CCD enabled)

This topic is 1779 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is a re-creation of my old thread here. I haven't been able to solve this issue and the thread got closed, so here's attempt 2:

 

My PxRigidDynamic actors intersect with other actors and I can't figure out why. There are still collisions between them, but the rigid dynamic slightly clips through them and is 'pushed' back. Here's a video of it ingame/in the PVD:

 

The box is a PxRigidDynamic actor.

The player is a PxCapsuleController.

All other actors are PxRigidStatic.

 

Having CCD disabled or enabled seems to make no difference. (CCD should only affect high-velocity objects anyway, so I doubt that's the cause here)

 

The collisions between the controller and the static actors are fine, so I don't see why the rigid dynamic would behave any differently.

 

I'm using PhysX-3.3.0

Share this post


Link to post
Share on other sites
Advertisement

Are you calling PxRigidBodyExt::setMassAndUpdateInertia (possibly instead of setMass) after all the shapes have been created? That behaviour in your video is exactly what happens if this call is omitted.

Share this post


Link to post
Share on other sites

I was using 'updateMassAndInertia', just changed it to 'setMassAndUpdateInertia', but the result is the same.

I didn't use this function on my character controllers and static actors (Like the world), but I assume that's not neccessary?

Share this post


Link to post
Share on other sites
Yes, it should be called on dynamic actors only. Otherwise static/dynamic actor initialization should look quite similar. I assume you're not manually applying impulses on the box (at onShapeHit callback)? Does your box behave like that if you're not pushing it with the character controller? Does it penetrate the static actor if it falls? I still suspect there's something wrong with how you're creating your dynamic actors. Even if the cc pushed the box in to the wall/ground, it should jump right off. Post some initialization code maybe so that can be ruled out?

Share this post


Link to post
Share on other sites
I'm applying my own gravity, but that's just 'addForce' with the 'physx::PxForceMode::eACCELERATION' flag.
And yes, the box behaves like that even if it is just interacting with the world (static actor):
 
As for the initialization, it's mainly this:
 
Line 53 is where the actual actor is created.

Share this post


Link to post
Share on other sites

Okay, I didn't notice anything odd in the code. But by looking that video I noticed that your world scale is enormous compared to that grid (it's not possible to scale that grid, is it?). What units are you using? It's known that too small units can cause jittering when using inappropriate contact offsets. There's something in the documentation about this and here: http://www.nvidia.com/object/physx_knowledge_base.html (it's for the previous version but probably still valid).

Edited by fanwars

Share this post


Link to post
Share on other sites

Make sure the PxTolerancesScale values are sensible when you create your scene - as fanwars suggests.

 

Make sure your iteration counts are OK - e.g. 4 for position iterations is sensible, and 2 for velocity (penetration correction). Though what you're seeing is so bad that I don't think it's this.

 

Also make sure that the shape contactOffset and restOffset are sensible for your units, on all shapes, static and dynamic (but again, I don't think it's this).

 

If you can upload a short PVD capture I'll take a look...

Share this post


Link to post
Share on other sites

Well, I'm currently using the same world scale as the source engine does, which means that 1 unit equals 19.05mm.

I'd hate having to change the scale of everything in my world, but I'd also like to avoid having a different scale for the physics only. Any way to compensate? If that's actually the issue here.

 

Here's a PVD capture, hope it'll give a bit more insight:

http://filesmelt.com/dl/physx_test1.zip

Share this post


Link to post
Share on other sites

OK great - having looked for just a few minutes:

 

1. The way the box falls, it doesn't look like CCD is enabled - are you sure it's enabled in the filter shader as well as the scene and dynamic actor (I can see the flag is these two)? However, this is not the cause of the problem. 

 

2. Your box looks like it's about 50 units across. The contactOffset value is 0.02 which is tiny, in proportion. I'd suggest setting contactOffset to 1. But I don't think this will solve the problem. 

 

3. The scene is reporting gravity as (0,0,0) (and the object has eDISABLE_GRAVITY) - is that right? So you're applying gravity manually? I don't see why you shouldn't - a constant force shouldn't cause penetration problems... but maybe it is.

 

4. PVD doesn't report the tolerancesScale length/mass values - but it does say the "normal" speed is 10 units/s. When your box falls it his the ground at about 909 units/s

 

I would:

 

1. Disable CCD for the moment - it hasn't been reliable in the past (though is probably fine now)

 

2. Make sure the PxTolerancesScale is set correctly

 

3. If that doesn't work, see whether it's due to disabling gravity and applying the gravitational force manually (if this is it, it sounds like a PhysX bug).

Share this post


Link to post
Share on other sites

1) The physx::PxSceneFlag::eENABLE_CCD is set in the PxSceneDesc and physx::PxPairFlag::eCCD_LINEAR inside the CCD Filter Shader.

The actor's also have the 'physx::PxRigidBodyFlag::Enum::eENABLE_CCD' and the 'physx::PxRigidBodyFlag::Enum::eENABLE_CCD_FRICTION' flags set.

2) How do I change the contact offset for dynamic actors? 'setContactReportThreshold'?

3) Yes, as I've said, I'm applying my own gravity. I disabled it and tried it with physx' inbuilt gravity as you've suggested, but the result was the same. (Without the below changes)

4) I've changed the values to the following:

length:

From the documentation: "For simulating roughly human-sized in metric units, 1 is a good choice. If simulation is done in centimetres, use 100 instead. This is used to estimate certain length-related tolerances."

Since in my case 1 unit = 19.05mm, I chose 190.5 as an appropriate value.

mass:

"The approximate mass of a length * length * length block. If using metric scale for character sized objects and measuring mass in kilogrammes, 1000 is a good choice."

My measurement is in kilogrammes, so I've set it to 1000.

speed:

"For normal physical environments, a good choice is the approximate speed of an object falling under gravity for one second."

This one's a bit difficult to determine in my case. The gravity can change entirely and there is no 'typical' velocity. I've set it to 180 for now.

 

That seemed to do the trick, although I can't push the box anymore, even with a low mass:

http://filesmelt.com/dl/physx_test2.zip

 

How can I change the push force of a controller?

Also, if you check the capture, you'll notice there's a rather large offset around the controller to anything it touches:

7iCsy.png

 

I've set the contact offset in the PxCapsuleControllerDesc to 0.01.

Why is the offset still that large?

 

Thanks to both of you, I'm already a large step further!

Edited by Silverlan

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!