Fix crash when using Physical Material with missing instance
(cherry picked from commit 5e77925492)
This commit is contained in:
@@ -246,7 +246,7 @@ void Collider::CreateShapeBase(const PxGeometry& geometry)
|
|||||||
const bool isTrigger = _isTrigger && CanBeTrigger();
|
const bool isTrigger = _isTrigger && CanBeTrigger();
|
||||||
const PxShapeFlags shapeFlags = GetShapeFlags(isTrigger, IsActiveInHierarchy());
|
const PxShapeFlags shapeFlags = GetShapeFlags(isTrigger, IsActiveInHierarchy());
|
||||||
PxMaterial* material = Physics::GetDefaultMaterial();
|
PxMaterial* material = Physics::GetDefaultMaterial();
|
||||||
if (Material && !Material->WaitForLoaded())
|
if (Material && !Material->WaitForLoaded() && Material->Instance)
|
||||||
{
|
{
|
||||||
material = ((PhysicalMaterial*)Material->Instance)->GetPhysXMaterial();
|
material = ((PhysicalMaterial*)Material->Instance)->GetPhysXMaterial();
|
||||||
}
|
}
|
||||||
@@ -291,13 +291,10 @@ void Collider::OnMaterialChanged()
|
|||||||
if (_shape)
|
if (_shape)
|
||||||
{
|
{
|
||||||
PxMaterial* material = Physics::GetDefaultMaterial();
|
PxMaterial* material = Physics::GetDefaultMaterial();
|
||||||
if (Material)
|
if (Material && !Material->WaitForLoaded() && Material->Instance)
|
||||||
{
|
|
||||||
if (!Material->WaitForLoaded())
|
|
||||||
{
|
{
|
||||||
material = ((PhysicalMaterial*)Material->Instance)->GetPhysXMaterial();
|
material = ((PhysicalMaterial*)Material->Instance)->GetPhysXMaterial();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_shape->setMaterials(&material, 1);
|
_shape->setMaterials(&material, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user