mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-05 07:08:46 +00:00
CogEngine: Selection prioritize another actor than the selected actor unless only touching the selected actor.
This commit is contained in:
@@ -407,17 +407,27 @@ void UCogEngineWindow_Selection::TickSelectionMode()
|
|||||||
FVector WorldOrigin, WorldDirection;
|
FVector WorldOrigin, WorldDirection;
|
||||||
if (UGameplayStatics::DeprojectScreenToWorld(PlayerController, FCogImguiHelper::ToVector2D(ImGui::GetMousePos()), WorldOrigin, WorldDirection))
|
if (UGameplayStatics::DeprojectScreenToWorld(PlayerController, FCogImguiHelper::ToVector2D(ImGui::GetMousePos()), WorldOrigin, WorldDirection))
|
||||||
{
|
{
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
|
// Prioritize another actor than the selected actor unless we only touch the selected actor.
|
||||||
|
//--------------------------------------------------------------------------------------------------------
|
||||||
TArray<AActor*> IgnoreList;
|
TArray<AActor*> IgnoreList;
|
||||||
|
IgnoreList.Add(FCogDebugSettings::GetSelection());
|
||||||
|
|
||||||
FHitResult HitResult;
|
FHitResult HitResult;
|
||||||
if (UKismetSystemLibrary::LineTraceSingle(GetWorld(), WorldOrigin, WorldOrigin + WorldDirection * 10000, TraceType, false, IgnoreList, EDrawDebugTrace::None, HitResult, true))
|
for (int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
if (HitResult.GetActor() != nullptr)
|
if (UKismetSystemLibrary::LineTraceSingle(GetWorld(), WorldOrigin, WorldOrigin + WorldDirection * 10000, TraceType, false, IgnoreList, EDrawDebugTrace::None, HitResult, true))
|
||||||
{
|
{
|
||||||
if (SelectedActorClass == nullptr || HitResult.GetActor()->GetClass()->IsChildOf(SelectedActorClass))
|
if (SelectedActorClass == nullptr || HitResult.GetActor()->GetClass()->IsChildOf(SelectedActorClass))
|
||||||
{
|
{
|
||||||
HoveredActor = HitResult.GetActor();
|
HoveredActor = HitResult.GetActor();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------
|
||||||
|
// The second time we accept the selected actor
|
||||||
|
//------------------------------------------------
|
||||||
|
IgnoreList.Empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -467,6 +477,7 @@ void UCogEngineWindow_Selection::DrawActorFrame(const AActor& Actor)
|
|||||||
if (const UPrimitiveComponent* PrimitiveComponent = Cast<UPrimitiveComponent>(Actor.GetRootComponent()))
|
if (const UPrimitiveComponent* PrimitiveComponent = Cast<UPrimitiveComponent>(Actor.GetRootComponent()))
|
||||||
{
|
{
|
||||||
PrimitiveFound = true;
|
PrimitiveFound = true;
|
||||||
|
|
||||||
Bounds += PrimitiveComponent->Bounds.GetBox();
|
Bounds += PrimitiveComponent->Bounds.GetBox();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -643,9 +654,3 @@ void UCogEngineWindow_Selection::SetGlobalSelection(AActor* Value) const
|
|||||||
{
|
{
|
||||||
FCogDebugSettings::SetSelection(GetWorld(), Value);
|
FCogDebugSettings::SetSelection(GetWorld(), Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
|
||||||
AActor* UCogEngineWindow_Selection::GetGlobalSelection(AActor* Value) const
|
|
||||||
{
|
|
||||||
return FCogDebugSettings::GetSelection();
|
|
||||||
}
|
|
||||||
@@ -58,8 +58,6 @@ protected:
|
|||||||
|
|
||||||
virtual void SetGlobalSelection(AActor* Value) const;
|
virtual void SetGlobalSelection(AActor* Value) const;
|
||||||
|
|
||||||
virtual AActor* GetGlobalSelection(AActor* Value) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
TSubclassOf<AActor> GetSelectedActorClass() const;
|
TSubclassOf<AActor> GetSelectedActorClass() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user