#pragma once #include #include "NvBlastExtAuthoringTypes.h" #include "PxFoundation.h" #include "PxPhysics.h" #include "PxCooking.h" #include "PxDefaultAllocator.h" #include "PxDefaultErrorCallback.h" #include #include "NvBlastExtAuthoringMesh.h" #include "NvBlastExtAuthoringBondGenerator.h" #include "NvBlastTypes.h" #include "NvBlastExtPxAsset.h" struct FractureResult { std::vector> resultGeometry; std::shared_ptr resultPhysicsAsset; }; struct FractureSettings { unsigned char mode; uint32_t cellsCount; uint32_t clusterCount; float clusterRadius; int32_t slicingX; int32_t slicingY; int32_t slicingZ; float angleVariation; float offsetVariation; }; class FractureProcessor { public: FractureProcessor(); ~FractureProcessor(); std::shared_ptr fractureMesh(std::shared_ptr sourceMesh, const FractureSettings &settings); physx::PxPhysics* getPhysics() { return physics; } physx::PxCooking* getCooking() { return cooking; } private: physx::PxFoundation* foundation = nullptr; physx::PxPhysics* physics = nullptr; physx::PxCooking* cooking = nullptr; Nv::Blast::TkFramework* framework = nullptr; physx::PxDefaultAllocator g_allocator; physx::PxDefaultErrorCallback g_errorCallback; void buildPhysicsChunks(const std::vector>& chunkGeometry, std::vector& outPhysicsChunks, std::vector& outPhysicsSubchunks); std::shared_ptr finalizeMeshProcessing(std::vector chunkDesc, std::vector bondDescs, std::vector > chunkMeshes); bool initPhysX(); void releasePhysX(); };