From 3a93bb992fade04a463d6cd91bc014b110e217a5 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 7 Mar 2009 00:27:56 +0000 Subject: * Added some limits to the maximum force applied per second by llMoveToTarget. Currently, it's 350 times the mass in newtons applied per second, maximum. --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 19 ++++++++++++++++++- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 10 +++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index f164048..3291b79 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -1500,6 +1500,8 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_usePID) { + //if (!d.BodyIsEnabled(Body)) + //d.BodySetForce(Body, 0f, 0f, 0f); // If we're using the PID controller, then we have no gravity fz = (-1 * _parent_scene.gravityz) * m_mass; @@ -1510,7 +1512,8 @@ namespace OpenSim.Region.Physics.OdePlugin if ((m_PIDTau < 1)) { - PID_G = PID_G / m_PIDTau; + //PID_G = PID_G / m_PIDTau; + m_PIDTau = 1; } if ((PID_G - m_PIDTau) <= 0) @@ -1668,6 +1671,20 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodySetForce(Body, 0, 0, 0); enableBodySoft(); } + + // 35x10 = 350n times the mass per second applied maximum. + float nmax = 35f * m_mass; + float nmin = -35f * m_mass; + + + if (fx > nmax) + fx = nmax; + if (fx < nmin) + fx = nmin; + if (fy > nmax) + fy = nmax; + if (fy < nmin) + fy = nmin; d.BodyAddForce(Body, fx, fy, fz); } } diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index b94f374..0a6faa8 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -482,6 +482,12 @@ namespace OpenSim.Region.Physics.OdePlugin d.WorldSetGravity(world, gravityx, gravityy, gravityz); d.WorldSetContactSurfaceLayer(world, contactsurfacelayer); + d.WorldSetLinearDamping(world, 256f); + d.WorldSetAngularDamping(world, 256f); + d.WorldSetAngularDampingThreshold(world, 256f); + d.WorldSetLinearDampingThreshold(world, 256f); + d.WorldSetMaxAngularSpeed(world, 256f); + // Set how many steps we go without running collision testing // This is in addition to the step size. // Essentially Steps * m_physicsiterations @@ -2296,9 +2302,11 @@ namespace OpenSim.Region.Physics.OdePlugin // Figure out the Frames Per Second we're going at. //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size - step_time = 0.09375f; + fps = (step_time/ODE_STEPSIZE) * 1000; + step_time = 0.09375f; + while (step_time > 0.0f) { //lock (ode) -- cgit v1.1