OutTM.isValid() ensure is failing in BodySetup.cpp when rotating a component

I am rotating a wheel with AddRelativeRotation and getting the following error:

[2017.08.10-16.41.52:620][114]LogOutputDevice: Error: Ensure condition failed: OutTM.isValid() [File:/Users/build/Build/++UE4+Release-4.17+Compile/Sync/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodySetup.cpp] [Line: 845]
[2017.08.10-16.41.52:620][114]LogStats: FDebug::EnsureFailed -  0.000 s

I am currently building the engine from source to try and get the exact line in the engine source instead of falling into the assembly of some .dll. Please correct me if I can this is unnecessary. I have added editor debug symbols from the epic games launcher but that did not seem to help. I’m developing on OSX in Xcode.

Here is the full backtrace, it appears that the welded body is being unwelded, transformed and rewelded to the root but something goes wrong where the transform is invalid:

* thread #5, stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
    frame #0: 0x0000000100019dc7 UE4Editor-Mac-Debug`FMacPlatformMisc::DebugBreak() at MacPlatformMisc.h:58
    frame #1: 0x000000010002eb0f UE4Editor-Mac-Debug`FMacPlatformMisc::DebugBreakAndPromptForRemoteReturningFalse(bIsEnsure=true) at MacPlatformMisc.h:79
    frame #2: 0x000000010001d2c0 UE4Editor-Mac-Debug`UE4Asserts_Private::OptionallyDebugBreakAndPromptForRemoteReturningFalse(bBreak=true, bIsEnsure=true) at AssertionMacros.h:177
    frame #3: 0x00000001034beb84 UE4Editor-Engine-Mac-Debug.dylib`bool FBodySetupShapeIterator::PopulatePhysXGeometryAndTransform<FKConvexElem, physx::PxConvexMeshGeometry>(this=0x0000700012a66008, ConvexElem=0x0000000190e3ce00, OutGeometry=0x0000700012a65e50, OutTM=0x0000700012a65e30) const at BodySetup.cpp:541
    frame #4: 0x00000001034c044f UE4Editor-Engine-Mac-Debug.dylib`void FBodySetupShapeIterator::ForEachShape<FKConvexElem, physx::PxConvexMeshGeometry>(this=0x0000700012a66008, Elements=size=1, VisitorFunc=TFunctionRef<void (const FKConvexElem &, const physx::PxConvexMeshGeometry &, const physx::PxTransform &, float)> @ 0x0000700012a65f80)>) const at BodySetup.cpp:413
    frame #5: 0x00000001034bf7f6 UE4Editor-Engine-Mac-Debug.dylib`UBodySetup::AddShapesToRigidActor_AssumesLocked(this=0x0000000190096000, OwningInstance=0x0000000167048540, PDestActor=0x00000001b34f9900, SceneType=PST_Sync, Scale3D=0x0000000167048544, SimpleMaterial=0x00000001b3411600, ComplexMaterials=size=1, ShapeData=0x0000700012a66410, RelativeTM=0x0000700012a66630, NewShapes=size=0, bShapeSharing=false) at BodySetup.cpp:697
    frame #6: 0x000000010349f681 UE4Editor-Engine-Mac-Debug.dylib`FBodyInstance::Weld(this=0x0000700012a665d8)::$_11::operator()() const at BodyInstance.cpp:2278
    frame #7: 0x000000010349f3fd UE4Editor-Engine-Mac-Debug.dylib`decltype(Func=0x0000700012a665d8)::$_11 const&>(fp)(Forward<>(fp0))) Invoke<FBodyInstance::Weld(FBodyInstance*, FTransform const&)::$_11 const&>(FBodyInstance::Weld(FBodyInstance*, FTransform const&)::$_11 const&&&) at Invoke.h:45
    frame #8: 0x000000010349f3b5 UE4Editor-Engine-Mac-Debug.dylib`UE4Function_Private::TFunctionRefCaller<FBodyInstance::Weld(FBodyInstance*, FTransform const&)::$_11 const, void ()>::Call(Obj=0x0000700012a665d8) at Function.h:244
    frame #9: 0x00000001000485d0 UE4Editor-Mac-Debug`UE4Function_Private::TFunctionRefBase<TFunctionRef<void ()>, void ()>::operator(this=0x0000700012a66600)() const at Function.h:283
    frame #10: 0x000000010347a9a4 UE4Editor-Engine-Mac-Debug.dylib`FBodyInstance::ExecuteOnPhysicsReadWrite(this=0x0000000167048540, Func=TFunctionRef<void ()> @ 0x0000700012a66600)>) const at BodyInstance.cpp:3390
    frame #11: 0x000000010347fe6f UE4Editor-Engine-Mac-Debug.dylib`FBodyInstance::Weld(this=0x0000000167048540, TheirBody=0x0000000190070540, TheirTM=0x0000000190070380) at BodyInstance.cpp:2261
    frame #12: 0x0000000103482a29 UE4Editor-Engine-Mac-Debug.dylib`FBodyInstance::SetWeldedBodyTransform(this=0x0000000167048540, TheirBody=0x0000000190070540, NewTransform=0x0000000190070380) at BodyInstance.cpp:3125
    frame #13: 0x0000000103482479 UE4Editor-Engine-Mac-Debug.dylib`FBodyInstance::SetBodyTransform(this=0x0000000190070540, NewTransform=0x0000000190070380, Teleport=None) at BodyInstance.cpp:3103
  * frame #14: 0x0000000102b87f92 UE4Editor-Engine-Mac-Debug.dylib`UPrimitiveComponent::SendPhysicsTransform(this=0x0000000190070100, Teleport=None) at PrimitiveComponent.cpp:690
    frame #15: 0x0000000102b46765 UE4Editor-Engine-Mac-Debug.dylib`UPrimitiveComponent::OnUpdateTransform(this=0x0000000190070100, UpdateTransformFlags=None, Teleport=None) at PrimitiveComponent.cpp:683
    frame #16: 0x0000000102bef6e5 UE4Editor-Engine-Mac-Debug.dylib`USceneComponent::PropagateTransformUpdate(this=0x0000000190070100, bTransformChanged=true, UpdateTransformFlags=None, Teleport=None) at SceneComponent.cpp:650
    frame #17: 0x0000000102bef415 UE4Editor-Engine-Mac-Debug.dylib`USceneComponent::UpdateComponentToWorldWithParent(this=0x0000000190070100, Parent=0x0000000167048100, SocketName=name="Turret", UpdateTransformFlags=None, RelativeRotationQuat=0x0000700012a66c10, Teleport=None) at SceneComponent.cpp:552
    frame #18: 0x0000000102bfcb52 UE4Editor-Engine-Mac-Debug.dylib`USceneComponent::InternalSetWorldLocationAndRotation(this=0x0000000190070100, NewLocation=(X = 0, Y = 0, Z = 0), RotationQuat=0x0000700012a678f0, bNoPhysics=false, Teleport=None) at SceneComponent.cpp:2578
    frame #19: 0x0000000102b8c087 UE4Editor-Engine-Mac-Debug.dylib`UPrimitiveComponent::MoveComponentImpl(this=0x0000000190070100, Delta=0x0000700012a67910, NewRotationQuat=0x0000700012a678f0, bSweep=false, OutHit=0x0000000000000000, MoveFlags=MOVECOMP_NoFlags, Teleport=None) at PrimitiveComponent.cpp:1761
    frame #20: 0x00000001025d74a0 UE4Editor-Engine-Mac-Debug.dylib`USceneComponent::MoveComponent(this=0x0000000190070100, Delta=0x0000700012a67910, NewRotation=0x0000700012a678f0, bSweep=false, Hit=0x0000000000000000, MoveFlags=MOVECOMP_NoFlags, Teleport=None) at SceneComponent.h:1294
    frame #21: 0x0000000102bf62f6 UE4Editor-Engine-Mac-Debug.dylib`USceneComponent::SetRelativeLocationAndRotation(this=0x0000000190070100, NewLocation=(X = 0, Y = 0, Z = 0), NewRotation=0x0000700012a67a20, bSweep=false, OutSweepHitResult=0x0000000000000000, Teleport=None) at SceneComponent.cpp:1153
    frame #22: 0x0000000102bf6671 UE4Editor-Engine-Mac-Debug.dylib`USceneComponent::SetRelativeRotation(this=0x0000000190070100, NewRotation=(Pitch = 0, Yaw = 51.5422859, Roll = 0), bSweep=false, OutSweepHitResult=0x0000000000000000, Teleport=None) at SceneComponent.cpp:1178
    frame #23: 0x0000000196f25155 UE4Editor-Battle_Tank-Mac-Debug.dylib`UTankTurret::Rotate(this=0x0000000190070100, RelativeSpeed=0.0764350891) at TankTurret.cpp:12
    frame #24: 0x0000000196f17f42 UE4Editor-Battle_Tank-Mac-Debug.dylib`UTankAimingComponent::MoveBarrelTowards(this=0x00000001b21c2c00) at TankAimingComponent.cpp:79
    frame #25: 0x0000000196f17bfb UE4Editor-Battle_Tank-Mac-Debug.dylib`UTankAimingComponent::AimAt(this=0x00000001b21c2c00, HitLocation=0x0000700012a67d08) at TankAimingComponent.cpp:61
    frame #26: 0x0000000196f1dcbe UE4Editor-Battle_Tank-Mac-Debug.dylib`ATankPlayerController::AimTowardsCrosshair(this=0x0000000196d6d600) at TankPlayerController.cpp:81
    frame #27: 0x0000000196f1dc53 UE4Editor-Battle_Tank-Mac-Debug.dylib`ATankPlayerController::Tick(this=0x0000000196d6d600, deltatime=0.0770248994) at TankPlayerController.cpp:56
    frame #28: 0x0000000103561f46 UE4Editor-Engine-Mac-Debug.dylib`APlayerController::TickActor(this=0x0000000196d6d600, DeltaSeconds=0.0770248994, TickType=LEVELTICK_All, ThisTickFunction=0x0000000196d6d638) at PlayerController.cpp:4191
    frame #29: 0x00000001025bd3d0 UE4Editor-Engine-Mac-Debug.dylib`FActorTickFunction::ExecuteTick(this=0x0000000196d6d638, DeltaTime=0.0770248994, TickType=LEVELTICK_All, CurrentThread=GameThread, MyCompletionGraphEvent=0x000000019c0ecf08) at Actor.cpp:126
    frame #30: 0x000000010398b1a0 UE4Editor-Engine-Mac-Debug.dylib`FTickFunctionTask::DoTask(this=0x000000019c0eced8, CurrentThread=GameThread, MyCompletionGraphEvent=0x000000019c0ecf08) at TickTaskManager.cpp:267
    frame #31: 0x000000010398ac57 UE4Editor-Engine-Mac-Debug.dylib`TGraphTask<FTickFunctionTask>::ExecuteTask(this=0x000000019c0ecec0, NewTasks=size=0, CurrentThread=GameThread) at TaskGraphInterfaces.h:883
    frame #32: 0x0000000100248d22 UE4Editor-Core-Mac-Debug.dylib`FBaseGraphTask::Execute(this=0x000000019c0ecec0, NewTasks=size=0, CurrentThread=GameThread) at TaskGraphInterfaces.h:488
    frame #33: 0x000000010024b927 UE4Editor-Core-Mac-Debug.dylib`FNamedTaskThread::ProcessTasksNamedThread(this=0x0000000137e9e000, QueueIndex=0, bAllowStall=true) at TaskGraph.cpp:952
    frame #34: 0x000000010024a9b8 UE4Editor-Core-Mac-Debug.dylib`FNamedTaskThread::ProcessTasksUntilQuit(this=0x0000000137e9e000, QueueIndex=0) at TaskGraph.cpp:699
    frame #35: 0x00000001002473df UE4Editor-Core-Mac-Debug.dylib`FTaskGraphImplementation::ProcessThreadUntilRequestReturn(this=0x0000000137cdf900, CurrentThread=GameThread) at TaskGraph.cpp:1758
    frame #36: 0x0000000100247728 UE4Editor-Core-Mac-Debug.dylib`FTaskGraphImplementation::WaitUntilTasksComplete(this=0x0000000137cdf900, Tasks=size=9, CurrentThreadIfKnown=GameThread) at TaskGraph.cpp:1807
    frame #37: 0x00000001039864ba UE4Editor-Engine-Mac-Debug.dylib`FTickTaskSequencer::ReleaseTickGroup(this=0x000000010537d8b8, WorldTickGroup=TG_PrePhysics, bBlockTillComplete=true) at TickTaskManager.cpp:537
    frame #38: 0x000000010398022a UE4Editor-Engine-Mac-Debug.dylib`FTickTaskManager::RunTickGroup(this=0x000000010537d6e0, Group=TG_PrePhysics, bBlockTillComplete=true) at TickTaskManager.cpp:1449
    frame #39: 0x000000010308c9d5 UE4Editor-Engine-Mac-Debug.dylib`UWorld::RunTickGroup(this=0x000000019c4a2080, Group=TG_PrePhysics, bBlockTillComplete=true) at LevelTick.cpp:757
    frame #40: 0x0000000103090707 UE4Editor-Engine-Mac-Debug.dylib`UWorld::Tick(this=0x000000019c4a2080, TickType=LEVELTICK_All, DeltaSeconds=0.0770248994) at LevelTick.cpp:1373
    frame #41: 0x000000010c755159 UE4Editor-UnrealEd-Mac-Debug.dylib`UEditorEngine::Tick(this=0x00000001878570c0, DeltaSeconds=0.0770248994, bIdleMode=false) at EditorEngine.cpp:1632
    frame #42: 0x000000010d1decb9 UE4Editor-UnrealEd-Mac-Debug.dylib`UUnrealEdEngine::Tick(this=0x00000001878570c0, DeltaSeconds=0.0770248994, bIdleMode=false) at UnrealEdEngine.cpp:383
    frame #43: 0x0000000100017d2f UE4Editor-Mac-Debug`FEngineLoop::Tick(this=0x0000000100065e38) at LaunchEngineLoop.cpp:3113
    frame #44: 0x0000000100016e40 UE4Editor-Mac-Debug`EngineTick() at Launch.cpp:62
    frame #45: 0x00000001000196a7 UE4Editor-Mac-Debug`GuardedMain(CmdLine=L" \"/Users/Alec/Projects/unreal/Battle_Tank 4.16 - 2/Battle_Tank.uproject\" -RunConfig= -NSDocumentRevisionsDebugMode YES") at Launch.cpp:168
    frame #46: 0x0000000100029c7b UE4Editor-Mac-Debug`::-[UE4AppDelegate runGameThread:](self=0x0000618000020fe0, _cmd="runGameThread:", Arg=0x0000000000000000) at LaunchMac.cpp:201
    frame #47: 0x00000001003cd80d UE4Editor-Core-Mac-Debug.dylib`::-[FCocoaGameThread main](self=0x00006180000655c0, _cmd="main") at CocoaThread.cpp:372
    frame #48: 0x00007fffad2f9b3d Foundation`__NSThread__start__ + 1243
    frame #49: 0x0000000110ab7b90 libsystem_pthread.dylib`_pthread_body + 180
    frame #50: 0x0000000110ab7adc libsystem_pthread.dylib`_pthread_start + 286
    frame #51: 0x0000000110ab72c5 libsystem_pthread.dylib`thread_start + 13

Hi , thanks for responding. I’m using AddRelativeRotation to rotate a wheel that is attached to a vehicle body that is simulating physics. I originally tried rotating the body with the defaults set for bSweep, OutSweepResult, and Teleport but I have now also tried it with bSweep set to true and Teleport set to ETeleportType::None. Are there any issues with those uses?

@ C
I checked the quaternion in PxTransform OutTM and its norm is .9999. Do you know if there are any steps taken that ensure that the quaternion will be of unit norm at this point in the code? Perhaps the code should be changed to OutTM.isSane() but that may cause problems elsewhere.

I checked the PhysX source for PxQuat::isUnit and it looks like the tolerance is set to 1e-4 meaning that the quaternion in my OutTM is right on the cusp. Is there anyway to confirm that a quaternion with norm .9999 should be an error?

Hi kosika,

Would you be able to provide an example of how you are using AddRelativeRotation to rotate a wheel? Do you see the same results if you try to rotate a wheel on one of the default vehicles in one of the vehicle templates?

Hi kosika,

Sorry for not getting back to you sooner. Are you still running into this same problem in 4.18? If so, are you able to reproduce it with the vehicle in the Advanced Vehicle template and can provide a small sample project that demonstrates the behavior that you are seeing? I have not been able to reproduce the issue myself.

Hi kosika,

We have not heard back from you for a while. Do you still need help with this issue? I will be marking this post as resolved for internal tracking purposes, but please feel free to add a comment and re-open the post if you need any additional assistance.