I enabled Tick Physics Async, also experimented with Substepping, Substepping Async (in all combinations), but still callback is called from game thread. (Code below)
My output is:
LogTemp: Warning: UAsyncPhysicsActorComponent::BeginPlay() on Thread: 2680 (GameThread)
PIE: Server logged in
PIE: Play in editor total start time 0.059 seconds.
LogTemp: Warning: UAsyncPhysicsActorComponent::TickComponent 0.00833 on Thread: 2680 (GameThread)
LogTemp: Warning: UAsyncPhysicsActorComponent::AsyncPhysicsTickComponent 0.00400 on Thread: 2680 (GameThread)
LogTemp: Warning: UAsyncPhysicsActorComponent::AsyncPhysicsTickComponent 0.00400 on Thread: 2680 (GameThread)
LogTemp: Warning: UAsyncPhysicsActorComponent::AsyncPhysicsTickComponent 0.00400 on Thread: 2680 (GameThread)
LogTemp: Warning: UAsyncPhysicsActorComponent::TickComponent 0.07302 on Thread: 2680 (GameThread)
LogTemp: Warning: UAsyncPhysicsActorComponent::AsyncPhysicsTickComponent 0.00400 on Thread: 2680 (GameThread)
LogTemp: Warning: UAsyncPhysicsActorComponent::AsyncPhysicsTickComponent 0.00400 on Thread: 2680 (GameThread)
LogTemp: Warning: UAsyncPhysicsActorComponent::AsyncPhysicsTickComponent 0.00400 on Thread: 2680 (GameThread)
above log is for config:
[/Script/Engine.PhysicsSettings]
bTickPhysicsAsync=True
AsyncFixedTimeStepSize=0.004000
bSubstepping=False
bSubsteppingAsync=False
MaxSubsteps=16
MaxSubstepDeltaTime=0.002500
Chaos settings are:
Enabling bSubstepping with (or without) bSubsteppingAsync gives same result.
All threads are same GameThread.
So it looks it is not very “async” when called from one thread.
Shouldn’t it be called from set dedicated threads for physical simulation?
// Called when the game starts
void UAsyncPhysicsActorComponent::BeginPlay()
{
Super::BeginPlay();
uint32 ThreadID = FPlatformTLS::GetCurrentThreadId();
FString ThreadName = FThreadManager::Get().GetThreadName(ThreadID);
UE_LOG(LogTemp, Warning, TEXT("UAsyncPhysicsActorComponent::BeginPlay() on Thread: %u (%s)"), ThreadID, *ThreadName);
// ...
SetAsyncPhysicsTickEnabled(true);
}
// Called every frame
void UAsyncPhysicsActorComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
uint32 ThreadID = FPlatformTLS::GetCurrentThreadId();
FString ThreadName = FThreadManager::Get().GetThreadName(ThreadID);
UE_LOG(LogTemp, Warning, TEXT("UAsyncPhysicsActorComponent::TickComponent %.5f on Thread: %u (%s)"), DeltaTime, ThreadID, *ThreadName);
// ...
}
void UAsyncPhysicsActorComponent::AsyncPhysicsTickComponent(float DeltaTime, float SimTime)
{
Super::AsyncPhysicsTickComponent(DeltaTime, SimTime);
uint32 ThreadID = FPlatformTLS::GetCurrentThreadId();
FString ThreadName = FThreadManager::Get().GetThreadName(ThreadID);
UE_LOG(LogTemp, Warning, TEXT("UAsyncPhysicsActorComponent::AsyncPhysicsTickComponent %.5f on Thread: %u (%s)"), DeltaTime, ThreadID, *ThreadName);
}