Files
UnrealEngineUWP/Engine/Source/Editor/ViewportInteraction/ActorTransformer.cpp

102 lines
3.6 KiB
C++
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
ViewportInteraction refactoring; miscellaneous VREditor improvements - This merge contains various changes to ViewportInteraction and VR Editor to make things more extensible - Some changes are from Yannick's recent shelved refactoring work, that I've modified and improved upon - EditorWorldManager is gone and replaced by EditorWorldExtensionManager - EditorWorldExtensions are sort of like a more modern version of 'FEdMode', but still a work in progress - Cleaned up access to VREditorMode from other modules, forcing systems to go through EditorWorldExtensions - Overhauled how transforming objects works with world interaction - Viewport interactors can now be used to move objects other than actors around (by implementing an UViewportTransformer, and a FViewportTransformable) - Undo/Redo now works better with inertial transformation! The transaction only ends when objects finally come to rest. - Some initial support for 'grabber sphere' interactor methods has been implemented (not used yet) - Viewport interaction input events now receive the viewport being interacted through - Viewport interaction hover events no longer get a viewport client (because they must be designed to work any number of viewports.) NOTE: This introduces UBT warnings about cyclic module dependencies. We'll have to address this in a different changelist. Other changes: - The active Viewport Interaction 'gizmo mode' is now tied directly to the editor's normal gizmo mode. They share the same state. - New console variable 'VI.UseTransientActors' can be turned off to force editor actors to be created non-transient to make it easier to debug - New console variable 'VI.DragTranslationVelocityStopEpsilon' sets the speed at which transformables will stop have inertia applied to them - Fixed cyclic dependencies with ViewportInteraction and VREditor modules not being tagged properly for UBT - Fixed some issues with transform gizmos not getting release events - Various methods that should have been const were made const - Eliminated duplicate implementation of SpawnTransientSceneActor and DestroyTransientActor; made it static - UnrealEd no longer directly depends on VREditor and ViewportInteraction modules - Engine: AActor::SetIsTemporarilyHiddenInEditor no longer does any work if the object's hidden state didn't change - Slate: Input preprocessor (if bound) now also gets a chance at mouse button down and up events #codereview yannick.lange,lauren.ridge #rb various [CL 3245240 by Mike Fricker in Dev-VREditor branch]
2017-01-03 14:38:17 -05:00
#include "ActorTransformer.h"
#include "ActorViewportTransformable.h"
#include "ViewportWorldInteraction.h"
#include "Engine/Selection.h"
#include "ViewportInteractionAssetContainer.h"
#include "ViewportInteractor.h"
#include "Editor.h"
ViewportInteraction refactoring; miscellaneous VREditor improvements - This merge contains various changes to ViewportInteraction and VR Editor to make things more extensible - Some changes are from Yannick's recent shelved refactoring work, that I've modified and improved upon - EditorWorldManager is gone and replaced by EditorWorldExtensionManager - EditorWorldExtensions are sort of like a more modern version of 'FEdMode', but still a work in progress - Cleaned up access to VREditorMode from other modules, forcing systems to go through EditorWorldExtensions - Overhauled how transforming objects works with world interaction - Viewport interactors can now be used to move objects other than actors around (by implementing an UViewportTransformer, and a FViewportTransformable) - Undo/Redo now works better with inertial transformation! The transaction only ends when objects finally come to rest. - Some initial support for 'grabber sphere' interactor methods has been implemented (not used yet) - Viewport interaction input events now receive the viewport being interacted through - Viewport interaction hover events no longer get a viewport client (because they must be designed to work any number of viewports.) NOTE: This introduces UBT warnings about cyclic module dependencies. We'll have to address this in a different changelist. Other changes: - The active Viewport Interaction 'gizmo mode' is now tied directly to the editor's normal gizmo mode. They share the same state. - New console variable 'VI.UseTransientActors' can be turned off to force editor actors to be created non-transient to make it easier to debug - New console variable 'VI.DragTranslationVelocityStopEpsilon' sets the speed at which transformables will stop have inertia applied to them - Fixed cyclic dependencies with ViewportInteraction and VREditor modules not being tagged properly for UBT - Fixed some issues with transform gizmos not getting release events - Various methods that should have been const were made const - Eliminated duplicate implementation of SpawnTransientSceneActor and DestroyTransientActor; made it static - UnrealEd no longer directly depends on VREditor and ViewportInteraction modules - Engine: AActor::SetIsTemporarilyHiddenInEditor no longer does any work if the object's hidden state didn't change - Slate: Input preprocessor (if bound) now also gets a chance at mouse button down and up events #codereview yannick.lange,lauren.ridge #rb various [CL 3245240 by Mike Fricker in Dev-VREditor branch]
2017-01-03 14:38:17 -05:00
void UActorTransformer::Init( UViewportWorldInteraction* InitViewportWorldInteraction )
{
Super::Init( InitViewportWorldInteraction );
// Find out about selection changes
USelection::SelectionChangedEvent.AddUObject( this, &UActorTransformer::OnActorSelectionChanged );
}
void UActorTransformer::Shutdown()
{
USelection::SelectionChangedEvent.RemoveAll( this );
Super::Shutdown();
}
void UActorTransformer::OnStartDragging(class UViewportInteractor* Interactor)
{
const UViewportInteractionAssetContainer& AssetContainer = ViewportWorldInteraction->GetAssetContainer();
const FVector& SoundLocation = Interactor->GetInteractorData().GizmoLastTransform.GetLocation();
const EViewportInteractionDraggingMode DraggingMode = Interactor->GetDraggingMode();
if (DraggingMode == EViewportInteractionDraggingMode::TransformablesWithGizmo)
{
ViewportWorldInteraction->PlaySound(AssetContainer.GizmoHandleSelectedSound, SoundLocation);
}
else if (DraggingMode == EViewportInteractionDraggingMode::TransformablesFreely ||
DraggingMode == EViewportInteractionDraggingMode::TransformablesAtLaserImpact)
{
ViewportWorldInteraction->PlaySound(AssetContainer.SelectionStartDragSound, SoundLocation);
}
}
void UActorTransformer::OnStopDragging(class UViewportInteractor* Interactor)
{
const UViewportInteractionAssetContainer& AssetContainer = ViewportWorldInteraction->GetAssetContainer();
const FVector& SoundLocation = Interactor->GetInteractorData().GizmoLastTransform.GetLocation();
const EViewportInteractionDraggingMode DraggingMode = Interactor->GetDraggingMode();
if (DraggingMode == EViewportInteractionDraggingMode::TransformablesWithGizmo)
{
ViewportWorldInteraction->PlaySound(AssetContainer.GizmoHandleDropSound, SoundLocation);
}
else if (DraggingMode == EViewportInteractionDraggingMode::TransformablesFreely ||
DraggingMode == EViewportInteractionDraggingMode::TransformablesAtLaserImpact)
{
ViewportWorldInteraction->PlaySound(AssetContainer.SelectionDropSound, SoundLocation);
}
}
void UActorTransformer::OnActorSelectionChanged( UObject* ChangedObject )
ViewportInteraction refactoring; miscellaneous VREditor improvements - This merge contains various changes to ViewportInteraction and VR Editor to make things more extensible - Some changes are from Yannick's recent shelved refactoring work, that I've modified and improved upon - EditorWorldManager is gone and replaced by EditorWorldExtensionManager - EditorWorldExtensions are sort of like a more modern version of 'FEdMode', but still a work in progress - Cleaned up access to VREditorMode from other modules, forcing systems to go through EditorWorldExtensions - Overhauled how transforming objects works with world interaction - Viewport interactors can now be used to move objects other than actors around (by implementing an UViewportTransformer, and a FViewportTransformable) - Undo/Redo now works better with inertial transformation! The transaction only ends when objects finally come to rest. - Some initial support for 'grabber sphere' interactor methods has been implemented (not used yet) - Viewport interaction input events now receive the viewport being interacted through - Viewport interaction hover events no longer get a viewport client (because they must be designed to work any number of viewports.) NOTE: This introduces UBT warnings about cyclic module dependencies. We'll have to address this in a different changelist. Other changes: - The active Viewport Interaction 'gizmo mode' is now tied directly to the editor's normal gizmo mode. They share the same state. - New console variable 'VI.UseTransientActors' can be turned off to force editor actors to be created non-transient to make it easier to debug - New console variable 'VI.DragTranslationVelocityStopEpsilon' sets the speed at which transformables will stop have inertia applied to them - Fixed cyclic dependencies with ViewportInteraction and VREditor modules not being tagged properly for UBT - Fixed some issues with transform gizmos not getting release events - Various methods that should have been const were made const - Eliminated duplicate implementation of SpawnTransientSceneActor and DestroyTransientActor; made it static - UnrealEd no longer directly depends on VREditor and ViewportInteraction modules - Engine: AActor::SetIsTemporarilyHiddenInEditor no longer does any work if the object's hidden state didn't change - Slate: Input preprocessor (if bound) now also gets a chance at mouse button down and up events #codereview yannick.lange,lauren.ridge #rb various [CL 3245240 by Mike Fricker in Dev-VREditor branch]
2017-01-03 14:38:17 -05:00
{
TArray<TUniquePtr<FViewportTransformable>> NewTransformables;
USelection* ActorSelectionSet = GEditor->GetSelectedActors();
static TArray<UObject*> SelectedActorObjects;
SelectedActorObjects.Reset();
ActorSelectionSet->GetSelectedObjects( AActor::StaticClass(), /* Out */ SelectedActorObjects );
for( UObject* SelectedActorObject : SelectedActorObjects )
{
AActor* SelectedActor = Cast<AActor>( SelectedActorObject );
if( SelectedActor != nullptr )
{
// We only are able to move objects that have a root scene component
if( SelectedActor->GetRootComponent() != nullptr )
{
FActorViewportTransformable* Transformable = new FActorViewportTransformable();
ViewportInteraction refactoring; miscellaneous VREditor improvements - This merge contains various changes to ViewportInteraction and VR Editor to make things more extensible - Some changes are from Yannick's recent shelved refactoring work, that I've modified and improved upon - EditorWorldManager is gone and replaced by EditorWorldExtensionManager - EditorWorldExtensions are sort of like a more modern version of 'FEdMode', but still a work in progress - Cleaned up access to VREditorMode from other modules, forcing systems to go through EditorWorldExtensions - Overhauled how transforming objects works with world interaction - Viewport interactors can now be used to move objects other than actors around (by implementing an UViewportTransformer, and a FViewportTransformable) - Undo/Redo now works better with inertial transformation! The transaction only ends when objects finally come to rest. - Some initial support for 'grabber sphere' interactor methods has been implemented (not used yet) - Viewport interaction input events now receive the viewport being interacted through - Viewport interaction hover events no longer get a viewport client (because they must be designed to work any number of viewports.) NOTE: This introduces UBT warnings about cyclic module dependencies. We'll have to address this in a different changelist. Other changes: - The active Viewport Interaction 'gizmo mode' is now tied directly to the editor's normal gizmo mode. They share the same state. - New console variable 'VI.UseTransientActors' can be turned off to force editor actors to be created non-transient to make it easier to debug - New console variable 'VI.DragTranslationVelocityStopEpsilon' sets the speed at which transformables will stop have inertia applied to them - Fixed cyclic dependencies with ViewportInteraction and VREditor modules not being tagged properly for UBT - Fixed some issues with transform gizmos not getting release events - Various methods that should have been const were made const - Eliminated duplicate implementation of SpawnTransientSceneActor and DestroyTransientActor; made it static - UnrealEd no longer directly depends on VREditor and ViewportInteraction modules - Engine: AActor::SetIsTemporarilyHiddenInEditor no longer does any work if the object's hidden state didn't change - Slate: Input preprocessor (if bound) now also gets a chance at mouse button down and up events #codereview yannick.lange,lauren.ridge #rb various [CL 3245240 by Mike Fricker in Dev-VREditor branch]
2017-01-03 14:38:17 -05:00
NewTransformables.Add( TUniquePtr<FViewportTransformable>( Transformable ) );
ViewportInteraction refactoring; miscellaneous VREditor improvements - This merge contains various changes to ViewportInteraction and VR Editor to make things more extensible - Some changes are from Yannick's recent shelved refactoring work, that I've modified and improved upon - EditorWorldManager is gone and replaced by EditorWorldExtensionManager - EditorWorldExtensions are sort of like a more modern version of 'FEdMode', but still a work in progress - Cleaned up access to VREditorMode from other modules, forcing systems to go through EditorWorldExtensions - Overhauled how transforming objects works with world interaction - Viewport interactors can now be used to move objects other than actors around (by implementing an UViewportTransformer, and a FViewportTransformable) - Undo/Redo now works better with inertial transformation! The transaction only ends when objects finally come to rest. - Some initial support for 'grabber sphere' interactor methods has been implemented (not used yet) - Viewport interaction input events now receive the viewport being interacted through - Viewport interaction hover events no longer get a viewport client (because they must be designed to work any number of viewports.) NOTE: This introduces UBT warnings about cyclic module dependencies. We'll have to address this in a different changelist. Other changes: - The active Viewport Interaction 'gizmo mode' is now tied directly to the editor's normal gizmo mode. They share the same state. - New console variable 'VI.UseTransientActors' can be turned off to force editor actors to be created non-transient to make it easier to debug - New console variable 'VI.DragTranslationVelocityStopEpsilon' sets the speed at which transformables will stop have inertia applied to them - Fixed cyclic dependencies with ViewportInteraction and VREditor modules not being tagged properly for UBT - Fixed some issues with transform gizmos not getting release events - Various methods that should have been const were made const - Eliminated duplicate implementation of SpawnTransientSceneActor and DestroyTransientActor; made it static - UnrealEd no longer directly depends on VREditor and ViewportInteraction modules - Engine: AActor::SetIsTemporarilyHiddenInEditor no longer does any work if the object's hidden state didn't change - Slate: Input preprocessor (if bound) now also gets a chance at mouse button down and up events #codereview yannick.lange,lauren.ridge #rb various [CL 3245240 by Mike Fricker in Dev-VREditor branch]
2017-01-03 14:38:17 -05:00
Transformable->ActorWeakPtr = SelectedActor;
Transformable->StartTransform = SelectedActor->GetTransform();
for (UViewportInteractor* Interactor : ViewportWorldInteraction->GetInteractors())
{
if (Interactor->CanCarry())
{
Transformable->bShouldBeCarried = true;
break;
}
}
}
}
ViewportInteraction refactoring; miscellaneous VREditor improvements - This merge contains various changes to ViewportInteraction and VR Editor to make things more extensible - Some changes are from Yannick's recent shelved refactoring work, that I've modified and improved upon - EditorWorldManager is gone and replaced by EditorWorldExtensionManager - EditorWorldExtensions are sort of like a more modern version of 'FEdMode', but still a work in progress - Cleaned up access to VREditorMode from other modules, forcing systems to go through EditorWorldExtensions - Overhauled how transforming objects works with world interaction - Viewport interactors can now be used to move objects other than actors around (by implementing an UViewportTransformer, and a FViewportTransformable) - Undo/Redo now works better with inertial transformation! The transaction only ends when objects finally come to rest. - Some initial support for 'grabber sphere' interactor methods has been implemented (not used yet) - Viewport interaction input events now receive the viewport being interacted through - Viewport interaction hover events no longer get a viewport client (because they must be designed to work any number of viewports.) NOTE: This introduces UBT warnings about cyclic module dependencies. We'll have to address this in a different changelist. Other changes: - The active Viewport Interaction 'gizmo mode' is now tied directly to the editor's normal gizmo mode. They share the same state. - New console variable 'VI.UseTransientActors' can be turned off to force editor actors to be created non-transient to make it easier to debug - New console variable 'VI.DragTranslationVelocityStopEpsilon' sets the speed at which transformables will stop have inertia applied to them - Fixed cyclic dependencies with ViewportInteraction and VREditor modules not being tagged properly for UBT - Fixed some issues with transform gizmos not getting release events - Various methods that should have been const were made const - Eliminated duplicate implementation of SpawnTransientSceneActor and DestroyTransientActor; made it static - UnrealEd no longer directly depends on VREditor and ViewportInteraction modules - Engine: AActor::SetIsTemporarilyHiddenInEditor no longer does any work if the object's hidden state didn't change - Slate: Input preprocessor (if bound) now also gets a chance at mouse button down and up events #codereview yannick.lange,lauren.ridge #rb various [CL 3245240 by Mike Fricker in Dev-VREditor branch]
2017-01-03 14:38:17 -05:00
}
const bool bNewObjectsSelected = true;
ViewportWorldInteraction->SetTransformables( MoveTemp( NewTransformables ), bNewObjectsSelected );
}