Files
UnrealEngineUWP/Engine/Source/Runtime/PhysicsCore/Public/IPhysXCooking.h
Ben Marsh cfe09c649f Merging //UE4/Dev-Main to Dev-Build (//UE4/Dev-Build)
#rb none
#rnx

[CL 6922670 by Ben Marsh in Dev-Build branch]
2019-06-10 19:47:29 -04:00

157 lines
5.3 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Misc/EnumClassFlags.h"
// The result of a cooking operation
enum class EPhysXCookingResult : uint8
{
// Cooking failed
Failed,
// Cooking succeeded with no issues
Succeeded,
// Cooking the exact source data failed, but succeeded after retrying with inflation enabled
SucceededWithInflation,
};
enum class EPhysXMeshCookFlags : uint8
{
Default = 0x0,
// Don't perform mesh cleaning, so resulting mesh has same vertex order as input mesh
DeformableMesh = 0x1,
// Prioritize cooking speed over runtime speed
FastCook = 0x2,
// Do not create remap table for this mesh
SuppressFaceRemapTable = 0x4,
// Turn off ActiveEdgePrecompute (This makes cooking faster, but will slow contact generation)
DisableActiveEdgePrecompute = 0x8,
};
ENUM_CLASS_FLAGS(EPhysXMeshCookFlags);
namespace physx
{
class PxCooking;
class PxConvexMesh;
class PxTriangleMesh;
class PxHeightField;
}
/**
* IPhysXCooking, PhysX cooking and serialization abstraction
**/
class PHYSICSCORE_API IPhysXCooking
{
public:
/**
* Checks whether parallel PhysX cooking is allowed.
*
* Note: This method is not currently used yet.
*
* @return true if this PhysX format can cook in parallel, false otherwise.
*/
virtual bool AllowParallelBuild( ) const
{
return false;
}
/**
* Cooks the source convex data for the platform and stores the cooked data internally.
*
* @param Format The desired format
* @param CookFlags Flags used to provide options for this cook
* @param SrcBuffer The source buffer
* @param OutBuffer The resulting cooked data
* @return An enum indicating full success, partial success, or failure (@see EPhysXCookingResult)
*/
virtual EPhysXCookingResult CookConvex( FName Format, EPhysXMeshCookFlags CookFlags, const TArray<FVector>& SrcBuffer, TArray<uint8>& OutBuffer ) const = 0;
/**
* Cooks the source convex data for the platform and returns the PhysX geometry directly (meant for runtime when you just need the geometry directly without serializing out)
*
* @param Format The desired format
* @param CookFlags Flags used to provide options for this cook
* @param SrcBuffer The source buffer
* @param OutBuffer The resulting cooked data
* @return The cooked convex mesh geometry
*/
virtual EPhysXCookingResult CreateConvex(FName Format, EPhysXMeshCookFlags CookFlags, const TArray<FVector>& SrcBuffer, physx::PxConvexMesh*& OutBuffer) const = 0;
/**
* Cooks the source Tri-Mesh data for the platform and stores the cooked data internally.
*
* @param Format The desired format.
* @param CookFlags Flags used to provide options for this cook
* @param SrcBuffer The source buffer.
* @param OutBuffer The resulting cooked data.
* @return true on success, false otherwise.
*/
virtual bool CookTriMesh( FName Format, EPhysXMeshCookFlags CookFlags, const TArray<FVector>& SrcVertices, const TArray<struct FTriIndices>& SrcIndices, const TArray<uint16>& SrcMaterialIndices, const bool FlipNormals, TArray<uint8>& OutBuffer) const = 0;
/**
* Cooks the source Tri-Mesh data for the platform and returns the PhysX geometry directly (meant for runtime when you just need the geometry directly without serializing out)
*
* @param Format The desired format.
* @param CookFlags Flags used to provide options for this cook
* @param SrcBuffer The source buffer.
* @param OutBuffer The resulting cooked data.
* @return true on success, false otherwise.
*/
virtual bool CreateTriMesh(FName Format, EPhysXMeshCookFlags CookFlags, const TArray<FVector>& SrcVertices, const TArray<struct FTriIndices>& SrcIndices, const TArray<uint16>& SrcMaterialIndices, const bool FlipNormals, physx::PxTriangleMesh*& OutTriangleMesh) const = 0;
/**
* Cooks the source height field data for the platform and stores the cooked data internally.
*
* @param Format The desired format
* @param HFSize Size of height field [NumColumns, NumRows]
* @param SrcBuffer The source buffer
* @param OutBuffer The resulting cooked data
* @return true on success, false otherwise.
*/
virtual bool CookHeightField( FName Format, FIntPoint HFSize, const void* Samples, uint32 SamplesStride, TArray<uint8>& OutBuffer ) const = 0;
/**
* Cooks the source height field data for the platform and returns the PhysX geometry directly (meant for runtime when you just need the geometry directly without serializing out)
*
* @param Format The desired format
* @param HFSize Size of height field [NumColumns, NumRows]
* @param SrcBuffer The source buffer
* @param OutBuffer The resulting cooked data
* @return true on success, false otherwise.
*/
virtual bool CreateHeightField(FName Format, FIntPoint HFSize, const void* Samples, uint32 SamplesStride, physx::PxHeightField*& OutHeightField) const = 0;
/**
* Gets the list of supported formats.
*
* @param OutFormats Will hold the list of formats.
*/
virtual void GetSupportedFormats( TArray<FName>& OutFormats ) const = 0;
/**
* Gets the current version of the specified PhysX format.
*
* @param Format The format to get the version for.
* @return Version number.
*/
virtual uint16 GetVersion( FName Format ) const = 0;
/** Get the actual physx cooker object */
virtual physx::PxCooking* GetCooking() const = 0;
public:
/**
* Virtual destructor.
*/
virtual ~IPhysXCooking( ) { }
};