// Lot CAM2 (CAM2-SPEC-01 rev. 3 ยง 12.4, F2-B) - voir LPRoomBoundsCameraModifier.h #include "LPRoomBoundsCameraModifier.h" #include "Camera/PlayerCameraManager.h" #include "GameFramework/Actor.h" void ULPRoomBoundsCameraModifier::SetBounds(AActor* InViewTarget, bool bInRoom, const FBox& InAllowed, bool bInWall, int32 InWallAxis, double InWallLimit, double InWallSign, const FBox2D& InWallSpan) { BoundedView = InViewTarget; bRoom = bInRoom && InAllowed.IsValid; Allowed = InAllowed; bWall = bInWall && InWallSpan.bIsValid; WallAxis = InWallAxis == 1 ? 1 : 0; WallLimit = InWallLimit; WallSign = InWallSign < 0.0 ? -1.0 : 1.0; WallSpan = InWallSpan; } bool ULPRoomBoundsCameraModifier::ConsumeCorrection(FVector& OutBefore, FVector& OutAfter, FString& OutWhat) { if (!bCorrected) { return false; } OutBefore = CorrectedBefore; OutAfter = CorrectedAfter; OutWhat = CorrectedWhat; bCorrected = false; return true; } void ULPRoomBoundsCameraModifier::SetStudio(AActor* InStudioView, const FVector& InOffset) { StudioView = InStudioView; StudioOffset = InOffset; } bool ULPRoomBoundsCameraModifier::ModifyCamera(float DeltaTime, FMinimalViewInfo& InOutPOV) { // Studio de creation (S1-C++) : la vue des cameras du studio est decalee du meme vecteur que le personnage edite. const AActor* Studio = StudioView.Get(); if (Studio && CameraOwner && CameraOwner->GetViewTarget() == Studio) { InOutPOV.Location += StudioOffset; } // Jamais hors de la vue designee : la cible de vue est relue a chaque image (C1, POV, Overview, C2 ne sont jamais bornes). const AActor* Target = BoundedView.Get(); if (!Target || !CameraOwner || CameraOwner->GetViewTarget() != Target || (!bRoom && !bWall)) { return false; } const FVector Before = InOutPOV.Location; FVector Location = Before; FString What; if (bRoom) { if (Location.X < Allowed.Min.X) { Location.X = Allowed.Min.X; What += TEXT("mur X- "); } if (Location.X > Allowed.Max.X) { Location.X = Allowed.Max.X; What += TEXT("mur X+ "); } if (Location.Y < Allowed.Min.Y) { Location.Y = Allowed.Min.Y; What += TEXT("mur Y- "); } if (Location.Y > Allowed.Max.Y) { Location.Y = Allowed.Max.Y; What += TEXT("mur Y+ "); } if (Location.Z < Allowed.Min.Z) { Location.Z = Allowed.Min.Z; What += TEXT("sol "); } if (Location.Z > Allowed.Max.Z) { Location.Z = Allowed.Max.Z; What += TEXT("plafond "); } } if (bWall) { const int32 Other = 1 - WallAxis; const bool bInSpan = Location[Other] >= WallSpan.Min.X && Location[Other] <= WallSpan.Max.X && Location.Z >= WallSpan.Min.Y && Location.Z <= WallSpan.Max.Y; if (bInSpan && (Location[WallAxis] - WallLimit) * WallSign < 0.0) { Location[WallAxis] = WallLimit; What += TEXT("mur du studio "); } } if (!Location.Equals(Before)) { InOutPOV.Location = Location; bCorrected = true; CorrectedBefore = Before; CorrectedAfter = Location; CorrectedWhat = What.TrimEnd(); } // Faux : les autres modificateurs de la liste s'appliquent ensuite. return false; }