4.6.1 Importing destructible from apex physics lab set Materials.bEnableShadowCasting to false


I Found something interesting, when you import destructible (*.apb) file created in PhysXLab to the engine, the engine will always set materials bEnableShadowCasting flag to false.

This is caused by

bool SetApexDestructibleAsset(UDestructibleMesh& DestructibleMesh, NxDestructibleAsset& ApexDestructibleAsset, FSkeletalMeshImportData* OutData, EDestructibleImportOptions::Type Options)

ExistingDestMeshData * ExistDestMeshDataPtr = SaveExistingDestMeshData(&DestructibleMesh);

//create materials
//create bones
//import influences

if (ExistDestMeshDataPtr)
	RestoreExistingDestMeshData(ExistDestMeshDataPtr, &DestructibleMesh);
	delete ExistDestMeshDataPtr;
	ExistDestMeshDataPtr = NULL;

As you see the ExistDestMeshDataPtr is always created and at the end of creation of DestructibleMesh asset old-invalid settings will be restored.

This piece of code:

ExistingDestMeshData * ExistDestMeshDataPtr = SaveExistingDestMeshData(&DestructibleMesh);

should be changed to:

ExistingDestMeshData * ExistDestMeshDataPtr = nullptr;
if ((Options & EDestructibleImportOptions::PreserveSettings))
	ExistDestMeshDataPtr = SaveExistingDestMeshData(&DestructibleMesh);

My code takes into account EDestructibleImportOptions::PreserveSettings which is None when you importing destructible asset and set to:
EDestructibleImportOptions::PreserveSettings during reimporting.

Am I right?



Hi Pierdek,

This seems right, but I want to step through it a bit. Do you mind submitting a pull request?

Sure I can.