当前位置: 首页>>代码示例>>C++>>正文


C++ FVector2D::SizeSquared方法代码示例

本文整理汇总了C++中FVector2D::SizeSquared方法的典型用法代码示例。如果您正苦于以下问题:C++ FVector2D::SizeSquared方法的具体用法?C++ FVector2D::SizeSquared怎么用?C++ FVector2D::SizeSquared使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FVector2D的用法示例。


在下文中一共展示了FVector2D::SizeSquared方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawText

void SProfilerThreadView::DrawText( const FString& Text, const FSlateFontInfo& FontInfo, FVector2D Position, const FColor& TextColor, const FColor& ShadowColor, FVector2D ShadowOffset, const FSlateRect* ClippingRect /*= nullptr*/ ) const
{
	check( PaintState );

	if( ShadowOffset.SizeSquared() > 0.0f )
	{
		FSlateDrawElement::MakeText
		(
			PaintState->OutDrawElements,
			PaintState->LayerId,
			PaintState->AllottedGeometry.ToOffsetPaintGeometry( Position + ShadowOffset ),
			Text,
			FontInfo,
			ClippingRect ? *ClippingRect : PaintState->AbsoluteClippingRect,
			PaintState->DrawEffects,
			ShadowColor
		);
	}

	FSlateDrawElement::MakeText
	(
		PaintState->OutDrawElements,
		++PaintState->LayerId,
		PaintState->AllottedGeometry.ToOffsetPaintGeometry( Position ),
		Text,
		FontInfo,
		ClippingRect ? *ClippingRect : PaintState->AbsoluteClippingRect,
		PaintState->DrawEffects,
		TextColor
	);
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:31,代码来源:SProfilerThreadView.cpp

示例2: FindClosestPointOnLine

/** Find the point on line segment from LineStart to LineEnd which is closest to Point */
FVector2D FGeometryHelper::FindClosestPointOnLine(const FVector2D& LineStart, const FVector2D& LineEnd, const FVector2D& TestPoint)
{
	const FVector2D LineVector = LineEnd - LineStart;

	const float A = -FVector2D::DotProduct(LineStart - TestPoint, LineVector);
	const float B = LineVector.SizeSquared();
	const float T = FMath::Clamp<float>(A / B, 0.0f, 1.0f);

	// Generate closest point
	return LineStart + (T * LineVector);
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:12,代码来源:ConnectionDrawingPolicy.cpp

示例3: ComputeActionAtLocation

ETransformAction STransformHandle::ComputeActionAtLocation(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) const
{
	FVector2D LocalPosition = MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition());
	FVector2D GrabOriginOffset = LocalPosition - DragOrigin;
	if ( GrabOriginOffset.SizeSquared() < 36.f )
	{
		return ETransformAction::Primary;
	}
	else
	{
		return ETransformAction::Secondary;
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:13,代码来源:STransformHandle.cpp

示例4: GetPreferredVelocity

FVector2D UAvoidanceComponent::GetPreferredVelocity()
{
	FVector2D ToTarget;
	if (bUseAITargetLocation && aiController)
	{
		ToTarget = FVector2D{ aiController->GetPathFollowingComponent()->GetCurrentTargetLocation() };
		//FVector2D actLoc {pawn->GetActorLocation() };
		//UE_LOG(LogRVOTest, Warning, TEXT("UAv::prefv GetCurrentTargetLocation, %f %f, actloc: %f %f"), CurrentTarget.X, CurrentTarget.Y, actLoc.X, actLoc.Y);
		//UE_LOG(LogRVOTest, Warning, TEXT("UAv::Totarget: %f %f"), ToTarget.X, ToTarget.Y);

	}
	else
	{
		ToTarget = FVector2D{ CurrentTarget - FVector2D{ pawn->GetActorLocation() } };
	}
	
	

	float sqrDist = ToTarget.SizeSquared();

	
	if (sqrDist < AcceptanceSquared)
		return FVector2D::ZeroVector;

	float m = 1.f / (SlowdownSquared - AcceptanceSquared);

	float b = -m * AcceptanceSquared;

	float k = (sqrDist < SlowdownSquared && pathFollowSlowdown) ? sqrDist * m + b : 1.f;
	if (k < SMALL_NUMBER)
	{
		return FVector2D::ZeroVector;
	}

	FVector2D res = ToTarget.GetSafeNormal() * MaxVelocity * k;
	
	if (res.ContainsNaN())
	{
		UE_LOG(LogRVOTest, VeryVerbose, TEXT("UAvoidanceComp:: GetPreferredV , %f %f"), res.X, res.Y);
	}
	

	return res;
}
开发者ID:balazon,项目名称:UnrealRVO,代码行数:44,代码来源:AvoidanceComponent.cpp

示例5:

float UKismetMathLibrary::VSize2DSquared(FVector2D A)
{
	return A.SizeSquared();
}
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:4,代码来源:KismetMathLibrary.cpp

示例6: ReceiveTick

void UTapGestureRecognizer::ReceiveTick(float DeltaTime)
{
	Super::ReceiveTick(DeltaTime);
	if (CurrentTouchCount > PreviousTouchCount) // more fingers this tick than last means a tap sequence can't have ended
	{
		return;
	}
	
	float Now = GetWorld()->GetRealTimeSeconds();
	
	for (int32 i = 0; i < EKeys::NUM_TOUCH_KEYS; i++)
	{
		TapCounts[i] = 0;
	}
	
	bool bDidFindTapSequence = false;
	// If less fingers on screen, we could have a tap sequence in any of the fingers
	for (int32 Index = CurrentTouchCount; Index < EKeys::NUM_TOUCH_KEYS; Index++)
	{
		FGestureTouchData ThisTouch = TouchData[Index];
		if (ThisTouch.TouchStartTimes.Num() == 0) continue; // No points to look at, so bail
		
		if (Now > ThisTouch.LatestTouchTime + MaximumTimeBetweenTaps && ThisTouch.LatestTouchTime != 0.f)
		{
			// Make sure it wasn't a pan or swipe
			if (ThisTouch.TouchPoints.Num() > 1)
			{
				FVector2D TouchDelta = ThisTouch.TouchPoints.Last() - ThisTouch.TouchPoints[0];
				float MovementSquared = TouchDelta.SizeSquared();
				if (MovementSquared > 16.f) // More than 4 pixels of movement
				{
					// Not a tap, move along
					ResetGesture();
					continue;
				}
			}
			
			// Enough time has passed that this finger MIGHT have finished a tap sequence
			for (int32 TouchTimeIndex = ThisTouch.TouchStartTimes.Num()-1; TouchTimeIndex >= 0; TouchTimeIndex--)
			{
				float TapDuration = ThisTouch.TouchEndTimes[TouchTimeIndex] - ThisTouch.TouchStartTimes[TouchTimeIndex];
				if ( TapDuration >= MinimumTimeForTap && TapDuration <= MaximumTimeForTap)
				{
					// We have a tap! But was it part of a sequence?
					
					// First valid touch doesn't need this check
					if (TouchTimeIndex == ThisTouch.TouchStartTimes.Num()-1)
					{
						TapCounts[Index]++;
					}
					// Need to include 0 in the loop for single taps, but don't want to try and compare it with previous tap
					if (TouchTimeIndex > 0)
					{
						if (ThisTouch.TouchStartTimes[TouchTimeIndex] <= ThisTouch.TouchStartTimes[TouchTimeIndex-1] + MaximumTimeBetweenTaps)
						{
							TapCounts[Index]++;
						}
					}
				}
				else
				{
					break; // Not fast enough for tap
				}
			}
		}
		
		// Don't want to count this one again!
		if (TapCounts[Index] > 0)
		{
			bDidFindTapSequence = true;
		}
	}
	if (bDidFindTapSequence)
	{
		NumberOfFingersInTap = 0;
		int32 HighestTapCount = 0;
		int32 FirstIndexMatchingHighestTapCount;
		
		// Find the highest tap count for a finger
		for (int32 Index = 0; Index < EKeys::NUM_TOUCH_KEYS; Index++)
		{
			if (TapCounts[Index] > HighestTapCount)
			{
				HighestTapCount = TapCounts[Index];
				FirstIndexMatchingHighestTapCount = Index;
			}
		}
		// Find out how many fingers tapped for that amount
		for (int32 Index = 0; Index < EKeys::NUM_TOUCH_KEYS; Index++)
		{
			if (TapCounts[Index] == HighestTapCount)
			{
				NumberOfFingersInTap++;
			}
		}
		NumberOfTaps = HighestTapCount;
		LastTapLocation = TouchData[FirstIndexMatchingHighestTapCount].TouchPoints.Last();
		
		if (NumberOfTaps >= MinimumNumberOfTaps &&
			NumberOfTaps <= MaximumNumberOfTaps &&
//.........这里部分代码省略.........
开发者ID:anuraX,项目名称:UE4-GestureRecognizers,代码行数:101,代码来源:TapGestureRecognizer.cpp

示例7: SnapDragDelta

void FVertexSnappingImpl::SnapDragDelta( FVertexSnappingArgs& InArgs, const FVector& StartLocation, const FBox& AllowedSnappingBox, TSet< TWeakObjectPtr<AActor> >& ActorsToIgnore, FVector& DragDelta )
{	
	const FSceneView* View = InArgs.SceneView;
	const FVector& DesiredUnsnappedLocation = InArgs.CurrentLocation;
	const FVector2D& MousePosition = InArgs.MousePosition;
	const EAxisList::Type CurrentAxis = InArgs.CurrentAxis;
	const FPlane ActorPlane = InArgs.ActorPlane;
	FLevelEditorViewportClient* ViewportClient = InArgs.ViewportClient;

	TArray<FSnapActor> PossibleSnapPointActors;
	GetPossibleSnapActors( AllowedSnappingBox, MousePosition.IntPoint(), ViewportClient, View, CurrentAxis, ActorsToIgnore, PossibleSnapPointActors );

	FVector Direction = FVector( ActorPlane.X, ActorPlane.Y, ActorPlane.Z );

	if( PossibleSnapPointActors.Num() > 0 )
	{
		// Get the closest vertex to the desired location (before snapping)
		FVector ClosestPoint = GetClosestVertex( PossibleSnapPointActors, InArgs ).Position;

		FVector PrevDragDelta = DragDelta;
		float Distance = 0;
		if( CurrentAxis != EAxisList::Screen )
		{
			// Compute a distance from the stat location to the snap point.  
			// When not using the screen space translation we snap to the plane along the movement axis that the nearest vertex is on and not the vertex itself
			FPlane RealPlane( StartLocation, Direction );
			Distance = RealPlane.PlaneDot( ClosestPoint );
						
			// Snap to the plane
			DragDelta = Distance*Direction;
		}
		else
		{
			// Snap to the nearest vertex
			DragDelta = ClosestPoint-StartLocation;
			Distance = DragDelta.Size();			
		}

		const FVector& PreSnapLocation = StartLocation;

		// Compute snapped location after computing the new drag delta
		FVector SnappedLocation = StartLocation+DragDelta;
				
		if( ViewportClient->IsPerspective() )
		{
			// Distance from start location to the location the actor would be in without snapping
			float DistFromPreSnapToDesiredUnsnapped = FVector::DistSquared( PreSnapLocation, DesiredUnsnappedLocation );

			// Distance from the new location of the actor without snapping to the location with snapping
			float DistFromDesiredUnsnappedToSnapped = FVector::DistSquared( DesiredUnsnappedLocation, SnappedLocation );

			// Only snap if the distance to the snapped location is less than the distance to the unsnapped location.  
			// This allows the user to control the speed of snapping based on how fast they move the mouse and also avoids jerkiness when the mouse is behind the snap location
			if( (CurrentAxis != EAxisList::Screen && DistFromDesiredUnsnappedToSnapped >= DistFromPreSnapToDesiredUnsnapped) || ClosestPoint == DesiredUnsnappedLocation )
			{
				DragDelta = FVector::ZeroVector;
			}
		}
		else
		{
			FVector2D PreSnapLocationPixel;
			View->WorldToPixel( PreSnapLocation, PreSnapLocationPixel );

			FVector2D SnappedLocationPixel;
			View->WorldToPixel( SnappedLocation, SnappedLocationPixel );

			FVector2D SLtoML = SnappedLocationPixel-MousePosition;
			FVector2D PStoML = MousePosition-PreSnapLocationPixel;

			// Only snap if the distance to the snapped location is less than the distance to the unsnapped location
			float Dist2 = PStoML.SizeSquared();
			float Dist1 = SLtoML.SizeSquared();
			if( Dist1 >= Dist2 || ClosestPoint == DesiredUnsnappedLocation )
			{
				DragDelta = FVector::ZeroVector;
			}
		}
	}
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:79,代码来源:VertexSnapping.cpp


注:本文中的FVector2D::SizeSquared方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。