From 79b2b14d2ff78c3cef9d4e088f3f971b76ad196d Mon Sep 17 00:00:00 2001 From: Dmitry Tsarevich Date: Tue, 10 Oct 2023 21:00:59 +0300 Subject: [PATCH] Cache wheel physical object --- vphysics_jolt/vjolt_controller_vehicle.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vphysics_jolt/vjolt_controller_vehicle.cpp b/vphysics_jolt/vjolt_controller_vehicle.cpp index 6c2cd5b..45cc1a0 100644 --- a/vphysics_jolt/vjolt_controller_vehicle.cpp +++ b/vphysics_jolt/vjolt_controller_vehicle.cpp @@ -320,11 +320,12 @@ void JoltPhysicsVehicleController::OnPostSimulate( float flDeltaTime ) // what to do about that?.. // We just want the local rotation, and this seems to work (?) QAngle newQuat = JoltToSource::Angle( wheelTransform.GetQuaternion() ); - m_Wheels[ w ].pObject->EnableCollisions( false ); + JoltPhysicsObject* object = m_Wheels[w].pObject; + object->EnableCollisions( false ); // Set dummy wheel object pos/angles so the game code can update pose positions for wheels. - m_Wheels[ w ].pObject->SetPosition( newPos, newQuat, true ); + object->SetPosition( newPos, newQuat, true ); // Wake it up so that the game bothers to do pose positions. - m_Wheels[ w ].pObject->Wake(); + object->Wake(); if ( m_VehicleConstraint->GetWheels()[w]->HasContact() ) m_OperatingParams.wheelsInContact++;