54 if (CurrentlyEditingComponent)
56 if (CurrentlyEditingComponent->bMirrorVisualizationMesh)
58 FTransform NewTrans = CurrentlyEditingComponent->GetRelativeTransform();
61 if (
USceneComponent* ParentComp = CurrentlyEditingComponent->GetAttachParent())
63 NewTrans = NewTrans * ParentComp->GetComponentTransform();
66 OutMatrix = FRotationMatrix::Make(NewTrans.GetRotation());
77 FTransform newTrans = FTransform::Identity;
78 if (CurrentlyEditingComponent->bDecoupleMeshPlacement)
80 if (
USceneComponent* ParentComp = CurrentlyEditingComponent->GetAttachParent())
82 newTrans = CurrentlyEditingComponent->HandRelativePlacement * ParentComp->GetComponentTransform();
87 newTrans = CurrentlyEditingComponent->GetHandRelativePlacement() * CurrentlyEditingComponent->GetComponentTransform();
90 OutMatrix = FRotationMatrix::Make(newTrans.GetRotation());
97 FTransform newTrans = CurrentlyEditingComponent->HandVisualizerComponent->GetBoneTransform(
CurrentlySelectedBoneIdx);
98 OutMatrix = FRotationMatrix::Make(newTrans.GetRotation());
126 if (!CurrentlyEditingComponent->HandVisualizerComponent)
133 const FIntRect CanvasRect = Canvas->GetViewRect();
135 FPlane location = View->Project(CurrentlyEditingComponent->HandVisualizerComponent->GetBoneTransform(
CurrentlySelectedBoneIdx).GetLocation());
139 const float DrawPositionX = FMath::FloorToFloat(CanvasRect.Min.X + (CanvasRect.Width() - XL) * 0.5f);
140 const float DrawPositionY = CanvasRect.Min.Y + 50.0f;
141 Canvas->DrawShadowedString(DrawPositionX, DrawPositionY, *
CurrentlySelectedBone.ToString(), GEngine->GetLargeFont(), FLinearColor::Yellow);
155 if (!HandComponent->HandVisualizerComponent)
159 const FLinearColor SelectedColor = FLinearColor::Yellow;
160 const FLinearColor UnselectedColor = FLinearColor::White;
161 const FVector Location = HandComponent->HandVisualizerComponent->GetComponentLocation();
162 float BoneScale = 1.0f - ((View->ViewLocation - Location).SizeSquared() / FMath::Square(100.0f));
163 BoneScale = FMath::Clamp(BoneScale, 0.2f, 1.0f);
166 PDI->SetHitProxy(newHitProxy);
168 PDI->SetHitProxy(NULL);
169 newHitProxy =
nullptr;
173 BoneScale = 1.0f - ((View->ViewLocation - HandComponent->GetComponentLocation()).SizeSquared() / FMath::Square(100.0f));
174 BoneScale = FMath::Clamp(BoneScale, 0.2f, 1.0f);
175 PDI->SetHitProxy(newHitProxy);
176 PDI->DrawPoint(HandComponent->GetComponentLocation(), FLinearColor::Green, 20.f * BoneScale, SDPG_Foreground);
177 PDI->SetHitProxy(NULL);
178 newHitProxy =
nullptr;
180 if (HandComponent->bUseCustomPoseDeltas)
182 TArray<FTransform> BoneTransforms = HandComponent->HandVisualizerComponent->GetBoneSpaceTransforms();
183 FTransform ParentTrans = HandComponent->HandVisualizerComponent->GetComponentTransform();
185 for (
int i = 1; i < HandComponent->HandVisualizerComponent->GetNumBones(); i++)
187 FName BoneName = HandComponent->HandVisualizerComponent->GetBoneName(i);
188 FTransform BoneTransform = HandComponent->HandVisualizerComponent->GetBoneTransform(i);
189 FVector BoneLoc = BoneTransform.GetLocation();
190 BoneScale = 1.0f - ((View->ViewLocation - BoneLoc).SizeSquared() / FMath::Square(100.0f));
191 BoneScale = FMath::Clamp(BoneScale, 0.1f, 0.9f);
195 PDI->SetHitProxy(newHitProxy);
197 PDI->SetHitProxy(NULL);
198 newHitProxy =
nullptr;
202 if (HandComponent->bShowRangeVisualization)
204 float RangeVisualization = HandComponent->OverrideDistance;
206 if (RangeVisualization <= 0.0f)
208 if (
USceneComponent* Parent = Cast<USceneComponent>(HandComponent->GetAttachParent()))
210 FStructProperty* ObjectProperty = CastField<FStructProperty>(Parent->GetClass()->FindPropertyByName(
"VRGripInterfaceSettings"));
212 AActor* ParentsActor =
nullptr;
215 ParentsActor = Parent->GetOwner();
218 ObjectProperty = CastField<FStructProperty>(Parent->GetOwner()->GetClass()->FindPropertyByName(
"VRGripInterfaceSettings"));
224 UObject* Target = ParentsActor;
226 if (Target ==
nullptr)
233 if (HandComponent->SlotPrefix ==
"VRGripS")
235 RangeVisualization = Curve->SecondarySlotRange;
239 RangeVisualization = Curve->PrimarySlotRange;
247 FBox BoxToDraw = FBox::BuildAABB(FVector::ZeroVector, FVector(RangeVisualization) * HandComponent->GetAttachParent()->GetComponentScale());
248 BoxToDraw.Min += HandComponent->GetComponentLocation();
249 BoxToDraw.Max += HandComponent->GetComponentLocation();
251 DrawWireBox(PDI, BoxToDraw, FColor::Green, 0.0f);
273 FTransform newTrans = FTransform::Identity;
274 if (CurrentlyEditingComponent->bDecoupleMeshPlacement)
276 if (
USceneComponent* ParentComp = CurrentlyEditingComponent->GetAttachParent())
278 newTrans = CurrentlyEditingComponent->HandRelativePlacement * ParentComp->GetComponentTransform();
283 newTrans = CurrentlyEditingComponent->GetHandRelativePlacement() * CurrentlyEditingComponent->GetComponentTransform();
286 OutLocation = newTrans.GetLocation();
293 OutLocation = CurrentlyEditingComponent->HandVisualizerComponent->GetBoneTransform(
CurrentlySelectedBoneIdx).GetLocation();
311 bool bHandled =
false;
321 const FScopedTransaction Transaction(LOCTEXT(
"ChangingComp",
"ChangingComp"));
324 if (!CurrentlyEditingComponent)
329 CurrentlyEditingComponent->Modify();
330 if (
AActor* Owner = CurrentlyEditingComponent->GetOwner())
334 bool bLevelEdit = ViewportClient->IsLevelEditorClient();
336 FTransform CurrentTrans = FTransform::Identity;
340 if (
USceneComponent* ParentComp = CurrentlyEditingComponent->GetAttachParent())
342 CurrentTrans = CurrentlyEditingComponent->
HandRelativePlacement * ParentComp->GetComponentTransform();
347 CurrentTrans = CurrentlyEditingComponent->
GetHandRelativePlacement() * CurrentlyEditingComponent->GetComponentTransform();
350 if (!DeltaTranslate.IsNearlyZero())
352 CurrentTrans.AddToTranslation(DeltaTranslate);
355 if (!DeltaRotate.IsNearlyZero())
357 CurrentTrans.SetRotation(DeltaRotate.Quaternion() * CurrentTrans.GetRotation());
360 if (!DeltaScale.IsNearlyZero())
362 CurrentTrans.MultiplyScale3D(DeltaScale);
367 if (
USceneComponent* ParentComp = CurrentlyEditingComponent->GetAttachParent())
369 CurrentlyEditingComponent->
HandRelativePlacement = CurrentTrans.GetRelativeTransform(ParentComp->GetComponentTransform());
374 CurrentlyEditingComponent->
HandRelativePlacement = CurrentTrans.GetRelativeTransform(CurrentlyEditingComponent->GetComponentTransform());
377 NotifyPropertyModified(CurrentlyEditingComponent, FindFProperty<FProperty>(UHandSocketComponent::StaticClass(), GET_MEMBER_NAME_CHECKED(
UHandSocketComponent, HandRelativePlacement)));
385 if (!CurrentlyEditingComponent || !CurrentlyEditingComponent->HandVisualizerComponent)
390 const FScopedTransaction Transaction(LOCTEXT(
"ChangingComp",
"ChangingComp"));
392 CurrentlyEditingComponent->Modify();
393 if (
AActor* Owner = CurrentlyEditingComponent->GetOwner())
397 bool bLevelEdit = ViewportClient->IsLevelEditorClient();
399 FTransform BoneTrans = CurrentlyEditingComponent->HandVisualizerComponent->GetBoneTransform(
CurrentlySelectedBoneIdx);
400 FTransform NewTrans = BoneTrans;
401 NewTrans.SetRotation(DeltaRotate.Quaternion() * NewTrans.GetRotation());
403 FQuat DeltaRotateMod = NewTrans.GetRelativeTransform(BoneTrans).GetRotation();
404 bool bFoundBone =
false;
410 BonePair.DeltaPose *= DeltaRotateMod;
426 NotifyPropertyModified(CurrentlyEditingComponent, FindFProperty<FProperty>(UHandSocketComponent::StaticClass(), GET_MEMBER_NAME_CHECKED(
UHandSocketComponent, CustomPoseDeltas)));