@@ -940,16 +940,21 @@ void CPhysHinge::Activate( void )
940
940
m_soundInfo.OnActivate (this );
941
941
if (m_pConstraint)
942
942
{
943
- if (m_soundInfo.m_iszTravelSoundFwd != NULL_STRING || m_soundInfo.m_iszTravelSoundBack != NULL_STRING || m_soundInfo.m_pTravelSound != nullptr )
943
+ if (
944
+ m_soundInfo.m_iszTravelSoundFwd != NULL_STRING ||
945
+ m_soundInfo.m_iszTravelSoundBack != NULL_STRING ||
946
+ m_soundInfo.m_pTravelSound != nullptr ||
947
+ m_pConstraint->GetAttachedObject () != nullptr
948
+ )
944
949
{
945
950
m_soundInfo.StartThinking (this ,
946
951
VelocitySampler::GetRelativeAngularVelocity (m_pConstraint->GetAttachedObject (), m_pConstraint->GetReferenceObject ()) ,
947
952
m_hinge.worldAxisDirection
948
953
);
949
- }
950
954
951
- SetThink (&CPhysHinge::SoundThink);
952
- SetNextThink ( gpGlobals->curtime + m_soundInfo.getThinkRate () );
955
+ SetThink (&CPhysHinge::SoundThink);
956
+ SetNextThink ( gpGlobals->curtime + m_soundInfo.getThinkRate () );
957
+ }
953
958
}
954
959
}
955
960
@@ -1277,13 +1282,24 @@ void CPhysSlideConstraint::Activate( void )
1277
1282
Vector axisDirection = m_axisEnd - GetAbsOrigin ();
1278
1283
VectorNormalize ( axisDirection );
1279
1284
UTIL_SnapDirectionToAxis ( axisDirection );
1280
- m_soundInfo.StartThinking (this ,
1281
- VelocitySampler::GetRelativeVelocity (m_pConstraint->GetAttachedObject (), m_pConstraint->GetReferenceObject ()),
1282
- axisDirection
1283
- );
1285
+ if ( m_pConstraint )
1286
+ {
1287
+ if (
1288
+ m_soundInfo.m_iszTravelSoundFwd != NULL_STRING ||
1289
+ m_soundInfo.m_iszTravelSoundBack != NULL_STRING ||
1290
+ m_soundInfo.m_pTravelSound != nullptr ||
1291
+ m_pConstraint->GetReferenceObject () != nullptr
1292
+ )
1293
+ {
1294
+ m_soundInfo.StartThinking (this ,
1295
+ VelocitySampler::GetRelativeVelocity (m_pConstraint->GetAttachedObject (), m_pConstraint->GetReferenceObject ()),
1296
+ axisDirection
1297
+ );
1284
1298
1285
- SetThink (&CPhysSlideConstraint::SoundThink);
1286
- SetNextThink (gpGlobals->curtime + m_soundInfo.getThinkRate ());
1299
+ SetThink (&CPhysSlideConstraint::SoundThink);
1300
+ SetNextThink (gpGlobals->curtime + m_soundInfo.getThinkRate ());
1301
+ }
1302
+ }
1287
1303
}
1288
1304
1289
1305
void CPhysSlideConstraint::Precache ()
0 commit comments