PhysX contacts problem

Hello! Can anybody provide some help? We have a problem with contacts placement in our project - we create two rigid kinematic objects using convex mesh shape and throw rigid dynamic capsule to one of them - all is ok:
https://drive.google.com/file/d/0B1SCg9e5O89zTUxIU0QtM1QzaFE/view?usp=sharing
then we remove one actor from scene and throw rigid dynamic capsule to it - and we have conacts generated in 0.1 meter out of them (beside it):
https://drive.google.com/file/d/0B1SCg9e5O89zNlpZcXk1UmpFLW8/view?usp=sharing
We test it with v3.3.2 and v3.3.3, CCD is enabled for capsule. I dont know where to look. Here is PVD with all data: https://drive.google.com/file/d/0B1SCg9e5O89zazNleG5ySXpTMkU/view?usp=sharing

Hi,

I’ll take a look.

We tested it with 3 objects and contacts are placed incorrectly only for actors, created after removed one. For example, we remove 2-nd object - contacts are ok for 1st and are wrong for 3rd. If we remove 1st, contacts are wrong for 2nd and 3rd.

This looks to me like a problem with the contact cache. Are you using the PCM option, or the non-PCM code path (Persistent Contact Manifold)? Is CCD enabled?

I was not using eENABLE_PCM, but tested it now - it changes nothing. CCD always was enebled. Is there any more tests i can perform to clarify problem?

I downloaded new PhysX 3.3 repo (https://github.com/NVIDIAGameWorks/PhysX-3.3), I used old one (GitHub - NVIDIAGameWorks/PhysX: NVIDIA PhysX SDK) before. Now contacts positions are always correct (looks like somebody fix this bug in new repo), but contact normals are flipped in same case - after removing object:
https://drive.google.com/file/d/0B1SCg9e5O89zQzZKWTJzNWlYSGs/view?usp=sharing
before removing:
https://drive.google.com/file/d/0B1SCg9e5O89zbnB2b1lZNnFCMEU/view?usp=sharing
Here is PVD:
https://drive.google.com/file/d/0B1SCg9e5O89zNmFBSHpYUC1XNnM/view?usp=sharing

Is this behavior for normals by design or it is a bug? I saw such problems with normals before in some other case (don’t remember exactly) and implemented such workaround in my code:

PxVec3 norm = iter.getContactNormal();
if(iterex.preSolverVelocity)
{ // Norm is not bound to actor (may be inverted), so we need to clarify it
	if(!iterex.preSolverVelocity->linearVelocity[0].isZero())
	{
		PxVec3 Dir = -iterex.preSolverVelocity->linearVelocity[0].getNormalized();
		float angle = acos(Dir.dot(norm));
		if(angle > MATH_PI / 2.0f)
			norm = -norm;
	}
	else
	if(!iterex.preSolverVelocity->linearVelocity[1].isZero())
	{
		PxVec3 Dir = -iterex.preSolverVelocity->linearVelocity[1].getNormalized();
		float angle = acos(Dir.dot(norm));
		if(angle > MATH_PI / 2.0f)
			norm = -norm;
	}
}

I am not sure if such workaround is problem free, what can you say about that?

The PxContactPair refers to two shapes, shapes[0] and shapes[1]. The contact normal always points from shape[1] to shape[0]. However, when you remove a shape from the scene, it is possible that the shapes are re-ordered in the contact pair, so it appears that the normal has been reversed. You are reversing a copy of the normal returned by the system, which is perfectly legal; but if you were somehow able to reverse the actual normal internal to the system, I think the collision system would fail.

Thanks for the help!

Hello again! Looks like I found more problems in same place - preSolverVelocity member of contact pair some times give me wrong value, equial to post solver velocity from previous contact. I through bullets to the target and get such pre solver velocity normally: 0.54 288.47 29.51, but some time it shows 0.90 -144.32 27.73. I use presolver velocity to check if i need to invert normal and has wrong results. Strange, but I got 5 contacts at a time with wrong velocity, and only one contact with correct velocity.

Also cp.shapes[0]->getActor()->isRigidDynamic().getLinearVelocity() give me the same value at that moment.