Files
UnrealEngineUWP/Engine/Source/Runtime/PhysicsCore/Public/PhysTestSerializer.h
Benn Gallagher 8757cb3641 Physics interface cleanup.
* Removed deprecated or dead code paths
* Simplified build system setup for physics support
* Deprecated build system flags and unsupported macros

#jira none
#rb Chris.Caulfield, Kriss.Gossart
#preflight 62963ec0fe779f23c8ea0c5e

[CL 20450744 by Benn Gallagher in ue5-main branch]
2022-06-01 06:59:18 -04:00

108 lines
2.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "PhysicsInterfaceDeclaresCore.h"
#include "Chaos/ChaosArchive.h"
#include "Chaos/PBDRigidsEvolutionGBF.h"
#include "Chaos/ParticleHandle.h"
#include "SQCapture.h"
#include "Serialization/MemoryReader.h"
#include "Serialization/CustomVersion.h"
#ifndef PHYS_TEST_SERIALIZER
#define PHYS_TEST_SERIALIZER 1
#endif
// Utility used for serializing just physics data. This is meant for only the physics engine data (physx or chaos, not any unreal side). It is not meant to be used for actual serialization
#if PHYS_TEST_SERIALIZER
namespace Chaos
{
class FChaosArchive;
}
class PHYSICSCORE_API FPhysTestSerializer
{
public:
FPhysTestSerializer();
FPhysTestSerializer(const FPhysTestSerializer& Other) = delete;
FPhysTestSerializer(FPhysTestSerializer&& Other) = delete;
FPhysTestSerializer& operator=(const FPhysTestSerializer&) = delete;
FPhysTestSerializer& operator=(FPhysTestSerializer&&) = delete;
void Serialize(Chaos::FChaosArchive& Ar);
void Serialize(const TCHAR* FilePrefix);
//Set the data from an external source. This will obliterate any existing data. Make sure you are not holding on to old internal data as it will go away
void SetPhysicsData(Chaos::FPBDRigidsEvolution& ChaosEvolution);
const Chaos::FChaosArchiveContext* GetChaosContext() const
{
return ChaosContext.Get();
}
FSQCapture& CaptureSQ()
{
ensure(!SQCapture); //we don't have support for multi sweeps yet since the scene could change
SQCapture = TUniquePtr<FSQCapture>(new FSQCapture(*this));
return *SQCapture;
}
const FSQCapture* GetSQCapture()
{
if (SQCapture)
{
//todo: this sucks, find a better way to create data instead of doing it lazily
GetChaosData();
#if 0
SQCapture->CreateChaosDataFromPhysX();
#endif
}
return SQCapture.Get();
}
Chaos::FPBDRigidsEvolution* GetChaosData()
{
#if 0
if (!bChaosDataReady)
{
ensure(!bDiskDataIsChaos);
//only supported for physx to chaos - don't have serialization context
CreateChaosData();
}
#endif
return ChaosEvolution.Get();
}
private:
#if 0
void CreateChaosData();
#endif
private:
TArray<uint8> Data; //how the data is stored before going to disk
bool bDiskDataIsChaos;
bool bChaosDataReady;
TUniquePtr<FSQCapture> SQCapture;
TUniquePtr<Chaos::FPBDRigidsEvolution> ChaosEvolution;
Chaos::FParticleUniqueIndicesMultithreaded UniqueIndices;
Chaos::FPBDRigidsSOAs Particles;
Chaos::THandleArray<Chaos::FChaosPhysicsMaterial> PhysicalMaterials;
TArray <TUniquePtr<Chaos::FGeometryParticle>> GTParticles;
TUniquePtr<Chaos::FChaosArchiveContext> ChaosContext;
FCustomVersionContainer ArchiveVersion;
};
#endif