Example #1
0
static inline
void PopValueImpl(const TArray<FOscDataElemStruct> & input, TArray<FOscDataElemStruct> & output, T & Value)
{
    if(input.Num() > 0)
    {
        output.Reserve(input.Num() - 1);
        for(int32 i=1, n=input.Num(); i!=n; ++i)
        {
            output.Add(input[i]);
        }
        Value = input[0].GetValue<T>();
    }
    else
    {
        output.Empty();
        Value = FOscDataElemStruct().GetValue<T>();
    }
}
void FAnimationRuntime::CreateMaskWeights(TArray<FPerBoneBlendWeight> & BoneBlendWeights, const TArray<FInputBlendPose>	&BlendFilters, const FBoneContainer& RequiredBones, const USkeleton* Skeleton)
{
	if ( Skeleton )
	{
		const TArray<FBoneIndexType> & RequiredBoneIndices = RequiredBones.GetBoneIndicesArray();
		
		BoneBlendWeights.Empty(RequiredBoneIndices.Num());
		BoneBlendWeights.AddZeroed(RequiredBoneIndices.Num());

		// base mask bone
		for (int32 PoseIndex=0; PoseIndex<BlendFilters.Num(); ++PoseIndex)
		{
			const FInputBlendPose& BlendPose = BlendFilters[PoseIndex];

			for (int32 BranchIndex=0; BranchIndex<BlendPose.BranchFilters.Num(); ++BranchIndex)
			{
				const FBranchFilter& BranchFilter = BlendPose.BranchFilters[BranchIndex];
				int32 MaskBoneIndex = RequiredBones.GetPoseBoneIndexForBoneName(BranchFilter.BoneName);

				// how much weight increase Per depth
				float MaxWeight = (BranchFilter.BlendDepth > 0) ? 1.f : -1.f;
				float IncreaseWeightPerDepth = (BranchFilter.BlendDepth != 0) ? (1.f/((float)BranchFilter.BlendDepth)) : 1.f;
	
				// go through skeleton tree requiredboneindices
				for (int32 BoneIndex = 0; BoneIndex<RequiredBoneIndices.Num(); ++BoneIndex)
				{
					int32 MeshBoneIndex = RequiredBoneIndices[BoneIndex];
					int32 Depth = RequiredBones.GetDepthBetweenBones(MeshBoneIndex, MaskBoneIndex);

					// if Depth == -1, it's not a child
					if( Depth != -1 )
					{
						// when you write to buffer, you'll need to match with BasePoses BoneIndex
						FPerBoneBlendWeight& BoneBlendWeight = BoneBlendWeights[BoneIndex];

						BoneBlendWeight.SourceIndex = PoseIndex;
						float BlendIncrease = IncreaseWeightPerDepth * (float)(Depth + 1);
						BoneBlendWeight.BlendWeight = FMath::Clamp<float>(BoneBlendWeight.BlendWeight + BlendIncrease, 0.f, 1.f);
					}
				}
			}
		}
	}
}
bool FBuildPatchVerificationImpl::VerifyAgainstDirectory(TArray<FString>& OutDatedFiles, double& TimeSpentPaused)
{
	bool bAllCorrect = true;
	OutDatedFiles.Empty();
	TimeSpentPaused = 0;
	if (VerifyMode == EVerifyMode::FileSizeCheckAllFiles || VerifyMode == EVerifyMode::ShaVerifyAllFiles)
	{
		Manifest->GetTaggedFileList(InstallTags, RequiredFiles);
	}

	// Setup progress tracking
	double TotalBuildSizeDouble = Manifest->GetFileSize(RequiredFiles);
	double ProcessedBytes = 0;
	CurrentBuildPercentage = 0;

	// Select verify function
	bool bVerifySha = VerifyMode == EVerifyMode::ShaVerifyAllFiles || VerifyMode == EVerifyMode::ShaVerifyTouchedFiles;

	// For all files in the manifest, check that they produce the correct SHA1 hash, adding any that don't to the list
	for (const FString& BuildFile : RequiredFiles)
	{
		// Break if quitting
		if (FBuildPatchInstallError::HasFatalError())
		{
			break;
		}

		// Get file details
		int64 BuildFileSize = Manifest->GetFileSize(BuildFile);

		// Verify the file
		CurrentFileWeight = BuildFileSize / TotalBuildSizeDouble;
		bool bFileOk = bVerifySha ? VerfiyFileSha(BuildFile, TimeSpentPaused) : VerfiyFileSize(BuildFile, TimeSpentPaused);
		if (bFileOk == false)
		{
			bAllCorrect = false;
			OutDatedFiles.Add(BuildFile);
		}
		ProcessedBytes += BuildFileSize;
		CurrentBuildPercentage = ProcessedBytes / TotalBuildSizeDouble;
	}

	return bAllCorrect && !FBuildPatchInstallError::HasFatalError();
}
Example #4
0
void UInputComponent::RemoveActionBinding( const int32 BindingIndex )
{
	if (BindingIndex >= 0 && BindingIndex < ActionBindings.Num())
	{
		const FInputActionBinding& BindingToRemove = ActionBindings[BindingIndex];

		// Potentially need to clear some pairings
		if (BindingToRemove.bPaired)
		{
			TArray<int32> IndicesToClear;
			const EInputEvent PairedEvent = (BindingToRemove.KeyEvent == IE_Pressed ? IE_Released : IE_Pressed);

			for (int32 ActionIndex = 0; ActionIndex < ActionBindings.Num(); ++ActionIndex)
			{
				if (ActionIndex != BindingIndex)
				{
					const FInputActionBinding& ActionBinding = ActionBindings[ActionIndex];
					if (ActionBinding.ActionName == BindingToRemove.ActionName)
					{
						// If we find another of the same key event then the pairing is intact so we're done
						if (ActionBinding.KeyEvent == BindingToRemove.KeyEvent)
						{
							IndicesToClear.Empty();
							break;
						}
						// Otherwise we may need to clear the pairing so track the index
						else if (ActionBinding.KeyEvent == PairedEvent)
						{
							IndicesToClear.Add(ActionIndex);
						}
					}
				}
			}

			for (int32 ClearIndex = 0; ClearIndex < IndicesToClear.Num(); ++ClearIndex)
			{
				ActionBindings[IndicesToClear[ClearIndex]].bPaired = false;
			}
		}

		ActionBindings.RemoveAt(BindingIndex);
	}
}
void FPIELoginSettingsInternal::Decrypt()
{
	if (TokenBytes.Num() > 0)
	{
		const int64 PaddedEncryptedFileSize = Align(TokenBytes.Num(), FAES::AESBlockSize);
		if (PaddedEncryptedFileSize > 0 && PaddedEncryptedFileSize == TokenBytes.Num())
		{
			TArray<uint8> TempArray;
			TempArray.Empty(PaddedEncryptedFileSize);
			TempArray.AddUninitialized(PaddedEncryptedFileSize);
			FMemory::Memcpy(TempArray.GetData(), TokenBytes.GetData(), PaddedEncryptedFileSize);
			
			// XOR Cipher
			int32 NumXors = PaddedEncryptedFileSize / sizeof(int32);
			int32* TempArrayPtr = (int32*)(TempArray.GetData());
			for (int32 i = 0; i < NumXors; i++)
			{
				TempArrayPtr[i] = TempArrayPtr[i] ^ ONLINEPIE_XOR_KEY;
			}

			//FAES::DecryptData(TempArray.GetData(), PaddedEncryptedFileSize);

			// Validate the unencrypted data (stored size less than total data, null terminated character where it should be)
			int32 PasswordDataSize = TempArray[0];
			int32 PasswordLength = PasswordDataSize / sizeof(TCHAR);
			TCHAR* Password = (TCHAR*)(TempArray.GetData() + 1);
			if (PasswordDataSize < TempArray.Num() &&
				Password[PasswordLength - 1] == '\0')
			{
				Token = FString(Password);
			}
			else
			{
				Token.Empty();
				TokenBytes.Empty();
			}
		}
	}
	else
	{
		Token.Empty();
	}
}
Example #6
0
void FAnimNode_BlendListBase::Evaluate(FPoseContext& Output)
{
	SCOPE_CYCLE_COUNTER(STAT_AnimNativeBlendPoses);

	const int32 MaxNumPoses = BlendPose.Num();

	//@TODO: This is currently using O(NumPoses) memory but doesn't need to
	if ((MaxNumPoses > 0) && (BlendPose.Num() == BlendWeights.Num()))
	{
		TArray<FPoseContext> FilteredPoseContexts;
		FilteredPoseContexts.Empty(MaxNumPoses);

		FTransformArrayA2** FilteredPoses = new FTransformArrayA2*[MaxNumPoses];
		float* FilteredWeights = new float[MaxNumPoses];

		int32 NumActivePoses = 0;
		for (int32 i = 0; i < BlendPose.Num(); ++i)
		{
			const float BlendWeight = BlendWeights[i];
			if (BlendWeight > ZERO_ANIMWEIGHT_THRESH)
			{
				FPoseContext& CurrentPoseContext = *(new (FilteredPoseContexts) FPoseContext(Output));

				FPoseLink& CurrentPose = BlendPose[i];
				CurrentPose.Evaluate(CurrentPoseContext);

				FilteredPoses[NumActivePoses] = &(CurrentPoseContext.Pose.Bones);
				FilteredWeights[NumActivePoses] = BlendWeight;
				NumActivePoses++;
			}
		}

		FAnimationRuntime::BlendPosesTogether(NumActivePoses, (const FTransformArrayA2**)FilteredPoses, (const float*)FilteredWeights, Output.AnimInstance->RequiredBones, Output.Pose.Bones);

		delete[] FilteredPoses;
		delete[] FilteredWeights;
	}
	else
	{
		Output.ResetToRefPose();
	}
}
	virtual bool Create(uint32 InNumQueuedThreads,uint32 StackSize = (32 * 1024),EThreadPriority ThreadPriority=TPri_Normal) override
	{
		// Make sure we have synch objects
		bool bWasSuccessful = true;
		check(SynchQueue == nullptr);
		SynchQueue = new FCriticalSection();
		FScopeLock Lock(SynchQueue);
		// Presize the array so there is no extra memory allocated
		check(QueuedThreads.Num() == 0);
		QueuedThreads.Empty(InNumQueuedThreads);

		// Check for stack size override.
		if( OverrideStackSize > StackSize )
		{
			StackSize = OverrideStackSize;
		}

		// Now create each thread and add it to the array
		for (uint32 Count = 0; Count < InNumQueuedThreads && bWasSuccessful == true; Count++)
		{
			// Create a new queued thread
			FQueuedThread* pThread = new FQueuedThread();
			// Now create the thread and add it if ok
			if (pThread->Create(this,StackSize,ThreadPriority) == true)
			{
				QueuedThreads.Add(pThread);
				AllThreads.Add(pThread);
			}
			else
			{
				// Failed to fully create so clean up
				bWasSuccessful = false;
				delete pThread;
			}
		}
		// Destroy any created threads if the full set was not successful
		if (bWasSuccessful == false)
		{
			Destroy();
		}
		return bWasSuccessful;
	}
Example #8
0
TArray<FLayoutGeometry> SSplitter2x2::ArrangeChildrenForLayout( const FGeometry& AllottedGeometry ) const
{
	check( Children.Num() == 4 );

	TArray<FLayoutGeometry> Result;
	Result.Empty(Children.Num());

	int32 NumNonCollapsedChildren = 0;
	FVector2D CoefficientTotal(0,0);

	// The allotted space for our children is our geometry minus a little space to show splitter handles
	const FVector2D SpaceAllottedForChildren = AllottedGeometry.Size - FVector2D(SplitterHandleSize,SplitterHandleSize);

	// The current offset that the next child should be positioned at.
	FVector2D Offset(0,0);

	for (int32 ChildIndex=0; ChildIndex < Children.Num(); ++ChildIndex)
	{
		const FSlot& CurSlot = Children[ChildIndex];

		// Calculate the amount of space that this child should take up.  
		// It is based on the current percentage of space it should take up which is defined by a user moving the splitters
		const FVector2D ChildSpace = SpaceAllottedForChildren * CurSlot.PercentageAttribute.Get();

		// put them in their spot
		Result.Emplace(FSlateLayoutTransform(Offset), ChildSpace);

		// Advance to the next slot. If the child is collapsed, it takes up no room and does not need a splitter
		if( ChildIndex == 1 )
		{
			// ChildIndex of 1 means we are starting the next column so reset the Y offset.
			Offset.Y = 0.0f;
			Offset += FVector2D( ChildSpace.X + SplitterHandleSize, 0);
		}
		else
		{
			Offset += FVector2D( 0, ChildSpace.Y + SplitterHandleSize );
		}
	}
	return Result;
}
void FSCSDiff::OnSCSEditorUpdateSelectionFromNodes(const TArray<FSCSEditorTreeNodePtrType>& SelectedNodes)
{
	FText InspectorTitle = FText::GetEmpty();
	TArray<UObject*> InspectorObjects;
	InspectorObjects.Empty(SelectedNodes.Num());
	for (auto NodeIt = SelectedNodes.CreateConstIterator(); NodeIt; ++NodeIt)
	{
		auto NodePtr = *NodeIt;
		if(NodePtr.IsValid() && NodePtr->CanEditDefaults())
		{
			InspectorTitle = FText::FromString(NodePtr->GetDisplayString());
			InspectorObjects.Add(NodePtr->GetComponentTemplate());
		}
	}

	if( Inspector.IsValid() )
	{
		SKismetInspector::FShowDetailsOptions Options(InspectorTitle, true);
		Inspector->ShowDetailsForObjects(InspectorObjects, Options);
	}
}
void UK2Node_CallArrayFunction::GetArrayTypeDependentPins(TArray<UEdGraphPin*>& OutPins) const
{
	OutPins.Empty();

	UFunction* TargetFunction = GetTargetFunction();
	check(TargetFunction);

	const FString DependentPinMetaData = TargetFunction->GetMetaData(FBlueprintMetadata::MD_ArrayDependentParam);
	TArray<FString> TypeDependentPinNames;
	DependentPinMetaData.ParseIntoArray(TypeDependentPinNames, TEXT(","), true);

	for(TArray<UEdGraphPin*>::TConstIterator it(Pins); it; ++it)
	{
		UEdGraphPin* CurrentPin = *it;
		int32 ItemIndex = 0;
		if( CurrentPin && TypeDependentPinNames.Find(CurrentPin->PinName, ItemIndex) )
		{
			OutPins.Add(CurrentPin);
		}
	}
}
void SortTriangles_Random( int32 NumTriangles, const FSoftSkinVertex* Vertices, uint32* Indices )
{
	TArray<int32> Triangles;
	for( int32 i=0;i<NumTriangles;i++ )
	{
		Triangles.Insert(i, i > 0 ? FMath::Rand() % i : 0);
	}

	// export new draw order
	TArray<uint32> NewIndices;
	NewIndices.Empty(NumTriangles*3);
	for( int TriIndex=0;TriIndex<NumTriangles;TriIndex++ )
	{
		int32 tri = Triangles[TriIndex];
		NewIndices.Add(Indices[tri*3+0]);
		NewIndices.Add(Indices[tri*3+1]);
		NewIndices.Add(Indices[tri*3+2]);	
	}

	FMemory::Memcpy( Indices, NewIndices.GetData(), NewIndices.Num() * sizeof(uint32) );
}
/** Calculates the step 1D cumulative distribution function for the given unnormalized probability distribution function. */
void CalculateStep1dCDF(const TArray<float>& PDF, TArray<float>& CDF, float& UnnormalizedIntegral)
{
	CDF.Empty(PDF.Num());
	float RunningUnnormalizedIntegral = 0;
	CDF.Add(0.0f);
	for (int32 i = 1; i < PDF.Num(); i++)
	{
		RunningUnnormalizedIntegral += PDF[i - 1];
		CDF.Add(RunningUnnormalizedIntegral);
	}
	UnnormalizedIntegral = RunningUnnormalizedIntegral + PDF.Last();
	if (UnnormalizedIntegral > 0.0f)
	{
		// Normalize the CDF
		for (int32 i = 1; i < CDF.Num(); i++)
		{
			CDF[i] /= UnnormalizedIntegral;
		}
	}
	check(CDF.Num() == PDF.Num());
}
// Called when the game starts or when spawned
void AWorldSpawn::BeginPlay() {
    Super::BeginPlay();

	UE_LOG(LogTemp, Warning, TEXT("BEGIN PLAY"));

	hex_list.clear();
	chunk_triangles.Empty();

	AActor* new_hex_obj = GetWorld()->SpawnActor<AActor>(hex_asset, FVector::ZeroVector, FRotator(0, -90, 0));
	UStaticMeshComponent* mesh_component = Cast<UStaticMeshComponent>(new_hex_obj->GetComponentByClass(UStaticMeshComponent::StaticClass()));
	vertex_buffer = &mesh_component->StaticMesh->RenderData->LODResources[0].PositionVertexBuffer;
	index_buffer = mesh_component->StaticMesh->RenderData->LODResources[0].IndexBuffer.GetArrayView();
	new_hex_obj->Destroy();

	SetActorRotation(FRotator(0, -90, 0));

	UE_LOG(LogTemp, Warning, TEXT("num_vertices: %d"), vertex_buffer->GetNumVertices());

    fnoise.init();
	gen_chunk();
}
void FDestructibleMeshEditorViewportClient::UpdateChunkSelection( TArray<int32> InSelectedChunkIndices )
{
	// Store the proxies in the ppol
	UnusedProxies.Append(SelectedChunks);

	// Clear selected chunks
	SelectedChunks.Empty(InSelectedChunkIndices.Num());

	// make sure we have enough proxies to fill the selection array */
	while(UnusedProxies.Num() < InSelectedChunkIndices.Num())
	{
		UnusedProxies.Add(NewObject<UDestructibleChunkParamsProxy>());
	}

	UDestructibleMesh* DestructibleMesh = DestructibleMeshEditorPtr.Pin()->GetDestructibleMesh();
	UDestructibleFractureSettings* FractureSettings = DestructibleMesh->FractureSettings;

	TArray<UObject*> SelectedObjects;
	// Setup the selection array
	for (int32 i=0; i < InSelectedChunkIndices.Num(); ++i)
	{
		UDestructibleChunkParamsProxy* Proxy = UnusedProxies.Pop();

		Proxy->DestructibleMesh = DestructibleMesh;
		Proxy->ChunkIndex = InSelectedChunkIndices[i];
		Proxy->DestructibleMeshEditorPtr = DestructibleMeshEditorPtr;

		if (FractureSettings != NULL && FractureSettings->ChunkParameters.Num() > Proxy->ChunkIndex)
		{
			Proxy->ChunkParams = Proxy->DestructibleMesh->FractureSettings->ChunkParameters[Proxy->ChunkIndex];
		}

		SelectedChunks.Add(Proxy);
		SelectedObjects.Add(Proxy);
	}


	FDestructibleMeshEditor* MeshEd = (FDestructibleMeshEditor*)DestructibleMeshEditorPtr.Pin().Get();
	MeshEd->SetSelectedChunks(SelectedObjects);
}
void FColorStructCustomization::OnColorPickerCancelled( FLinearColor OriginalColor )
{
	TArray<FString> PerObjectColors;

	for( int32 ColorIndex = 0; ColorIndex < SavedPreColorPickerColors.Num(); ++ColorIndex )
	{
		if( bIsLinearColor )
		{
			PerObjectColors.Add( SavedPreColorPickerColors[ColorIndex].ToString() );
		}
		else
		{
			const bool bSRGB = false;
			FColor Color = SavedPreColorPickerColors[ColorIndex].ToFColor( bSRGB );
			PerObjectColors.Add( Color.ToString() );
		}
	}

	StructPropertyHandle->SetPerObjectValues( PerObjectColors );

	PerObjectColors.Empty();
}
Example #16
0
void GetObjectsWithAnyMarks(TArray<UObject *>& Results, EObjectMark Marks)
{
	// We don't want to return any objects that are currently being background loaded unless we're using the object iterator during async loading.
	EObjectFlags ExclusionFlags = RF_Unreachable;
	if (!IsInAsyncLoadingThread())
	{
		ExclusionFlags = EObjectFlags(ExclusionFlags | RF_AsyncLoading);
	}
	const TMap<const UObjectBase *, FObjectMark>& Map = MarkAnnotation.GetAnnotationMap();
	Results.Empty(Map.Num());
	for (TMap<const UObjectBase *, FObjectMark>::TConstIterator It(Map); It; ++It)
	{
		if (It.Value().Marks & Marks)
		{
			UObject* Item = (UObject*)It.Key();
			if (!Item->HasAnyFlags(ExclusionFlags))
			{
				Results.Add(Item);
			}
		}
	}
}
Example #17
0
void FOptionalPinManager::RebuildPropertyList(TArray<FOptionalPinFromProperty>& Properties, UStruct* SourceStruct)
{
	// Save the old visibility
	TMap<FName, bool> OldVisibility;
	for (auto ExtraPropertyIt = Properties.CreateIterator(); ExtraPropertyIt; ++ExtraPropertyIt)
	{
		FOptionalPinFromProperty& PropertyEntry = *ExtraPropertyIt;

		OldVisibility.Add(PropertyEntry.PropertyName, PropertyEntry.bShowPin);
	}

	// Rebuild the property list
	Properties.Empty();

	for (TFieldIterator<UProperty> It(SourceStruct, EFieldIteratorFlags::IncludeSuper); It; ++It)
	{
		UProperty* TestProperty = *It;

		if (CanTreatPropertyAsOptional(TestProperty))
		{
			FOptionalPinFromProperty* Record = new (Properties) FOptionalPinFromProperty;
			Record->PropertyName = TestProperty->GetFName();
			Record->PropertyFriendlyName = UEditorEngine::GetFriendlyName(TestProperty, SourceStruct);
			Record->PropertyTooltip = TestProperty->GetToolTipText();

			// Get the defaults
			GetRecordDefaults(TestProperty, *Record);

			// If this is a refresh, propagate the old visibility
			if (Record->bCanToggleVisibility)
			{
				if (bool* pShowHide = OldVisibility.Find(Record->PropertyName))
				{
					Record->bShowPin = *pShowHide;
				}
			}
		}
	}
}
void FAnimationRuntime::FillUpSpaceBasesRefPose(const USkeleton* Skeleton, TArray<FTransform> &SpaceBaseRefPose)
{
	check(Skeleton);

	const TArray<FTransform> & ReferencePose = Skeleton->GetReferenceSkeleton().GetRefBonePose();
	SpaceBaseRefPose.Empty(ReferencePose.Num());
	SpaceBaseRefPose.AddUninitialized(ReferencePose.Num());

	// initialize to identity since some of them don't have tracks
	for(int Index=0; Index <SpaceBaseRefPose.Num(); ++Index)
	{
		int32 ParentIndex = Skeleton->GetReferenceSkeleton().GetParentIndex(Index);
		if(ParentIndex != INDEX_NONE)
		{
			SpaceBaseRefPose[Index] = ReferencePose[Index] * SpaceBaseRefPose[ParentIndex];
		}
		else
		{
			SpaceBaseRefPose[Index] = ReferencePose[Index];
		}
	}
}
Example #19
0
void FDragConnection::ValidateGraphPinList(TArray<UEdGraphPin*>& OutValidPins)
{
	OutValidPins.Empty(StartingPins.Num());

	for (TArray< TSharedRef<SGraphPin> >::TIterator PinIterator(StartingPins); PinIterator; ++PinIterator)
	{
		if (UEdGraphPin* StartingPinObj = (*PinIterator)->GetPinObj())
		{
			//Check whether the list contains updated pin object references by checking its outer class type
			if ((StartingPinObj->GetOuter() == NULL) || !StartingPinObj->GetOuter()->IsA(UEdGraphNode::StaticClass()))
			{
				//This pin object reference is old. So remove it from the list.
				TSharedRef<SGraphPin> PinPtr = *PinIterator;
				StartingPins.Remove( PinPtr );
			}
			else
			{
				OutValidPins.Add(StartingPinObj);
			}
		}
	}
}
Example #20
0
void UPaperSprite::Triangulate(const FSpritePolygonCollection& Source, TArray<FVector2D>& Target)
{
	Target.Empty();

	for (int32 PolygonIndex = 0; PolygonIndex < Source.Polygons.Num(); ++PolygonIndex)
	{
		const FSpritePolygon& SourcePoly = Source.Polygons[PolygonIndex];
		if (SourcePoly.Vertices.Num() >= 3)
		{
			// Convert our format into one the triangulation library supports
			FClipSMPolygon ClipPolygon(0);
			for (int32 VertexIndex = 0; VertexIndex < SourcePoly.Vertices.Num() ; ++VertexIndex)
			{
				FClipSMVertex* ClipVertex = new (ClipPolygon.Vertices) FClipSMVertex;
				FMemory::Memzero(ClipVertex, sizeof(FClipSMVertex));

				const FVector2D& SourceVertex = SourcePoly.Vertices[VertexIndex];
				ClipVertex->Pos.X = SourceVertex.X;
				ClipVertex->Pos.Z = SourceVertex.Y;
			}
			ClipPolygon.FaceNormal = FVector(0.0f, -1.0f, 0.0f);

			// Attempt to triangulate this polygon
			TArray<FClipSMTriangle> GeneratedTriangles;
			if (TriangulatePoly(/*out*/ GeneratedTriangles, ClipPolygon))
			{
				// Convert the triangles back to our 2D data structure
				for (int32 TriangleIndex = 0; TriangleIndex < GeneratedTriangles.Num(); ++TriangleIndex)
				{
					const FClipSMTriangle& Triangle = GeneratedTriangles[TriangleIndex];

					new (Target) FVector2D(Triangle.Vertices[0].Pos.X, Triangle.Vertices[0].Pos.Z);
					new (Target) FVector2D(Triangle.Vertices[1].Pos.X, Triangle.Vertices[1].Pos.Z);
					new (Target) FVector2D(Triangle.Vertices[2].Pos.X, Triangle.Vertices[2].Pos.Z);
				}
			}
		}
	}
}
/** Generates unit length, stratified and uniformly distributed direction samples in a hemisphere. */
void GenerateStratifiedUniformHemisphereSamples(int32 NumThetaSteps, int32 NumPhiSteps, FLMRandomStream& RandomStream, TArray<FVector4>& Samples, TArray<FVector2D>& Uniforms)
{
	Samples.Empty(NumThetaSteps * NumPhiSteps);
	for (int32 ThetaIndex = 0; ThetaIndex < NumThetaSteps; ThetaIndex++)
	{
		for (int32 PhiIndex = 0; PhiIndex < NumPhiSteps; PhiIndex++)
		{
			const float U1 = RandomStream.GetFraction();
			const float U2 = RandomStream.GetFraction();

			const float Fraction1 = (ThetaIndex + U1) / (float)NumThetaSteps;
			const float Fraction2 = (PhiIndex + U2) / (float)NumPhiSteps;

			const float R = FMath::Sqrt(1.0f - Fraction1 * Fraction1);

			const float Phi = 2.0f * (float)PI * Fraction2;
			// Convert to Cartesian
			Samples.Add(FVector4(FMath::Cos(Phi) * R, FMath::Sin(Phi) * R, Fraction1));
			Uniforms.Add(FVector2D(Fraction1, Fraction2));
		}
	}
}
void FInternationalization::GetTimeZonesIDs(TArray<FString>& TimeZonesIDs)
{
	TimeZonesIDs.Empty();
#if UE_ENABLE_ICU
	UErrorCode ICUStatus = U_ZERO_ERROR;

	TSharedPtr<icu::StringEnumeration> StringEnumeration( icu::TimeZone::createEnumeration() );
	TimeZonesIDs.Reserve( StringEnumeration->count(ICUStatus) );

	const icu::UnicodeString* ICUString;
	do
	{
		ICUString = StringEnumeration->snext(ICUStatus);
		if(ICUString)
		{
			FString NativeString;
			ICUUtilities::Convert(*ICUString, NativeString);
			TimeZonesIDs.Add( NativeString );
		}
	} while( ICUString );
#endif
}
void FComponentTypeRegistryData::Tick(float)
{
	bool bRequiresRefresh = bNeedsRefreshNextTick;
	bNeedsRefreshNextTick = false;

	if (PendingAssetData.Num() != 0)
	{
		FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
		TArray<FName> ClassNames;
		ClassNames.Add(UActorComponent::StaticClass()->GetFName());
		TSet<FName> DerivedClassNames;
		AssetRegistryModule.Get().GetDerivedClassNames(ClassNames, TSet<FName>(), DerivedClassNames);

		for (auto Asset : PendingAssetData)
		{
			const FName BPParentClassName(GET_MEMBER_NAME_CHECKED(UBlueprint, ParentClass));

			bool FoundBPNotify = false;
			for (TMap<FName, FString>::TConstIterator TagIt(Asset.TagsAndValues); TagIt; ++TagIt)
			{
				FString TagValue = Asset.TagsAndValues.FindRef(BPParentClassName);
				const FString ObjectPath = FPackageName::ExportTextPathToObjectPath(TagValue);
				FName ObjectName = FName(*FPackageName::ObjectPathToObjectName(ObjectPath));
				if (DerivedClassNames.Contains(ObjectName))
				{
					bRequiresRefresh = true;
					break;
				}
			}
		}
		PendingAssetData.Empty();
	}

	if (bRequiresRefresh)
	{
		ForceRefreshComponentList();
	}
}
void AProject_152GameMode::ProcessWin(int32 InputExperience, int32 Currencytoadd)
{
	AProject_152Character* MyCharTemp;
	MyCharTemp = Cast<AProject_152Character>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
	TArray<int32> ItemIdArray;
	ItemIdArray.Empty();

	/*
	for (int i = 0; i < CharactersInCombat.Num(); i++)
	{
		if (CharactersInCombat[i]->bIsHumanPlayer)
		{
			ItemIdArray.Add(CharactersInCombat[i]->ItemId);
			//CharactersInCombat[i]->AddExperience(InputExperience);
		}
	}
	
	for (int i = 0; i < ItemIdArray.Num(); i++)
	{
		for (int j = 0; j < MyCharTemp->ParentCombatCharacterInventoryArray.Num(); j++)
		{
			if (MyCharTemp->ParentCombatCharacterInventoryArray[j].ItemID == ItemIdArray[i])
			{
				MyCharTemp->ParentCombatCharacterInventoryArray[j].Experience += InputExperience;
				CheckForLevelUP(MyCharTemp->ParentCombatCharacterInventoryArray[j]);
			}
		}
	}
	*/
	for (int k = 0; k < MyCharTemp->ParentCombatCharacterInventoryArray.Num(); k++)
	{
		MyCharTemp->ParentCombatCharacterInventoryArray[k].Experience += InputExperience;
		CheckForLevelUP(MyCharTemp->ParentCombatCharacterInventoryArray[k], k);
	}

	MyCharTemp->Currency += Currencytoadd;

}
Example #25
0
    /** Create connectivity groups */
    void CreateConnectivityGroups()
    {
        // Delete group list
        Groups.Empty();

        // Reset group assignments
        for ( int32 i=0; i<Triangles.Num(); i++ )
        {
            Triangles[i].Group = INDEX_NONE;
        }

        // Flood fill using connectivity info
        for ( ;; )
        {
            // Find first triangle without group assignment
            int32 InitialTriangle = INDEX_NONE;
            for ( int32 i=0; i<Triangles.Num(); i++ )
            {
                if ( Triangles[i].Group == INDEX_NONE )
                {
                    InitialTriangle = i;
                    break;
                }
            }

            // No more unassigned triangles, flood fill is done
            if ( InitialTriangle == INDEX_NONE )
            {
                break;
            }

            // Create group
            int32 GroupIndex = Groups.AddZeroed( 1 );

            // Start flood fill using connectivity information
            FloodFillTriangleGroups( InitialTriangle, GroupIndex );
        }
    }
Example #26
0
bool FBuildPatchVerificationImpl::VerifyAgainstDirectory(TArray<FString>& OutDatedFiles, double& TimeSpentPaused)
{
	bool bAllCorrect = true;
	OutDatedFiles.Empty();
	TimeSpentPaused = 0;

	// Setup progress tracking
	double TotalBuildSizeDouble = Manifest->GetBuildSize();
	double ProcessedBytes = 0;
	CurrentBuildPercentage = 0;

	// For all files in the manifest, check that they produce the correct SHA1 hash, adding any that don't to the list
	TArray<FString> BuildFiles;
	Manifest->GetFileList(BuildFiles);
	for (const FString& BuildFile : BuildFiles)
	{
		// Get file details
		int64 BuildFileSize = Manifest->GetFileSize(BuildFile);
		FSHAHashData BuildFileHash;
		bool bFoundHash = Manifest->GetFileHash(BuildFile, BuildFileHash);
		check(bFoundHash);

		// Chose the file to check
		FString FullFilename = SelectFullFilePath(BuildFile);

		// Verify the file
		CurrentFileWeight = BuildFileSize / TotalBuildSizeDouble;
		if (FBuildPatchUtils::VerifyFile(FullFilename, BuildFileHash, BuildFileHash, FBuildPatchFloatDelegate::CreateRaw(this, &FBuildPatchVerificationImpl::PerFileProgress), ShouldPauseDelegate, TimeSpentPaused) == 0)
		{
			bAllCorrect = false;
			OutDatedFiles.Add(BuildFile);
		}
		ProcessedBytes += BuildFileSize;
		CurrentBuildPercentage = ProcessedBytes / TotalBuildSizeDouble;
	}

	return bAllCorrect && !FBuildPatchInstallError::HasFatalError();
}
Example #27
0
void FRawStaticIndexBuffer::GetCopy(TArray<uint32>& OutIndices) const
{
	int32 NumIndices = b32Bit ? (IndexStorage.Num() / 4) : (IndexStorage.Num() / 2);
	OutIndices.Empty(NumIndices);
	OutIndices.AddUninitialized(NumIndices);

	if (b32Bit)
	{
		// If the indices are 32 bit we can just do a memcpy.
		check(IndexStorage.Num() == OutIndices.Num() * OutIndices.GetTypeSize());
		FMemory::Memcpy(OutIndices.GetData(),IndexStorage.GetData(),IndexStorage.Num());
	}
	else
	{
		// Copy element by element promoting 16-bit integers to 32-bit.
		check(IndexStorage.Num() == OutIndices.Num() * sizeof(uint16));
		const uint16* SrcIndices16Bit = (const uint16*)IndexStorage.GetData();
		for (int32 i = 0; i < NumIndices; ++i)
		{
			OutIndices[i] = SrcIndices16Bit[i];
		}
	}
}
// 全ソケットの情報を取得 
void USsPlayerComponent::QuerySupportedSockets(TArray<FComponentSocketDescription>& OutSockets) const
{
	OutSockets.Empty();
	if(    (RenderMode != ESsPlayerComponentRenderMode::OffScreenOnly)
		&& (Player.GetSsProject().IsValid())
		)
	{
		int32 AnimPackIndex  = Player.GetPlayingAnimPackIndex();
		int32 AnimationIndex = Player.GetPlayingAnimationIndex();
		if((0 <= AnimPackIndex) && (0 <= AnimationIndex))
		{
			FSsAnimation& Animation = Player.GetSsProject()->AnimeList[AnimPackIndex].AnimeList[AnimationIndex];
			for(int32 i = 0; i < Animation.PartAnimes.Num(); ++i)
			{
				OutSockets.Add(
					FComponentSocketDescription(
						Animation.PartAnimes[i].PartName,
						EComponentSocketType::Socket
						));
			}
		}
	}
}
Example #29
0
void FAutoReimportManager::Destroy()
{
	if (auto* AssetRegistryModule = FModuleManager::GetModulePtr<FAssetRegistryModule>("AssetRegistry"))
	{
		AssetRegistryModule->Get().OnAssetRenamed().RemoveAll(this);
	}
	
	if (auto* Settings = GetMutableDefault<UEditorLoadingSavingSettings>())
	{
		Settings->OnSettingChanged().RemoveAll(this);
	}

	FPackageName::OnContentPathMounted().RemoveAll(this);
	FPackageName::OnContentPathDismounted().RemoveAll(this);

	if (FAssetRegistryModule* AssetRegistryModule = FModuleManager::GetModulePtr<FAssetRegistryModule>("AssetRegistry"))
	{
		AssetRegistryModule->Get().OnInMemoryAssetDeleted().RemoveAll(this);
	}

	// Force a save of all the caches
	DirectoryMonitors.Empty();
}
bool ConvertOverlapResults(int32 NumOverlaps, PxOverlapHit* POverlapResults, const PxFilterData& QueryFilter, TArray<FOverlapResult>& OutOverlaps)
{
	OutOverlaps.Empty();

	bool bBlockingFound = false;

	for(int32 i=0; i<NumOverlaps; i++)
	{
		FOverlapResult NewOverlap;		
		
		ConvertQueryOverlap( POverlapResults[i].shape, POverlapResults[i].actor, NewOverlap, QueryFilter);


		if(NewOverlap.bBlockingHit)
		{
			bBlockingFound = true;
		}

		AddUniqueOverlap(OutOverlaps, NewOverlap);
	}

	return bBlockingFound;
}