Commit Graph

393 Commits

Author SHA1 Message Date
mikko mononen
eda018b6bd StateTree: Fix accessing state captured event
#rb Yoan.StAmant

[CL 33228442 by mikko mononen in ue5-main branch]
2024-04-25 08:50:27 -04:00
robert millar
113e467dce Backing out to avoid crash opening some assets with instanced structs.
[Backout] - CL33171468
[FYI] logan.buchy
Original CL Desc
-----------------------------------------------------------------
Performance improvement for nested FInstancedStruct in details panel
* Pathological performance issues occurred when viewing/editing USTRUCT objects that nested FInstancedStruct (either directly or in containers).  The PropertyNode system's implementation when handling FInstancedStructs would recurse up the property tree to discover the address of the owning objects and then recurse again up with the starting address.  The root cause of the performance issue is that the recursion would branch on the way up in the following functions: GetInstancesNum, GetMemoryOfInstance, GetOwnerPackages, HasValidStructData (by way of IsValid). On the way up again, branches would occur in GetValueBaseAddress, via duplicate calls in FItemPropertyNode::GetValueBaseAddress to ParentNode->GetValueAddress.
* The problem has been addressed by having the StructPropertyNode handle StructProviders that perform indirection differently than other providers.  When indirection is present, walk up to the parent node of the struct which will be an ItemPropertyNode - the address of this is retrieved and passed back down to the StructProvider.  In the current codebase, the FInstancedStructProvider is the only one that does this type of indirection - it can make the assumption that the passed in address is an FInstancedStruct and thus reinterpret it to get the StructMemory and UStruct* pointers.
* Added an InternalGetReadAddressUncached which public GetReadAddress** functions will call.  This new function will not resolve the Struct in the case of a Struct property indirection unlike GetReadAddressUncached.  It is intended as an internal function only to be called by the public APIs.
* Added a safeguard canary value to FInstancedStruct to debug/catch cases where the wrong raw void* is reinterpreted as an FInstancedStruct.  FInstancedStruct::CastFromVoid helper should be used over a naked reinterpret_cast
* Note that it isn't guarantees all paths where slow recursive behaviour occurs has been addressed in this CL. Specifically, the InstancedStructDetails implementations to get the dispaly values still go through the data enumeration though it should be better now that GetInstancesNum and GetMemoryOfInstance are not recursively calling the Enumerate pathways.  See GetDisplayValueString, GetTooltipText, GetDisplayValueIcon, GenerateStructPicker - this is the primary expense in Slate that is probably causing additional performance loss.

#rb mikko.mononen
#jira UE-207555

[CL 33205050 by robert millar in ue5-main branch]
2024-04-24 13:31:59 -04:00
mikko mononen
a2a77adfe5 StateTrees: Made StateTree override schemas overridable.
[CL 33197151 by mikko mononen in ue5-main branch]
2024-04-24 08:52:09 -04:00
mikko mononen
a583516941 StateTrees: Made FStateTreeNodeBase::PostLoad available in all kinds of builds.
[CL 33197099 by mikko mononen in ue5-main branch]
2024-04-24 08:49:40 -04:00
jacob wang
60131c19b5 [State Tree] StateTreeInstanceData RandomStream variable Initialization Fix/Improvement
- When duplicating the Component, RandomStream was always copied from the one on Component CDO and wasn't constructed with the current time as expected. We now initialize RandomStream at FStateTreeExecutionContext::Start(), where the InstanceData is going to persist till Stop().
- Moved RandomStream variable to FStateTreeExecutionState as it better reflects the window it persists now.
- Fixed non-deterministic default-constructed value of RandomStream variable in UStruct LogError by the above

#jira UE-212551
#rb mikko.mononen

[CL 33174826 by jacob wang in ue5-main branch]
2024-04-23 14:17:24 -04:00
logan buchy
6a08f9cc13 Performance improvement for nested FInstancedStruct in details panel
* Pathological performance issues occurred when viewing/editing USTRUCT objects that nested FInstancedStruct (either directly or in containers).  The PropertyNode system's implementation when handling FInstancedStructs would recurse up the property tree to discover the address of the owning objects and then recurse again up with the starting address.  The root cause of the performance issue is that the recursion would branch on the way up in the following functions: GetInstancesNum, GetMemoryOfInstance, GetOwnerPackages, HasValidStructData (by way of IsValid). On the way up again, branches would occur in GetValueBaseAddress, via duplicate calls in FItemPropertyNode::GetValueBaseAddress to ParentNode->GetValueAddress.
* The problem has been addressed by having the StructPropertyNode handle StructProviders that perform indirection differently than other providers.  When indirection is present, walk up to the parent node of the struct which will be an ItemPropertyNode - the address of this is retrieved and passed back down to the StructProvider.  In the current codebase, the FInstancedStructProvider is the only one that does this type of indirection - it can make the assumption that the passed in address is an FInstancedStruct and thus reinterpret it to get the StructMemory and UStruct* pointers.
* Added an InternalGetReadAddressUncached which public GetReadAddress** functions will call.  This new function will not resolve the Struct in the case of a Struct property indirection unlike GetReadAddressUncached.  It is intended as an internal function only to be called by the public APIs.
* Added a safeguard canary value to FInstancedStruct to debug/catch cases where the wrong raw void* is reinterpreted as an FInstancedStruct.  FInstancedStruct::CastFromVoid helper should be used over a naked reinterpret_cast
* Note that it isn't guarantees all paths where slow recursive behaviour occurs has been addressed in this CL. Specifically, the InstancedStructDetails implementations to get the dispaly values still go through the data enumeration though it should be better now that GetInstancesNum and GetMemoryOfInstance are not recursively calling the Enumerate pathways.  See GetDisplayValueString, GetTooltipText, GetDisplayValueIcon, GenerateStructPicker - this is the primary expense in Slate that is probably causing additional performance loss.

#rb mikko.mononen
#jira UE-207555

[CL 33171500 by logan buchy in ue5-main branch]
2024-04-23 12:26:48 -04:00
mikko mononen
0580cb723a StateTree: Remove debug code left in by mistake.
[CL 33162735 by mikko mononen in ue5-main branch]
2024-04-23 03:28:39 -04:00
logan buchy
e92a21f90b [Backout] - CL33154533
[FYI] logan.buchy
Original CL Desc
-----------------------------------------------------------------
Performance improvement for nested FInstancedStruct in details panel
* Pathological performance issues occurred when viewing/editing USTRUCT objects that nested FInstancedStruct (either directly or in containers).  The PropertyNode system's implementation when handling FInstancedStructs would recurse up the property tree to discover the address of the owning objects and then recurse again up with the starting address.  The root cause of the performance issue is that the recursion would branch on the way up in the following functions: GetInstancesNum, GetMemoryOfInstance, GetOwnerPackages, HasValidStructData (by way of IsValid). On the way up again, branches would occur in GetValueBaseAddress, via duplicate calls in FItemPropertyNode::GetValueBaseAddress to ParentNode->GetValueAddress.
* The problem has been addressed by having the StructPropertyNode handle StructProviders that perform indirection differently than other providers.  When indirection is present, walk up to the parent node of the struct which will be an ItemPropertyNode - the address of this is retrieved and passed back down to the StructProvider.  In the current codebase, the FInstancedStructProvider is the only one that does this type of indirection - it can make the assumption that the passed in address is an FInstancedStruct and thus reinterpret it to get the StructMemory and UStruct* pointers.
* Added an InternalGetReadAddressUncached which public GetReadAddress** functions will call.  This new function will not resolve the Struct in the case of a Struct property indirection unlike GetReadAddressUncached.  It is intended as an internal function only to be called by the public APIs.
* Added a safeguard canary value to FInstancedStruct to debug/catch cases where the wrong raw void* is reinterpreted as an FInstancedStruct.  FInstancedStruct::CastFromVoid helper should be used over a naked reinterpret_cast
* Note that it isn't guarantees all paths where slow recursive behaviour occurs has been addressed in this CL. Specifically, the InstancedStructDetails implementations to get the dispaly values still go through the data enumeration though it should be better now that GetInstancesNum and GetMemoryOfInstance are not recursively calling the Enumerate pathways.  See GetDisplayValueString, GetTooltipText, GetDisplayValueIcon, GenerateStructPicker - this is the primary expense in Slate that is probably causing additional performance loss.

#rb mikko.mononen
#jira UE-207555

[CL 33161624 by logan buchy in ue5-main branch]
2024-04-23 00:48:23 -04:00
logan buchy
f0ce334aa6 Performance improvement for nested FInstancedStruct in details panel
* Pathological performance issues occurred when viewing/editing USTRUCT objects that nested FInstancedStruct (either directly or in containers).  The PropertyNode system's implementation when handling FInstancedStructs would recurse up the property tree to discover the address of the owning objects and then recurse again up with the starting address.  The root cause of the performance issue is that the recursion would branch on the way up in the following functions: GetInstancesNum, GetMemoryOfInstance, GetOwnerPackages, HasValidStructData (by way of IsValid). On the way up again, branches would occur in GetValueBaseAddress, via duplicate calls in FItemPropertyNode::GetValueBaseAddress to ParentNode->GetValueAddress.
* The problem has been addressed by having the StructPropertyNode handle StructProviders that perform indirection differently than other providers.  When indirection is present, walk up to the parent node of the struct which will be an ItemPropertyNode - the address of this is retrieved and passed back down to the StructProvider.  In the current codebase, the FInstancedStructProvider is the only one that does this type of indirection - it can make the assumption that the passed in address is an FInstancedStruct and thus reinterpret it to get the StructMemory and UStruct* pointers.
* Added an InternalGetReadAddressUncached which public GetReadAddress** functions will call.  This new function will not resolve the Struct in the case of a Struct property indirection unlike GetReadAddressUncached.  It is intended as an internal function only to be called by the public APIs.
* Added a safeguard canary value to FInstancedStruct to debug/catch cases where the wrong raw void* is reinterpreted as an FInstancedStruct.  FInstancedStruct::CastFromVoid helper should be used over a naked reinterpret_cast
* Note that it isn't guarantees all paths where slow recursive behaviour occurs has been addressed in this CL. Specifically, the InstancedStructDetails implementations to get the dispaly values still go through the data enumeration though it should be better now that GetInstancesNum and GetMemoryOfInstance are not recursively calling the Enumerate pathways.  See GetDisplayValueString, GetTooltipText, GetDisplayValueIcon, GenerateStructPicker - this is the primary expense in Slate that is probably causing additional performance loss.

#rb mikko.mononen
#jira UE-207555

[CL 33154559 by logan buchy in ue5-main branch]
2024-04-22 18:20:14 -04:00
yoan stamant
9f4886944e [StateTreeDebugger]
allowed to provide verbosity to STATETREE_TRACE_LOG_EVENT and STATETREE_LOG_AND_TRACE so the debugger can add custom icons accordingly.
#jira UE-210505
#rb mikko.mononen

[CL 33140307 by yoan stamant in ue5-main branch]
2024-04-22 11:34:53 -04:00
mikko mononen
533e9f7eb7 StateTrees: Made empty linked asset a valid setup.
[CL 33135868 by mikko mononen in ue5-main branch]
2024-04-22 07:44:19 -04:00
mikko mononen
c78e76aa16 StateTrees: AddOverride replaces now already existing override.
Also, added removing overrides

[CL 33135832 by mikko mononen in ue5-main branch]
2024-04-22 07:42:21 -04:00
mikko mononen
4211bca4fd StateTrees: Made TStateTreeInstanceDataStructRef usable when const.
[CL 33135828 by mikko mononen in ue5-main branch]
2024-04-22 07:42:16 -04:00
mikko mononen
02f386fc88 StateTree: Fix crash when transitioning into linked tree.
[CL 33135580 by mikko mononen in ue5-main branch]
2024-04-22 07:02:22 -04:00
yoan stamant
8f73653f92 [StateTreeDebugger]
- new recording started from the debugger will be selected as the new active analysis
- allow multiple recordings during the same PIE session to reactive existing tracks
- do not apply trace selection if user reselect the current trace to avoid clearing data
#jira UE-207595
#jira UE-207406
#jira UE-207414
#rb mikko.mononen

[CL 33099625 by yoan stamant in ue5-main branch]
2024-04-19 07:51:55 -04:00
mikko mononen
19bc060246 StateTree: Added support for description and icon for BP nodes.
#rb Thomas.Sarkanen, Yoan.StAmant

[CL 33098383 by mikko mononen in ue5-main branch]
2024-04-19 05:44:13 -04:00
guillaume arruda
bdfff2913f Make FStateTreeExecutionContext::AreContextDataViewsValid properly account for optional external data.
#rnx
#rb mikko.mononen

[CL 33033068 by guillaume arruda in ue5-main branch]
2024-04-17 07:49:42 -04:00
mikko mononen
b5f3e45d9b StateTree: Debugger fixes and improvements
- Another fix for stuck timeline
- Removed exec context to emit  EStateTreeUpdatePhase::TickStateTree scope, to allow cleaner logs for parallel STs

[CL 33030889 by mikko mononen in ue5-main branch]
2024-04-17 04:18:52 -04:00
mikko mononen
ef148ecd80 StateTree: StateTree UI spring clean.
- Added icons and icon colors for ST nodes
- Implemented icons for some common ST nodes
- Small update to ST logic icons
- Added icons to the task list in State treeview row, adjusted task list BG color to make icons visible
- Fixed ST editor tabs icons and names (e.g. there were two tabs that had the same label)
- Moved ST node picker to separate class
- Moved category array customization to common helper function
- Added node icons to the ST node picker
- Add node button is not node selector too (simila to Niagara)
- Consolidated the add button style across all lists
- Cleaned up the node customization
  - Moved type selector, debug, and property controls into one menu at right
  - The combined menu can be also summoned using right click
  - Renaming now has to be triggered via the menu
  - Replacing node happens via menu
  - Most of the row was left "clickable" to later use it for selection
  - Improved the visualization and controls for the expression indentation
- Cleaned up state customization
  - Moved parameters to own category (similar to the tree params)
  - Moved event to the enter conditions category
- Cleaned up transition customization
  - Improved the transition display
  - Consolidated add button styles

#jira UE-180608
#rb Juan.Portillo, Mieszko.Zielinski

[CL 33030431 by mikko mononen in ue5-main branch]
2024-04-17 03:01:36 -04:00
jacob wang
c641fa607f [State Tree] Uniformly Random State Selection
- Added a new option for selecint child at uniform random in StateTreeStateSelectionBehavior
- Added RandomStream in StateTreeInstanceData and relevant APIs to get stream and set seed
#rb mikko.mononen

[CL 33006455 by jacob wang in ue5-main branch]
2024-04-16 13:30:24 -04:00
guillaume arruda
4f79176477 Add compile in StateTree PostLoad and compile on PIE begin to state tree so that the trees are never out of sync with the editor state in game
Add validation warning if the state tree is not compiled to prevent uncompiled state tree to be submitted
#rb mikko.mononen

[CL 33001894 by guillaume arruda in ue5-main branch]
2024-04-16 11:14:34 -04:00
guillaume arruda
1c7f123911 Mark FStateTreeReference BlueprintType
#rnx

#rb mikko.mononen

[CL 32998046 by guillaume arruda in ue5-main branch]
2024-04-16 08:28:26 -04:00
mikko mononen
9bcda384a4 StateTree: Fix parameter handling entering to a subtree directly.
- When transitioning to a subtree directly, self host the parameters
- Made transitioning to a subtree directly a warning, may make it an error in future versions

#jira UE-211189
#rb Yoan.StAmant

[CL 32969399 by mikko mononen in ue5-main branch]
2024-04-15 08:23:17 -04:00
mikko mononen
2b93815d0a StateTree: Improved event handling
- Added support for shared event buffer, so that multiple instance data can use the same
- Added API to consume events
- Removed double buffering from events
- Treat TriggerTransitions() as event handler (events flushed after each call to the method)
- Event handlers (including tasks) are executed in priority order
- Transitions and event capturing states can consume events on successful selection
- Added API to tick a StateTree in two passes (update tasks and trigger transitions)
- Change parallel tree tasks to do the task update in Tick(), and event handling in TriggerTransitions()
- Small improvements to the ST debugger to display events
- NOTE: this is breaking change for implementations that has relied events emitted during tick to be available on next EnterState()

#okfirgithub public
#rb Yoan.StAmant

[CL 32924765 by mikko mononen in ue5-main branch]
2024-04-12 06:04:01 -04:00
mikko mononen
551d9cb46d StateTree: Fix stack-use-after-scope
#jira UE-210969
#rb Mieszko.Zielinski

[CL 32876371 by mikko mononen in ue5-main branch]
2024-04-11 04:38:59 -04:00