From ba8fd2952f9f337a6163a8d66f70825d364d9362 Mon Sep 17 00:00:00 2001 From: nillerusr Date: Sun, 31 Jul 2022 19:56:00 +0300 Subject: [PATCH] vphysics: fix velocity restore --- vphysics/physics_object.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/vphysics/physics_object.cpp b/vphysics/physics_object.cpp index 69f78f6a..4d1f3b94 100644 --- a/vphysics/physics_object.cpp +++ b/vphysics/physics_object.cpp @@ -1042,7 +1042,7 @@ void CPhysicsObject::SetVelocityInstantaneous( const Vector *velocity, const Ang return; IVP_Core *core = m_pObject->get_core(); - Wake(); + WakeNow(); if ( velocity ) { @@ -1859,27 +1859,29 @@ void CPhysicsObject::InitFromTemplate( CPhysicsEnvironment *pEnvironment, void * EnableCollisions( true ); } - // will wake up the object + m_asleepSinceCreation = objectTemplate.asleepSinceCreation; + if ( objectTemplate.velocity.LengthSqr() != 0 || objectTemplate.angVelocity.LengthSqr() != 0 ) { + // will wake up the object SetVelocityInstantaneous( &objectTemplate.velocity, &objectTemplate.angVelocity ); - if ( objectTemplate.isAsleep ) - { - Sleep(); - } } - - m_asleepSinceCreation = objectTemplate.asleepSinceCreation; - if ( !objectTemplate.isAsleep ) + else if( !objectTemplate.isAsleep ) { Assert( !objectTemplate.isStatic ); - Wake(); + WakeNow(); + } + + if( objectTemplate.isAsleep ) + { + Sleep(); } if ( objectTemplate.hingeAxis ) { BecomeHinged( objectTemplate.hingeAxis-1 ); } + if ( objectTemplate.hasTouchedDynamic ) { SetTouchedDynamic();