Skip to content
Snippets Groups Projects
Commit aba2e4da authored by mmeierkrueger's avatar mmeierkrueger :art:
Browse files

removed comments & debug content

parent da084de8
No related branches found
No related tags found
1 merge request!21Changed the way how the grabbing behaviors work: The behaviours now know from...
Pipeline #211229 failed
......@@ -40,23 +40,17 @@ void UGrabbingBehaviorOnPlaneComponent::HandleNewPositionAndDirection(FVector Po
FVector Intersection = FMath::LinePlaneIntersection(Position, Position + Direction, AttachmentPoint, PlaneNormal);
if(bShouldSnapToRayEnd == true)
{
//DrawDebugSphere(GetWorld(), Intersection, 10, 5, FColor::Purple, false, 10);
//DrawDebugSphere(GetWorld(), Intersection.GetClampedToMaxSize(MaxDistance), 10, 5, FColor::Red, false, 10);
//DrawDebugSphere(GetWorld(), GetComponentLocation(), 15, 5, FColor::Black, false, 10);
//GetNewPos
FVector NewPosition = -AttachmentPoint + Intersection;
// clamp size by maxDistance
//DrawDebugSphere(GetWorld(), NewPosition, 10, 5, FColor::Green, false, 10);
// clamp size by maxDistance
NewPosition = NewPosition.GetClampedToMaxSize(MaxDistance);
//DrawDebugSphere(GetWorld(), NewPosition, 10, 5, FColor::Red, false, 10);
// after this NewPoint is in world position
NewPosition += AttachmentPoint;
//DrawDebugSphere(GetWorld(), NewPosition, 10 , 5, FColor::Magenta, false, 10);
// set new position and orientation using calculated quaternion and position
// here rotation is not changed
GetOwner()->SetActorLocation(NewPosition);
//Set new location
GetOwner()->SetActorLocation(NewPosition);
}
else if(bShouldSnapToRayEnd == false)
{
......@@ -85,26 +79,14 @@ void UGrabbingBehaviorOnPlaneComponent::HandleNewPositionAndDirection(FVector Po
if(MaxDistance >= 0)
{
//TODO clamp this and add to original position
float DistanceFromOrigin = FVector::Dist(PointOnConstrainPlane, OriginalPosition); // PointOnConstrainPlane - OriginalPosition;
float const DistanceFromOrigin = FVector::Dist(PointOnConstrainPlane, OriginalPosition); // PointOnConstrainPlane - OriginalPosition;
PointAsVector = PointOnConstrainPlane - OriginalPosition;
//DrawDebugSphere(GetWorld(), PointAsVector, 30, 5, FColor::Magenta, false, 10);
//DrawDebugSphere(GetWorld(), PointOnConstrainPlane, 30, 5, FColor::Blue, false, 10);
//DrawDebugSphere(GetWorld(), PointOnConstrainPlane.GetClampedToMaxSize(MaxDistance), 30, 30, FColor::Cyan, false, 10);
//UE_LOG(LogTemp, Warning, TEXT("DistanceFromOrigin = %f"), DistanceFromOrigin);
if (DistanceFromOrigin > MaxDistance)
{
//UE_LOG(LogTemp, Error, TEXT("Distance too large"));
//PointOnConstrainPlane = PointOnConstrainPlane.GetClampedToMaxSize(MaxDistance);
//DrawDebugSphere(GetWorld(), PointAsVector, 30, 5, FColor::Green, false, 10);
FVector ClampedVector = PointAsVector.GetClampedToMaxSize(MaxDistance);
//Correct Vector position since clamping moves it to world origin
FVector OffsetForNewPos = ClampedVector - PointAsVector;
//PointAsVector += GetComponentLocation();
//DrawDebugSphere(GetWorld(), PointAsVector, 30, 5, FColor::Red, false, 10);
GetOwner()->SetActorLocation(PointOnConstrainPlane + OffsetForNewPos);
}
......@@ -112,25 +94,15 @@ void UGrabbingBehaviorOnPlaneComponent::HandleNewPositionAndDirection(FVector Po
{
GetOwner()->SetActorLocation(PointOnConstrainPlane);
}
}
else
{
//UE_LOG(LogTemp, Warning, TEXT("No Distance Limit found"));
//if MaxDistance == -1 (no limitations)
GetOwner()->SetActorLocation(PointOnConstrainPlane);
}
//GetOwner()->SetActorLocation(PointOnConstrainPlane);
this->SetRelativeLocation(GetOwner()->GetActorLocation());
}
}
//UE_LOG(LogTemp, Warning, TEXT("Owner = %s"), *GetOwner()->GetName());
//this->SetWorldLocation(GetOwner()->GetActorLocation());
}
......@@ -139,10 +111,6 @@ void UGrabbingBehaviorOnPlaneComponent::BeginPlay()
{
Super::BeginPlay();
SetWorldLocation(GetOwner()->GetActorLocation(), false);
// ...
}
......@@ -150,9 +118,5 @@ void UGrabbingBehaviorOnPlaneComponent::BeginPlay()
void UGrabbingBehaviorOnPlaneComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
......@@ -35,8 +35,5 @@ private:
UPROPERTY(EditAnywhere) float MaxDistance = -1; // distance the object can be moved from the center. -1 for no limit
UPROPERTY() FPlane ConstraintPlane; //the plane on which the parent actor is allowed to move
UPROPERTY() FPlane InteractionPlane; // the same plane as the ConstraintPlane, but shifted onto the intersection point of the parent object and the interaction ray
UPROPERTY() FVector OffsetToParentLocation;
UPROPERTY() FVector OffsetToParentLocation; //Vector describing the offset between the interaction point of the object and its center
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment