Space Plunder
Loading...
Searching...
No Matches
ULineOfSightComponent Class Reference

#include <LineOfSightComponent.h>

Inheritance diagram for ULineOfSightComponent:

Public Member Functions

 ULineOfSightComponent (const FObjectInitializer &ObjectInitializer=FObjectInitializer::Get())
 
virtual void TickComponent (float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override
 
virtual void BeginPlay () override
 
virtual void BeginDestroy () override
 
 UPROPERTY (EditAnywhere, Category="LineOfSight Component", meta=(DisplayName="HitEveryFrameEvent (Deprecated)")) bool HitEveryFrameEvent
 
void SetAngle1 (const float NewAngle)
 
void SetAngle2 (const float NewAngle)
 
FORCEINLINE float GetAngle1 () const
 
FORCEINLINE float GetAngle2 () const
 
void SetRadius1 (const float NewRadius)
 
void SetRadius2 (const float NewRadius)
 
FORCEINLINE float GetRadius1 () const
 
FORCEINLINE float GetRadius2 () const
 
void SetStandardCollision (const bool NewStatus)
 
void InterpAngle ()
 
void StartInterpAngle (const float NewAngle1, const float NewAngle2, const float Speed1, const float Speed2)
 
void StopInterpAngle ()
 
void InterpRadius ()
 
void StartInterpRadius (const float NewRadius1, const float NewRadius2, const float Speed1, const float Speed2)
 
void StopInterpRadius ()
 
FORCEINLINE uint8 GetHitEveryFrame () const
 
FORCEINLINE uint8 GetBeginAndEndOverlapEvent () const
 
void SetHitEveryFrame (const bool NewValue)
 
void SetBeginAndEndOverlapEvent (const bool NewValue)
 
void SetTraceChannel (const ETraceTypeQuery NewTraceChanne)
 
void SetTraceComplex (const bool NewValue)
 
void AddIgnoredActor (UPARAM(ref) const AActor *ActorToIgnore)
 
void AddActorsToIgnore (UPARAM(ref) TArray< AActor * > &ActorsToIgnore)
 
void ClearActorsToIgnore (const bool NewIgnoreSelf=true)
 
void SetIgnoreSelf (const bool NewValueIgnoreSelf)
 
void BuildArcVectorLenght ()
 
void BuildArcVectorLenghtFlat ()
 
void BuildMesh ()
 
void StartLineTrace (ETraceTypeQuery TraceChannel, int32 NumberOfLines=60)
 
void ZStartCloneTo (ULineOfSightComponent *OtherLineOfSightComponent)
 
void ZStopCloneTo ()
 
void CloneTick ()
 
void StopLineTrace ()
 
void StartBuildMesh ()
 
void StopBuildMesh ()
 
void SetTickEnable (const bool Enable)
 
void SetVisibilityOfMesh (const bool NewVisibility)
 
bool MeshIsBuilt () const
 
bool LineOfSightIsActive () const
 
void SetTolerance (const float NewTolerance)
 
void RotateInRange ()
 
void RotateToAngle ()
 
void StartRotateInRangeAxis (const EAxisTypeComp Axis, const float Angle, float Speed, const ETypeRotation TypeRotation, const bool NegativeToPositive)
 
void StartRotateToAngleAxis (const EAxisTypeComp Axis, const float Angle, const float Speed, const ETypeRotation TypeRotation, const bool AddToCurrent=true)
 
void StartRotateToActor (const EAxisTypeComp Axis, AActor *Actor, const float Speed)
 
void StopRotateToAngle ()
 
void StopRotateInRange ()
 
void StopAllRotate ()
 
float GetAxisValue (EAxisTypeComp Axis, FRotator &Rotator)
 
FRotator SetAxisValue (EAxisTypeComp Axis, const float Value, FRotator &Rotator)
 
FRotator FindAngleRotate (UPARAM(ref) AActor *&Actor)
 
void SetGeometryType (const ETypeArc NewType)
 
void SetNormals (const FVector Normals)
 

Public Attributes

FHitStart BeginOverlap
 
FHitEnd EndOverlap
 
FHitEveryFrame HitEveryFrame
 
FRotateToAngleEnd RotateToAngleEnd
 
ETypeArc GeometryType
 
float Angle1
 
float Angle2
 
float Radius1
 
float Radius2
 
ETypeTriangle Type_Of_Triangles
 
bool ReverseArch1
 
bool IgnoreSelf
 
bool BeginAndEndOverlapEvent
 
bool OnlyOneArc
 
bool Only_Z_Rotation
 
bool TraceComplex
 
UMaterialInterface * Material
 
bool UseStandardCollision
 
bool bInterpAngleBool
 
float AngleForInterpAngle1
 
float AngleForInterpAngle2
 
float SpeedInterpAngle1
 
float SpeedInterpAngle2
 
bool InterpRadiusBool
 
float Radius1ForInterp
 
float Radius2ForInterp
 
float SpeedInterpRadius
 
float SpeedInterpRadius1
 
float SpeedInterpRadius2
 
ETypeTriangle TypeTriangle
 
bool FlipDirection
 
FCollisionQueryParams TraceParams
 
ECollisionChannel TraceChanne2
 
bool Cloned
 
ULineOfSightComponentLineOfSightComponentForClone
 
int16 SlackArray
 
uint8 bRotateInRangeActive
 
uint8 bRotateToAngleActive
 
FRotator AngleRotateRot
 
FRotator AngleRotateRot2
 
FQuat AngleRotateQuat
 
FQuat AngleRotateQuat2
 
float SpeedRotate
 
float Tolerance = 0.0000005f
 
EAxisTypeComp AxisForRotateAngle
 
ETypeRotation TypeRotationGlobal
 

Protected Attributes

bool bBuildMeshActive
 
bool StartLineTraceActive
 
TArray< FHitResult > WasStartOverlapArray
 
TArray< FVector > PointArray1
 
TArray< FVector > NormalVertex
 
TArray< FVector2D > UV0
 
TArray< FLinearColor > VertexColors
 
TArray< FProcMeshTangent > Tangents
 
TArray< int32 > Triangle
 

Private Attributes

int Number_Of_Lines
 

Constructor & Destructor Documentation

◆ ULineOfSightComponent()

ULineOfSightComponent::ULineOfSightComponent ( const FObjectInitializer & ObjectInitializer = FObjectInitializer::Get())
14 : Super(ObjectInitializer)
15{
16 PrimaryComponentTick.bCanEverTick = true;
17 PrimaryComponentTick.bStartWithTickEnabled = true;
18 bAutoActivate = true;
19 bTickInEditor = true;
20
21 Angle1 = 40;
22 Angle2 = 30;
23 Radius1 = 70;
24 Radius2 = 1000;
25 Number_Of_Lines = 60;
26 Type_Of_Triangles = ETypeTriangle::E_LR;
27 ReverseArch1 = false;
28 OnlyOneArc = false;
29 Only_Z_Rotation = false;
30 TraceComplex = false;
31 IgnoreSelf = true;
32 HitEveryFrameEvent = false;
34
35 FlipDirection = false;
36 bBuildMeshActive = false;
37 bUseComplexAsSimpleCollision = false;
38 CastShadow = false;
39 SetCollisionProfileName(TEXT("NoCollision"));
40 SetGenerateOverlapEvents(false);
41 SetCanEverAffectNavigation(false);
42 bVisibleInReflectionCaptures = false;
43 bVisibleInRayTracing = false;
44 bReceiveMobileCSMShadows = false;
45
46 GeometryType = ETypeArc::Arc_VectorLenght;
49}
bool TraceComplex
Definition LineOfSightComponent.h:123
ULineOfSightComponent * LineOfSightComponentForClone
Definition LineOfSightComponent.h:265
ETypeTriangle Type_Of_Triangles
Definition LineOfSightComponent.h:98
float Angle1
Definition LineOfSightComponent.h:86
float Radius2
Definition LineOfSightComponent.h:95
float Radius1
Definition LineOfSightComponent.h:92
bool Only_Z_Rotation
Definition LineOfSightComponent.h:120
ETypeArc GeometryType
Definition LineOfSightComponent.h:83
bool ReverseArch1
Definition LineOfSightComponent.h:101
bool UseStandardCollision
Definition LineOfSightComponent.h:161
bool BeginAndEndOverlapEvent
Definition LineOfSightComponent.h:113
bool IgnoreSelf
Definition LineOfSightComponent.h:105
bool FlipDirection
Definition LineOfSightComponent.h:211
bool OnlyOneArc
Definition LineOfSightComponent.h:117
float Angle2
Definition LineOfSightComponent.h:89
bool bBuildMeshActive
Definition LineOfSightComponent.h:373
int Number_Of_Lines
Definition LineOfSightComponent.h:399

Member Function Documentation

◆ AddActorsToIgnore()

void ULineOfSightComponent::AddActorsToIgnore ( UPARAM(ref) TArray< AActor * > & ActorsToIgnore)
1083{
1084 TraceParams.AddIgnoredActors(ActorsToIgnore);
1085}
FCollisionQueryParams TraceParams
Definition LineOfSightComponent.h:225

◆ AddIgnoredActor()

void ULineOfSightComponent::AddIgnoredActor ( UPARAM(ref) const AActor * ActorToIgnore)
1088{
1089 TraceParams.AddIgnoredActor(ActorToIgnore);
1090}

◆ BeginDestroy()

void ULineOfSightComponent::BeginDestroy ( )
overridevirtual
378{
379 Super::BeginDestroy();
380 TraceParams.ClearIgnoredActors();
381 PointArray1.Empty();
382 WasStartOverlapArray.Empty();
383}
TArray< FVector > PointArray1
Definition LineOfSightComponent.h:380
TArray< FHitResult > WasStartOverlapArray
Definition LineOfSightComponent.h:377

◆ BeginPlay()

void ULineOfSightComponent::BeginPlay ( )
overridevirtual
52{
53 Super::BeginPlay();
54
55}

◆ BuildArcVectorLenght()

void ULineOfSightComponent::BuildArcVectorLenght ( )
447{
448 TRACE_CPUPROFILER_EVENT_SCOPE(LineOfSight_Trace);
449 SCOPE_CYCLE_COUNTER(STAT_LineOfSightLineTrace);
450
451 PointArray1.Reset(SlackArray);
452 if (OnlyOneArc)
453 {
454 PointArray1.Add(FVector::ZeroVector);
455 }
456
457 TSet<TWeakObjectPtr<AActor>> AllHitActorTSet;
458
459 float CurrentAngle1;
460 if (!ReverseArch1)
461 {
462 CurrentAngle1 = Angle1 * -1;
463 }
464 else
465 {
466 CurrentAngle1 = (180 - Angle1) + (Angle1 * 2);
467 }
468
469 const float IncrementAngle1 = (Angle1 * 2) / Number_Of_Lines;
470 float CurrentAngle2 = Angle2 * -1;
471 const float IncrementAngle2 = (Angle2 * 2) / Number_Of_Lines;
472
473 const FVector ComponentLocation = GetComponentLocation();
474
475 for (int i = 0; i <= Number_Of_Lines; ++i)
476 {
477 // arc 1
478 FVector ClearPosition1;
479 FVector Point1;
480
481 if (OnlyOneArc)
482 {
483 ClearPosition1 = FVector::ZeroVector;
484 Point1 = ComponentLocation;
485 }
486 else
487 {
488 float pos1X = FMath::Cos(FMath::DegreesToRadians(CurrentAngle1)) * Radius1; // x
489 float pos1Y = FMath::Sin(FMath::DegreesToRadians(CurrentAngle1)) * Radius1; // y
490
491 ClearPosition1 = FVector(pos1X, pos1Y, 0);
492 pos1X += ComponentLocation.X;
493 pos1Y += ComponentLocation.Y;
494 Point1 = FVector(pos1X, pos1Y, ComponentLocation.Z);
495 }
496
497 // arc 2
498 float pos2X = FMath::Cos(FMath::DegreesToRadians(CurrentAngle2)) * Radius2; // x
499 float pos2Y = FMath::Sin(FMath::DegreesToRadians(CurrentAngle2)) * Radius2; // y
500
501 FVector ClearPosition2(pos2X, pos2Y, 0);
502 pos2X += ComponentLocation.X;
503 pos2Y += ComponentLocation.Y;
504 FVector Point2(pos2X, pos2Y, ComponentLocation.Z);
505
506 const FVector direction1 = (Point1 - ComponentLocation).GetSafeNormal(); // Direction
507 const FVector direction2 = (Point2 - ComponentLocation).GetSafeNormal();
508
509 FVector directionRotate1;
510 FVector directionRotate2;
511 const FRotator RotationComponent = GetComponentRotation();
512
513 // Point 1
514 if (OnlyOneArc)
515 {
516 directionRotate1 = ComponentLocation;
517 }
518 else
519 {
520 if (Only_Z_Rotation)
521 {
522 directionRotate1 = direction1.RotateAngleAxis(RotationComponent.Yaw, FVector(0, 0, 1)); // Z
523 }
524 else
525 {
526 //directionRotate1 = UKismetMathLibrary::GreaterGreater_VectorRotator(direction1, RotationComponent); // SSE Version
527 directionRotate1 = direction1.RotateAngleAxis(RotationComponent.Roll * -1, FVector(1, 0, 0)); // X
528 directionRotate1 = directionRotate1.RotateAngleAxis(RotationComponent.Pitch * -1, FVector(0, 1, 0)); // Y
529 directionRotate1 = directionRotate1.RotateAngleAxis(RotationComponent.Yaw, FVector(0, 0, 1)); // Z
530 }
531 directionRotate1 = (directionRotate1 * Radius1) + ComponentLocation;
532 }
533
534 // Point 2
535 if (Only_Z_Rotation)
536 {
537 directionRotate2 = direction2.RotateAngleAxis(RotationComponent.Yaw, FVector(0, 0, 1)); // Z
538 }
539 else
540 {
541 //directionRotate2 = UKismetMathLibrary::GreaterGreater_VectorRotator(direction2, RotationComponent); // SSE Version
542 directionRotate2 = direction2.RotateAngleAxis(RotationComponent.Roll * -1, FVector(1, 0, 0)); // X
543 directionRotate2 = directionRotate2.RotateAngleAxis(RotationComponent.Pitch * -1, FVector(0, 1, 0)); // Y
544 directionRotate2 = directionRotate2.RotateAngleAxis(RotationComponent.Yaw, FVector(0, 0, 1)); // Z
545 }
546 directionRotate2 = (directionRotate2 * Radius2) + ComponentLocation;
547
548 TArray<FHitResult> HitResult;
549 const bool hit = GetWorld()->LineTraceMultiByChannel(HitResult, directionRotate1, directionRotate2, TraceChanne2, TraceParams);
550
551 if (hit)
552 {
553 const float distance = UKismetMathLibrary::Vector_Distance(directionRotate1, HitResult.Last().Location);
554 //const float distance = FVector::Distance(directionRotate1, HitResult.Last().Location);
555
556 //const FVector DirectionHit = UKismetMathLibrary::GetDirectionUnitVector(ClearPosition1, ClearPosition2);
557 const FVector DirectionHit = (ClearPosition2 - ClearPosition1).GetSafeNormal();
558
559 const FVector PositionHit = (DirectionHit * distance) + ClearPosition1;
560
561 if (!OnlyOneArc)
562 {
563 PointArray1.Add(ClearPosition1);
564 }
565
566 PointArray1.Add(PositionHit);
567 }
568 else
569 {
570 if (!OnlyOneArc)
571 {
572 PointArray1.Add(ClearPosition1);
573 }
574 PointArray1.Add(ClearPosition2);
575 }
576
577 if (BeginAndEndOverlapEvent || HitEveryFrameEvent) // Begin Overlap
578 {
579 for (auto& val : HitResult)
580 {
581 if (AllHitActorTSet.Contains(val.GetActor()) == false)
582 {
583 AllHitActorTSet.Add(val.GetActor());
584
585 if (HitEveryFrameEvent)
586 {
587 HitEveryFrame.Broadcast(val);
588 }
589
590 if (!WasStartOverlapArray.ContainsByPredicate([&](FHitResult& HitResult) {
591 return HitResult.GetActor() == val.GetActor();
592 }))
593 {
594 WasStartOverlapArray.Add(val);
595 //HitResultHitStart.Add(val);
596 BeginOverlap.Broadcast(val); // Run Delegate
597 }
598 }
599 }
600 }
601
602#if WITH_EDITORONLY_DATA
603 if (Debug)
604 {
605 FVector HitLocation = (hit) ? HitResult.Last().Location : directionRotate2;
606 DrawDebugLine(GetWorld(), directionRotate1, HitLocation, FColor::Orange, false, -1.f, 0, 1);
607 }
608#endif
609
610 CurrentAngle1 = (!ReverseArch1) ? CurrentAngle1 += IncrementAngle1 : CurrentAngle1 -= IncrementAngle1; // if ReverseArch1 then subtract IncrementAngle1
611 CurrentAngle2 += IncrementAngle2;
612 }
613
615 {
616 for (int32 i = WasStartOverlapArray.Num() - 1; i >= 0; --i)
617 {
618 if (AllHitActorTSet.Contains(WasStartOverlapArray[i].GetActor()) == false)
619 {
620 if (WasStartOverlapArray[i].GetActor())
621 {
622 EndOverlap.Broadcast(WasStartOverlapArray[i]); // Run Delegate
623 }
624 WasStartOverlapArray.RemoveAt(i, 1, false);
625 }
626 }
627 }
628 /*WasStartOverlapArray.RemoveAllSwap([&](FHitResult& HitResult) {
629 return (AllHitActorTSet.Contains(HitResult.Actor) == false && !HitResult.Actor.IsValid() == false);
630 }, false);
631 */
632 WasStartOverlapArray.Shrink();
633}
FHitEnd EndOverlap
Definition LineOfSightComponent.h:72
ECollisionChannel TraceChanne2
Definition LineOfSightComponent.h:227
FHitEveryFrame HitEveryFrame
Definition LineOfSightComponent.h:76
FHitStart BeginOverlap
Definition LineOfSightComponent.h:68
int16 SlackArray
Definition LineOfSightComponent.h:299

◆ BuildArcVectorLenghtFlat()

void ULineOfSightComponent::BuildArcVectorLenghtFlat ( )
636{
637 TRACE_CPUPROFILER_EVENT_SCOPE(LineOfSight_Trace);
638 SCOPE_CYCLE_COUNTER(STAT_LineOfSightLineTrace);
639
640 PointArray1.Reset(SlackArray);
641
642 if (OnlyOneArc)
643 {
644 PointArray1.Add(FVector::ZeroVector);
645 }
646
647 TSet<TWeakObjectPtr<AActor>> AllHitActorTSet;
648 const FVector ComponentLocation = GetComponentLocation();
649
650 float Step1;
651 FVector direction1Neg;
652 FVector direction1Pos;
653 float posNegative1XOrig = 0;
654 float posNegative1YOrig = 0;
655
656 if (OnlyOneArc)
657 {
658 Step1 = 0.0f;
659 }
660 else
661 {
662 float posNegative1X = FMath::Cos(FMath::DegreesToRadians(Angle1 * -1)) * Radius1; // x
663 float posNegative1Y = FMath::Sin(FMath::DegreesToRadians(Angle1 * -1)) * Radius1; // y
664
665 float posPositive1X = FMath::Cos(FMath::DegreesToRadians(Angle1)) * Radius1; // x
666 float posPositive1Y = FMath::Sin(FMath::DegreesToRadians(Angle1)) * Radius1; // y
667
668 posNegative1XOrig = posNegative1X; // For Clear Position
669 posNegative1YOrig = posNegative1Y;
670
671 posNegative1X += ComponentLocation.X;
672 posNegative1Y += ComponentLocation.Y;
673 posPositive1X += ComponentLocation.X;
674 posPositive1Y += ComponentLocation.Y;
675
676 FVector Point1Neg(posNegative1X, posNegative1Y, ComponentLocation.Z);
677 FVector Point1Pos(posPositive1X, posPositive1Y, ComponentLocation.Z);
678
679 float Distance1 = FMath::Abs(posPositive1Y - posNegative1Y);
680 Step1 = Distance1 / Number_Of_Lines;
681
682 direction1Neg = (Point1Neg - ComponentLocation).GetSafeNormal();
683 direction1Pos = (Point1Pos - ComponentLocation).GetSafeNormal();
684 }
685
686 float posNegative2X = FMath::Cos(FMath::DegreesToRadians(Angle2 * -1)) * Radius2; // x
687 float posNegative2Y = FMath::Sin(FMath::DegreesToRadians(Angle2 * -1)) * Radius2; // y
688
689 float posPositive2X = FMath::Cos(FMath::DegreesToRadians(Angle2)) * Radius2; // x
690 float posPositive2Y = FMath::Sin(FMath::DegreesToRadians(Angle2)) * Radius2; // y
691
692 const float posNegative2XOrig = posNegative2X; // For Clear Position
693 const float posNegative2YOrig = posNegative2Y;
694
695 posNegative2X += ComponentLocation.X;
696 posNegative2Y += ComponentLocation.Y;
697 posPositive2X += ComponentLocation.X;
698 posPositive2Y += ComponentLocation.Y;
699
700 const FVector Point2Neg(posNegative2X, posNegative2Y, ComponentLocation.Z);
701 const FVector Point2Pos(posPositive2X, posPositive2Y, ComponentLocation.Z);
702
703 const float Distance2 = FMath::Abs(posPositive2Y - posNegative2Y);
704 const float Step2 = Distance2 / Number_Of_Lines;
705
706 const FVector direction2Neg = (Point2Neg - ComponentLocation).GetSafeNormal();
707 const FVector direction2Pos = (Point2Pos - ComponentLocation).GetSafeNormal();
708
709 FVector directionRotate1Neg;
710 FVector directionRotate1Pos;
711 const FRotator RotationComponent = GetComponentRotation();
712
713 // Point 1
714 if (OnlyOneArc)
715 {
716 directionRotate1Neg = ComponentLocation;
717 directionRotate1Pos = ComponentLocation;
718 }
719 else
720 {
721 directionRotate1Neg = direction1Neg.RotateAngleAxis(RotationComponent.Roll * -1, FVector(1, 0, 0)); // X
722 directionRotate1Neg = directionRotate1Neg.RotateAngleAxis(RotationComponent.Pitch * -1, FVector(0, 1, 0)); // Y
723 directionRotate1Neg = directionRotate1Neg.RotateAngleAxis(RotationComponent.Yaw, FVector(0, 0, 1)); // Z
724 directionRotate1Neg = (directionRotate1Neg * Radius1) + ComponentLocation;
725
726 directionRotate1Pos = direction1Pos.RotateAngleAxis(RotationComponent.Roll * -1, FVector(1, 0, 0)); // X
727 directionRotate1Pos = directionRotate1Pos.RotateAngleAxis(RotationComponent.Pitch * -1, FVector(0, 1, 0)); // Y
728 directionRotate1Pos = directionRotate1Pos.RotateAngleAxis(RotationComponent.Yaw, FVector(0, 0, 1)); // Z
729 directionRotate1Pos = (directionRotate1Pos * Radius1) + ComponentLocation;
730 }
731
732 // Points 2
733 FVector directionRotate2Neg = direction2Neg.RotateAngleAxis(RotationComponent.Roll * -1, FVector(1, 0, 0)); // X
734 directionRotate2Neg = directionRotate2Neg.RotateAngleAxis(RotationComponent.Pitch * -1, FVector(0, 1, 0)); // Y
735 directionRotate2Neg = directionRotate2Neg.RotateAngleAxis(RotationComponent.Yaw, FVector(0, 0, 1)); // Z
736 directionRotate2Neg = (directionRotate2Neg * Radius2) + ComponentLocation;
737
738 FVector directionRotate2Pos = direction2Pos.RotateAngleAxis(RotationComponent.Roll * -1, FVector(1, 0, 0)); // X
739 directionRotate2Pos = directionRotate2Pos.RotateAngleAxis(RotationComponent.Pitch * -1, FVector(0, 1, 0)); // Y
740 directionRotate2Pos = directionRotate2Pos.RotateAngleAxis(RotationComponent.Yaw, FVector(0, 0, 1)); // Z
741 directionRotate2Pos = (directionRotate2Pos * Radius2) + ComponentLocation;
742
743 const FVector Direction1AfterRotation = (directionRotate1Pos - directionRotate1Neg).GetSafeNormal(); // UKismetMathLibrary::GetDirectionUnitVector(GetComponentLocation(), Point1);
744 const FVector Direction2AfterRotation = (directionRotate2Pos - directionRotate2Neg).GetSafeNormal();
745
746 for (int i = 0; i <= Number_Of_Lines; i++)
747 {
748 FVector direction1Step;
749 if (OnlyOneArc)
750 {
751 direction1Step = GetComponentLocation();
752 }
753 else
754 {
755 direction1Step = (Direction1AfterRotation * (Step1 * i)) + directionRotate1Neg;
756 }
757
758 FVector direction2Step = (Direction2AfterRotation * (Step2 * i)) + directionRotate2Neg;
759
760 FVector ClearPosition1(posNegative1XOrig, posNegative1YOrig + (Step1 * i), 0);
761 FVector ClearPosition2(posNegative2XOrig, posNegative2YOrig + (Step2 * i), 0);
762 if (OnlyOneArc)
763 {
764 ClearPosition1 = FVector::ZeroVector;
765 }
766
767 TArray< FHitResult> HitResult;
768 const bool hit = GetWorld()->LineTraceMultiByChannel(HitResult, direction1Step, direction2Step, TraceChanne2, TraceParams);
769
770 if (BeginAndEndOverlapEvent || HitEveryFrameEvent) // Begin Overlap
771 {
772 for (auto& val : HitResult)
773 {
774 if (AllHitActorTSet.Contains(val.GetActor()) == false)
775 {
776 AllHitActorTSet.Add(val.GetActor());
777
778 if (HitEveryFrameEvent)
779 {
780 HitEveryFrame.Broadcast(val);
781 }
782
783 if (!WasStartOverlapArray.ContainsByPredicate([&](FHitResult& HitResult) {
784 return HitResult.GetActor() == val.GetActor();
785 }))
786 {
787 WasStartOverlapArray.Add(val);
788 BeginOverlap.Broadcast(val); // Run Delegate
789 }
790 }
791 }
792 }
793
794 if (hit)
795 {
796 const float distance = UKismetMathLibrary::Vector_Distance(direction1Step, HitResult.Last().Location);
797 const FVector DirectionHit = UKismetMathLibrary::GetDirectionUnitVector(ClearPosition1, ClearPosition2);
798 const FVector PositionHit = (DirectionHit * distance) + ClearPosition1;
799
800 if (!OnlyOneArc)
801 {
802 //PointArray1.Add(direction1Step - ComponentLocation);
803 PointArray1.Add(ClearPosition1);
804 }
805
806 //PointArray1.Add(ClearPosition1);
807 PointArray1.Add(PositionHit);
808 }
809 else
810 {
811 if (!OnlyOneArc)
812 {
813 PointArray1.Add(ClearPosition1);
814 }
815
816 PointArray1.Add(ClearPosition2);
817 }
818
819#if WITH_EDITORONLY_DATA
820 if (Debug)
821 {
822 FVector HitLocation = (hit) ? HitResult.Last().Location : direction2Step;
823 DrawDebugLine(GetWorld(), direction1Step, HitLocation, FColor::Orange, false, -1.f, 0, 1);
824 }
825#endif
826 }
827
829 {
830 for (int32 i = WasStartOverlapArray.Num() - 1; i >= 0; --i)
831 {
832 if (AllHitActorTSet.Contains(WasStartOverlapArray[i].GetActor()) == false)
833 {
834 if (WasStartOverlapArray[i].GetActor())
835 {
836 EndOverlap.Broadcast(WasStartOverlapArray[i]); // Run Delegate
837 }
838 WasStartOverlapArray.RemoveAt(i, 1, false);
839 }
840 }
841 }
842}

◆ BuildMesh()

void ULineOfSightComponent::BuildMesh ( )
69{
70 TRACE_CPUPROFILER_EVENT_SCOPE(LineOfSight_Build_Mesh);
71 SCOPE_CYCLE_COUNTER(STAT_LineOfSightBuildMesh);
72
73 UpdateMeshSection_LinearColor(0, PointArray1, NormalVertex, UV0, VertexColors, Tangents);
74}
TArray< FVector2D > UV0
Definition LineOfSightComponent.h:386
TArray< FProcMeshTangent > Tangents
Definition LineOfSightComponent.h:392
TArray< FLinearColor > VertexColors
Definition LineOfSightComponent.h:389
TArray< FVector > NormalVertex
Definition LineOfSightComponent.h:383

◆ ClearActorsToIgnore()

void ULineOfSightComponent::ClearActorsToIgnore ( const bool NewIgnoreSelf = true)
1093{
1094 TraceParams.ClearIgnoredActors();
1095 if (NewIgnoreSelf)
1096 {
1097 TraceParams.AddIgnoredActor(GetOwner());
1098 }
1099}

◆ CloneTick()

void ULineOfSightComponent::CloneTick ( )
303{
304 if (IsValid(LineOfSightComponentForClone))
305 {
306 LineOfSightComponentForClone->SetWorldRotation(GetComponentRotation());
307 LineOfSightComponentForClone->UpdateMeshSection_LinearColor(0, PointArray1, NormalVertex, UV0, VertexColors, Tangents);
308 }
309 else
310 {
311 ZStopCloneTo();
312 }
313}
void ZStopCloneTo()
Definition LineOfSightComponent.cpp:296

◆ FindAngleRotate()

FRotator ULineOfSightComponent::FindAngleRotate ( UPARAM(ref) AActor *& Actor)
1067{
1068 if (!IsValid(Actor))
1069 {
1070 return FRotator::ZeroRotator;
1071 }
1072 FVector vec1 = Actor->GetActorLocation() - GetComponentLocation();
1073 FRotator rot1 = FRotationMatrix::MakeFromX(vec1).Rotator();
1074 return rot1;
1075}

◆ GetAngle1()

FORCEINLINE float ULineOfSightComponent::GetAngle1 ( ) const
inline
144{ return Angle1; };

◆ GetAngle2()

FORCEINLINE float ULineOfSightComponent::GetAngle2 ( ) const
inline
147{ return Angle2; };

◆ GetAxisValue()

float ULineOfSightComponent::GetAxisValue ( EAxisTypeComp Axis,
FRotator & Rotator )
1116{
1117 if (Axis == EAxisTypeComp::Z)
1118 {
1119 return Rotator.Yaw;
1120 }
1121 else if (Axis == EAxisTypeComp::Y)
1122 {
1123 return Rotator.Pitch;
1124 }
1125 else if (Axis == EAxisTypeComp::X)
1126 {
1127 return Rotator.Roll;
1128 }
1129
1130 return 0.0f;
1131}

◆ GetBeginAndEndOverlapEvent()

FORCEINLINE uint8 ULineOfSightComponent::GetBeginAndEndOverlapEvent ( ) const
inline
217{ return BeginAndEndOverlapEvent; }

◆ GetHitEveryFrame()

FORCEINLINE uint8 ULineOfSightComponent::GetHitEveryFrame ( ) const
inline
214{ return HitEveryFrameEvent; }

◆ GetRadius1()

FORCEINLINE float ULineOfSightComponent::GetRadius1 ( ) const
inline
156{ return Radius1; };

◆ GetRadius2()

FORCEINLINE float ULineOfSightComponent::GetRadius2 ( ) const
inline
159{ return Radius2; };

◆ InterpAngle()

void ULineOfSightComponent::InterpAngle ( )
850{
851 Angle1 = FMath::FInterpConstantTo(Angle1, AngleForInterpAngle1, GetWorld()->GetDeltaSeconds(), SpeedInterpAngle1);
852 Angle2 = FMath::FInterpConstantTo(Angle2, AngleForInterpAngle2, GetWorld()->GetDeltaSeconds(), SpeedInterpAngle2);
853
854 if (FMath::IsNearlyEqual(Angle1, AngleForInterpAngle1, Tolerance) && FMath::IsNearlyEqual(Angle2, AngleForInterpAngle2, Tolerance))
855 {
856 bInterpAngleBool = false;
857 }
858}
float Tolerance
Definition LineOfSightComponent.h:315
float SpeedInterpAngle1
Definition LineOfSightComponent.h:181
float SpeedInterpAngle2
Definition LineOfSightComponent.h:183
float AngleForInterpAngle1
Definition LineOfSightComponent.h:177
float AngleForInterpAngle2
Definition LineOfSightComponent.h:179
bool bInterpAngleBool
Definition LineOfSightComponent.h:169

◆ InterpRadius()

void ULineOfSightComponent::InterpRadius ( )
420{
421 UWorld* World = GetWorld();
422 if (!World) return;
423 Radius1 = FMath::FInterpConstantTo(Radius1, Radius1ForInterp, World->GetDeltaSeconds(), SpeedInterpRadius1);
424 Radius2 = FMath::FInterpConstantTo(Radius2, Radius2ForInterp, World->GetDeltaSeconds(), SpeedInterpRadius2);
425
426 if (FMath::IsNearlyEqual(Radius1, Radius1ForInterp, Tolerance) && FMath::IsNearlyEqual(Radius2, Radius2ForInterp, Tolerance))
427 {
428 InterpRadiusBool = false;
429 }
430}
float Radius2ForInterp
Definition LineOfSightComponent.h:198
float Radius1ForInterp
Definition LineOfSightComponent.h:196
float SpeedInterpRadius2
Definition LineOfSightComponent.h:204
bool InterpRadiusBool
Definition LineOfSightComponent.h:187
float SpeedInterpRadius1
Definition LineOfSightComponent.h:202

◆ LineOfSightIsActive()

bool ULineOfSightComponent::LineOfSightIsActive ( ) const
234{
236}
bool StartLineTraceActive
Definition LineOfSightComponent.h:375

◆ MeshIsBuilt()

bool ULineOfSightComponent::MeshIsBuilt ( ) const
229{
230 return bBuildMeshActive;
231}

◆ RotateInRange()

void ULineOfSightComponent::RotateInRange ( )
867{
868 FQuat CurrentQuat;
869
870 if (TypeRotationGlobal == ETypeRotation::Relative_Rotation)
871 {
872 CurrentQuat = GetRelativeRotation().Quaternion();
873 }
874 else
875 {
876 CurrentQuat = GetComponentRotation().Quaternion();
877 }
878
879 FQuat NewQuat;
880 if (FlipDirection)
881 {
882 NewQuat = FMath::QInterpConstantTo(CurrentQuat, AngleRotateQuat, GetWorld()->GetDeltaSeconds(), SpeedRotate);
883 if (AngleRotateQuat.Equals(NewQuat, Tolerance))
884 {
885 FlipDirection = false;
886 }
887 }
888 else
889 {
890 NewQuat = FMath::QInterpConstantTo(CurrentQuat, AngleRotateQuat2, GetWorld()->GetDeltaSeconds(), SpeedRotate);
891 if (AngleRotateQuat2.Equals(NewQuat, Tolerance))
892 {
893 FlipDirection = true;
894 }
895 }
896
897 if (TypeRotationGlobal == ETypeRotation::Relative_Rotation)
898 {
899 SetRelativeRotation(NewQuat);
900 }
901 else
902 {
903 SetWorldRotation(NewQuat);
904 }
905}
FQuat AngleRotateQuat2
Definition LineOfSightComponent.h:311
float SpeedRotate
Definition LineOfSightComponent.h:313
FQuat AngleRotateQuat
Definition LineOfSightComponent.h:309
ETypeRotation TypeRotationGlobal
Definition LineOfSightComponent.h:323

◆ RotateToAngle()

void ULineOfSightComponent::RotateToAngle ( )
909{
910 FQuat CurrentQuat;
911 if (TypeRotationGlobal == ETypeRotation::Relative_Rotation)
912 {
913 CurrentQuat = GetRelativeRotation().Quaternion();
914 }
915 else
916 {
917 CurrentQuat = GetComponentRotation().Quaternion();
918 }
919
920 FQuat NewQuat = FMath::QInterpConstantTo(CurrentQuat, AngleRotateQuat, GetWorld()->GetDeltaSeconds(), SpeedRotate);
921 if (TypeRotationGlobal == ETypeRotation::Relative_Rotation)
922 {
923 SetRelativeRotation(NewQuat);
924 }
925 else
926 {
927 SetWorldRotation(NewQuat);
928 }
929
930 if (AngleRotateQuat.Equals(NewQuat, Tolerance))
931 {
932 bRotateToAngleActive = false;
933 RotateToAngleEnd.Broadcast();
934 }
935}
uint8 bRotateToAngleActive
Definition LineOfSightComponent.h:303
FRotateToAngleEnd RotateToAngleEnd
Definition LineOfSightComponent.h:79

◆ SetAngle1()

void ULineOfSightComponent::SetAngle1 ( const float NewAngle)
386{
387 Angle1 = NewAngle;
388}

◆ SetAngle2()

void ULineOfSightComponent::SetAngle2 ( const float NewAngle)
391{
392 Angle2 = NewAngle;
393}

◆ SetAxisValue()

FRotator ULineOfSightComponent::SetAxisValue ( EAxisTypeComp Axis,
const float Value,
FRotator & Rotator )
1134{
1135 if (Axis == EAxisTypeComp::Z)
1136 {
1137 Rotator.SetComponentForAxis(EAxis::Z, Value);
1138 }
1139 else if (Axis == EAxisTypeComp::Y)
1140 {
1141 Rotator.SetComponentForAxis(EAxis::Y, Value);
1142 }
1143 else if (Axis == EAxisTypeComp::X)
1144 {
1145 Rotator.SetComponentForAxis(EAxis::X, Value);
1146 }
1147
1148 return Rotator;
1149}

◆ SetBeginAndEndOverlapEvent()

void ULineOfSightComponent::SetBeginAndEndOverlapEvent ( const bool NewValue)
58{
59 BeginAndEndOverlapEvent = NewValue;
61}

◆ SetGeometryType()

void ULineOfSightComponent::SetGeometryType ( const ETypeArc NewType)
1040{
1042 {
1043 GeometryType = NewType;
1044 }
1045}

◆ SetHitEveryFrame()

void ULineOfSightComponent::SetHitEveryFrame ( const bool NewValue)
64{
65 HitEveryFrameEvent = NewValue;
66}

◆ SetIgnoreSelf()

void ULineOfSightComponent::SetIgnoreSelf ( const bool NewValueIgnoreSelf)
1102{
1103 TraceParams.ClearIgnoredActors();
1104 TraceParams.AddIgnoredActor(GetOwner());
1105 IgnoreSelf = NewValueIgnoreSelf;
1106}

◆ SetNormals()

void ULineOfSightComponent::SetNormals ( const FVector Normals)
1048{
1050 {
1051 NormalVertex.Reset(SlackArray);
1052 NormalVertex.Init(Normals, SlackArray);
1053 }
1054}

◆ SetRadius1()

void ULineOfSightComponent::SetRadius1 ( const float NewRadius)
396{
397 Radius1 = NewRadius;
398}

◆ SetRadius2()

void ULineOfSightComponent::SetRadius2 ( const float NewRadius)
401{
402 Radius2 = NewRadius;
403}

◆ SetStandardCollision()

void ULineOfSightComponent::SetStandardCollision ( const bool NewStatus)
845{
846 UseStandardCollision = NewStatus;
847}

◆ SetTickEnable()

void ULineOfSightComponent::SetTickEnable ( const bool Enable)
218{
220 PrimaryComponentTick.SetTickFunctionEnable(Enable);
221}
void StopLineTrace()
Definition LineOfSightComponent.cpp:315

◆ SetTolerance()

void ULineOfSightComponent::SetTolerance ( const float NewTolerance)
861{
862 Tolerance = NewTolerance;
863}

◆ SetTraceChannel()

void ULineOfSightComponent::SetTraceChannel ( const ETraceTypeQuery NewTraceChanne)
1078{
1079 TraceChanne2 = UEngineTypes::ConvertToCollisionChannel(NewTraceChanne);
1080}

◆ SetTraceComplex()

void ULineOfSightComponent::SetTraceComplex ( const bool NewValue)
1152{
1153 TraceParams.bTraceComplex = NewValue;
1154}

◆ SetVisibilityOfMesh()

void ULineOfSightComponent::SetVisibilityOfMesh ( const bool NewVisibility)
224{
225 SetMeshSectionVisible(0, NewVisibility);
226}

◆ StartBuildMesh()

void ULineOfSightComponent::StartBuildMesh ( )
78{
79 TRACE_CPUPROFILER_EVENT_SCOPE(LineOfSight_StartBuildMesh);
80
81 if (StartLineTraceActive == false)
82 {
83 UE_LOG(LogTemp, Error, TEXT("LineOfSight Component: The StartBuildMesh function can only be called after the StartLineTrace function."));
84 return;
85 }
86
87 bBuildMeshActive = true;
88
89 ClearMeshSection(0);
90 SetMaterial(0, Material);
91 NormalVertex.Reset();
92 Triangle.Reset();
93
94 int32 iter = 0;
95 if (OnlyOneArc)
96 {
97 iter = Number_Of_Lines + 2;
98 }
99 else
100 {
101 iter = (Number_Of_Lines * 2) + 2;
102 }
103
104 NormalVertex.Init(FVector(0.0f, 0.0f, 1.0f), iter);
105
106 if (OnlyOneArc)
107 {
108 for (int i = 0; i < iter - 1; i++)
109 {
110 Triangle.Add(0);
111 Triangle.Add(i + 2);
112 Triangle.Add(i + 1);
113 }
114 }
115 else
116 {
117 if (Type_Of_Triangles == ETypeTriangle::E_LR) // Left -> Right
118 {
119 for (int i = 0; i < iter - 2; i++)
120 {
121 if (i % 2 == false)
122 {
123 Triangle.Add(i);
124 Triangle.Add(i + 3);
125 Triangle.Add(i + 1);
126 Triangle.Add(i);
127 Triangle.Add(i + 2);
128 Triangle.Add(i + 3);
129 }
130 }
131 }
132 else if (Type_Of_Triangles == ETypeTriangle::E_RL) // Right -> Left
133 {
134 for (int i = 0; i < iter - 2; i++)
135 {
136 if (i % 2 == false)
137 {
138 Triangle.Add(i);
139 Triangle.Add(i + 2);
140 Triangle.Add(i + 1);
141 Triangle.Add(i + 1);
142 Triangle.Add(i + 2);
143 Triangle.Add(i + 3);
144 }
145 }
146 }
147 else if (Type_Of_Triangles == ETypeTriangle::E_LR_RL)
148 {
149 for (int i = 0; i < iter - 2; i++)
150 {
151 if (i % 2 == false)
152 {
153 if (i > Number_Of_Lines - 1)
154 {
155 Triangle.Add(i);
156 Triangle.Add(i + 2);
157 Triangle.Add(i + 1);
158 Triangle.Add(i + 1);
159 Triangle.Add(i + 2);
160 Triangle.Add(i + 3);
161 }
162 else
163 {
164 Triangle.Add(i);
165 Triangle.Add(i + 3);
166 Triangle.Add(i + 1);
167 Triangle.Add(i);
168 Triangle.Add(i + 2);
169 Triangle.Add(i + 3);
170 }
171 }
172 }
173 }
174 else if (Type_Of_Triangles == ETypeTriangle::E_RL_LR)
175 {
176 for (int i = 0; i < iter - 2; i++)
177 {
178 if (i % 2 == false)
179 {
180 if (i > Number_Of_Lines - 1)
181 {
182 Triangle.Add(i);
183 Triangle.Add(i + 3);
184 Triangle.Add(i + 1);
185 Triangle.Add(i);
186 Triangle.Add(i + 2);
187 Triangle.Add(i + 3);
188 }
189 else
190 {
191 Triangle.Add(i);
192 Triangle.Add(i + 2);
193 Triangle.Add(i + 1);
194 Triangle.Add(i + 1);
195 Triangle.Add(i + 2);
196 Triangle.Add(i + 3);
197 }
198 }
199 }
200 }
201 }
202 //UE_LOG(LogTemp, Warning, TEXT("Triangle %d"), Triangle.Num());
203 CreateMeshSection_LinearColor(0, PointArray1, Triangle, NormalVertex, UV0, VertexColors, Tangents, UseStandardCollision);
204}
TArray< int32 > Triangle
Definition LineOfSightComponent.h:395
UMaterialInterface * Material
Definition LineOfSightComponent.h:135

◆ StartInterpAngle()

void ULineOfSightComponent::StartInterpAngle ( const float NewAngle1,
const float NewAngle2,
const float Speed1,
const float Speed2 )
406{
407 bInterpAngleBool = true;
408 AngleForInterpAngle1 = NewAngle1;
409 AngleForInterpAngle2 = NewAngle2;
410 SpeedInterpAngle1 = Speed1;
411 SpeedInterpAngle2 = Speed2;
412}

◆ StartInterpRadius()

void ULineOfSightComponent::StartInterpRadius ( const float NewRadius1,
const float NewRadius2,
const float Speed1,
const float Speed2 )
433{
434 InterpRadiusBool = true;
435 Radius1ForInterp = NewRadius1;
436 Radius2ForInterp = NewRadius2;
437 SpeedInterpRadius1 = Speed1;
438 SpeedInterpRadius2 = Speed2;
439}

◆ StartLineTrace()

void ULineOfSightComponent::StartLineTrace ( ETraceTypeQuery TraceChannel,
int32 NumberOfLines = 60 )
239{
240 TRACE_CPUPROFILER_EVENT_SCOPE(LineOfSight_StartLineTrace);
241
243 ClearMeshSection(0);
244
245#if WITH_EDITORONLY_DATA
246 if (HitEveryFrameEvent)
247 {
248 UE_LOG(LogTemp, Warning, TEXT("LineOfSight Component: The HitEveryFrameEvent parameter is deprecated. It will be removed in future releases. Use Begin Overlap and EndOverlap (BeginAndEndOverlapEvent) instead."));
249 }
250#endif
251
252 if (NumberOfLines < 1)
253 {
254 NumberOfLines = 1;
255 }
256
257 Number_Of_Lines = NumberOfLines;
258
259 if (OnlyOneArc)
260 {
262 }
263 else
264 {
265 SlackArray = (Number_Of_Lines * 2) + 2;
266 }
267
268 PointArray1.Empty();
269 PointArray1.Init(FVector(0.0f, 0.0f, 0.0f), SlackArray);
270
271 TraceChanne2 = UEngineTypes::ConvertToCollisionChannel(TraceChannel);
272 TraceParams.ClearIgnoredActors();
273 TraceParams.ClearIgnoredComponents();
274 TraceParams.bTraceComplex = TraceComplex;
275 TraceParams.bReturnFaceIndex = false;
276 TraceParams.bReturnPhysicalMaterial = false;
277
278 if (IgnoreSelf)
279 {
280 TraceParams.AddIgnoredActor(GetOwner());
281 }
282}

◆ StartRotateInRangeAxis()

void ULineOfSightComponent::StartRotateInRangeAxis ( const EAxisTypeComp Axis,
const float Angle,
float Speed,
const ETypeRotation TypeRotation,
const bool NegativeToPositive )
938{
939 FlipDirection = NegativeToPositive;
940 AxisForRotateAngle = Axis;
941 bRotateToAngleActive = false;
943 SpeedRotate = Speed;
944 TypeRotationGlobal = TypeRotation;
945
946 FRotator Clear(0.0f, 0.0f, 0.0f);
947 FRotator Delta = SetAxisValue(Axis, Angle, Clear);
948 FRotator Delta2 = SetAxisValue(Axis, Angle * -1, Clear);
949
950 FRotator CurrentRotator;
951 if (TypeRotation == ETypeRotation::World_Rotation) // World Rotation
952 {
953 FQuat Current(GetComponentRotation());
954 CurrentRotator = GetComponentRotation();
955
956 FQuat DeltaQuat = Delta.Quaternion();
957 FQuat DeltaQuat2 = Delta2.Quaternion();
958 AngleRotateQuat = Current * DeltaQuat; // World
959 AngleRotateQuat2 = Current * DeltaQuat2;
960 }
961 else if (TypeRotation == ETypeRotation::Relative_Rotation)
962 {
963 FRotator Current(GetRelativeRotation());
964 FRotator DeltaRotator = Current + Delta;
965 FRotator DeltaRotator2 = Current - Delta;
966 AngleRotateQuat = DeltaRotator.Quaternion(); // Relaltive
967 AngleRotateQuat2 = DeltaRotator2.Quaternion();
968 }
969}
uint8 bRotateInRangeActive
Definition LineOfSightComponent.h:301
EAxisTypeComp AxisForRotateAngle
Definition LineOfSightComponent.h:321
FRotator SetAxisValue(EAxisTypeComp Axis, const float Value, FRotator &Rotator)
Definition LineOfSightComponent.cpp:1133

◆ StartRotateToActor()

void ULineOfSightComponent::StartRotateToActor ( const EAxisTypeComp Axis,
AActor * Actor,
const float Speed )
1016{
1017 if (IsValid(Actor))
1018 {
1019 AxisForRotateAngle = Axis;
1020 bRotateInRangeActive = false;
1021 bRotateToAngleActive = true;
1022
1023 FRotator AngleTo = FindAngleRotate(Actor);
1024 float Angle = GetAxisValue(Axis, AngleTo);
1025
1026 SpeedRotate = Speed;
1027 TypeRotationGlobal = ETypeRotation::World_Rotation;
1028
1029 FRotator Clear(0.0f, 0.0f, 0.0f);
1030 FRotator Delta = SetAxisValue(Axis, Angle, Clear);
1031
1032 FRotator Current(GetComponentRotation());
1033 FRotator DeltaRotator = SetAxisValue(Axis, Angle, Current);
1034 AngleRotateQuat = DeltaRotator.Quaternion();
1035 }
1036}
FRotator FindAngleRotate(UPARAM(ref) AActor *&Actor)
Definition LineOfSightComponent.cpp:1066
float GetAxisValue(EAxisTypeComp Axis, FRotator &Rotator)
Definition LineOfSightComponent.cpp:1115

◆ StartRotateToAngleAxis()

void ULineOfSightComponent::StartRotateToAngleAxis ( const EAxisTypeComp Axis,
const float Angle,
const float Speed,
const ETypeRotation TypeRotation,
const bool AddToCurrent = true )
972{
973 AxisForRotateAngle = Axis;
974 bRotateInRangeActive = false;
976 SpeedRotate = Speed;
977 TypeRotationGlobal = TypeRotation;
978
979 if (AddToCurrent)
980 {
981 FRotator Clear(0.0f, 0.0f, 0.0f);
982 FRotator Delta = SetAxisValue(Axis, Angle, Clear);
983
984 // World Rotation
985 if (TypeRotation == ETypeRotation::World_Rotation)
986 {
987 FQuat Current(GetComponentRotation());
988 FQuat DeltaQuat = Delta.Quaternion();
989 AngleRotateQuat = Current * DeltaQuat;
990 }
991 else if (TypeRotation == ETypeRotation::Relative_Rotation)
992 {
993 FRotator Current(GetRelativeRotation());
994 FRotator DeltaRotator = Current + Delta;
995 AngleRotateQuat = DeltaRotator.Quaternion();
996 }
997 }
998 else
999 {
1000 if (TypeRotation == ETypeRotation::World_Rotation)
1001 {
1002 FRotator Current(GetComponentRotation());
1003 FRotator DeltaRotator = SetAxisValue(Axis, Angle, Current);
1004 AngleRotateQuat = DeltaRotator.Quaternion();
1005 }
1006 else if (TypeRotation == ETypeRotation::Relative_Rotation)
1007 {
1008 FRotator Current(GetRelativeRotation());
1009 FRotator DeltaRotator = SetAxisValue(Axis, Angle, Current);
1010 AngleRotateQuat = DeltaRotator.Quaternion();
1011 }
1012 }
1013}

◆ StopAllRotate()

void ULineOfSightComponent::StopAllRotate ( )
1110{
1111 bRotateInRangeActive = false;
1112 bRotateToAngleActive = false;
1113}

◆ StopBuildMesh()

void ULineOfSightComponent::StopBuildMesh ( )
208{
209 bBuildMeshActive = false;
210 Cloned = false;
211 ClearAllMeshSections();
212 NormalVertex.Reset();
213 Triangle.Reset();
214 //PointArray1.Reset(SlackArray);
215}
bool Cloned
Definition LineOfSightComponent.h:262

◆ StopInterpAngle()

void ULineOfSightComponent::StopInterpAngle ( )
415{
416 bInterpAngleBool = false;
417}

◆ StopInterpRadius()

void ULineOfSightComponent::StopInterpRadius ( )
442{
443 InterpRadiusBool = false;
444}

◆ StopLineTrace()

void ULineOfSightComponent::StopLineTrace ( )
316{
317 StartLineTraceActive = false;
318 bBuildMeshActive = false;
319 PointArray1.Empty();
320 WasStartOverlapArray.Empty();
321 TraceParams.ClearIgnoredActors();
322 TraceParams.ClearIgnoredComponents();
323 Cloned = false;
325}
void StopBuildMesh()
Definition LineOfSightComponent.cpp:207

◆ StopRotateInRange()

void ULineOfSightComponent::StopRotateInRange ( )
1062{
1063 bRotateInRangeActive = false;
1064}

◆ StopRotateToAngle()

void ULineOfSightComponent::StopRotateToAngle ( )
1057{
1058 bRotateToAngleActive = false;
1059}

◆ TickComponent()

void ULineOfSightComponent::TickComponent ( float DeltaTime,
enum ELevelTick TickType,
FActorComponentTickFunction * ThisTickFunction )
overridevirtual
328{
329 TRACE_CPUPROFILER_EVENT_SCOPE(LineOfSight_Tick);
330 SCOPE_CYCLE_COUNTER(STAT_LineOfSightTick);
331
332 Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
333
335 {
337 {
339 }
340
342 {
344 }
345
347 {
348 InterpAngle();
349 }
350
352 {
353 InterpRadius();
354 }
355
356 if (GeometryType == ETypeArc::Arc_VectorLenght)
357 {
359 }
360 else if (GeometryType == ETypeArc::ArcVectorLenghtFlat)
361 {
363 }
364
366 {
367 BuildMesh();
368 }
369
370 if (Cloned)
371 {
372 CloneTick();
373 }
374 }
375}
void InterpAngle()
Definition LineOfSightComponent.cpp:849
void BuildArcVectorLenght()
Definition LineOfSightComponent.cpp:446
void BuildArcVectorLenghtFlat()
Definition LineOfSightComponent.cpp:635
void InterpRadius()
Definition LineOfSightComponent.cpp:419
void RotateInRange()
Definition LineOfSightComponent.cpp:866
void BuildMesh()
Definition LineOfSightComponent.cpp:68
void CloneTick()
Definition LineOfSightComponent.cpp:302
void RotateToAngle()
Definition LineOfSightComponent.cpp:908

◆ UPROPERTY()

ULineOfSightComponent::UPROPERTY ( EditAnywhere ,
Category = "LineOfSight Component",
meta = (DisplayName="HitEveryFrameEvent (Deprecated)") )

◆ ZStartCloneTo()

void ULineOfSightComponent::ZStartCloneTo ( ULineOfSightComponent * OtherLineOfSightComponent)
285{
286 if (IsValid(OtherLineOfSightComponent))
287 {
288 LineOfSightComponentForClone = OtherLineOfSightComponent;
289 Cloned = true;
290
293 }
294}

◆ ZStopCloneTo()

void ULineOfSightComponent::ZStopCloneTo ( )
297{
298 Cloned = false;
299 //LineOfSightComponentForClone.Reset();
300}

Member Data Documentation

◆ Angle1

float ULineOfSightComponent::Angle1

◆ Angle2

float ULineOfSightComponent::Angle2

◆ AngleForInterpAngle1

float ULineOfSightComponent::AngleForInterpAngle1

◆ AngleForInterpAngle2

float ULineOfSightComponent::AngleForInterpAngle2

◆ AngleRotateQuat

FQuat ULineOfSightComponent::AngleRotateQuat

◆ AngleRotateQuat2

FQuat ULineOfSightComponent::AngleRotateQuat2

◆ AngleRotateRot

FRotator ULineOfSightComponent::AngleRotateRot

◆ AngleRotateRot2

FRotator ULineOfSightComponent::AngleRotateRot2

◆ AxisForRotateAngle

EAxisTypeComp ULineOfSightComponent::AxisForRotateAngle

◆ bBuildMeshActive

bool ULineOfSightComponent::bBuildMeshActive
protected

◆ BeginAndEndOverlapEvent

bool ULineOfSightComponent::BeginAndEndOverlapEvent

◆ BeginOverlap

FHitStart ULineOfSightComponent::BeginOverlap

◆ bInterpAngleBool

bool ULineOfSightComponent::bInterpAngleBool

◆ bRotateInRangeActive

uint8 ULineOfSightComponent::bRotateInRangeActive

◆ bRotateToAngleActive

uint8 ULineOfSightComponent::bRotateToAngleActive

◆ Cloned

bool ULineOfSightComponent::Cloned

◆ EndOverlap

FHitEnd ULineOfSightComponent::EndOverlap

◆ FlipDirection

bool ULineOfSightComponent::FlipDirection

◆ GeometryType

ETypeArc ULineOfSightComponent::GeometryType

◆ HitEveryFrame

FHitEveryFrame ULineOfSightComponent::HitEveryFrame

◆ IgnoreSelf

bool ULineOfSightComponent::IgnoreSelf

◆ InterpRadiusBool

bool ULineOfSightComponent::InterpRadiusBool

◆ LineOfSightComponentForClone

ULineOfSightComponent* ULineOfSightComponent::LineOfSightComponentForClone

◆ Material

UMaterialInterface* ULineOfSightComponent::Material

◆ NormalVertex

TArray<FVector> ULineOfSightComponent::NormalVertex
protected

◆ Number_Of_Lines

int ULineOfSightComponent::Number_Of_Lines
private

◆ Only_Z_Rotation

bool ULineOfSightComponent::Only_Z_Rotation

◆ OnlyOneArc

bool ULineOfSightComponent::OnlyOneArc

◆ PointArray1

TArray<FVector> ULineOfSightComponent::PointArray1
protected

◆ Radius1

float ULineOfSightComponent::Radius1

◆ Radius1ForInterp

float ULineOfSightComponent::Radius1ForInterp

◆ Radius2

float ULineOfSightComponent::Radius2

◆ Radius2ForInterp

float ULineOfSightComponent::Radius2ForInterp

◆ ReverseArch1

bool ULineOfSightComponent::ReverseArch1

◆ RotateToAngleEnd

FRotateToAngleEnd ULineOfSightComponent::RotateToAngleEnd

◆ SlackArray

int16 ULineOfSightComponent::SlackArray

◆ SpeedInterpAngle1

float ULineOfSightComponent::SpeedInterpAngle1

◆ SpeedInterpAngle2

float ULineOfSightComponent::SpeedInterpAngle2

◆ SpeedInterpRadius

float ULineOfSightComponent::SpeedInterpRadius

◆ SpeedInterpRadius1

float ULineOfSightComponent::SpeedInterpRadius1

◆ SpeedInterpRadius2

float ULineOfSightComponent::SpeedInterpRadius2

◆ SpeedRotate

float ULineOfSightComponent::SpeedRotate

◆ StartLineTraceActive

bool ULineOfSightComponent::StartLineTraceActive
protected

◆ Tangents

TArray<FProcMeshTangent> ULineOfSightComponent::Tangents
protected

◆ Tolerance

float ULineOfSightComponent::Tolerance = 0.0000005f

◆ TraceChanne2

ECollisionChannel ULineOfSightComponent::TraceChanne2

◆ TraceComplex

bool ULineOfSightComponent::TraceComplex

◆ TraceParams

FCollisionQueryParams ULineOfSightComponent::TraceParams

◆ Triangle

TArray<int32> ULineOfSightComponent::Triangle
protected

◆ Type_Of_Triangles

ETypeTriangle ULineOfSightComponent::Type_Of_Triangles

◆ TypeRotationGlobal

ETypeRotation ULineOfSightComponent::TypeRotationGlobal

◆ TypeTriangle

ETypeTriangle ULineOfSightComponent::TypeTriangle

◆ UseStandardCollision

bool ULineOfSightComponent::UseStandardCollision

◆ UV0

TArray<FVector2D> ULineOfSightComponent::UV0
protected

◆ VertexColors

TArray<FLinearColor> ULineOfSightComponent::VertexColors
protected

◆ WasStartOverlapArray

TArray<FHitResult> ULineOfSightComponent::WasStartOverlapArray
protected

The documentation for this class was generated from the following files: