* Added Rotational Velocity reporting for Client Interpolation to Terse Updates

* Added Angular Velocity reporting for smooth-ish rotations on object collisions
afrisby
Teravus Ovares 2007-11-08 00:10:40 +00:00
parent 08701ee7fc
commit 9e9dad1cde
10 changed files with 130 additions and 30 deletions

View File

@ -409,7 +409,7 @@ namespace OpenSim.Framework
void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position,
LLQuaternion rotation); LLQuaternion rotation);
void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, 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<InventoryItemBase> items); void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items);
void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item); void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item);

View File

@ -1062,23 +1062,24 @@ namespace OpenSim.Region.ClientStack
LLQuaternion rotation) LLQuaternion rotation)
{ {
LLVector3 velocity = new LLVector3(0f,0f,0f); LLVector3 velocity = new LLVector3(0f,0f,0f);
LLVector3 rotationalvelocity = new LLVector3(0f,0f,0f);
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = regionHandle; terse.RegionData.RegionHandle = regionHandle;
terse.RegionData.TimeDilation = timeDilation; terse.RegionData.TimeDilation = timeDilation;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 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); OutPacket(terse);
} }
public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, 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(); ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = regionHandle; terse.RegionData.RegionHandle = regionHandle;
terse.RegionData.TimeDilation = timeDilation; terse.RegionData.TimeDilation = timeDilation;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 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); OutPacket(terse);
} }
@ -1184,7 +1185,7 @@ namespace OpenSim.Region.ClientStack
/// <returns></returns> /// <returns></returns>
protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID,
LLVector3 position, LLVector3 position,
LLQuaternion rotation, LLVector3 velocity) LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity)
{ {
uint ID = localID; uint ID = localID;
byte[] bytes = new byte[60]; byte[] bytes = new byte[60];
@ -1248,12 +1249,24 @@ namespace OpenSim.Region.ClientStack
bytes[i++] = (byte) ((rw >> 8)%256); bytes[i++] = (byte) ((rw >> 8)%256);
//rotation vel //rotation vel
bytes[i++] = (byte) (ac%256); ushort rvelx, rvely, rvelz;
bytes[i++] = (byte) ((ac >> 8)%256); Vector3 rvel = new Vector3(rotationalvelocity.X, rotationalvelocity.Y, rotationalvelocity.Z);
bytes[i++] = (byte) (ac%256);
bytes[i++] = (byte) ((ac >> 8)%256); rvel = rvel / 128.0f;
bytes[i++] = (byte) (ac%256); rvel.x += 1;
bytes[i++] = (byte) ((ac >> 8)%256); 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; dat.Data = bytes;
return dat; return dat;

View File

@ -69,6 +69,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
protected LLVector3 m_velocity; protected LLVector3 m_velocity;
protected LLVector3 m_rotationalvelocity;
/// <summary> /// <summary>
/// ///
@ -106,7 +107,7 @@ namespace OpenSim.Region.Environment.Scenes
m_velocity = new LLVector3(); m_velocity = new LLVector3();
Rotation = new Quaternion(); Rotation = new Quaternion();
m_name = "(basic entity)"; m_name = "(basic entity)";
m_rotationalvelocity = new LLVector3(0, 0, 0);
m_children = new List<EntityBase>(); m_children = new List<EntityBase>();
} }

View File

@ -231,6 +231,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
protected LLVector3 m_velocity; protected LLVector3 m_velocity;
protected LLVector3 m_rotationalvelocity;
/// <summary></summary> /// <summary></summary>
public LLVector3 Velocity public LLVector3 Velocity
@ -253,6 +254,28 @@ namespace OpenSim.Region.Environment.Scenes
} }
set { m_velocity = value; } 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; protected LLVector3 m_angularVelocity;
@ -384,6 +407,7 @@ namespace OpenSim.Region.Environment.Scenes
OffsetPosition = offsetPosition; OffsetPosition = offsetPosition;
RotationOffset = rotationOffset; RotationOffset = rotationOffset;
Velocity = new LLVector3(0, 0, 0); Velocity = new LLVector3(0, 0, 0);
m_rotationalvelocity = new LLVector3(0, 0, 0);
AngularVelocity = new LLVector3(0, 0, 0); AngularVelocity = new LLVector3(0, 0, 0);
Acceleration = new LLVector3(0, 0, 0); Acceleration = new LLVector3(0, 0, 0);
@ -1020,7 +1044,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
else 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 else
{ {
remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity); remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot, Velocity, RotationalVelocity);
//System.Console.WriteLine("Vel:" + Velocity); //System.Console.WriteLine("RVel:" + RotationalVelocity);
} }
} }

View File

@ -282,7 +282,7 @@ namespace SimpleApp
{ {
} }
public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID,
LLVector3 position, LLQuaternion rotation,LLVector3 velocity) LLVector3 position, LLQuaternion rotation,LLVector3 velocity, LLVector3 rotationalvelocity)
{ {
} }

View File

@ -181,6 +181,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
private PhysicsVector _position; private PhysicsVector _position;
private PhysicsVector _velocity; private PhysicsVector _velocity;
private PhysicsVector _acceleration; private PhysicsVector _acceleration;
private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero;
private bool flying; private bool flying;
private bool iscolliding; private bool iscolliding;
@ -190,7 +191,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
_position = new PhysicsVector(); _position = new PhysicsVector();
_acceleration = new PhysicsVector(); _acceleration = new PhysicsVector();
} }
public override PhysicsVector RotationalVelocity
{
get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; }
}
public override bool IsPhysical public override bool IsPhysical
{ {
get { return false; } get { return false; }

View File

@ -643,6 +643,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
protected PhysicsVector _size; protected PhysicsVector _size;
protected PhysicsVector _acceleration; protected PhysicsVector _acceleration;
protected AxiomQuaternion _orientation; protected AxiomQuaternion _orientation;
protected PhysicsVector m_rotationalVelocity = PhysicsVector.Zero;
protected RigidBody rigidBody; protected RigidBody rigidBody;
private Boolean iscolliding = false; 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 public override PhysicsVector Velocity
{ {
get { return _velocity; } get { return _velocity; }

View File

@ -36,6 +36,8 @@ namespace OpenSim.Region.Physics.Manager
public delegate void OrientationUpdate(Quaternion orientation); public delegate void OrientationUpdate(Quaternion orientation);
public abstract class PhysicsActor public abstract class PhysicsActor
{ {
#pragma warning disable 67 #pragma warning disable 67
@ -69,6 +71,7 @@ namespace OpenSim.Region.Physics.Manager
public abstract bool Flying { get; set; } public abstract bool Flying { get; set; }
public abstract bool IsColliding { get; set; } public abstract bool IsColliding { get; set; }
public abstract PhysicsVector RotationalVelocity { get; set; }
public abstract bool Kinematic { get; set; } public abstract bool Kinematic { get; set; }
@ -144,7 +147,11 @@ namespace OpenSim.Region.Physics.Manager
{ {
return; return;
} }
public override PhysicsVector RotationalVelocity
{
get { return PhysicsVector.Zero; }
set { return; }
}
public override void SetMomentum(PhysicsVector momentum) public override void SetMomentum(PhysicsVector momentum)
{ {
return; return;

View File

@ -617,6 +617,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private PhysicsVector _velocity; private PhysicsVector _velocity;
private PhysicsVector _target_velocity; private PhysicsVector _target_velocity;
private PhysicsVector _acceleration; private PhysicsVector _acceleration;
private PhysicsVector m_rotationalVelocity;
private static float PID_D = 4000.0f; private static float PID_D = 4000.0f;
private static float PID_P = 7000.0f; private static float PID_P = 7000.0f;
private static float POSTURE_SERVO = 10000.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 public override PhysicsVector Size
{ {
get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); } 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 _velocity;
private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f,0.0f,0.0f); 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_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f);
private PhysicsVector m_rotationalVelocity;
private PhysicsVector _size; private PhysicsVector _size;
private PhysicsVector _acceleration; private PhysicsVector _acceleration;
public Quaternion _orientation; public Quaternion _orientation;
@ -887,6 +893,7 @@ namespace OpenSim.Region.Physics.OdePlugin
_position = pos; _position = pos;
_size = size; _size = size;
_acceleration = new PhysicsVector(); _acceleration = new PhysicsVector();
m_rotationalVelocity = PhysicsVector.Zero;
_orientation = rotation; _orientation = rotation;
_mesh = mesh; _mesh = mesh;
_pbs = pbs; _pbs = pbs;
@ -1226,6 +1233,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
} }
public override PhysicsVector RotationalVelocity
{
get{ return m_rotationalVelocity;}
set { m_rotationalVelocity = value; }
}
public void UpdatePositionAndVelocity() { public void UpdatePositionAndVelocity() {
// no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
@ -1234,6 +1246,8 @@ namespace OpenSim.Region.Physics.OdePlugin
d.Vector3 vec = d.BodyGetPosition(Body); d.Vector3 vec = d.BodyGetPosition(Body);
d.Quaternion ori = d.BodyGetQuaternion(Body); d.Quaternion ori = d.BodyGetQuaternion(Body);
d.Vector3 vel = d.BodyGetLinearVel(Body); d.Vector3 vel = d.BodyGetLinearVel(Body);
d.Vector3 rotvel = d.BodyGetAngularVel(Body);
PhysicsVector l_position = new PhysicsVector(); PhysicsVector l_position = new PhysicsVector();
// kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) // 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; if (vec.X < 0.0f) vec.X = 0.0f;
@ -1271,6 +1285,9 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity.X = 0; _velocity.X = 0;
_velocity.Y = 0; _velocity.Y = 0;
_velocity.Z = 0; _velocity.Z = 0;
m_rotationalVelocity.X = 0;
m_rotationalVelocity.Y = 0;
m_rotationalVelocity.Z = 0;
_zeroFlag = true; _zeroFlag = true;
} }
@ -1293,11 +1310,13 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity.X = 0.0f; _velocity.X = 0.0f;
_velocity.Y = 0.0f; _velocity.Y = 0.0f;
_velocity.Z = 0.0f; _velocity.Z = 0.0f;
_orientation.w = 0f; //_orientation.w = 0f;
_orientation.x = 0f; //_orientation.x = 0f;
_orientation.y = 0f; //_orientation.y = 0f;
_orientation.z = 0f; //_orientation.z = 0f;
m_rotationalVelocity.X = 0;
m_rotationalVelocity.Y = 0;
m_rotationalVelocity.Z = 0;
} }
else else
@ -1310,6 +1329,10 @@ namespace OpenSim.Region.Physics.OdePlugin
_velocity.Y = vel.Y; _velocity.Y = vel.Y;
_velocity.Z = vel.Z; _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.w = ori.W;
_orientation.x = ori.X; _orientation.x = ori.X;
_orientation.y = ori.Y; _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) public override void SetMomentum(PhysicsVector momentum)

View File

@ -184,6 +184,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
{ {
private PhysicsVector _position; private PhysicsVector _position;
private PhysicsVector _velocity; private PhysicsVector _velocity;
private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero;
private PhysicsVector _acceleration; private PhysicsVector _acceleration;
private NxCharacter _character; private NxCharacter _character;
private bool flying; private bool flying;
@ -214,7 +215,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin
get { return iscolliding; } get { return iscolliding; }
set { iscolliding = value; } set { iscolliding = value; }
} }
public override PhysicsVector RotationalVelocity
{
get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; }
}
public override PhysicsVector Position public override PhysicsVector Position
{ {
get { return _position; } get { return _position; }
@ -314,6 +319,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
private PhysicsVector _position; private PhysicsVector _position;
private PhysicsVector _velocity; private PhysicsVector _velocity;
private PhysicsVector _acceleration; private PhysicsVector _acceleration;
private PhysicsVector m_rotationalVelocity;
private NxActor _prim; private NxActor _prim;
public PhysXPrim(NxActor prim) public PhysXPrim(NxActor prim)
@ -329,7 +335,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin
get { return false; } get { return false; }
set { return; } set { return; }
} }
public override PhysicsVector RotationalVelocity
{
get { return m_rotationalVelocity; }
set { m_rotationalVelocity = value; }
}
public override bool Flying public override bool Flying
{ {
get { return false; //no flying prims for you get { return false; //no flying prims for you