UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ConstraintsEvaluationGraph.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "UObject/Object.h"
7
10class UWorld;
12
18{
19 /* Constraint data */
22
23 /* Internal indices for quick navigation through the nodes and constraints data structures */
26
27 /* internal hierarchy representing dependencies at the nodes level (indices here represent the nodes' NodeIndex)*/
30
31 /* Whether this node needs to be evaluated on the next flush. */
33
34 /* Whether this node is currently being evaluated (used to avoid re-entrant evaluations). */
35 bool bEvaluating = false;
36};
37
43struct FConstraintsEvaluationGraph: public TSharedFromThis<FConstraintsEvaluationGraph>
44{
45public:
49
55
56 /* Evaluates constraints marked for evaluation + their dependencies. */
58
59 /* Invalidates internal data so that the graph will be rebuilt on request. */
60 void InvalidateData();
61
62 /* Rebuilds the full graph taking constraints tick dependencies into account. */
63 void Rebuild();
64
65 /* Should the graph be evaluated ? */
66 bool IsPendingEvaluation() const;
67
68 /* Get Sorted Constraints */
70
71 static bool UseEvaluationGraph();
72
73private:
74
75 enum EGraphState
76 {
77 InvalidData = 0, // Invalid data
78 ReadyForEvaluation, // Internal data has been built and is ready for evaluation
79 PendingEvaluation, // Some constraints has been marked for evaluation
80 Flushing // The graph is currently being evaluated
81 };
82
86
87 /* Get or create a new node in the graph that wraps that constraint. */
89
90 /* Returns the node wrapping that constraint if any. */
92
93 /* Evaluates InConstraint ensuring there's a corresponding node. */
95
96 /* Evaluates InNode if its tick function is enabled + evaluates its children recursively. */
97 void Evaluate(FConstraintNode* InNode);
98
99 /* Dumps the current state of the graph. */
100 void Dump() const;
101
102 /* Array of constraint wrappers. */
104
105 /* References to the actual stored data. */
106 const FConstraintsInWorld& ConstraintsInWorld;
107
108 /* Current graph state. */
109 EGraphState State = InvalidData;
110};
111
113{
114
115using ConstraintPtr = TWeakObjectPtr<UTickableConstraint>;
116
123
129
130}
@ INDEX_NONE
Definition CoreMiscDefines.h:150
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition ArrayView.h:139
Definition Array.h:670
Definition SharedPointer.h:1640
Definition ConstraintsManager.h:74
Definition World.h:918
Definition ConstraintsEvaluationGraph.cpp:309
Definition ConstraintsEvaluationGraph.h:18
FGuid ConstraintID
Definition ConstraintsEvaluationGraph.h:20
TSet< uint32 > Parents
Definition ConstraintsEvaluationGraph.h:28
TSet< uint32 > Children
Definition ConstraintsEvaluationGraph.h:29
bool bEvaluating
Definition ConstraintsEvaluationGraph.h:35
FConstraintTickFunction * ConstraintTick
Definition ConstraintsEvaluationGraph.h:21
int32 NodeIndex
Definition ConstraintsEvaluationGraph.h:24
bool bMarkedForEvaluation
Definition ConstraintsEvaluationGraph.h:32
int32 ConstraintIndex
Definition ConstraintsEvaluationGraph.h:25
Definition ConstraintsManager.h:25
Definition ConstraintsEvaluationGraph.h:44
bool IsPendingEvaluation() const
Definition ConstraintsEvaluationGraph.cpp:158
static bool UseEvaluationGraph()
Definition ConstraintsEvaluationGraph.cpp:27
CONSTRAINTS_API void FlushPendingEvaluations()
Definition ConstraintsEvaluationGraph.cpp:63
void InvalidateData()
Definition ConstraintsEvaluationGraph.cpp:219
void Rebuild()
Definition ConstraintsEvaluationGraph.cpp:99
void MarkForEvaluation(const TWeakObjectPtr< UTickableConstraint > &InConstraint)
Definition ConstraintsEvaluationGraph.cpp:225
FConstraintsEvaluationGraph(const FConstraintsInWorld *InConstraintsInWorld)
Definition ConstraintsEvaluationGraph.h:46
bool GetSortedConstraints(TArray< TWeakObjectPtr< UTickableConstraint > > &OutConstraints)
Definition ConstraintsEvaluationGraph.cpp:121
Definition ConstraintSubsystem.h:19
Definition Guid.h:109
Definition WeakObjectPtrTemplates.h:25