UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GizmoElementBase.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
11#include "InputState.h"
12#include "SceneView.h"
14#include "UObject/GCObject.h"
15#include "GizmoElementBase.generated.h"
16
18
24UCLASS(Transient, Abstract, MinimalAPI)
26{
28
30
31public:
32
33 static constexpr float DefaultViewDependentAngleTol = 0.052f; // ~3 degrees
34 static constexpr float DefaultViewDependentAxialMaxCosAngleTol = 0.998f; // Cos(DefaultViewDependentAngleTol)
35 static constexpr float DefaultViewDependentPlanarMinCosAngleTol = 0.052f; // Cos(HALF_PI - DefaultViewDependentAngleTol)
36
37 static constexpr float DefaultViewAlignAngleTol = 0.052f; // ~3 degrees
38 static constexpr float DefaultViewAlignMaxCosAngleTol = 0.998f; // Cos(DefaultViewAlignAngleTol)
39
40 static constexpr uint32 DefaultPartIdentifier = 0; // Default part ID, used for elements that are not associated with any gizmo part
41
42 //
43 // Render traversal state structure used to maintain the current render state while rendering.
44 // As the gizmo element hierarchy is traversed, current state is maintained and updated.
45 // Element state attribute inheritance works as follows:
46 //
47 // - Child element state that is not set inherits from parent state.
48 // - Child element state that is set replaces the parent state, except in the case of overrides.
49 // - Overrides: parent element state with override set to true replaces all child state regardless of whether the child state has been set.
50 //
52 {
53 // LocalToWorld transform
54 // Note: non-uniform scale is not supported and the X scale element will be used for uniform scaling.
56
57 // Pixel to world scale. Also accounts for DPI scale, @see IToolsContextRenderAPI::ViewCameraState.
58 double PixelToWorldScale = 1.0;
59
60 // Interact state, if not equal to none, overrides the element's interact state
62
63 // Current state used for rendering meshes
65
66 // Current state used for rendering lines
68
69 // Initialize state
71 {
72 LocalToWorldTransform = InTransform;
74 }
75
76 // Returns the mesh material based on the current interaction state.
78 {
79 return MeshRenderState.GetMaterial(InteractionState);
80 }
81
82 // Returns the mesh vertex color based on the current interaction state.
84 {
85 return MeshRenderState.GetVertexColor(InteractionState);
86 }
87
88 // Returns the line color based on the current interaction state.
90 {
91 return LineRenderState.GetLineColor(InteractionState);
92 }
93 };
94
96 {
97 // LocalToWorld transform
98 // Note: non-uniform scale is not supported and the X scale element will be used for uniform scaling.
100
101 // Pixel to world scale
102 double PixelToWorldScale = 1.0;
103
104 // View context is perspective projecion
105 bool bIsPerspectiveProjection = true;
106
107 // The criteria that determines the singular element when multiple are hit.
109
110 // Initialize state
112 {
114
115 LocalToWorldTransform = InTransform;
116 bIsPerspectiveProjection = InGizmoViewContext->IsPerspectiveProjection();
117
118 constexpr bool bUseDPIScaleFromViewContext = true;
120 }
121 };
122
125 {
127 int32 HitPriority = 0;
128
130 bool bIsSurfaceHit = false;
131 };
132
133public:
134
135 // Render enabled visible element.
136 virtual void Render(IToolsContextRenderAPI* RenderAPI, const FRenderTraversalState& RenderState) PURE_VIRTUAL(UGizmoElementBase::Render);
137
138 // Do screen space drawing.
140
141 // Line trace enabled hittable element.
143
144 // Line trace enabled hittable element.
145 UE_DEPRECATED(5.7, "Use the version of LineTrace that outputs FLineTraceOutput instead.")
147
148 // Set/get the visible bit in element state.
149 INTERACTIVETOOLSFRAMEWORK_API virtual void SetVisibleState(bool bVisible);
150 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetVisibleState() const;
151
152 // Set/get the hittable bit in element state.
153 INTERACTIVETOOLSFRAMEWORK_API virtual void SetHittableState(bool bHittable);
154 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetHittableState() const;
155
156 // Set/get the hit priority. When hits overlap, higher priority elements will be hit first. If two elements have the same priority, the one that was closest to the hit location will be returned.
157 INTERACTIVETOOLSFRAMEWORK_API virtual void SetHitPriority(const int32 InHitPriority);
158 INTERACTIVETOOLSFRAMEWORK_API virtual int32 GetHitPriority() const;
159
160 // Element enabled flag. Render and LineTrace only occur when bEnabled is true.
161 // This flag is useful for turning on and off an element globally while retaining its specific settings.
163 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetEnabled() const;
164
165 // Whether element is enabled for perspective projections.
166 INTERACTIVETOOLSFRAMEWORK_API virtual void SetEnabledForPerspectiveProjection(bool bInEnabledForPerspectiveProjection);
167 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetEnabledForPerspectiveProjection();
168
169 // Whether element is enabled for orthographic projections.
170 INTERACTIVETOOLSFRAMEWORK_API virtual void SetEnabledInOrthographicProjection(bool bInEnabledForOrthographicProjection);
171 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetEnabledInOrthographicProjection();
172
173 // Whether element is enabled when element state is default.
174 INTERACTIVETOOLSFRAMEWORK_API virtual void SetEnabledForDefaultState(bool bInEnabledForDefaultState);
175 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetEnabledForDefaultState();
176
177 // Whether element is enabled when element state is hovering.
178 INTERACTIVETOOLSFRAMEWORK_API virtual void SetEnabledForHoveringState(bool bInEnabledForHoveringState);
179 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetEnabledForHoveringState();
180
181 // Whether element is enabled when element state is interacting.
182 INTERACTIVETOOLSFRAMEWORK_API virtual void SetEnabledForInteractingState(bool bInEnabledForInteractingState);
183 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetEnabledForInteractingState();
184
185 // Whether element is enabled when element state is selected.
186 INTERACTIVETOOLSFRAMEWORK_API virtual void SetEnabledForSelectedState(bool bInEnabledForSelectedState);
187 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetEnabledForSelectedState();
188
189 // Whether element is enabled when element state is subdued.
190 INTERACTIVETOOLSFRAMEWORK_API virtual void SetEnabledForSubduedState(bool bInEnabledForSubduedState);
191 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetEnabledForSubduedState();
192
193 // For an element hierarchy representing multiple parts of a single gizmo, the part identifier establishes
194 // a correspondence between a gizmo part and the elements that represent that part. The recognized
195 // part identifier values should be defined in the gizmo. Gizmo part identifiers must be greater than or
196 // equal to one. Identifier 0 is reserved for the default ID which should be assigned to elements
197 // that do not correspond to any gizmo part, such as non-hittable decorative elements.
199 INTERACTIVETOOLSFRAMEWORK_API virtual uint32 GetPartIdentifier();
200 INTERACTIVETOOLSFRAMEWORK_API virtual uint32 GetPartIdentifier() const;
201
202 // Sets the part identifier for this element and all of its children whose current ID is 0/Default.
203 // If bInOverrideSet is true, the PartId will be set even if it's currently 0.
204 INTERACTIVETOOLSFRAMEWORK_API virtual void SetPartIdentifier(uint32 InPartId, const bool bInOverrideUnsetChildren, const bool bInOverrideSet = true);
205
206 // Returns the element associated with the specified part id, or nullptr if not found.
208
209 // Returns the element associated with the specified part id, or nullptr if not found.
210 INTERACTIVETOOLSFRAMEWORK_API virtual const UGizmoElementBase* FindPartElement(const uint32 InPartId) const;
211
212 // Get the (top-level) sub-elements, if any.
214
215 // Object type bitmask indicating whether this object is visible or hittable or both
218
219 // Object interaction state - None, Hovering, Interacting, Selected or Subdued
222
223 // Update element's visibility state if element is associated with the specified gizmo part, return true if part was found.
224 UE_DEPRECATED(5.7, "Use UpdatePartVisibleState with bInAllowMultipleElements instead.")
225 INTERACTIVETOOLSFRAMEWORK_API virtual bool UpdatePartVisibleState(bool bVisible, uint32 InPartIdentifier);
226
227 // Update element's visibility state if element is associated with the specified gizmo part, return true if part was found.
228 // Setting bAllowMultipleElements to true will allow multiple elements with the same Part Id to be updated.
229 INTERACTIVETOOLSFRAMEWORK_API virtual bool UpdatePartVisibleState(bool bVisible, uint32 InPartIdentifier, bool bInAllowMultipleElements);
230
231 // Get element's visible state for element associated with the specified gizmo part, if part id was found.
233
234 // Update element's hittable state if element is associated with the specified gizmo part, return true if part id was found.
235 UE_DEPRECATED(5.7, "Use UpdatePartHittableState with bInAllowMultipleElements instead.")
236 INTERACTIVETOOLSFRAMEWORK_API virtual bool UpdatePartHittableState(bool bHittable, uint32 InPartIdentifier);
237
238 // Update element's hittable state if element is associated with the specified gizmo part, return true if part id was found.
239 // Setting bAllowMultipleElements to true will allow multiple elements with the same Part Id to be updated.
241
242 // Get element's hittable state for element associated with the specified gizmo part, if part id was found.
244
245 // Update element's interaction state if element is associated with the specified gizmo part, return true if part id was found.
246 UE_DEPRECATED(5.7, "Use UpdatePartInteractionState with bInAllowMultipleElements instead.")
248
249 // Update element's interaction state if element is associated with the specified gizmo part, return true if part id was found.
250 // Setting bAllowMultipleElements to true will allow multiple elements with the same Part Id to be updated.
252
253 // Get element's interaction state for element associated with the specified gizmo part, if part id was found.
255
256 // View-dependent type - None, Axis or Plane.
257 INTERACTIVETOOLSFRAMEWORK_API virtual void SetViewDependentType(EGizmoElementViewDependentType ViewDependentType);
259
260 // View-dependent angle tolerance in radians
261 // For Axis, object is culled when angle between view dependent axis and view direction is less than tolerance angle.
262 // For Planar, cos of angle between view dependent axis (plane normal) and view direction.
263 // When the view direction is within this tolerance from the plane or axis, this object will be culled.
264 INTERACTIVETOOLSFRAMEWORK_API virtual void SetViewDependentAngleTol(float InMaxAngleTol);
265 INTERACTIVETOOLSFRAMEWORK_API virtual float GetViewDependentAngleTol() const;
266
267 // View-dependent axis or plane normal, based on the view-dependent type.
268 INTERACTIVETOOLSFRAMEWORK_API virtual void SetViewDependentAxis(FVector InAxis);
269 INTERACTIVETOOLSFRAMEWORK_API virtual FVector GetViewDependentAxis() const;
270
271 // View align type: None, PointEye, PointOnly, or Axial.
274
275 // View align axis.
276 // PointEye, PointScreen and PointOnly rotate this axis to align with view up.
277 // Axial rotates about this axis.
279 INTERACTIVETOOLSFRAMEWORK_API virtual FVector GetViewAlignAxis() const;
280
281 // View align normal.
282 // PointEye rotates the normal to align with camera view direction.
283 // PointScreen rotates the normal to align with screen forward direction.
284 // Axial rotates the normal around the axis to align as closely as possible with the view direction.
285 INTERACTIVETOOLSFRAMEWORK_API virtual void SetViewAlignNormal(FVector InAxis);
286 INTERACTIVETOOLSFRAMEWORK_API virtual FVector GetViewAlignNormal() const;
287
288 // View-align angle tolerance in radians.
289 // Viewer alignment will not occur when the viewing angle is within this angle of view align axis.
290 INTERACTIVETOOLSFRAMEWORK_API virtual void SetViewAlignAxialAngleTol(float InMaxAngleTol);
291 INTERACTIVETOOLSFRAMEWORK_API virtual float GetViewAlignAxialAngleTol() const;
292
293 // Additional view-space offset to apply to the element, affecting both visuals and the hit geometry. Greater values are further away from the camera.
294 // An example use case: A large sphere and view-facing rectangle are both at the origin, but the rectangle should draw on top of the sphere.
295 // The sphere would otherwise overlap the rectangle.
296 INTERACTIVETOOLSFRAMEWORK_API virtual void SetViewDepthOffset(float InViewDepthOffset);
297 INTERACTIVETOOLSFRAMEWORK_API virtual float GetViewDepthOffset() const;
298
299 // Pixel hit distance threshold, element will be scaled enough to add this threshold when line-tracing. */
300 INTERACTIVETOOLSFRAMEWORK_API virtual void SetPixelHitDistanceThreshold(float InPixelHitDistanceThreshold);
301 INTERACTIVETOOLSFRAMEWORK_API virtual float GetPixelHitDistanceThreshold() const;
302
303 // Minimum pixel hit distance threshold, element will be scaled enough to add this threshold when line-tracing the "exact" element (useful for pixel-thin elements where an "exact" hit would be otherwise challenging to hit).
304 INTERACTIVETOOLSFRAMEWORK_API virtual void SetMinimumPixelHitDistanceThreshold(const float InMinimumPixelHitDistanceThreshold);
305 INTERACTIVETOOLSFRAMEWORK_API virtual float GetMinimumPixelHitDistanceThreshold() const;
306
307 //
308 // Methods for managing render state attributes: Material, HoverMaterial, InteractMaterial, SelectMaterial, SubdueMaterial, VertexColor
309 //
310 // State inheritance works as follows:
311 // - Gizmo element state that is not set inherits from the corresponding state in the current render traversal.
312 // - Gizmo element state that is set replaces the corresponding state in the current render traversal, except in the case of overrides.
313 // - Gizmo element state that is set to override, will override any corresponding state in children.
314 //
315
316 // Set mesh render state material attribute.
317 // @param InMaterial - material to be set
318 // @param InOverridesChildState - when true, this material will override the material of all child elements.
320
321 // Get mesh render state material attribute's value.
323
324 // Get mesh render state material attribute's override setting.
325 INTERACTIVETOOLSFRAMEWORK_API virtual bool DoesMaterialOverrideChildState() const;
326
327 // Clear mesh render state material attribute.
328 INTERACTIVETOOLSFRAMEWORK_API virtual void ClearMaterial();
329
330 // Set mesh render state hover material attribute.
331 // @param InHoverMaterial - hover material to be set
332 // @param InOverridesChildState - when true, this hover material will override the material of all child elements.
334
335 // Get mesh render state hover material attribute's value.
336 INTERACTIVETOOLSFRAMEWORK_API virtual const UMaterialInterface* GetHoverMaterial() const;
337
338 // Get mesh render state hover material attribute's override setting.
339 INTERACTIVETOOLSFRAMEWORK_API virtual bool DoesHoverMaterialOverrideChildState() const;
340
341 // Clear mesh render state hover material attribute.
342 INTERACTIVETOOLSFRAMEWORK_API virtual void ClearHoverMaterial();
343
344 // Set mesh render state interact material attribute.
345 // @param InInteractMaterial - interact material to be set
346 // @param InOverridesChildState - when true, this interact material will override the material of all child elements.
348
349 // Get mesh render state interact material attribute's value.
350 INTERACTIVETOOLSFRAMEWORK_API virtual const UMaterialInterface* GetInteractMaterial() const;
351
352 // Get mesh render state interact material attribute's override setting.
353 INTERACTIVETOOLSFRAMEWORK_API virtual bool DoesInteractMaterialOverrideChildState() const;
354
355 // Clear mesh render interact state material attribute.
356 INTERACTIVETOOLSFRAMEWORK_API virtual void ClearInteractMaterial();
357
358 // Set mesh render state Select material attribute.
359 // @param InSelectMaterial - Select material to be set
360 // @param InOverridesChildState - when true, this Select material will override the material of all child elements.
362
363 // Get mesh render state Select material attribute's value.
364 INTERACTIVETOOLSFRAMEWORK_API virtual const UMaterialInterface* GetSelectMaterial() const;
365
366 // Get mesh render state Select material attribute's override setting.
367 INTERACTIVETOOLSFRAMEWORK_API virtual bool DoesSelectMaterialOverrideChildState() const;
368
369 // Clear mesh render Select state material attribute.
370 INTERACTIVETOOLSFRAMEWORK_API virtual void ClearSelectMaterial();
371
372 // Set mesh render state Subdue material attribute.
373 // @param InSubdueMaterial - Subdue material to be set
374 // @param InOverridesChildState - when true, this Subdue material will override the material of all child elements.
376
377 // Get mesh render state Subdue material attribute's value.
378 INTERACTIVETOOLSFRAMEWORK_API virtual const UMaterialInterface* GetSubdueMaterial() const;
379
380 // Get mesh render state Subdue material attribute's override setting.
381 INTERACTIVETOOLSFRAMEWORK_API virtual bool DoesSubdueMaterialOverrideChildState() const;
382
383 // Clear mesh render Subdue state material attribute.
384 INTERACTIVETOOLSFRAMEWORK_API virtual void ClearSubdueMaterial();
385
386 // Set mesh render state vertex color attribute.
387 // @param InVertexColor - vertex color to be set
388 // @param InOverridesChildState - when true, this vertex color will override the material of all child elements.
390
391 // Get mesh render state vertex color attribute's value.
393
394 // Returns true, if mesh render state vertex color attribute has been set.
395 INTERACTIVETOOLSFRAMEWORK_API virtual bool HasVertexColor() const;
396
397 // Get mesh render state vertex color attribute's override setting.
398 INTERACTIVETOOLSFRAMEWORK_API virtual bool DoesVertexColorOverrideChildState() const;
399
400 // Clear mesh render state vertex color attribute.
401 INTERACTIVETOOLSFRAMEWORK_API virtual void ClearVertexColor();
402
403 // Set mesh render state vertex color attribute.
404 // @param InVertexColor - vertex color to be set
405 // @param InOverridesChildState - when true, this vertex color will override the material of all child elements.
407
408 // Get mesh render state vertex color attribute's value.
409 INTERACTIVETOOLSFRAMEWORK_API virtual FLinearColor GetHoverVertexColor() const;
410
411 // Returns true, if mesh render state vertex color attribute has been set.
412 INTERACTIVETOOLSFRAMEWORK_API virtual bool HasHoverVertexColor() const;
413
414 // Get mesh render state vertex color attribute's override setting.
415 INTERACTIVETOOLSFRAMEWORK_API virtual bool DoesHoverVertexColorOverrideChildState() const;
416
417 // Clear mesh render state vertex color attribute.
418 INTERACTIVETOOLSFRAMEWORK_API virtual void ClearHoverVertexColor();
419
420 // Set mesh render state vertex color attribute.
421 // @param InVertexColor - vertex color to be set
422 // @param InOverridesChildState - when true, this vertex color will override the material of all child elements.
424
425 // Get mesh render state vertex color attribute's value.
426 INTERACTIVETOOLSFRAMEWORK_API virtual FLinearColor GetInteractVertexColor() const;
427
428 // Returns true, if mesh render state vertex color attribute has been set.
429 INTERACTIVETOOLSFRAMEWORK_API virtual bool HasInteractVertexColor() const;
430
431 // Get mesh render state vertex color attribute's override setting.
432 INTERACTIVETOOLSFRAMEWORK_API virtual bool DoesInteractVertexColorOverrideChildState() const;
433
434 // Clear mesh render state vertex color attribute.
435 INTERACTIVETOOLSFRAMEWORK_API virtual void ClearInteractVertexColor();
436
437 // Set mesh render state vertex color attribute.
438 // @param InVertexColor - vertex color to be set
439 // @param InOverridesChildState - when true, this vertex color will override the material of all child elements.
441
442 // Get mesh render state vertex color attribute's value.
443 INTERACTIVETOOLSFRAMEWORK_API virtual FLinearColor GetSelectVertexColor() const;
444
445 // Returns true, if mesh render state vertex color attribute has been set.
446 INTERACTIVETOOLSFRAMEWORK_API virtual bool HasSelectVertexColor() const;
447
448 // Get mesh render state vertex color attribute's override setting.
449 INTERACTIVETOOLSFRAMEWORK_API virtual bool DoesSelectVertexColorOverrideChildState() const;
450
451 // Clear mesh render state vertex color attribute.
452 INTERACTIVETOOLSFRAMEWORK_API virtual void ClearSelectVertexColor();
453
454 // Set mesh render state vertex color attribute.
455 // @param InVertexColor - vertex color to be set
456 // @param InOverridesChildState - when true, this vertex color will override the material of all child elements.
458
459 // Get mesh render state vertex color attribute's value.
460 INTERACTIVETOOLSFRAMEWORK_API virtual FLinearColor GetSubdueVertexColor() const;
461
462 // Returns true, if mesh render state vertex color attribute has been set.
463 INTERACTIVETOOLSFRAMEWORK_API virtual bool HasSubdueVertexColor() const;
464
465 // Get mesh render state vertex color attribute's override setting.
466 INTERACTIVETOOLSFRAMEWORK_API virtual bool DoesSubdueVertexColorOverrideChildState() const;
467
468 // Clear mesh render state vertex color attribute.
469 INTERACTIVETOOLSFRAMEWORK_API virtual void ClearSubdueVertexColor();
470
472
473 // Whether element is enabled. Render and LineTrace only occur when bEnabled is true.
474 UPROPERTY()
475 bool bEnabled = true;
476
477 // Whether element is enabled for perspective projection
478 UPROPERTY()
479 bool bEnabledForPerspectiveProjection = true;
480
481 // Whether element is enabled for orthographic projection
482 UPROPERTY()
483 bool bEnabledForOrthographicProjection = true;
484
485 // Whether element is enabled when element state is default
486 UPROPERTY()
487 bool bEnabledForDefaultState = true;
488
489 // Whether element is enabled when element state is hovering
490 UPROPERTY()
491 bool bEnabledForHoveringState = true;
492
493 // Whether element is enabled when element state is interacting
494 UPROPERTY()
495 bool bEnabledForInteractingState = true;
496
497 // Whether element is enabled when element state is selected
498 UPROPERTY()
499 bool bEnabledForSelectedState = true;
500
501 // Whether element is enabled when element state is subdued
502 UPROPERTY()
503 bool bEnabledForSubduedState = true;
504
505 // Part identifier
506 UPROPERTY()
507 uint32 PartIdentifier = DefaultPartIdentifier;
508
509 // Mesh render state attributes for this element
510 UPROPERTY()
512
513 // Element state - indicates whether object is visible or hittable
514 UPROPERTY()
516
517 // Current element interaction state - None, Hovering, Interacting, Selected or Subdued
518 UPROPERTY()
520
521 // View-dependent type - None, Axis or Plane.
522 UPROPERTY()
524
525 // View-dependent axis or plane normal, based on the view-dependent type.
526 UPROPERTY()
527 FVector ViewDependentAxis = FVector::UpVector;
528
529 // View-dependent angle tolerance based on :
530 // For Axis, minimum radians between view dependent axis and view direction.
531 // For Planar, minimum radians between view dependent axis and the plane where axis is its normal.
532 // When the angle between the view direction and the axis/plane is less than this tolerance, this object should be culled.
533 UPROPERTY()
534 float ViewDependentAngleTol = DefaultViewDependentAngleTol;
535
536 // Axial view alignment minimum cos angle tolerance, computed based on ViewDependentAngleTol.
537 // When the cos of the angle between the view direction and the axis is less than this value, this object should not be culled.
538 UPROPERTY()
539 float ViewDependentAxialMaxCosAngleTol = DefaultViewDependentAxialMaxCosAngleTol;
540
541 // Planar view alignment minimum cos angle tolerance, computed based on ViewDependentAngleTol.
542 // When the cos of the angle between the view direction and the axis is greater than this value, this object should not be culled.
543 UPROPERTY()
544 float ViewDependentPlanarMinCosAngleTol = DefaultViewDependentPlanarMinCosAngleTol;
545
546 // View align type: None, PointEye, or PointWorld.
547 // PointEye rotates this axis to align with the view up axis.
548 // PointWorld rotates this axis to align with the world up axis.
549 // Axial rotates around this axis to align the normal as closely as possible to the view direction.
550 UPROPERTY()
552
553 // View align axis.
554 UPROPERTY()
555 FVector ViewAlignAxis = FVector::UpVector;
556
557 // View align normal.
558 // PointEye and PointWorld both rotate the normal to align with the view direction.
559 // Axial rotates the normal to align as closely as possible with view direction.
560 UPROPERTY()
561 FVector ViewAlignNormal = -FVector::ForwardVector;
562
563 // Axial view alignment angle tolerance in radians, based on angle between align normal and view direction.
564 // When angle between the view align normal and the view direction is greater than this angle, the align rotation will be computed.
565 UPROPERTY()
566 float ViewAlignAxialAngleTol = DefaultViewAlignAngleTol;
567
568 // Axial view alignment minimum cos angle tolerance, computed based on ViewAlignAxialAngleTol.
569 // When the cos of the angle between the view direction and the align normal is less than this value, the align rotation will be computed.
570 UPROPERTY()
571 float ViewAlignAxialMaxCosAngleTol = DefaultViewAlignMaxCosAngleTol;
572
573 // Pixel hit distance threshold, element will be scaled enough to add this threshold when line-tracing.
574 UPROPERTY()
575 float PixelHitDistanceThreshold = 7.0f;
576
577 // Minimum pixel hit distance threshold, element will be scaled enough to add this threshold when line-tracing the "exact" element (useful for pixel-thin elements where an "exact" hit would be otherwise challenging to hit).
578 UPROPERTY()
579 float MinimumPixelHitDistanceThreshold = 1.0f;
580
581 // When hits overlap, higher priority elements will be hit first. If two elements have the same priority, the one that was closest to the hit location will be returned.
582 UPROPERTY()
583 int32 HitPriority = 0;
584
585private:
586
587 // Additional view-space offset to apply to the element, affecting both visuals and the hit geometry.
588 UPROPERTY()
589 float ViewDepthOffset = 0.0;
590
592
593 // Iterate over each top-level element (sub-element), excluding the element itself.
594 INTERACTIVETOOLSFRAMEWORK_API void ForEachSubElement(const TFunctionRef<void(UGizmoElementBase*)>& InFunc);
595
596 // Iterate over each element (sub-element) in the element tree, excluding the element itself.
597 INTERACTIVETOOLSFRAMEWORK_API void ForEachSubElementRecursive(const TFunctionRef<void(UGizmoElementBase*)>& InFunc) const;
598
599 // Iterate over each sub-element with the given Part Id in the element tree, excluding the element itself.
600 INTERACTIVETOOLSFRAMEWORK_API void ForEachSubElementRecursive(const TFunctionRef<void(UGizmoElementBase*)>& InFunc, const uint32 InPartId) const;
601
602 // Get all sub-elements for the element tree, if any. Returns true if any sub-elements were found.
603 INTERACTIVETOOLSFRAMEWORK_API bool GetSubElementsRecursive(TArray<TObjectPtr<UGizmoElementBase>>& OutElements) const;
604
605 // Get all sub-elements with the given Part Id for the element tree, if any. Returns true if any sub-elements were found.
606 INTERACTIVETOOLSFRAMEWORK_API bool GetSubElementsRecursive(TArray<TObjectPtr<UGizmoElementBase>>& OutElements, const uint32 InPartId) const;
607
608 // Return whether element is currently visible.
611
612 // Return whether element is currently hittable.
614
615 // Returns whether object is visible in input FSceneView based on view-dependent visibility settings.
616 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetViewDependentVisibility(const FSceneView* View, const FTransform& InLocalToWorldTransform, const FVector& InLocalCenter) const;
617
618 // Returns whether object is visible in input gizmo view context based on view-dependent visibility settings
619 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetViewDependentVisibility(const UGizmoViewContext* View, const FTransform& InLocalToWorldTransform, const FVector& InLocalCenter) const;
620
621 // Returns whether object is visible based on view-dependent visibility settings.
623
624 // Returns whether element is enabled for given interaction state.
626
627 // Returns whether element is enabled for given view projection type.
628 INTERACTIVETOOLSFRAMEWORK_API virtual bool GetEnabledForViewProjection(bool bIsPerspectiveProjection) const;
629
630 // Return whether this element has a view alignment rotation based on input FSceneView and view-dependent alignment settings.
631 // @param OutAlignRot the rotation to align this element in local space, should be prepended to the local-to-world transform.
633
634 // Return whether this element has a view alignment rotation based on input gizmo view context and view-dependent alignment settings.
635 // @param OutAlignRot the rotation to align this element in local space, should be prepended to the local-to-world transform.
637
638 // Return whether this element has a view alignment rotation based on input view parameters and view-dependent alignment settings.
639 // @param OutAlignRot the rotation to align this element in local space, should be prepended to the local-to-world transform.
641
642 INTERACTIVETOOLSFRAMEWORK_API virtual void ApplyViewDepthOffset(const FSceneView* InView, const double& InViewDepthOffset, FTransform& InOutTransform) const;
643
645
647
648 // Get mesh render state material attribute's value.
650
651 // Get mesh render state hover material attribute's value.
653
654 // Get mesh render state interact material attribute's value.
656
657 // Get mesh render state Select material attribute's value.
659
660 // Get mesh render state Subdue material attribute's value.
662
663 // Update render state during render traversal, determines the current render state for this element
664 // @param RenderAPI - tools render context
665 // @param InLocalCenter - local element center position
666 // @param InOutRenderState - render state's local to world transform will be updated with translation to center and view-dependent alignment rotation, if applicable.
667 // @return view dependent visibility, true if this element is visible in the current view.
669
670 // Update render state during render traversal, determines the current render state for this element
671 // Same parameters as UpdateRenderState above plus two output parameters:
672 // @param bOutHasAlignRot - whether alignment rotation was applied to output state
673 // @param OutAlignRot - alignment rotation applied to output state, if applicable.
675
676 // Update line trace state during line trace traversal, determines the current state for this element
677 // @param ViewContext - current gizmo view context
678 // @param InLocalCenter - local element center position, this will update InOutLineTraceState's LocalToWorldTransform with a translation to LocalCenter
679 // @param InOutLineTraceState - line trace state's local to world transform will be updated with translation to center and view-dependent alignment rotation, if applicable.
680 // @return view dependent visibility, true if this element is visible in the current view.
682
683 // Update line trace state during line trace traversal, determines the current state for this element
684 // Same parameters as UpdateLineTraceState above plus two output parameters:
685 // @param bOutHasAlignRot - whether alignment rotation was applied to output state
686 // @param OutAlignRot - alignment rotation applied to output state, if applicable.
688
689 // Initialize ray hit for this element, injecting the Part Identifier, Hit Priority, etc.
691
693
694 // Helper method to verify scale is uniform. If it is non-uniform, a one-time warning log is issued.
695 // Returns true if scale is uniform.
696 INTERACTIVETOOLSFRAMEWORK_API bool VerifyUniformScale(const FVector& Scale) const;
697
698 // Helper method for view alignment.
699 // Returns rotation between source and target input coordinate spaces.
701};
702
#define check(expr)
Definition AssertionMacros.h:314
#define PURE_VIRTUAL(func,...)
Definition CoreMiscDefines.h:103
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
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
return true
Definition ExternalRpcRegistry.cpp:601
EGizmoElementInteractionState
Definition GizmoElementShared.h:28
EGizmoElementViewAlignType
Definition GizmoElementShared.h:62
EGizmoElementViewDependentType
Definition GizmoElementShared.h:46
EGizmoElementHitSortType
Definition GizmoElementShared.h:101
EGizmoElementState
Definition GizmoElementShared.h:14
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition CanvasTypes.h:211
Definition GizmoUtil.h:19
Definition UnrealType.h:3087
Definition SceneView.h:1425
Definition ToolContextInterfaces.h:427
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition GizmoElementBase.h:26
virtual FInputRayHit LineTrace(const UGizmoViewContext *ViewContext, const FLineTraceTraversalState &LineTraceState, const FVector &RayOrigin, const FVector &RayDirection, FLineTraceOutput &OutLineTraceOutput) PURE_VIRTUAL(UGizmoElementBase
Definition GizmoElementBase.h:142
virtual void Render(IToolsContextRenderAPI *RenderAPI, const FRenderTraversalState &RenderState) PURE_VIRTUAL(UGizmoElementBase virtual INTERACTIVETOOLSFRAMEWORK_API voi DrawHUD)(FCanvas *Canvas, IToolsContextRenderAPI *RenderAPI, const FRenderTraversalState &RenderState)
Definition GizmoElementBase.h:139
Definition GizmoViewContext.h:20
Definition MaterialInterface.h:296
Definition Object.h:95
INTERACTIVETOOLSFRAMEWORK_API float CalculateLocalPixelToWorldScale(const FSceneView *View, const FVector &Location, const double InDPIScale=1.0)
Definition GizmoRenderingUtil.cpp:113
@ false
Definition radaudio_common.h:23
Definition GizmoElementRenderState.h:164
INTERACTIVETOOLSFRAMEWORK_API FLinearColor GetLineColor(EGizmoElementInteractionState InteractionState)
Definition GizmoElementRenderState.cpp:161
Definition GizmoElementRenderState.h:93
INTERACTIVETOOLSFRAMEWORK_API const UMaterialInterface * GetMaterial(EGizmoElementInteractionState InteractionState)
Definition GizmoElementRenderState.cpp:80
INTERACTIVETOOLSFRAMEWORK_API FLinearColor GetVertexColor(EGizmoElementInteractionState InteractionState)
Definition GizmoElementRenderState.cpp:113
Definition InputState.h:52
Definition Color.h:48
Definition ObjectPtr.h:488
Definition Optional.h:131
Definition WeakObjectPtrTemplates.h:25
Definition GizmoElementBase.h:125
Definition GizmoElementBase.h:96
void Initialize(const UGizmoViewContext *InGizmoViewContext, FTransform InTransform)
Definition GizmoElementBase.h:111
FTransform LocalToWorldTransform
Definition GizmoElementBase.h:99
Definition GizmoElementBase.h:52
FLinearColor GetCurrentLineColor()
Definition GizmoElementBase.h:89
FTransform LocalToWorldTransform
Definition GizmoElementBase.h:55
void Initialize(const FSceneView *InSceneView, FTransform InTransform, const double InDPIScale=1.0)
Definition GizmoElementBase.h:70
FGizmoElementMeshRenderStateAttributes MeshRenderState
Definition GizmoElementBase.h:64
FLinearColor GetCurrentVertexColor()
Definition GizmoElementBase.h:83
FGizmoElementLineRenderStateAttributes LineRenderState
Definition GizmoElementBase.h:67
const UMaterialInterface * GetCurrentMaterial()
Definition GizmoElementBase.h:77