示例#1
0
bool UBlendSpaceBase::ValidateSampleInput(FBlendSample & BlendSample, int32 OriginalIndex) const
{
	// make sure we get same kinds of samples(additive or nonadditive)
	if (SampleData.Num() > 0 && BlendSample.Animation)
	{
		if (IsValidAdditive() != (BlendSample.Animation->IsValidAdditive()))
		{
			UE_LOG(LogAnimation, Log, TEXT("Adding sample failed. Please add same kinds of sequence (additive/non-additive)."));
			return false;
		}
	}

	const USkeleton* MySkeleton = GetSkeleton();
	if (BlendSample.Animation &&
		(! MySkeleton ||
		! BlendSample.Animation->GetSkeleton()->IsCompatible(MySkeleton)))
	{
		UE_LOG(LogAnimation, Log, TEXT("Adding sample failed. Please add same kinds of sequence (additive/non-additive)."));
		return false;
	}

	SnapToBorder(BlendSample);
	// make sure blendsample is within the parameter range
	BlendSample.SampleValue = ClampBlendInput(BlendSample.SampleValue);

	if (IsTooCloseToExistingSamplePoint(BlendSample.SampleValue, OriginalIndex))
	{
		UE_LOG(LogAnimation, Log, TEXT("Adding sample failed. Too close to existing sample point."));
		return false;
	}

	return true;
}
示例#2
0
void UBlendSpaceBase::ValidateSampleData()
{
	bool bSampleDataChanged=false;
	AnimLength = 0.f;

	for (int32 I=0; I<SampleData.Num(); ++I)
	{
		if ( SampleData[I].Animation == 0 )
		{
			SampleData.RemoveAt(I);
			--I;

			bSampleDataChanged = true;
			continue;
		}

		// set rotation blend in mesh space
		bRotationBlendInMeshSpace = IsValidAdditiveInternal(AAT_RotationOffsetMeshSpace);

		// we need data to be snapped on the border
		// otherwise, you have this grid area that doesn't have valid 
		// sample points. Usually users will put it there
		// if the value is around border, snap to border
		SnapToBorder(SampleData[I]);

		// see if same data exists, by same, same values
		for (int32 J=I+1; J<SampleData.Num(); ++J)
		{
			if ( IsSameSamplePoint(SampleData[I].SampleValue, SampleData[J].SampleValue) )
			{
				SampleData.RemoveAt(J);
				--J;

				bSampleDataChanged = true;
			}
		}

		if (SampleData[I].Animation->SequenceLength > AnimLength)
		{
			// @todo : should apply scale? If so, we'll need to apply also when blend
			AnimLength = SampleData[I].Animation->SequenceLength;
		}
	}

	if (bSampleDataChanged)
	{
		GridSamples.Empty();
		MarkPackageDirty();
	}
}
void UBlendSpaceBase::ValidateSampleData()
{
	bool bSampleDataChanged=false;
	AnimLength = 0.f;

	bool bAllMarkerPatternsMatch = true;
	FSyncPattern BlendSpacePattern;

	int32 SampleWithMarkers = INDEX_NONE;

	for (int32 I=0; I<SampleData.Num(); ++I)
	{
		FBlendSample& Sample = SampleData[I];

		if (Sample.Animation == nullptr)
		{
			SampleData.RemoveAt(I);
			--I;

			bSampleDataChanged = true;
			continue;
		}

		// set rotation blend in mesh space
		bRotationBlendInMeshSpace = IsValidAdditiveInternal(AAT_RotationOffsetMeshSpace);

		// we need data to be snapped on the border
		// otherwise, you have this grid area that doesn't have valid 
		// sample points. Usually users will put it there
		// if the value is around border, snap to border
		SnapToBorder(Sample);

		// see if same data exists, by same, same values
		for (int32 J=I+1; J<SampleData.Num(); ++J)
		{
			if (IsSameSamplePoint(Sample.SampleValue, SampleData[J].SampleValue))
			{
				SampleData.RemoveAt(J);
				--J;

				bSampleDataChanged = true;
			}
		}

		if (Sample.Animation->SequenceLength > AnimLength)
		{
			// @todo : should apply scale? If so, we'll need to apply also when blend
			AnimLength = Sample.Animation->SequenceLength;
		}

		if (Sample.Animation->AuthoredSyncMarkers.Num() > 0)
		{
			if (SampleWithMarkers == INDEX_NONE)
			{
				SampleWithMarkers = I;
			}

			if (BlendSpacePattern.MarkerNames.Num() == 0)
			{
				PopulateMarkerNameArray(BlendSpacePattern.MarkerNames, Sample.Animation->AuthoredSyncMarkers);
			}
			else
			{
				TArray<FName> ThisPattern;
				PopulateMarkerNameArray(ThisPattern, Sample.Animation->AuthoredSyncMarkers);
				if (!BlendSpacePattern.DoesPatternMatch(ThisPattern))
				{
					bAllMarkerPatternsMatch = false;
				}
			}
		}
	}

	SampleIndexWithMarkers = bAllMarkerPatternsMatch ? SampleWithMarkers : INDEX_NONE;

	if (bSampleDataChanged)
	{
		GridSamples.Empty();
		MarkPackageDirty();
	}
}