fix compiling with c++17 on linux

This commit is contained in:
arthurdead 2022-08-29 00:17:26 -03:00
parent 11adbb57bd
commit 8bd9bc8b6d
5 changed files with 27 additions and 2 deletions

View File

@ -14,6 +14,8 @@ $Configuration
// CPU feature macros, we may want to tune these before release.
$PreprocessorDefinitions "$BASE;JPH_USE_SSE4_1;JPH_USE_SSE4_2;JPH_USE_LZCNT;JPH_USE_TZCNT;JPH_USE_F16C;JPH_USE_FMADD"
$GCC_ExtraCompilerFlags "$BASE -msse4.1 -msse4.2 -mlzcnt -mf16c -mfma"
// We DO want to comment this line out for release, AVX 1 & 2 adoption isn't reliable enough yet
// $EnableEnhancedInstructionSet "Advanced Vector Extensions 2 (/arch:AVX2)" [$DEVELOPMENT_ONLY]

View File

@ -41,7 +41,7 @@
#include "tier1/tier1.h"
#include "tier1/strtools.h"
#include "tier1/interface.h"
#include "tier1/keyvalues.h"
#include "tier1/KeyValues.h"
#include "tier1/UtlStringMap.h"
#include "tier1/utlbuffer.h"

View File

@ -103,7 +103,14 @@ void JoltPhysicsFluidController::OnJoltPhysicsObjectDestroyed( JoltPhysicsObject
if ( pObject == m_pFluidObject )
m_pFluidObject = nullptr;
#if __cplusplus >= 202002L
std::erase_if( m_ObjectsInShape, [pObject]( JoltPhysicsObject *pCachedObject ) { return pObject == pCachedObject; } );
#else
for ( auto it( m_ObjectsInShape.begin() ); it != m_ObjectsInShape.end(); ++it ) {
if ( *it == pObject )
it = m_ObjectsInShape.erase(it);
}
#endif
}
//-------------------------------------------------------------------------------------------------

View File

@ -5,6 +5,13 @@
struct JoltPhysicsContactPair
{
#if __cplusplus < 202002L
JoltPhysicsContactPair( JoltPhysicsObject *object1, JoltPhysicsObject *object2 )
: pObject1(object1), pObject2(object2)
{
}
#endif
JoltPhysicsObject *pObject1 = nullptr;
JoltPhysicsObject *pObject2 = nullptr;
};

View File

@ -54,7 +54,12 @@ void JoltPhysicsObjectPairHash::RemoveObjectPair( void *pObject0, void *pObject1
bool JoltPhysicsObjectPairHash::IsObjectPairInHash( void *pObject0, void *pObject1 )
{
auto pair = CreateSortedPair( pObject0, pObject1 );
return m_PairHashes[ GetHashArrayIndex( PointerHasher{}( pair ) ) ].contains( pair );
auto &pairHashes = m_PairHashes[ GetHashArrayIndex( PointerHasher{}( pair ) ) ];
#if __cplusplus >= 202002L
return pairHashes.contains( pair );
#else
return pairHashes.find( pair ) != pairHashes.cend();
#endif
}
void JoltPhysicsObjectPairHash::RemoveAllPairsForObject( void *pObject0 )
@ -71,7 +76,11 @@ void JoltPhysicsObjectPairHash::RemoveAllPairsForObject( void *pObject0 )
bool JoltPhysicsObjectPairHash::IsObjectInHash( void *pObject0 )
{
#if __cplusplus >= 202002L
return m_Objects.contains( pObject0 );
#else
return m_Objects.find( pObject0 ) != m_Objects.cend();
#endif
}
//-------------------------------------------------------------------------------------------------