A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
HandSocketVisualizer.h
Go to the documentation of this file.
1#pragma once
2
3#include "ComponentVisualizer.h"
5#include "ActorEditorUtils.h"
6
7class FEditorViewportClient;
8
10struct VREXPANSIONEDITOR_API HHandSocketVisProxy : public HComponentVisProxy
11{
13
15 : HComponentVisProxy(InComponent, HPP_Wireframe)
16 {
17 BoneIdx = 0;
18 TargetBoneName = NAME_None;
19 }
20
21 uint32 BoneIdx;
23};
24
25class VREXPANSIONEDITOR_API FHandSocketVisualizer : public FComponentVisualizer
26{
27public:
29 {
30 CurrentlySelectedBone = NAME_None;
31 CurrentlySelectedBoneIdx = INDEX_NONE;
32 HandPropertyPath = FComponentPropertyPath();
33 TargetViewport = nullptr;
34 }
35
37 {
38
39 }
40
41 UPROPERTY()
42 FComponentPropertyPath HandPropertyPath;
43
44 FName CurrentlySelectedBone;
45 uint32 CurrentlySelectedBoneIdx;
47 UPROPERTY()
48 FViewport* TargetViewport;
49
50 UHandSocketComponent* GetCurrentlyEditingComponent() const
51 {
52 return Cast<UHandSocketComponent>(HandPropertyPath.GetComponent());;
53 }
55 const UHandSocketComponent* UpdateSelectedHandComponent(HComponentVisProxy* VisProxy)
56 {
57 const UHandSocketComponent* HandComp = CastChecked<const UHandSocketComponent>(VisProxy->Component.Get());
58 UHandSocketComponent* OldHandComp = Cast<UHandSocketComponent>(HandPropertyPath.GetComponent());
59 AActor* OldOwningActor = HandPropertyPath.GetParentOwningActor();
60 HandPropertyPath = FComponentPropertyPath(HandComp);
61 AActor* NewOwningActor = HandPropertyPath.GetParentOwningActor();
62
63 if (HandPropertyPath.IsValid())
64 {
65 if (OldOwningActor != NewOwningActor || OldHandComp != HandComp)
66 {
67 // Reset selection state if we are selecting a different actor to the one previously selected
68 CurrentlySelectedBoneIdx = INDEX_NONE;
69 CurrentlySelectedBone = NAME_None;
70 }
71
72 return HandComp;
73 }
74
75 HandPropertyPath = FComponentPropertyPath();
76 return nullptr;
77 }
78
79 bool SaveAnimationAsset(const FString& InAssetPath, const FString& InAssetName);
80
81
82 bool GetCustomInputCoordinateSystem(const FEditorViewportClient* ViewportClient, FMatrix& OutMatrix) const override;
84 bool IsVisualizingArchetype() const override;
85
86 virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override;
87 virtual void DrawVisualizationHUD(const UActorComponent* Component, const FViewport* Viewport, const FSceneView* View, FCanvas* Canvas) override;
88 virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, const FViewportClick& Click) override;
89 bool GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const override;
90 bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) override;
91 virtual void EndEditing() override;
92
93private:
94
95};
FComponentPropertyPath HandPropertyPath
UPROPERTY()
FViewport * TargetViewport
UPROPERTY()
bool SaveAnimationAsset(const FString &InAssetPath, const FString &InAssetName)
const UHandSocketComponent * UpdateSelectedHandComponent(HComponentVisProxy *VisProxy)
UHandSocketComponent * GetCurrentlyEditingComponent() const
UCLASS(Blueprintable, ClassGroup = (VRExpansionPlugin), hideCategories = ("Component Tick",...
HHandSocketVisProxy(const UActorComponent *InComponent)