UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ViewBasedTransformAdjusters.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "Math/Transform.h"
8
9class USceneComponent;
11
13{
14 class ISceneViewInterface;
15
23 {
24 public:
26
32
41 {
42 // By default, just route to the other implementation. This is safe to do for any adjusters
43 // that remain constant for the life of the render proxy.
45 }
46
52 virtual void UpdateWorldLocalState(bool bWorldIn) {}
53
64 {
65 return OriginalBounds;
66 }
67 };
68
75 {
76 public:
77 // IGizmoViewTransformAdjuster
79 const ISceneViewInterface& View,
80 const FTransform& CurrentComponentToWorld) override;
81
83 const FBoxSphereBounds& OriginalBounds) override;
84 private:
85 };
86
92 // Used for getting a weak pointer to itself when enqueuing state change on the render thread (in SetGizmoOriginTransform)
93 public TSharedFromThis<FSubGizmoTransformAdjuster, ESPMode::ThreadSafe>
94 {
95 public:
96 struct FSettings
97 {
98 // Some compilers (clang, at least) have issues with using a nested class with default initializers
99 // and a default constructor as a default argument in a function, hence this constructor.
101
102 // Keeps view size and offset relative to parent gizmo constant
104 // Mirrors the component depending on which octant of the parent gizmo the view is located
106 // Considers the parent gizmo transform to be unrotated, and applies the relative component transform on top of that.
107 // This is frequently not necessary to set because code upstream will typically update it every tick anyway
108 // via UViewAdjustedStaticMeshGizmoComponent's UpdateWorldLocalState implementation.
110 // If positive, keeps the component a given distance in front of the ortho camera, to avoid
111 // clipping it. Applied before bKeepConstantViewSize.
113 };
114
117 : GizmoOriginToComponent_GameThread(GizmoOriginToComponent)
118 , GizmoOriginToComponent_RenderThread(GizmoOriginToComponent)
119 , Settings(SettingsIn)
120 {}
121
127
129 {
130 Settings.bMirrorBasedOnOctant = bOn;
131 }
133 {
134 Settings = SettingsIn;
135 }
136
148 bool bMirrorBasedOnOctant);
149
153
154
155 // IGizmoViewTransformAdjuster
158 const FTransform& CurrentComponentToWorld) override;
159
161 const ISceneViewInterface& View, const FTransform& CurrentComponentToWorld) override;
162
163 virtual void UpdateWorldLocalState(bool bWorldIn) override
164 {
166 }
167
169 const FBoxSphereBounds& OriginalBounds) override;
170 private:
171 FTransform GizmoOriginToComponent_GameThread = FTransform::Identity;
172 FTransform GizmoOriginToComponent_RenderThread = FTransform::Identity;
173 // We might decide to have a render thread version of the settings as well, but it's unclear whether it's
174 // worth it, since it seems like a brief inconsistency during the update is unlikely to cause much of a
175 // problem: a user is unlikely to be changing multiple bools at once, and reading an outdated bool seems
176 // fine.
177 FSettings Settings;
178 };
179
187 //~ TODO: May someday want a non-const version of this where the relative transform is editable, for sliders.
189 {
190 public:
192 : ViewRelativeTransform(ViewRelativeTransformIn)
193 , bKeepConstantViewSize(bConstantSize)
194 {
195 }
196
197 // IGizmoViewTransformAdjuster
200 const FTransform& CurrentComponentToWorld) override;
201
203 const FBoxSphereBounds& OriginalBounds) override;
204 private:
205 FTransform ViewRelativeTransform = FTransform::Identity;
206 bool bKeepConstantViewSize = true;
207 };
208}
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition AndroidPlatformMisc.h:14
Definition SharedPointer.h:1640
Definition SharedPointer.h:692
Definition ViewBasedTransformAdjusters.h:189
virtual INTERACTIVETOOLSFRAMEWORK_API FBoxSphereBounds GetViewIndependentBounds(const FTransform &LocalToWorld, const FBoxSphereBounds &OriginalBounds) override
Definition ViewBasedTransformAdjusters.cpp:259
virtual INTERACTIVETOOLSFRAMEWORK_API FTransform GetAdjustedComponentToWorld(const UE::GizmoRenderingUtil::ISceneViewInterface &View, const FTransform &CurrentComponentToWorld) override
Definition ViewBasedTransformAdjusters.cpp:239
FConstantViewRelativeTransformAdjuster(const FTransform &ViewRelativeTransformIn, bool bConstantSize=true)
Definition ViewBasedTransformAdjusters.h:191
Definition ViewBasedTransformAdjusters.h:75
virtual INTERACTIVETOOLSFRAMEWORK_API FBoxSphereBounds GetViewIndependentBounds(const FTransform &LocalToWorld, const FBoxSphereBounds &OriginalBounds) override
Definition ViewBasedTransformAdjusters.cpp:136
virtual INTERACTIVETOOLSFRAMEWORK_API FTransform GetAdjustedComponentToWorld(const ISceneViewInterface &View, const FTransform &CurrentComponentToWorld) override
Definition ViewBasedTransformAdjusters.cpp:126
Definition ViewBasedTransformAdjusters.h:94
static INTERACTIVETOOLSFRAMEWORK_API TSharedPtr< FSubGizmoTransformAdjuster > AddTransformAdjuster(UViewAdjustedStaticMeshGizmoComponent *ComponentIn, USceneComponent *GizmoRootComponent, bool bMirrorBasedOnOctant)
Definition ViewBasedTransformAdjusters.cpp:162
INTERACTIVETOOLSFRAMEWORK_API void SetGizmoOriginTransform(const FTransform &GizmoOriginToComponent)
Definition ViewBasedTransformAdjusters.cpp:145
virtual void UpdateWorldLocalState(bool bWorldIn) override
Definition ViewBasedTransformAdjusters.h:163
FSubGizmoTransformAdjuster(const FTransform &GizmoOriginToComponent=FTransform::Identity, const FSettings &SettingsIn=FSettings())
Definition ViewBasedTransformAdjusters.h:115
static INTERACTIVETOOLSFRAMEWORK_API TSharedPtr< FSubGizmoTransformAdjuster > AddTransformAdjuster(UViewAdjustedStaticMeshGizmoComponent *ComponentIn, USceneComponent *GizmoRootComponent, TFunction< bool()> ShouldMirrorBasedOnOctant)
void SetMirrorBasedOnOctant(bool bOn)
Definition ViewBasedTransformAdjusters.h:128
virtual INTERACTIVETOOLSFRAMEWORK_API FTransform GetAdjustedComponentToWorld(const UE::GizmoRenderingUtil::ISceneViewInterface &View, const FTransform &CurrentComponentToWorld) override
Definition ViewBasedTransformAdjusters.cpp:191
virtual INTERACTIVETOOLSFRAMEWORK_API FTransform GetAdjustedComponentToWorld_RenderThread(const ISceneViewInterface &View, const FTransform &CurrentComponentToWorld) override
Definition ViewBasedTransformAdjusters.cpp:205
virtual INTERACTIVETOOLSFRAMEWORK_API FBoxSphereBounds GetViewIndependentBounds(const FTransform &LocalToWorld, const FBoxSphereBounds &OriginalBounds) override
Definition ViewBasedTransformAdjusters.cpp:215
void SetSettings(const FSettings &SettingsIn)
Definition ViewBasedTransformAdjusters.h:132
Definition GizmoRenderingUtil.h:25
Definition ViewBasedTransformAdjusters.h:23
virtual FTransform GetAdjustedComponentToWorld_RenderThread(const ISceneViewInterface &View, const FTransform &CurrentComponentToWorld)
Definition ViewBasedTransformAdjusters.h:39
virtual FTransform GetAdjustedComponentToWorld(const ISceneViewInterface &View, const FTransform &CurrentComponentToWorld)=0
virtual ~IViewBasedTransformAdjuster()
Definition ViewBasedTransformAdjusters.h:25
virtual void UpdateWorldLocalState(bool bWorldIn)
Definition ViewBasedTransformAdjusters.h:52
virtual FBoxSphereBounds GetViewIndependentBounds(const FTransform &LocalToWorld, const FBoxSphereBounds &OriginalBounds)
Definition ViewBasedTransformAdjusters.h:62
Definition ViewAdjustedStaticMeshGizmoComponent.h:26
Definition CombinedTransformGizmo.h:30
Definition ViewBasedTransformAdjusters.h:97
FSettings()
Definition ViewBasedTransformAdjusters.h:100
double DistanceInFrontOfCameraInOrtho
Definition ViewBasedTransformAdjusters.h:112
bool bKeepConstantViewSize
Definition ViewBasedTransformAdjusters.h:103
bool bMirrorBasedOnOctant
Definition ViewBasedTransformAdjusters.h:105
bool bUseWorldAxesForGizmo
Definition ViewBasedTransformAdjusters.h:109
Definition BoxSphereBounds.h:25
static CORE_API const TTransform< double > Identity
Definition TransformNonVectorized.h:58