Skip to content

Commit 88c749d

Browse files
committed
1 parent d0fcf2f commit 88c749d

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

game/server/props.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5977,7 +5977,7 @@ bool UTIL_CreateScaledPhysObject( CBaseAnimating *pInstance, float flScale )
59775977

59785978
// Create a container to hold all the convexes we'll create
59795979
const int nNumConvex = pQuery->ConvexCount();
5980-
CPhysConvex **pConvexes = (CPhysConvex **) stackalloc( sizeof(CPhysConvex *) * nNumConvex );
5980+
CPhysPolysoup *pPolySoups = physcollision->PolysoupCreate();
59815981

59825982
// For each convex, collect the verts and create a convex from it we'll retain for later
59835983
for ( int i = 0; i < nNumConvex; i++ )
@@ -5986,33 +5986,26 @@ bool UTIL_CreateScaledPhysObject( CBaseAnimating *pInstance, float flScale )
59865986
int nNumVerts = nNumTris * 3;
59875987
// FIXME: Really? stackalloc?
59885988
Vector *pVerts = (Vector *) stackalloc( sizeof(Vector) * nNumVerts );
5989-
Vector **ppVerts = (Vector **) stackalloc( sizeof(Vector *) * nNumVerts );
59905989
for ( int j = 0; j < nNumTris; j++ )
59915990
{
59925991
// Get all the verts for this triangle and scale them up
59935992
pQuery->GetTriangleVerts( i, j, pVerts+(j*3) );
59945993
*(pVerts+(j*3)) *= flScale;
59955994
*(pVerts+(j*3)+1) *= flScale;
59965995
*(pVerts+(j*3)+2) *= flScale;
5997-
5998-
// Setup our pointers (blech!)
5999-
*(ppVerts+(j*3)) = pVerts+(j*3);
6000-
*(ppVerts+(j*3)+1) = pVerts+(j*3)+1;
6001-
*(ppVerts+(j*3)+2) = pVerts+(j*3)+2;
60025996
}
60035997

6004-
// Convert it back to a convex
6005-
pConvexes[i] = physcollision->ConvexFromVerts( ppVerts, nNumVerts );
6006-
Assert( pConvexes[i] != NULL );
6007-
if ( pConvexes[i] == NULL )
6008-
return false;
5998+
for ( int j = 0; j < nNumVerts; j += 3 )
5999+
{
6000+
physcollision->PolysoupAddTriangle( pPolySoups, pVerts[j], pVerts[j + 1], pVerts[j + 2], 0 );
6001+
}
60096002
}
60106003

60116004
// Clean up
60126005
physcollision->DestroyQueryModel( pQuery );
60136006

60146007
// Create a collision model from all the convexes
6015-
pNewCollide = physcollision->ConvertConvexToCollide( pConvexes, nNumConvex );
6008+
pNewCollide = physcollision->ConvertPolysoupToCollide( pPolySoups, true );
60166009
if ( pNewCollide == NULL )
60176010
return false;
60186011
}

0 commit comments

Comments
 (0)