本文整理汇总了C++中TArray类的典型用法代码示例。如果您正苦于以下问题:C++ TArray类的具体用法?C++ TArray怎么用?C++ TArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateEncounterFrequency
void GenerateEncounterFrequency (CUniverse &Universe, CXMLElement *pCmdLine)
{
enum ETypes
{
outputFreq,
outputFillLocations,
};
int i, j;
// Options
int iSystemSample = pCmdLine->GetAttributeIntegerBounded(CONSTLIT("count"), 1, -1, 1);
bool bLogo = !pCmdLine->GetAttributeBool(CONSTLIT("noLogo"));
bool bAll = pCmdLine->GetAttributeBool(CONSTLIT("all"));
bool bRawData = pCmdLine->GetAttributeBool(CONSTLIT("rawData"));
ETypes iType;
if (pCmdLine->GetAttributeBool(CONSTLIT("fillLocations")))
iType = outputFillLocations;
else
iType = outputFreq;
// Additional columns
TArray<CString> Cols;
for (i = 0; i < pCmdLine->GetAttributeCount(); i++)
{
CString sAttrib = pCmdLine->GetAttributeName(i);
if (!IsMainCommandParam(sAttrib)
&& !strEquals(sAttrib, CONSTLIT("count"))
&& !strEquals(sAttrib, CONSTLIT("fillLocations"))
&& !strEquals(sAttrib, CONSTLIT("rawData"))
&& !strEquals(sAttrib, CONSTLIT("encounterfreq")))
{
CString sValue = pCmdLine->GetAttribute(i);
if (!strEquals(sValue, CONSTLIT("true")))
Cols.Insert(strPatternSubst(CONSTLIT("%s:%s"), sAttrib, sValue));
else
Cols.Insert(sAttrib);
}
}
// Generate systems for multiple games
CSystemCreateStats Stats;
for (i = 0; i < iSystemSample; i++)
{
if (bLogo)
printf("pass %d...\n", i+1);
// Initialize the game
CString sError;
if (Universe.InitGame(0, &sError) != NOERROR)
{
printf("%s\n", sError.GetASCIIZPointer());
return;
}
for (j = 0; j < Universe.GetTopologyNodeCount(); j++)
{
CTopologyNode *pNode = Universe.GetTopologyNode(j);
if (pNode->IsEndGame())
continue;
// Create the system
CSystem *pSystem;
if (Universe.CreateStarSystem(pNode, &pSystem, NULL, &Stats) != NOERROR)
{
printf("ERROR: Unable to create star system.\n");
return;
}
// Done with old system
Universe.DestroySystem(pSystem);
}
Universe.Reinit();
}
// Output based on type
if (iType == outputFreq)
{
// Generate a table for each encounter
TSortMap<CStationType *, SEncounterFreqEntry> EncounterFreq;
for (i = 0; i < Stats.GetEncounterTableCount(); i++)
{
const CSystemCreateStats::SEncounterTable &Table = Stats.GetEncounterTable(i);
// Skip if only planets and asteroids
if (!Table.bHasStation && !bAll)
//.........这里部分代码省略.........
示例2: ParseRow
bool CCSVParser::ParseRow (TArray<CString> &Row, CString *retsError)
// ParseRow
//
// Parses a row
{
enum EStates
{
stateStart,
stateSingleQuote,
stateDoubleQuote,
stateInPlainValue,
stateEndOfValue,
stateCR,
stateLF,
};
Row.DeleteAll();
// Parse the BOM, if any
if (m_iFormat == formatUnknown)
m_iFormat = ParseBOM();
// Keep reading until we hit the end of the line.
EStates iState = stateStart;
CBuffer Value;
while (true)
{
switch (iState)
{
case stateStart:
{
switch (GetCurChar())
{
case '\0':
return true;
case ' ':
case '\t':
break;
case ',':
Row.Insert(NULL_STR);
break;
case '\r':
iState = stateCR;
break;
case '\n':
iState = stateLF;
break;
case '\'':
iState = stateSingleQuote;
break;
case '\"':
iState = stateDoubleQuote;
break;
default:
Value.WriteChar(GetCurChar());
iState = stateInPlainValue;
break;
}
break;
}
case stateSingleQuote:
{
switch (GetCurChar())
{
case '\0':
Row.Insert(CString(Value.GetPointer(), Value.GetLength()));
return true;
case '\'':
Row.Insert(CString(Value.GetPointer(), Value.GetLength()));
Value.SetLength(0);
iState = stateEndOfValue;
break;
default:
Value.WriteChar(GetCurChar());
break;
}
break;
}
case stateDoubleQuote:
{
switch (GetCurChar())
{
case '\0':
Row.Insert(CString(Value.GetPointer(), Value.GetLength()));
return true;
//.........这里部分代码省略.........
示例3: StringFromBinaryArray
//Rama's String From Binary Array
//This function requires #include <string>
FString CloudyWebConnectorImpl::StringFromBinaryArray(const TArray<uint8>& BinaryArray)
{
//Create a string from a byte array!
std::string cstr(reinterpret_cast<const char*>(BinaryArray.GetData()), BinaryArray.Num());
return FString(cstr.c_str());
}
示例4: EvaluateBoneTransforms
void FAnimNode_TwoBoneIK::EvaluateBoneTransforms(USkeletalMeshComponent* SkelComp, FCSPose<FCompactPose>& MeshBases, TArray<FBoneTransform>& OutBoneTransforms)
{
SCOPE_CYCLE_COUNTER(STAT_TwoBoneIK_Eval);
check(OutBoneTransforms.Num() == 0);
const FBoneContainer& BoneContainer = MeshBases.GetPose().GetBoneContainer();
// Get indices of the lower and upper limb bones and check validity.
bool bInvalidLimb = false;
FCompactPoseBoneIndex IKBoneCompactPoseIndex = IKBone.GetCompactPoseIndex(BoneContainer);
const FCompactPoseBoneIndex LowerLimbIndex = BoneContainer.GetParentBoneIndex(IKBoneCompactPoseIndex);
if (LowerLimbIndex == INDEX_NONE)
{
bInvalidLimb = true;
}
const FCompactPoseBoneIndex UpperLimbIndex = BoneContainer.GetParentBoneIndex(LowerLimbIndex);
if (UpperLimbIndex == INDEX_NONE)
{
bInvalidLimb = true;
}
const bool bInBoneSpace = (EffectorLocationSpace == BCS_ParentBoneSpace) || (EffectorLocationSpace == BCS_BoneSpace);
const int32 EffectorBoneIndex = bInBoneSpace ? BoneContainer.GetPoseBoneIndexForBoneName(EffectorSpaceBoneName) : INDEX_NONE;
const FCompactPoseBoneIndex EffectorSpaceBoneIndex = BoneContainer.MakeCompactPoseIndex(FMeshPoseBoneIndex(EffectorBoneIndex));
if (bInBoneSpace && (EffectorSpaceBoneIndex == INDEX_NONE))
{
bInvalidLimb = true;
}
// If we walked past the root, this controlled is invalid, so return no affected bones.
if( bInvalidLimb )
{
return;
}
// Get Local Space transforms for our bones. We do this first in case they already are local.
// As right after we get them in component space. (And that does the auto conversion).
// We might save one transform by doing local first...
const FTransform EndBoneLocalTransform = MeshBases.GetLocalSpaceTransform(IKBoneCompactPoseIndex);
// Now get those in component space...
FTransform LowerLimbCSTransform = MeshBases.GetComponentSpaceTransform(LowerLimbIndex);
FTransform UpperLimbCSTransform = MeshBases.GetComponentSpaceTransform(UpperLimbIndex);
FTransform EndBoneCSTransform = MeshBases.GetComponentSpaceTransform(IKBoneCompactPoseIndex);
// Get current position of root of limb.
// All position are in Component space.
const FVector RootPos = UpperLimbCSTransform.GetTranslation();
const FVector InitialJointPos = LowerLimbCSTransform.GetTranslation();
const FVector InitialEndPos = EndBoneCSTransform.GetTranslation();
// Transform EffectorLocation from EffectorLocationSpace to ComponentSpace.
FTransform EffectorTransform(EffectorLocation);
FAnimationRuntime::ConvertBoneSpaceTransformToCS(SkelComp, MeshBases, EffectorTransform, EffectorSpaceBoneIndex, EffectorLocationSpace);
// This is our reach goal.
FVector DesiredPos = EffectorTransform.GetTranslation();
FVector DesiredDelta = DesiredPos - RootPos;
float DesiredLength = DesiredDelta.Size();
// Check to handle case where DesiredPos is the same as RootPos.
FVector DesiredDir;
if (DesiredLength < (float)KINDA_SMALL_NUMBER)
{
DesiredLength = (float)KINDA_SMALL_NUMBER;
DesiredDir = FVector(1,0,0);
}
else
{
DesiredDir = DesiredDelta / DesiredLength;
}
// Get joint target (used for defining plane that joint should be in).
FTransform JointTargetTransform(JointTargetLocation);
FCompactPoseBoneIndex JointTargetSpaceBoneIndex(INDEX_NONE);
if (JointTargetLocationSpace == BCS_ParentBoneSpace || JointTargetLocationSpace == BCS_BoneSpace)
{
int32 Index = BoneContainer.GetPoseBoneIndexForBoneName(JointTargetSpaceBoneName);
JointTargetSpaceBoneIndex = BoneContainer.MakeCompactPoseIndex(FMeshPoseBoneIndex(Index));
}
FAnimationRuntime::ConvertBoneSpaceTransformToCS(SkelComp, MeshBases, JointTargetTransform, JointTargetSpaceBoneIndex, JointTargetLocationSpace);
FVector JointTargetPos = JointTargetTransform.GetTranslation();
FVector JointTargetDelta = JointTargetPos - RootPos;
const float JointTargetLengthSqr = JointTargetDelta.SizeSquared();
// Same check as above, to cover case when JointTarget position is the same as RootPos.
FVector JointPlaneNormal, JointBendDir;
if (JointTargetLengthSqr < FMath::Square((float)KINDA_SMALL_NUMBER))
{
JointBendDir = FVector(0,1,0);
JointPlaneNormal = FVector(0,0,1);
}
//.........这里部分代码省略.........
示例5: HandleCpiAttributeResponseL
void CGlxCollectionPluginAlbums::HandleCpiAttributeResponseL(CMPXMedia* aResponse, TArray<TMPXAttribute> aCpiAttributes, TGlxMediaId aMediaId)
{
_LIT(KResourceFile, "z:glxpluginalbums.rsc");
const TInt attribCount = aCpiAttributes.Count();
for (TInt index = 0; index < attribCount ; index++)
{
const TMPXAttribute attr = aCpiAttributes[index];
if (attr == KGlxMediaCollectionPluginSpecificSubTitle)
{
TInt usageCount = 0;
if ( aResponse->IsSupported(KMPXMediaGeneralCount) )
{
usageCount = aResponse->ValueTObjectL<TInt>(KMPXMediaGeneralCount);
}
else if ( aResponse->IsSupported(KGlxMediaCollectionInternalUsageCount) )
{
usageCount = aResponse->ValueTObjectL<TInt>(KGlxMediaCollectionInternalUsageCount);
aResponse->Delete(KGlxMediaCollectionInternalUsageCount);
}
else
{
User::Leave(KErrNotSupported);
}
HBufC* tempTitle = NULL;
if (TGlxMediaId(KGlxCollectionRootId) == aMediaId)
{
if (1 == usageCount)
{
tempTitle = LoadLocalizedStringLC(KResourceFile, R_ALBUM_SUB_TITLE_SINGLE);
}
else
{
tempTitle = LoadLocalizedStringLC(KResourceFile, R_ALBUM_SUB_TITLE_MULTI);
}
}
else
{
tempTitle = HbTextResolverSymbian::LoadLC(KAlbumContainer, usageCount);
// Set the title in the response.
aResponse->SetTextValueL(attr, *tempTitle);
CleanupStack::PopAndDestroy(tempTitle);
continue;
}
TPtr formatString = tempTitle->Des();
// Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number
HBufC* title = HBufC::NewLC(formatString.Length() + 10);
TPtr ptr = title->Des();
StringLoader::Format(ptr, formatString, -1, usageCount);
// Set the title in the response.
aResponse->SetTextValueL(attr, *title);
CleanupStack::PopAndDestroy(title);
CleanupStack::PopAndDestroy(tempTitle);
}
else if (attr == KGlxMediaCollectionPluginSpecificSelectMediaPopupTitle)
{
HBufC* title = LoadLocalizedStringLC(KResourceFile, R_ALBUM_POPUP_TITLE);
aResponse->SetTextValueL(attr, *title);
CleanupStack::PopAndDestroy(title);
}
else if (attr == KGlxMediaCollectionPluginSpecificNewMediaItemTitle)
{
HBufC* title = LoadLocalizedStringLC(KResourceFile, R_ALBUM_ITEM_TITLE);
aResponse->SetTextValueL(attr, *title);
CleanupStack::PopAndDestroy(title);
}
else if (attr == KGlxMediaCollectionPluginSpecificDefaultMediaTitle)
{
HBufC* title = LoadLocalizedStringLC(KResourceFile, R_ALBUM_DEFAULT_TITLE);
aResponse->SetTextValueL(attr, *title);
CleanupStack::PopAndDestroy(title);
}
else if (attr == KMPXMediaGeneralTitle)
{
if( TGlxMediaId(KGlxCollectionRootId) == aMediaId )
{
HBufC* title = LoadLocalizedStringLC(KResourceFile, R_ALBUM_GENERAL_TITLE);
aResponse->SetTextValueL(attr, *title);
CleanupStack::PopAndDestroy(title);
}
else
{
if( aResponse->IsSupported(KGlxMediaCollectionInternalSystemItemType) )
{
if( TGlxMediaId(KCapturedAlbumId) == aMediaId )
{
HBufC* title = HbTextResolverSymbian::LoadLC(KCameraText);
aResponse->SetTextValueL(attr, *title);
CleanupStack::PopAndDestroy(title);
}
else if (TGlxMediaId(KFavoriteAlbumId) == aMediaId )
//.........这里部分代码省略.........
示例6: QueryConnectedDevices
void QueryConnectedDevices()
{
// grab the list of devices via adb
FString StdOut;
if (!ExecuteAdbCommand(TEXT("devices -l"), &StdOut, nullptr))
{
return;
}
// separate out each line
TArray<FString> DeviceStrings;
StdOut = StdOut.Replace(TEXT("\r"), TEXT("\n"));
StdOut.ParseIntoArray(&DeviceStrings, TEXT("\n"), true);
// a list containing all devices found this time, so we can remove anything not in this list
TArray<FString> CurrentlyConnectedDevices;
for (int32 StringIndex = 0; StringIndex < DeviceStrings.Num(); ++StringIndex)
{
const FString& DeviceString = DeviceStrings[StringIndex];
// skip over non-device lines
if (DeviceString.StartsWith("* ") || DeviceString.StartsWith("List "))
{
continue;
}
// grab the device serial number
int32 TabIndex;
if (!DeviceString.FindChar(TCHAR(' '), TabIndex))
{
continue;
}
FAndroidDeviceInfo NewDeviceInfo;
NewDeviceInfo.SerialNumber = DeviceString.Left(TabIndex);
const FString DeviceState = DeviceString.Mid(TabIndex + 1).Trim();
NewDeviceInfo.bUnauthorizedDevice = DeviceState == TEXT("unauthorized");
// add it to our list of currently connected devices
CurrentlyConnectedDevices.Add(NewDeviceInfo.SerialNumber);
// move on to next device if this one is already a known device
if (DeviceMap.Contains(NewDeviceInfo.SerialNumber))
{
continue;
}
if (NewDeviceInfo.bUnauthorizedDevice)
{
NewDeviceInfo.DeviceName = TEXT("Unauthorized - enable USB debugging");
}
else
{
// grab the Android version
const FString AndroidVersionCommand = FString::Printf(TEXT("-s %s shell getprop ro.build.version.release"), *NewDeviceInfo.SerialNumber);
if (!ExecuteAdbCommand(*AndroidVersionCommand, &NewDeviceInfo.HumanAndroidVersion, nullptr))
{
continue;
}
NewDeviceInfo.HumanAndroidVersion = NewDeviceInfo.HumanAndroidVersion.Replace(TEXT("\r"), TEXT("")).Replace(TEXT("\n"), TEXT(""));
NewDeviceInfo.HumanAndroidVersion.Trim().TrimTrailing();
// grab the Android SDK version
const FString SDKVersionCommand = FString::Printf(TEXT("-s %s shell getprop ro.build.version.sdk"), *NewDeviceInfo.SerialNumber);
FString SDKVersionString;
if (!ExecuteAdbCommand(*SDKVersionCommand, &SDKVersionString, nullptr))
{
continue;
}
NewDeviceInfo.SDKVersion = FCString::Atoi(*SDKVersionString);
if (NewDeviceInfo.SDKVersion <= 0)
{
NewDeviceInfo.SDKVersion = INDEX_NONE;
}
// get the GL extensions string (and a bunch of other stuff)
const FString ExtensionsCommand = FString::Printf(TEXT("-s %s shell dumpsys SurfaceFlinger"), *NewDeviceInfo.SerialNumber);
if (!ExecuteAdbCommand(*ExtensionsCommand, &NewDeviceInfo.GLESExtensions, nullptr))
{
continue;
}
// grab the GL ES version
FString GLESVersionString;
const FString GLVersionCommand = FString::Printf(TEXT("-s %s shell getprop ro.opengles.version"), *NewDeviceInfo.SerialNumber);
if (!ExecuteAdbCommand(*GLVersionCommand, &GLESVersionString, nullptr))
{
continue;
}
NewDeviceInfo.GLESVersion = FCString::Atoi(*GLESVersionString);
// parse the device model
FParse::Value(*DeviceString, TEXT("model:"), NewDeviceInfo.Model);
if (NewDeviceInfo.Model.IsEmpty())
{
FString ModelCommand = FString::Printf(TEXT("-s %s shell getprop ro.product.model"), *NewDeviceInfo.SerialNumber);
//.........这里部分代码省略.........
示例7: FLinearColor
void FEQSSceneProxy::CollectEQSData(const FEnvQueryResult* ResultItems, const FEnvQueryInstance* QueryInstance, float HighlightRangePct, bool ShouldDrawFailedItems, TArray<FSphere>& Spheres, TArray<FText3d>& Texts, TArray<EQSDebug::FDebugHelper>& DebugItems)
{
if (ResultItems == NULL)
{
if (QueryInstance == NULL)
{
return;
}
else
{
ResultItems = QueryInstance;
}
}
// using "mid-results" requires manual normalization
const bool bUseMidResults = QueryInstance && (QueryInstance->Items.Num() < QueryInstance->DebugData.DebugItems.Num());
// no point in checking if QueryInstance != null since bUseMidResults == true guarantees that, PVS-Studio doesn't
// understand that invariant though, and we need to disable V595:
const TArray<FEnvQueryItem>& Items = bUseMidResults ? QueryInstance->DebugData.DebugItems : ResultItems->Items; //-V595
const TArray<uint8>& RawData = bUseMidResults ? QueryInstance->DebugData.RawData : ResultItems->RawData;
const int32 ItemCountLimit = FMath::Clamp(Items.Num(), 0, EQSMaxItemsDrawn);
const bool bNoTestsPerformed = QueryInstance != NULL && QueryInstance->CurrentTest <= 0;
const bool bSingleItemResult = QueryInstance != NULL && QueryInstance->DebugData.bSingleItemResult;
float MinScore = 0.f;
float MaxScore = -BIG_NUMBER;
if (bUseMidResults || HighlightRangePct < 1.0f)
{
const FEnvQueryItem* ItemInfo = Items.GetData();
for (int32 ItemIndex = 0; ItemIndex < Items.Num(); ItemIndex++, ItemInfo++)
{
if (ItemInfo->IsValid())
{
MinScore = FMath::Min(MinScore, ItemInfo->Score);
MaxScore = FMath::Max(MaxScore, ItemInfo->Score);
}
}
}
const float ScoreNormalizer = bUseMidResults && (MaxScore != MinScore) ? 1.f / (MaxScore - MinScore) : 1.f;
const float HighlightThreshold = (HighlightRangePct < 1.0f) ? (MaxScore * HighlightRangePct) : FLT_MAX;
if (bSingleItemResult == false)
{
for (int32 ItemIndex = 0; ItemIndex < ItemCountLimit; ++ItemIndex)
{
if (Items[ItemIndex].IsValid())
{
const float Score = bNoTestsPerformed ? 1 : Items[ItemIndex].Score * ScoreNormalizer;
const bool bLowRadius = (HighlightThreshold < FLT_MAX) && (bNoTestsPerformed || (Items[ItemIndex].Score < HighlightThreshold));
const float Radius = ItemDrawRadius.X * (bLowRadius ? 0.2f : 1.0f);
const FVector Loc = FEQSRenderingHelper::ExtractLocation(ResultItems->ItemType, RawData, Items, ItemIndex);
Spheres.Add(FSphere(Radius, Loc, bNoTestsPerformed == false
? FLinearColor(FColor::MakeRedToGreenColorFromScalar(Score))
: FLinearColor(0.2, 1.0, 1.0, 1)));
DebugItems.Add(EQSDebug::FDebugHelper(Loc, Radius));
const FString Label = bNoTestsPerformed ? TEXT("") : FString::Printf(TEXT("%.2f"), Score);
Texts.Add(FText3d(Label, Loc, FLinearColor::White));
}
}
}
else if (ItemCountLimit > 0)
{
if (Items[0].IsValid())
{
const float Score = Items[0].Score * ScoreNormalizer;
const bool bLowRadius = false;
const float Radius = ItemDrawRadius.X * (bLowRadius ? 0.2f : 1.0f);
const FVector Loc = FEQSRenderingHelper::ExtractLocation(ResultItems->ItemType, RawData, Items, 0);
Spheres.Add(FSphere(Radius, Loc, FLinearColor(0.0, 1.0, 0.12, 1)));
DebugItems.Add(EQSDebug::FDebugHelper(Loc, Radius));
const FString Label = FString::Printf(TEXT("Winner %.2f"), Score);
Texts.Add(FText3d(Label, Loc, FLinearColor::White));
}
for (int32 ItemIndex = 1; ItemIndex < ItemCountLimit; ++ItemIndex)
{
if (Items[ItemIndex].IsValid())
{
const float Score = bNoTestsPerformed ? 1 : Items[ItemIndex].Score * ScoreNormalizer;
const bool bLowRadius = (HighlightThreshold < FLT_MAX) && (bNoTestsPerformed || (Items[ItemIndex].Score < HighlightThreshold));
const float Radius = ItemDrawRadius.X * (bLowRadius ? 0.2f : 1.0f);
const FVector Loc = FEQSRenderingHelper::ExtractLocation(ResultItems->ItemType, RawData, Items, ItemIndex);
Spheres.Add(FSphere(Radius, Loc, FLinearColor(0.0, 0.2, 0.025, 1)));
DebugItems.Add(EQSDebug::FDebugHelper(Loc, Radius));
const FString Label = bNoTestsPerformed ? TEXT("") : FString::Printf(TEXT("%.2f"), Score);
Texts.Add(FText3d(Label, Loc, FLinearColor::White));
}
}
}
if (ShouldDrawFailedItems && QueryInstance)
{
//.........这里部分代码省略.........
示例8: OnGetAllowedClasses
void SPropertyEditorAsset::OnGetAllowedClasses(TArray<const UClass*>& AllowedClasses)
{
AllowedClasses.Add(ObjectClass);
}
示例9: OnArrangeChildren
void SGridPanel::OnArrangeChildren( const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren ) const
{
// PREPARE PHASE
// Prepare some data for arranging children.
// FinalColumns will be populated with column sizes that include the stretched column sizes.
// Then we will build partial sums so that we can easily handle column spans.
// Repeat the same for rows.
float ColumnCoeffTotal = 0.0f;
TArray<float> FinalColumns;
if ( Columns.Num() > 0 )
{
FinalColumns.AddUninitialized(Columns.Num());
FinalColumns[FinalColumns.Num()-1] = 0.0f;
}
float RowCoeffTotal = 0.0f;
TArray<float> FinalRows;
if ( Rows.Num() > 0 )
{
FinalRows.AddUninitialized(Rows.Num());
FinalRows[FinalRows.Num()-1] = 0.0f;
}
CalculateStretchedCellSizes(FinalColumns, AllottedGeometry.Size.X, Columns, ColFillCoefficients);
CalculateStretchedCellSizes(FinalRows, AllottedGeometry.Size.Y, Rows, RowFillCoefficients);
// Build up partial sums for row and column sizes so that we can handle column and row spans conveniently.
ComputePartialSums(FinalColumns);
ComputePartialSums(FinalRows);
// ARRANGE PHASE
for( int32 SlotIndex=0; SlotIndex < Slots.Num(); ++SlotIndex )
{
const FSlot& CurSlot = Slots[SlotIndex];
const EVisibility ChildVisibility = CurSlot.GetWidget()->GetVisibility();
if ( ArrangedChildren.Accepts(ChildVisibility) )
{
// Figure out the position of this cell.
const FVector2D ThisCellOffset( FinalColumns[CurSlot.ColumnParam], FinalRows[CurSlot.RowParam] );
// Figure out the size of this slot; takes row span into account.
// We use the properties of partial sums arrays to achieve this.
const FVector2D CellSize(
FinalColumns[CurSlot.ColumnParam+CurSlot.ColumnSpanParam] - ThisCellOffset.X ,
FinalRows[CurSlot.RowParam+CurSlot.RowSpanParam] - ThisCellOffset.Y );
// Do the standard arrangement of elements within a slot
// Takes care of alignment and padding.
const FMargin SlotPadding(CurSlot.SlotPadding.Get());
AlignmentArrangeResult XAxisResult = AlignChild<Orient_Horizontal>( CellSize.X, CurSlot, SlotPadding );
AlignmentArrangeResult YAxisResult = AlignChild<Orient_Vertical>( CellSize.Y, CurSlot, SlotPadding );
// Output the result
ArrangedChildren.AddWidget( ChildVisibility, AllottedGeometry.MakeChild(
CurSlot.GetWidget(),
ThisCellOffset + FVector2D( XAxisResult.Offset, YAxisResult.Offset ) + CurSlot.NudgeParam,
FVector2D(XAxisResult.Size, YAxisResult.Size)
));
}
}
}
示例10: SkipByteCodeHelper
//------------------------------------------------------------------------------
bool FStructScriptLoader::LoadStructWithScript(UStruct* DestScriptContainer, FArchive& Ar, bool bAllowDeferredSerialization)
{
if (!Ar.IsLoading() || !IsPrimed() || GIsDuplicatingClassForReinstancing)
{
return false;
}
bool const bIsLinkerLoader = Ar.IsPersistent() && (Ar.GetLinker() != nullptr);
int32 const ScriptEndOffset = ScriptSerializationOffset + SerializedScriptSize;
// to help us move development forward (and not have to support ancient
// script code), we define a minimum script version
bool bSkipScriptSerialization = (Ar.UE4Ver() < VER_MIN_SCRIPTVM_UE4) || (Ar.LicenseeUE4Ver() < VER_MIN_SCRIPTVM_LICENSEEUE4);
#if WITH_EDITOR
static const FBoolConfigValueHelper SkipByteCodeHelper(TEXT("StructSerialization"), TEXT("SkipByteCodeSerialization"));
// in editor builds, we're going to regenerate the bytecode anyways, so it
// is a waste of cycles to try and serialize it in
bSkipScriptSerialization |= (bool)SkipByteCodeHelper;
#endif // WITH_EDITOR
bSkipScriptSerialization &= bIsLinkerLoader; // to keep consistent with old UStruct::Serialize() functionality
if (bSkipScriptSerialization)
{
int32 TrackedBufferSize = BytecodeBufferSize;
BytecodeBufferSize = 0; // temporarily clear so that ClearScriptCode() doesn't leave Class->Script with anything allocated
ClearScriptCode(DestScriptContainer);
BytecodeBufferSize = TrackedBufferSize;
// we have to at least move the archiver forward, so it is positioned
// where it expects to be (as if we read in the script)
Ar.Seek(ScriptEndOffset);
return false;
}
bAllowDeferredSerialization &= bIsLinkerLoader;
if (bAllowDeferredSerialization && ShouldDeferScriptSerialization(Ar))
{
ULinkerLoad* Linker = CastChecked<ULinkerLoad>(Ar.GetLinker());
FDeferredScriptTracker::Get().AddDeferredScriptObject(Linker, DestScriptContainer, *this);
// we have to at least move the archiver forward, so it is positioned
// where it expects to be (as if we read in the script)
Ar.Seek(ScriptEndOffset);
return false;
}
Ar.Seek(ScriptSerializationOffset);
if (bIsLinkerLoader)
{
ULinkerLoad* LinkerLoad = CastChecked<ULinkerLoad>(Ar.GetLinker());
TArray<uint8> ShaScriptBuffer;
ShaScriptBuffer.AddUninitialized(SerializedScriptSize);
Ar.Serialize(ShaScriptBuffer.GetData(), SerializedScriptSize);
ensure(ScriptEndOffset == Ar.Tell());
LinkerLoad->UpdateScriptSHAKey(ShaScriptBuffer);
Ar.Seek(ScriptSerializationOffset);
}
DestScriptContainer->Script.Empty(BytecodeBufferSize);
DestScriptContainer->Script.AddUninitialized(BytecodeBufferSize);
int32 BytecodeIndex = 0;
while (BytecodeIndex < BytecodeBufferSize)
{
DestScriptContainer->SerializeExpr(BytecodeIndex, Ar);
}
ensure(ScriptEndOffset == Ar.Tell());
checkf(BytecodeIndex == BytecodeBufferSize, TEXT("'%s' script expression-count mismatch; Expected: %i, Got: %i"), *DestScriptContainer->GetName(), BytecodeBufferSize, BytecodeIndex);
if (!GUObjectArray.IsDisregardForGC(DestScriptContainer))
{
DestScriptContainer->ScriptObjectReferences.Empty();
FArchiveScriptReferenceCollector ObjRefCollector(DestScriptContainer->ScriptObjectReferences);
BytecodeIndex = 0;
while (BytecodeIndex < BytecodeBufferSize)
{
DestScriptContainer->SerializeExpr(BytecodeIndex, ObjRefCollector);
}
}
// success! (we filled the target with serialized script code)
return true;
}
示例11: AssetRegistryName
FPropertyAccess::Result SPropertyEditorAsset::GetValue( FObjectOrAssetData& OutValue ) const
{
// Potentially accessing the value while garbage collecting or saving the package could trigger a crash.
// so we fail to get the value when that is occuring.
if ( GIsSavingPackage || GIsGarbageCollecting )
{
return FPropertyAccess::Fail;
}
FPropertyAccess::Result Result = FPropertyAccess::Fail;
if( PropertyEditor.IsValid() && PropertyEditor->GetPropertyHandle()->IsValidHandle() )
{
UObject* Object = NULL;
Result = PropertyEditor->GetPropertyHandle()->GetValue(Object);
if (Object == NULL)
{
// Check to see if it's pointing to an unloaded object
FString CurrentObjectPath;
PropertyEditor->GetPropertyHandle()->GetValueAsFormattedString( CurrentObjectPath );
if (CurrentObjectPath.Len() > 0 && CurrentObjectPath != TEXT("None"))
{
if( CurrentObjectPath != TEXT("None") && ( !CachedAssetData.IsValid() || CachedAssetData.ObjectPath.ToString() != CurrentObjectPath ) )
{
static FName AssetRegistryName("AssetRegistry");
FAssetRegistryModule& AssetRegistryModule = FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>(AssetRegistryName);
CachedAssetData = AssetRegistryModule.Get().GetAssetByObjectPath( *CurrentObjectPath );
}
Result = FPropertyAccess::Success;
OutValue = FObjectOrAssetData( CachedAssetData );
return Result;
}
}
OutValue = FObjectOrAssetData( Object );
}
else
{
const FString CurrentObjectPath = ObjectPath.Get();
Result = FPropertyAccess::Success;
if( CurrentObjectPath != TEXT("None") && ( !CachedAssetData.IsValid() || CachedAssetData.ObjectPath.ToString() != CurrentObjectPath ) )
{
static FName AssetRegistryName("AssetRegistry");
FAssetRegistryModule& AssetRegistryModule = FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>(AssetRegistryName);
CachedAssetData = AssetRegistryModule.Get().GetAssetByObjectPath( *CurrentObjectPath );
if( PropertyHandle.IsValid() )
{
// No property editor was specified so check if multiple property values are associated with the property handle
TArray<FString> ObjectValues;
PropertyHandle->GetPerObjectValues( ObjectValues );
if( ObjectValues.Num() > 1 )
{
for( int32 ObjectIndex = 1; ObjectIndex < ObjectValues.Num() && Result == FPropertyAccess::Success; ++ObjectIndex )
{
if( ObjectValues[ ObjectIndex ] != ObjectValues[ 0 ] )
{
Result = FPropertyAccess::MultipleValues;
}
}
}
}
}
else if( CurrentObjectPath == TEXT("None") )
{
CachedAssetData = FAssetData();
}
OutValue = FObjectOrAssetData( CachedAssetData );
}
return Result;
}
示例12: Draw
//----------------------------------------------------------------------------
void NodeCamera::Draw(TArray<NodeCamera*>& rNodeCameras, Spatial* pRoot,
Culler& rCuller, Renderer* pRenderer)
{
WIRE_ASSERT(pRenderer && pRoot);
if (!pRenderer || !pRoot)
{
return;
}
const UInt maxCameraCount = 64;
if (rNodeCameras.GetQuantity() >= 64)
{
WIRE_ASSERT(false);
return;
}
// cull all skyboxes attached to cameras in the scene
Spatial::CullingMode tempCullingModes[maxCameraCount];
for (UInt i = 0; i < rNodeCameras.GetQuantity(); i++)
{
NodeCamera* pNodeCamera = rNodeCameras[i];
WIRE_ASSERT(pNodeCamera);
Node* pSkybox = pNodeCamera->mspSkybox;
if (pSkybox && pNodeCamera->IsEnabled())
{
tempCullingModes[i] = pSkybox->Culling;
pSkybox->Culling = Spatial::CULL_ALWAYS;
}
}
for (UInt i = 0; i < rNodeCameras.GetQuantity(); i++)
{
NodeCamera* pNodeCamera = rNodeCameras[i];
WIRE_ASSERT(pNodeCamera && pNodeCamera->Get());
if (!pNodeCamera->IsEnabled())
{
continue;
}
Camera* pCamera = pNodeCamera->Get();
rCuller.SetCamera(pCamera);
rCuller.ComputeVisibleSet(pRoot);
Float left;
Float right;
Float top;
Float bottom;
pCamera->GetViewport(left, right, top, bottom);
UInt width = pRenderer->GetWidth();
UInt height = pRenderer->GetHeight();
Vector4F rect;
rect.X() = MathF::Round(left*width);
rect.Y() = MathF::Round((1.0F-top)*height);
rect.Z() = MathF::Round((right-left)*width);
rect.W() = MathF::Round((top-bottom)*height);
ColorRGBA clearColor = pRenderer->GetClearColor();
switch (rNodeCameras[i]->mClearFlag)
{
case CF_ALL:
pRenderer->SetClearColor(pNodeCamera->GetClearColor());
pRenderer->ClearBuffers(true, true, rect);
pRenderer->SetClearColor(clearColor);
break;
case CF_Z_ONLY:
pRenderer->ClearBuffers(false, true, rect);
break;
case CF_NONE:
break;
default:
WIRE_ASSERT(false);
}
pRenderer->SetCamera(pCamera);
pRenderer->Draw(rCuller.GetVisibleSets());
Node* pSkybox = pNodeCamera->mspSkybox;
if (pSkybox)
{
pSkybox->Culling = Spatial::CULL_NEVER;
rCuller.ComputeVisibleSet(pSkybox);
pRenderer->Draw(rCuller.GetVisibleSets());
pSkybox->Culling = Spatial::CULL_ALWAYS;
}
}
// restore culling mode of all skyboxes attached to cameras in the scene
for (UInt i = 0; i < rNodeCameras.GetQuantity(); i++)
{
NodeCamera* pNodeCamera = rNodeCameras[i];
WIRE_ASSERT(pNodeCamera);
Node* pSkybox = pNodeCamera->mspSkybox;
if (pSkybox && pNodeCamera->IsEnabled())
{
pSkybox->Culling = tempCullingModes[i];
//.........这里部分代码省略.........
示例13: GenerateKDopAsSimpleCollision
int32 GenerateKDopAsSimpleCollision(UStaticMesh* StaticMesh, const TArray<FVector> &Dirs)
{
// Make sure rendering is done - so we are not changing data being used by collision drawing.
FlushRenderingCommands();
if (!PromptToRemoveExistingCollision(StaticMesh))
{
return INDEX_NONE;
}
UBodySetup* bs = StaticMesh->BodySetup;
// Do k- specific stuff.
int32 kCount = Dirs.Num();
TArray<float> maxDist;
for(int32 i=0; i<kCount; i++)
maxDist.Add(-MY_FLTMAX);
// Construct temporary UModel for kdop creation. We keep no refs to it, so it can be GC'd.
auto TempModel = NewObject<UModel>();
TempModel->Initialize(nullptr, 1);
// For each vertex, project along each kdop direction, to find the max in that direction.
const FStaticMeshLODResources& RenderData = StaticMesh->RenderData->LODResources[0];
for(int32 i=0; i<RenderData.GetNumVertices(); i++)
{
for(int32 j=0; j<kCount; j++)
{
float dist = RenderData.PositionVertexBuffer.VertexPosition(i) | Dirs[j];
maxDist[j] = FMath::Max(dist, maxDist[j]);
}
}
// Inflate kdop to ensure it is no degenerate
const float MinSize = 0.1f;
for(int32 i=0; i<kCount; i++)
{
maxDist[i] += MinSize;
}
// Now we have the planes of the kdop, we work out the face polygons.
TArray<FPlane> planes;
for(int32 i=0; i<kCount; i++)
planes.Add( FPlane(Dirs[i], maxDist[i]) );
for(int32 i=0; i<planes.Num(); i++)
{
FPoly* Polygon = new(TempModel->Polys->Element) FPoly();
FVector Base, AxisX, AxisY;
Polygon->Init();
Polygon->Normal = planes[i];
Polygon->Normal.FindBestAxisVectors(AxisX,AxisY);
Base = planes[i] * planes[i].W;
new(Polygon->Vertices) FVector(Base + AxisX * HALF_WORLD_MAX + AxisY * HALF_WORLD_MAX);
new(Polygon->Vertices) FVector(Base + AxisX * HALF_WORLD_MAX - AxisY * HALF_WORLD_MAX);
new(Polygon->Vertices) FVector(Base - AxisX * HALF_WORLD_MAX - AxisY * HALF_WORLD_MAX);
new(Polygon->Vertices) FVector(Base - AxisX * HALF_WORLD_MAX + AxisY * HALF_WORLD_MAX);
for(int32 j=0; j<planes.Num(); j++)
{
if(i != j)
{
if(!Polygon->Split(-FVector(planes[j]), planes[j] * planes[j].W))
{
Polygon->Vertices.Empty();
break;
}
}
}
if(Polygon->Vertices.Num() < 3)
{
// If poly resulted in no verts, remove from array
TempModel->Polys->Element.RemoveAt(TempModel->Polys->Element.Num()-1);
}
else
{
// Other stuff...
Polygon->iLink = i;
Polygon->CalcNormal(1);
}
}
if(TempModel->Polys->Element.Num() < 4)
{
TempModel = NULL;
return INDEX_NONE;
}
// Build bounding box.
TempModel->BuildBound();
// Build BSP for the brush.
FBSPOps::bspBuild(TempModel,FBSPOps::BSP_Good,15,70,1,0);
FBSPOps::bspRefresh(TempModel,1);
FBSPOps::bspBuildBounds(TempModel);
//.........这里部分代码省略.........
示例14: TEXT
UObject* USspjFactory::FactoryCreateBinary(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, const TCHAR* Type, const uint8*& Buffer, const uint8* InBufferEnd, FFeedbackContext* Warn)
{
bool bReimport = this->IsA(UReimportSspjFactory::StaticClass());
TMap<FString, UTexture*>* ExistImages = NULL;
if(bReimport)
{
ExistImages = &(Cast<UReimportSspjFactory>(this)->ExistImages);
}
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools");
FString ProjectNameStr = InName.ToString();
FName ProjectName = InName;
UPackage* InParentPackage = Cast<UPackage>(InParent);
if(InParentPackage && !bReimport)
{
FString ProjectPackageName;
FString BasePackageName = FPackageName::GetLongPackagePath(InParent->GetOutermost()->GetName()) / ProjectNameStr;
AssetToolsModule.Get().CreateUniqueAssetName(BasePackageName, TEXT(""), ProjectPackageName, ProjectNameStr);
InParentPackage->Rename(*ProjectPackageName);
}
// インポート設定の取得
const USsImportSettings* ImportSettings = GetDefault<USsImportSettings>();
// インポート開始
FEditorDelegates::OnAssetPreImport.Broadcast(this, InClass, InParent, ProjectName, Type);
// sspj
USsProject* NewProject = FSsLoader::LoadSsProject(InParent, ProjectName, Flags, Buffer, (InBufferEnd - Buffer) + 1);
NewProject->SetFilepath( GetCurrentFilename() );
if(NewProject)
{
if(NewProject->AssetImportData == nullptr)
{
NewProject->AssetImportData = NewObject<UAssetImportData>(NewProject);
}
NewProject->AssetImportData->Update(CurrentFilename);
FString CurPath = FPaths::GetPath(GetCurrentFilename());
TArray<FString> ImagePaths;
TArray<SsTexWrapMode::Type> ImageWrapModes;
TArray<SsTexFilterMode::Type> ImageFilterModes;
// ssce
NewProject->CellmapList.Empty();
NewProject->CellmapList.AddZeroed(NewProject->CellmapNames.Num());
for(int i = 0; i < NewProject->CellmapNames.Num(); ++i)
{
FString FileName = GetFilePath(CurPath, NewProject->Settings.CellMapBaseDirectory, NewProject->CellmapNames[i].ToString());
TArray<uint8> Data;
if(FFileHelper::LoadFileToArray(Data, *FileName))
{
const uint8* BufferBegin = Data.GetData();
const uint8* BufferEnd = BufferBegin + Data.Num() - 1;
if(FSsLoader::LoadSsCellMap(&(NewProject->CellmapList[i]), BufferBegin, (BufferEnd - BufferBegin) + 1))
{
NewProject->CellmapList[i].FileName = NewProject->CellmapNames[i];
if(0 < NewProject->CellmapList[i].ImagePath.Len())
{
if(INDEX_NONE == ImagePaths.Find(NewProject->CellmapList[i].ImagePath))
{
ImagePaths.Add(NewProject->CellmapList[i].ImagePath);
if(NewProject->CellmapList[i].OverrideTexSettings)
{
ImageWrapModes.Add(NewProject->CellmapList[i].WrapMode);
ImageFilterModes.Add(NewProject->CellmapList[i].FilterMode);
}
else
{
ImageWrapModes.Add(NewProject->Settings.WrapMode);
ImageFilterModes.Add(NewProject->Settings.FilterMode);
}
}
}
}
}
}
// ssae
NewProject->AnimeList.Empty();
NewProject->AnimeList.AddZeroed(NewProject->AnimepackNames.Num());
for(int i = 0; i < NewProject->AnimepackNames.Num(); ++i)
{
FString FileName = GetFilePath(CurPath, NewProject->Settings.AnimeBaseDirectory, NewProject->AnimepackNames[i].ToString());
TArray<uint8> Data;
if(FFileHelper::LoadFileToArray(Data, *FileName))
{
const uint8* BufferBegin = Data.GetData();
const uint8* BufferEnd = BufferBegin + Data.Num() - 1;
FSsLoader::LoadSsAnimePack(&(NewProject->AnimeList[i]), BufferBegin, (BufferEnd - BufferBegin) + 1);
}
}
// texture
for(int i = 0; i < ImagePaths.Num(); ++i)
//.........这里部分代码省略.........
示例15: NSLOCTEXT
void FEdModeGeometry::GetFromSource()
{
GWarn->BeginSlowTask( NSLOCTEXT("EditorModes", "GeometryMode-BeginRebuildingBSPTask", "Rebuilding BSP"), false);
TArray<HGeomMidPoints> GeomData;
// Go through each brush and update its components before updating below
for( int32 i=0; i<GeomObjects.Num(); i++ )
{
FGeomObject* GeomObject = GeomObjects[i];
if(GeomObject && GeomObject->ActualBrush)
{
#ifdef BSP_RESELECT
// Cache any information that'll help us reselect the object after it's reconstructed
CacheSelectedData( GeomData, *GeomObject );
#endif // BSP_RESELECT
GeomObject->ActualBrush->UnregisterAllComponents();
if (GeomObject->ActualBrush->GetWorld())
{
GeomObject->ActualBrush->RegisterAllComponents();
}
delete GeomObject;
}
}
GeomObjects.Empty();
TArray<FGeomBase*> SelectedGeom;
// Notify the selected actors that they have been moved.
bool bFound = true;
for ( FSelectionIterator It( GEditor->GetSelectedActorIterator() ) ; It ; ++It )
{
AActor* Actor = static_cast<AActor*>( *It );
checkSlow( Actor->IsA(AActor::StaticClass()) );
ABrush* BrushActor = Cast< ABrush >( Actor );
if ( BrushActor )
{
if( BrushActor->Brush != NULL )
{
FGeomObject* GeomObject = new FGeomObject();
GeomObject->SetParentObjectIndex( GeomObjects.Add( GeomObject ) );
GeomObject->ActualBrush = BrushActor;
GeomObject->GetFromSource();
#ifdef BSP_RESELECT
// Attempt to find all the previously selected geometry on this object if everything has gone OK so far
if ( bFound && !FindFromCache( GeomData, *GeomObject, SelectedGeom ) )
{
#ifdef BSP_RESELECT__ALL_OR_NOTHING
// If it didn't succeed, don't attempt to reselect anything as the user will only end up moving part of their previous selection
UE_LOG(LogGeometryMode, Warning, TEXT( "Unable to find all previously selected geometry data, resetting selection" ) );
SelectedGeom.Empty();
GeomData.Empty();
bFound = false;
#endif // BSP_RESELECT__ALL_OR_NOTHING
}
#endif // BSP_RESELECT
}
}
}
#ifdef BSP_RESELECT
// Reselect anything that came close to the cached midpoints
SelectCachedData( SelectedGeom );
#endif // BSP_RESELECT
GWarn->EndSlowTask();
}