Wrong density calculation in UBodySetup::CalculateMass.
The licensee has provided the following analysis and suggested fix:
In UBodySetup::CalculateMass, the following code is present:
// physical material - nothing can weigh less than hydrogen (0.09 kg/m^3)
float DensityKGPerCubicUU = 1.0f;
float RaiseMassToPower = 0.75f;
if (PhysMat)
The idea being to set a sensible lower bound for object density. However, the calculation for `DensityKGPerCubicUU` is incorrect.
As stated in the code, the density of hydrogen is 0.08988g/L, correctly approximated to 0.09 kg / m³. DensityKGPerCubicUU is kg / cm³, and the conversion from m³ to cm³ should be reducing the value in the FMath::Max statement by a factor of 1e-6 (one million). However, it's only being reduced by a thousand in the problematic statement.
While this doesn't seem to affect the actual physics (which use UPrimitiveComponent->GetMass()), it still causes the following problems for us:
The in-editor mass estimate uses CalculateMass and displays an inaccurate mass to our designers
In many cases, we need to get the mass of objects which have physics simulation turned off (it gets turned on later on). This is not possible using the regular GetMass function, we need to use CalculateMass
In some cases, objects get modified during gameplay and we need to access the initial mass. We do this using CalculateMass on the class default object, GetMass isn't possible here.
The suggested fix would be as follows:
// physical material - nothing can weigh less than hydrogen (0.09 kg/m^3)
float DensityKGPerCubicUU = 1.0f;
float RaiseMassToPower = 0.75f;
if (PhysMat)
I've confirmed this behavior reproduces on UE5.5 up to P4 main (CL45755840).
Using the repro project:
Play In Editor and verify the text labels in each block
From Scratch:
Create a custom physical material with a density of 0.05g/cm³ (50kg/m³), and a RaiseMassToPower value of 1.0
Place a 1m³ object in the scene
Assign the created custom material to the cube
Notice the mass when selecting the object in the editor: It will display 90kg instead of 50kg.
Additionally, fetching the mass through UBodySetup's CalculateMass will return 90kg instead of 50kg. UPrimitiveComponent's GetMass will return the correct value of 50kg.
> UnrealEditor-Engine.dll!UBodySetup::CalculateMass(const UPrimitiveComponent * Component) Line 2277 C++
UnrealEditor-Engine.dll!UPrimitiveComponent::OnCreatePhysicsState() Line 908 C++
UnrealEditor-Engine.dll!UStaticMeshComponent::OnCreatePhysicsState() Line 875 C++
UnrealEditor-Engine.dll!UActorComponent::CreatePhysicsState(bool bAllowDeferral) Line 1767 C++
UnrealEditor-Engine.dll!UActorComponent::ExecuteRegisterEvents(FRegisterComponentContext * Context) Line 1824 C++
UnrealEditor-Engine.dll!UActorComponent::RegisterComponentWithWorld(UWorld * InWorld, FRegisterComponentContext * Context) Line 1481 C++
UnrealEditor-Engine.dll!AActor::IncrementalRegisterComponents(int NumComponentsToRegister, FRegisterComponentContext * Context) Line 5560 C++
UnrealEditor-Engine.dll!ULevel::IncrementalRegisterComponents(bool bPreRegisterComponents, int NumComponentsToUpdate, FRegisterComponentContext * Context) Line 1814 C++
UnrealEditor-Engine.dll!ULevel::IncrementalUpdateComponents(int NumComponentsToUpdate, bool bRerunConstructionScripts, FRegisterComponentContext * Context) Line 1733 C++
UnrealEditor-Engine.dll!UWorld::UpdateWorldComponents(bool bRerunConstructionScripts, bool bCurrentLevelOnly, FRegisterComponentContext * Context) Line 2677 C++
UnrealEditor-Engine.dll!UWorld::InitializeActorsForPlay(const FURL & InURL, bool bResetTime, FRegisterComponentContext * Context) Line 5255 C++
UnrealEditor-Engine.dll!UGameInstance::StartPlayInEditorGameInstance(ULocalPlayer * LocalPlayer, const FGameInstancePIEParameters & Params) Line 529 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 2027 C++
UnrealEditor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 550 C++
UnrealEditor.exe!FEngineLoop::Tick() Line 5877 C++
[Inline Frame] UnrealEditor.exe!EngineTick() Line 69 C++
UnrealEditor.exe!GuardedMain(const wchar_t * CmdLine) Line 188 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]
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-341342 in the post.
0 |
Component | UE - Simulation - Physics |
---|---|
Affects Versions | 5.5, 5.8 |
Created | Sep 29, 2025 |
---|---|
Updated | Oct 1, 2025 |