Merge branch 'master' into windows

This commit is contained in:
HappyDOGE
2022-07-27 12:58:56 +03:00
3089 changed files with 38639 additions and 844820 deletions
+18 -18
View File
@@ -189,8 +189,8 @@ IPhysicsCollisionSet *CPhysicsInterface::FindOrCreateCollisionSet( unsigned int
IPhysicsCollisionSet *pSet = FindCollisionSet( id );
if ( pSet )
return pSet;
int index = m_collisionSets.AddToTail();
m_pCollisionSetHash->add_elem( (void *)id, (void *)(index+1) );
intp index = m_collisionSets.AddToTail();
m_pCollisionSetHash->add_elem( (void *)(intp)id, (void *)(intp)(index+1) );
return &m_collisionSets[index];
}
@@ -198,7 +198,7 @@ IPhysicsCollisionSet *CPhysicsInterface::FindCollisionSet( unsigned int id )
{
if ( m_pCollisionSetHash )
{
int index = (int)m_pCollisionSetHash->find_elem( (void *)id );
intp index = (intp)m_pCollisionSetHash->find_elem( (void *)(intp)id );
if ( index > 0 )
{
Assert( index <= m_collisionSets.Count() );
@@ -223,20 +223,20 @@ void CPhysicsInterface::DestroyAllCollisionSets()
// In release build, each of these libraries must contain a symbol that indicates it is also a release build
// You MUST disable this in order to run a release vphysics.dll with a debug library.
// This should not usually be necessary
#if !defined(_DEBUG) && defined(_WIN32)
extern int ivp_physics_lib_is_a_release_build;
extern int ivp_compactbuilder_lib_is_a_release_build;
extern int hk_base_lib_is_a_release_build;
extern int hk_math_lib_is_a_release_build;
extern int havana_constraints_lib_is_a_release_build;
// #if !defined(_DEBUG) && defined(_WIN32)
// extern int ivp_physics_lib_is_a_release_build;
// extern int ivp_compactbuilder_lib_is_a_release_build;
// extern int hk_base_lib_is_a_release_build;
// extern int hk_math_lib_is_a_release_build;
// extern int havana_constraints_lib_is_a_release_build;
void DebugTestFunction()
{
ivp_physics_lib_is_a_release_build = 0;
ivp_compactbuilder_lib_is_a_release_build = 0;
hk_base_lib_is_a_release_build = 0;
hk_math_lib_is_a_release_build = 0;
havana_constraints_lib_is_a_release_build = 0;
}
#endif
// void DebugTestFunction()
// {
// ivp_physics_lib_is_a_release_build = 0;
// ivp_compactbuilder_lib_is_a_release_build = 0;
// hk_base_lib_is_a_release_build = 0;
// hk_math_lib_is_a_release_build = 0;
// havana_constraints_lib_is_a_release_build = 0;
// }
// #endif
+6 -1
View File
@@ -1641,8 +1641,13 @@ void CPhysicsCollision::VCollideLoad( vcollide_t *pOutput, int solidCount, const
memcpy( &size, pBuffer + position, sizeof(int) );
position += sizeof(int);
pOutput->solids[i] = CPhysCollide::UnserializeFromBuffer( pBuffer + position, size, i, swap );
char *tmpbuf = new char[size];
memcpy(tmpbuf, pBuffer + position, size);
pOutput->solids[i] = CPhysCollide::UnserializeFromBuffer( tmpbuf, size, i, swap );
position += size;
delete[] tmpbuf;
}
END_IVP_ALLOCATION();
+3 -3
View File
@@ -2041,7 +2041,7 @@ public:
if ( !pHash )
return m_objectList.InvalidIndex();
unsigned int hash = (unsigned int)pHash;
uintp hash = (uintp)pHash;
// mask off the extra bit we added to avoid zeros
hash &= 0xFFFF;
return (unsigned short)hash;
@@ -2051,10 +2051,10 @@ public:
void *ListIndexToHash( unsigned short listIndex )
{
unsigned int hash = (unsigned int)listIndex;
// set the high bit, so zero means "not there"
hash |= 0x80000000;
return (void *)hash;
return (void *)(intp)hash;
}
// Lookup this object and get a multilist entry
+5 -4
View File
@@ -177,6 +177,11 @@ void CPhysicsObject::Wake( void )
m_pObject->ensure_in_simulation();
}
void CPhysicsObject::WakeNow( void )
{
m_pObject->ensure_in_simulation_now();
}
// supported
void CPhysicsObject::Sleep( void )
{
@@ -642,9 +647,6 @@ void CPhysicsObject::SetInertia( const Vector &inertia )
ri.k[1] = IVP_Inline_Math::fabsd(ri.k[1]);
ri.k[2] = IVP_Inline_Math::fabsd(ri.k[2]);
if( ri.k[0] > 1e14f ) ri.k[0] = 1e14f; if( ri.k[1] > 1e14f ) ri.k[1] = 1e14f; if( ri.k[2] > 1e14f ) ri.k[2] = 1e14f;
if( ri.k[0] <= 0 ) ri.k[0] = 1.f; if( ri.k[1] <= 0 ) ri.k[1] = 1.f; if( ri.k[2] <= 0 ) ri.k[2] = 1.f;
m_pObject->get_core()->set_rotation_inertia( &ri );
}
@@ -1092,7 +1094,6 @@ void GetWorldCoordFromSynapse( IVP_Synapse_Friction *pfriction, IVP_U_Point &wor
world.set(pfriction->get_contact_point()->get_contact_point_ws());
}
bool CPhysicsObject::GetContactPoint( Vector *contactPoint, IPhysicsObject **contactObject ) const
{
IVP_Synapse_Friction *pfriction = m_pObject->get_first_friction_synapse();
+1
View File
@@ -112,6 +112,7 @@ public:
unsigned short GetGameIndex( void ) const;
void Wake();
void WakeNow();
void Sleep();
void RecheckCollisionFilter();
void RecheckContactPoints();
+8 -6
View File
@@ -27,7 +27,7 @@
class CPhysCollideVirtualMesh;
CTSPool< CUtlVector<CPhysCollideVirtualMesh *> > g_MeshFrameLocksPool;
CThreadLocalPtr< CUtlVector<CPhysCollideVirtualMesh *> > g_pMeshFrameLocks;
CTHREADLOCALPTR(CUtlVector<CPhysCollideVirtualMesh *>) g_pMeshFrameLocks;
// This is the surfacemanager class for IVP that implements the required functions by layering CPhysCollideVirtualMesh
class IVP_SurfaceManager_VirtualMesh : public IVP_SurfaceManager
@@ -148,7 +148,7 @@ void CMeshInstance::Init( const virtualmeshlist_t &list )
m_memSize = memSize;
m_hullCount = 0;
m_pMemory = (char *)ivp_malloc_aligned( memSize, 16 );
Assert( (int(m_pMemory) & 15) == 0 ); // make sure it is aligned
Assert( (intp(m_pMemory) & 15) == 0 ); // make sure it is aligned
IVP_Compact_Poly_Point *pPoints = (IVP_Compact_Poly_Point *)&m_pMemory[ledgeSize];
triangleledge_t *pLedges = (triangleledge_t *) m_pMemory;
memset( m_pMemory, 0, memSize );
@@ -185,8 +185,7 @@ void CMeshInstance::Init( const virtualmeshlist_t &list )
}
}
// UNDONE: Tune / expose this constant 512K budget for terrain collision
const int g_MeshSize = (2048 * 1024);
const int g_MeshSize = (2048 * 1024 * 4); // nillerusr: 2 MiB should be enough, old value causes problems in ep2
static CDataManager<CMeshInstance, virtualmeshlist_t, CMeshInstance *, CThreadFastMutex> g_MeshManager( g_MeshSize );
static int numIndices = 0, numTriangles = 0, numBaseTriangles = 0, numSplits = 0;
//-----------------------------------------------------------------------------
@@ -443,12 +442,15 @@ CMeshInstance *CPhysCollideVirtualMesh::BuildLedges()
{
list.pHull = (byte *)m_pHull;
}
if ( list.triangleCount )
{
m_hMemory = g_MeshManager.CreateResource( list );
m_ledgeCount = list.triangleCount;
CMeshInstance *pMesh = g_MeshManager.LockResource( m_hMemory );
Assert( g_MeshManager.AvailableSize() != 0 );
return pMesh;
}
return NULL;
@@ -532,7 +534,6 @@ CPhysCollide *CreateVirtualMesh( const virtualmeshparams_t &params )
void DestroyVirtualMesh( CPhysCollide *pMesh )
{
FlushFrameLocks();
delete pMesh;
}
@@ -547,6 +548,7 @@ IVP_SurfaceManager_VirtualMesh::IVP_SurfaceManager_VirtualMesh( CPhysCollideVirt
IVP_SurfaceManager_VirtualMesh::~IVP_SurfaceManager_VirtualMesh()
{
FlushFrameLocks();
}
void IVP_SurfaceManager_VirtualMesh::add_reference_to_ledge(const IVP_Compact_Ledge *ledge)
+2 -14
View File
@@ -174,13 +174,7 @@ void CVPhysicsParse::ParseSolid( solid_t *pSolid, IVPhysicsKeyHandler *unknownKe
}
else if ( !Q_stricmp( key, "inertia" ) )
{
float inertia = atof(value);
if( inertia > 1e14f )
pSolid->params.inertia = 1e14f;
else if( inertia <= 0 )
pSolid->params.inertia = 1.f;
else
pSolid->params.inertia = inertia;
pSolid->params.inertia = atof(value);
}
else if ( !Q_stricmp( key, "damping" ) )
{
@@ -474,13 +468,7 @@ void CVPhysicsParse::ParseVehicleWheel( vehicle_wheelparams_t &wheel )
}
else if ( !Q_stricmp( key, "inertia" ) )
{
float inertia = atof(value);
if( inertia > 1e14f )
wheel.inertia = 1e14f;
else if( inertia <= 0 )
wheel.inertia = 1.f;
else
wheel.inertia = inertia;
wheel.inertia = atof(value);
}
else if ( !Q_stricmp( key, "damping" ) )
{
+10 -8
View File
@@ -57,7 +57,7 @@ bool CPhysicsEnvironment::Save( const physsaveparams_t &params )
if ( type >= 0 && type < PIID_NUM_TYPES )
{
params.pSave->WriteInt( (int *)&params.pObject );
params.pSave->WriteData( (char *)&params.pObject, sizeof(void*) );
return (*saveFuncs[type])( params, params.pObject );
}
return false;
@@ -105,7 +105,7 @@ bool CPhysicsEnvironment::Restore( const physrestoreparams_t &params )
if ( type >= 0 && type < PIID_NUM_TYPES )
{
void *pOldObject;
params.pRestore->ReadInt( (int *)&pOldObject );
params.pRestore->ReadData( (char *)&pOldObject, sizeof(void*), 0 );
if ( (*restoreFuncs[type])( params, params.ppObject ) )
{
AddPtrAssociation( pOldObject, *params.ppObject );
@@ -131,12 +131,12 @@ void CPhysicsEnvironment::PostRestore()
void CVPhysPtrSaveRestoreOps::Save( const SaveRestoreFieldInfo_t &fieldInfo, ISave *pSave )
{
int *pField = (int *)fieldInfo.pField;
char *pField = (char *)fieldInfo.pField;
int nObjects = fieldInfo.pTypeDesc->fieldSize;
for ( int i = 0; i < nObjects; i++ )
{
pSave->WriteInt( pField );
++pField;
pSave->WriteData( (char*)pField, sizeof(void*) );
pField += sizeof(void*);
}
}
@@ -153,9 +153,10 @@ void CVPhysPtrSaveRestoreOps::Restore( const SaveRestoreFieldInfo_t &fieldInfo,
{
void **ppField = (void **)fieldInfo.pField;
int nObjects = fieldInfo.pTypeDesc->fieldSize;
for ( int i = 0; i < nObjects; i++ )
{
pRestore->ReadInt( (int *)ppField );
pRestore->ReadData( (char *)ppField, sizeof(void*), 0 );
int iNewVal = s_VPhysPtrMap.Find( *ppField );
if ( iNewVal != s_VPhysPtrMap.InvalidIndex() )
@@ -188,10 +189,11 @@ void CVPhysPtrUtlVectorSaveRestoreOps::Save( const SaveRestoreFieldInfo_t &field
VPhysPtrVector *pUtlVector = (VPhysPtrVector*)fieldInfo.pField;
int nObjects = pUtlVector->Count();
pSave->WriteInt( &nObjects );
for ( int i = 0; i < nObjects; i++ )
{
pSave->WriteInt( &pUtlVector->Element(i) );
pSave->WriteData( (char*)&pUtlVector->Element(i), sizeof(void*) );
}
}
@@ -207,7 +209,7 @@ void CVPhysPtrUtlVectorSaveRestoreOps::Restore( const SaveRestoreFieldInfo_t &fi
for ( int i = 0; i < nObjects; i++ )
{
void **ppElem = (void**)(&pUtlVector->Element(i));
pRestore->ReadInt( (int*)ppElem );
pRestore->ReadData( (char *)ppElem, sizeof(void*), 0 );
int iNewVal = s_VPhysPtrMap.Find( *ppElem );
if ( iNewVal != s_VPhysPtrMap.InvalidIndex() )
+1 -1
View File
@@ -69,7 +69,7 @@ public:
void Restore( const SaveRestoreFieldInfo_t &fieldInfo, IRestore *pRestore );
private:
typedef CUtlVector<int> VPhysPtrVector;
typedef CUtlVector<intp> VPhysPtrVector;
};
extern CVPhysPtrUtlVectorSaveRestoreOps g_VPhysPtrUtlVectorSaveRestoreOps;