Files
ryan schmidt 74b3c229b3 ModelingMode: Mesh Element Selection system evolution.
Refactor most of FDynamicMeshSelector into FDynamicMeshSelectorBase, FDynamicMeshSelector is now a subclass.
Move the DynamicMeshTransformer from cpp to FBasicDynamicMeshSelectionTransformer in header.
Add FVolumeSelector and FStaticMeshSelector which are derived from FBaseDynamicMeshSelector.
Add ability to filter selection queries/edits by TopologyID in FGeometrySelectionEditor. This is necesary for polygroup and polygroup-edge selections as their encoding includes an arbitrary TriangleID paired w/ the TopologyID.
UGeometrySelectionManager now manages this TopologyID filtering on selection editors it creates/updates
Add concept of "Tracked" selection changes to UGeometrySelectionManager, allows a single selection FChange to be constructed incrementally, eg like with a brush. Add a variant of raycast-selection-update that can be run inside a tracked change.
#rb none
#preflight 6388f0cf4b2f03a7d761ccef

[CL 23361634 by ryan schmidt in ue5-main branch]
2022-12-01 16:11:52 -05:00

151 lines
3.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "InputBehaviorSet.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(InputBehaviorSet)
UInputBehaviorSet::UInputBehaviorSet()
{
}
UInputBehaviorSet::~UInputBehaviorSet()
{
}
bool UInputBehaviorSet::IsEmpty() const
{
return Behaviors.Num() == 0;
}
void UInputBehaviorSet::Add(UInputBehavior* Behavior, void* Source, const FString& Group)
{
//if (source == null)
// source = DefaultSource;
FBehaviorInfo Info;
Info.Behavior = Behavior;
Info.Source = Source;
Info.Group = Group;
Behaviors.Add(Info);
BehaviorsModified();
}
void UInputBehaviorSet::Add(const UInputBehaviorSet* OtherSet, void* NewSource, const FString& NewGroup)
{
for (const FBehaviorInfo& OtherInfo : OtherSet->Behaviors)
{
FBehaviorInfo Info;
Info.Behavior = OtherInfo.Behavior;
Info.Source = (NewSource == nullptr) ? OtherInfo.Source : NewSource;
Info.Group = (NewGroup.IsEmpty()) ? OtherInfo.Group : NewGroup;
Behaviors.Add(Info);
}
if (OtherSet->Behaviors.Num() > 0)
{
BehaviorsModified();
}
}
bool UInputBehaviorSet::Remove(UInputBehavior* behavior)
{
int32 idx = Behaviors.IndexOfByPredicate(
[behavior] (const FBehaviorInfo& b) { return b.Behavior == behavior; }
);
if ( idx != INDEX_NONE ) {
Behaviors.RemoveAt(idx);
BehaviorsModified();
return true;
}
return false;
}
bool UInputBehaviorSet::RemoveByGroup(const FString& Group)
{
int RemovedCount = Behaviors.RemoveAll(
[Group](const FBehaviorInfo& b) { return b.Group == Group; }
);
if (RemovedCount > 0)
{
BehaviorsModified();
}
return (RemovedCount > 0);
}
bool UInputBehaviorSet::RemoveBySource(void* Source)
{
int RemovedCount = Behaviors.RemoveAll(
[Source](const FBehaviorInfo& b) { return b.Source == Source; }
);
if (RemovedCount > 0)
{
BehaviorsModified();
}
return (RemovedCount > 0);
}
void UInputBehaviorSet::RemoveAll()
{
Behaviors.Reset();
BehaviorsModified();
}
void UInputBehaviorSet::CollectWantsCapture(const FInputDeviceState& input, TArray<FInputCaptureRequest>& result)
{
for (FBehaviorInfo& BehaviorInfo : Behaviors)
{
// only call WantsCapture if the Behavior supports the current input device
if (SupportsInputType(BehaviorInfo.Behavior, input))
{
FInputCaptureRequest request = BehaviorInfo.Behavior->WantsCapture(input);
if ( request.Type != EInputCaptureRequestType::Ignore )
{
request.Owner = BehaviorInfo.Source;
result.Add(request);
}
}
}
}
void UInputBehaviorSet::CollectWantsHoverCapture(const FInputDeviceState& input, TArray<FInputCaptureRequest>& result)
{
for (FBehaviorInfo& BehaviorInfo : Behaviors)
{
// only call WantsCapture if the Behavior supports the current input device
if (BehaviorInfo.Behavior->WantsHoverEvents() && SupportsInputType(BehaviorInfo.Behavior, input))
{
FInputCaptureRequest request = BehaviorInfo.Behavior->WantsHoverCapture(input);
if (request.Type != EInputCaptureRequestType::Ignore)
{
request.Owner = BehaviorInfo.Source;
result.Add(request);
}
}
}
}
void UInputBehaviorSet::BehaviorsModified()
{
// sort by priority
Behaviors.StableSort();
//send some kind of event...
//FUtil.SafeSendAnyEvent(OnSetChanged, this);
}