If we fail to create a convex hull from the supplied points, substitute it for a small sphere.
continuous-integration/drone/push Build encountered an error Details

I found exactly one model in a single map for gmod that causes this to happen, a better solution would be to re-calculate a valid hull from the supplied points, but this'll do since it's such a rare case.
This commit is contained in:
Josh Dowell 2023-04-11 07:15:10 +01:00
parent d407472830
commit 562458200c
1 changed files with 14 additions and 1 deletions

View File

@ -535,7 +535,20 @@ namespace ivp_compat
settings.mHullTolerance = 0.0f;
JPH::ConvexShape *pConvexShape = ShapeSettingsToShape< JPH::ConvexShape >( settings );
if ( !pConvexShape )
return nullptr;
{
// Wow that sucks, just mock up a small sphere to subsitute.
// This can happen for models with extremely broken collision hulls.
// If we don't do this, we'll crash later on because older versions of Source are missing
// an important nullptr check.
// A better solution would be to generate a valid convex hull from the points provided.
JPH::SphereShapeSettings sphereSettings( 1.0f );
pConvexShape = ShapeSettingsToShape< JPH::ConvexShape >( sphereSettings );
if ( !pConvexShape )
{
// This should never fail, but catching anyway
return nullptr;
}
}
pConvexShape->SetUserData( pLedge->client_data );
return pConvexShape;