PhysicalSurfaces
PhysicalSurfaces
#Overview
name: PhysicalSurfaces
The value of this variable can be defined or overridden in .ini config files. 3
.ini config files referencing this setting variable.
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of PhysicalSurfaces is to define and manage physical surface types in the Unreal Engine’s physics system. This setting variable is used to customize the physical properties of different surfaces in the game world, which affects how objects interact with these surfaces during physics simulations.
The PhysicalSurfaces setting variable is primarily used by the physics engine subsystem within Unreal Engine 5. Based on the callsites, it’s also utilized in the Editor’s DetailCustomizations module for user interface representation and configuration.
The value of this variable is set in the UPhysicsSettings class, which is part of the Engine’s core physics configuration. It’s defined as a TArray of FPhysicalSurfaceName structures, allowing for multiple surface types to be defined.
This variable interacts with the PhysicalSurfaceEnum, which is an enumeration of surface types. The PhysicalSurfaces array is used to populate and update this enum with custom surface names and types.
Developers should be aware of several important aspects when using this variable:
- Duplicate surface types are automatically removed, keeping only the last occurrence.
- The first element in the array is always considered the default surface type.
- Changes to this variable require updating the project’s configuration file and reloading the surface types.
Best practices for using this variable include:
- Ensuring unique names for each surface type to avoid unintended overwriting.
- Regularly updating the PhysicalSurfaces array when adding or modifying surface types in the project.
- Using the provided UI in the Editor (via FPhysicsSettingsDetails) to manage these surfaces, which handles the necessary updates and configurations.
- Being mindful of the performance impact when adding numerous surface types, as this can affect physics calculations and memory usage.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:347, section: [/Script/Engine.PhysicsSettings]
- INI Section:
/Script/Engine.PhysicsSettings
- Raw value:
(Type=SurfaceType1,Name="Character")
- Is Array:
True
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:348, section: [/Script/Engine.PhysicsSettings]
- INI Section:
/Script/Engine.PhysicsSettings
- Raw value:
(Type=SurfaceType2,Name="Concrete")
- Is Array:
True
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:349, section: [/Script/Engine.PhysicsSettings]
- INI Section:
/Script/Engine.PhysicsSettings
- Raw value:
(Type=SurfaceType3,Name="Glass")
- Is Array:
True
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/PhysicsSettingsDetails.cpp:119
Scope (from outer to inner):
file
class class FPhysicalSurfaceList : public IDetailCustomNodeBuilder, public TSharedFromThis<FPhysicalSurfaceList>
function void RefreshPhysicalSurfaceList
Source code excerpt:
// make sure no duplicate exists
// if exists, use the last one
for(auto Iter = PhysicsSettings->PhysicalSurfaces.CreateIterator(); Iter; ++Iter)
{
for(auto InnerIter = Iter+1; InnerIter; ++InnerIter)
{
// see if same type
if(Iter->Type == InnerIter->Type)
{
// remove the current one
PhysicsSettings->PhysicalSurfaces.RemoveAt(Iter.GetIndex());
--Iter;
break;
}
}
}
#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/PhysicsSettingsDetails.cpp:152
Scope (from outer to inner):
file
class class FPhysicalSurfaceList : public IDetailCustomNodeBuilder, public TSharedFromThis<FPhysicalSurfaceList>
function void RefreshPhysicalSurfaceList
Source code excerpt:
// we don't create the first one. First one is always default.
for(auto Iter = PhysicsSettings->PhysicalSurfaces.CreateIterator(); Iter; ++Iter)
{
bCreatedItem[Iter->Type] = true;
PhysicalSurfaceList.Add(MakeShareable(new FPhysicalSurfaceListItem(MakeShareable(new FPhysicalSurfaceName(*Iter)))));
}
for(int32 Index = (int32)SurfaceType1; Index < SurfaceType_Max; ++Index)
#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/PhysicsSettingsDetails.cpp:262
Scope (from outer to inner):
file
class class FPhysicalSurfaceList : public IDetailCustomNodeBuilder, public TSharedFromThis<FPhysicalSurfaceList>
function void OnCommitChange
Source code excerpt:
PhysicalSurfacesProperty->NotifyPreChange();
PhysicsSettings->PhysicalSurfaces.Empty();
for(auto Iter = PhysicalSurfaceList.CreateConstIterator()+1; Iter; ++Iter)
{
TSharedPtr<FPhysicalSurfaceListItem> ListItem = *Iter;
if(ListItem->PhysicalSurface->Name != NAME_None)
{
PhysicsSettings->PhysicalSurfaces.Add(FPhysicalSurfaceName(ListItem->PhysicalSurface->Type, ListItem->PhysicalSurface->Name));
}
}
PhysicsSettings->TryUpdateDefaultConfigFile();
PhysicsSettings->LoadSurfaceType();
#Loc: <Workspace>/Engine/Source/Editor/DetailCustomizations/Private/PhysicsSettingsDetails.cpp:305
Scope (from outer to inner):
file
function void FPhysicsSettingsDetails::CustomizeDetails
Source code excerpt:
check(PhysicalSurfaceEnum);
TSharedPtr<IPropertyHandle> PhysicalSurfacesProperty = DetailBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(UPhysicsSettings, PhysicalSurfaces));
TSharedRef<FPhysicalSurfaceList> PhysicalSurfaceListCustomization = MakeShareable(new FPhysicalSurfaceList(PhysicsSettings, PhysicalSurfaceEnum, PhysicalSurfacesProperty) );
PhysicalSurfaceListCustomization->RefreshPhysicalSurfaceList();
const FString PhysicalSurfaceDocLink = TEXT("Shared/Physics");
TSharedPtr<SToolTip> PhysicalSurfaceTooltip = IDocumentation::Get()->CreateToolTip(LOCTEXT("PhysicalSurface", "Edit physical surface."), NULL, PhysicalSurfaceDocLink, TEXT("PhysicalSurface"));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/PhysicsEngine/PhysicsSettings.h:241
Scope (from outer to inner):
file
class class UPhysicsSettings : public UPhysicsSettingsCore
Source code excerpt:
// PhysicalMaterial Surface Types
UPROPERTY(config, EditAnywhere, Category=PhysicalSurfaces)
TArray<FPhysicalSurfaceName> PhysicalSurfaces;
/** If we want to Enable MPB or not globally. This is then overridden by project settings if not enabled. **/
UPROPERTY(config, EditAnywhere, Category = Broadphase)
FBroadphaseSettings DefaultBroadphaseSettings;
/** Minimum velocity delta required on a collinding object for Chaos to send a hit event */
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysicsSettings.cpp:156
Scope (from outer to inner):
file
function void UPhysicsSettings::LoadSurfaceType
Source code excerpt:
}
for(auto Iter=PhysicalSurfaces.CreateConstIterator(); Iter; ++Iter)
{
// @todo only for editor
Enum->SetMetaData(*KeyName, *Iter->Name.ToString(), Iter->Type);
// also need to remove "Hidden"
Enum->RemoveMetaData(*HiddenMeta, Iter->Type);
}