Skip to content

Commit

Permalink
Add FirstActor pivot setting
Browse files Browse the repository at this point in the history
  • Loading branch information
devhyper committed Oct 19, 2024
1 parent e92c2bf commit e16b6fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions Source/PrefabricatorRuntime/Private/Asset/PrefabricatorAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ FVector FPrefabricatorAssetUtils::FindPivot(const TArray<AActor*>& InActors)
FBox ActorBounds = FPrefabTools::GetPrefabBounds(Actor, false);
Bounds += ActorBounds;
}

AActor* FirstActor = InActors[0];

switch (GetDefault< UPrefabricatorSettings>()->PivotPosition)
switch (GetDefault<UPrefabricatorSettings>()->PivotPosition)
{
case EPrefabricatorPivotPosition::ExtremeLeft:
Pivot = Bounds.GetCenter() - Bounds.GetExtent();
Expand All @@ -44,16 +46,14 @@ FVector FPrefabricatorAssetUtils::FindPivot(const TArray<AActor*>& InActors)
case EPrefabricatorPivotPosition::Center:
Pivot = Bounds.GetCenter();
break;
case EPrefabricatorPivotPosition::FirstActor:
Pivot = FirstActor->GetActorLocation();
return Pivot;
default:;
}
Pivot.Z = Bounds.Min.Z;
}

TSharedPtr<IPrefabricatorService> Service = FPrefabricatorService::Get();
if (Service.IsValid()) {
Pivot = Service->SnapToGrid(Pivot);
}

return Pivot;
}

Expand Down
3 changes: 2 additions & 1 deletion Source/PrefabricatorRuntime/Public/PrefabricatorSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ enum class EPrefabricatorPivotPosition : uint8
{
ExtremeLeft,
ExtremeRight,
Center
Center,
FirstActor
};

/**
Expand Down

0 comments on commit e16b6fa

Please sign in to comment.