blob: 8b8fefe7f59841ec4e7c2456ae75a3a90210785b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#pragma once
#include <vector>
#include "NvBlastExtAuthoringTypes.h"
#include "PxFoundation.h"
#include "PxPhysics.h"
#include "PxCooking.h"
#include "PxDefaultAllocator.h"
#include "PxDefaultErrorCallback.h"
#include <memory>
#include "NvBlastExtAuthoringMesh.h"
#include "NvBlastExtAuthoringBondGenerator.h"
#include "NvBlastTypes.h"
#include "NvBlastExtPxAsset.h"
struct FractureResult
{
std::vector<std::vector<Nv::Blast::Triangle>> resultGeometry;
std::shared_ptr<Nv::Blast::ExtPxAsset> 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<FractureResult> fractureMesh(std::shared_ptr<Nv::Blast::Mesh> 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<std::vector<Nv::Blast::Triangle>>& chunkGeometry, std::vector<Nv::Blast::ExtPxAssetDesc::ChunkDesc>& outPhysicsChunks,
std::vector<Nv::Blast::ExtPxAssetDesc::SubchunkDesc>& outPhysicsSubchunks);
std::shared_ptr<FractureResult> finalizeMeshProcessing(std::vector<NvBlastChunkDesc> chunkDesc, std::vector<NvBlastBondDesc> bondDescs, std::vector<std::vector<Nv::Blast::Triangle> > chunkMeshes);
bool initPhysX();
void releasePhysX();
};
|