Hey again, I checked the files for 4-26 and there are similar functions to wake up a UPrimitiveComponents, leading to a call (::wakeUp) on a NVidia PhysX file:
\UE_4.26\Engine\Source\ThirdParty\PhysX3\PhysX_3.4\Include\PxRigidDynamic.h
It might be worth checking how this file compares in UE5 and if it’s still called, or replaced by chaos?
@tigerija
The file provides additional information about the sleep mechanic in UE4.26 and 5.0:
When an actor does not move for a period of time, it is no longer simulated in order to save time. This state
is called sleeping. However, because the object automatically wakes up when it is either touched by an awake object,
or one of its properties is changed by the user, the entire sleep mechanism should be transparent to the user.
In general, a dynamic rigid actor is guaranteed to be awake if at least one of the following holds:
\li The wake counter is positive (see #setWakeCounter()).
\li The linear or angular velocity is non-zero.
\li A non-zero force or torque has been applied.
If a dynamic rigid actor is sleeping, the following state is guaranteed:
\li The wake counter is zero.
\li The linear and angular velocity is zero.
\li There is no force update pending.
When an actor gets inserted into a scene, it will be considered asleep if all the points above hold, else it will be treated as awake.
If an actor is asleep after the call to PxScene::fetchResults() returns, it is guaranteed that the pose of the actor
was not changed. You can use this information to avoid updating the transforms of associated objects.
\note A kinematic actor is asleep unless a target pose has been set (in which case it will stay awake until the end of the next
simulation step where no target pose has been set anymore). The wake counter will get set to zero or to the reset value
#PxSceneDesc::wakeCounterResetValue in the case where a target pose has been set to be consistent with the definitions above.
*Edit 1. One sec, I actually have UE5 installed already. The Physx file exists there as well and is identical.
*Edit 2. So for most part the calls from the start (UPrimitiveComponent) to the end (Physx) are identical in UE5.
UPrimitiveComponent::WakeRigidBody
> FBodyInstance::WakeInstance
> FPhysicsInterface::WakeUp_AssumesLocked
> PxRigidDynamic::wakeUp
The problem might be with this file:
\UE_5.0\Engine\Source\Runtime\Engine\Private\PhysicsEngine\BodyInstance.cpp
In which a lot of changes have been made and checks have been added. For example:
FInitBodiesHelperBase::FInitBodiesHelperBase(...) {
....
#if WITH_CHAOS
FPhysicsInterface::SetMaxLinearVelocity_AssumesLocked(Instance->ActorHandle, TNumericLimits<float>::Max());
....
#endif
....
}
Comparing that to the PhysX comment above:
In general, a dynamic rigid actor is guaranteed to be awake if at least one of the following holds:
* The linear or angular velocity is non-zero.
This already suggests one reason why the component might not wake properly. Nothing looks wrong with it so far but change is change, it’s definitely going wrong somewhere :).
Additional (new) checks can be found in that file which can prevent execution of updating mass properties,