ProfileRedirects

ProfileRedirects

#Overview

name: ProfileRedirects

The value of this variable can be defined or overridden in .ini config files. 15 .ini config files referencing this setting variable.

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ProfileRedirects is to handle the renaming of collision profiles in Unreal Engine 5. It serves as a mechanism to maintain backwards compatibility when profile names are changed, ensuring that references to old profile names are properly redirected to their new counterparts.

This setting variable is primarily used by the collision system within Unreal Engine’s core engine module. Specifically, it is part of the UCollisionProfile class, which is responsible for managing collision profiles and their settings.

The value of ProfileRedirects is set as a UPROPERTY with the ‘globalconfig’ specifier, meaning it can be configured globally through the engine’s configuration files. It is an array of FRedirector structures, each containing an old name and a new name for a collision profile.

ProfileRedirects interacts closely with the ProfileRedirectsMap, which is likely an internal map used for quick lookups of redirects. The AddProfileRedirect function demonstrates how these two data structures are kept in sync.

Developers should be aware that:

  1. This variable is crucial for maintaining compatibility when renaming collision profiles.
  2. Changes to ProfileRedirects can affect how old project data or assets are interpreted.
  3. It’s part of the engine’s configuration system, so changes might need to be made in the appropriate config files.

Best practices when using this variable include:

  1. Always use the AddProfileRedirect function to add new redirects, as it ensures both ProfileRedirects and ProfileRedirectsMap are updated correctly.
  2. Be cautious when manually modifying this variable, as it could break existing projects if not done correctly.
  3. Document any changes to profile names and their corresponding redirects to maintain project clarity.
  4. Consider the performance impact of having a large number of redirects, as they are checked during the LoadProfileConfig process.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:2890, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Engine/Config/BaseEngine.ini:2891, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Engine/Config/BaseEngine.ini:2892, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Engine/Config/BaseEngine.ini:2893, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Engine/Config/BaseEngine.ini:2894, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:214, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:215, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:216, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:217, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:218, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:219, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:220, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:221, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:222, section: [/Script/Engine.CollisionProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:223, section: [/Script/Engine.CollisionProfile]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/CollisionProfile.h:177

Scope (from outer to inner):

file
class        class UCollisionProfile : public UDeveloperSettings

Source code excerpt:

	/** Used to handle renaming profiles */
	UPROPERTY(globalconfig)
	TArray<FRedirector>					ProfileRedirects;

	/** Used to handle renaming collision channels */
	UPROPERTY(globalconfig)
	TArray<FRedirector>					CollisionChannelRedirects;

public:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Collision/CollisionProfile.cpp:247

Scope (from outer to inner):

file
function     void UCollisionProfile::AddProfileRedirect

Source code excerpt:

		ProfileRedirectsMap.FindOrAdd(OldName) = NewName;

		ProfileRedirects.Empty();

		// now add back to it
		TArray<FString> KeyValues;
		for(auto Iter=ProfileRedirectsMap.CreateConstIterator(); Iter; ++Iter)
		{
			const FName &Key = Iter.Key();
			const FName &Value = Iter.Value();
			ProfileRedirects.Add(FRedirector(Key, Value));
		}
	}
}

void UCollisionProfile::LoadProfileConfig(bool bForceInit)
{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Collision/CollisionProfile.cpp:555

Scope (from outer to inner):

file
function     void UCollisionProfile::LoadProfileConfig

Source code excerpt:


	// handle profile redirect here
	for(auto Iter = ProfileRedirects.CreateConstIterator(); Iter; ++Iter)
	{
		FName OldName = Iter->OldName;
		FName NewName = Iter->NewName;

		// at least we need to have OldName
		if(OldName!= NAME_None && NewName != NAME_None)