diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs index 288cab5bed..076da7816c 100644 --- a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs @@ -55,4 +55,4 @@ using System.Runtime.InteropServices; // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): -[assembly : AssemblyVersion("0.8.0.*")] +[assembly : AssemblyVersion("0.8.2.*")] diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 86735de282..05eaf2aa68 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -167,6 +167,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// /// + /// /// /// /// @@ -178,7 +179,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// public OdeCharacter( - String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, + String avName, OdeScene parent_scene, Vector3 pos, Vector3 vel, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float walk_divisor, float rundivisor) { @@ -210,6 +211,9 @@ namespace OpenSim.Region.Physics.OdePlugin m_log.WarnFormat("[ODE CHARACTER]: Got NaN Position on Character Create for {0}", avName); } + _velocity = vel; + m_taintTargetVelocity = vel; + _parent_scene = parent_scene; PID_D = pid_d; @@ -500,8 +504,10 @@ namespace OpenSim.Region.Physics.OdePlugin { m_pidControllerActive = true; - m_tainted_CAPSULE_LENGTH = (size.Z) - CAPSULE_RADIUS * 2.0f; -// m_log.Info("[ODE CHARACTER]: " + CAPSULE_LENGTH); + m_tainted_CAPSULE_LENGTH = size.Z - CAPSULE_RADIUS * 2.0f; + + // m_log.InfoFormat("[ODE CHARACTER]: Size = {0}, Capsule Length = {1} (Capsule Radius = {2})", + // size, m_tainted_CAPSULE_LENGTH, CAPSULE_RADIUS); } else { @@ -890,42 +896,30 @@ namespace OpenSim.Region.Physics.OdePlugin // vec, _target_velocity, movementdivisor, vel); } - if (m_iscolliding && !flying && _target_velocity.Z > 0.0f) - { - // We're colliding with something and we're not flying but we're moving - // This means we're walking or running. - d.Vector3 pos = d.BodyGetPosition(Body); - vec.Z = (_target_velocity.Z - vel.Z)*PID_D + (_zeroPosition.Z - pos.Z)*PID_P; - if (_target_velocity.X > 0) - { - vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; - } - if (_target_velocity.Y > 0) - { - vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; - } - } - else if (!m_iscolliding && !flying) - { - // we're not colliding and we're not flying so that means we're falling! - // m_iscolliding includes collisions with the ground. - - // d.Vector3 pos = d.BodyGetPosition(Body); - if (_target_velocity.X > 0) - { - vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; - } - if (_target_velocity.Y > 0) - { - vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; - } - } - if (flying) { // This also acts as anti-gravity so that we hover when flying rather than fall. vec.Z = (_target_velocity.Z - vel.Z) * (PID_D); } + else + { + if (m_iscolliding && _target_velocity.Z > 0.0f) + { + // We're colliding with something and we're not flying but we're moving + // This means we're walking or running. + d.Vector3 pos = d.BodyGetPosition(Body); + vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; + vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; + vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; + } + else if (!m_iscolliding) + { + // we're not colliding and we're not flying so that means we're falling! + // m_iscolliding includes collisions with the ground. + vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; + vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; + } + } } if (flying) @@ -1255,7 +1249,11 @@ namespace OpenSim.Region.Physics.OdePlugin } public override Vector3 PIDTarget { set { return; } } - public override bool PIDActive { set { return; } } + public override bool PIDActive + { + get { return false; } + set { return; } + } public override float PIDTau { set { return; } } public override float PIDHoverHeight { set { return; } } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index b4b7e7f163..f934b8a32a 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -114,7 +114,6 @@ namespace OpenSim.Region.Physics.OdePlugin private float m_PIDTau; private float PID_D = 35f; private float PID_G = 25f; - private bool m_usePID; // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), // and are for non-VEHICLES only. @@ -351,11 +350,10 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_assetFailed) { d.GeomSetCategoryBits(prim_geom, 0); - d.GeomSetCollideBits(prim_geom, BadAssetColideBits()); + d.GeomSetCollideBits(prim_geom, BadMeshAssetCollideBits); } else { - d.GeomSetCategoryBits(prim_geom, (int)m_collisionCategories); d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); } @@ -425,7 +423,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_assetFailed) { d.GeomSetCategoryBits(prim_geom, 0); - d.GeomSetCollideBits(prim_geom, BadAssetColideBits()); + d.GeomSetCollideBits(prim_geom, BadMeshAssetCollideBits); } else { @@ -787,6 +785,14 @@ namespace OpenSim.Region.Physics.OdePlugin } } + private void setAngularVelocity(float x, float y, float z) + { + if (Body != (IntPtr)0) + { + d.BodySetAngularVel(Body, x, y, z); + } + } + /// /// Stop a prim from being subject to physics. /// @@ -858,11 +864,6 @@ namespace OpenSim.Region.Physics.OdePlugin private static Dictionary m_MeshToTriMeshMap = new Dictionary(); - public int BadAssetColideBits() - { - return (m_isphysical ? (int)CollisionCategories.Land : 0); - } - private void setMesh(OdeScene parent_scene, IMesh mesh) { // m_log.DebugFormat("[ODE PRIM]: Setting mesh on {0} to {1}", Name, mesh); @@ -1144,7 +1145,7 @@ Console.WriteLine("ZProcessTaints for " + Name); if (prm.m_assetFailed) { d.GeomSetCategoryBits(prm.prim_geom, 0); - d.GeomSetCollideBits(prm.prim_geom, prm.BadAssetColideBits()); + d.GeomSetCollideBits(prm.prim_geom, prm.BadMeshAssetCollideBits); } else { @@ -1198,7 +1199,7 @@ Console.WriteLine("ZProcessTaints for " + Name); if (m_assetFailed) { d.GeomSetCategoryBits(prim_geom, 0); - d.GeomSetCollideBits(prim_geom, BadAssetColideBits()); + d.GeomSetCollideBits(prim_geom, BadMeshAssetCollideBits); } else { @@ -1400,7 +1401,7 @@ Console.WriteLine("ZProcessTaints for " + Name); if (m_assetFailed) { d.GeomSetCategoryBits(prim_geom, 0); - d.GeomSetCollideBits(prim_geom, BadAssetColideBits()); + d.GeomSetCollideBits(prim_geom, BadMeshAssetCollideBits); } else { @@ -1729,7 +1730,7 @@ Console.WriteLine(" JointCreateFixed"); // gravityz multiplier = 1 - m_buoyancy fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass; - if (m_usePID) + if (PIDActive) { //Console.WriteLine("PID " + Name); // KF - this is for object move? eg. llSetPos() ? @@ -1798,10 +1799,10 @@ Console.WriteLine(" JointCreateFixed"); fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass); } - } // end if (m_usePID) + } // end if (PIDActive) // Hover PID Controller needs to be mutually exlusive to MoveTo PID controller - if (m_useHoverPID && !m_usePID) + if (m_useHoverPID && !PIDActive) { //Console.WriteLine("Hover " + Name); @@ -2144,7 +2145,7 @@ Console.WriteLine(" JointCreateFixed"); } if (m_assetFailed) - d.GeomSetCollideBits(prim_geom, BadAssetColideBits()); + d.GeomSetCollideBits(prim_geom, BadMeshAssetCollideBits); else d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); @@ -2652,6 +2653,7 @@ Console.WriteLine(" JointCreateFixed"); if (value.IsFinite()) { m_rotationalVelocity = value; + setAngularVelocity(value.X, value.Y, value.Z); } else { @@ -2872,7 +2874,7 @@ Console.WriteLine(" JointCreateFixed"); // it does make sense to do this for tiny little instabilities with physical prim, however 0.5m/frame is fairly large. // reducing this to 0.02m/frame seems to help the angular rubberbanding quite a bit, however, to make sure it doesn't affect elevators and vehicles // adding these logical exclusion situations to maintain this where I think it was intended to be. - if (m_throttleUpdates || m_usePID || (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) || (Amotor != IntPtr.Zero)) + if (m_throttleUpdates || PIDActive || (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) || (Amotor != IntPtr.Zero)) { m_minvelocity = 0.5f; } @@ -2953,9 +2955,9 @@ Console.WriteLine(" JointCreateFixed"); m_log.WarnFormat("[PHYSICS]: Got NaN PIDTarget from Scene on Object {0}", Name); } } - public override bool PIDActive { set { m_usePID = value; } } + public override bool PIDActive { get; set; } public override float PIDTau { set { m_PIDTau = value; } } - + public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } } public override bool PIDHoverActive { set { m_useHoverPID = value; } } public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } } @@ -3350,7 +3352,7 @@ Console.WriteLine(" JointCreateFixed"); RequestAssetDelegate assetProvider = _parent_scene.RequestAssetMethod; if (assetProvider != null) assetProvider(_pbs.SculptTexture, MeshAssetReceived); - }); + }, null, "ODEPrim.CheckMeshAsset"); } } @@ -3382,4 +3384,4 @@ Console.WriteLine(" JointCreateFixed"); } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 6d7f079e88..59535574d1 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -1969,16 +1969,11 @@ namespace OpenSim.Region.Physics.OdePlugin #region Add/Remove Entities - public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) - { - Vector3 pos; - pos.X = position.X; - pos.Y = position.Y; - pos.Z = position.Z; - + public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying) + { OdeCharacter newAv = new OdeCharacter( - avName, this, pos, size, avPIDD, avPIDP, + avName, this, position, velocity, size, avPIDD, avPIDP, avCapRadius, avStandupTensor, avDensity, avMovementDivisorWalk, avMovementDivisorRun);