I just figured out that when UPrimitiveComponent::CreatePhysicsState() is called, it calculates the mass, but only in editor, also when i build for non-editor it is faster (standalone) this is not because the editor is eating up resources, because time is measured in code. Why is the mass only calculated in editor?
It seems as if you are referring to this block of code, in
UPrimitiveComponent. Specifically the line which calls
this as a parameter.
This entire block of code is only run in editor builds (note the
WITH_EDITOR guards), either because it is slow or because it is relying on assumptions that can be made of a primitive component placed in the editor but not at runtime (such as, perhaps when placing the component a slow operation was run to generate some data the code depends on, but that slow operation is not automatically run if the component is created at runtime).
In general, Unreal does not do cooking of complex physics collision data at runtime, except for a few things (such as for road splines at the like), because it is expensive.
CalculateMass function just calculates the mass. It doesn't store it anywhere, so just because this code is not executed here, in
OnCreatePhysicsState, does not mean it does not happen elsewhere.