From 9e9dad1cde362de093d0d7e6c3e247ff00ceac96 Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Thu, 8 Nov 2007 00:10:40 +0000
Subject: * Added Rotational Velocity reporting for Client Interpolation to
Terse Updates * Added Angular Velocity reporting for smooth-ish rotations on
object collisions
---
OpenSim/Region/ClientStack/ClientView.API.cs | 33 +++++++++----
OpenSim/Region/Environment/Scenes/EntityBase.cs | 3 +-
.../Region/Environment/Scenes/SceneObjectPart.cs | 30 ++++++++++--
.../Region/Examples/SimpleApp/MyNpcCharacter.cs | 2 +-
.../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 7 ++-
.../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 6 +++
OpenSim/Region/Physics/Manager/PhysicsActor.cs | 9 +++-
OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 54 ++++++++++++++++++----
OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 14 +++++-
9 files changed, 129 insertions(+), 29 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs
index bbe07d2..14e1b39 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 d0cbcf6..1c21159 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 4c6865a..0e2b186 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 1a7901e..75b3f04 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 46037df..d5cb99f 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 efc99e4..cdccc70 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 b151e16..2d8eb9a 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 8b8aac6..512b96e 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 5483703..d282e9d 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
--
cgit v1.1