diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 11e6ae71f9..bd980416a4 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -409,7 +409,7 @@ namespace OpenSim.Framework void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation); void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, - LLQuaternion rotation,LLVector3 velocity); + LLQuaternion rotation,LLVector3 velocity, LLVector3 rotationalvelocity); void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items); void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item); diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index bbe07d2bdb..14e1b39e45 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -1062,23 +1062,24 @@ namespace OpenSim.Region.ClientStack LLQuaternion rotation) { LLVector3 velocity = new LLVector3(0f,0f,0f); + LLVector3 rotationalvelocity = new LLVector3(0f,0f,0f); ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); terse.RegionData.RegionHandle = regionHandle; terse.RegionData.TimeDilation = timeDilation; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation, velocity); + terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation, velocity, rotationalvelocity); OutPacket(terse); } public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, - LLQuaternion rotation, LLVector3 velocity) + LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity) { ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); terse.RegionData.RegionHandle = regionHandle; terse.RegionData.TimeDilation = timeDilation; terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; - terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation, velocity); + terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation, velocity, rotationalvelocity); OutPacket(terse); } @@ -1184,7 +1185,7 @@ namespace OpenSim.Region.ClientStack /// protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, - LLQuaternion rotation, LLVector3 velocity) + LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity) { uint ID = localID; byte[] bytes = new byte[60]; @@ -1248,12 +1249,24 @@ namespace OpenSim.Region.ClientStack bytes[i++] = (byte) ((rw >> 8)%256); //rotation vel - bytes[i++] = (byte) (ac%256); - bytes[i++] = (byte) ((ac >> 8)%256); - bytes[i++] = (byte) (ac%256); - bytes[i++] = (byte) ((ac >> 8)%256); - bytes[i++] = (byte) (ac%256); - bytes[i++] = (byte) ((ac >> 8)%256); + ushort rvelx, rvely, rvelz; + Vector3 rvel = new Vector3(rotationalvelocity.X, rotationalvelocity.Y, rotationalvelocity.Z); + + rvel = rvel / 128.0f; + rvel.x += 1; + rvel.y += 1; + rvel.z += 1; + //vel + rvelx = (ushort)(32768 * (rvel.x)); + rvely = (ushort)(32768 * (rvel.y)); + rvelz = (ushort)(32768 * (rvel.z)); + + bytes[i++] = (byte)(rvelx % 256); + bytes[i++] = (byte)((rvelx >> 8) % 256); + bytes[i++] = (byte)(rvely % 256); + bytes[i++] = (byte)((rvely >> 8) % 256); + bytes[i++] = (byte)(rvelz % 256); + bytes[i++] = (byte)((rvelz >> 8) % 256); dat.Data = bytes; return dat; diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index d0cbcf622d..1c21159587 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -69,6 +69,7 @@ namespace OpenSim.Region.Environment.Scenes } protected LLVector3 m_velocity; + protected LLVector3 m_rotationalvelocity; /// /// @@ -106,7 +107,7 @@ namespace OpenSim.Region.Environment.Scenes m_velocity = new LLVector3(); Rotation = new Quaternion(); m_name = "(basic entity)"; - + m_rotationalvelocity = new LLVector3(0, 0, 0); m_children = new List(); } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 4c6865a7ba..0e2b1860d7 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -231,6 +231,7 @@ namespace OpenSim.Region.Environment.Scenes } protected LLVector3 m_velocity; + protected LLVector3 m_rotationalvelocity; /// public LLVector3 Velocity @@ -253,6 +254,28 @@ namespace OpenSim.Region.Environment.Scenes } set { m_velocity = value; } } + public LLVector3 RotationalVelocity + { + get + { + //if (PhysActor.Velocity.x != 0 || PhysActor.Velocity.y != 0 + //|| PhysActor.Velocity.z != 0) + //{ + if (PhysActor != null) + { + if (PhysActor.IsPhysical) + { + m_rotationalvelocity.X = PhysActor.RotationalVelocity.X; + m_rotationalvelocity.Y = PhysActor.RotationalVelocity.Y; + m_rotationalvelocity.Z = PhysActor.RotationalVelocity.Z; + } + } + + return m_rotationalvelocity; + } + set { m_rotationalvelocity = value; } + } + protected LLVector3 m_angularVelocity; @@ -384,6 +407,7 @@ namespace OpenSim.Region.Environment.Scenes OffsetPosition = offsetPosition; RotationOffset = rotationOffset; Velocity = new LLVector3(0, 0, 0); + m_rotationalvelocity = new LLVector3(0, 0, 0); AngularVelocity = new LLVector3(0, 0, 0); Acceleration = new LLVector3(0, 0, 0); @@ -1020,7 +1044,7 @@ namespace OpenSim.Region.Environment.Scenes } else { - remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity); + remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, RotationalVelocity); } } @@ -1033,8 +1057,8 @@ namespace OpenSim.Region.Environment.Scenes } else { - remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity); - //System.Console.WriteLine("Vel:" + Velocity); + remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, RotationalVelocity); + //System.Console.WriteLine("RVel:" + RotationalVelocity); } } diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 1a7901e88b..75b3f04c97 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -282,7 +282,7 @@ namespace SimpleApp { } public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, - LLVector3 position, LLQuaternion rotation,LLVector3 velocity) + LLVector3 position, LLQuaternion rotation,LLVector3 velocity, LLVector3 rotationalvelocity) { } diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 46037df466..d5cb99f6f0 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -181,6 +181,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin private PhysicsVector _position; private PhysicsVector _velocity; private PhysicsVector _acceleration; + private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; private bool flying; private bool iscolliding; @@ -190,7 +191,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin _position = new PhysicsVector(); _acceleration = new PhysicsVector(); } - + public override PhysicsVector RotationalVelocity + { + get { return m_rotationalVelocity; } + set { m_rotationalVelocity = value; } + } public override bool IsPhysical { get { return false; } diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index efc99e48f4..cdccc70f87 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -643,6 +643,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin protected PhysicsVector _size; protected PhysicsVector _acceleration; protected AxiomQuaternion _orientation; + protected PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; protected RigidBody rigidBody; private Boolean iscolliding = false; @@ -662,6 +663,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin } } } + public override PhysicsVector RotationalVelocity + { + get { return m_rotationalVelocity; } + set { m_rotationalVelocity = value; } + } public override PhysicsVector Velocity { get { return _velocity; } diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index b151e16b04..2d8eb9afe9 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -36,6 +36,8 @@ namespace OpenSim.Region.Physics.Manager public delegate void OrientationUpdate(Quaternion orientation); + + public abstract class PhysicsActor { #pragma warning disable 67 @@ -69,6 +71,7 @@ namespace OpenSim.Region.Physics.Manager public abstract bool Flying { get; set; } public abstract bool IsColliding { get; set; } + public abstract PhysicsVector RotationalVelocity { get; set; } public abstract bool Kinematic { get; set; } @@ -144,7 +147,11 @@ namespace OpenSim.Region.Physics.Manager { return; } - + public override PhysicsVector RotationalVelocity + { + get { return PhysicsVector.Zero; } + set { return; } + } public override void SetMomentum(PhysicsVector momentum) { return; diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 8b8aac6d59..512b96e206 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -617,6 +617,7 @@ namespace OpenSim.Region.Physics.OdePlugin private PhysicsVector _velocity; private PhysicsVector _target_velocity; private PhysicsVector _acceleration; + private PhysicsVector m_rotationalVelocity; private static float PID_D = 4000.0f; private static float PID_P = 7000.0f; private static float POSTURE_SERVO = 10000.0f; @@ -682,7 +683,11 @@ namespace OpenSim.Region.Physics.OdePlugin } } } - + public override PhysicsVector RotationalVelocity + { + get { return m_rotationalVelocity; } + set { m_rotationalVelocity = value; } + } public override PhysicsVector Size { get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); } @@ -858,6 +863,7 @@ namespace OpenSim.Region.Physics.OdePlugin private PhysicsVector _velocity; private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f,0.0f,0.0f); private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); + private PhysicsVector m_rotationalVelocity; private PhysicsVector _size; private PhysicsVector _acceleration; public Quaternion _orientation; @@ -887,6 +893,7 @@ namespace OpenSim.Region.Physics.OdePlugin _position = pos; _size = size; _acceleration = new PhysicsVector(); + m_rotationalVelocity = PhysicsVector.Zero; _orientation = rotation; _mesh = mesh; _pbs = pbs; @@ -1224,7 +1231,12 @@ namespace OpenSim.Region.Physics.OdePlugin } public void Move(float timestep) { - + + } + public override PhysicsVector RotationalVelocity + { + get{ return m_rotationalVelocity;} + set { m_rotationalVelocity = value; } } public void UpdatePositionAndVelocity() { @@ -1234,6 +1246,8 @@ namespace OpenSim.Region.Physics.OdePlugin d.Vector3 vec = d.BodyGetPosition(Body); d.Quaternion ori = d.BodyGetQuaternion(Body); d.Vector3 vel = d.BodyGetLinearVel(Body); + d.Vector3 rotvel = d.BodyGetAngularVel(Body); + PhysicsVector l_position = new PhysicsVector(); // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) if (vec.X < 0.0f) vec.X = 0.0f; @@ -1256,7 +1270,7 @@ namespace OpenSim.Region.Physics.OdePlugin try { disableBody(); - + } catch (System.Exception e) { @@ -1264,13 +1278,16 @@ namespace OpenSim.Region.Physics.OdePlugin { d.BodyDestroy(Body); Body = (IntPtr)0; - + } - } + } IsPhysical = false; _velocity.X = 0; _velocity.Y = 0; _velocity.Z = 0; + m_rotationalVelocity.X = 0; + m_rotationalVelocity.Y = 0; + m_rotationalVelocity.Z = 0; _zeroFlag = true; } @@ -1293,11 +1310,13 @@ namespace OpenSim.Region.Physics.OdePlugin _velocity.X = 0.0f; _velocity.Y = 0.0f; _velocity.Z = 0.0f; - _orientation.w = 0f; - _orientation.x = 0f; - _orientation.y = 0f; - _orientation.z = 0f; - + //_orientation.w = 0f; + //_orientation.x = 0f; + //_orientation.y = 0f; + //_orientation.z = 0f; + m_rotationalVelocity.X = 0; + m_rotationalVelocity.Y = 0; + m_rotationalVelocity.Z = 0; } else @@ -1310,6 +1329,10 @@ namespace OpenSim.Region.Physics.OdePlugin _velocity.Y = vel.Y; _velocity.Z = vel.Z; + m_rotationalVelocity.X = rotvel.X; + m_rotationalVelocity.Y = rotvel.Y; + m_rotationalVelocity.Z = rotvel.Z; + //System.Console.WriteLine("ODE: " + m_rotationalVelocity.ToString()); _orientation.w = ori.W; _orientation.x = ori.X; _orientation.y = ori.Y; @@ -1317,6 +1340,17 @@ namespace OpenSim.Region.Physics.OdePlugin } } + else + { + // Not a body.. so Make sure the client isn't interpolating + _velocity.X = 0; + _velocity.Y = 0; + _velocity.Z = 0; + m_rotationalVelocity.X = 0; + m_rotationalVelocity.Y = 0; + m_rotationalVelocity.Z = 0; + _zeroFlag = true; + } } public override void SetMomentum(PhysicsVector momentum) diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index 5483703387..d282e9da6c 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -184,6 +184,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin { private PhysicsVector _position; private PhysicsVector _velocity; + private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; private PhysicsVector _acceleration; private NxCharacter _character; private bool flying; @@ -214,7 +215,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin get { return iscolliding; } set { iscolliding = value; } } - + public override PhysicsVector RotationalVelocity + { + get { return m_rotationalVelocity; } + set { m_rotationalVelocity = value; } + } public override PhysicsVector Position { get { return _position; } @@ -314,6 +319,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin private PhysicsVector _position; private PhysicsVector _velocity; private PhysicsVector _acceleration; + private PhysicsVector m_rotationalVelocity; private NxActor _prim; public PhysXPrim(NxActor prim) @@ -329,7 +335,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin get { return false; } set { return; } } - + public override PhysicsVector RotationalVelocity + { + get { return m_rotationalVelocity; } + set { m_rotationalVelocity = value; } + } public override bool Flying { get { return false; //no flying prims for you