Added initial draft of Universal Object Locator mechanism
Universal Object Locators (UOLs) are designed to support referencing objects that don't fit neatly into a basic outer->inner path representation. Examples might include transient actors, dynamically created objects, or objects that need to be referenced by an external ID or using external lookup logic. Specifically this might be an object spawned by Sequencer, a transient object on a USD stage, or a gameplay-specific object created by a game system.
A UOL comprises zero or more 'fragments': atomic pieces of data and logic that defines how to lookup or load an object based on a context. Fragment types are globally registered as part of module initialization.
UOLs are hashable, and support string conversion that conforms to RFC3986 so they can be used as URIs (though that is not a current use-case). In order to support this type of string conversion, the 'path' part of of a UOL defines the fragment types, and the query string is used to encode the payload data for each fragment. This allows us to support a more diverse set of characters as part of payload strings (ie, / : and .) which are otherwise unsupported as part of the path.
An example UOL to an anim instance might look like: uobj://actor/subobj/animinst?payload0=/Path/To/Package.LevelName:PathToActor&payload1=ComponentName
#rb david.bromberg, ludovic.chabant, Max.Chen
[CL 29714989 by andrew rodham in ue5-main branch]
2023-11-14 11:31:58 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
# pragma once
# include "Modules/ModuleInterface.h"
# include "UniversalObjectLocatorFwd.h"
# include "UniversalObjectLocatorFragmentTypeHandle.h"
# include "UniversalObjectLocatorFragmentType.h"
# include "UniversalObjectLocatorStringParams.h"
# include "UniversalObjectLocatorInitializeResult.h"
# include "UniversalObjectLocatorFragment.h"
Sequencer: Major integration of Universal Object Locators into Sequencer. This includes:
* Adding some first pass UI for editing the Universal Object Locators that are used to bind objects to tracks in Sequencer. This is currently in the form of:
* An 'Add Empty Binding' item in the + Actor to Sequencer menu
* A 'Binding Properties' sub-menu in the object binding track properties that allows you to modify the array of UOL's that bind objects to the track. This allows you to specifically select certain UOL types and then fill in the data that makes up that UOL. This is necessary for example for the FortAIPlayerPawn binding we plan on adding for UEFN.
* Major refactor of MovieScene binding code to more seamlessly allow for the use of the Locator resolution, especially in the case of supporting locators that spawn actors, either in the case of editor preview actors or future runtime 'spawnables'. This was necessary to consolidate the cases where locator resolve params were being created to as few places as possible for simplicity.
* Add the concept of 'default' editor and runtime flags to locators to make it easier for Sequencer to know how to interact with bindings of different types. These flags are then stored with the binding in Sequencer and editable by users as necessary. Sequencer treats 'load'/'unload' in this case similar to 'spawn'/'despawn' and generally speaking resolving a locator with editor flags of 'load' will expect the locator to spawn an actor for preview, while resolving a locator with runtime flags of 'load' will expect the locator to create a 'spawnable' character.
* To manage lifetime of these preview/spawnable characters, created an interface for a 'LocatorSpawnedCache' which the locators interact with when creating or destroying an actor. This allows the resolver of locators to differentiate between cases where they expect multiple resolves of the same locator to create duplicate actors vs. resolve to the same actor and track the lifetimes of these spawned actors.
* Sequencer implements the above cache within its own object cache in evaluation state.
* Expand the role of the previously created Binding Lifetime track to trigger loading/unloading via locators in the cache. The Binding Lifetime track will now automatically be added to a binding if its locator type contains 'Load' as a default editor or runtime flag.
* Some other editor updates to support the above.
Future issues to be resolved:
* We want to more easily expose the editing of binding properties when necessary rather than having it buried in a sub-menu. Ideas for this include some kind of UI on the track itself, for example a combo box with binding types on it, as well as potentially the properties menu appearing on hovering over the possessable icon on the object binding track. We also want to expose properties based on selection, for example object binding properties, track properties, and section properties, in another external window.
* We want to eventually replace the 'Actor to Sequencer' and 'Assign Actor' menu with this once the UX is better.
The above was all tested with a Fortnite NPC Locator type which will be added in a separate changelist.
[REVIEW] [at]ue-sequencer
#jira UE-199299
[CL 30596833 by david bromberg in ue5-main branch]
2024-01-12 12:41:00 -05:00
# include "UniversalObjectLocatorFragmentType.h"
Added initial draft of Universal Object Locator mechanism
Universal Object Locators (UOLs) are designed to support referencing objects that don't fit neatly into a basic outer->inner path representation. Examples might include transient actors, dynamically created objects, or objects that need to be referenced by an external ID or using external lookup logic. Specifically this might be an object spawned by Sequencer, a transient object on a USD stage, or a gameplay-specific object created by a game system.
A UOL comprises zero or more 'fragments': atomic pieces of data and logic that defines how to lookup or load an object based on a context. Fragment types are globally registered as part of module initialization.
UOLs are hashable, and support string conversion that conforms to RFC3986 so they can be used as URIs (though that is not a current use-case). In order to support this type of string conversion, the 'path' part of of a UOL defines the fragment types, and the query string is used to encode the payload data for each fragment. This allows us to support a more diverse set of characters as part of payload strings (ie, / : and .) which are otherwise unsupported as part of the path.
An example UOL to an anim instance might look like: uobj://actor/subobj/animinst?payload0=/Path/To/Package.LevelName:PathToActor&payload1=ComponentName
#rb david.bromberg, ludovic.chabant, Max.Chen
[CL 29714989 by andrew rodham in ue5-main branch]
2023-11-14 11:31:58 -05:00
# include "Concepts/GetTypeHashable.h"
# include "Templates/UnrealTypeTraits.h"
# include "Misc/GeneratedTypeName.h"
struct FSubObjectLocator ;
namespace UE : : UniversalObjectLocator
{
struct FFragmentTypeParameters
{
FFragmentTypeParameters ( FName InFragmentTypeID , FText InDisplayText )
: DisplayText ( InDisplayText )
, FragmentTypeID ( InFragmentTypeID )
2024-05-16 12:52:19 -04:00
, Flags ( EFragmentTypeFlags : : None )
Added initial draft of Universal Object Locator mechanism
Universal Object Locators (UOLs) are designed to support referencing objects that don't fit neatly into a basic outer->inner path representation. Examples might include transient actors, dynamically created objects, or objects that need to be referenced by an external ID or using external lookup logic. Specifically this might be an object spawned by Sequencer, a transient object on a USD stage, or a gameplay-specific object created by a game system.
A UOL comprises zero or more 'fragments': atomic pieces of data and logic that defines how to lookup or load an object based on a context. Fragment types are globally registered as part of module initialization.
UOLs are hashable, and support string conversion that conforms to RFC3986 so they can be used as URIs (though that is not a current use-case). In order to support this type of string conversion, the 'path' part of of a UOL defines the fragment types, and the query string is used to encode the payload data for each fragment. This allows us to support a more diverse set of characters as part of payload strings (ie, / : and .) which are otherwise unsupported as part of the path.
An example UOL to an anim instance might look like: uobj://actor/subobj/animinst?payload0=/Path/To/Package.LevelName:PathToActor&payload1=ComponentName
#rb david.bromberg, ludovic.chabant, Max.Chen
[CL 29714989 by andrew rodham in ue5-main branch]
2023-11-14 11:31:58 -05:00
{
}
FText DisplayText ;
FName FragmentTypeID ;
FName PrimaryEditorType ;
2024-01-24 16:04:51 -05:00
EFragmentTypeFlags Flags ;
Added initial draft of Universal Object Locator mechanism
Universal Object Locators (UOLs) are designed to support referencing objects that don't fit neatly into a basic outer->inner path representation. Examples might include transient actors, dynamically created objects, or objects that need to be referenced by an external ID or using external lookup logic. Specifically this might be an object spawned by Sequencer, a transient object on a USD stage, or a gameplay-specific object created by a game system.
A UOL comprises zero or more 'fragments': atomic pieces of data and logic that defines how to lookup or load an object based on a context. Fragment types are globally registered as part of module initialization.
UOLs are hashable, and support string conversion that conforms to RFC3986 so they can be used as URIs (though that is not a current use-case). In order to support this type of string conversion, the 'path' part of of a UOL defines the fragment types, and the query string is used to encode the payload data for each fragment. This allows us to support a more diverse set of characters as part of payload strings (ie, / : and .) which are otherwise unsupported as part of the path.
An example UOL to an anim instance might look like: uobj://actor/subobj/animinst?payload0=/Path/To/Package.LevelName:PathToActor&payload1=ComponentName
#rb david.bromberg, ludovic.chabant, Max.Chen
[CL 29714989 by andrew rodham in ue5-main branch]
2023-11-14 11:31:58 -05:00
} ;
class IUniversalObjectLocatorModule
: public IModuleInterface
{
public :
/**
* Register a new fragment type that can be used to locate objects from a Universal Object Locator
*
* Fragment types must be serializable USTRUCTS , must be equality comparable , and must be GetTypeHashable .
* Additionally , the following member functions must be defined :
*
* // Initialize the fragment to point at an object within a context
* FInitializeResult Initialize ( const FInitializeParams & InParams ) const ;
* // Resolve the fragment to the resulting object, potentially loading or unloading it
* FResolveResult Resolve ( const FResolveParams & Params ) const ;
*
* // Convert this fragment to its string representation
* void ToString ( FStringBuilderBase & OutStringBuilder ) const ;
* // Try and parse this fragment from its string representation
* FParseStringResult TryParseString ( FStringView InString , const FParseStringParams & Params ) const ;
*
* // Compute a priority for this fragment based on an object and context in order to decide which fragment type should be used if multiple can address the same object
* static uint32 ComputePriority ( const UObject * Object , const UObject * Context ) const ;
*/
template < typename PayloadStructType
UE_REQUIRES (
// Payloads must be equality-comparable (we don't use the CEqualityComparable concept here because we need to make sure the ICppStructOps are set up correctly)
( TStructOpsTypeTraits < PayloadStructType > : : WithIdenticalViaEquality | | TStructOpsTypeTraits < PayloadStructType > : : WithIdentical ) & &
// Payloads must be type-hashable
TModels_V < CGetTypeHashable , PayloadStructType >
)
>
Sequencer: Major integration of Universal Object Locators into Sequencer. This includes:
* Adding some first pass UI for editing the Universal Object Locators that are used to bind objects to tracks in Sequencer. This is currently in the form of:
* An 'Add Empty Binding' item in the + Actor to Sequencer menu
* A 'Binding Properties' sub-menu in the object binding track properties that allows you to modify the array of UOL's that bind objects to the track. This allows you to specifically select certain UOL types and then fill in the data that makes up that UOL. This is necessary for example for the FortAIPlayerPawn binding we plan on adding for UEFN.
* Major refactor of MovieScene binding code to more seamlessly allow for the use of the Locator resolution, especially in the case of supporting locators that spawn actors, either in the case of editor preview actors or future runtime 'spawnables'. This was necessary to consolidate the cases where locator resolve params were being created to as few places as possible for simplicity.
* Add the concept of 'default' editor and runtime flags to locators to make it easier for Sequencer to know how to interact with bindings of different types. These flags are then stored with the binding in Sequencer and editable by users as necessary. Sequencer treats 'load'/'unload' in this case similar to 'spawn'/'despawn' and generally speaking resolving a locator with editor flags of 'load' will expect the locator to spawn an actor for preview, while resolving a locator with runtime flags of 'load' will expect the locator to create a 'spawnable' character.
* To manage lifetime of these preview/spawnable characters, created an interface for a 'LocatorSpawnedCache' which the locators interact with when creating or destroying an actor. This allows the resolver of locators to differentiate between cases where they expect multiple resolves of the same locator to create duplicate actors vs. resolve to the same actor and track the lifetimes of these spawned actors.
* Sequencer implements the above cache within its own object cache in evaluation state.
* Expand the role of the previously created Binding Lifetime track to trigger loading/unloading via locators in the cache. The Binding Lifetime track will now automatically be added to a binding if its locator type contains 'Load' as a default editor or runtime flag.
* Some other editor updates to support the above.
Future issues to be resolved:
* We want to more easily expose the editing of binding properties when necessary rather than having it buried in a sub-menu. Ideas for this include some kind of UI on the track itself, for example a combo box with binding types on it, as well as potentially the properties menu appearing on hovering over the possessable icon on the object binding track. We also want to expose properties based on selection, for example object binding properties, track properties, and section properties, in another external window.
* We want to eventually replace the 'Actor to Sequencer' and 'Assign Actor' menu with this once the UX is better.
The above was all tested with a Fortnite NPC Locator type which will be added in a separate changelist.
[REVIEW] [at]ue-sequencer
#jira UE-199299
[CL 30596833 by david bromberg in ue5-main branch]
2024-01-12 12:41:00 -05:00
TFragmentTypeHandle < PayloadStructType > RegisterFragmentType ( FFragmentTypeParameters & FragmentTypeParameters )
Added initial draft of Universal Object Locator mechanism
Universal Object Locators (UOLs) are designed to support referencing objects that don't fit neatly into a basic outer->inner path representation. Examples might include transient actors, dynamically created objects, or objects that need to be referenced by an external ID or using external lookup logic. Specifically this might be an object spawned by Sequencer, a transient object on a USD stage, or a gameplay-specific object created by a game system.
A UOL comprises zero or more 'fragments': atomic pieces of data and logic that defines how to lookup or load an object based on a context. Fragment types are globally registered as part of module initialization.
UOLs are hashable, and support string conversion that conforms to RFC3986 so they can be used as URIs (though that is not a current use-case). In order to support this type of string conversion, the 'path' part of of a UOL defines the fragment types, and the query string is used to encode the payload data for each fragment. This allows us to support a more diverse set of characters as part of payload strings (ie, / : and .) which are otherwise unsupported as part of the path.
An example UOL to an anim instance might look like: uobj://actor/subobj/animinst?payload0=/Path/To/Package.LevelName:PathToActor&payload1=ComponentName
#rb david.bromberg, ludovic.chabant, Max.Chen
[CL 29714989 by andrew rodham in ue5-main branch]
2023-11-14 11:31:58 -05:00
{
checkf ( FragmentTypeParameters . FragmentTypeID ! = NAME_None , TEXT ( " 'None' is not a valid Fragment Type ID for type %s " ) , GetGeneratedTypeName < PayloadStructType > ( ) ) ;
checkf ( ! FAsciiSet : : HasAny ( * FragmentTypeParameters . FragmentTypeID . ToString ( ) , ~ FUniversalObjectLocatorFragment : : ValidFragmentTypeCharacters ) , TEXT ( " Fragment Type ID '%s' contains invalid characters " ) , * FragmentTypeParameters . FragmentTypeID . ToString ( ) ) ;
FFragmentType NewFragmentType ;
NewFragmentType . FragmentTypeID = FragmentTypeParameters . FragmentTypeID ;
NewFragmentType . PrimaryEditorType = FragmentTypeParameters . PrimaryEditorType ;
2024-08-28 10:40:36 -04:00
NewFragmentType . Flags = FragmentTypeParameters . Flags ;
Added initial draft of Universal Object Locator mechanism
Universal Object Locators (UOLs) are designed to support referencing objects that don't fit neatly into a basic outer->inner path representation. Examples might include transient actors, dynamically created objects, or objects that need to be referenced by an external ID or using external lookup logic. Specifically this might be an object spawned by Sequencer, a transient object on a USD stage, or a gameplay-specific object created by a game system.
A UOL comprises zero or more 'fragments': atomic pieces of data and logic that defines how to lookup or load an object based on a context. Fragment types are globally registered as part of module initialization.
UOLs are hashable, and support string conversion that conforms to RFC3986 so they can be used as URIs (though that is not a current use-case). In order to support this type of string conversion, the 'path' part of of a UOL defines the fragment types, and the query string is used to encode the payload data for each fragment. This allows us to support a more diverse set of characters as part of payload strings (ie, / : and .) which are otherwise unsupported as part of the path.
An example UOL to an anim instance might look like: uobj://actor/subobj/animinst?payload0=/Path/To/Package.LevelName:PathToActor&payload1=ComponentName
#rb david.bromberg, ludovic.chabant, Max.Chen
[CL 29714989 by andrew rodham in ue5-main branch]
2023-11-14 11:31:58 -05:00
NewFragmentType . PayloadType = PayloadStructType : : StaticStruct ( ) ;
// Static bindings
NewFragmentType . StaticBindings . Priority = PayloadStructType : : ComputePriority ;
// Member function bindings
NewFragmentType . InstanceBindings . Resolve = [ ] ( const void * Payload , const FResolveParams & Params ) - > FResolveResult
{
return static_cast < const PayloadStructType * > ( Payload ) - > Resolve ( Params ) ;
} ;
NewFragmentType . InstanceBindings . Initialize = [ ] ( void * Payload , const FInitializeParams & InParams ) - > FInitializeResult
{
return static_cast < PayloadStructType * > ( Payload ) - > Initialize ( InParams ) ;
} ;
NewFragmentType . InstanceBindings . ToString = [ ] ( const void * Payload , FStringBuilderBase & OutStringBuilder )
{
return static_cast < const PayloadStructType * > ( Payload ) - > ToString ( OutStringBuilder ) ;
} ;
NewFragmentType . InstanceBindings . TryParseString = [ ] ( void * Payload , FStringView InString , const FParseStringParams & Params ) - > FParseStringResult
{
return static_cast < PayloadStructType * > ( Payload ) - > TryParseString ( InString , Params ) ;
} ;
2024-08-28 10:40:36 -04:00
# if UE_UNIVERSALOBJECTLOCATOR_DEBUG
NewFragmentType . StaticBindings . FragmentDebugInitializer = [ ] ( void * Payload )
{
new ( Payload ) TFragmentPayload < PayloadStructType > ;
} ;
# endif
Added initial draft of Universal Object Locator mechanism
Universal Object Locators (UOLs) are designed to support referencing objects that don't fit neatly into a basic outer->inner path representation. Examples might include transient actors, dynamically created objects, or objects that need to be referenced by an external ID or using external lookup logic. Specifically this might be an object spawned by Sequencer, a transient object on a USD stage, or a gameplay-specific object created by a game system.
A UOL comprises zero or more 'fragments': atomic pieces of data and logic that defines how to lookup or load an object based on a context. Fragment types are globally registered as part of module initialization.
UOLs are hashable, and support string conversion that conforms to RFC3986 so they can be used as URIs (though that is not a current use-case). In order to support this type of string conversion, the 'path' part of of a UOL defines the fragment types, and the query string is used to encode the payload data for each fragment. This allows us to support a more diverse set of characters as part of payload strings (ie, / : and .) which are otherwise unsupported as part of the path.
An example UOL to an anim instance might look like: uobj://actor/subobj/animinst?payload0=/Path/To/Package.LevelName:PathToActor&payload1=ComponentName
#rb david.bromberg, ludovic.chabant, Max.Chen
[CL 29714989 by andrew rodham in ue5-main branch]
2023-11-14 11:31:58 -05:00
return TFragmentTypeHandle < PayloadStructType > ( RegisterFragmentTypeImpl ( NewFragmentType ) ) ;
}
2023-11-22 12:02:21 -05:00
template < typename ParameterType >
TParameterTypeHandle < ParameterType > RegisterParameterType ( )
{
return TParameterTypeHandle < ParameterType > ( RegisterParameterTypeImpl ( ParameterType : : StaticStruct ( ) ) ) ;
}
void UnregisterParameterType ( FParameterTypeHandle InHandle )
{
UnregisterParameterTypeImpl ( InHandle ) ;
}
Added initial draft of Universal Object Locator mechanism
Universal Object Locators (UOLs) are designed to support referencing objects that don't fit neatly into a basic outer->inner path representation. Examples might include transient actors, dynamically created objects, or objects that need to be referenced by an external ID or using external lookup logic. Specifically this might be an object spawned by Sequencer, a transient object on a USD stage, or a gameplay-specific object created by a game system.
A UOL comprises zero or more 'fragments': atomic pieces of data and logic that defines how to lookup or load an object based on a context. Fragment types are globally registered as part of module initialization.
UOLs are hashable, and support string conversion that conforms to RFC3986 so they can be used as URIs (though that is not a current use-case). In order to support this type of string conversion, the 'path' part of of a UOL defines the fragment types, and the query string is used to encode the payload data for each fragment. This allows us to support a more diverse set of characters as part of payload strings (ie, / : and .) which are otherwise unsupported as part of the path.
An example UOL to an anim instance might look like: uobj://actor/subobj/animinst?payload0=/Path/To/Package.LevelName:PathToActor&payload1=ComponentName
#rb david.bromberg, ludovic.chabant, Max.Chen
[CL 29714989 by andrew rodham in ue5-main branch]
2023-11-14 11:31:58 -05:00
template < typename PayloadStructType >
void UnregisterFragmentType ( TFragmentTypeHandle < PayloadStructType > FragmentType )
{
UnregisterFragmentTypeImpl ( FragmentType ) ;
}
private :
virtual FFragmentTypeHandle RegisterFragmentTypeImpl ( const FFragmentType & FragmentType ) = 0 ;
virtual void UnregisterFragmentTypeImpl ( FFragmentTypeHandle FragmentType ) = 0 ;
2023-11-22 12:02:21 -05:00
virtual FParameterTypeHandle RegisterParameterTypeImpl ( UScriptStruct * Struct ) = 0 ;
virtual void UnregisterParameterTypeImpl ( FParameterTypeHandle ParameterType ) = 0 ;
Added initial draft of Universal Object Locator mechanism
Universal Object Locators (UOLs) are designed to support referencing objects that don't fit neatly into a basic outer->inner path representation. Examples might include transient actors, dynamically created objects, or objects that need to be referenced by an external ID or using external lookup logic. Specifically this might be an object spawned by Sequencer, a transient object on a USD stage, or a gameplay-specific object created by a game system.
A UOL comprises zero or more 'fragments': atomic pieces of data and logic that defines how to lookup or load an object based on a context. Fragment types are globally registered as part of module initialization.
UOLs are hashable, and support string conversion that conforms to RFC3986 so they can be used as URIs (though that is not a current use-case). In order to support this type of string conversion, the 'path' part of of a UOL defines the fragment types, and the query string is used to encode the payload data for each fragment. This allows us to support a more diverse set of characters as part of payload strings (ie, / : and .) which are otherwise unsupported as part of the path.
An example UOL to an anim instance might look like: uobj://actor/subobj/animinst?payload0=/Path/To/Package.LevelName:PathToActor&payload1=ComponentName
#rb david.bromberg, ludovic.chabant, Max.Chen
[CL 29714989 by andrew rodham in ue5-main branch]
2023-11-14 11:31:58 -05:00
} ;
} // namespace UE::UniversalObjectLocator