[PHYSICS] Center of mass needs a rework

I hear you. Yeah, agree with that, would be very useful option to set COM directly. I’m not sure why devs added offset instead of override, perhaps something related to how code is structured or how it’s fed to PhysX. Don’t know exactly.

If you are in dire need of such change, this is the code for c++ function to set InertiaTensor:



void UMMTBPFunctionLibrary::MMTSetInertiaTensor(UPrimitiveComponent * Target, const FVector& InertiaTensor)
{
	FBodyInstance* BodyInstance = GetBodyInstance(Target);
	if (BodyInstance != NULL) {

		PxRigidBody* PRigidBody = BodyInstance->GetPxRigidBody_AssumesLocked();

		if (PRigidBody != NULL) {

			PRigidBody->setMassSpaceInertiaTensor(U2PVector(InertiaTensor));
		}
	}
}


For center of mass you can replace “PRigidBody->setMassSpaceInertiaTensor(U2PVector(InertiaTensor));” with this line:
PRigidBody->setCMassLocalPose( [NewCenterOfMassTransform] );

Transform here is not FTransform but PxTransform of Physx. Haven’t tested it but should work.