bool UBlendSpaceBase::IsTooCloseToExistingSamplePoint(const FVector& SampleValue, int32 OriginalIndex) const { for (int32 I=0; I<SampleData.Num(); ++I) { if (I!=OriginalIndex) { if ( IsSameSamplePoint(SampleValue, SampleData[I].SampleValue) ) { return true; } } } return false; }
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(); } }