本文整理汇总了C++中FVector2D函数的典型用法代码示例。如果您正苦于以下问题:C++ FVector2D函数的具体用法?C++ FVector2D怎么用?C++ FVector2D使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FVector2D函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SCOPED_DRAW_EVENT
void FRCPassPostProcessLensFlares::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, LensFlares);
const FPooledRenderTargetDesc* InputDesc1 = GetInputDesc(ePId_Input0);
const FPooledRenderTargetDesc* InputDesc2 = GetInputDesc(ePId_Input1);
if(!InputDesc1 || !InputDesc2)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntPoint TexSize1 = InputDesc1->Extent;
FIntPoint TexSize2 = InputDesc2->Extent;
uint32 ScaleToFullRes1 = GSceneRenderTargets.GetBufferSizeXY().X / TexSize1.X;
uint32 ScaleToFullRes2 = GSceneRenderTargets.GetBufferSizeXY().X / TexSize2.X;
FIntRect ViewRect1 = FIntRect::DivideAndRoundUp(View.ViewRect, ScaleToFullRes1);
FIntRect ViewRect2 = FIntRect::DivideAndRoundUp(View.ViewRect, ScaleToFullRes2);
FIntPoint ViewSize1 = ViewRect1.Size();
FIntPoint ViewSize2 = ViewRect2.Size();
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
// is optimized away if possible (RT size=view size, )
Context.RHICmdList.Clear(true, FLinearColor::Black, false, 1.0f, false, 0, ViewRect1);
Context.SetViewportAndCallRHI(ViewRect1);
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
// setup background (bloom), can be implemented to use additive blending to avoid the read here
{
TShaderMapRef<FPostProcessLensFlareBasePS> PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
VertexShader->SetParameters(Context);
PixelShader->SetParameters(Context);
// Draw a quad mapping scene color to the view's render target
DrawRectangle(
Context.RHICmdList,
0, 0,
ViewSize1.X, ViewSize1.Y,
ViewRect1.Min.X, ViewRect1.Min.Y,
ViewSize1.X, ViewSize1.Y,
ViewSize1,
TexSize1,
*VertexShader,
EDRF_UseTriangleOptimization);
}
// additive blend
Context.RHICmdList.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_One, BF_One>::GetRHI());
// add lens flares on top of that
{
TShaderMapRef<FPostProcessLensFlaresPS> PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
FVector2D TexScaleValue = FVector2D(TexSize2) / ViewSize2;
VertexShader->SetParameters(Context);
PixelShader->SetParameters(Context, TexScaleValue);
// todo: expose
const uint32 Count = 8;
// we assume the center of the view is the center of the lens (would not be correct for tiled rendering)
FVector2D Center = FVector2D(ViewSize1) * 0.5f;
FLinearColor LensFlareHDRColor = Context.View.FinalPostProcessSettings.LensFlareTint * Context.View.FinalPostProcessSettings.LensFlareIntensity;
// to get the same brightness with 4x more quads (TileSize=1 in LensBlur)
LensFlareHDRColor.R *= 0.25f;
LensFlareHDRColor.G *= 0.25f;
LensFlareHDRColor.B *= 0.25f;
for(uint32 i = 0; i < Count; ++i)
//.........这里部分代码省略.........
示例2: check
void SProfilerThreadView::DrawUIStackNodes() const
{
// SCOPE_LOG_TIME_FUNC();
check( PaintState );
const double ThreadViewOffsetPx = PositionXMS*NumPixelsPerMillisecond;
PaintState->LayerId++;
static const FSlateBrush* BorderBrush = FEditorStyle::GetBrush( "Profiler.ThreadView.SampleBorder" );
const FColor GameThreadColor = FColorList::Red;
const FColor RenderThreadColor = FColorList::Blue;
const FColor ThreadColors[2] = {GameThreadColor, RenderThreadColor};
// Draw nodes.
for( const auto& RowOfNodes : ProfilerUIStream.LinearRowsOfNodes )
{
int32 NodeIndex = 0;
for( const auto& UIStackNode : RowOfNodes )
{
NodeIndex++;
// Check if the node is visible.
//if( UIStackNode->IsVisible() )
{
const FVector2D PositionPx = UIStackNode->GetLocalPosition( ThreadViewOffsetPx, PositionY ) * FVector2D( 1.0f, NUM_PIXELS_PER_ROW );
const FVector2D SizePx = FVector2D( FMath::Max( UIStackNode->WidthPx - 1.0, 0.0 ), NUM_PIXELS_PER_ROW );
const FSlateRect ClippedNodeRect = PaintState->LocalClippingRect.IntersectionWith( FSlateRect( PositionPx, PositionPx + SizePx ) );
// Check if this node is inside the visible area.
if( ClippedNodeRect.IsEmpty() )
{
continue;
}
FColor NodeColor = UIStackNode->bIsCombined ? ThreadColors[UIStackNode->ThreadIndex].WithAlpha( 64 ) : ThreadColors[UIStackNode->ThreadIndex].WithAlpha( 192 );
NodeColor.G += NodeIndex % 2 ? 0 : 64;
// Draw a cycle counter for this profiler UI stack node.
FSlateDrawElement::MakeBox
(
PaintState->OutDrawElements,
PaintState->LayerId,
PaintState->AllottedGeometry.ToPaintGeometry( ClippedNodeRect.GetTopLeft(), ClippedNodeRect.GetSize() ),
BorderBrush,
PaintState->AbsoluteClippingRect,
PaintState->DrawEffects,
NodeColor
);
}
}
}
// @TODO yrx 2014-04-29 Separate layer for makebox, makeshadowtext, maketext.
PaintState->LayerId++;
const float MarkerPosYOffsetPx = ((float)NUM_PIXELS_PER_ROW - PaintState->SummaryFont8Height)*0.5f;
// Draw nodes' descriptions.
for( const auto& RowOfNodes : ProfilerUIStream.LinearRowsOfNodes )
{
for( const auto& UIStackNode : RowOfNodes )
{
const FVector2D PositionPx = UIStackNode->GetLocalPosition( ThreadViewOffsetPx, PositionY ) * FVector2D( 1.0f, NUM_PIXELS_PER_ROW );
const FVector2D SizePx = FVector2D( UIStackNode->WidthPx, NUM_PIXELS_PER_ROW );
const FSlateRect ClippedNodeRect = PaintState->LocalClippingRect.IntersectionWith( FSlateRect( PositionPx, PositionPx + SizePx ) );
// Check if this node is inside the visible area.
if( ClippedNodeRect.IsEmpty() )
{
continue;
}
FString StringStatName = UIStackNode->StatName.GetPlainNameString();
FString StringStatNameWithTime = StringStatName + FString::Printf( TEXT( " (%.4f MS)" ), UIStackNode->GetDurationMS() );
if( UIStackNode->bIsCulled )
{
StringStatName += TEXT( " [C]" );
StringStatNameWithTime += TEXT( " [C]" );
}
// Update position of the text to be always visible and try to center it.
const float StatNameWidthPx = PaintState->FontMeasureService->Measure( StringStatName, PaintState->SummaryFont8 ).X;
const float StatNameWithTimeWidthPx = PaintState->FontMeasureService->Measure( StringStatNameWithTime, PaintState->SummaryFont8 ).X;
const float TextAreaWidthPx = ClippedNodeRect.GetSize().X;
bool bUseShortVersion = true;
FVector2D AdjustedPositionPx;
// Center the stat name with timing if we can.
if( TextAreaWidthPx > StatNameWithTimeWidthPx )
{
AdjustedPositionPx = FVector2D( ClippedNodeRect.Left + (TextAreaWidthPx - StatNameWithTimeWidthPx)*0.5f, PositionPx.Y + MarkerPosYOffsetPx );
bUseShortVersion = false;
}
// Center the stat name.
else if( TextAreaWidthPx > StatNameWidthPx )
{
AdjustedPositionPx = FVector2D( ClippedNodeRect.Left + (TextAreaWidthPx - StatNameWidthPx)*0.5f, PositionPx.Y + MarkerPosYOffsetPx );
}
// Move to the edge.
else
{
AdjustedPositionPx = FVector2D( ClippedNodeRect.Left, PositionPx.Y + MarkerPosYOffsetPx );
//.........这里部分代码省略.........
示例3: ShouldBeEnabled
int32 SProfilerThreadView::OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const
{
// SCOPE_LOG_TIME_FUNC();
// Rendering info.
const bool bEnabled = ShouldBeEnabled( bParentEnabled );
const ESlateDrawEffect::Type DrawEffects = bEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
const FSlateBrush* BackgroundBrush = FEditorStyle::GetBrush( "Profiler.LineGraphArea" );
const FSlateBrush* WhiteBrush = FEditorStyle::GetBrush( "WhiteTexture" );
// Paint state for this call to OnPaint, valid only in this scope.
PaintState = new((void*)PaintStateMemory) FSlateOnPaintState( AllottedGeometry, MyClippingRect, OutDrawElements, LayerId, InWidgetStyle, DrawEffects );
// Draw background.
FSlateDrawElement::MakeBox
(
PaintState->OutDrawElements,
PaintState->LayerId,
PaintState->AllottedGeometry.ToPaintGeometry( FVector2D( 0, 0 ), PaintState->Size2D() ),
BackgroundBrush,
PaintState->AbsoluteClippingRect,
PaintState->DrawEffects,
BackgroundBrush->GetTint( InWidgetStyle ) * InWidgetStyle.GetColorAndOpacityTint()
);
LayerId++;
// Draw all cycle counters for each thread nodes.
if( IsReady() )
{
DrawFramesBackgroundAndTimelines();
DrawUIStackNodes();
DrawFrameMarkers();
}
#if 0/*DEBUG_PROFILER_PERFORMANCE*/
LayerId++;
// Draw debug information.
float GraphDescPosY = PaintState->Size2D().Y - 4.0f * PaintState->SummaryFont8Height;
// Debug text.
FSlateDrawElement::MakeText
(
OutDrawElements,
LayerId,
AllottedGeometry.ToOffsetPaintGeometry( FVector2D( 16.0f, GraphDescPosY ) ),
FString::Printf( TEXT( "Pos X=%f,Y=%f R X=%f,Y=%f TR X=%f,Y=%f ZF X=%f" ), PositionXMS, PositionY, RangeXMS, RangeY, TotalRangeXMS, TotalRangeY, ZoomFactorX ),
PaintState->SummaryFont8,
MyClippingRect,
DrawEffects,
FLinearColor::White
);
GraphDescPosY -= PaintState->SummaryFont8Height + 1.0f;
FSlateDrawElement::MakeText
(
OutDrawElements,
LayerId,
AllottedGeometry.ToOffsetPaintGeometry( FVector2D( 16.0f, GraphDescPosY ) ),
FString::Printf( TEXT( "NumMSPerWin=%f H Fr=%i,TID=%i,PX=%f,PY=%f" ), NumMillisecondsPerWindow, HoveredFrameIndex, HoveredThreadID, HoveredPositionX, HoveredPositionY ),
PaintState->SummaryFont8,
MyClippingRect,
DrawEffects,
FLinearColor::White
);
GraphDescPosY -= PaintState->SummaryFont8Height + 1.0f;
FSlateDrawElement::MakeText
(
OutDrawElements,
LayerId,
AllottedGeometry.ToOffsetPaintGeometry( FVector2D( 16.0f, GraphDescPosY ) ),
FString::Printf( TEXT( "DistD=%.2f FI=%3i,%3i" ), DistanceDragged, FramesIndices.X, FramesIndices.Y ),
PaintState->SummaryFont8,
MyClippingRect,
DrawEffects,
FLinearColor::White
);
GraphDescPosY -= PaintState->SummaryFont8Height + 1.0f;
#endif // DEBUG_PROFILER_PERFORMANCE
// Reset paint state.
PaintState = nullptr;
return SCompoundWidget::OnPaint( Args, AllottedGeometry, MyClippingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled && IsEnabled() );
}
示例4: It
/**
* For the given text, constructs a mesh to be used by the vertex factory for rendering.
*/
bool FTextRenderSceneProxy::BuildStringMesh( TArray<FDynamicMeshVertex>& OutVertices, TArray<uint16>& OutIndices )
{
if(!Font || Text.IsEmpty())
{
return false;
}
float FirstLineHeight = -1; // Only kept around for legacy positioning support
float StartY = 0;
const float CharIncrement = ( (float)Font->Kerning + HorizSpacingAdjust ) * XScale;
float LineX = 0;
const int32 PageIndex = 0;
FTextIterator It(*Text.ToString());
while (It.NextLine())
{
FVector2D LineSize = ComputeTextSize(It, Font, XScale, YScale, HorizSpacingAdjust);
float StartX = ComputeHorizontalAlignmentOffset(LineSize, HorizontalAlignment);
if (FirstLineHeight < 0)
{
FirstLineHeight = LineSize.Y;
}
LineX = 0;
int32 Ch;
while (It.NextCharacterInLine(Ch))
{
Ch = (int32)Font->RemapChar(Ch);
if(!Font->Characters.IsValidIndex(Ch + PageIndex))
{
continue;
}
FFontCharacter& Char = Font->Characters[Ch + PageIndex];
if(!Font->Textures.IsValidIndex(Char.TextureIndex))
{
continue;
}
UTexture2D* Tex = Font->Textures[Char.TextureIndex];
if(Tex)
{
FIntPoint ImportedTextureSize = Tex->GetImportedSize();
FVector2D InvTextureSize(1.0f / (float)ImportedTextureSize.X, 1.0f / (float)ImportedTextureSize.Y);
const float X = LineX + StartX;
const float Y = StartY + Char.VerticalOffset * YScale;
float SizeX = Char.USize * XScale;
const float SizeY = Char.VSize * YScale;
const float U = Char.StartU * InvTextureSize.X;
const float V = Char.StartV * InvTextureSize.Y;
const float SizeU = Char.USize * InvTextureSize.X;
const float SizeV = Char.VSize * InvTextureSize.Y;
float Left = X;
float Top = Y;
float Right = X + SizeX;
float Bottom = Y + SizeY;
// axis choice and sign to get good alignment when placed on surface
FVector4 V0 = FVector4(0, -Left, -Top, 0);
FVector4 V1 = FVector4(0, -Right, -Top, 0);
FVector4 V2 = FVector4(0, -Left, -Bottom, 0);
FVector4 V3 = FVector4(0, -Right, -Bottom, 0);
FVector TangentX(0, -1, 0);
FVector TangentY(0, 0, -1);
FVector TangentZ(1, 0, 0);
int32 V00 = OutVertices.Add(FDynamicMeshVertex(V0, TangentX, TangentZ, FVector2D(U, V), TextRenderColor));
int32 V10 = OutVertices.Add(FDynamicMeshVertex(V1, TangentX, TangentZ, FVector2D(U + SizeU, V), TextRenderColor));
int32 V01 = OutVertices.Add(FDynamicMeshVertex(V2, TangentX, TangentZ, FVector2D(U, V + SizeV), TextRenderColor));
int32 V11 = OutVertices.Add(FDynamicMeshVertex(V3, TangentX, TangentZ, FVector2D(U + SizeU, V + SizeV), TextRenderColor));
check(V00 < 65536);
check(V10 < 65536);
check(V01 < 65536);
check(V11 < 65536);
OutIndices.Add(V00);
OutIndices.Add(V11);
OutIndices.Add(V10);
OutIndices.Add(V00);
OutIndices.Add(V01);
OutIndices.Add(V11);
// if we have another non-whitespace character to render, add the font's kerning.
int32 NextChar;
//.........这里部分代码省略.........
示例5: MenuBuilder
TSharedPtr<SWidget> SHierarchyView::WidgetHierarchy_OnContextMenuOpening()
{
FMenuBuilder MenuBuilder(true, nullptr);
FWidgetBlueprintEditorUtils::CreateWidgetContextMenu(MenuBuilder, BlueprintEditor.Pin().ToSharedRef(), FVector2D(0, 0));
MenuBuilder.AddMenuEntry(FGenericCommands::Get().Rename);
return MenuBuilder.MakeWidget();
}
示例6: switch
void USlateBrushThumbnailRenderer::Draw(UObject* Object, int32 X, int32 Y, uint32 Width, uint32 Height, FRenderTarget* RenderTarget, FCanvas* Canvas)
{
USlateBrushAsset* SlateBrushAsset = Cast<USlateBrushAsset>(Object);
if (SlateBrushAsset)
{
FSlateBrush Brush = SlateBrushAsset->Brush;
UTexture2D* Texture = Cast<UTexture2D>( Brush.GetResourceObject() );
// Draw the background checkboard pattern
const int32 CheckerDensity = 8;
auto* Checker = UThumbnailManager::Get().CheckerboardTexture;
Canvas->DrawTile(
0.0f, 0.0f, Width, Height, // Dimensions
0.0f, 0.0f, CheckerDensity, CheckerDensity, // UVs
FLinearColor::White, Checker->Resource); // Tint & Texture
if (Texture)
{
switch(Brush.DrawAs)
{
case ESlateBrushDrawType::Image:
{
FCanvasTileItem CanvasTile( FVector2D( X, Y ), Texture->Resource, FVector2D( Width,Height ), Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
break;
case ESlateBrushDrawType::Border:
{
FCanvasTileItem CanvasTile( FVector2D( X, Y ), Texture->Resource, FVector2D( Width,Height ), Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
break;
case ESlateBrushDrawType::Box:
{
float NaturalWidth = Texture->GetSurfaceWidth();
float NaturalHeight = Texture->GetSurfaceHeight();
float TopPx = FMath::Clamp<float>(NaturalHeight * Brush.Margin.Top, 0, Height);
float BottomPx = FMath::Clamp<float>(NaturalHeight * Brush.Margin.Bottom, 0, Height);
float VerticalCenterPx = FMath::Clamp<float>(Height - TopPx - BottomPx, 0, Height);
float LeftPx = FMath::Clamp<float>(NaturalWidth * Brush.Margin.Left, 0, Width);
float RightPx = FMath::Clamp<float>(NaturalWidth * Brush.Margin.Right, 0, Width);
float HorizontalCenterPx = FMath::Clamp<float>(Width - LeftPx - RightPx, 0, Width);
// Top-Left
FVector2D TopLeftSize( LeftPx, TopPx );
{
FVector2D UV0( 0, 0 );
FVector2D UV1( Brush.Margin.Left, Brush.Margin.Top );
FCanvasTileItem CanvasTile( FVector2D( X, Y ), Texture->Resource, TopLeftSize, UV0, UV1, Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
// Bottom-Left
FVector2D BottomLeftSize( LeftPx, BottomPx );
{
FVector2D UV0( 0, 1 - Brush.Margin.Bottom );
FVector2D UV1( Brush.Margin.Left, 1 );
FCanvasTileItem CanvasTile( FVector2D( X, Y + Height - BottomPx ), Texture->Resource, BottomLeftSize, UV0, UV1, Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
// Top-Right
FVector2D TopRightSize( RightPx, TopPx );
{
FVector2D UV0( 1 - Brush.Margin.Right, 0 );
FVector2D UV1( 1, Brush.Margin.Top );
FCanvasTileItem CanvasTile( FVector2D( X + Width - RightPx, Y ), Texture->Resource, TopRightSize, UV0, UV1, Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
// Bottom-Right
FVector2D BottomRightSize( RightPx, BottomPx );
{
FVector2D UV0( 1 - Brush.Margin.Right, 1 - Brush.Margin.Bottom );
FVector2D UV1( 1, 1 );
FCanvasTileItem CanvasTile( FVector2D( X + Width - RightPx, Y + Height - BottomPx ), Texture->Resource, BottomRightSize, UV0, UV1, Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
CanvasTile.Draw( Canvas );
}
//-----------------------------------------------------------------------
// Center-Vertical-Left
FVector2D CenterVerticalLeftSize( LeftPx, VerticalCenterPx );
{
FVector2D UV0( 0, Brush.Margin.Top );
FVector2D UV1( Brush.Margin.Left, 1 - Brush.Margin.Bottom );
FCanvasTileItem CanvasTile( FVector2D( X, Y + TopPx), Texture->Resource, CenterVerticalLeftSize, UV0, UV1, Brush.TintColor.GetSpecifiedColor() );
CanvasTile.BlendMode = SE_BLEND_Translucent;
//.........这里部分代码省略.........
示例7: GetWorld
void AStrategyHUD::DrawMiniMap()
{
const AStrategyPlayerController* const PC = Cast<AStrategyPlayerController>(PlayerOwner);
AStrategyGameState const* const MyGameState = GetWorld()->GetGameState<AStrategyGameState>();
// @todo, clean this up
if (PC && MyGameState && MyGameState->MiniMapCamera.IsValid())
{
const float BaseRotation = 270;
UTexture* MiniMapTexture = Cast<UTexture>(MyGameState->MiniMapCamera->GetCaptureComponent2D()->TextureTarget);
const float MapWidth = (MyGameState->MiniMapCamera->MiniMapWidth - MiniMapMargin) * UIScale;
const float MapHeight = (MyGameState->MiniMapCamera->MiniMapHeight - MiniMapMargin) * UIScale;
const FVector WorldCenter = MyGameState->WorldBounds.GetCenter();
const FVector WorldExtent = MyGameState->WorldBounds.GetExtent();
const FRotator RotOrg = MyGameState->MiniMapCamera->GetCaptureComponent2D()->GetComponentRotation();
const FRotationMatrix RotationMatrix(FRotator(0,BaseRotation-RotOrg.Roll,0));
const FVector2D Offset(MiniMapMargin * UIScale + (MapWidth/2.0f), Canvas->ClipY - (MapHeight/2.0f) - MiniMapMargin * UIScale );
if (MiniMapTexture)
{
FCanvasTileItem MapTileItem( FVector2D( 0.0f, 0.0f), FVector2D( 0.0f, 0.0f ), FLinearColor::White );
MapTileItem.Texture = MiniMapTexture->Resource;
MapTileItem.Size = FVector2D( MapWidth, MapHeight );
MapTileItem.BlendMode = SE_BLEND_Opaque;
Canvas->DrawItem( MapTileItem, FVector2D( MiniMapMargin * UIScale, Canvas->ClipY - MapHeight - MiniMapMargin * UIScale ) );
}
FCanvasTileItem TileItem( FVector2D( 0.0f, 0.0f), FVector2D( 0.0f, 0.0f ), FLinearColor::White );
TileItem.Size = FVector2D( 6 * UIScale, 6 * UIScale );
for (FConstPawnIterator Iterator = GetWorld()->GetPawnIterator(); Iterator; ++Iterator)
{
AStrategyChar* TestChar = Cast<AStrategyChar>(*Iterator);
if (TestChar != NULL && TestChar->GetHealth() > 0 )
{
AStrategyAIController* AIController = Cast<AStrategyAIController>(TestChar->Controller);
if (AIController != NULL && AIController->IsLogicEnabled())
{
FLinearColor DrawColor;
if (PC != NULL && TestChar->GetTeamNum() == PC->GetTeamNum())
{
DrawColor = FColor( 49, 137, 253, 255);
}
else
{
DrawColor = FColor( 242, 114, 16, 255);
}
const FVector CenterRelativeLocation = RotationMatrix.TransformPosition(TestChar->GetActorLocation() - WorldCenter);
const FVector2D MiniMapPoint = FVector2D(CenterRelativeLocation.X / WorldExtent.X, CenterRelativeLocation.Y / WorldExtent.Y);
TileItem.SetColor( DrawColor );
Canvas->DrawItem( TileItem, FVector2D( Offset.X + MiniMapPoint.X * (MapWidth/2.0f), Offset.Y + MiniMapPoint.Y * (MapHeight/2.0f) ) );
}
}
}
ULocalPlayer* MyPlayer = Cast<ULocalPlayer>(PC->Player);
FVector2D ScreenCorners[4] = { FVector2D(0, 0), FVector2D(Canvas->ClipX, 0), FVector2D(Canvas->ClipX, Canvas->ClipY), FVector2D(0, Canvas->ClipY) };
const FPlane GroundPlane = FPlane(FVector(0, 0, MyGameState->WorldBounds.Max.Z), FVector::UpVector);
for (int32 i = 0; i < 4; i++)
{
FVector RayOrigin, RayDirection;
FStrategyHelpers::DeprojectScreenToWorld(ScreenCorners[i], MyPlayer, RayOrigin, RayDirection);
const FVector GroundPoint = FStrategyHelpers::IntersectRayWithPlane(RayOrigin, RayDirection, GroundPlane);
const FVector CenterRelativeLocation = RotationMatrix.TransformPosition(GroundPoint - WorldCenter);
MiniMapPoints[i] = FVector2D(CenterRelativeLocation.X / WorldExtent.X, CenterRelativeLocation.Y / WorldExtent.Y);
}
}
}
示例8: RunCrashReportClient
void RunCrashReportClient(const TCHAR* CommandLine)
{
// Override the stack size for the thread pool.
FQueuedThreadPool::OverrideStackSize = 256 * 1024;
// Set up the main loop
GEngineLoop.PreInit(CommandLine);
// Initialize config.
FCrashReportClientConfig::Get();
const bool bUnattended =
#if CRASH_REPORT_UNATTENDED_ONLY
true;
#else
FApp::IsUnattended();
#endif // CRASH_REPORT_UNATTENDED_ONLY
// Set up the main ticker
FMainLoopTiming MainLoop(IdealTickRate, bUnattended ? EMainLoopOptions::CoreTickerOnly : EMainLoopOptions::UsingSlate);
// Find the report to upload in the command line arguments
ParseCommandLine(CommandLine);
// Increase the HttpSendTimeout to 5 minutes
GConfig->SetFloat(TEXT("HTTP"), TEXT("HttpSendTimeout"), 5*60.0f, GEngineIni);
FPlatformErrorReport::Init();
auto ErrorReport = LoadErrorReport();
if( ErrorReport.HasFilesToUpload() )
{
// Send analytics.
extern FCrashDescription& GetCrashDescription();
GetCrashDescription().SendAnalytics();
}
if (bUnattended)
{
ErrorReport.SetUserComment( NSLOCTEXT( "CrashReportClient", "UnattendedMode", "Sent in the unattended mode" ), false );
FCrashReportClientUnattended CrashReportClient( ErrorReport );
// loop until the app is ready to quit
while (!GIsRequestingExit)
{
MainLoop.Tick();
}
}
else
{
#if !CRASH_REPORT_UNATTENDED_ONLY
// crank up a normal Slate application using the platform's standalone renderer
FSlateApplication::InitializeAsStandaloneApplication(GetStandardStandaloneRenderer());
// Prepare the custom Slate styles
FCrashReportClientStyle::Initialize();
// Create the main implementation object
TSharedRef<FCrashReportClient> CrashReportClient = MakeShareable(new FCrashReportClient(ErrorReport));
// open up the app window
TSharedRef<SCrashReportClient> ClientControl = SNew(SCrashReportClient, CrashReportClient);
auto Window = FSlateApplication::Get().AddWindow(
SNew(SWindow)
.Title(NSLOCTEXT("CrashReportClient", "CrashReportClientAppName", "Unreal Engine 4 Crash Reporter"))
.ClientSize(InitialWindowDimensions)
[
ClientControl
]);
Window->SetRequestDestroyWindowOverride(FRequestDestroyWindowOverride::CreateSP(CrashReportClient, &FCrashReportClient::RequestCloseWindow));
// Setting focus seems to have to happen after the Window has been added
FSlateApplication::Get().ClearKeyboardFocus(EFocusCause::Cleared);
// Debugging code
if (RunWidgetReflector)
{
FSlateApplication::Get().AddWindow(
SNew(SWindow)
.ClientSize(FVector2D(800, 600))
[
FModuleManager::LoadModuleChecked<ISlateReflectorModule>("SlateReflector").GetWidgetReflector()
]);
}
// loop until the app is ready to quit
while (!GIsRequestingExit)
{
MainLoop.Tick();
if (CrashReportClient->ShouldWindowBeHidden())
{
Window->HideWindow();
}
}
// Clean up the custom styles
FCrashReportClientStyle::Shutdown();
//.........这里部分代码省略.........
示例9: FVector2D
void AFogOfWarWorker::UpdateFowTexture()
{
Manager->LastFrameTextureData = TArray<FColor>(Manager->TextureData);
uint32 halfTextureSize = Manager->TextureSize / 2;
int signedSize = (int)Manager->TextureSize; //For convenience....
TSet<FVector2D> texelsToBlur;
int sightTexels = Manager->SightRange * Manager->SamplesPerMeter;
float dividend = 100.0f / Manager->SamplesPerMeter;
Manager->CurrentlyInSight.Reset();
for (auto Itr(Manager->FowActors.CreateIterator()); Itr; Itr++)
{
if (StopTaskCounter.GetValue() != 0)
{
return;
}
//Find actor position
if (!*Itr) continue;
FVector position = (*Itr)->GetActorLocation();
//We divide by 100.0 because 1 texel equals 1 meter of visibility-data.
int posX = (int)(position.X / dividend) + halfTextureSize;
int posY = (int)(position.Y / dividend) + halfTextureSize;
float integerX, integerY;
FVector2D fractions = FVector2D(modf(position.X / 50.0f, &integerX), modf(position.Y / 50.0f, &integerY));
FVector2D textureSpacePos = FVector2D(posX, posY);
int size = (int)Manager->TextureSize;
FCollisionQueryParams queryParams(FName(TEXT("FOW trace")), false, (*Itr));
int halfKernelSize = (Manager->blurKernelSize - 1) / 2;
//Store the positions we want to blur
for (int y = posY - sightTexels - halfKernelSize; y <= posY + sightTexels + halfKernelSize; y++)
{
for (int x = posX - sightTexels - halfKernelSize; x <= posX + sightTexels + halfKernelSize; x++)
{
if (x > 0 && x < size && y > 0 && y < size) {
texelsToBlur.Add(FIntPoint(x, y));
}
}
}
//Unveil the positions our actors are currently looking at
for (int y = posY - sightTexels; y <= posY + sightTexels; y++)
{
for (int x = posX - sightTexels; x <= posX + sightTexels; x++)
{
//Kernel for radial sight
if (x > 0 && x < size && y > 0 && y < size)
{
FVector2D currentTextureSpacePos = FVector2D(x, y);
int length = (int)(textureSpacePos - currentTextureSpacePos).Size();
if (length <= sightTexels)
{
FVector currentWorldSpacePos = FVector(
((x - (int)halfTextureSize)) * dividend,
((y - (int)halfTextureSize)) * dividend,
position.Z);
//CONSIDER: This is NOT the most efficient way to do conditional unfogging. With long view distances and/or a lot of actors affecting the FOW-data
//it would be preferrable to not trace against all the boundary points and internal texels/positions of the circle, but create and cache "rasterizations" of
//viewing circles (using Bresenham's midpoint circle algorithm) for the needed sightranges, shift the circles to the actor's location
//and just trace against the boundaries.
//We would then use Manager->GetWorld()->LineTraceSingle() and find the first collision texel. Having found the nearest collision
//for every ray we would unveil all the points between the collision and origo using Bresenham's Line-drawing algorithm.
//However, the tracing doesn't seem like it takes much time at all (~0.02ms with four actors tracing circles of 18 texels each),
//it's the blurring that chews CPU..
if (!Manager->GetWorld()->LineTraceTestByObjectType(position, currentWorldSpacePos, ECC_WorldStatic, queryParams))
//if (!Manager->GetWorld()->LineTraceTestByChannel(position, currentWorldSpacePos, ECC_WorldStatic, queryParams))
{
//Unveil the positions we are currently seeing
Manager->UnfoggedData[x + y * Manager->TextureSize] = true;
//Store the positions we are currently seeing.
Manager->CurrentlyInSight.Add(FVector2D(x, y));
}
}
}
}
}
}
if (Manager->GetIsBlurEnabled())
{
//Horizontal blur pass
int offset = floorf(Manager->blurKernelSize / 2.0f);
for (auto Itr(texelsToBlur.CreateIterator()); Itr; ++Itr)
{
int x = (Itr)->IntPoint().X;
int y = (Itr)->IntPoint().Y;
float sum = 0;
for (int i = 0; i < Manager->blurKernelSize; i++)
{
int shiftedIndex = i - offset;
if (x + shiftedIndex >= 0 && x + shiftedIndex <= signedSize - 1)
{
if (Manager->UnfoggedData[x + shiftedIndex + (y * signedSize)])
{
//.........这里部分代码省略.........
示例10: FVector2D
FVector2D SAutoFolding::ComputeDesiredSize(float) const
{
return FVector2D(100, 50);
}
示例11: FMargin
void SScrubControlPanel::Construct( const SScrubControlPanel::FArguments& InArgs )
{
ScrubWidget = NULL;
IsRealtimeStreamingMode = InArgs._IsRealtimeStreamingMode;
FEditorWidgetsModule& EditorWidgetsModule = FModuleManager::Get().LoadModuleChecked<FEditorWidgetsModule>( "EditorWidgets" );
FTransportControlArgs TransportControlArgs;
TransportControlArgs.OnForwardPlay = InArgs._OnClickedForwardPlay;
TransportControlArgs.OnRecord = InArgs._OnClickedRecord;
TransportControlArgs.OnBackwardPlay = InArgs._OnClickedBackwardPlay;
TransportControlArgs.OnForwardStep = InArgs._OnClickedForwardStep;
TransportControlArgs.OnBackwardStep = InArgs._OnClickedBackwardStep;
TransportControlArgs.OnForwardEnd = InArgs._OnClickedForwardEnd;
TransportControlArgs.OnBackwardEnd = InArgs._OnClickedBackwardEnd;
TransportControlArgs.OnToggleLooping = InArgs._OnClickedToggleLoop;
TransportControlArgs.OnGetLooping = InArgs._OnGetLooping;
TransportControlArgs.OnGetPlaybackMode = InArgs._OnGetPlaybackMode;
TransportControlArgs.OnTickPlayback = InArgs._OnTickPlayback;
FTransportControlArgs TransportControlArgsForRealtimeStreamingMode;
TransportControlArgsForRealtimeStreamingMode.OnForwardPlay = TransportControlArgs.OnForwardPlay;
TransportControlArgsForRealtimeStreamingMode.OnForwardStep = TransportControlArgs.OnForwardStep;
TransportControlArgsForRealtimeStreamingMode.OnGetPlaybackMode = TransportControlArgs.OnGetPlaybackMode;
this->ChildSlot
.Padding( FMargin( 0.0f, 1.0f) )
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Center)
.FillWidth(1)
.Padding( FMargin( 0.0f, 0.0f) )
[
SNew( SBorder )
[
SAssignNew(ScrubWidget, SScrubWidget)
.Value(InArgs._Value)
.NumOfKeys(InArgs._NumOfKeys)
.SequenceLength(InArgs._SequenceLength)
.OnValueChanged(InArgs._OnValueChanged)
.OnBeginSliderMovement(InArgs._OnBeginSliderMovement)
.OnEndSliderMovement(InArgs._OnEndSliderMovement)
.ViewInputMin(InArgs._ViewInputMin)
.ViewInputMax(InArgs._ViewInputMax)
.OnSetInputViewRange(InArgs._OnSetInputViewRange)
.OnCropAnimSequence(InArgs._OnCropAnimSequence)
.OnAddAnimSequence(InArgs._OnAddAnimSequence)
.OnReZeroAnimSequence(InArgs._OnReZeroAnimSequence)
.bAllowZoom(InArgs._bAllowZoom)
.DraggableBars(InArgs._DraggableBars)
.OnBarDrag(InArgs._OnBarDrag)
]
]
// Padding
+SHorizontalBox::Slot()
.AutoWidth()
[
// Padding to make controls line up with the track label widths.
// note: a more robust way to accomplish this would be nice.
SNew(SSpacer)
.Size(FVector2D(16.0f, 16.0f))
]
+SHorizontalBox::Slot()
.AutoWidth()
[
SNew(SBorder)
.Padding(0)
.BorderImage(FEditorStyle::GetBrush("NoBorder"))
.Visibility(this, &SScrubControlPanel::GetRealtimeControlVisibility, false)
[
EditorWidgetsModule.CreateTransportControl(TransportControlArgs)
]
]
+SHorizontalBox::Slot()
.AutoWidth()
[
SNew(SBorder)
.Padding(0)
.BorderImage(FEditorStyle::GetBrush("NoBorder"))
.Visibility(this, &SScrubControlPanel::GetRealtimeControlVisibility, true)
[
EditorWidgetsModule.CreateTransportControl(TransportControlArgsForRealtimeStreamingMode)
]
]
];
}
示例12: SNew
void SLogVisualizerTimeline::Construct(const FArguments& InArgs, TSharedPtr<FVisualLoggerTimeSliderController> TimeSliderController, TSharedPtr<SVisualLoggerTimelinesContainer> InContainer, FName InName, FName InOwnerClassName)
{
OnGetMenuContent = InArgs._OnGetMenuContent;
Owner = InContainer;
OwnerName = InName;
OwnerClassName = InOwnerClassName;
ChildSlot
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.Padding(FMargin(0, 4, 0, 0))
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
.FillWidth(TAttribute<float>::Create(TAttribute<float>::FGetter::CreateLambda([=] { return FLogVisualizer::Get().GetAnimationOutlinerFillPercentage(); })))
[
SAssignNew(PopupAnchor, STimelineLabelAnchor, SharedThis(this))
.OnGetMenuContent(OnGetMenuContent)
[
SNew(SBorder)
.HAlign(HAlign_Fill)
.Padding(FMargin(0, 0, 4, 0))
.BorderImage(FCoreStyle::Get().GetBrush("NoBorder"))
[
SNew(SBorder)
.VAlign(VAlign_Center)
.BorderImage(this, &SLogVisualizerTimeline::GetBorder)
.Padding(FMargin(4, 0, 2, 0))
[
// Search box for searching through the outliner
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.Padding(FMargin(0, 0, 0, 0))
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(STextBlock)
.Text(FText::FromName(OwnerName))
.ShadowOffset(FVector2D(1.f, 1.f))
]
+ SVerticalBox::Slot()
.Padding(FMargin(0, 0, 0, 0))
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
[
SNew(STextBlock)
.Text(FText::FromName(OwnerClassName))
.TextStyle(FLogVisualizerStyle::Get(), TEXT("Sequencer.ClassNAme"))
]
]
]
]
]
+ SHorizontalBox::Slot()
.Padding(FMargin(0, 4, 0, 0))
.HAlign(HAlign_Left)
[
SNew(SBox)
.Padding(FMargin(0, 0, 0, 0))
.HAlign(HAlign_Left)
[
// Search box for searching through the outliner
SAssignNew(TimelineBar, SVisualLoggerTimelineBar, TimeSliderController, SharedThis(this))
]
]
];
ULogVisualizerSettings::StaticClass()->GetDefaultObject<ULogVisualizerSettings>()->OnSettingChanged().AddRaw(this, &SLogVisualizerTimeline::HandleLogVisualizerSettingChanged);
FVisualLoggerDatabase::Get().GetEvents().OnNewItem.AddRaw(this, &SLogVisualizerTimeline::OnNewItemHandler);
FVisualLoggerDatabase::Get().GetEvents().OnRowSelectionChanged.AddRaw(this, &SLogVisualizerTimeline::OnRowSelectionChanged);
}
示例13: FVector2D
FVector2D UKismetMathLibrary::MakeVector2D(float X, float Y)
{
return FVector2D(X, Y);
}
示例14: Construct
/**
* Construct the widget
*
* @param InDeclaration A declaration from which to construct the widget
*/
void Construct( const STableColumnHeader::FArguments& InArgs, const SHeaderRow::FColumn& Column, const FMargin DefaultHeaderContentPadding )
{
check(InArgs._Style);
SWidget::Construct( InArgs._ToolTipText, InArgs._ToolTip, InArgs._Cursor, InArgs._IsEnabled, InArgs._Visibility, InArgs._RenderTransform, InArgs._RenderTransformPivot, InArgs._Tag, InArgs._ForceVolatile, InArgs.MetaData );
Style = InArgs._Style;
ColumnId = Column.ColumnId;
SortMode = Column.SortMode;
SortPriority = Column.SortPriority;
OnSortModeChanged = Column.OnSortModeChanged;
ContextMenuContent = Column.HeaderMenuContent.Widget;
ComboVisibility = Column.HeaderComboVisibility;
FMargin AdjustedDefaultHeaderContentPadding = DefaultHeaderContentPadding;
TAttribute< FText > LabelText = Column.DefaultText;
TAttribute< FText > TooltipText = Column.DefaultTooltip;
if (Column.HeaderContent.Widget == SNullWidget::NullWidget)
{
if (!Column.DefaultText.IsSet())
{
LabelText = FText::FromString( Column.ColumnId.ToString() + TEXT("[LabelMissing]") );
}
if (!Column.DefaultTooltip.IsSet())
{
TooltipText = LabelText;
}
}
TSharedPtr< SHorizontalBox > Box;
TSharedRef< SOverlay > Overlay = SNew( SOverlay );
Overlay->AddSlot( 0 )
[
SAssignNew( Box, SHorizontalBox )
];
TSharedRef< SWidget > PrimaryContent = Column.HeaderContent.Widget;
if ( PrimaryContent == SNullWidget::NullWidget )
{
PrimaryContent =
SNew( SBox )
.Padding( OnSortModeChanged.IsBound() ? FMargin( 0, 2, 0, 2 ) : FMargin( 0, 4, 0, 4 ) )
.VAlign( VAlign_Center )
[
SNew(STextBlock)
.Text( LabelText )
.ToolTipText( TooltipText )
];
}
if ( OnSortModeChanged.IsBound() )
{
//optional main button with the column's title. Used to toggle sorting modes.
PrimaryContent = SNew(SButton)
.ButtonStyle( FCoreStyle::Get(), "NoBorder" )
.ForegroundColor( FSlateColor::UseForeground() )
.ContentPadding( FMargin( 0, 2, 0, 2 ) )
.OnClicked(this, &STableColumnHeader::OnTitleClicked)
[
PrimaryContent
];
}
Box->AddSlot()
.FillWidth(1.0f)
[
PrimaryContent
];
if( Column.HeaderMenuContent.Widget != SNullWidget::NullWidget )
{
// Add Drop down menu button (only if menu content has been specified)
Box->AddSlot()
.AutoWidth()
[
SAssignNew( MenuOverlay, SOverlay )
.Visibility( this, &STableColumnHeader::GetMenuOverlayVisibility )
+SOverlay::Slot()
[
SNew( SSpacer )
.Size( FVector2D( 12.0f, 0 ) )
]
+SOverlay::Slot()
.Padding(FMargin(0,1,0,1))
[
SNew( SBorder )
.Padding( FMargin( 0, 0, AdjustedDefaultHeaderContentPadding.Right, 0 ) )
.BorderImage( this, &STableColumnHeader::GetComboButtonBorderBrush )
//.........这里部分代码省略.........
示例15: FVector2D
FVector2D SErrorText::GetDesiredSizeScale() const
{
const float AnimAmount = ExpandAnimation.GetLerp();
return FVector2D( 1.0f, AnimAmount );
}