void UAnimSequenceBase::VerifyCurveNames(USkeleton* Skeleton, const FName& NameContainer, TArray<DataType>& CurveList) { FSmartNameMapping* NameMapping = Skeleton->SmartNames.GetContainer(NameContainer); // since this is verify function that makes sure it exists after loaded // we should add it if it doesn't exist if (!NameMapping) { // if it doens't exists, we should add it Skeleton->Modify(true); Skeleton->SmartNames.AddContainer(NameContainer); NameMapping = Skeleton->SmartNames.GetContainer(NameContainer); check(NameMapping); } TArray<DataType*> UnlinkedCurves; for(DataType& Curve : CurveList) { if(!NameMapping->Exists(Curve.LastObservedName)) { // The skeleton doesn't know our name. Use the last observed name that was saved with the // curve to create a new name. This can happen if a user saves an animation but not a skeleton // either when updating the assets or editing the curves within. UnlinkedCurves.Add(&Curve); } } for(DataType* Curve : UnlinkedCurves) { NameMapping->AddOrFindName(Curve->LastObservedName, Curve->CurveUid); } }
void USkeleton::RemoveSmartnameAndModify(FName ContainerName, FSmartNameMapping::UID Uid) { FSmartNameMapping* RequestedMapping = SmartNames.GetContainer(ContainerName); if(RequestedMapping) { if(RequestedMapping->Exists(Uid)) { Modify(); RequestedMapping->Remove(Uid); } } }
bool UnFbx::FFbxImporter::ImportCurveToAnimSequence(class UAnimSequence * TargetSequence, const FString& CurveName, const FbxAnimCurve* FbxCurve, int32 CurveFlags,const FbxTimeSpan AnimTimeSpan, const float ValueScale/*=1.f*/) const { if (TargetSequence && FbxCurve) { FName Name = *CurveName; USkeleton* Skeleton = TargetSequence->GetSkeleton(); FSmartNameMapping* NameMapping = Skeleton->SmartNames.GetContainer(USkeleton::AnimCurveMappingName); // Add or retrieve curve USkeleton::AnimCurveUID Uid; if (!NameMapping->Exists(Name)) { // mark skeleton dirty Skeleton->Modify(); } NameMapping->AddOrFindName(Name, Uid); FFloatCurve * CurveToImport = static_cast<FFloatCurve *>(TargetSequence->RawCurveData.GetCurveData(Uid, FRawCurveTracks::FloatType)); if(CurveToImport==NULL) { if(TargetSequence->RawCurveData.AddCurveData(Uid, CurveFlags)) { CurveToImport = static_cast<FFloatCurve *> (TargetSequence->RawCurveData.GetCurveData(Uid, FRawCurveTracks::FloatType)); } else { // this should not happen, we already checked before adding ensureMsgf(0, TEXT("FBX Import: Critical error: no memory?")); } } else { CurveToImport->FloatCurve.Reset(); } return ImportCurve(FbxCurve, CurveToImport, AnimTimeSpan, ValueScale); } return false; }