From ca41ec9eb4616c0cb96ed48d591e473d95af2701 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 10 Jul 2012 05:11:06 +0100 Subject: let rotationVelocity or AngularVelocity be setted on prims. Limited to 12rad/s --- OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 65 +++++++++++++++++-------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index 3d8e680..14e4272 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -583,8 +583,6 @@ namespace OpenSim.Region.Physics.OdePlugin if (value.IsFinite()) { AddChange(changes.Velocity, value); -// _velocity = value; - } else { @@ -676,9 +674,7 @@ namespace OpenSim.Region.Physics.OdePlugin { if (value.IsFinite()) { - m_rotationalVelocity = value; - if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) - d.BodyEnable(Body); + AddChange(changes.AngVelocity, value); } else { @@ -687,7 +683,6 @@ namespace OpenSim.Region.Physics.OdePlugin } } - public override float Buoyancy { get { return m_buoyancy; } @@ -1737,17 +1732,14 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodySetAutoDisableFlag(Body, true); d.BodySetAutoDisableSteps(Body, body_autodisable_frames); -// d.BodySetLinearDampingThreshold(Body, 0.01f); -// d.BodySetAngularDampingThreshold(Body, 0.001f); - d.BodySetDamping(Body, .002f, .002f); - - if (m_targetSpace != IntPtr.Zero) - { - _parent_scene.waitForSpaceUnlock(m_targetSpace); - if (d.SpaceQuery(m_targetSpace, prim_geom)) - d.SpaceRemove(m_targetSpace, prim_geom); - } + d.BodySetDamping(Body, .005f, .005f); + if (m_targetSpace != IntPtr.Zero) + { + _parent_scene.waitForSpaceUnlock(m_targetSpace); + if (d.SpaceQuery(m_targetSpace, prim_geom)) + d.SpaceRemove(m_targetSpace, prim_geom); + } if (childrenPrim.Count == 0) { @@ -3296,6 +3288,13 @@ namespace OpenSim.Region.Physics.OdePlugin private void changevelocity(Vector3 newVel) { + float len = newVel.LengthSquared(); + if (len > 100000.0f) // limit to 100m/s + { + len = 100.0f / (float)Math.Sqrt(len); + newVel *= len; + } + if (!m_isSelected) { if (Body != IntPtr.Zero) @@ -3312,6 +3311,33 @@ namespace OpenSim.Region.Physics.OdePlugin _velocity = newVel; } + + private void changeangvelocity(Vector3 newAngVel) + { + float len = newAngVel.LengthSquared(); + if (len > 144.0f) // limit to 12rad/s + { + len = 12.0f / (float)Math.Sqrt(len); + newAngVel *= len; + } + + if (!m_isSelected) + { + if (Body != IntPtr.Zero) + { + if (m_disabled) + enableBodySoft(); + else if (!d.BodyIsEnabled(Body)) + d.BodyEnable(Body); + + + d.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z); + } + //resetCollisionAccounting(); + } + m_rotationalVelocity = newAngVel; + } + private void changeVolumedetetion(bool newVolDtc) { m_isVolumeDetect = newVolDtc; @@ -3948,9 +3974,10 @@ namespace OpenSim.Region.Physics.OdePlugin // case changes.Acceleration: // changeacceleration((Vector3)arg); // break; -// case changes.AngVelocity: -// changeangvelocity((Vector3)arg); -// break; + + case changes.AngVelocity: + changeangvelocity((Vector3)arg); + break; case changes.Force: changeForce((Vector3)arg); -- cgit v1.1