Files
UnrealEngineUWP/Engine/Source/Runtime/ClothingSystemRuntimeInterface/Private/ClothingSimulationInteractor.cpp
Marc Audy 9753392e2b Merge UE5/RES CL# 15462083 to UE5/Main
This represents UE4/Main @ 15414221

[CL 15463811 by Marc Audy in ue5-main branch]
2021-02-18 18:13:28 -04:00

53 lines
1.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "ClothingSimulationInteractor.h"
#include "ClothingAssetBase.h"
#include "ClothingSimulationInterface.h"
void UClothingSimulationInteractor::CreateClothingInteractor(const UClothingAssetBase* ClothingAsset, int32 ClothingId)
{
if (ClothingAsset)
{
if (UClothingInteractor* const ClothingInteractor = CreateClothingInteractor())
{
ClothingInteractor->ClothingId = ClothingId;
ClothingInteractors.Emplace(ClothingAsset->GetName(), ClothingInteractor);
}
}
}
void UClothingSimulationInteractor::DestroyClothingInteractors()
{
ClothingInteractors.Reset();
}
UClothingInteractor* UClothingSimulationInteractor::GetClothingInteractor(const FString& ClothingAssetName) const
{
if (UClothingInteractor* const* const ClothingInteractor = ClothingInteractors.Find(FName(ClothingAssetName)))
{
return *ClothingInteractor;
}
// Returning the default object will still make this a valid ClothingInteractor pointer, but one with no type or interface
return UClothingInteractor::StaticClass()->GetDefaultObject<UClothingInteractor>();
}
void UClothingSimulationInteractor::Sync(IClothingSimulation* Simulation, IClothingSimulationContext* Context)
{
LastNumCloths = Simulation->GetNumCloths();
LastNumKinematicParticles = Simulation->GetNumKinematicParticles();
LastNumDynamicParticles = Simulation->GetNumDynamicParticles();
LastNumIterations = Simulation->GetNumIterations();
LastNumSubsteps = Simulation->GetNumSubsteps();
LastSimulationTime = Simulation->GetSimulationTime();
for (const TPair<FName, UClothingInteractor*>& ClothingInteractor : UClothingSimulationInteractor::ClothingInteractors)
{
if (ClothingInteractor.Value)
{
ClothingInteractor.Value->Sync(Simulation);
}
}
}