From 3f2291611fcca7859f774976038e0c15168eda57 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 4 Aug 2016 16:24:19 +0100 Subject: apply external forces and torque to vehicles also, as other engines do --- OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs') diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs index c3b4dd8..d8a2272 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs @@ -935,8 +935,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde float roll; float pitch; - - float ftmp = m_invtimestep / m_verticalAttractionTimescale / m_verticalAttractionTimescale; float ftmp2; @@ -957,7 +955,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde effroll = 1 - effroll; effroll *= roll; - torque.X += effroll * ftmp; if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) == 0) @@ -1074,10 +1071,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde torque.Z -= curLocalAngVel.Z * m_amdampZ; } + force *= dmass.mass; + + force += rootPrim.m_force; + force += rootPrim.m_forceacc; + rootPrim.m_forceacc = Vector3.Zero; if (force.X != 0 || force.Y != 0 || force.Z != 0) { - force *= dmass.mass; d.BodyAddForce(Body, force.X, force.Y, force.Z); } @@ -1091,6 +1092,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde d.MultiplyM3V3(out dvtmp, ref dmass.I, ref dtorque); d.BodyAddRelTorque(Body, dvtmp.X, dvtmp.Y, dvtmp.Z); // add torque in object frame } + + torque = rootPrim.m_torque; + torque += rootPrim.m_angularForceacc; + rootPrim.m_angularForceacc = Vector3.Zero; + if (torque.X != 0 || torque.Y != 0 || torque.Z != 0) + d.BodyAddTorque(Body,torque.X, torque.Y, torque.Z); } } } -- cgit v1.1