RigidBody not rotating (also PVD crash).

Hello !

I have following problem: I created ragdoll with capsules, linked using joints (spherical, no limits) and put actors to aggregate (nothing special here). I’m setting actors position with setKinematicTarget and at some point I’m turning animation driven ragdoll to simulation one (just switching eKINEMATIC to false, waking up and so on…). velocity is preserved, but angular rotation is somehow removed completly from all ragdoll actors.

I tried not to create joints, use separate actors (not aggeregate). Ragdoll actors setup uses the very same code path as for other actors (I’m settuping custom filter shader and overriding filter data word0 etc…). For non ragdoll actors everything looks fine.

When doing visual debug I can clearly see that velocity is there, anular rotation is properly calculated when actor is kinematic. In the same moment when I’m switching to use simulation angular is cleared.

Whats even more strange is that actor no longer gets any rotation. It just keeps its rotation from the last animation frame. It could event lay horizontally touching ‘by finger’ one of its capsule’s ends another object levitating in air xD

Im attaching pxd2 capture (it contains two ragdolls, working sphere and static part of the scene).

[url]- YouTube

Another issue: I am not able to use any of the PVD version (nor 3.0 or 2.x from git). It just crashes just after connection from my app or loading dumped pxd2 file.

Thank you for any help :)


Note:
Visual Studio 2015
PhysX 3.3.4
x86 app and libs

PXD2 File: [url]https://drive.google.com/file/d/0B1bHKr7llvDIWWZuY0dLbDZrakU/view?usp=sharing[/url]

Solved (hacky).

I checked with PVD 2.01 (only version that works), and inertia tensors used to be 0,0,0 for all ragdoll actors.
I’m using updateMassAndInertia after setuping actor (and before adding to aggregate and scene). getCMass and getInertiaTensor shows proper values after updateMass. In the next frame inertia is lost (some double-buffered issue ??).

What I had to do is update actor’s amassAndInertia again after switching from kinematic to simulated one:

const PxVec3 linVel = shape.m_actor->getLinearVelocity();
const PxVec3 angVel = shape.m_actor->getAngularVelocity();

shape.m_actor->setRigidDynamicFlag( PxRigidBodyFlag::eKINEMATIC, isKinematic );
shape.m_actor->wakeUp();

if( !isKinematic )
{
	// Magic happens. Somehow PhysX lost all its inertia tensors and I need to recalculate it.
	// Should be fast since its just once capsule to compute
	PxRigidBodyExt::updateMassAndInertia( *shape.m_actor, shape.m_density );

	// Preserve linear and angular momentum
	shape.m_actor->setLinearVelocity( linVel );
	shape.m_actor->setAngularVelocity( angVel );
}