Error initializing PhysX (3.4) when using Blast

Hi all,

I’m trying to use the Blast library within Unity and have created some additional C# bindings on top of the examples that are included with the library. I am getting a crash when initializing PhysX though, and I can’t see what I’m doing wrong. Any ideas?

Code:

bool initPhysX()
{
	printf("Going to init physx\n");
	gFoundation = PxCreateFoundation(PX_FOUNDATION_VERSION, NvBlastGetPxAllocatorCallback(), NvBlastGetPxErrorCallback());
	if (!gFoundation)
	{
		std::cerr << "Can't init PhysX foundation" << std::endl;
		return false;
	}
	else {
		printf("created foundation\n");
	}
	physx::PxTolerancesScale scale;
	gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, scale, true);
	if (!gPhysics)
	{
		std::cerr << "Can't create Physics" << std::endl;
		return false;
	}
	else {
		printf("created physics\n");
	}
	physx::PxCookingParams cookingParams(scale);
	cookingParams.buildGPUData = true;
	gCooking = PxCreateCooking(PX_PHYSICS_VERSION, gPhysics->getFoundation(), cookingParams);
	if (!gCooking)
	{
		std::cerr << "Can't create Cooking" << std::endl;
		return false;
	}
	else {
		printf("created cooking\n");
	}

	return true;
}

NVBLAST_API uint32_t _AuthoringTool_ProcessFracture(FractureTool* fractureTool) {
	if (!fractureTool) { printf("(Warning) _AuthoringTool_ProcessFracture: NULL tool\n"); return NULL; }

	printf("Going to process the fracture...\n");

	if (gPhysics == NULL) {
		initPhysX();
	}

	printf("set up bond generator and mexh builder...\n");

	Nv::Blast::BlastBondGenerator* bondGenerator = NvBlastExtAuthoringCreateBondGenerator(gCooking, &gPhysics->getPhysicsInsertionCallback());
	Nv::Blast::ConvexMeshBuilder* collisionBuilder = NvBlastExtAuthoringCreateConvexMeshBuilder(gCooking, &gPhysics->getPhysicsInsertionCallback());
	
	printf("set up collision param...\n");

	Nv::Blast::CollisionParams collisionParameter;
	collisionParameter.maximumNumberOfHulls = 1;
	collisionParameter.voxelGridResolution = 0;
	
	printf("Call NvBlastExtAuthoringProcessFracture...\n");

	Nv::Blast::AuthoringResult* result = NvBlastExtAuthoringProcessFracture(*fractureTool, *bondGenerator, *collisionBuilder, collisionParameter);
	
	printf("release bond generator and collision builder...\n");
	collisionBuilder->release();
	bondGenerator->release();

	printf("return authoring result\n");

	return (uint32_t)result;
}

Stack trace:

0x00007FF9CCB8A839 (KERNELBASE) RaiseException
0x00007FF9482B290E (PhysX3_x64) PxSetPhysXDelayLoadHook
0x00007FF9482B11D0 (PhysX3_x64) PxSetPhysXDelayLoadHook
0x00007FF94819055A (PhysX3_x64) physx::ProjectionPlaneProperty::ProjectionPlaneProperty
0x00007FF9481916DC (PhysX3_x64) physx::ProjectionPlaneProperty::ProjectionPlaneProperty
0x00007FF9481A7256 (PhysX3_x64) PxGetPhysics
0x00007FF9C4401CB7 (NvBlastExtUnity_x64) [c:\users\joe\code\blast\compiler\vc15win64-cmake\blast_bin\nvblastextunity\nvblastextunity.cpp:272] initPhysX 
0x00007FF9C4401E93 (NvBlastExtUnity_x64) [c:\users\joe\code\blast\compiler\vc15win64-cmake\blast_bin\nvblastextunity\nvblastextunity.cpp:305] _AuthoringTool_ProcessFracture 
0x0000000000E62B2A (Mono JIT Code) (wrapper managed-to-native) NvFractureTool:_AuthoringTool_ProcessFracture (intptr)
0x0000000000E6297B (Mono JIT Code) [C:\Users\joe\Code\Blast\examples\UnityExample\Assets\NvBlast\Plugins\NvBlastExtUnity.cs:222] NvFractureTool:processFracture () 
0x0000000000E59973 (Mono JIT Code) [C:\Users\joe\Code\Blast\examples\UnityExample\Assets\NvBlast\Editor\CEditorTestFracture.cs:186] CEditorTestFracture:_createPreview (bool) 
0x0000000016EFDA6B (Mono JIT Code) [C:\Users\joe\Code\Blast\examples\UnityExample\Assets\NvBlast\Editor\CEditorTestFracture.cs:127] CEditorTestFracture:OnGUI ()