Description

Changing the state of a PrimitiveComponent->BodyInstance while SetSimulatePhysics(false) updates the game thread but does not update the physics behavior.
In the repro project provided (see addl info URL), calling SetOneWayInteraction(true) will display the correct value in the editor (via inspection via the Details Panel) but the physics behavior does not follow. It's expected that the cube with OneWayInteraction would not interfere with the cube below, like the other pair of cubes on the side, but it does.
It's not clear if this is an actual bug or a misuse of the API.

Steps to Reproduce

To reproduce from the repro project (see addl info URL), simply play the scene in the Editor and verify that in the left pair of cubes the top cube starts off as OneWayInteraction true, it falls and does not move the bottom cube, but in the right pair, the top cube has a component that disables the physics simulation, sets the OneWayInteraction to true, and later enables physics simulation - the change is reflected in the Details Panel but the physics behavior is as if the setting was false, the cube falls and affects the bottom cube.

To reproduce the bug manually:
Create a new project
Add one cube to the scene, not touching the ground, set it to simulate physics and to not be affected by gravity
Duplicate this cube by ALT dragging it above the first cube so that if would fall on top of the bottom one, set it to be affected by gravity.
Confirm both are set to OneWayInteraction false
Create a C++ ActorComponent (SetOneWayInteractionAtBeginPlay in the repro project)
In the BeginPlay add this code snippet:
UPrimitiveComponent* PrimitiveComponent = GetOwner()->GetComponentByClass<UPrimitiveComponent>();
PrimitiveComponent->SetSimulatePhysics(false);
PrimitiveComponent->BodyInstance.SetOneWayInteraction(true);
PrimitiveComponent->SetSimulatePhysics(true);

This will make it disable physics simulation, set the OneWayInteractionFlag, and enable physics simulation
Save/recompile, open up the editor again, add the component to the top cube.
Play in Editor
Expected behavior: the top cube falls and stays put on top of the bottom one. It should not affect the bottom one as OneWayInteraction is true (this can be verified by selecting the top cube and checking in the Details Panel)
Actual behavior: the top cube will fall and move the bottom cube as OneWayInteraction was false

Callstack

> UnrealEditor-PhysicsCore.dll!FChaosEngineInterface::SetOneWayInteraction_AssumesLocked(Chaos::FSingleParticlePhysicsProxy * const & InHandle, bool InOneWayInteraction) Line 1213 C++
[External Code]
[Inline Frame] UnrealEditor-Engine.dll!UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::FFunctionRefStoragePolicy,void __cdecl(Chaos::FSingleParticlePhysicsProxy * &)>::operator()(Chaos::FSingleParticlePhysicsProxy * &) Line 470 C++
UnrealEditor-Engine.dll!FPhysInterface_Chaos::ExecuteWrite(Chaos::FSingleParticlePhysicsProxy * & InActorReference, TFunctionRef<void __cdecl(Chaos::FSingleParticlePhysicsProxy * &)> InCallable) Line 580 C++
UnrealEditor-Engine.dll!FBodyInstance::UpdateOneWayInteraction() Line 3629 C++
UnrealEditor-Engine.dll!FBodyInstance::InitDynamicProperties_AssumesLocked() Line 4425 C++
UnrealEditor-Engine.dll!TInitBodiesHelperBase<TSizedInlineAllocator<1,32,TSizedDefaultAllocator<32>>>::InitBodies::__l12::<lambda_1>::operator()() Line 1637 C++
[Inline Frame] UnrealEditor-Engine.dll!UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::FFunctionRefStoragePolicy,void __cdecl(void)>::operator()() Line 470 C++
UnrealEditor-Engine.dll!FPhysInterface_Chaos::ExecuteWrite(FPhysScene_Chaos * InScene, TFunctionRef<void __cdecl(void)> InCallable) Line 618 C++
UnrealEditor-Engine.dll!TInitBodiesHelperBase<TSizedInlineAllocator<1,32,TSizedDefaultAllocator<32>>>::InitBodies() Line 1553 C++
UnrealEditor-Engine.dll!FBodyInstance::InitBody(UBodySetup * Setup, const UE::Math::TTransform<double> & Transform, UPrimitiveComponent * PrimComp, UObject * InSourceObject, FPhysScene_Chaos * InRBScene, const FInitBodySpawnParams & SpawnParams) Line 1713 C++
UnrealEditor-Engine.dll!FBodyInstance::InitBody(UBodySetup * Setup, const UE::Math::TTransform<double> & Transform, UPrimitiveComponent * PrimComp, FPhysScene_Chaos * InRBScene, const FInitBodySpawnParams & SpawnParams) Line 1680 C++
[Inline Frame] UnrealEditor-Engine.dll!FBodyInstance::InitBody(UBodySetup * InRBScene, const UE::Math::TTransform<double> &) Line 697 C++
UnrealEditor-Engine.dll!UPrimitiveComponent::OnCreatePhysicsState() Line 899 C++
UnrealEditor-Engine.dll!UStaticMeshComponent::OnCreatePhysicsState() Line 939 C++
UnrealEditor-Engine.dll!UActorComponent::CreatePhysicsState(bool bAllowDeferral) Line 2010 C++
UnrealEditor-Engine.dll!UActorComponent::ExecuteRegisterEvents(FRegisterComponentContext * Context) Line 2096 C++
UnrealEditor-Engine.dll!UActorComponent::RegisterComponentWithWorld(UWorld * InWorld, FRegisterComponentContext * Context) Line 1635 C++
UnrealEditor-Engine.dll!AActor::IncrementalRegisterComponents(int NumComponentsToRegister, FRegisterComponentContext * Context) Line 5814 C++
UnrealEditor-Engine.dll!ULevel::IncrementalRegisterComponents(FRegisterComponentContext & Context) Line 1928 C++
UnrealEditor-Engine.dll!ULevel::IncrementalUpdateComponents(int NumComponentsToUpdate, bool bRerunConstructionScripts, FRegisterComponentContext * InContext) Line 1790 C++
UnrealEditor-Engine.dll!UWorld::AddToWorld(ULevel * Level, const UE::Math::TTransform<double> & LevelTransform, bool bConsiderTimeLimit, FNetLevelVisibilityTransactionId TransactionId, ULevelStreaming * InOwningLevelStreaming) Line 3401 C++
UnrealEditor-Engine.dll!ULevelStreaming::UpdateStreamingState(bool & bOutUpdateAgain, bool & bOutRedetermineTarget) Line 1048 C++
[Inline Frame] UnrealEditor-Engine.dll!FStreamingLevelPrivateAccessor::UpdateStreamingState(ULevelStreaming *) Line 794 C++
UnrealEditor-Engine.dll!UWorld::UpdateLevelStreaming() Line 4493 C++
UnrealEditor-Engine.dll!UWorld::BlockTillLevelStreamingCompleted() Line 4295 C++
UnrealEditor-Engine.dll!UEngine::BlockTillLevelStreamingCompleted(UWorld * InWorld) Line 16156 C++
UnrealEditor-Engine.dll!UGameInstance::StartPlayInEditorGameInstance(ULocalPlayer * LocalPlayer, const FGameInstancePIEParameters & Params) Line 542 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::CreateInnerProcessPIEGameInstance(FRequestPlaySessionParams & InParams, const FGameInstancePIEParameters & InPIEParameters, int InPIEInstanceIndex) Line 3153 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::OnLoginPIEComplete_Deferred(int LocalUserNum, bool bWasSuccessful, FString ErrorString, FPieLoginStruct DataStruct) Line 1599 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::CreateNewPlayInEditorInstance(FRequestPlaySessionParams & InRequestParams, const bool bInDedicatedInstance, const EPlayNetMode InNetMode) Line 1862 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::StartPlayInEditorSession(FRequestPlaySessionParams & InRequestParams) Line 2884 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::StartQueuedPlaySessionRequestImpl() Line 1176 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::StartQueuedPlaySessionRequest() Line 1077 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 2029 C++
UnrealEditor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 550 C++
UnrealEditor.exe!FEngineLoop::Tick() Line 5874 C++
[Inline Frame] UnrealEditor.exe!EngineTick() Line 69 C++
UnrealEditor.exe!GuardedMain(const wchar_t * CmdLine) Line 196 C++
UnrealEditor.exe!LaunchWindowsStartup(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow, const wchar_t * CmdLine) Line 266 C++
UnrealEditor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * pCmdLine, int nCmdShow) Line 317 C++
[External Code]

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-231209 in the post.

0
Login to Vote

Unresolved
ComponentUE - Simulation - Physics
Affects Versions5.65.4.4
Target Fix5.6
CreatedNov 21, 2024
UpdatedNov 26, 2024
View Jira Issue